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__
28 #include <gtk-canvas.h>
30 #include <ardour/types.h>
31 #include <ardour/region.h>
34 #include "axis_view.h"
47 class AudioRegionSelection;
50 class TimeAxisViewItem;
55 * TimeAxisView defines the abstract base class for time-axis views.
57 * This class provides the basic LHS controls and display methods. This should be
58 * extended to create functional time-axis based views.
61 class TimeAxisView : public virtual AxisView
65 /* canvas units. they need to be odd
66 valued so that there is a precise
77 TimeAxisView(ARDOUR::Session& sess, PublicEditor& ed, TimeAxisView* parent, Gtk::Widget *canvas);
78 virtual ~TimeAxisView ();
80 /* public data: XXX create accessor/mutators for these ?? */
84 guint32 height; /* in canvas units */
85 guint32 effective_height; /* in canvas units */
90 GtkCanvasItem *canvas_display;
91 Gtk::VBox *control_parent;
93 /* The Standard LHS Controls */
94 Gtk::Frame controls_frame;
95 Gtk::HBox controls_hbox;
96 Gtk::EventBox controls_lhs_pad;
97 Gtk::Table controls_table;
98 Gtk::EventBox controls_ebox;
99 Gtk::VBox controls_vbox;
101 Gtk::Frame name_frame;
102 Gtk::Entry name_entry;
105 * Display this TrackView as the nth component of the parent box, at y.
109 * @param parent the parent component
110 * @return the height of this TrackView
112 virtual guint32 show_at (double y, int& nth, Gtk::VBox *parent);
114 bool touched (double top, double bot);
117 * Hides this TrackView
119 virtual void hide ();
120 bool hidden() const { return _hidden; }
122 virtual void set_selected (bool);
125 * potential handler for entered events
128 virtual void entered () {}
129 virtual void exited () {}
132 * Sets the height of this TrackView to one of ths TrackHeghts
134 * @param h the TrackHeight value to set
136 virtual void set_height (TrackHeight h);
139 * Steps through the defined TrackHeights for this TrackView.
140 * Sets bigger to true to step up in size, set to fals eot step smaller.
142 * @param bigger true if stepping should increase in size, false otherwise
144 virtual void step_height (bool bigger);
146 virtual ARDOUR::RouteGroup* edit_group() const { return 0; }
147 virtual ARDOUR::Playlist* playlist() const { return 0; }
149 virtual void set_samples_per_unit (double);
150 virtual void show_selection (TimeSelection&);
151 virtual void hide_selection ();
152 virtual void reshow_selection (TimeSelection&);
153 virtual void show_timestretch (jack_nframes_t start, jack_nframes_t end);
154 virtual void hide_timestretch ();
156 virtual void hide_dependent_views (TimeAxisViewItem&) {}
157 virtual void reveal_dependent_views (TimeAxisViewItem&) {}
159 /* editing operations */
161 virtual bool cut_copy_clear (Selection&, Editing::CutCopyOp) { return false; }
162 virtual bool paste (jack_nframes_t, float times, Selection&, size_t nth) { return false; }
164 virtual void set_selected_regionviews (AudioRegionSelection&) {}
165 virtual void set_selected_points (PointSelection&) {}
167 virtual ARDOUR::Region* find_next_region (jack_nframes_t pos, ARDOUR::RegionPoint, int32_t dir) {
171 void order_selection_trims (GtkCanvasItem *item, bool put_start_on_top);
173 virtual void get_selectables (jack_nframes_t start, jack_nframes_t end, double top, double bot, list<Selectable*>& results);
174 virtual void get_inverted_selectables (Selection&, list<Selectable *>& results);
176 /* state/serialization management */
178 void set_parent (TimeAxisView& p);
179 bool has_state () const;
181 virtual void set_state (const XMLNode&);
182 virtual XMLNode* get_state_node () { return 0; }
184 /* call this on the parent */
186 virtual XMLNode* get_child_xml_node (std::string childname) { return 0; }
190 string controls_base_unselected_name;
191 string controls_base_selected_name;
194 * Handle mouse press on our LHS control name entry.
196 * @param ev the event
198 virtual gint name_entry_button_press (GdkEventButton *ev);
201 * Handle mouse relaese on our LHS control name entry.
203 *@ param ev the event
205 virtual gint name_entry_button_release (GdkEventButton *ev);
208 * Handle mouse relaese on our LHS control name ebox.
210 *@ param ev the event
212 virtual gint controls_ebox_button_release (GdkEventButton *ev);
215 * Displays the standard LHS control menu at when.
217 * @param when the popup activation time
219 virtual void popup_display_menu (guint32 when);
222 * Build the standard LHS control menu.
223 * Subclasses should extend this method to add their own menu options.
226 virtual void build_display_menu ();
229 * Do anything that needs to be done to dynamically reset
230 * the LHS control menu.
232 virtual gint handle_display_menu_map_event (GdkEventAny *ev) { return FALSE; }
235 * Build the standard LHS control size menu for the default TrackHeight options.
238 virtual void build_size_menu();
241 * Displays the standard LHS controls size menu for the TrackHeight.
243 * @parem when the popup activation time
245 void popup_size_menu(guint32 when);
248 * Handle the size option of out main menu.
250 * @param ev the event
252 gint size_click(GdkEventButton *ev);
254 /* The standard LHS Track control popup-menus */
256 Gtk::Menu *display_menu;
257 Gtk::Menu *size_menu;
259 Gtk::Label name_label;
261 TimeAxisView* parent;
263 /* find the parent with state */
265 TimeAxisView* get_parent_with_state();
267 std::vector<TimeAxisView*> children;
268 bool is_child (TimeAxisView*);
270 void remove_child (TimeAxisView*);
271 void add_child (TimeAxisView*);
273 /* selection display */
275 GtkCanvasItem *selection_group;
277 list<SelectionRect*> free_selection_rects;
278 list<SelectionRect*> used_selection_rects;
280 SelectionRect* get_selection_rect(uint32_t id);
282 virtual void selection_click (GdkEventButton*);
287 }; /* class TimeAxisView */
289 #endif /* __ardour_gtk_time_axis_h__ */