remove <gtkmm/gtkmm.h> from all files, plus a small fix related to map/realize handling
[ardour.git] / gtk2_ardour / 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     $Id$
19 */
20
21 #ifndef __ardour_gtk_time_axis_h__
22 #define __ardour_gtk_time_axis_h__
23
24 #include <vector>
25 #include <list>
26
27 #include <gtkmm/box.h>
28 #include <gtkmm/frame.h>
29 #include <gtkmm/eventbox.h>
30 #include <gtkmm/table.h>
31 #include <gtkmm/entry.h>
32 #include <gtkmm/label.h>
33
34 #include <ardour/types.h>
35 #include <ardour/region.h>
36
37 #include "prompter.h"
38 #include "axis_view.h"
39 #include "enums.h"
40 #include "editing.h"
41 #include "canvas.h"
42
43 namespace ARDOUR {
44         class Session;
45         class Region;
46         class Session;
47         class RouteGroup;
48         class Playlist;
49 }
50
51 namespace Gtk {
52         class Menu;
53 }
54
55 class PublicEditor;
56 class AudioRegionSelection;
57 class TimeSelection;
58 class PointSelection;
59 class TimeAxisViewItem;
60 class Selection;
61 class Selectable;
62
63 /**
64  * TimeAxisView defines the abstract base class for time-axis views.
65  *
66  * This class provides the basic LHS controls and display methods. This should be
67  * extended to create functional time-axis based views.
68  *
69  */
70 class TimeAxisView : public virtual AxisView
71 {
72   public:
73         enum TrackHeight { 
74                 /* canvas units. they need to be odd
75                    valued so that there is a precise
76                    middle.
77                 */
78                 Largest = 301,
79                 Large = 201,
80                 Larger = 101,
81                 Normal = 51,
82                 Smaller = 31,
83                 Small = 21
84         };
85
86         TimeAxisView(ARDOUR::Session& sess, PublicEditor& ed, TimeAxisView* parent, ArdourCanvas::Canvas& canvas);
87         virtual ~TimeAxisView ();
88
89         /* public data: XXX create accessor/mutators for these ?? */
90
91         PublicEditor& editor;
92
93         guint32 height;  /* in canvas units */
94         guint32 effective_height;  /* in canvas units */
95         double  y_position;
96         int     order;
97
98         
99         ArdourCanvas::Group   *canvas_display;
100         Gtk::VBox       *control_parent;
101
102         /* The Standard LHS Controls */
103         Gtk::Frame    controls_frame;
104         Gtk::HBox     controls_hbox;
105         Gtk::EventBox controls_lhs_pad;
106         Gtk::Table    controls_table;
107         Gtk::EventBox controls_ebox;
108         Gtk::VBox     controls_vbox;
109         Gtk::HBox     name_hbox;
110         Gtk::Frame    name_frame;
111         Gtk::Entry    name_entry;
112
113         /**
114          * Display this TrackView as the nth component of the parent box, at y.
115          *
116          * @param y 
117          * @param nth
118          * @param parent the parent component
119          * @return the height of this TrackView
120          */
121         virtual guint32 show_at (double y, int& nth, Gtk::VBox *parent);
122
123         bool touched (double top, double bot);
124
125         /**
126          * Hides this TrackView
127          */
128         virtual void hide ();
129         bool hidden() const { return _hidden; }
130
131         virtual void set_selected (bool);
132
133         /**
134          * potential handler for entered events
135          */
136
137         virtual void entered () {}
138         virtual void exited () {}
139
140         /**
141          * Sets the height of this TrackView to one of ths TrackHeghts
142          *
143          * @param h the TrackHeight value to set
144          */
145         virtual void set_height (TrackHeight h);
146         void reset_height();
147         /**
148          * Steps through the defined TrackHeights for this TrackView.
149          * Sets bigger to true to step up in size, set to fals eot step smaller.
150          *
151          * @param bigger true if stepping should increase in size, false otherwise
152          */
153         virtual void step_height (bool bigger);
154
155         virtual ARDOUR::RouteGroup* edit_group() const { return 0; }
156         virtual ARDOUR::Playlist* playlist() const { return 0; }
157
158         virtual void set_samples_per_unit (double);
159         virtual void show_selection (TimeSelection&);
160         virtual void hide_selection ();
161         virtual void reshow_selection (TimeSelection&);
162         virtual void show_timestretch (jack_nframes_t start, jack_nframes_t end);
163         virtual void hide_timestretch ();
164
165         virtual void hide_dependent_views (TimeAxisViewItem&) {}
166         virtual void reveal_dependent_views (TimeAxisViewItem&) {}
167
168         /* editing operations */
169         
170         virtual bool cut_copy_clear (Selection&, Editing::CutCopyOp) { return false; }
171         virtual bool paste (jack_nframes_t, float times, Selection&, size_t nth) { return false; }
172         
173         virtual void set_selected_regionviews (AudioRegionSelection&) {}
174         virtual void set_selected_points (PointSelection&) {}
175
176         virtual ARDOUR::Region* find_next_region (jack_nframes_t pos, ARDOUR::RegionPoint, int32_t dir) {
177                 return 0;
178         }
179
180         void order_selection_trims (ArdourCanvas::Item *item, bool put_start_on_top);
181
182         virtual void get_selectables (jack_nframes_t start, jack_nframes_t end, double top, double bot, list<Selectable*>& results);
183         virtual void get_inverted_selectables (Selection&, list<Selectable *>& results);
184
185         /* state/serialization management */
186
187         void set_parent (TimeAxisView& p);
188         bool has_state () const;
189
190         virtual void set_state (const XMLNode&);
191         virtual XMLNode* get_state_node () { return 0; }
192
193         /* call this on the parent */
194
195         virtual XMLNode* get_child_xml_node (std::string childname) { return 0; }
196
197   protected:
198
199         string controls_base_unselected_name;
200         string controls_base_selected_name;
201
202         /**
203          * Handle mouse press on our LHS control name entry.
204          *
205          * @param ev the event
206          */
207         virtual bool name_entry_button_press (GdkEventButton *ev);
208
209         /**
210          * Handle mouse relaese on our LHS control name entry.
211          * 
212          *@ param ev the event
213          */
214         virtual bool name_entry_button_release (GdkEventButton *ev);
215
216         /**
217          * Handle mouse relaese on our LHS control name ebox.
218          * 
219          *@ param ev the event
220          */
221         virtual gint controls_ebox_button_release (GdkEventButton *ev);
222
223         /**
224          * Displays the standard LHS control menu at when.
225          *
226          * @param when the popup activation time
227          */
228         virtual void popup_display_menu (guint32 when);
229
230         /**
231          * Build the standard LHS control menu.
232          * Subclasses should extend this method to add their own menu options.
233          *
234          */
235         virtual void build_display_menu ();
236
237         /**
238          * Do anything that needs to be done to dynamically reset
239          * the LHS control menu.
240          */
241         virtual bool handle_display_menu_map_event (GdkEventAny *ev) { return false; }
242
243         /**
244          * Build the standard LHS control size menu for the default TrackHeight options.
245          *
246          */
247         virtual void build_size_menu();
248
249         /**
250          * Displays the standard LHS controls size menu for the TrackHeight.
251          *
252          * @parem when the popup activation time
253          */
254         void popup_size_menu(guint32 when);
255
256         /**
257          * Handle the size option of out main menu.
258          * 
259          * @param ev the event
260          */
261         gint size_click(GdkEventButton *ev);
262
263         /* The standard LHS Track control popup-menus */
264
265         Gtk::Menu *display_menu;
266         Gtk::Menu *size_menu;
267
268         Gtk::Label    name_label;
269
270         TimeAxisView* parent;
271
272         /* find the parent with state */
273
274         TimeAxisView* get_parent_with_state();
275
276         std::vector<TimeAxisView*> children;
277         bool is_child (TimeAxisView*);
278
279         void remove_child (TimeAxisView*);
280         void add_child (TimeAxisView*);
281
282         /* selection display */
283
284         ArdourCanvas::Group      *selection_group;
285
286         list<SelectionRect*> free_selection_rects;
287         list<SelectionRect*> used_selection_rects;
288
289         SelectionRect* get_selection_rect(uint32_t id);
290
291         virtual void selection_click (GdkEventButton*);
292
293         bool _hidden;
294         bool _has_state;
295
296 }; /* class TimeAxisView */
297
298 #endif /* __ardour_gtk_time_axis_h__ */
299