2 Copyright (C) 2003 Paul Davis
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.
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.
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.
21 #ifndef __ardour_gtk_time_axis_h__
22 #define __ardour_gtk_time_axis_h__
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>
34 #include <ardour/types.h>
35 #include <ardour/region.h>
38 #include "axis_view.h"
56 class AudioRegionSelection;
59 class TimeAxisViewItem;
64 * TimeAxisView defines the abstract base class for time-axis views.
66 * This class provides the basic LHS controls and display methods. This should be
67 * extended to create functional time-axis based views.
70 class TimeAxisView : public virtual AxisView
74 /* canvas units. they need to be odd
75 valued so that there is a precise
86 TimeAxisView(ARDOUR::Session& sess, PublicEditor& ed, TimeAxisView* parent, ArdourCanvas::Canvas& canvas);
87 virtual ~TimeAxisView ();
89 /* public data: XXX create accessor/mutators for these ?? */
93 guint32 height; /* in canvas units */
94 guint32 effective_height; /* in canvas units */
99 ArdourCanvas::Group *canvas_display;
100 Gtk::VBox *control_parent;
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;
110 Gtk::Frame name_frame;
111 Gtk::Entry name_entry;
114 * Display this TrackView as the nth component of the parent box, at y.
118 * @param parent the parent component
119 * @return the height of this TrackView
121 virtual guint32 show_at (double y, int& nth, Gtk::VBox *parent);
123 bool touched (double top, double bot);
126 * Hides this TrackView
128 virtual void hide ();
129 bool hidden() const { return _hidden; }
131 virtual void set_selected (bool);
134 * potential handler for entered events
137 virtual void entered () {}
138 virtual void exited () {}
141 * Sets the height of this TrackView to one of ths TrackHeghts
143 * @param h the TrackHeight value to set
145 virtual void set_height (TrackHeight h);
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.
151 * @param bigger true if stepping should increase in size, false otherwise
153 virtual void step_height (bool bigger);
155 virtual ARDOUR::RouteGroup* edit_group() const { return 0; }
156 virtual ARDOUR::Playlist* playlist() const { return 0; }
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 ();
165 virtual void hide_dependent_views (TimeAxisViewItem&) {}
166 virtual void reveal_dependent_views (TimeAxisViewItem&) {}
168 /* editing operations */
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; }
173 virtual void set_selected_regionviews (AudioRegionSelection&) {}
174 virtual void set_selected_points (PointSelection&) {}
176 virtual ARDOUR::Region* find_next_region (jack_nframes_t pos, ARDOUR::RegionPoint, int32_t dir) {
180 void order_selection_trims (ArdourCanvas::Item *item, bool put_start_on_top);
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);
185 /* state/serialization management */
187 void set_parent (TimeAxisView& p);
188 bool has_state () const;
190 virtual void set_state (const XMLNode&);
191 virtual XMLNode* get_state_node () { return 0; }
193 /* call this on the parent */
195 virtual XMLNode* get_child_xml_node (const string & childname) { return 0; }
199 string controls_base_unselected_name;
200 string controls_base_selected_name;
202 bool name_entry_button_press (GdkEventButton *ev);
203 bool name_entry_button_release (GdkEventButton *ev);
204 bool name_entry_key_release (GdkEventKey *ev);
205 void name_entry_activated ();
206 sigc::connection name_entry_key_timeout;
207 bool name_entry_key_timed_out ();
208 guint32 last_name_entry_key_press_event;
210 /* derived classes can override these */
212 virtual void name_entry_changed ();
213 virtual bool name_entry_focus_in (GdkEventFocus *ev);
214 virtual bool name_entry_focus_out (GdkEventFocus *ev);
217 * Handle mouse relaese on our LHS control name ebox.
219 *@ param ev the event
221 virtual gint controls_ebox_button_release (GdkEventButton *ev);
224 * Displays the standard LHS control menu at when.
226 * @param when the popup activation time
228 virtual void popup_display_menu (guint32 when);
231 * Build the standard LHS control menu.
232 * Subclasses should extend this method to add their own menu options.
235 virtual void build_display_menu ();
238 * Do anything that needs to be done to dynamically reset
239 * the LHS control menu.
241 virtual bool handle_display_menu_map_event (GdkEventAny *ev) { return false; }
244 * Build the standard LHS control size menu for the default TrackHeight options.
247 virtual void build_size_menu();
250 * Displays the standard LHS controls size menu for the TrackHeight.
252 * @parem when the popup activation time
254 void popup_size_menu(guint32 when);
257 * Handle the size option of out main menu.
259 * @param ev the event
261 gint size_click(GdkEventButton *ev);
263 /* The standard LHS Track control popup-menus */
265 Gtk::Menu *display_menu;
266 Gtk::Menu *size_menu;
268 Gtk::Label name_label;
270 TimeAxisView* parent;
272 /* find the parent with state */
274 TimeAxisView* get_parent_with_state();
276 std::vector<TimeAxisView*> children;
277 bool is_child (TimeAxisView*);
279 void remove_child (TimeAxisView*);
280 void add_child (TimeAxisView*);
282 /* selection display */
284 ArdourCanvas::Group *selection_group;
286 list<SelectionRect*> free_selection_rects;
287 list<SelectionRect*> used_selection_rects;
289 SelectionRect* get_selection_rect(uint32_t id);
291 virtual void selection_click (GdkEventButton*);
296 }; /* class TimeAxisView */
298 #endif /* __ardour_gtk_time_axis_h__ */