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