use entered track for fit-tracks if in internal edit mode and no tracks or regions...
[ardour2.git] / gtk2_ardour / imageframe_time_axis_view.h
blob1191068c1d1f3143bc7336daefd8e211955fa574
1 /*
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.
20 #ifndef __ardour_imageframe_time_axis_view_h__
21 #define __ardour_imageframe_time_axis_view_h__
23 #include <list>
24 #include <cmath>
26 #include <gdkmm/color.h>
28 #include <jack/jack.h>
30 #include <libgnomecanvasmm.h>
31 #include "canvas.h"
32 #include "simplerect.h"
35 class PublicEditor ;
36 class ImageFrameTimeAxis ;
37 class ImageFrameView ;
38 class ImageFrameTimeAxisGroup ;
40 /**
41 * ImageFrameTimeAxisView defines the time axis view helper
42 * This object is responsible for the time axis canvas view, and
43 * maintains the list of items that have been added to it
46 class ImageFrameTimeAxisView : public sigc::trackable
48 public:
49 //---------------------------------------------------------------------------------------//
50 // Constructor / Desctructor
52 /**
53 * Constructs a new ImageFrameTimeAxisView.
55 * @param ifta the parent ImageFrameTimeAxis of this view helper
57 ImageFrameTimeAxisView(ImageFrameTimeAxis& ifta) ;
59 /**
60 * Destructor
61 * Responsible for destroying all items tat may have been added to this time axis
63 ~ImageFrameTimeAxisView () ;
65 //---------------------------------------------------------------------------------------//
66 // Parent/Child helper object accessors
68 /**
69 * Returns the TimeAxisView thatt his object is acting as a helper for
71 * @return the TimeAxisView that this object is acting as a view helper for
73 ImageFrameTimeAxis& trackview() { return _trackview; }
75 /**
78 ArdourCanvas::Group * canvas_item() { return &canvas_group; }
81 //---------------------------------------------------------------------------------------//
82 // ui methods & data
84 /**
85 * Sets the height of the time axis view and the item upon it
87 * @param height the new height
89 int set_height(gdouble) ;
91 /**
92 * Sets the position of this view helper on the canvas
94 * @param x the x position upon the canvas
95 * @param y the y position upon the canvas
97 int set_position(gdouble x, gdouble y) ;
99 /**
100 * Sets the current samples per unit.
101 * this method tells each item upon the time axis of the change
103 * @param spu the new samples per canvas unit value
105 int set_samples_per_unit(gdouble spu) ;
108 * Returns the current samples per unit of this time axis view helper
110 * @return the current samples per unit of this time axis view helper
112 gdouble get_samples_per_unit() { return _samples_per_unit; }
115 * Sets the color of the items contained uopn this view helper
117 * @param color the new base color
119 void apply_color (Gdk::Color&) ;
121 //---------------------------------------------------------------------------------------//
122 // Child ImageFrameTimeAxisGroup Accessors/Mutators
125 * Adds an ImageFrameTimeAxisGroup to the list of items upon this time axis view helper
126 * the new ImageFrameTimeAxisGroup is returned
128 * @param group_id the unique id of the new group
129 * @param src the identity of the object that initiated the change
131 ImageFrameTimeAxisGroup* add_imageframe_group(std::string group_id, void* src) ;
134 * Returns the named ImageFrameTimeAxisGroup or 0 if the named group does not exist on this view helper
136 * @param group_id the unique id of the group to search for
137 * @return the named ImageFrameTimeAxisGroup, or 0 if it is not held upon this view
139 ImageFrameTimeAxisGroup* get_named_imageframe_group(std::string group_id) ;
142 * Removes and returns the named ImageFrameTimeAxisGroup from the list of ImageFrameTimeAxisGroup held by this view helper
144 * @param group_id the ImageFrameTimeAxisGroup unique id to remove
145 * @param src the identity of the object that initiated the change
146 * @see add_imageframe_group
148 ImageFrameTimeAxisGroup* remove_named_imageframe_group(std::string group_id, void* src) ;
151 * Removes the specified ImageFrameTimeAxisGroup from the list of ImageFrameTimeAxisGroups upon this TimeAxis.
153 * @param iftag the ImageFrameView to remove
155 void remove_imageframe_group(ImageFrameTimeAxisGroup* iftag, void* src) ;
158 //---------------------------------------------------------------------------------------//
159 // Selected group methods
162 * Sets the currently selected group upon this time axis
164 * @param ifv the item to set selected
166 void set_selected_imageframe_group(ImageFrameTimeAxisGroup* iftag) ;
169 * Clears the currently selected image frame group unpo this time axis
172 void clear_selected_imageframe_group() ;
175 * Returns the currently selected group upon this time axis
177 * @return the currently selected group upon this time axis
179 ImageFrameTimeAxisGroup* get_selected_imageframe_group() const ;
183 * Sets the duration of the selected ImageFrameView to the specified number of seconds
185 * @param sec the duration to set the ImageFrameView to, in seconds
187 void set_imageframe_duration_sec(double sec) ;
189 //---------------------------------------------------------------------------------------//
190 // Selected item methods
193 * Sets the currently selected image frame view item
195 * @param iftag the group the selected item is part
196 * @param ifv the selected item
198 void set_selected_imageframe_view(ImageFrameTimeAxisGroup* iftag, ImageFrameView* ifv) ;
201 * Clears the currently selected image frame view item
203 * @param clear_group set true if the selected parent group of the item should be cleared also
205 void clear_selected_imageframe_item(bool clear_group) ;
208 * Returns the currently selected image frame view item upon this time axis
210 * @return the currently selected image frame view item
212 ImageFrameView* get_selected_imageframe_view() const ;
217 * Removes the currently selected ImageFrameTimeAxisGroup
219 * @param src the identity of the object that initiated the change
220 * @see add_imageframe_group
222 void remove_selected_imageframe_item(void* src) ;
225 //---------------------------------------------------------------------------------//
226 // Emitted Signals
228 /** Emitted when and ImageFrameGroup is added to this time axis */
229 sigc::signal<void,ImageFrameTimeAxisGroup*,void*> ImageFrameGroupAdded ;
231 /** Emitted when an ImageFrameGroup is removed from this time axis */
232 sigc::signal<void,std::string,void*> ImageFrameGroupRemoved ;
234 protected:
237 private:
239 * convenience method to re-get the samples per unit and tell items upon this view
242 void reset_samples_per_unit() ;
245 * The list of ImageFrameViews held by this view helper */
246 typedef std::list<ImageFrameTimeAxisGroup *> ImageFrameGroupList ;
247 ImageFrameGroupList imageframe_groups ;
249 /** the currently selected time axis item upon this time axis */
250 ImageFrameTimeAxisGroup* selected_imageframe_group ;
253 * thecurrently selected image frame view
254 * we keep this here so that we only have one per view, not one per group
256 ImageFrameView* selected_imageframe_view ;
260 /* the TimeAxisView that this object is acting as the view helper for */
261 ImageFrameTimeAxis& _trackview ;
263 ArdourCanvas::Group canvas_group ;
264 ArdourCanvas::SimpleRect canvas_rect; /* frame around the whole thing */
266 /** the current samples per unit */
267 double _samples_per_unit ;
269 /* XXX why are these different? */
270 Gdk::Color region_color ;
271 uint32_t stream_base_color ;
273 } ; /* class ImageFrameTimeAxisView */
275 #endif /* __ardour_imageframe_time_axis_view_h__ */