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