a boatload of minor and middle-sized changes to try to speed up undo. imperfect,...
[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 <libgnomecanvas/libgnomecanvas.h>
26 #include <sigc++/signal.h>
27 #include <list>
28
29 #include "canvas.h"
30 #include "enums.h"
31 #include "time_axis_view_item.h"
32 #include "marker_view.h"
33
34 class ImageFrameTimeAxis;
35 class ImageFrameTimeAxisGroup ;
36
37 /**
38  * An ImageFrameItem to display an image upon the ardour time line
39  *
40  */
41 class ImageFrameView : public TimeAxisViewItem
42 {
43         public:
44                 //---------------------------------------------------------------------------------------//
45                 // Constructor / Desctructor
46
47                 /**
48                  * Constructs a new ImageFrameView upon the canvas
49                  *
50                  * @param item_id unique id of this item
51                  * @param parent the parent canvas item
52                  * @param tv the time axis view that this item is to be placed upon
53                  * @param group the ImageFrameGroup that this item is a member of
54                  * @param spu the current samples per canvas unit
55                  * @param start the start frame ogf this item
56                  * @param duration the duration of this item
57                  * @param rgb_data the rgb data of the image
58                  * @param width the width of the original rgb_data image data
59                  * @param height the width of the origianl rgb_data image data
60                  * @param num_channels the number of color channels within rgb_data
61                  */
62                 ImageFrameView(const std::string & item_id,
63                          ArdourCanvas::Group *parent,
64                         ImageFrameTimeAxis *tv,
65                         ImageFrameTimeAxisGroup* group,
66                         double spu,
67                         Gdk::Color& base_color,
68                         nframes_t start,
69                         nframes_t duration,
70                         unsigned char* rgb_data,
71                         uint32_t width,
72                         uint32_t height,
73                         uint32_t num_channels) ;
74
75                 /**
76                  * Destructor
77                  * Reposible for removing and destroying all marker items associated with this item
78                  */
79                 ~ImageFrameView() ;
80
81                 static PBD::Signal1<void,ImageFrameView*> CatchDeletion;
82
83                 //---------------------------------------------------------------------------------------//
84                 // Position and duration Accessors/Mutators
85
86                 /**
87                  * Set the position of this item to the specified value
88                  *
89                  * @param pos the new position
90                  * @param src the identity of the object that initiated the change
91                  * @return true if the position change was a success, false otherwise
92                  */
93                 virtual bool set_position(nframes64_t pos, void* src, double* delta = 0) ;
94
95                 /**
96                  * Sets the duration of this item
97                  *
98                  * @param dur the new duration of this item
99                  * @param src the identity of the object that initiated the change
100                  * @return true if the duration change was succesful, false otherwise
101                  */
102                 virtual bool set_duration(nframes64_t dur, void* src) ;
103
104                 //---------------------------------------------------------------------------------------//
105                 // Parent Component Methods
106
107                 /**
108                  * Sets the parent ImageFrameTimeAxisGroup of thie item
109                  * each Item must be part of exactly one group (or 'scene') upon the timeline
110                  *
111                  * @param group the new parent group
112                  */
113                 void set_time_axis_group(ImageFrameTimeAxisGroup* group) ;
114
115                 /**
116                  * Returns the parent group of this item
117                  *
118                  * @return the parent group of this item
119                  */
120                 ImageFrameTimeAxisGroup* get_time_axis_group() ;
121
122                 //---------------------------------------------------------------------------------------//
123                 // ui methods
124
125                 /**
126                  * Set the height of this item
127                  *
128                  * @param h the new height
129                  */
130                 virtual void set_height(gdouble h) ;
131
132
133                 //---------------------------------------------------------------------------------------//
134                 // MarkerView methods
135
136                 /**
137                  * Adds a markerView to the list of marker views associated with this item
138                  *
139                  * @param item the marker item to add
140                  * @param src the identity of the object that initiated the change
141                  */
142                 void add_marker_view_item(MarkerView* item, void* src) ;
143
144                 /**
145                  * Removes the named marker view from the list of marker view associated with this item
146                  * The Marker view is not destroyed on removal, so the caller must handle the item themself
147                  *
148                  * @param markId the id/name of the item to remove
149                  * @param src the identity of the object that initiated the change
150                  * @return the removed marker item
151                  */
152                 MarkerView* remove_named_marker_view_item(const std::string & markId, void* src) ;
153
154                 /**
155                  * Removes item from the list of marker views assocaited with this item
156                  * This method will do nothing if item if not assiciated with this item
157                  * The Marker view is not destroyed on removal, so the caller must handle the item themself
158                  *
159                  * @param item the item to remove
160                  * @param src the identity of the object that initiated the change
161                  */
162                 void remove_marker_view_item(MarkerView* item, void* src) ;
163
164                 /**
165                  * Determines if the named marker is one of those associated with this item
166                  *
167                  * @param markId the id/name of the item to search for
168                  */
169                 bool has_marker_view_item(const std::string & markId) ;
170
171
172                 //---------------------------------------------------------------------------------//
173                 // Emitted Signals
174
175                 /** Emitted when a marker Item is added to this Item */
176                 sigc::signal<void,MarkerView*,void*> MarkerViewAdded ;
177
178                 /** Emitted when a Marker Item is added to this Item */
179                 sigc::signal<void,MarkerView*,void*> MarkerViewRemoved ;
180
181         private:
182                 /** the list of MarkerViews associated with this item */
183                 typedef std::list<MarkerView*> MarkerViewList ;
184                 MarkerViewList marker_view_list ;
185
186
187                 /** The parent group that this item is a member of */
188                 ImageFrameTimeAxisGroup* the_parent_group ;
189
190                 // ------- Image data -----------
191
192                 /** the image data that we display */
193                 //unsigned char* the_rgb_data ;
194
195                 /** The width of the image contained within the_rgb_data */
196                 uint32_t image_data_width ;
197
198                 /** The height of the image contained within the_rgb_data */
199                 uint32_t image_data_height ;
200
201                 /** the number of channels contained in the_rgb_data */
202                 uint32_t image_data_num_channels ;
203
204
205                 // ------- Our canvas element -----------
206
207                 /** the CanvasImageFrame to display the image */
208                 ArdourCanvas::ImageFrame* imageframe ;
209
210 } ; /* class ImageFrameView */
211
212 #endif /* __gtk_ardour_imageframe_view_h__ */