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"
57 class RegionSelection;
60 class TimeAxisViewItem;
64 /** Abstract base class for time-axis views (horizontal editor 'strips')
66 * This class provides the basic LHS controls and display methods. This should be
67 * extended to create functional time-axis based views.
69 class TimeAxisView : public virtual AxisView
72 enum NamePackingBits {
73 NameLabelPacked = 0x1,
87 static uint32_t hLargest;
88 static uint32_t hLarge;
89 static uint32_t hLarger;
90 static uint32_t hNormal;
91 static uint32_t hSmaller;
92 static uint32_t hSmall;
94 static uint32_t height_to_pixels (TrackHeight);
96 TimeAxisView(ARDOUR::Session& sess, PublicEditor& ed, TimeAxisView* parent, ArdourCanvas::Canvas& canvas);
97 virtual ~TimeAxisView ();
99 /* public data: XXX create accessor/mutators for these ?? */
101 PublicEditor& editor;
103 TrackHeight height_style;
104 uint32_t height; /* in canvas units */
105 uint32_t effective_height; /* in canvas units */
109 ArdourCanvas::Group *canvas_display;
110 Gtk::VBox *control_parent;
112 /* The Standard LHS Controls */
113 Gtk::Frame controls_frame;
114 Gtk::HBox controls_hbox;
115 Gtk::EventBox controls_lhs_pad;
116 Gtk::Table controls_table;
117 Gtk::EventBox controls_ebox;
118 Gtk::VBox controls_vbox;
120 Gtk::Frame name_frame;
121 Gtk::Entry name_entry;
123 void hide_name_label ();
124 void hide_name_entry ();
125 void show_name_label ();
126 void show_name_entry ();
128 /** Display this TrackView as the nth component of the parent box, at y.
132 * @param parent the parent component
133 * @return the height of this TrackView
135 virtual guint32 show_at (double y, int& nth, Gtk::VBox *parent);
137 bool touched (double top, double bot);
139 /** Hides this TrackView */
140 virtual void hide ();
141 bool hidden() const { return _hidden; }
143 virtual void set_selected (bool);
146 * potential handler for entered events
149 virtual void entered () {}
150 virtual void exited () {}
152 virtual void set_height (TrackHeight h);
155 /** Steps through the defined heights for this TrackView.
156 * Sets bigger to true to step up in size, set to fals eot step smaller.
158 * @param bigger true if stepping should increase in size, false otherwise
160 virtual void step_height (bool bigger);
162 virtual ARDOUR::RouteGroup* edit_group() const { return 0; }
163 virtual ARDOUR::Playlist* playlist() const { return 0; }
165 virtual void set_samples_per_unit (double);
166 virtual void show_selection (TimeSelection&);
167 virtual void hide_selection ();
168 virtual void reshow_selection (TimeSelection&);
169 virtual void show_timestretch (nframes_t start, nframes_t end);
170 virtual void hide_timestretch ();
172 virtual void hide_dependent_views (TimeAxisViewItem&) {}
173 virtual void reveal_dependent_views (TimeAxisViewItem&) {}
175 /* editing operations */
177 virtual bool cut_copy_clear (Selection&, Editing::CutCopyOp) { return false; }
178 virtual bool paste (nframes_t, float times, Selection&, size_t nth) { return false; }
180 virtual void set_selected_regionviews (RegionSelection&) {}
181 virtual void set_selected_points (PointSelection&) {}
183 virtual boost::shared_ptr<ARDOUR::Region> find_next_region (nframes_t pos, ARDOUR::RegionPoint, int32_t dir) {
184 return boost::shared_ptr<ARDOUR::Region> ();
187 void order_selection_trims (ArdourCanvas::Item *item, bool put_start_on_top);
189 virtual void get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results);
190 virtual void get_inverted_selectables (Selection&, list<Selectable *>& results);
192 /* state/serialization management */
194 void set_parent (TimeAxisView& p);
195 bool has_state () const;
197 virtual void set_state (const XMLNode&);
198 virtual XMLNode* get_state_node () { return 0; }
200 /* call this on the parent */
202 virtual XMLNode* get_child_xml_node (const string & childname) { return 0; }
206 string controls_base_unselected_name;
207 string controls_base_selected_name;
209 bool name_entry_button_press (GdkEventButton *ev);
210 bool name_entry_button_release (GdkEventButton *ev);
211 bool name_entry_key_release (GdkEventKey *ev);
212 void name_entry_activated ();
213 sigc::connection name_entry_key_timeout;
214 bool name_entry_key_timed_out ();
215 guint32 last_name_entry_key_press_event;
217 /* derived classes can override these */
219 virtual void name_entry_changed ();
220 virtual bool name_entry_focus_in (GdkEventFocus *ev);
221 virtual bool name_entry_focus_out (GdkEventFocus *ev);
223 /** Handle mouse relaese on our LHS control name ebox.
225 *@ param ev the event
227 virtual bool controls_ebox_button_release (GdkEventButton *ev);
228 virtual bool controls_ebox_scroll (GdkEventScroll *ev);
230 /** Display the standard LHS control menu at when.
232 * @param when the popup activation time
234 virtual void popup_display_menu (guint32 when);
236 /** Build the standard LHS control menu.
237 * Subclasses should extend this method to add their own menu options.
239 virtual void build_display_menu ();
241 /** Do whatever needs to be done to dynamically reset the LHS control menu.
243 virtual bool handle_display_menu_map_event (GdkEventAny *ev) { return false; }
245 /** Build the standard LHS control size menu for the default heights options.
247 virtual void build_size_menu();
249 /** Displays the standard LHS controls size menu for the track heights
251 * @param when the popup activation time
253 void popup_size_menu(guint32 when);
255 /** Handle the size option of our main menu.
257 * @param ev the event
259 gint size_click(GdkEventButton *ev);
261 /* The standard LHS Track control popup-menus */
263 Gtk::Menu *display_menu;
264 Gtk::Menu *size_menu;
266 Gtk::Label name_label;
268 TimeAxisView* parent;
270 /** Find the parent with state */
271 TimeAxisView* get_parent_with_state();
273 std::vector<TimeAxisView*> children;
274 bool is_child (TimeAxisView*);
276 void remove_child (TimeAxisView*);
277 void add_child (TimeAxisView*);
279 /* selection display */
281 ArdourCanvas::Group *selection_group;
283 list<SelectionRect*> free_selection_rects;
284 list<SelectionRect*> used_selection_rects;
286 SelectionRect* get_selection_rect(uint32_t id);
288 virtual void selection_click (GdkEventButton*);
292 NamePackingBits name_packing;
294 static void compute_controls_size_info ();
295 static bool need_size_info;
297 void set_height_pixels (uint32_t h);
298 void color_handler (ColorID, uint32_t);
300 }; /* class TimeAxisView */
302 #endif /* __ardour_gtk_time_axis_h__ */