tweaks to improve enter/leave event handling - fixes at least some crashes caused...
[ardour.git] / gtk2_ardour / imageframe_view.h
1 /*
2     Copyright (C) 2003 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __gtk_ardour_imageframe_view_h__
21 #define __gtk_ardour_imageframe_view_h__
22
23 #include <string>
24 #include <gdkmm/color.h>
25 #include <sigc++/signal.h>
26 #include <list>
27
28 #include "enums.h"
29 #include "time_axis_view_item.h"
30 #include "marker_view.h"
31
32 class ImageFrameTimeAxis;
33 class ImageFrameTimeAxisGroup ;
34
35 /**
36  * An ImageFrameItem to display an image upon the ardour time line
37  *
38  */
39 class ImageFrameView : public TimeAxisViewItem
40 {
41         public:
42                 //---------------------------------------------------------------------------------------//
43                 // Constructor / Desctructor
44
45                 /**
46                  * Constructs a new ImageFrameView upon the canvas
47                  *
48                  * @param item_id unique id of this item
49                  * @param parent the parent canvas item
50                  * @param tv the time axis view that this item is to be placed upon
51                  * @param group the ImageFrameGroup that this item is a member of
52                  * @param spu the current samples per canvas unit
53                  * @param start the start frame ogf this item
54                  * @param duration the duration of this item
55                  * @param rgb_data the rgb data of the image
56                  * @param width the width of the original rgb_data image data
57                  * @param height the width of the origianl rgb_data image data
58                  * @param num_channels the number of color channels within rgb_data
59                  */
60                 ImageFrameView(const std::string & item_id,
61                          ArdourCanvas::Group *parent,
62                         ImageFrameTimeAxis *tv,
63                         ImageFrameTimeAxisGroup* group,
64                         double spu,
65                         Gdk::Color& base_color,
66                         framepos_t start,
67                         framecnt_t duration,
68                         unsigned char* rgb_data,
69                         uint32_t width,
70                         uint32_t height,
71                         uint32_t num_channels) ;
72
73                 /**
74                  * Destructor
75                  * Reposible for removing and destroying all marker items associated with this item
76                  */
77                 ~ImageFrameView() ;
78
79                 static PBD::Signal1<void,ImageFrameView*> CatchDeletion;
80
81                 //---------------------------------------------------------------------------------------//
82                 // Position and duration Accessors/Mutators
83
84                 /**
85                  * Set the position of this item to the specified value
86                  *
87                  * @param pos the new position
88                  * @param src the identity of the object that initiated the change
89                  * @return true if the position change was a success, false otherwise
90                  */
91                 virtual bool set_position(framepos_t pos, void* src, double* delta = 0) ;
92
93                 /**
94                  * Sets the duration of this item
95                  *
96                  * @param dur the new duration of this item
97                  * @param src the identity of the object that initiated the change
98                  * @return true if the duration change was succesful, false otherwise
99                  */
100                 virtual bool set_duration(framepos_t dur, void* src) ;
101
102                 //---------------------------------------------------------------------------------------//
103                 // Parent Component Methods
104
105                 /**
106                  * Sets the parent ImageFrameTimeAxisGroup of thie item
107                  * each Item must be part of exactly one group (or 'scene') upon the timeline
108                  *
109                  * @param group the new parent group
110                  */
111                 void set_time_axis_group(ImageFrameTimeAxisGroup* group) ;
112
113                 /**
114                  * Returns the parent group of this item
115                  *
116                  * @return the parent group of this item
117                  */
118                 ImageFrameTimeAxisGroup* get_time_axis_group() ;
119
120                 //---------------------------------------------------------------------------------------//
121                 // ui methods
122
123                 /**
124                  * Set the height of this item
125                  *
126                  * @param h the new height
127                  */
128                 virtual void set_height(gdouble h) ;
129
130
131                 //---------------------------------------------------------------------------------------//
132                 // MarkerView methods
133
134                 /**
135                  * Adds a markerView to the list of marker views associated with this item
136                  *
137                  * @param item the marker item to add
138                  * @param src the identity of the object that initiated the change
139                  */
140                 void add_marker_view_item(MarkerView* item, void* src) ;
141
142                 /**
143                  * Removes the named marker view from the list of marker view associated with this item
144                  * The Marker view is not destroyed on removal, so the caller must handle the item themself
145                  *
146                  * @param markId the id/name of the item to remove
147                  * @param src the identity of the object that initiated the change
148                  * @return the removed marker item
149                  */
150                 MarkerView* remove_named_marker_view_item(const std::string & markId, void* src) ;
151
152                 /**
153                  * Removes item from the list of marker views assocaited with this item
154                  * This method will do nothing if item if not assiciated with this item
155                  * The Marker view is not destroyed on removal, so the caller must handle the item themself
156                  *
157                  * @param item the item to remove
158                  * @param src the identity of the object that initiated the change
159                  */
160                 void remove_marker_view_item(MarkerView* item, void* src) ;
161
162                 /**
163                  * Determines if the named marker is one of those associated with this item
164                  *
165                  * @param markId the id/name of the item to search for
166                  */
167                 bool has_marker_view_item(const std::string & markId) ;
168
169
170                 //---------------------------------------------------------------------------------//
171                 // Emitted Signals
172
173                 /** Emitted when a marker Item is added to this Item */
174                 sigc::signal<void,MarkerView*,void*> MarkerViewAdded ;
175
176                 /** Emitted when a Marker Item is added to this Item */
177                 sigc::signal<void,MarkerView*,void*> MarkerViewRemoved ;
178
179         private:
180                 /** the list of MarkerViews associated with this item */
181                 typedef std::list<MarkerView*> MarkerViewList ;
182                 MarkerViewList marker_view_list ;
183
184
185                 /** The parent group that this item is a member of */
186                 ImageFrameTimeAxisGroup* the_parent_group ;
187
188                 // ------- Image data -----------
189
190                 /** the image data that we display */
191                 //unsigned char* the_rgb_data ;
192
193                 /** The width of the image contained within the_rgb_data */
194                 uint32_t image_data_width ;
195
196                 /** The height of the image contained within the_rgb_data */
197                 uint32_t image_data_height ;
198
199                 /** the number of channels contained in the_rgb_data */
200                 uint32_t image_data_num_channels ;
201
202
203                 // ------- Our canvas element -----------
204
205                 /** the CanvasImageFrame to display the image */
206                 ArdourCanvas::ImageFrame* imageframe ;
207
208 } ; /* class ImageFrameView */
209
210 #endif /* __gtk_ardour_imageframe_view_h__ */