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