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 <libgnomecanvasmm/group.h>
29 #include <libgnomecanvasmm/canvas.h>
31 #include <ardour/types.h>
32 #include <ardour/region.h>
35 #include "axis_view.h"
48 class AudioRegionSelection;
51 class TimeAxisViewItem;
56 * TimeAxisView defines the abstract base class for time-axis views.
58 * This class provides the basic LHS controls and display methods. This should be
59 * extended to create functional time-axis based views.
62 class TimeAxisView : public virtual AxisView
66 /* canvas units. they need to be odd
67 valued so that there is a precise
78 TimeAxisView(ARDOUR::Session& sess, PublicEditor& ed, TimeAxisView* parent, Gtk::Widget *canvas);
79 virtual ~TimeAxisView ();
81 /* public data: XXX create accessor/mutators for these ?? */
85 guint32 height; /* in canvas units */
86 guint32 effective_height; /* in canvas units */
91 Gnome::Canvas::Item *canvas_display;
92 Gtk::VBox *control_parent;
94 /* The Standard LHS Controls */
95 Gtk::Frame controls_frame;
96 Gtk::HBox controls_hbox;
97 Gtk::EventBox controls_lhs_pad;
98 Gtk::Table controls_table;
99 Gtk::EventBox controls_ebox;
100 Gtk::VBox controls_vbox;
102 Gtk::Frame name_frame;
103 Gtk::Entry name_entry;
106 * Display this TrackView as the nth component of the parent box, at y.
110 * @param parent the parent component
111 * @return the height of this TrackView
113 virtual guint32 show_at (double y, int& nth, Gtk::VBox *parent);
115 bool touched (double top, double bot);
118 * Hides this TrackView
120 virtual void hide ();
121 bool hidden() const { return _hidden; }
123 virtual void set_selected (bool);
126 * potential handler for entered events
129 virtual void entered () {}
130 virtual void exited () {}
133 * Sets the height of this TrackView to one of ths TrackHeghts
135 * @param h the TrackHeight value to set
137 virtual void set_height (TrackHeight h);
140 * Steps through the defined TrackHeights for this TrackView.
141 * Sets bigger to true to step up in size, set to fals eot step smaller.
143 * @param bigger true if stepping should increase in size, false otherwise
145 virtual void step_height (bool bigger);
147 virtual ARDOUR::RouteGroup* edit_group() const { return 0; }
148 virtual ARDOUR::Playlist* playlist() const { return 0; }
150 virtual void set_samples_per_unit (double);
151 virtual void show_selection (TimeSelection&);
152 virtual void hide_selection ();
153 virtual void reshow_selection (TimeSelection&);
154 virtual void show_timestretch (jack_nframes_t start, jack_nframes_t end);
155 virtual void hide_timestretch ();
157 virtual void hide_dependent_views (TimeAxisViewItem&) {}
158 virtual void reveal_dependent_views (TimeAxisViewItem&) {}
160 /* editing operations */
162 virtual bool cut_copy_clear (Selection&, Editing::CutCopyOp) { return false; }
163 virtual bool paste (jack_nframes_t, float times, Selection&, size_t nth) { return false; }
165 virtual void set_selected_regionviews (AudioRegionSelection&) {}
166 virtual void set_selected_points (PointSelection&) {}
168 virtual ARDOUR::Region* find_next_region (jack_nframes_t pos, ARDOUR::RegionPoint, int32_t dir) {
172 void order_selection_trims (Gnome::Canvas::Item *item, bool put_start_on_top);
174 virtual void get_selectables (jack_nframes_t start, jack_nframes_t end, double top, double bot, list<Selectable*>& results);
175 virtual void get_inverted_selectables (Selection&, list<Selectable *>& results);
177 /* state/serialization management */
179 void set_parent (TimeAxisView& p);
180 bool has_state () const;
182 virtual void set_state (const XMLNode&);
183 virtual XMLNode* get_state_node () { return 0; }
185 /* call this on the parent */
187 virtual XMLNode* get_child_xml_node (std::string childname) { return 0; }
191 string controls_base_unselected_name;
192 string controls_base_selected_name;
195 * Handle mouse press on our LHS control name entry.
197 * @param ev the event
199 virtual bool name_entry_button_press (GdkEventButton *ev);
202 * Handle mouse relaese on our LHS control name entry.
204 *@ param ev the event
206 virtual bool name_entry_button_release (GdkEventButton *ev);
209 * Handle mouse relaese on our LHS control name ebox.
211 *@ param ev the event
213 virtual gint controls_ebox_button_release (GdkEventButton *ev);
216 * Displays the standard LHS control menu at when.
218 * @param when the popup activation time
220 virtual void popup_display_menu (guint32 when);
223 * Build the standard LHS control menu.
224 * Subclasses should extend this method to add their own menu options.
227 virtual void build_display_menu ();
230 * Do anything that needs to be done to dynamically reset
231 * the LHS control menu.
233 virtual gint handle_display_menu_map_event (GdkEventAny *ev) { return FALSE; }
236 * Build the standard LHS control size menu for the default TrackHeight options.
239 virtual void build_size_menu();
242 * Displays the standard LHS controls size menu for the TrackHeight.
244 * @parem when the popup activation time
246 void popup_size_menu(guint32 when);
249 * Handle the size option of out main menu.
251 * @param ev the event
253 gint size_click(GdkEventButton *ev);
255 /* The standard LHS Track control popup-menus */
257 Gtk::Menu *display_menu;
258 Gtk::Menu *size_menu;
260 Gtk::Label name_label;
262 TimeAxisView* parent;
264 /* find the parent with state */
266 TimeAxisView* get_parent_with_state();
268 std::vector<TimeAxisView*> children;
269 bool is_child (TimeAxisView*);
271 void remove_child (TimeAxisView*);
272 void add_child (TimeAxisView*);
274 /* selection display */
276 Gnome::Canvas::Group *selection_group;
278 list<SelectionRect*> free_selection_rects;
279 list<SelectionRect*> used_selection_rects;
281 SelectionRect* get_selection_rect(uint32_t id);
283 virtual void selection_click (GdkEventButton*);
288 }; /* class TimeAxisView */
290 #endif /* __ardour_gtk_time_axis_h__ */