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>
32 #include <gtkmm2ext/utils.h>
33 #include <gtkmm2ext/selector.h>
34 #include <gtkmm2ext/stop_signal.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 "public_editor.h"
44 #include "time_axis_view.h"
45 #include "region_view.h"
46 #include "ghostregion.h"
47 #include "simplerect.h"
48 #include "simpleline.h"
49 #include "selection.h"
51 #include "rgb_macros.h"
59 using namespace ARDOUR;
61 using namespace Editing;
62 using namespace ArdourCanvas;
64 const double trim_handle_size = 6.0; /* pixels */
66 uint32_t TimeAxisView::hLargest = 0;
67 uint32_t TimeAxisView::hLarge = 0;
68 uint32_t TimeAxisView::hLarger = 0;
69 uint32_t TimeAxisView::hNormal = 0;
70 uint32_t TimeAxisView::hSmaller = 0;
71 uint32_t TimeAxisView::hSmall = 0;
72 bool TimeAxisView::need_size_info = true;
74 TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisView* rent, Canvas& canvas)
82 compute_controls_size_info ();
83 need_size_info = false;
86 canvas_display = new Group (*ed.get_trackview_group (), 0.0, 0.0);
88 ghost_group = new Group (*canvas_display);
89 ghost_group->lower_to_bottom();
92 selection_group = new Group (*canvas_display);
93 selection_group->hide();
98 _marked_for_display = false;
100 in_destructor = false;
102 effective_height = 0;
105 last_name_entry_key_press_event = 0;
106 name_packing = NamePackingBits (0);
107 resize_drag_start = -1;
110 Create the standard LHS Controls
111 We create the top-level container and name add the name label here,
112 subclasses can add to the layout as required
115 name_entry.set_name ("EditorTrackNameDisplay");
116 name_entry.signal_button_release_event().connect (mem_fun (*this, &TimeAxisView::name_entry_button_release));
117 name_entry.signal_button_press_event().connect (mem_fun (*this, &TimeAxisView::name_entry_button_press));
118 name_entry.signal_key_release_event().connect (mem_fun (*this, &TimeAxisView::name_entry_key_release));
119 name_entry.signal_activate().connect (mem_fun(*this, &TimeAxisView::name_entry_activated));
120 name_entry.signal_focus_in_event().connect (mem_fun (*this, &TimeAxisView::name_entry_focus_in));
121 name_entry.signal_focus_out_event().connect (mem_fun (*this, &TimeAxisView::name_entry_focus_out));
122 Gtkmm2ext::set_size_request_to_display_given_text (name_entry, N_("gTortnam"), 10, 10); // just represents a short name
124 name_label.set_name ("TrackLabel");
125 name_label.set_alignment (0.0, 0.5);
127 /* typically, either name_label OR name_entry are visible,
128 but not both. its up to derived classes to show/hide them as they
134 controls_table.set_border_width (2);
135 controls_table.set_row_spacings (0);
136 controls_table.set_col_spacings (0);
137 controls_table.set_homogeneous (true);
139 controls_table.attach (name_hbox, 0, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 3, 0);
140 controls_table.show_all ();
141 controls_table.set_no_show_all ();
143 resizer.set_size_request (10, 10);
144 resizer.set_name ("ResizeHandle");
145 resizer.signal_expose_event().connect (mem_fun (*this, &TimeAxisView::resizer_expose));
146 resizer.signal_button_press_event().connect (mem_fun (*this, &TimeAxisView::resizer_button_press));
147 resizer.signal_button_release_event().connect (mem_fun (*this, &TimeAxisView::resizer_button_release));
148 resizer.signal_motion_notify_event().connect (mem_fun (*this, &TimeAxisView::resizer_motion));
149 resizer.set_events (Gdk::BUTTON_PRESS_MASK|
150 Gdk::BUTTON_RELEASE_MASK|
151 Gdk::POINTER_MOTION_MASK|
154 resizer_box.pack_start (resizer, false, false);
158 controls_vbox.pack_start (controls_table, false, false);
159 controls_vbox.pack_end (resizer_box, false, true);
160 controls_vbox.show ();
162 //controls_ebox.set_name ("TimeAxisViewControlsBaseUnselected");
163 controls_ebox.add (controls_vbox);
164 controls_ebox.add_events (BUTTON_PRESS_MASK|BUTTON_RELEASE_MASK|SCROLL_MASK);
165 controls_ebox.set_flags (CAN_FOCUS);
167 controls_ebox.signal_button_release_event().connect (mem_fun (*this, &TimeAxisView::controls_ebox_button_release));
168 controls_ebox.signal_scroll_event().connect (mem_fun (*this, &TimeAxisView::controls_ebox_scroll), true);
170 controls_hbox.pack_start (controls_ebox,true,true);
171 controls_hbox.show ();
173 //controls_frame.add (controls_hbox);
174 //controls_frame.set_name ("TimeAxisViewControlsBaseUnselected");
175 //controls_vbox.set_name ("TimeAxisViewControlsBaseUnselected");
176 //controls_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
178 ColorsChanged.connect (mem_fun (*this, &TimeAxisView::color_handler));
181 TimeAxisView::~TimeAxisView()
183 in_destructor = true;
185 for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
189 for (list<SelectionRect*>::iterator i = free_selection_rects.begin(); i != free_selection_rects.end(); ++i) {
191 delete (*i)->start_trim;
192 delete (*i)->end_trim;
196 for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
198 delete (*i)->start_trim;
199 delete (*i)->end_trim;
202 for (list<SimpleLine*>::iterator i = feature_lines.begin(); i != feature_lines.end(); ++i) {
206 if (selection_group) {
207 delete selection_group;
211 if (canvas_display) {
212 delete canvas_display;
223 TimeAxisView::show_at (double y, int& nth, VBox *parent)
225 gdouble ix1, ix2, iy1, iy2;
226 effective_height = 0;
228 if (control_parent) {
229 control_parent->reorder_child (controls_hbox, nth);
231 control_parent = parent;
232 parent->pack_start (controls_hbox, false, false);
233 parent->reorder_child (controls_hbox, nth);
235 controls_hbox.show ();
236 controls_ebox.show ();
238 /* the coordinates used here are in the system of the
242 canvas_display->get_bounds (ix1, iy1, ix2, iy2);
243 iy1 += editor.get_trackview_group_vertical_offset ();
244 Group* pg = canvas_display->property_parent();
251 canvas_display->move (0.0, y - iy1);
252 canvas_display->show();/* XXX not necessary */
257 /* height in pixels depends on _order, so update it now we've changed _order */
260 effective_height = current_height();
262 /* now show children */
264 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
266 if ((*i)->marked_for_display()) {
267 (*i)->canvas_display->show();
270 if (canvas_item_visible ((*i)->canvas_display)) {
272 effective_height += (*i)->show_at (y + effective_height, nth, parent);
276 return effective_height;
280 TimeAxisView::controls_ebox_scroll (GdkEventScroll* ev)
282 switch (ev->direction) {
284 if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
287 } else if (Keyboard::no_modifiers_active (ev->state)) {
288 editor.scroll_tracks_up_line();
293 case GDK_SCROLL_DOWN:
294 if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
297 } else if (Keyboard::no_modifiers_active (ev->state)) {
298 editor.scroll_tracks_down_line();
304 /* no handling for left/right, yet */
312 TimeAxisView::controls_ebox_button_release (GdkEventButton* ev)
314 switch (ev->button) {
316 selection_click (ev);
320 popup_display_menu (ev->time);
328 TimeAxisView::selection_click (GdkEventButton* ev)
330 Selection::Operation op = Keyboard::selection_type (ev->state);
331 editor.set_selected_track (*this, op, false);
335 TimeAxisView::hide ()
341 canvas_display->hide();
342 controls_hbox.hide ();
344 if (control_parent) {
345 control_parent->remove (controls_hbox);
352 /* now hide children */
354 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
362 TimeAxisView::step_height (bool bigger)
364 static const uint32_t step = 20;
367 set_height (height + step);
370 set_height (std::max (height - step, hSmall));
371 } else if (height != hSmall) {
378 TimeAxisView::set_heights (uint32_t h)
380 TrackSelection& ts (editor.get_selection().tracks);
382 for (TrackSelection::iterator i = ts.begin(); i != ts.end(); ++i) {
383 (*i)->set_height (h);
388 TimeAxisView::set_height(uint32_t h)
392 for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
396 if (canvas_item_visible (selection_group)) {
397 /* resize the selection rect */
398 show_selection (editor.get_selection().time);
401 reshow_feature_lines ();
405 TimeAxisView::name_entry_key_release (GdkEventKey* ev)
407 PublicEditor::TrackViewList *allviews = 0;
408 PublicEditor::TrackViewList::iterator i;
410 switch (ev->keyval) {
412 name_entry.select_region (0,0);
413 controls_ebox.grab_focus ();
414 name_entry_changed ();
417 /* Shift+Tab Keys Pressed. Note that for Shift+Tab, GDK actually
418 * generates a different ev->keyval, rather than setting
421 case GDK_ISO_Left_Tab:
423 name_entry_changed ();
424 allviews = editor.get_valid_views (0);
426 i = find (allviews->begin(), allviews->end(), this);
427 if (ev->keyval == GDK_Tab) {
428 if (i != allviews->end()) {
430 if (++i == allviews->end()) { return true; }
431 } while((*i)->hidden());
434 if (i != allviews->begin()) {
436 if (--i == allviews->begin()) { return true; }
437 } while ((*i)->hidden());
442 /* resize to show editable name display */
444 if ((*i)->current_height() >= hSmall && (*i)->current_height() < hNormal) {
445 (*i)->set_height (hSmaller);
448 (*i)->name_entry.grab_focus();
454 name_entry_changed ();
461 #ifdef TIMEOUT_NAME_EDIT
462 /* adapt the timeout to reflect the user's typing speed */
464 guint32 name_entry_timeout;
466 if (last_name_entry_key_press_event) {
467 /* timeout is 1/2 second or 5 times their current inter-char typing speed */
468 name_entry_timeout = std::max (500U, (5 * (ev->time - last_name_entry_key_press_event)));
470 /* start with a 1 second timeout */
471 name_entry_timeout = 1000;
474 last_name_entry_key_press_event = ev->time;
476 /* wait 1 seconds and if no more keys are pressed, act as if they pressed enter */
478 name_entry_key_timeout.disconnect();
479 name_entry_key_timeout = Glib::signal_timeout().connect (mem_fun (*this, &TimeAxisView::name_entry_key_timed_out), name_entry_timeout);
486 TimeAxisView::name_entry_focus_in (GdkEventFocus* ev)
488 name_entry.select_region (0, -1);
489 name_entry.set_name ("EditorActiveTrackNameDisplay");
494 TimeAxisView::name_entry_focus_out (GdkEventFocus* ev)
498 last_name_entry_key_press_event = 0;
499 name_entry_key_timeout.disconnect ();
500 name_entry.set_name ("EditorTrackNameDisplay");
501 name_entry.select_region (0,0);
503 /* do the real stuff */
505 name_entry_changed ();
511 TimeAxisView::name_entry_key_timed_out ()
513 name_entry_activated();
518 TimeAxisView::name_entry_activated ()
520 controls_ebox.grab_focus();
524 TimeAxisView::name_entry_changed ()
529 TimeAxisView::name_entry_button_press (GdkEventButton *ev)
531 if (ev->button == 3) {
538 TimeAxisView::name_entry_button_release (GdkEventButton *ev)
540 if (ev->button == 3) {
541 popup_display_menu (ev->time);
548 TimeAxisView::conditionally_add_to_selection ()
550 Selection& s (editor.get_selection());
552 if (!s.selected (this)) {
553 editor.set_selected_track (*this, Selection::Set);
559 TimeAxisView::popup_display_menu (guint32 when)
561 if (display_menu == 0) {
562 build_display_menu ();
565 conditionally_add_to_selection ();
566 display_menu->popup (1, when);
570 TimeAxisView::size_click (GdkEventButton *ev)
572 conditionally_add_to_selection ();
573 popup_size_menu (ev->time);
578 TimeAxisView::popup_size_menu (guint32 when)
580 if (size_menu == 0) {
583 size_menu->popup (1, when);
587 TimeAxisView::set_selected (bool yn)
589 if (yn == _selected) {
593 Selectable::set_selected (yn);
596 controls_ebox.set_name (controls_base_selected_name);
597 controls_hbox.set_name (controls_base_selected_name);
598 controls_vbox.set_name (controls_base_selected_name);
599 /* propagate any existing selection, if the mode is right */
601 if (editor.current_mouse_mode() == Editing::MouseRange && !editor.get_selection().time.empty()) {
602 show_selection (editor.get_selection().time);
606 controls_ebox.set_name (controls_base_unselected_name);
607 controls_hbox.set_name (controls_base_unselected_name);
608 controls_vbox.set_name (controls_base_unselected_name);
611 /* children will be set for the yn=true case. but when deselecting
612 the editor only has a list of top-level trackviews, so we
613 have to do this here.
616 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
617 (*i)->set_selected (false);
621 resizer.queue_draw ();
625 TimeAxisView::build_size_menu ()
627 using namespace Menu_Helpers;
629 size_menu = new Menu;
630 size_menu->set_name ("ArdourContextMenu");
631 MenuList& items = size_menu->items();
633 items.push_back (MenuElem (_("Largest"), bind (mem_fun (*this, &TimeAxisView::set_heights), hLargest)));
634 items.push_back (MenuElem (_("Large"), bind (mem_fun (*this, &TimeAxisView::set_heights), hLarge)));
635 items.push_back (MenuElem (_("Larger"), bind (mem_fun (*this, &TimeAxisView::set_heights), hLarger)));
636 items.push_back (MenuElem (_("Normal"), bind (mem_fun (*this, &TimeAxisView::set_heights), hNormal)));
637 items.push_back (MenuElem (_("Smaller"), bind (mem_fun (*this, &TimeAxisView::set_heights),hSmaller)));
638 items.push_back (MenuElem (_("Small"), bind (mem_fun (*this, &TimeAxisView::set_heights), hSmall)));
642 TimeAxisView::build_display_menu ()
644 using namespace Menu_Helpers;
646 display_menu = new Menu;
647 display_menu->set_name ("ArdourContextMenu");
649 // Just let implementing classes define what goes into the manu
653 TimeAxisView::set_samples_per_unit (double spu)
655 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
656 (*i)->set_samples_per_unit (spu);
659 AnalysisFeatureList::const_iterator i;
660 list<ArdourCanvas::SimpleLine*>::iterator l;
662 for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
663 (*l)->property_x1() = editor.frame_to_pixel (*i);
664 (*l)->property_x2() = editor.frame_to_pixel (*i);
669 TimeAxisView::show_timestretch (nframes_t start, nframes_t end)
671 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
672 (*i)->show_timestretch (start, end);
677 TimeAxisView::hide_timestretch ()
679 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
680 (*i)->hide_timestretch ();
685 TimeAxisView::show_selection (TimeSelection& ts)
692 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
693 (*i)->show_selection (ts);
696 if (canvas_item_visible (selection_group)) {
697 while (!used_selection_rects.empty()) {
698 free_selection_rects.push_front (used_selection_rects.front());
699 used_selection_rects.pop_front();
700 free_selection_rects.front()->rect->hide();
701 free_selection_rects.front()->start_trim->hide();
702 free_selection_rects.front()->end_trim->hide();
704 selection_group->hide();
707 selection_group->show();
708 selection_group->raise_to_top();
710 for (list<AudioRange>::iterator i = ts.begin(); i != ts.end(); ++i) {
711 nframes_t start, end, cnt;
715 cnt = end - start + 1;
717 rect = get_selection_rect ((*i).id);
719 x1 = editor.frame_to_unit (start);
720 x2 = editor.frame_to_unit (start + cnt - 1);
721 y2 = current_height();
723 rect->rect->property_x1() = x1;
724 rect->rect->property_y1() = 1.0;
725 rect->rect->property_x2() = x2;
726 rect->rect->property_y2() = y2;
728 // trim boxes are at the top for selections
731 rect->start_trim->property_x1() = x1;
732 rect->start_trim->property_y1() = 1.0;
733 rect->start_trim->property_x2() = x1 + trim_handle_size;
734 rect->start_trim->property_y2() = 1.0 + trim_handle_size;
736 rect->end_trim->property_x1() = x2 - trim_handle_size;
737 rect->end_trim->property_y1() = 1.0;
738 rect->end_trim->property_x2() = x2;
739 rect->end_trim->property_y2() = 1.0 + trim_handle_size;
741 rect->start_trim->show();
742 rect->end_trim->show();
744 rect->start_trim->hide();
745 rect->end_trim->hide();
749 used_selection_rects.push_back (rect);
754 TimeAxisView::reshow_selection (TimeSelection& ts)
758 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
759 (*i)->show_selection (ts);
764 TimeAxisView::hide_selection ()
766 if (canvas_item_visible (selection_group)) {
767 while (!used_selection_rects.empty()) {
768 free_selection_rects.push_front (used_selection_rects.front());
769 used_selection_rects.pop_front();
770 free_selection_rects.front()->rect->hide();
771 free_selection_rects.front()->start_trim->hide();
772 free_selection_rects.front()->end_trim->hide();
774 selection_group->hide();
777 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
778 (*i)->hide_selection ();
783 TimeAxisView::order_selection_trims (ArdourCanvas::Item *item, bool put_start_on_top)
785 /* find the selection rect this is for. we have the item corresponding to one
789 for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
790 if ((*i)->start_trim == item || (*i)->end_trim == item) {
792 /* make one trim handle be "above" the other so that if they overlap,
793 the top one is the one last used.
796 (*i)->rect->raise_to_top ();
797 (put_start_on_top ? (*i)->start_trim : (*i)->end_trim)->raise_to_top ();
798 (put_start_on_top ? (*i)->end_trim : (*i)->start_trim)->raise_to_top ();
806 TimeAxisView::get_selection_rect (uint32_t id)
810 /* check to see if we already have a visible rect for this particular selection ID */
812 for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
813 if ((*i)->id == id) {
818 /* ditto for the free rect list */
820 for (list<SelectionRect*>::iterator i = free_selection_rects.begin(); i != free_selection_rects.end(); ++i) {
821 if ((*i)->id == id) {
822 SelectionRect* ret = (*i);
823 free_selection_rects.erase (i);
828 /* no existing matching rect, so go get a new one from the free list, or create one if there are none */
830 if (free_selection_rects.empty()) {
832 rect = new SelectionRect;
834 rect->rect = new SimpleRect (*selection_group);
835 rect->rect->property_x1() = 0.0;
836 rect->rect->property_y1() = 0.0;
837 rect->rect->property_x2() = 0.0;
838 rect->rect->property_y2() = 0.0;
839 rect->rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_SelectionRect.get();
840 rect->rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
842 rect->start_trim = new SimpleRect (*selection_group);
843 rect->start_trim->property_x1() = 0.0;
844 rect->start_trim->property_x2() = 0.0;
845 rect->start_trim->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
846 rect->start_trim->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
848 rect->end_trim = new SimpleRect (*selection_group);
849 rect->end_trim->property_x1() = 0.0;
850 rect->end_trim->property_x2() = 0.0;
851 rect->end_trim->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
852 rect->end_trim->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
854 free_selection_rects.push_front (rect);
856 rect->rect->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_selection_rect_event), rect->rect, rect));
857 rect->start_trim->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_selection_start_trim_event), rect->rect, rect));
858 rect->end_trim->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_selection_end_trim_event), rect->rect, rect));
861 rect = free_selection_rects.front();
863 free_selection_rects.pop_front();
867 struct null_deleter { void operator()(void const *) const {} };
870 TimeAxisView::is_child (TimeAxisView* tav)
872 return find (children.begin(), children.end(), boost::shared_ptr<TimeAxisView>(tav, null_deleter())) != children.end();
876 TimeAxisView::add_child (boost::shared_ptr<TimeAxisView> child)
878 children.push_back (child);
882 TimeAxisView::remove_child (boost::shared_ptr<TimeAxisView> child)
884 Children::iterator i;
886 if ((i = find (children.begin(), children.end(), child)) != children.end()) {
892 TimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& result)
898 TimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& result)
904 TimeAxisView::add_ghost (RegionView* rv) {
905 GhostRegion* gr = rv->add_ghost (*this);
908 ghosts.push_back(gr);
909 gr->GoingAway.connect (mem_fun(*this, &TimeAxisView::erase_ghost));
914 TimeAxisView::remove_ghost (RegionView* rv) {
915 rv->remove_ghost_in (*this);
919 TimeAxisView::erase_ghost (GhostRegion* gr) {
924 list<GhostRegion*>::iterator i;
926 for (i = ghosts.begin(); i != ghosts.end(); ++i) {
935 TimeAxisView::touched (double top, double bot)
937 /* remember: this is X Window - coordinate space starts in upper left and moves down.
938 y_position is the "origin" or "top" of the track.
941 double mybot = y_position + current_height();
943 return ((y_position <= bot && y_position >= top) ||
944 ((mybot <= bot) && (top < mybot)) ||
945 (mybot >= bot && y_position < top));
949 TimeAxisView::set_parent (TimeAxisView& p)
955 TimeAxisView::has_state () const
961 TimeAxisView::get_parent_with_state ()
967 if (parent->has_state()) {
971 return parent->get_parent_with_state ();
976 TimeAxisView::get_state ()
978 XMLNode* node = new XMLNode ("TAV-" + name());
981 snprintf (buf, sizeof(buf), "%u", height);
982 node->add_property ("height", buf);
983 node->add_property ("marked_for_display", (_marked_for_display ? "1" : "0"));
988 TimeAxisView::set_state (const XMLNode& node)
990 const XMLProperty *prop;
992 if ((prop = node.property ("marked_for_display")) != 0) {
993 _marked_for_display = (prop->value() == "1");
996 if ((prop = node.property ("track_height")) != 0) {
998 if (prop->value() == "largest") {
999 set_height (hLargest);
1000 } else if (prop->value() == "large") {
1001 set_height (hLarge);
1002 } else if (prop->value() == "larger") {
1003 set_height (hLarger);
1004 } else if (prop->value() == "normal") {
1005 set_height (hNormal);
1006 } else if (prop->value() == "smaller") {
1007 set_height (hSmaller);
1008 } else if (prop->value() == "small") {
1009 set_height (hSmall);
1011 error << string_compose(_("unknown track height name \"%1\" in XML GUI information"), prop->value()) << endmsg;
1012 set_height (Normal);
1015 } else if ((prop = node.property ("height")) != 0) {
1017 set_height (atoi (prop->value()));
1021 set_height (hNormal);
1028 TimeAxisView::reset_height()
1030 set_height (height);
1032 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1033 (*i)->set_height ((*i)->height);
1038 TimeAxisView::compute_controls_size_info ()
1040 Gtk::Window window (Gtk::WINDOW_TOPLEVEL);
1041 Gtk::Table two_row_table (2, 8);
1042 Gtk::Table one_row_table (1, 8);
1044 const int border_width = 2;
1045 const int extra_height = (2 * border_width) + 2 // 2 pixels for the controls frame
1046 + 10; // resizer button
1048 window.add (one_row_table);
1050 one_row_table.set_border_width (border_width);
1051 one_row_table.set_row_spacings (0);
1052 one_row_table.set_col_spacings (0);
1053 one_row_table.set_homogeneous (true);
1055 two_row_table.set_border_width (border_width);
1056 two_row_table.set_row_spacings (0);
1057 two_row_table.set_col_spacings (0);
1058 two_row_table.set_homogeneous (true);
1060 for (int i = 0; i < 5; ++i) {
1061 buttons[i] = manage (new Button (X_("f")));
1062 buttons[i]->set_name ("TrackMuteButton");
1065 one_row_table.attach (*buttons[0], 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
1067 one_row_table.show_all ();
1068 Gtk::Requisition req(one_row_table.size_request ());
1071 // height required to show 1 row of buttons
1073 hSmaller = req.height + extra_height;
1076 window.add (two_row_table);
1078 two_row_table.attach (*buttons[1], 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
1079 two_row_table.attach (*buttons[2], 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
1080 two_row_table.attach (*buttons[3], 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
1081 two_row_table.attach (*buttons[4], 8, 9, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
1083 two_row_table.show_all ();
1084 req = two_row_table.size_request ();
1086 // height required to show all normal buttons
1088 hNormal = req.height + extra_height;
1090 // these heights are all just larger than normal. no more
1091 // elements are visible (yet).
1093 hLarger = hNormal + 50;
1094 hLarge = hNormal + 150;
1095 hLargest = hNormal + 250;
1097 // height required to show track name
1103 TimeAxisView::show_name_label ()
1105 if (!(name_packing & NameLabelPacked)) {
1106 name_hbox.pack_start (name_label, true, true);
1107 name_packing = NamePackingBits (name_packing | NameLabelPacked);
1114 TimeAxisView::show_name_entry ()
1116 if (!(name_packing & NameEntryPacked)) {
1117 name_hbox.pack_start (name_entry, true, true);
1118 name_packing = NamePackingBits (name_packing | NameEntryPacked);
1125 TimeAxisView::hide_name_label ()
1127 if (name_packing & NameLabelPacked) {
1128 name_hbox.remove (name_label);
1129 name_packing = NamePackingBits (name_packing & ~NameLabelPacked);
1134 TimeAxisView::hide_name_entry ()
1136 if (name_packing & NameEntryPacked) {
1137 name_hbox.remove (name_entry);
1138 name_packing = NamePackingBits (name_packing & ~NameEntryPacked);
1143 TimeAxisView::color_handler ()
1145 for (list<GhostRegion*>::iterator i=ghosts.begin(); i != ghosts.end(); i++ ) {
1149 for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
1151 (*i)->rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_SelectionRect.get();
1152 (*i)->rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1154 (*i)->start_trim->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1155 (*i)->start_trim->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1157 (*i)->end_trim->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1158 (*i)->end_trim->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1161 for (list<SelectionRect*>::iterator i = free_selection_rects.begin(); i != free_selection_rects.end(); ++i) {
1163 (*i)->rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_SelectionRect.get();
1164 (*i)->rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1166 (*i)->start_trim->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1167 (*i)->start_trim->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1169 (*i)->end_trim->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1170 (*i)->end_trim->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1175 TimeAxisView::covers_y_position (double y)
1181 if (y_position <= y && y < (y_position + height)) {
1185 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1188 if ((tv = (*i)->covers_y_position (y)) != 0) {
1197 TimeAxisView::show_feature_lines (const AnalysisFeatureList& pos)
1199 analysis_features = pos;
1200 reshow_feature_lines ();
1205 TimeAxisView::hide_feature_lines ()
1207 list<ArdourCanvas::SimpleLine*>::iterator l;
1209 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
1215 TimeAxisView::reshow_feature_lines ()
1217 while (feature_lines.size()< analysis_features.size()) {
1218 ArdourCanvas::SimpleLine* l = new ArdourCanvas::SimpleLine (*canvas_display);
1219 l->property_color_rgba() = (guint) ARDOUR_UI::config()->canvasvar_ZeroLine.get();
1220 feature_lines.push_back (l);
1223 while (feature_lines.size() > analysis_features.size()) {
1224 ArdourCanvas::SimpleLine *line = feature_lines.back();
1225 feature_lines.pop_back ();
1229 AnalysisFeatureList::const_iterator i;
1230 list<ArdourCanvas::SimpleLine*>::iterator l;
1232 for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
1233 (*l)->property_x1() = editor.frame_to_pixel (*i);
1234 (*l)->property_x2() = editor.frame_to_pixel (*i);
1235 (*l)->property_y1() = 0;
1236 (*l)->property_y2() = current_height();
1242 TimeAxisView::resizer_button_press (GdkEventButton* event)
1244 resize_drag_start = event->y_root;
1245 resize_idle_target = current_height();
1246 editor.start_resize_line_ops ();
1251 TimeAxisView::resizer_button_release (GdkEventButton* ev)
1253 resize_drag_start = -1;
1254 editor.end_resize_line_ops ();
1259 TimeAxisView::idle_resize (uint32_t h)
1265 TimeAxisView::resizer_motion (GdkEventMotion* ev)
1267 if (resize_drag_start < 0) {
1271 int32_t delta = (int32_t) floor (resize_drag_start - ev->y_root);
1273 resize_idle_target = std::max (resize_idle_target - delta, (int) hSmall);
1274 editor.add_to_idle_resize (this, resize_idle_target);
1276 resize_drag_start = ev->y_root;
1282 TimeAxisView::resizer_expose (GdkEventExpose* event)
1285 Glib::RefPtr<Gdk::Window> win (resizer.get_window());
1286 Glib::RefPtr<Gdk::GC> dark (resizer.get_style()->get_fg_gc (STATE_NORMAL));
1287 Glib::RefPtr<Gdk::GC> light (resizer.get_style()->get_bg_gc (STATE_NORMAL));
1289 win->draw_rectangle (controls_ebox.get_style()->get_bg_gc(STATE_NORMAL),
1294 event->area.height);
1296 win->get_geometry (x, y, w, h, d);
1298 /* handle/line #1 */
1300 win->draw_line (dark, 0, 0, w - 2, 0);
1301 win->draw_point (dark, 0, 1);
1302 win->draw_line (light, 1, 1, w - 1, 1);
1303 win->draw_point (light, w - 1, 0);
1305 /* handle/line #2 */
1307 win->draw_line (dark, 0, 4, w - 2, 4);
1308 win->draw_point (dark, 0, 5);
1309 win->draw_line (light, 1, 5, w - 1, 5);
1310 win->draw_point (light, w - 1, 4);
1312 /* handle/line #3 */
1314 win->draw_line (dark, 0, 8, w - 2, 8);
1315 win->draw_point (dark, 0, 9);
1316 win->draw_line (light, 1, 9, w - 1, 9);
1317 win->draw_point (light, w - 1, 8);