25ec1d8ef34fa5f254975a92bae1fd87d955f603
[ardour.git] / gtk2_ardour / visual_time_axis.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_visual_time_axis_h__
21 #define __ardour_visual_time_axis_h__
22
23 #include <gtkmm/box.h>
24 #include <gtkmm/button.h>
25
26 #include <gtkmm2ext/selector.h>
27
28 #include "ardour_dialog.h"
29 #include "route_ui.h"
30 #include "enums.h"
31 #include "time_axis_view.h"
32 #include "canvas.h"
33
34 namespace ARDOUR
35 {
36         class Session ;
37 }
38
39 class PublicEditor;
40 class ImageFrameView;
41 class ImageFrameTimeAxisView;
42 class MarkersTimeAxisView;
43 class TimeSelection;
44 class RegionSelection;
45 class MarkerTimeAxis;
46 class TimeAxisViewStrip;
47
48 /**
49  * Base Abstact Class for TimeAxis views that operate purely within the visual domain.
50  *
51  * This class provides many of the common methods required for visual TimeAxis views. The aim is
52  * to provide an abstract layer during the developmnt of the visual based time axis'. Many of these
53  * methods have a better home further up the class heirarchy, and in fact some are replication of
54  * methods found within RouteUI. This, however, has been required due to various problems with previous
55  * versions of g++, mainly 2.95, which are not correctly handling virtual methods, virtual base classes,
56  * and virtual methods when used with Multiple Inheritance. Perhaps these could be combined once the
57  * compilers all agree on hos do to do stuff...
58  */
59 class VisualTimeAxis : public TimeAxisView
60 {
61         public:
62                 //---------------------------------------------------------------------------------------//
63                 // Constructor / Desctructor
64
65                 /**
66                  * VisualTimeAxis Destructor
67                  *
68                  */
69                 virtual ~VisualTimeAxis() ;
70
71                 //---------------------------------------------------------------------------------------//
72                 // Name/Id Accessors/Mutators
73
74                 /**
75                  * Returns the name of this TimeAxis
76                  *
77                  * @return the name of this TimeAxis
78                  */
79                 virtual std::string name() const ;
80
81                 /**
82                  * Sets the name of this TimeAxis
83                  *
84                  * @param name the new name of this TimeAxis
85                  * @param src the identity of the object that initiated the change
86                  */
87                 virtual void set_time_axis_name(const std::string & name, void* src) ;
88
89
90                 //---------------------------------------------------------------------------------------//
91                 // ui methods & data
92
93                 /**
94                  * Sets the height of this TrackView to one of the defined TrackHeghts
95                  *
96                  * @param h the number of pixels to set the height to
97                  */
98                 virtual void set_height (uint32_t);
99
100                 //---------------------------------------------------------------------------------------//
101                 // Selection Methods
102                 // selection methods are not handled by visual time axis object yet...
103
104                 /**
105                  * Not implemented
106                  */
107                 virtual void set_selected_regionviews(RegionSelection&) ;
108
109
110                 //---------------------------------------------------------------------------------//
111                 // Emitted Signals
112
113                 /**
114                  * Emitted when we have changed the gui, and what we have shanged
115                  */
116                 sigc::signal<void,const std::string &,void*> gui_changed ;
117
118                 /**
119                  * Emitted when this Visual Time Axis has been removed
120                  * This is different to the CatchDeletion signal in that this signal
121                  * is emitted during the deletion of this Time Axis, and not during
122                  * the destructor, this allows us to capture the source of the deletion
123                  * event
124                  */
125                 sigc::signal<void,const std::string &,void*> VisualTimeAxisRemoved ;
126
127                 /**
128                  * Emitted when we have changed the name of this TimeAxis
129                  */
130                 sigc::signal<void,const std::string &,const std::string &,void*> NameChanged ;
131
132                 /**
133                  * Emitted when this time axis has been selected for removal
134                  */
135                 //sigc::signal<void,std::std::string,void*> VisualTimeAxisRemoved ;
136
137                 //---------------------------------------------------------------------------------------//
138                 // Constructor / Desctructor
139
140                 /**
141                  * Abstract Constructor for base visual time axis classes
142                  *
143                  * @param name the name/Id of thie TimeAxis
144                  * @param ed the Ardour PublicEditor
145                  * @param sess the current session
146                  * @param canvas the parent canvas object
147                  */
148                 VisualTimeAxis(const std::string & name, PublicEditor& ed, ARDOUR::Session* sess, ArdourCanvas::Canvas& canvas) ;
149
150
151                 //---------------------------------------------------------------------------------------//
152                 // Handle time axis removal
153
154                 /**
155                  * Handles the Removal of this VisualTimeAxis
156                  *
157                  * @param src the identity of the object that initiated the change
158                  */
159                 virtual void remove_this_time_axis(void* src) ;
160
161                 /**
162                  * Callback used to remove this time axis during the gtk idle loop
163                  * This is used to avoid deleting the obejct while inside the remove_this_time_axis
164                  * method
165                  *
166                  * @param ta the VisualTimeAxis to remove
167                  * @param src the identity of the object that initiated the change
168                  */
169                 static gint idle_remove_this_time_axis(VisualTimeAxis* ta, void* src) ;
170
171
172
173                 //---------------------------------------------------------------------------------------//
174                 // ui methods & data
175
176                 /**
177                  * Handle the visuals button click
178                  *
179                  */
180                 void visual_click() ;
181
182                 /**
183                  * Handle the hide buttons click
184                  *
185                  */
186                 void hide_click() ;
187
188                 /**
189                  * Allows the selection of a new color for this TimeAxis
190                  *
191                  */
192                 virtual void select_track_color() ;
193
194                 /**
195                  * Provides a color chooser for the selection of a new time axis color.
196                  *
197                  */
198                  bool choose_time_axis_color() ;
199
200                 /**
201                  * Sets the color of this TimeAxis to the specified color c
202                  *
203                  * @param c the new TimeAxis color
204                  */
205                 void set_time_axis_color(Gdk::Color c) ;
206
207
208                 //---------------------------------------------------------------------------------------//
209                 // Handle TimeAxis rename
210
211                 /**
212                  * Construct a new prompt to receive a new name for this TimeAxis
213                  *
214                  * @see finish_time_axis_rename()
215                  */
216                 void start_time_axis_rename() ;
217
218                 /**
219                  * Handles the new name for this TimeAxis from the name prompt
220                  *
221                  * @see start_time_axis_rename()
222                  */
223                 virtual void label_view() ;
224
225
226                 //---------------------------------------------------------------------------------------//
227                 // Handle name entry signals
228
229                 void name_entry_changed() ;
230                 bool name_entry_focus_out_handler(GdkEventFocus*) ;
231                 bool name_entry_key_release_handler(GdkEventKey*) ;
232                 bool name_entry_button_release_handler(GdkEventButton*) ;
233                 bool name_entry_button_press_handler(GdkEventButton*) ;
234
235                 //---------------------------------------------------------------------------------------//
236                 // VisualTimeAxis Widgets
237                 Gtk::HBox other_button_hbox ;
238                 Gtk::Button hide_button ;
239                 Gtk::Button visual_button ;
240                 Gtk::Button size_button ;
241
242                 /** the name of this TimeAxis object */
243                 std::string time_axis_name ;
244
245                 //---------------------------------------------------------------------------------------//
246                 // Super class methods not handled by VisualTimeAxis
247
248                 /**
249                  * Not handled by purely Visual TimeAxis
250                  *
251                  * @todo should VisualTimeAxis handle this?
252                  */
253                 void show_timestretch (nframes_t start, nframes_t end, int layers, int layer);
254
255                 /**
256                  * Not handle by purely visual TimeAxis
257                  * @see show_timestratch
258                  */
259                 virtual void hide_timestretch() ;
260
261         private:
262
263 };
264
265 #endif /* __ardour_visual_time_axis_h__ */
266