fix load+save of plugin parameter automation
[ardour.git] / gtk2_ardour / marker_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_marker_time_axis_view_h__
21 #define __ardour_marker_time_axis_view_h__
22
23 #include <list>
24 #include <gdkmm/color.h>
25 #include <libgnomecanvasmm/group.h>
26
27 #include "ardour/location.h"
28 #include "simplerect.h"
29 #include "canvas.h"
30
31 class PublicEditor;
32 class MarkerTimeAxis;
33 class ImageFrameView ;
34 class MarkerView ;
35 class TimeAxisView ;
36 class TimeAxisViewItem ;
37
38 /**
39  * A view helper for handling MarkerView objects.
40  * This object is responsible for the time axis canvas view, and
41  * maintains the list of items that have been added to it
42  */
43 class MarkerTimeAxisView : public sigc::trackable
44 {
45         public:
46                 //---------------------------------------------------------------------------------------//
47                 // Constructor / Desctructor
48
49                 /**
50                  * Construct a new MarkerTimeAxisView helper time axis helper
51                  *
52                  * @param mta the TimeAxsiView that this objbect is the helper for
53                  */
54                 MarkerTimeAxisView(MarkerTimeAxis& mta) ;
55
56                 /**
57                  * Destructor
58                  * Reposinsibly for destroying all marker items that may have been added to this time axis view
59                  *
60                  */
61                 ~MarkerTimeAxisView () ;
62
63                 //---------------------------------------------------------------------------------------//
64                 // Parent/Child helper object accessors
65
66                 /**
67                  * Returns the TimeAxisView thatt his object is acting as a helper for
68                  *
69                  * @return the TimeAxisView that this object is acting as a view helper for
70                  */
71                 MarkerTimeAxis& trackview() { return _trackview; }
72
73                 /**
74                  *
75                  */
76                 ArdourCanvas::Item *canvas_item() { return canvas_group; }
77
78
79                 //---------------------------------------------------------------------------------------//
80                 // ui methods & data
81
82                 /**
83                  * Sets the height of the time axis view and the item upon it
84                  *
85                  * @param height the new height
86                  */
87                 int set_height(gdouble height) ;
88
89                 /**
90                  * Sets the position of this view helper on the canvas
91                  *
92                  * @param x the x position upon the canvas
93                  * @param y the y position upon the canvas
94                  */
95                 int set_position(gdouble x, gdouble y) ;
96
97                 /**
98                  * Sets the current samples per unit.
99                  * this method tells each item upon the time axis of the change
100                  *
101                  * @param spu the new samples per canvas unit value
102                  */
103                 int set_samples_per_unit(gdouble spu) ;
104
105                 /**
106                  * Returns the current samples per unit of this time axis view helper
107                  *
108                  * @return the current samples per unit of this time axis view helper
109                  */
110                 gdouble get_samples_per_unit() { return _samples_per_unit; }
111
112                 /**
113                  * Sets the color of the items contained upon this view helper
114                  *
115                  * @param color the new base color
116                  */
117                 void apply_color(Gdk::Color& color) ;
118
119                 //---------------------------------------------------------------------------------------//
120                 // Child MarkerView Accessors/Mutators
121
122                 /**
123                  * Adds a marker view to the list of items upon this time axis view helper
124                  * the new MarkerView is returned
125                  *
126                  * @param ifv the ImageFrameView that the new item is marking up
127                  * @param mark_text the text to be displayed uopn the new marker item
128                  * @param mark_id the unique id of the new item
129                  * @param start the position the new item should be placed upon the time line
130                  * @param duration the duration the new item should be placed upon the timeline
131                  * @param src the identity of the object that initiated the change
132                  */
133                 MarkerView* add_marker_view(ImageFrameView* ifv, std::string mark_type, std::string mark_id, nframes_t start, nframes_t dur, void* src) ;
134
135                 /**
136                  * Returns the named MarkerView or 0 if the named marker does not exist
137                  *
138                  * @param item_id the unique id of the item to search for
139                  * @return the named MarkerView, or 0 if it is not held upon this view
140                  */
141                 MarkerView* get_named_marker_view(std::string item_id) ;
142
143                 /**
144                  * Removes the currently selected MarverView
145                  * Note that this method actually destroys the MarkerView too.
146                  * We assume that since we own the object, we are allowed to do this
147                  *
148                  * @param src the identity of the object that initiated the change
149                  * @see add_marker_view
150                  */
151                 void remove_selected_marker_view(void* src) ;
152
153                 /**
154                  * Removes and returns the named MarkerView from the list of MarkerView held by this view helper
155                  *
156                  * @param item_id the MarkerView unique id to remove
157                  * @param src the identity of the object that initiated the change
158                  * @see add_marker_view
159                  */
160                 MarkerView* remove_named_marker_view(std::string item_id, void* src) ;
161
162                 /**
163                  * Removes mv from the list of MarkerView upon this TimeAxis
164                  *
165                  * @param mv the MarkerView to remove
166                  * @param src the identity of the object that initiated the change
167                  */
168                 void remove_marker_view(MarkerView* item, void* src) ;
169
170                 //---------------------------------------------------------------------------------------//
171                 // Selected item methods
172
173                 /**
174                  * Sets the currently selected item upon this time axis
175                  *
176                  * @param mv the item to set selected
177                  */
178                 void set_selected_time_axis_item(MarkerView* mv) ;
179
180                 /**
181                  * Clears any selected item upon this time axis
182                  *
183                  */
184                 void clear_selected_time_axis_item() ;
185
186                 /**
187                  * Returnsthe currently selected item upon this time axis
188                  *
189                  * @return the currently selected item pon this time axis
190                  */
191                 MarkerView* get_selected_time_axis_item() ;
192
193
194                 /**
195                  * Sets the duration of the selected MarkerView to the specified number of seconds
196                  *
197                  * @param sec the duration to set the MArkerView to, in seconds
198                  */
199                 void set_marker_duration_sec(double sec) ;
200
201                 //---------------------------------------------------------------------------------//
202                 // Emitted Signals
203
204                 /** Emitted when a MarkerView is Added */
205                 sigc::signal<void,MarkerView*,void*> MarkerViewAdded ;
206
207                 /** Emitted when a MarkerView Item is removed */
208                 sigc::signal<void,std::string,void*> MarkerViewRemoved ;
209
210         private:
211                 /**
212                  * convenience method to re-get the samples per unit and tell items upon this view
213                  *
214                  */
215                 void reset_samples_per_unit() ;
216
217                 /** The list of items held by this time axis view helper */
218                 typedef std::list<MarkerView *> MarkerViewList ;
219                 MarkerViewList marker_view_list;
220
221                 /** the currently selected time axis item upon this time axis */
222                 MarkerView* selected_time_axis_item ;
223
224                 /* the TimeAxisView that this object is acting as the view helper for */
225                 MarkerTimeAxis& _trackview ;
226
227                 ArdourCanvas::Group *canvas_group ;
228                 ArdourCanvas::SimpleRect *canvas_rect ; /* frame around the whole thing */
229
230                 /** the current samples per unit */
231                 double _samples_per_unit;
232
233                 /* XXX why are these different? */
234                 Gdk::Color region_color;
235                 uint32_t stream_base_color;
236
237 }; /* class MarkerTimeAxisView */
238
239 #endif /* __ardour_marker_time_axis_view_h__ */