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_marker_time_axis_view_h__
22 #define __ardour_marker_time_axis_view_h__
27 #include <libgnomecanvasmm/group.h>
29 #include <ardour/location.h>
30 #include "simplerect.h"
35 class ImageFrameView ;
38 class TimeAxisViewItem ;
41 * A view helper for handling MarkerView objects.
42 * This object is responsible for the time axis canvas view, and
43 * maintains the list of items that have been added to it
45 class MarkerTimeAxisView : public sigc::trackable
48 //---------------------------------------------------------------------------------------//
49 // Constructor / Desctructor
52 * Construct a new MarkerTimeAxisView helper time axis helper
54 * @param mta the TimeAxsiView that this objbect is the helper for
56 MarkerTimeAxisView(MarkerTimeAxis& mta) ;
60 * Reposinsibly for destroying all marker items that may have been added to this time axis view
63 ~MarkerTimeAxisView () ;
65 //---------------------------------------------------------------------------------------//
66 // Parent/Child helper object accessors
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 MarkerTimeAxis& trackview() { return _trackview; }
78 ArdourCanvas::Item *canvas_item() { return canvas_group; }
81 //---------------------------------------------------------------------------------------//
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 height) ;
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) ;
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 upon this view helper
117 * @param color the new base color
119 void apply_color(Gdk::Color& color) ;
121 //---------------------------------------------------------------------------------------//
122 // Child MarkerView Accessors/Mutators
125 * Adds a marker view to the list of items upon this time axis view helper
126 * the new MarkerView is returned
128 * @param ifv the ImageFrameView that the new item is marking up
129 * @param mark_text the text to be displayed uopn the new marker item
130 * @param mark_id the unique id of the new item
131 * @param start the position the new item should be placed upon the time line
132 * @param duration the duration the new item should be placed upon the timeline
133 * @param src the identity of the object that initiated the change
135 MarkerView* add_marker_view(ImageFrameView* ifv, std::string mark_type, std::string mark_id, jack_nframes_t start, jack_nframes_t dur, void* src) ;
138 * Returns the named MarkerView or 0 if the named marker does not exist
140 * @param item_id the unique id of the item to search for
141 * @return the named MarkerView, or 0 if it is not held upon this view
143 MarkerView* get_named_marker_view(std::string item_id) ;
146 * Removes the currently selected MarverView
147 * Note that this method actually destroys the MarkerView too.
148 * We assume that since we own the object, we are allowed to do this
150 * @param src the identity of the object that initiated the change
151 * @see add_marker_view
153 void remove_selected_marker_view(void* src) ;
156 * Removes and returns the named MarkerView from the list of MarkerView held by this view helper
158 * @param item_id the MarkerView unique id to remove
159 * @param src the identity of the object that initiated the change
160 * @see add_marker_view
162 MarkerView* remove_named_marker_view(std::string item_id, void* src) ;
165 * Removes mv from the list of MarkerView upon this TimeAxis
167 * @param mv the MarkerView to remove
168 * @param src the identity of the object that initiated the change
170 void remove_marker_view(MarkerView* item, void* src) ;
172 //---------------------------------------------------------------------------------------//
173 // Selected item methods
176 * Sets the currently selected item upon this time axis
178 * @param mv the item to set selected
180 void set_selected_time_axis_item(MarkerView* mv) ;
183 * Clears any selected item upon this time axis
186 void clear_selected_time_axis_item() ;
189 * Returnsthe currently selected item upon this time axis
191 * @return the currently selected item pon this time axis
193 MarkerView* get_selected_time_axis_item() ;
197 * Sets the duration of the selected MarkerView to the specified number of seconds
199 * @param sec the duration to set the MArkerView to, in seconds
201 void set_marker_duration_sec(double sec) ;
203 //---------------------------------------------------------------------------------//
206 /** Emitted when a MarkerView is Added */
207 sigc::signal<void,MarkerView*,void*> MarkerViewAdded ;
209 /** Emitted when a MarkerView Item is removed */
210 sigc::signal<void,std::string,void*> MarkerViewRemoved ;
214 * convenience method to re-get the samples per unit and tell items upon this view
217 void reset_samples_per_unit() ;
219 /** The list of items held by this time axis view helper */
220 typedef std::list<MarkerView *> MarkerViewList ;
221 MarkerViewList marker_view_list;
223 /** the currently selected time axis item upon this time axis */
224 MarkerView* selected_time_axis_item ;
226 /* the TimeAxisView that this object is acting as the view helper for */
227 MarkerTimeAxis& _trackview ;
229 ArdourCanvas::Group *canvas_group ;
230 ArdourCanvas::SimpleRect *canvas_rect ; /* frame around the whole thing */
232 /** the current samples per unit */
233 double _samples_per_unit;
235 /* XXX why are these different? */
236 Gdk::Color region_color;
237 uint32_t stream_base_color;
239 }; /* class MarkerTimeAxisView */
241 #endif /* __ardour_marker_time_axis_view_h__ */