2 Copyright (C) 2003 Paul Davis
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.
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.
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.
21 #ifndef __ardour_imageframe_time_axis_group_h__
22 #define __ardour_imageframe_time_axis_group_h__
27 #include <gdkmm/color.h>
29 #include <libgnomecanvas/libgnomecanvas.h>
30 #include <jack/jack.h>
31 #include <ardour/types.h>
32 #include "imageframe_time_axis_view.h"
35 class ImageFrameView ;
38 * ImageFrameTimeAxisGroup defines a group/scene of ImageFrame view that can appear upon a time axis
39 * At the moment this is a bit bare, we really want to add some kind of time constraints upon
40 * items atht are added to the group, ie bounded by the start and end of the scene, which itself
42 * A viewable object may also be useful...
45 class ImageFrameTimeAxisGroup : public sigc::trackable
48 //---------------------------------------------------------------------------------------//
49 // Constructor / Desctructor
52 * Constructs a new ImageFrameTimeAxisGroup.
54 * @param iftav the parent ImageFrameTimeAxis of this view helper
55 * @param group_id the unique name/id of this group
57 ImageFrameTimeAxisGroup(ImageFrameTimeAxisView& iftav, const string & group_id) ;
61 * Responsible for destroying any Items that may have been added to this group
64 virtual ~ImageFrameTimeAxisGroup() ;
67 //---------------------------------------------------------------------------------------//
68 // Name/Id Accessors/Mutators
71 * Set the name/Id of this group.
73 * @param new_name the new name of this group
74 * @param src the identity of the object that initiated the change
76 void set_group_name(const string & new_name, void* src) ;
79 * Returns the id of this group
80 * The group id must be unique upon a time axis
82 * @return the id of this group
84 std::string get_group_name() const ;
87 //---------------------------------------------------------------------------------------//
88 // Parent/Child helper object accessors
91 * Returns the TimeAxisView thatt his object is acting as a helper for
93 * @return the TimeAxisView that this object is acting as a view helper for
95 ImageFrameTimeAxisView& get_view() const { return _view_helper ; }
99 //---------------------------------------------------------------------------------------//
103 * Sets the height of the time axis view and the item upon it
105 * @param height the new height
107 int set_item_heights(gdouble) ;
110 * Sets the current samples per unit.
111 * this method tells each item upon the time axis of the change
113 * @param spu the new samples per canvas unit value
115 int set_item_samples_per_units(gdouble spu) ;
118 * Sets the color of the items contained uopn this view helper
120 * @param color the new base color
122 void apply_item_color(Gdk::Color&) ;
125 //---------------------------------------------------------------------------------------//
126 // child ImageFrameView methods
129 * Adds an ImageFrameView to the list of items upon this time axis view helper
130 * the new ImageFrameView is returned
132 * @param item_id the unique id of the new item
133 * @param image_id the id/name of the image data we are usin
134 * @param start the position the new item should be placed upon the time line
135 * @param duration the duration the new item should be placed upon the timeline
136 * @param rgb_data the rgb data of the image
137 * @param width the original image width of the rgb_data (not the size to display)
138 * @param height the irigianl height of the rgb_data
139 * @param num_channels the number of channles within the rgb_data
140 * @param src the identity of the object that initiated the change
142 ImageFrameView* add_imageframe_item(const string & item_id, nframes_t start, nframes_t duration, unsigned char* rgb_data, uint32_t width, uint32_t height, uint32_t num_channels, void* src) ;
145 * Returns the named ImageFrameView or 0 if the named view does not exist on this view helper
147 * @param item_id the unique id of the item to search for
148 * @return the named ImageFrameView, or 0 if it is not held upon this view
150 ImageFrameView* get_named_imageframe_item(const string & item_id) ;
153 * Removes the currently selected ImageFrameView
155 * @param src the identity of the object that initiated the change
156 * @see add_imageframe_view
158 void remove_selected_imageframe_item(void* src) ;
161 * Removes and returns the named ImageFrameView from the list of ImageFrameViews held by this view helper
163 * @param item_id the ImageFrameView unique id to remove
164 * @param src the identity of the object that initiated the change
165 * @see add_imageframe_view
167 ImageFrameView* remove_named_imageframe_item(const string & item_id, void* src) ;
170 * Removes ifv from the list of ImageFrameViews upon this TimeAxis.
171 * if ifv is not upon this TimeAxis, this method takes no action
173 * @param ifv the ImageFrameView to remove
175 void remove_imageframe_item(ImageFrameView*, void* src) ;
178 //---------------------------------------------------------------------------------------//
179 // Selected group methods
182 // removed in favour of a track level selectewd item
183 // this is simply easier to manage a singularly selected item, rather than
184 // a selected item within each group
187 * Sets the currently selected item upon this time axis
189 * @param ifv the item to set selected
191 //void set_selected_imageframe_item(ImageFrameView* ifv) ;
194 * Sets the currently selected item upon this time axis to the named item
196 * @param item_id the name/id of the item to set selected
198 //void set_selected_imageframe_item(std::string item_id) ;
201 * Returns the currently selected item upon this time axis
203 * @return the currently selected item pon this time axis
205 //ImageFrameView* get_selected_imageframe_item() ;
208 * Returns whether this grou pis currently selected
210 * @returns true if this group is currently selected
212 bool get_selected() const ;
215 * Sets he selected state of this group
217 * @param yn set true if this group is selected, false otherwise
219 void set_selected(bool yn) ;
221 //---------------------------------------------------------------------------------------//
222 // Handle group removal
225 * Handles the Removal of this VisualTimeAxis
226 * This _needs_ to be called to alert others of the removal properly, ie where the source
227 * of the removal came from.
229 * XXX Although im not too happy about this method of doing things, I cant think of a cleaner method
230 * just now to capture the source of the removal
232 * @param src the identity of the object that initiated the change
234 virtual void remove_this_group(void* src) ;
236 //---------------------------------------------------------------------------------//
239 sigc::signal<void> GoingAway ;
242 * Emitted when this Group has been removed
243 * This is different to the GoingAway signal in that this signal
244 * is emitted during the deletion of this Time Axis, and not during
245 * the destructor, this allows us to capture the source of the deletion
248 sigc::signal<void,std::string,void*> GroupRemoved ;
250 /** Emitted when we have changed the name of this TimeAxis */
251 sigc::signal<void,std::string,std::string,void*> NameChanged ;
253 /** Emitted when an ImageFrameView is added to this group */
254 sigc::signal<void, ImageFrameView*, void*> ImageFrameAdded ;
256 /** Emitted when an ImageFrameView is removed from this group */
257 sigc::signal<void, const string &, const string &, const string &, void*> ImageFrameRemoved ;
264 * convenience method to re-get the samples per unit and tell items upon this view
267 void reset_samples_per_unit() ;
270 * Callback used to remove this group during the gtk idle loop
271 * This is used to avoid deleting the obejct while inside the remove_this_group
274 * @param group the ImageFrameTimeAxisGroup to remove
275 * @param src the identity of the object that initiated the change
277 static gint idle_remove_this_group(ImageFrameTimeAxisGroup* group, void* src) ;
279 /** The list of ImageFrameViews held by this view helper */
280 typedef std::list<ImageFrameView *> ImageFrameViewList ;
281 ImageFrameViewList imageframe_views ;
283 /** the currently selected time axis item upon this time axis */
284 ImageFrameView* selected_imageframe_item ;
286 /** the view helper that this object is acting as a container upon on */
287 ImageFrameTimeAxisView& _view_helper ;
289 /** the is of this group */
290 std::string _group_id ;
292 /* XXX why are these different? */
293 Gdk::Color region_color ;
294 uint32_t stream_base_color ;
296 /** indicates if this group is currently selected */
299 } ; /* class ImageFrameTimeAxisGroup */
301 #endif /* __ardour_imageframe_time_axis_group_h__ */