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.
26 #include <libgnomecanvasmm.h>
27 #include <libgnomecanvasmm/canvas.h>
28 #include <libgnomecanvasmm/item.h>
30 #include "pbd/error.h"
31 #include "pbd/convert.h"
33 #include <gtkmm2ext/utils.h>
34 #include <gtkmm2ext/selector.h>
36 #include "ardour/session.h"
37 #include "ardour/utils.h"
38 #include "ardour/ladspa_plugin.h"
39 #include "ardour/processor.h"
40 #include "ardour/location.h"
42 #include "ardour_ui.h"
43 #include "global_signals.h"
44 #include "gui_thread.h"
45 #include "public_editor.h"
46 #include "time_axis_view.h"
47 #include "region_view.h"
48 #include "ghostregion.h"
49 #include "simplerect.h"
50 #include "simpleline.h"
51 #include "selection.h"
53 #include "rgb_macros.h"
55 #include "streamview.h"
56 #include "editor_drag.h"
63 using namespace ARDOUR;
65 using namespace Editing;
66 using namespace ArdourCanvas;
67 using Gtkmm2ext::Keyboard;
69 const double trim_handle_size = 6.0; /* pixels */
70 uint32_t TimeAxisView::extra_height;
71 uint32_t TimeAxisView::small_height;
72 int const TimeAxisView::_max_order = 512;
73 PBD::Signal1<void,TimeAxisView*> TimeAxisView::CatchDeletion;
75 TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisView* rent, Canvas& /*canvas*/)
77 , controls_table (2, 8)
83 if (extra_height == 0) {
87 _canvas_background = new Group (*ed.get_background_group (), 0.0, 0.0);
88 _canvas_display = new Group (*ed.get_trackview_group (), 0.0, 0.0);
89 _canvas_display->hide(); // reveal as needed
91 selection_group = new Group (*_canvas_display);
92 selection_group->set_data (X_("timeselection"), (void *) 1);
93 selection_group->hide();
95 _ghost_group = new Group (*_canvas_display);
96 _ghost_group->lower_to_bottom();
102 in_destructor = false;
104 _effective_height = 0;
106 last_name_entry_key_press_event = 0;
107 name_packing = NamePackingBits (0);
108 _resize_drag_start = -1;
111 Create the standard LHS Controls
112 We create the top-level container and name add the name label here,
113 subclasses can add to the layout as required
116 name_entry.set_name ("EditorTrackNameDisplay");
117 name_entry.signal_button_release_event().connect (sigc::mem_fun (*this, &TimeAxisView::name_entry_button_release));
118 name_entry.signal_button_press_event().connect (sigc::mem_fun (*this, &TimeAxisView::name_entry_button_press));
119 name_entry.signal_key_release_event().connect (sigc::mem_fun (*this, &TimeAxisView::name_entry_key_release));
120 name_entry.signal_activate().connect (sigc::mem_fun(*this, &TimeAxisView::name_entry_activated));
121 name_entry.signal_focus_in_event().connect (sigc::mem_fun (*this, &TimeAxisView::name_entry_focus_in));
122 name_entry.signal_focus_out_event().connect (sigc::mem_fun (*this, &TimeAxisView::name_entry_focus_out));
123 Gtkmm2ext::set_size_request_to_display_given_text (name_entry, N_("gTortnam"), 10, 10); // just represents a short name
125 name_label.set_name ("TrackLabel");
126 name_label.set_alignment (0.0, 0.5);
128 /* typically, either name_label OR name_entry are visible,
129 but not both. its up to derived classes to show/hide them as they
135 controls_table.set_size_request (200);
136 controls_table.set_row_spacings (0);
137 controls_table.set_col_spacings (0);
138 controls_table.set_homogeneous (true);
140 controls_table.attach (name_hbox, 0, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 3, 0);
141 controls_table.show_all ();
142 controls_table.set_no_show_all ();
144 resizer.set_size_request (10, 6);
145 resizer.set_name ("ResizeHandle");
146 resizer.signal_expose_event().connect (sigc::mem_fun (*this, &TimeAxisView::resizer_expose));
147 resizer.signal_button_press_event().connect (sigc::mem_fun (*this, &TimeAxisView::resizer_button_press));
148 resizer.signal_button_release_event().connect (sigc::mem_fun (*this, &TimeAxisView::resizer_button_release));
149 resizer.signal_motion_notify_event().connect (sigc::mem_fun (*this, &TimeAxisView::resizer_motion));
151 resizer.set_events (Gdk::BUTTON_PRESS_MASK|
152 Gdk::BUTTON_RELEASE_MASK|
153 Gdk::POINTER_MOTION_MASK|
156 resizer_box.pack_start (resizer, false, false);
160 HSeparator* separator = manage (new HSeparator());
162 controls_vbox.pack_start (controls_table, false, false);
163 controls_vbox.pack_end (resizer_box, false, false);
164 controls_vbox.show ();
166 //controls_ebox.set_name ("TimeAxisViewControlsBaseUnselected");
167 controls_ebox.add (controls_vbox);
168 controls_ebox.add_events (BUTTON_PRESS_MASK|BUTTON_RELEASE_MASK|SCROLL_MASK);
169 controls_ebox.set_flags (CAN_FOCUS);
171 controls_ebox.signal_button_release_event().connect (sigc::mem_fun (*this, &TimeAxisView::controls_ebox_button_release));
172 controls_ebox.signal_scroll_event().connect (sigc::mem_fun (*this, &TimeAxisView::controls_ebox_scroll), true);
173 controls_ebox.show ();
175 controls_hbox.pack_start (controls_ebox, true, true);
176 controls_hbox.show ();
178 time_axis_vbox.pack_start (controls_hbox, true, true);
179 time_axis_vbox.pack_end (*separator, false, false);
180 time_axis_vbox.show();
182 ColorsChanged.connect (sigc::mem_fun (*this, &TimeAxisView::color_handler));
184 GhostRegion::CatchDeletion.connect (*this, invalidator (*this), ui_bind (&TimeAxisView::erase_ghost, this, _1), gui_context());
187 TimeAxisView::~TimeAxisView()
189 in_destructor = true;
191 for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
195 for (list<SelectionRect*>::iterator i = free_selection_rects.begin(); i != free_selection_rects.end(); ++i) {
197 delete (*i)->start_trim;
198 delete (*i)->end_trim;
202 for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
204 delete (*i)->start_trim;
205 delete (*i)->end_trim;
208 delete selection_group;
211 delete _canvas_background;
212 _canvas_background = 0;
214 delete _canvas_display;
224 TimeAxisView::hide ()
230 _canvas_display->hide ();
231 _canvas_background->hide ();
233 if (control_parent) {
234 control_parent->remove (time_axis_vbox);
241 /* now hide children */
243 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
247 /* if its hidden, it cannot be selected */
248 _editor.get_selection().remove (this);
249 /* and neither can its regions */
250 _editor.get_selection().remove_regions (this);
255 /** Display this TimeAxisView as the nth component of the parent box, at y.
257 * @param y y position.
258 * @param nth index for this TimeAxisView, increased if this view has children.
259 * @param parent parent component.
260 * @return height of this TimeAxisView.
263 TimeAxisView::show_at (double y, int& nth, VBox *parent)
265 if (control_parent) {
266 control_parent->reorder_child (time_axis_vbox, nth);
268 control_parent = parent;
269 parent->pack_start (time_axis_vbox, false, false);
270 parent->reorder_child (time_axis_vbox, nth);
275 if (_y_position != y) {
276 _canvas_display->property_y () = y;
277 _canvas_background->property_y () = y;
279 _canvas_display->move (0.0, 0.0);
280 _canvas_background->move (0.0, 0.0);
285 _canvas_background->raise_to_top ();
286 _canvas_display->raise_to_top ();
288 _canvas_background->show ();
289 _canvas_display->show ();
293 _effective_height = current_height ();
295 /* now show relevant children */
297 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
298 if ((*i)->marked_for_display()) {
300 _effective_height += (*i)->show_at (y + _effective_height, nth, parent);
306 return _effective_height;
310 TimeAxisView::clip_to_viewport ()
312 if (marked_for_display()) {
313 if (_y_position + _effective_height < _editor.get_trackview_group_vertical_offset () || _y_position > _editor.get_trackview_group_vertical_offset () + _canvas_display->get_canvas()->get_height()) {
314 _canvas_background->hide ();
315 _canvas_display->hide ();
318 _canvas_background->show ();
319 _canvas_display->show ();
325 TimeAxisView::controls_ebox_scroll (GdkEventScroll* ev)
327 if (Keyboard::some_magic_widget_has_focus()) {
331 switch (ev->direction) {
333 if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
336 } else if (Keyboard::no_modifiers_active (ev->state)) {
337 _editor.scroll_tracks_up_line();
342 case GDK_SCROLL_DOWN:
343 if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
346 } else if (Keyboard::no_modifiers_active (ev->state)) {
347 _editor.scroll_tracks_down_line();
353 /* no handling for left/right, yet */
361 TimeAxisView::controls_ebox_button_release (GdkEventButton* ev)
363 switch (ev->button) {
365 selection_click (ev);
369 popup_display_menu (ev->time);
377 TimeAxisView::selection_click (GdkEventButton* ev)
379 Selection::Operation op = ArdourKeyboard::selection_type (ev->state);
380 _editor.set_selected_track (*this, op, false);
384 /** Steps through the defined heights for this TrackView.
385 * @param coarser true if stepping should decrease in size, otherwise false.
388 TimeAxisView::step_height (bool coarser)
390 static const uint32_t step = 25;
394 if (height <= preset_height (HeightSmall)) {
396 } else if (height <= preset_height (HeightNormal) && height > preset_height (HeightSmall)) {
397 set_height_enum (HeightSmall);
399 set_height (height - step);
404 if (height <= preset_height(HeightSmall)) {
405 set_height_enum (HeightNormal);
407 set_height (height + step);
414 TimeAxisView::set_heights (uint32_t h)
416 TrackSelection& ts (_editor.get_selection().tracks);
418 for (TrackSelection::iterator i = ts.begin(); i != ts.end(); ++i) {
419 (*i)->set_height (h);
424 TimeAxisView::set_height_enum (Height h, bool apply_to_selection)
426 if (apply_to_selection) {
427 _editor.get_selection().tracks.foreach_time_axis (boost::bind (&TimeAxisView::set_height_enum, _1, h, false));
429 set_height (preset_height (h));
434 TimeAxisView::set_height (uint32_t h)
436 if (h < preset_height (HeightSmall)) {
437 h = preset_height (HeightSmall);
440 time_axis_vbox.property_height_request () = h;
444 snprintf (buf, sizeof (buf), "%u", height);
445 set_gui_property ("height", buf);
447 for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
451 if (canvas_item_visible (selection_group)) {
452 /* resize the selection rect */
453 show_selection (_editor.get_selection().time);
458 TimeAxisView::name_entry_key_release (GdkEventKey* ev)
460 TrackViewList::iterator i;
462 switch (ev->keyval) {
464 name_entry.select_region (0,0);
465 controls_ebox.grab_focus ();
466 name_entry_changed ();
469 /* Shift+Tab Keys Pressed. Note that for Shift+Tab, GDK actually
470 * generates a different ev->keyval, rather than setting
473 case GDK_ISO_Left_Tab:
476 name_entry_changed ();
477 TrackViewList const & allviews = _editor.get_track_views ();
478 TrackViewList::const_iterator i = find (allviews.begin(), allviews.end(), this);
479 if (ev->keyval == GDK_Tab) {
480 if (i != allviews.end()) {
482 if (++i == allviews.end()) {
485 } while((*i)->hidden());
488 if (i != allviews.begin()) {
490 if (i == allviews.begin()) {
494 } while ((*i)->hidden());
498 (*i)->name_entry.grab_focus();
504 name_entry_changed ();
511 #ifdef TIMEOUT_NAME_EDIT
512 /* adapt the timeout to reflect the user's typing speed */
514 guint32 name_entry_timeout;
516 if (last_name_entry_key_press_event) {
517 /* timeout is 1/2 second or 5 times their current inter-char typing speed */
518 name_entry_timeout = std::max (500U, (5 * (ev->time - last_name_entry_key_press_event)));
520 /* start with a 1 second timeout */
521 name_entry_timeout = 1000;
524 last_name_entry_key_press_event = ev->time;
526 /* wait 1 seconds and if no more keys are pressed, act as if they pressed enter */
528 name_entry_key_timeout.disconnect();
529 name_entry_key_timeout = Glib::signal_timeout().connect (sigc::mem_fun (*this, &TimeAxisView::name_entry_key_timed_out), name_entry_timeout);
536 TimeAxisView::name_entry_focus_in (GdkEventFocus*)
538 name_entry.select_region (0, -1);
539 name_entry.set_name ("EditorActiveTrackNameDisplay");
544 TimeAxisView::name_entry_focus_out (GdkEventFocus*)
548 last_name_entry_key_press_event = 0;
549 name_entry_key_timeout.disconnect ();
550 name_entry.set_name ("EditorTrackNameDisplay");
551 name_entry.select_region (0,0);
553 /* do the real stuff */
555 name_entry_changed ();
561 TimeAxisView::name_entry_key_timed_out ()
563 name_entry_activated();
568 TimeAxisView::name_entry_activated ()
570 controls_ebox.grab_focus();
574 TimeAxisView::name_entry_changed ()
579 TimeAxisView::name_entry_button_press (GdkEventButton *ev)
581 if (ev->button == 3) {
588 TimeAxisView::name_entry_button_release (GdkEventButton *ev)
590 if (ev->button == 3) {
591 popup_display_menu (ev->time);
598 TimeAxisView::conditionally_add_to_selection ()
600 Selection& s (_editor.get_selection ());
602 if (!s.selected (this)) {
603 _editor.set_selected_track (*this, Selection::Set);
608 TimeAxisView::popup_display_menu (guint32 when)
610 conditionally_add_to_selection ();
612 build_display_menu ();
613 display_menu->popup (1, when);
617 TimeAxisView::set_selected (bool yn)
619 if (yn == _selected) {
623 Selectable::set_selected (yn);
626 controls_ebox.set_name (controls_base_selected_name);
627 time_axis_vbox.set_name (controls_base_selected_name);
628 controls_vbox.set_name (controls_base_selected_name);
630 controls_ebox.set_name (controls_base_unselected_name);
631 time_axis_vbox.set_name (controls_base_unselected_name);
632 controls_vbox.set_name (controls_base_unselected_name);
635 /* children will be set for the yn=true case. but when deselecting
636 the editor only has a list of top-level trackviews, so we
637 have to do this here.
640 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
641 (*i)->set_selected (false);
645 resizer.queue_draw ();
649 TimeAxisView::build_display_menu ()
651 using namespace Menu_Helpers;
655 display_menu = new Menu;
656 display_menu->set_name ("ArdourContextMenu");
658 // Just let implementing classes define what goes into the manu
662 TimeAxisView::set_samples_per_unit (double spu)
664 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
665 (*i)->set_samples_per_unit (spu);
668 AnalysisFeatureList::const_iterator i;
669 list<ArdourCanvas::SimpleLine*>::iterator l;
673 TimeAxisView::show_timestretch (framepos_t start, framepos_t end)
675 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
676 (*i)->show_timestretch (start, end);
681 TimeAxisView::hide_timestretch ()
683 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
684 (*i)->hide_timestretch ();
689 TimeAxisView::show_selection (TimeSelection& ts)
696 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
697 (*i)->show_selection (ts);
700 if (canvas_item_visible (selection_group)) {
701 while (!used_selection_rects.empty()) {
702 free_selection_rects.push_front (used_selection_rects.front());
703 used_selection_rects.pop_front();
704 free_selection_rects.front()->rect->hide();
705 free_selection_rects.front()->start_trim->hide();
706 free_selection_rects.front()->end_trim->hide();
708 selection_group->hide();
711 selection_group->show();
712 selection_group->raise_to_top();
714 for (list<AudioRange>::iterator i = ts.begin(); i != ts.end(); ++i) {
715 framepos_t start, end;
720 cnt = end - start + 1;
722 rect = get_selection_rect ((*i).id);
724 x1 = _editor.frame_to_unit (start);
725 x2 = _editor.frame_to_unit (start + cnt - 1);
726 y2 = current_height();
728 rect->rect->property_x1() = x1;
729 rect->rect->property_y1() = 1.0;
730 rect->rect->property_x2() = x2;
731 rect->rect->property_y2() = y2;
733 // trim boxes are at the top for selections
736 rect->start_trim->property_x1() = x1;
737 rect->start_trim->property_y1() = 1.0;
738 rect->start_trim->property_x2() = x1 + trim_handle_size;
739 rect->start_trim->property_y2() = y2;
741 rect->end_trim->property_x1() = x2 - trim_handle_size;
742 rect->end_trim->property_y1() = 1.0;
743 rect->end_trim->property_x2() = x2;
744 rect->end_trim->property_y2() = y2;
746 rect->start_trim->show();
747 rect->end_trim->show();
749 rect->start_trim->hide();
750 rect->end_trim->hide();
754 used_selection_rects.push_back (rect);
759 TimeAxisView::reshow_selection (TimeSelection& ts)
763 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
764 (*i)->show_selection (ts);
769 TimeAxisView::hide_selection ()
771 if (canvas_item_visible (selection_group)) {
772 while (!used_selection_rects.empty()) {
773 free_selection_rects.push_front (used_selection_rects.front());
774 used_selection_rects.pop_front();
775 free_selection_rects.front()->rect->hide();
776 free_selection_rects.front()->start_trim->hide();
777 free_selection_rects.front()->end_trim->hide();
779 selection_group->hide();
782 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
783 (*i)->hide_selection ();
788 TimeAxisView::order_selection_trims (ArdourCanvas::Item *item, bool put_start_on_top)
790 /* find the selection rect this is for. we have the item corresponding to one
794 for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
795 if ((*i)->start_trim == item || (*i)->end_trim == item) {
797 /* make one trim handle be "above" the other so that if they overlap,
798 the top one is the one last used.
801 (*i)->rect->raise_to_top ();
802 (put_start_on_top ? (*i)->start_trim : (*i)->end_trim)->raise_to_top ();
803 (put_start_on_top ? (*i)->end_trim : (*i)->start_trim)->raise_to_top ();
811 TimeAxisView::get_selection_rect (uint32_t id)
815 /* check to see if we already have a visible rect for this particular selection ID */
817 for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
818 if ((*i)->id == id) {
823 /* ditto for the free rect list */
825 for (list<SelectionRect*>::iterator i = free_selection_rects.begin(); i != free_selection_rects.end(); ++i) {
826 if ((*i)->id == id) {
827 SelectionRect* ret = (*i);
828 free_selection_rects.erase (i);
833 /* no existing matching rect, so go get a new one from the free list, or create one if there are none */
835 if (free_selection_rects.empty()) {
837 rect = new SelectionRect;
839 rect->rect = new SimpleRect (*selection_group);
840 rect->rect->property_outline_what() = 0x0;
841 rect->rect->property_x1() = 0.0;
842 rect->rect->property_y1() = 0.0;
843 rect->rect->property_x2() = 0.0;
844 rect->rect->property_y2() = 0.0;
845 rect->rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_SelectionRect.get();
847 rect->start_trim = new SimpleRect (*selection_group);
848 rect->start_trim->property_outline_what() = 0x0;
849 rect->start_trim->property_x1() = 0.0;
850 rect->start_trim->property_x2() = 0.0;
852 rect->end_trim = new SimpleRect (*selection_group);
853 rect->end_trim->property_outline_what() = 0x0;
854 rect->end_trim->property_x1() = 0.0;
855 rect->end_trim->property_x2() = 0.0;
857 free_selection_rects.push_front (rect);
859 rect->rect->signal_event().connect (sigc::bind (sigc::mem_fun (_editor, &PublicEditor::canvas_selection_rect_event), rect->rect, rect));
860 rect->start_trim->signal_event().connect (sigc::bind (sigc::mem_fun (_editor, &PublicEditor::canvas_selection_start_trim_event), rect->rect, rect));
861 rect->end_trim->signal_event().connect (sigc::bind (sigc::mem_fun (_editor, &PublicEditor::canvas_selection_end_trim_event), rect->rect, rect));
864 rect = free_selection_rects.front();
866 free_selection_rects.pop_front();
870 struct null_deleter { void operator()(void const *) const {} };
873 TimeAxisView::is_child (TimeAxisView* tav)
875 return find (children.begin(), children.end(), boost::shared_ptr<TimeAxisView>(tav, null_deleter())) != children.end();
879 TimeAxisView::add_child (boost::shared_ptr<TimeAxisView> child)
881 children.push_back (child);
885 TimeAxisView::remove_child (boost::shared_ptr<TimeAxisView> child)
887 Children::iterator i;
889 if ((i = find (children.begin(), children.end(), child)) != children.end()) {
894 /** Get selectable things within a given range.
895 * @param start Start time in session frames.
896 * @param end End time in session frames.
897 * @param top Top y range, in trackview coordinates (ie 0 is the top of the track view)
898 * @param bot Bottom y range, in trackview coordinates (ie 0 is the top of the track view)
899 * @param result Filled in with selectable things.
902 TimeAxisView::get_selectables (framepos_t /*start*/, framepos_t /*end*/, double /*top*/, double /*bot*/, list<Selectable*>& /*result*/)
908 TimeAxisView::get_inverted_selectables (Selection& /*sel*/, list<Selectable*>& /*result*/)
914 TimeAxisView::add_ghost (RegionView* rv)
916 GhostRegion* gr = rv->add_ghost (*this);
919 ghosts.push_back(gr);
924 TimeAxisView::remove_ghost (RegionView* rv)
926 rv->remove_ghost_in (*this);
930 TimeAxisView::erase_ghost (GhostRegion* gr)
936 for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
945 TimeAxisView::touched (double top, double bot)
947 /* remember: this is X Window - coordinate space starts in upper left and moves down.
948 y_position is the "origin" or "top" of the track.
951 double mybot = _y_position + current_height();
953 return ((_y_position <= bot && _y_position >= top) ||
954 ((mybot <= bot) && (top < mybot)) ||
955 (mybot >= bot && _y_position < top));
959 TimeAxisView::set_parent (TimeAxisView& p)
965 TimeAxisView::reset_height ()
969 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
970 (*i)->set_height ((*i)->height);
975 TimeAxisView::compute_heights ()
977 Gtk::Window window (Gtk::WINDOW_TOPLEVEL);
978 Gtk::Table two_row_table (2, 8);
979 Gtk::Table one_row_table (1, 8);
981 const int border_width = 2;
982 extra_height = (2 * border_width)
983 //+ 2 // 2 pixels for the hseparator between TimeAxisView control areas
984 + 6; // resizer button (3 x 2 pixel elements + 2 x 2 pixel gaps)
986 window.add (one_row_table);
988 one_row_table.set_border_width (border_width);
989 one_row_table.set_row_spacings (0);
990 one_row_table.set_col_spacings (0);
991 one_row_table.set_homogeneous (true);
993 two_row_table.set_border_width (border_width);
994 two_row_table.set_row_spacings (0);
995 two_row_table.set_col_spacings (0);
996 two_row_table.set_homogeneous (true);
998 for (int i = 0; i < 5; ++i) {
999 buttons[i] = manage (new Button (X_("f")));
1000 buttons[i]->set_name ("TrackMuteButton");
1003 one_row_table.attach (*buttons[0], 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
1005 one_row_table.show_all ();
1006 Gtk::Requisition req(one_row_table.size_request ());
1008 // height required to show 1 row of buttons
1010 small_height = req.height + (2 * border_width);
1014 TimeAxisView::show_name_label ()
1016 if (!(name_packing & NameLabelPacked)) {
1017 name_hbox.pack_start (name_label, true, true);
1018 name_packing = NamePackingBits (name_packing | NameLabelPacked);
1025 TimeAxisView::show_name_entry ()
1027 if (!(name_packing & NameEntryPacked)) {
1028 name_hbox.pack_start (name_entry, true, true);
1029 name_packing = NamePackingBits (name_packing | NameEntryPacked);
1036 TimeAxisView::hide_name_label ()
1038 if (name_packing & NameLabelPacked) {
1039 name_hbox.remove (name_label);
1040 name_packing = NamePackingBits (name_packing & ~NameLabelPacked);
1045 TimeAxisView::hide_name_entry ()
1047 if (name_packing & NameEntryPacked) {
1048 name_hbox.remove (name_entry);
1049 name_packing = NamePackingBits (name_packing & ~NameEntryPacked);
1054 TimeAxisView::color_handler ()
1056 for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); i++) {
1060 for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
1062 (*i)->rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_SelectionRect.get();
1063 (*i)->rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1065 (*i)->start_trim->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1066 (*i)->start_trim->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1068 (*i)->end_trim->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1069 (*i)->end_trim->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1072 for (list<SelectionRect*>::iterator i = free_selection_rects.begin(); i != free_selection_rects.end(); ++i) {
1074 (*i)->rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_SelectionRect.get();
1075 (*i)->rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1077 (*i)->start_trim->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1078 (*i)->start_trim->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1080 (*i)->end_trim->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1081 (*i)->end_trim->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1085 /** @return Pair: TimeAxisView, layer index.
1086 * TimeAxisView is non-0 if this object covers y, or one of its children does.
1087 * If the covering object is a child axis, then the child is returned.
1088 * TimeAxisView is 0 otherwise.
1089 * Layer index is the layer number if the TimeAxisView is valid and is in stacked
1090 * region display mode, otherwise 0.
1092 std::pair<TimeAxisView*, layer_t>
1093 TimeAxisView::covers_y_position (double y)
1096 return std::make_pair ((TimeAxisView *) 0, 0);
1099 if (_y_position <= y && y < (_y_position + height)) {
1101 /* work out the layer index if appropriate */
1103 if (layer_display () == Stacked && view ()) {
1105 l = layer_t ((_y_position + height - y) / (view()->child_height ()));
1106 /* clamp to max layers to be on the safe side; sometimes the above calculation
1107 returns a too-high value */
1108 if (l >= view()->layers ()) {
1109 l = view()->layers() - 1;
1113 return std::make_pair (this, l);
1116 for (Children::const_iterator i = children.begin(); i != children.end(); ++i) {
1118 std::pair<TimeAxisView*, int> const r = (*i)->covers_y_position (y);
1124 return std::make_pair ((TimeAxisView *) 0, 0);
1128 TimeAxisView::resizer_button_press (GdkEventButton* event)
1130 _resize_drag_start = event->y_root;
1135 TimeAxisView::resizer_button_release (GdkEventButton*)
1137 _editor.stop_canvas_autoscroll ();
1138 _resize_drag_start = -1;
1143 TimeAxisView::idle_resize (uint32_t h)
1149 TimeAxisView::resizer_motion (GdkEventMotion* ev)
1151 if (_resize_drag_start >= 0) {
1152 /* (ab)use the DragManager to do autoscrolling; adjust the event coordinates
1153 into the world coordinate space that DragManager::motion_handler is expecting,
1154 and then fake a DragManager motion event so that when maybe_autoscroll
1155 asks DragManager for the current pointer position it will get the correct
1159 resizer.translate_coordinates (*control_parent, ev->x, ev->y, tx, ty);
1160 ev->y = ty - _editor.get_trackview_group_vertical_offset();
1161 _editor.drags()->motion_handler ((GdkEvent *) ev, false);
1162 _editor.maybe_autoscroll (false, true);
1164 /* now do the actual TAV resize */
1165 int32_t const delta = (int32_t) floor (ev->y_root - _resize_drag_start);
1166 _editor.add_to_idle_resize (this, delta);
1167 _resize_drag_start = ev->y_root;
1174 TimeAxisView::resizer_expose (GdkEventExpose* event)
1177 Glib::RefPtr<Gdk::Window> win (resizer.get_window());
1178 Glib::RefPtr<Gdk::GC> dark (resizer.get_style()->get_fg_gc (STATE_NORMAL));
1179 Glib::RefPtr<Gdk::GC> light (resizer.get_style()->get_bg_gc (STATE_NORMAL));
1181 win->draw_rectangle (controls_ebox.get_style()->get_bg_gc(STATE_NORMAL),
1186 event->area.height);
1188 win->get_geometry (x, y, w, h, d);
1190 /* handle/line #1 */
1192 win->draw_line (dark, 0, 0, w - 2, 0);
1193 win->draw_point (dark, 0, 1);
1194 win->draw_line (light, 1, 1, w - 1, 1);
1195 win->draw_point (light, w - 1, 0);
1197 /* handle/line #2 */
1199 win->draw_line (dark, 0, 4, w - 2, 4);
1200 win->draw_point (dark, 0, 5);
1201 win->draw_line (light, 1, 5, w - 1, 5);
1202 win->draw_point (light, w - 1, 4);
1204 /* use vertical resize mouse cursor */
1205 win->set_cursor(Gdk::Cursor(Gdk::SB_V_DOUBLE_ARROW));
1211 TimeAxisView::preset_height (Height h)
1215 return extra_height + 48 + 250;
1217 return extra_height + 48 + 150;
1219 return extra_height + 48 + 50;
1221 return extra_height + 48;
1223 return small_height;
1230 /** @return Child time axis views that are not hidden */
1231 TimeAxisView::Children
1232 TimeAxisView::get_child_list ()
1236 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1237 if (!(*i)->hidden()) {
1246 TimeAxisView::build_size_menu ()
1248 if (_size_menu && _size_menu->gobj ()) {
1254 using namespace Menu_Helpers;
1256 _size_menu = new Menu;
1257 _size_menu->set_name ("ArdourContextMenu");
1258 MenuList& items = _size_menu->items();
1260 items.push_back (MenuElem (_("Largest"), sigc::bind (sigc::mem_fun (*this, &TimeAxisView::set_height_enum), HeightLargest, true)));
1261 items.push_back (MenuElem (_("Larger"), sigc::bind (sigc::mem_fun (*this, &TimeAxisView::set_height_enum), HeightLarger, true)));
1262 items.push_back (MenuElem (_("Large"), sigc::bind (sigc::mem_fun (*this, &TimeAxisView::set_height_enum), HeightLarge, true)));
1263 items.push_back (MenuElem (_("Normal"), sigc::bind (sigc::mem_fun (*this, &TimeAxisView::set_height_enum), HeightNormal, true)));
1264 items.push_back (MenuElem (_("Small"), sigc::bind (sigc::mem_fun (*this, &TimeAxisView::set_height_enum), HeightSmall, true)));
1268 TimeAxisView::reset_visual_state ()
1270 /* this method is not required to trigger a global redraw */
1272 string str = gui_property ("height");
1275 set_height (atoi (str));
1277 set_height (preset_height (HeightNormal));