Merge branch 'master' into cairocanvas
[ardour.git] / gtk2_ardour / imageframe_time_axis_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 __ardour_imageframe_time_axis_view_h__
21 #define __ardour_imageframe_time_axis_view_h__
22
23 #include <list>
24 #include <cmath>
25
26 #include <gdkmm/color.h>
27
28 #include <jack/jack.h>
29
30
31
32 class PublicEditor ;
33 class ImageFrameTimeAxis ;
34 class ImageFrameView ;
35 class ImageFrameTimeAxisGroup ;
36
37 /**
38  * ImageFrameTimeAxisView defines the time axis view helper
39  * This object is responsible for the time axis canvas view, and
40  * maintains the list of items that have been added to it
41  *
42  */
43 class ImageFrameTimeAxisView : public sigc::trackable
44 {
45         public:
46                 //---------------------------------------------------------------------------------------//
47                 // Constructor / Desctructor
48
49                 /**
50                  * Constructs a new ImageFrameTimeAxisView.
51                  *
52                  * @param ifta the parent ImageFrameTimeAxis of this view helper
53                  */
54                 ImageFrameTimeAxisView(ImageFrameTimeAxis& ifta) ;
55
56                 /**
57                  * Destructor
58                  * Responsible for destroying all items tat may have been added to this time axis
59                  */
60                 ~ImageFrameTimeAxisView () ;
61
62                 //---------------------------------------------------------------------------------------//
63                 // Parent/Child helper object accessors
64
65                 /**
66                  * Returns the TimeAxisView thatt his object is acting as a helper for
67                  *
68                  * @return the TimeAxisView that this object is acting as a view helper for
69                  */
70                 ImageFrameTimeAxis& trackview() { return _trackview; }
71
72                 /**
73                  *
74                  */
75                 ArdourCanvas::Group * canvas_item() { return &canvas_group; }
76
77
78                 //---------------------------------------------------------------------------------------//
79                 // ui methods & data
80
81                 /**
82                  * Sets the height of the time axis view and the item upon it
83                  *
84                  * @param height the new height
85                  */
86                 int set_height(gdouble) ;
87
88                 /**
89                  * Sets the position of this view helper on the canvas
90                  *
91                  * @param x the x position upon the canvas
92                  * @param y the y position upon the canvas
93                  */
94                 int set_position(gdouble x, gdouble y) ;
95
96                 int set_frames_per_pixel (double);
97                 double get_frames_per_pixel () { return _frames_per_pixel; }
98
99                 /**
100                  * Sets the color of the items contained uopn this view helper
101                  *
102                  * @param color the new base color
103                  */
104                 void apply_color (Gdk::Color&) ;
105
106                 //---------------------------------------------------------------------------------------//
107                 // Child ImageFrameTimeAxisGroup Accessors/Mutators
108
109                 /**
110                  * Adds an ImageFrameTimeAxisGroup to the list of items upon this time axis view helper
111                  * the new ImageFrameTimeAxisGroup is returned
112                  *
113                  * @param group_id the unique id of the new group
114                  * @param src the identity of the object that initiated the change
115                  */
116                 ImageFrameTimeAxisGroup* add_imageframe_group(std::string group_id, void* src) ;
117
118                 /**
119                  * Returns the named ImageFrameTimeAxisGroup or 0 if the named group does not exist on this view helper
120                  *
121                  * @param group_id the unique id of the group to search for
122                  * @return the named ImageFrameTimeAxisGroup, or 0 if it is not held upon this view
123                  */
124                 ImageFrameTimeAxisGroup* get_named_imageframe_group(std::string group_id) ;
125
126                 /**
127                  * Removes and returns the named ImageFrameTimeAxisGroup from the list of ImageFrameTimeAxisGroup held by this view helper
128                  *
129                  * @param group_id the ImageFrameTimeAxisGroup unique id to remove
130                  * @param src the identity of the object that initiated the change
131                  * @see add_imageframe_group
132                  */
133                 ImageFrameTimeAxisGroup* remove_named_imageframe_group(std::string group_id, void* src) ;
134
135                 /**
136                  * Removes the specified ImageFrameTimeAxisGroup from the list of ImageFrameTimeAxisGroups upon this TimeAxis.
137                  *
138                  * @param iftag the ImageFrameView to remove
139                  */
140                 void remove_imageframe_group(ImageFrameTimeAxisGroup* iftag, void* src) ;
141
142
143                 //---------------------------------------------------------------------------------------//
144                 // Selected group methods
145
146                 /**
147                  * Sets the currently selected group upon this time axis
148                  *
149                  * @param ifv the item to set selected
150                  */
151                 void set_selected_imageframe_group(ImageFrameTimeAxisGroup* iftag) ;
152
153                 /**
154                  * Clears the currently selected image frame group unpo this time axis
155                  *
156                  */
157                 void clear_selected_imageframe_group() ;
158
159                 /**
160                  * Returns the currently selected group upon this time axis
161                  *
162                  * @return the currently selected group upon this time axis
163                  */
164                 ImageFrameTimeAxisGroup* get_selected_imageframe_group() const ;
165
166
167                 /**
168                  * Sets the duration of the selected ImageFrameView to the specified number of seconds
169                  *
170                  * @param sec the duration to set the ImageFrameView to, in seconds
171                  */
172                 void set_imageframe_duration_sec(double sec) ;
173
174                 //---------------------------------------------------------------------------------------//
175                 // Selected item methods
176
177                 /**
178                  * Sets the currently selected image frame view item
179                  *
180                  * @param iftag the group the selected item is part
181                  * @param ifv the selected item
182                  */
183                 void set_selected_imageframe_view(ImageFrameTimeAxisGroup* iftag, ImageFrameView* ifv) ;
184
185                 /**
186                  * Clears the currently selected image frame view item
187                  *
188                  * @param clear_group set true if the selected parent group of the item should be cleared also
189                  */
190                 void clear_selected_imageframe_item(bool clear_group) ;
191
192                 /**
193                  * Returns the currently selected image frame view item upon this time axis
194                  *
195                  * @return the currently selected image frame view item
196                  */
197                 ImageFrameView* get_selected_imageframe_view() const ;
198
199
200
201                 /**
202                  * Removes the currently selected ImageFrameTimeAxisGroup
203                  *
204                  * @param src the identity of the object that initiated the change
205                  * @see add_imageframe_group
206                  */
207                 void remove_selected_imageframe_item(void* src) ;
208
209
210                 //---------------------------------------------------------------------------------//
211                 // Emitted Signals
212
213                 /** Emitted when and ImageFrameGroup is added to this time axis */
214                 sigc::signal<void,ImageFrameTimeAxisGroup*,void*> ImageFrameGroupAdded ;
215
216                 /** Emitted when an ImageFrameGroup is removed from this time axis */
217                 sigc::signal<void,std::string,void*> ImageFrameGroupRemoved ;
218
219         protected:
220
221
222         private:
223                 /**
224                  * convenience method to re-get the samples per unit and tell items upon this view
225                  */
226                 void reset_frames_per_pixel ();
227
228                 /**
229                  * The list of ImageFrameViews held by this view helper */
230                 typedef std::list<ImageFrameTimeAxisGroup *> ImageFrameGroupList ;
231                 ImageFrameGroupList imageframe_groups ;
232
233                 /** the currently selected time axis item upon this time axis */
234                 ImageFrameTimeAxisGroup* selected_imageframe_group ;
235
236                 /**
237                  * thecurrently selected image frame view
238                  * we keep this here so that we only have one per view, not one per group
239                  */
240                 ImageFrameView* selected_imageframe_view ;
241
242
243
244                 /* the TimeAxisView that this object is acting as the view helper for */
245                 ImageFrameTimeAxis& _trackview ;
246
247                 ArdourCanvas::Group       canvas_group ;
248                 ArdourCanvas::Rectangle  canvas_rect; /* frame around the whole thing */
249
250                 /** the current frames per pixel */
251                 double _frames_per_pixel;
252
253                 /* XXX why are these different? */
254                 Gdk::Color region_color ;
255                 uint32_t stream_base_color ;
256
257 } ; /* class ImageFrameTimeAxisView */
258
259 #endif /* __ardour_imageframe_time_axis_view_h__ */