2 Copyright (C) 2000 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.
27 #include "pbd/error.h"
28 #include "pbd/convert.h"
30 #include <gtkmm2ext/doi.h>
31 #include <gtkmm2ext/utils.h>
32 #include <gtkmm2ext/selector.h>
34 #include "canvas/rectangle.h"
36 #include "ardour_ui.h"
37 #include "ardour_dialog.h"
38 #include "global_signals.h"
39 #include "gui_thread.h"
40 #include "public_editor.h"
41 #include "time_axis_view.h"
42 #include "region_view.h"
43 #include "ghostregion.h"
44 #include "selection.h"
46 #include "rgb_macros.h"
48 #include "streamview.h"
49 #include "editor_drag.h"
57 using namespace ARDOUR;
59 using namespace Editing;
60 using namespace ArdourCanvas;
61 using Gtkmm2ext::Keyboard;
63 const double trim_handle_size = 6.0; /* pixels */
64 uint32_t TimeAxisView::button_height = 0;
65 uint32_t TimeAxisView::extra_height = 0;
66 int const TimeAxisView::_max_order = 512;
67 PBD::Signal1<void,TimeAxisView*> TimeAxisView::CatchDeletion;
69 TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisView* rent, Canvas& /*canvas*/)
71 , controls_table (2, 8)
72 , _name_editing (false)
78 , in_destructor (false)
86 , _effective_height (0)
87 , _resize_drag_start (-1)
88 , _preresize_cursor (0)
89 , _have_preresize_cursor (false)
91 , _ebox_release_can_act (true)
93 if (extra_height == 0) {
97 _canvas_display = new Group (ed.get_trackview_group (), ArdourCanvas::Duple (0.0, 0.0));
98 _canvas_display->hide(); // reveal as needed
100 selection_group = new Group (_canvas_display);
101 selection_group->set_data (X_("timeselection"), (void *) 1);
102 selection_group->hide();
104 _ghost_group = new Group (_canvas_display);
105 _ghost_group->lower_to_bottom();
106 _ghost_group->show();
108 name_label.set_name ("TrackLabel");
109 name_label.set_alignment (0.0, 0.5);
110 ARDOUR_UI::instance()->set_tip (name_label, _("Track/Bus name (double click to edit)"));
112 Gtk::Entry* an_entry = new Gtk::Entry;
113 Gtk::Requisition req;
114 an_entry->size_request (req);
115 name_label.set_size_request (-1, req.height);
118 name_hbox.pack_start (name_label, true, true);
122 controls_table.set_size_request (200);
123 controls_table.set_row_spacings (2);
124 controls_table.set_col_spacings (2);
125 controls_table.set_border_width (2);
126 controls_table.set_homogeneous (true);
128 controls_table.attach (name_hbox, 0, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 3, 0);
129 controls_table.show_all ();
130 controls_table.set_no_show_all ();
132 HSeparator* separator = manage (new HSeparator());
134 controls_vbox.pack_start (controls_table, false, false);
135 controls_vbox.show ();
137 //controls_ebox.set_name ("TimeAxisViewControlsBaseUnselected");
138 controls_ebox.add (controls_vbox);
139 controls_ebox.add_events (Gdk::BUTTON_PRESS_MASK|
140 Gdk::BUTTON_RELEASE_MASK|
141 Gdk::POINTER_MOTION_MASK|
142 Gdk::ENTER_NOTIFY_MASK|
143 Gdk::LEAVE_NOTIFY_MASK|
145 controls_ebox.set_flags (CAN_FOCUS);
147 /* note that this handler connects *before* the default handler */
148 controls_ebox.signal_scroll_event().connect (sigc::mem_fun (*this, &TimeAxisView::controls_ebox_scroll), true);
149 controls_ebox.signal_button_press_event().connect (sigc::mem_fun (*this, &TimeAxisView::controls_ebox_button_press));
150 controls_ebox.signal_button_release_event().connect (sigc::mem_fun (*this, &TimeAxisView::controls_ebox_button_release));
151 controls_ebox.signal_motion_notify_event().connect (sigc::mem_fun (*this, &TimeAxisView::controls_ebox_motion));
152 controls_ebox.signal_leave_notify_event().connect (sigc::mem_fun (*this, &TimeAxisView::controls_ebox_leave));
153 controls_ebox.show ();
155 controls_hbox.pack_start (controls_ebox, true, true);
156 controls_hbox.show ();
158 time_axis_vbox.pack_start (controls_hbox, true, true);
159 time_axis_vbox.pack_end (*separator, false, false);
160 time_axis_vbox.show();
162 ColorsChanged.connect (sigc::mem_fun (*this, &TimeAxisView::color_handler));
164 GhostRegion::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&TimeAxisView::erase_ghost, this, _1), gui_context());
167 TimeAxisView::~TimeAxisView()
169 in_destructor = true;
171 for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
175 for (list<SelectionRect*>::iterator i = free_selection_rects.begin(); i != free_selection_rects.end(); ++i) {
177 delete (*i)->start_trim;
178 delete (*i)->end_trim;
182 for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
184 delete (*i)->start_trim;
185 delete (*i)->end_trim;
188 delete selection_group;
191 delete _canvas_display;
201 TimeAxisView::hide ()
207 _canvas_display->hide ();
209 if (control_parent) {
210 control_parent->remove (time_axis_vbox);
217 /* now hide children */
219 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
223 /* if its hidden, it cannot be selected */
224 _editor.get_selection().remove (this);
225 /* and neither can its regions */
226 _editor.get_selection().remove_regions (this);
231 /** Display this TimeAxisView as the nth component of the parent box, at y.
233 * @param y y position.
234 * @param nth index for this TimeAxisView, increased if this view has children.
235 * @param parent parent component.
236 * @return height of this TimeAxisView.
239 TimeAxisView::show_at (double y, int& nth, VBox *parent)
241 if (control_parent) {
242 control_parent->reorder_child (time_axis_vbox, nth);
244 control_parent = parent;
245 parent->pack_start (time_axis_vbox, false, false);
246 parent->reorder_child (time_axis_vbox, nth);
251 if (_y_position != y) {
252 _canvas_display->set_y_position (y);
257 _canvas_display->raise_to_top ();
258 _canvas_display->show ();
262 _effective_height = current_height ();
264 /* now show relevant children */
266 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
267 if ((*i)->marked_for_display()) {
269 _effective_height += (*i)->show_at (y + _effective_height, nth, parent);
275 return _effective_height;
279 TimeAxisView::controls_ebox_scroll (GdkEventScroll* ev)
281 switch (ev->direction) {
283 if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
284 /* See Editor::_stepping_axis_view for notes on this hack */
285 Editor& e = dynamic_cast<Editor&> (_editor);
286 if (!e.stepping_axis_view ()) {
287 e.set_stepping_axis_view (this);
289 e.stepping_axis_view()->step_height (false);
291 } else if (Keyboard::no_modifiers_active (ev->state)) {
292 _editor.scroll_tracks_up_line();
297 case GDK_SCROLL_DOWN:
298 if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
299 /* See Editor::_stepping_axis_view for notes on this hack */
300 Editor& e = dynamic_cast<Editor&> (_editor);
301 if (!e.stepping_axis_view ()) {
302 e.set_stepping_axis_view (this);
304 e.stepping_axis_view()->step_height (true);
306 } else if (Keyboard::no_modifiers_active (ev->state)) {
307 _editor.scroll_tracks_down_line();
313 /* no handling for left/right, yet */
321 TimeAxisView::controls_ebox_button_press (GdkEventButton* event)
323 if ((event->button == 1 && event->type == GDK_2BUTTON_PRESS) || Keyboard::is_edit_event (event)) {
324 /* see if it is inside the name label */
325 if (name_label.is_ancestor (controls_ebox)) {
328 controls_ebox.translate_coordinates (name_label, event->x, event->y, nlx, nly);
329 Gtk::Allocation a = name_label.get_allocation ();
330 if (nlx > 0 && nlx < a.get_width() && nly > 0 && nly < a.get_height()) {
332 _ebox_release_can_act = false;
339 _ebox_release_can_act = true;
341 if (maybe_set_cursor (event->y) > 0) {
342 _resize_drag_start = event->y_root;
349 TimeAxisView::idle_resize (uint32_t h)
356 TimeAxisView::controls_ebox_motion (GdkEventMotion* ev)
358 if (_resize_drag_start >= 0) {
359 /* (ab)use the DragManager to do autoscrolling; adjust the event coordinates
360 into the world coordinate space that DragManager::motion_handler is expecting,
361 and then fake a DragManager motion event so that when maybe_autoscroll
362 asks DragManager for the current pointer position it will get the correct
366 controls_ebox.translate_coordinates (*control_parent, ev->x, ev->y, tx, ty);
368 _editor.drags()->motion_handler ((GdkEvent *) ev, false);
369 _editor.maybe_autoscroll (false, true, false, ev->y_root < _resize_drag_start);
371 /* now do the actual TAV resize */
372 int32_t const delta = (int32_t) floor (ev->y_root - _resize_drag_start);
373 _editor.add_to_idle_resize (this, delta);
374 _resize_drag_start = ev->y_root;
376 /* not dragging but ... */
377 maybe_set_cursor (ev->y);
384 TimeAxisView::controls_ebox_leave (GdkEventCrossing*)
386 if (_have_preresize_cursor) {
387 gdk_window_set_cursor (controls_ebox.get_window()->gobj(), _preresize_cursor);
388 _have_preresize_cursor = false;
394 TimeAxisView::maybe_set_cursor (int y)
396 /* XXX no Gtkmm Gdk::Window::get_cursor() */
397 Glib::RefPtr<Gdk::Window> win = controls_ebox.get_window();
399 if (y > (gint) floor (controls_ebox.get_height() * 0.75)) {
401 /* y-coordinate in lower 25% */
403 if (!_have_preresize_cursor) {
404 _preresize_cursor = gdk_window_get_cursor (win->gobj());
405 _have_preresize_cursor = true;
406 win->set_cursor (Gdk::Cursor(Gdk::SB_V_DOUBLE_ARROW));
411 } else if (_have_preresize_cursor) {
412 gdk_window_set_cursor (win->gobj(), _preresize_cursor);
413 _have_preresize_cursor = false;
422 TimeAxisView::controls_ebox_button_release (GdkEventButton* ev)
424 if (_resize_drag_start >= 0) {
425 if (_have_preresize_cursor) {
426 gdk_window_set_cursor (controls_ebox.get_window()->gobj(), _preresize_cursor);
427 _preresize_cursor = 0;
428 _have_preresize_cursor = false;
430 _editor.stop_canvas_autoscroll ();
431 _resize_drag_start = -1;
434 if (!_ebox_release_can_act) {
438 switch (ev->button) {
440 selection_click (ev);
444 popup_display_menu (ev->time);
452 TimeAxisView::selection_click (GdkEventButton* ev)
454 Selection::Operation op = ArdourKeyboard::selection_type (ev->state);
455 _editor.set_selected_track (*this, op, false);
459 /** Steps through the defined heights for this TrackView.
460 * @param coarser true if stepping should decrease in size, otherwise false.
463 TimeAxisView::step_height (bool coarser)
465 static const uint32_t step = 25;
469 if (height <= preset_height (HeightSmall)) {
471 } else if (height <= preset_height (HeightNormal) && height > preset_height (HeightSmall)) {
472 set_height_enum (HeightSmall);
474 set_height (height - step);
479 if (height <= preset_height(HeightSmall)) {
480 set_height_enum (HeightNormal);
482 set_height (height + step);
489 TimeAxisView::set_height_enum (Height h, bool apply_to_selection)
491 if (apply_to_selection) {
492 _editor.get_selection().tracks.foreach_time_axis (boost::bind (&TimeAxisView::set_height_enum, _1, h, false));
494 set_height (preset_height (h));
499 TimeAxisView::set_height (uint32_t h)
501 if (h < preset_height (HeightSmall)) {
502 h = preset_height (HeightSmall);
505 time_axis_vbox.property_height_request () = h;
509 snprintf (buf, sizeof (buf), "%u", height);
510 set_gui_property ("height", buf);
512 for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
516 if (selection_group->visible ()) {
517 /* resize the selection rect */
518 show_selection (_editor.get_selection().time);
523 TimeAxisView::name_entry_key_press (GdkEventKey* ev)
525 /* steal escape, tabs from GTK */
527 switch (ev->keyval) {
529 case GDK_ISO_Left_Tab:
537 TimeAxisView::name_entry_key_release (GdkEventKey* ev)
539 TrackViewList::iterator i;
541 switch (ev->keyval) {
543 end_name_edit (RESPONSE_CANCEL);
546 /* Shift+Tab Keys Pressed. Note that for Shift+Tab, GDK actually
547 * generates a different ev->keyval, rather than setting
550 case GDK_ISO_Left_Tab:
551 end_name_edit (RESPONSE_APPLY);
555 end_name_edit (RESPONSE_ACCEPT);
565 TimeAxisView::name_entry_focus_out (GdkEventFocus*)
567 end_name_edit (RESPONSE_OK);
572 TimeAxisView::begin_name_edit ()
578 if (can_edit_name()) {
580 name_entry = manage (new Gtkmm2ext::FocusEntry);
582 name_entry->set_name ("EditorTrackNameDisplay");
583 name_entry->signal_key_press_event().connect (sigc::mem_fun (*this, &TimeAxisView::name_entry_key_press), false);
584 name_entry->signal_key_release_event().connect (sigc::mem_fun (*this, &TimeAxisView::name_entry_key_release), false);
585 name_entry->signal_focus_out_event().connect (sigc::mem_fun (*this, &TimeAxisView::name_entry_focus_out));
586 name_entry->set_text (name_label.get_text());
587 name_entry->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &TimeAxisView::end_name_edit), RESPONSE_OK));
589 if (name_label.is_ancestor (name_hbox)) {
590 name_hbox.remove (name_label);
593 name_hbox.pack_start (*name_entry);
596 name_entry->select_region (0, -1);
597 name_entry->set_state (STATE_SELECTED);
598 name_entry->grab_focus ();
599 name_entry->start_editing (0);
604 TimeAxisView::end_name_edit (int response)
610 bool edit_next = false;
611 bool edit_prev = false;
614 case RESPONSE_CANCEL:
617 name_entry_changed ();
619 case RESPONSE_ACCEPT:
620 name_entry_changed ();
623 name_entry_changed ();
627 /* this will delete the name_entry. but it will also drop focus, which
628 * will cause another callback to this function, so set name_entry = 0
629 * first to ensure we don't double-remove etc. etc.
632 Gtk::Entry* tmp = name_entry;
634 name_hbox.remove (*tmp);
636 /* put the name label back */
638 name_hbox.pack_start (name_label);
643 TrackViewList const & allviews = _editor.get_track_views ();
644 TrackViewList::const_iterator i = find (allviews.begin(), allviews.end(), this);
646 if (i != allviews.end()) {
649 if (++i == allviews.end()) {
653 RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*>(*i);
655 if (rtav && rtav->route()->record_enabled()) {
659 if (!(*i)->hidden()) {
666 if ((i != allviews.end()) && (*i != this) && !(*i)->hidden()) {
667 _editor.ensure_time_axis_view_is_visible (**i);
668 (*i)->begin_name_edit ();
671 } else if (edit_prev) {
673 TrackViewList const & allviews = _editor.get_track_views ();
674 TrackViewList::const_iterator i = find (allviews.begin(), allviews.end(), this);
676 if (i != allviews.begin()) {
678 if (i == allviews.begin()) {
684 RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*>(*i);
686 if (rtav && rtav->route()->record_enabled()) {
690 if (!(*i)->hidden()) {
697 if ((i != allviews.end()) && (*i != this) && !(*i)->hidden()) {
698 _editor.ensure_time_axis_view_is_visible (**i);
699 (*i)->begin_name_edit ();
705 TimeAxisView::name_entry_changed ()
710 TimeAxisView::can_edit_name () const
716 TimeAxisView::conditionally_add_to_selection ()
718 Selection& s (_editor.get_selection ());
720 if (!s.selected (this)) {
721 _editor.set_selected_track (*this, Selection::Set);
726 TimeAxisView::popup_display_menu (guint32 when)
728 conditionally_add_to_selection ();
730 build_display_menu ();
731 display_menu->popup (1, when);
735 TimeAxisView::set_selected (bool yn)
737 if (yn == _selected) {
741 Selectable::set_selected (yn);
744 controls_ebox.set_name (controls_base_selected_name);
745 time_axis_vbox.set_name (controls_base_selected_name);
746 controls_vbox.set_name (controls_base_selected_name);
748 controls_ebox.set_name (controls_base_unselected_name);
749 time_axis_vbox.set_name (controls_base_unselected_name);
750 controls_vbox.set_name (controls_base_unselected_name);
753 /* children will be set for the yn=true case. but when deselecting
754 the editor only has a list of top-level trackviews, so we
755 have to do this here.
758 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
759 (*i)->set_selected (false);
765 TimeAxisView::build_display_menu ()
767 using namespace Menu_Helpers;
771 display_menu = new Menu;
772 display_menu->set_name ("ArdourContextMenu");
774 // Just let implementing classes define what goes into the manu
778 TimeAxisView::set_samples_per_pixel (double fpp)
780 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
781 (*i)->set_samples_per_pixel (fpp);
784 AnalysisFeatureList::const_iterator i;
785 list<ArdourCanvas::Line*>::iterator l;
789 TimeAxisView::show_timestretch (framepos_t start, framepos_t end, int layers, int layer)
791 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
792 (*i)->show_timestretch (start, end, layers, layer);
797 TimeAxisView::hide_timestretch ()
799 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
800 (*i)->hide_timestretch ();
805 TimeAxisView::show_selection (TimeSelection& ts)
812 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
813 (*i)->show_selection (ts);
816 if (selection_group->visible ()) {
817 while (!used_selection_rects.empty()) {
818 free_selection_rects.push_front (used_selection_rects.front());
819 used_selection_rects.pop_front();
820 free_selection_rects.front()->rect->hide();
821 free_selection_rects.front()->start_trim->hide();
822 free_selection_rects.front()->end_trim->hide();
824 selection_group->hide();
827 selection_group->show();
828 selection_group->raise_to_top();
830 for (list<AudioRange>::iterator i = ts.begin(); i != ts.end(); ++i) {
831 framepos_t start, end;
836 cnt = end - start + 1;
838 rect = get_selection_rect ((*i).id);
840 x1 = _editor.sample_to_pixel (start);
841 x2 = _editor.sample_to_pixel (start + cnt - 1);
842 y2 = current_height();
844 rect->rect->set (ArdourCanvas::Rect (x1, 1, x2, y2));
846 // trim boxes are at the top for selections
849 rect->start_trim->set (ArdourCanvas::Rect (x1, 1, x1 + trim_handle_size, y2));
850 rect->end_trim->set (ArdourCanvas::Rect (x2 - trim_handle_size, 1, x2, y2));
852 rect->start_trim->show();
853 rect->end_trim->show();
855 rect->start_trim->hide();
856 rect->end_trim->hide();
860 used_selection_rects.push_back (rect);
865 TimeAxisView::reshow_selection (TimeSelection& ts)
869 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
870 (*i)->show_selection (ts);
875 TimeAxisView::hide_selection ()
877 if (selection_group->visible ()) {
878 while (!used_selection_rects.empty()) {
879 free_selection_rects.push_front (used_selection_rects.front());
880 used_selection_rects.pop_front();
881 free_selection_rects.front()->rect->hide();
882 free_selection_rects.front()->start_trim->hide();
883 free_selection_rects.front()->end_trim->hide();
885 selection_group->hide();
888 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
889 (*i)->hide_selection ();
894 TimeAxisView::order_selection_trims (ArdourCanvas::Item *item, bool put_start_on_top)
896 /* find the selection rect this is for. we have the item corresponding to one
900 for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
901 if ((*i)->start_trim == item || (*i)->end_trim == item) {
903 /* make one trim handle be "above" the other so that if they overlap,
904 the top one is the one last used.
907 (*i)->rect->raise_to_top ();
908 (put_start_on_top ? (*i)->start_trim : (*i)->end_trim)->raise_to_top ();
909 (put_start_on_top ? (*i)->end_trim : (*i)->start_trim)->raise_to_top ();
917 TimeAxisView::get_selection_rect (uint32_t id)
921 /* check to see if we already have a visible rect for this particular selection ID */
923 for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
924 if ((*i)->id == id) {
929 /* ditto for the free rect list */
931 for (list<SelectionRect*>::iterator i = free_selection_rects.begin(); i != free_selection_rects.end(); ++i) {
932 if ((*i)->id == id) {
933 SelectionRect* ret = (*i);
934 free_selection_rects.erase (i);
939 /* no existing matching rect, so go get a new one from the free list, or create one if there are none */
941 if (free_selection_rects.empty()) {
943 rect = new SelectionRect;
945 rect->rect = new ArdourCanvas::Rectangle (selection_group);
946 rect->rect->set_outline_what (0);
947 rect->rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_SelectionRect());
949 rect->start_trim = new ArdourCanvas::Rectangle (selection_group);
950 rect->start_trim->set_outline_what (0);
952 rect->end_trim = new ArdourCanvas::Rectangle (selection_group);
953 rect->end_trim->set_outline_what (0);
955 free_selection_rects.push_front (rect);
957 rect->rect->Event.connect (sigc::bind (sigc::mem_fun (_editor, &PublicEditor::canvas_selection_rect_event), rect->rect, rect));
958 rect->start_trim->Event.connect (sigc::bind (sigc::mem_fun (_editor, &PublicEditor::canvas_selection_start_trim_event), rect->rect, rect));
959 rect->end_trim->Event.connect (sigc::bind (sigc::mem_fun (_editor, &PublicEditor::canvas_selection_end_trim_event), rect->rect, rect));
962 rect = free_selection_rects.front();
964 free_selection_rects.pop_front();
968 struct null_deleter { void operator()(void const *) const {} };
971 TimeAxisView::is_child (TimeAxisView* tav)
973 return find (children.begin(), children.end(), boost::shared_ptr<TimeAxisView>(tav, null_deleter())) != children.end();
977 TimeAxisView::add_child (boost::shared_ptr<TimeAxisView> child)
979 children.push_back (child);
983 TimeAxisView::remove_child (boost::shared_ptr<TimeAxisView> child)
985 Children::iterator i;
987 if ((i = find (children.begin(), children.end(), child)) != children.end()) {
992 /** Get selectable things within a given range.
993 * @param start Start time in session frames.
994 * @param end End time in session frames.
995 * @param top Top y range, in trackview coordinates (ie 0 is the top of the track view)
996 * @param bot Bottom y range, in trackview coordinates (ie 0 is the top of the track view)
997 * @param result Filled in with selectable things.
1000 TimeAxisView::get_selectables (framepos_t /*start*/, framepos_t /*end*/, double /*top*/, double /*bot*/, list<Selectable*>& /*result*/)
1006 TimeAxisView::get_inverted_selectables (Selection& /*sel*/, list<Selectable*>& /*result*/)
1012 TimeAxisView::add_ghost (RegionView* rv)
1014 GhostRegion* gr = rv->add_ghost (*this);
1017 ghosts.push_back(gr);
1022 TimeAxisView::remove_ghost (RegionView* rv)
1024 rv->remove_ghost_in (*this);
1028 TimeAxisView::erase_ghost (GhostRegion* gr)
1030 if (in_destructor) {
1034 for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
1043 TimeAxisView::touched (double top, double bot)
1045 /* remember: this is X Window - coordinate space starts in upper left and moves down.
1046 y_position is the "origin" or "top" of the track.
1049 double mybot = _y_position + current_height();
1051 return ((_y_position <= bot && _y_position >= top) ||
1052 ((mybot <= bot) && (top < mybot)) ||
1053 (mybot >= bot && _y_position < top));
1057 TimeAxisView::set_parent (TimeAxisView& p)
1063 TimeAxisView::reset_height ()
1065 set_height (height);
1067 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1068 (*i)->set_height ((*i)->height);
1073 TimeAxisView::compute_heights ()
1075 Gtk::Window window (Gtk::WINDOW_TOPLEVEL);
1076 Gtk::Table two_row_table (2, 8);
1077 Gtk::Table one_row_table (1, 8);
1079 const int border_width = 2;
1081 const int separator_height = 2;
1082 extra_height = (2 * border_width) + separator_height;
1084 window.add (one_row_table);
1086 one_row_table.set_border_width (border_width);
1087 one_row_table.set_row_spacings (0);
1088 one_row_table.set_col_spacings (0);
1089 one_row_table.set_homogeneous (true);
1091 two_row_table.set_border_width (border_width);
1092 two_row_table.set_row_spacings (0);
1093 two_row_table.set_col_spacings (0);
1094 two_row_table.set_homogeneous (true);
1096 for (int i = 0; i < 5; ++i) {
1097 buttons[i] = manage (new Button (X_("f")));
1098 buttons[i]->set_name ("TrackMuteButton");
1101 one_row_table.attach (*buttons[0], 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
1103 one_row_table.show_all ();
1104 Gtk::Requisition req(one_row_table.size_request ());
1106 // height required to show 1 row of buttons
1107 button_height = req.height;
1111 TimeAxisView::color_handler ()
1113 for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); i++) {
1117 for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
1119 (*i)->rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_SelectionRect());
1120 (*i)->rect->set_outline_color (ARDOUR_UI::config()->get_canvasvar_Selection());
1122 (*i)->start_trim->set_fill_color (ARDOUR_UI::config()->get_canvasvar_Selection());
1123 (*i)->start_trim->set_outline_color (ARDOUR_UI::config()->get_canvasvar_Selection());
1125 (*i)->end_trim->set_fill_color (ARDOUR_UI::config()->get_canvasvar_Selection());
1126 (*i)->end_trim->set_outline_color (ARDOUR_UI::config()->get_canvasvar_Selection());
1129 for (list<SelectionRect*>::iterator i = free_selection_rects.begin(); i != free_selection_rects.end(); ++i) {
1131 (*i)->rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_SelectionRect());
1132 (*i)->rect->set_outline_color (ARDOUR_UI::config()->get_canvasvar_Selection());
1134 (*i)->start_trim->set_fill_color (ARDOUR_UI::config()->get_canvasvar_Selection());
1135 (*i)->start_trim->set_outline_color (ARDOUR_UI::config()->get_canvasvar_Selection());
1137 (*i)->end_trim->set_fill_color (ARDOUR_UI::config()->get_canvasvar_Selection());
1138 (*i)->end_trim->set_outline_color (ARDOUR_UI::config()->get_canvasvar_Selection());
1142 /** @return Pair: TimeAxisView, layer index.
1143 * TimeAxisView is non-0 if this object covers y, or one of its children does.
1144 * If the covering object is a child axis, then the child is returned.
1145 * TimeAxisView is 0 otherwise.
1146 * Layer index is the layer number (possibly fractional) if the TimeAxisView is valid
1147 * and is in stacked or expanded * region display mode, otherwise 0.
1149 std::pair<TimeAxisView*, double>
1150 TimeAxisView::covers_y_position (double y)
1153 return std::make_pair ((TimeAxisView *) 0, 0);
1156 if (_y_position <= y && y < (_y_position + height)) {
1158 /* work out the layer index if appropriate */
1160 switch (layer_display ()) {
1166 l = layer_t ((_y_position + height - y) / (view()->child_height ()));
1167 /* clamp to max layers to be on the safe side; sometimes the above calculation
1168 returns a too-high value */
1169 if (l >= view()->layers ()) {
1170 l = view()->layers() - 1;
1176 int const n = floor ((_y_position + height - y) / (view()->child_height ()));
1178 if (l >= (view()->layers() - 0.5)) {
1179 l = view()->layers() - 0.5;
1185 return std::make_pair (this, l);
1188 for (Children::const_iterator i = children.begin(); i != children.end(); ++i) {
1190 std::pair<TimeAxisView*, int> const r = (*i)->covers_y_position (y);
1196 return std::make_pair ((TimeAxisView *) 0, 0);
1201 TimeAxisView::preset_height (Height h)
1205 return (button_height * 2) + extra_height + 260;
1207 return (button_height * 2) + extra_height + 160;
1209 return (button_height * 2) + extra_height + 60;
1211 return (button_height * 2) + extra_height + 10;
1213 return button_height + extra_height;
1220 /** @return Child time axis views that are not hidden */
1221 TimeAxisView::Children
1222 TimeAxisView::get_child_list ()
1226 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1227 if (!(*i)->hidden()) {
1236 TimeAxisView::build_size_menu ()
1238 if (_size_menu && _size_menu->gobj ()) {
1244 using namespace Menu_Helpers;
1246 _size_menu = new Menu;
1247 _size_menu->set_name ("ArdourContextMenu");
1248 MenuList& items = _size_menu->items();
1250 items.push_back (MenuElem (_("Largest"), sigc::bind (sigc::mem_fun (*this, &TimeAxisView::set_height_enum), HeightLargest, true)));
1251 items.push_back (MenuElem (_("Larger"), sigc::bind (sigc::mem_fun (*this, &TimeAxisView::set_height_enum), HeightLarger, true)));
1252 items.push_back (MenuElem (_("Large"), sigc::bind (sigc::mem_fun (*this, &TimeAxisView::set_height_enum), HeightLarge, true)));
1253 items.push_back (MenuElem (_("Normal"), sigc::bind (sigc::mem_fun (*this, &TimeAxisView::set_height_enum), HeightNormal, true)));
1254 items.push_back (MenuElem (_("Small"), sigc::bind (sigc::mem_fun (*this, &TimeAxisView::set_height_enum), HeightSmall, true)));
1258 TimeAxisView::reset_visual_state ()
1260 /* this method is not required to trigger a global redraw */
1262 string str = gui_property ("height");
1265 set_height (atoi (str));
1267 set_height (preset_height (HeightNormal));
1272 TrackViewList::filter_to_unique_playlists ()
1274 std::set<boost::shared_ptr<ARDOUR::Playlist> > playlists;
1277 for (iterator i = begin(); i != end(); ++i) {
1278 RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*> (*i);
1280 /* not a route: include it anyway */
1283 boost::shared_ptr<ARDOUR::Track> t = rtav->track();
1285 if (playlists.insert (t->playlist()).second) {
1286 /* playlist not seen yet */
1290 /* not a track: include it anyway */