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 (*canvas.root(), 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 Group* pg = canvas_display->property_parent();
250 canvas_display->move (0.0, y - iy1);
251 canvas_display->show();/* XXX not necessary */
256 /* height in pixels depends on _order, so update it now we've changed _order */
259 effective_height = current_height();
261 /* now show children */
263 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
265 if ((*i)->marked_for_display()) {
266 (*i)->canvas_display->show();
269 if (canvas_item_visible ((*i)->canvas_display)) {
271 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)) {
286 } else if (Keyboard::no_modifiers_active (ev->state)) {
287 editor.scroll_tracks_up_line();
292 case GDK_SCROLL_DOWN:
293 if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
296 } else if (Keyboard::no_modifiers_active (ev->state)) {
297 editor.scroll_tracks_down_line();
303 /* no handling for left/right, yet */
311 TimeAxisView::controls_ebox_button_release (GdkEventButton* ev)
313 switch (ev->button) {
315 selection_click (ev);
319 popup_display_menu (ev->time);
327 TimeAxisView::selection_click (GdkEventButton* ev)
329 Selection::Operation op = Keyboard::selection_type (ev->state);
330 editor.set_selected_track (*this, op, false);
334 TimeAxisView::hide ()
340 canvas_display->hide();
341 controls_hbox.hide ();
343 if (control_parent) {
344 control_parent->remove (controls_hbox);
351 /* now hide children */
353 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
361 TimeAxisView::step_height (bool bigger)
363 static const uint32_t step = 20;
366 set_height (height + step);
369 set_height (std::max (height - step, hSmall));
370 } else if (height != hSmall) {
377 TimeAxisView::set_heights (uint32_t h)
379 TrackSelection& ts (editor.get_selection().tracks);
381 for (TrackSelection::iterator i = ts.begin(); i != ts.end(); ++i) {
382 (*i)->set_height (h);
387 TimeAxisView::set_height(uint32_t h)
391 for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
395 if (canvas_item_visible (selection_group)) {
396 /* resize the selection rect */
397 show_selection (editor.get_selection().time);
400 reshow_feature_lines ();
404 TimeAxisView::name_entry_key_release (GdkEventKey* ev)
406 PublicEditor::TrackViewList *allviews = 0;
407 PublicEditor::TrackViewList::iterator i;
409 switch (ev->keyval) {
411 name_entry.select_region (0,0);
412 controls_ebox.grab_focus ();
413 name_entry_changed ();
416 /* Shift+Tab Keys Pressed. Note that for Shift+Tab, GDK actually
417 * generates a different ev->keyval, rather than setting
420 case GDK_ISO_Left_Tab:
422 name_entry_changed ();
423 allviews = editor.get_valid_views (0);
425 i = find (allviews->begin(), allviews->end(), this);
426 if (ev->keyval == GDK_Tab) {
427 if (i != allviews->end()) {
429 if (++i == allviews->end()) { return true; }
430 } while((*i)->hidden());
433 if (i != allviews->begin()) {
435 if (--i == allviews->begin()) { return true; }
436 } while ((*i)->hidden());
441 /* resize to show editable name display */
443 if ((*i)->current_height() >= hSmall && (*i)->current_height() < hNormal) {
444 (*i)->set_height (hSmaller);
447 (*i)->name_entry.grab_focus();
453 name_entry_changed ();
460 #ifdef TIMEOUT_NAME_EDIT
461 /* adapt the timeout to reflect the user's typing speed */
463 guint32 name_entry_timeout;
465 if (last_name_entry_key_press_event) {
466 /* timeout is 1/2 second or 5 times their current inter-char typing speed */
467 name_entry_timeout = std::max (500U, (5 * (ev->time - last_name_entry_key_press_event)));
469 /* start with a 1 second timeout */
470 name_entry_timeout = 1000;
473 last_name_entry_key_press_event = ev->time;
475 /* wait 1 seconds and if no more keys are pressed, act as if they pressed enter */
477 name_entry_key_timeout.disconnect();
478 name_entry_key_timeout = Glib::signal_timeout().connect (mem_fun (*this, &TimeAxisView::name_entry_key_timed_out), name_entry_timeout);
485 TimeAxisView::name_entry_focus_in (GdkEventFocus* ev)
487 name_entry.select_region (0, -1);
488 name_entry.set_name ("EditorActiveTrackNameDisplay");
493 TimeAxisView::name_entry_focus_out (GdkEventFocus* ev)
497 last_name_entry_key_press_event = 0;
498 name_entry_key_timeout.disconnect ();
499 name_entry.set_name ("EditorTrackNameDisplay");
500 name_entry.select_region (0,0);
502 /* do the real stuff */
504 name_entry_changed ();
510 TimeAxisView::name_entry_key_timed_out ()
512 name_entry_activated();
517 TimeAxisView::name_entry_activated ()
519 controls_ebox.grab_focus();
523 TimeAxisView::name_entry_changed ()
528 TimeAxisView::name_entry_button_press (GdkEventButton *ev)
530 if (ev->button == 3) {
537 TimeAxisView::name_entry_button_release (GdkEventButton *ev)
539 if (ev->button == 3) {
540 popup_display_menu (ev->time);
547 TimeAxisView::conditionally_add_to_selection ()
549 Selection& s (editor.get_selection());
551 if (!s.selected (this)) {
552 editor.set_selected_track (*this, Selection::Set);
558 TimeAxisView::popup_display_menu (guint32 when)
560 if (display_menu == 0) {
561 build_display_menu ();
564 conditionally_add_to_selection ();
565 display_menu->popup (1, when);
569 TimeAxisView::size_click (GdkEventButton *ev)
571 conditionally_add_to_selection ();
572 popup_size_menu (ev->time);
577 TimeAxisView::popup_size_menu (guint32 when)
579 if (size_menu == 0) {
582 size_menu->popup (1, when);
586 TimeAxisView::set_selected (bool yn)
588 if (yn == _selected) {
592 Selectable::set_selected (yn);
595 controls_ebox.set_name (controls_base_selected_name);
596 controls_hbox.set_name (controls_base_selected_name);
597 controls_vbox.set_name (controls_base_selected_name);
598 /* propagate any existing selection, if the mode is right */
600 if (editor.current_mouse_mode() == Editing::MouseRange && !editor.get_selection().time.empty()) {
601 show_selection (editor.get_selection().time);
605 controls_ebox.set_name (controls_base_unselected_name);
606 controls_hbox.set_name (controls_base_unselected_name);
607 controls_vbox.set_name (controls_base_unselected_name);
610 /* children will be set for the yn=true case. but when deselecting
611 the editor only has a list of top-level trackviews, so we
612 have to do this here.
615 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
616 (*i)->set_selected (false);
620 resizer.queue_draw ();
624 TimeAxisView::build_size_menu ()
626 using namespace Menu_Helpers;
628 size_menu = new Menu;
629 size_menu->set_name ("ArdourContextMenu");
630 MenuList& items = size_menu->items();
632 items.push_back (MenuElem (_("Largest"), bind (mem_fun (*this, &TimeAxisView::set_heights), hLargest)));
633 items.push_back (MenuElem (_("Large"), bind (mem_fun (*this, &TimeAxisView::set_heights), hLarge)));
634 items.push_back (MenuElem (_("Larger"), bind (mem_fun (*this, &TimeAxisView::set_heights), hLarger)));
635 items.push_back (MenuElem (_("Normal"), bind (mem_fun (*this, &TimeAxisView::set_heights), hNormal)));
636 items.push_back (MenuElem (_("Smaller"), bind (mem_fun (*this, &TimeAxisView::set_heights),hSmaller)));
637 items.push_back (MenuElem (_("Small"), bind (mem_fun (*this, &TimeAxisView::set_heights), hSmall)));
641 TimeAxisView::build_display_menu ()
643 using namespace Menu_Helpers;
645 display_menu = new Menu;
646 display_menu->set_name ("ArdourContextMenu");
648 // Just let implementing classes define what goes into the manu
652 TimeAxisView::set_samples_per_unit (double spu)
654 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
655 (*i)->set_samples_per_unit (spu);
658 AnalysisFeatureList::const_iterator i;
659 list<ArdourCanvas::SimpleLine*>::iterator l;
661 for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
662 (*l)->property_x1() = editor.frame_to_pixel (*i);
663 (*l)->property_x2() = editor.frame_to_pixel (*i);
668 TimeAxisView::show_timestretch (nframes_t start, nframes_t end)
670 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
671 (*i)->show_timestretch (start, end);
676 TimeAxisView::hide_timestretch ()
678 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
679 (*i)->hide_timestretch ();
684 TimeAxisView::show_selection (TimeSelection& ts)
691 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
692 (*i)->show_selection (ts);
695 if (canvas_item_visible (selection_group)) {
696 while (!used_selection_rects.empty()) {
697 free_selection_rects.push_front (used_selection_rects.front());
698 used_selection_rects.pop_front();
699 free_selection_rects.front()->rect->hide();
700 free_selection_rects.front()->start_trim->hide();
701 free_selection_rects.front()->end_trim->hide();
703 selection_group->hide();
706 selection_group->show();
707 selection_group->raise_to_top();
709 for (list<AudioRange>::iterator i = ts.begin(); i != ts.end(); ++i) {
710 nframes_t start, end, cnt;
714 cnt = end - start + 1;
716 rect = get_selection_rect ((*i).id);
718 x1 = editor.frame_to_unit (start);
719 x2 = editor.frame_to_unit (start + cnt - 1);
720 y2 = current_height();
722 rect->rect->property_x1() = x1;
723 rect->rect->property_y1() = 1.0;
724 rect->rect->property_x2() = x2;
725 rect->rect->property_y2() = y2;
727 // trim boxes are at the top for selections
730 rect->start_trim->property_x1() = x1;
731 rect->start_trim->property_y1() = 1.0;
732 rect->start_trim->property_x2() = x1 + trim_handle_size;
733 rect->start_trim->property_y2() = 1.0 + trim_handle_size;
735 rect->end_trim->property_x1() = x2 - trim_handle_size;
736 rect->end_trim->property_y1() = 1.0;
737 rect->end_trim->property_x2() = x2;
738 rect->end_trim->property_y2() = 1.0 + trim_handle_size;
740 rect->start_trim->show();
741 rect->end_trim->show();
743 rect->start_trim->hide();
744 rect->end_trim->hide();
748 used_selection_rects.push_back (rect);
753 TimeAxisView::reshow_selection (TimeSelection& ts)
757 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
758 (*i)->show_selection (ts);
763 TimeAxisView::hide_selection ()
765 if (canvas_item_visible (selection_group)) {
766 while (!used_selection_rects.empty()) {
767 free_selection_rects.push_front (used_selection_rects.front());
768 used_selection_rects.pop_front();
769 free_selection_rects.front()->rect->hide();
770 free_selection_rects.front()->start_trim->hide();
771 free_selection_rects.front()->end_trim->hide();
773 selection_group->hide();
776 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
777 (*i)->hide_selection ();
782 TimeAxisView::order_selection_trims (ArdourCanvas::Item *item, bool put_start_on_top)
784 /* find the selection rect this is for. we have the item corresponding to one
788 for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
789 if ((*i)->start_trim == item || (*i)->end_trim == item) {
791 /* make one trim handle be "above" the other so that if they overlap,
792 the top one is the one last used.
795 (*i)->rect->raise_to_top ();
796 (put_start_on_top ? (*i)->start_trim : (*i)->end_trim)->raise_to_top ();
797 (put_start_on_top ? (*i)->end_trim : (*i)->start_trim)->raise_to_top ();
805 TimeAxisView::get_selection_rect (uint32_t id)
809 /* check to see if we already have a visible rect for this particular selection ID */
811 for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
812 if ((*i)->id == id) {
817 /* ditto for the free rect list */
819 for (list<SelectionRect*>::iterator i = free_selection_rects.begin(); i != free_selection_rects.end(); ++i) {
820 if ((*i)->id == id) {
821 SelectionRect* ret = (*i);
822 free_selection_rects.erase (i);
827 /* no existing matching rect, so go get a new one from the free list, or create one if there are none */
829 if (free_selection_rects.empty()) {
831 rect = new SelectionRect;
833 rect->rect = new SimpleRect (*selection_group);
834 rect->rect->property_x1() = 0.0;
835 rect->rect->property_y1() = 0.0;
836 rect->rect->property_x2() = 0.0;
837 rect->rect->property_y2() = 0.0;
838 rect->rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_SelectionRect.get();
839 rect->rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
841 rect->start_trim = new SimpleRect (*selection_group);
842 rect->start_trim->property_x1() = 0.0;
843 rect->start_trim->property_x2() = 0.0;
844 rect->start_trim->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
845 rect->start_trim->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
847 rect->end_trim = new SimpleRect (*selection_group);
848 rect->end_trim->property_x1() = 0.0;
849 rect->end_trim->property_x2() = 0.0;
850 rect->end_trim->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
851 rect->end_trim->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
853 free_selection_rects.push_front (rect);
855 rect->rect->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_selection_rect_event), rect->rect, rect));
856 rect->start_trim->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_selection_start_trim_event), rect->rect, rect));
857 rect->end_trim->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_selection_end_trim_event), rect->rect, rect));
860 rect = free_selection_rects.front();
862 free_selection_rects.pop_front();
866 struct null_deleter { void operator()(void const *) const {} };
869 TimeAxisView::is_child (TimeAxisView* tav)
871 return find (children.begin(), children.end(), boost::shared_ptr<TimeAxisView>(tav, null_deleter())) != children.end();
875 TimeAxisView::add_child (boost::shared_ptr<TimeAxisView> child)
877 children.push_back (child);
881 TimeAxisView::remove_child (boost::shared_ptr<TimeAxisView> child)
883 Children::iterator i;
885 if ((i = find (children.begin(), children.end(), child)) != children.end()) {
891 TimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& result)
897 TimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& result)
903 TimeAxisView::add_ghost (RegionView* rv) {
904 GhostRegion* gr = rv->add_ghost (*this);
907 ghosts.push_back(gr);
908 gr->GoingAway.connect (mem_fun(*this, &TimeAxisView::erase_ghost));
913 TimeAxisView::remove_ghost (RegionView* rv) {
914 rv->remove_ghost_in (*this);
918 TimeAxisView::erase_ghost (GhostRegion* gr) {
923 list<GhostRegion*>::iterator i;
925 for (i = ghosts.begin(); i != ghosts.end(); ++i) {
934 TimeAxisView::touched (double top, double bot)
936 /* remember: this is X Window - coordinate space starts in upper left and moves down.
937 y_position is the "origin" or "top" of the track.
940 double mybot = y_position + current_height();
942 return ((y_position <= bot && y_position >= top) ||
943 ((mybot <= bot) && (top < mybot)) ||
944 (mybot >= bot && y_position < top));
948 TimeAxisView::set_parent (TimeAxisView& p)
954 TimeAxisView::has_state () const
960 TimeAxisView::get_parent_with_state ()
966 if (parent->has_state()) {
970 return parent->get_parent_with_state ();
975 TimeAxisView::get_state ()
977 XMLNode* node = new XMLNode ("TAV-" + name());
980 snprintf (buf, sizeof(buf), "%u", height);
981 node->add_property ("height", buf);
982 node->add_property ("marked_for_display", (_marked_for_display ? "1" : "0"));
987 TimeAxisView::set_state (const XMLNode& node)
989 const XMLProperty *prop;
991 if ((prop = node.property ("marked_for_display")) != 0) {
992 _marked_for_display = (prop->value() == "1");
995 if ((prop = node.property ("track_height")) != 0) {
997 if (prop->value() == "largest") {
998 set_height (hLargest);
999 } else if (prop->value() == "large") {
1000 set_height (hLarge);
1001 } else if (prop->value() == "larger") {
1002 set_height (hLarger);
1003 } else if (prop->value() == "normal") {
1004 set_height (hNormal);
1005 } else if (prop->value() == "smaller") {
1006 set_height (hSmaller);
1007 } else if (prop->value() == "small") {
1008 set_height (hSmall);
1010 error << string_compose(_("unknown track height name \"%1\" in XML GUI information"), prop->value()) << endmsg;
1011 set_height (Normal);
1014 } else if ((prop = node.property ("height")) != 0) {
1016 set_height (atoi (prop->value()));
1020 set_height (hNormal);
1027 TimeAxisView::reset_height()
1029 set_height (height);
1031 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1032 (*i)->set_height ((*i)->height);
1037 TimeAxisView::compute_controls_size_info ()
1039 Gtk::Window window (Gtk::WINDOW_TOPLEVEL);
1040 Gtk::Table two_row_table (2, 8);
1041 Gtk::Table one_row_table (1, 8);
1043 const int border_width = 2;
1044 const int extra_height = (2 * border_width) + 2 // 2 pixels for the controls frame
1045 + 10; // resizer button
1047 window.add (one_row_table);
1049 one_row_table.set_border_width (border_width);
1050 one_row_table.set_row_spacings (0);
1051 one_row_table.set_col_spacings (0);
1052 one_row_table.set_homogeneous (true);
1054 two_row_table.set_border_width (border_width);
1055 two_row_table.set_row_spacings (0);
1056 two_row_table.set_col_spacings (0);
1057 two_row_table.set_homogeneous (true);
1059 for (int i = 0; i < 5; ++i) {
1060 buttons[i] = manage (new Button (X_("f")));
1061 buttons[i]->set_name ("TrackMuteButton");
1064 one_row_table.attach (*buttons[0], 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
1066 one_row_table.show_all ();
1067 Gtk::Requisition req(one_row_table.size_request ());
1070 // height required to show 1 row of buttons
1072 hSmaller = req.height + extra_height;
1075 window.add (two_row_table);
1077 two_row_table.attach (*buttons[1], 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
1078 two_row_table.attach (*buttons[2], 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
1079 two_row_table.attach (*buttons[3], 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
1080 two_row_table.attach (*buttons[4], 8, 9, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
1082 two_row_table.show_all ();
1083 req = two_row_table.size_request ();
1085 // height required to show all normal buttons
1087 hNormal = req.height + extra_height;
1089 // these heights are all just larger than normal. no more
1090 // elements are visible (yet).
1092 hLarger = hNormal + 50;
1093 hLarge = hNormal + 150;
1094 hLargest = hNormal + 250;
1096 // height required to show track name
1102 TimeAxisView::show_name_label ()
1104 if (!(name_packing & NameLabelPacked)) {
1105 name_hbox.pack_start (name_label, true, true);
1106 name_packing = NamePackingBits (name_packing | NameLabelPacked);
1113 TimeAxisView::show_name_entry ()
1115 if (!(name_packing & NameEntryPacked)) {
1116 name_hbox.pack_start (name_entry, true, true);
1117 name_packing = NamePackingBits (name_packing | NameEntryPacked);
1124 TimeAxisView::hide_name_label ()
1126 if (name_packing & NameLabelPacked) {
1127 name_hbox.remove (name_label);
1128 name_packing = NamePackingBits (name_packing & ~NameLabelPacked);
1133 TimeAxisView::hide_name_entry ()
1135 if (name_packing & NameEntryPacked) {
1136 name_hbox.remove (name_entry);
1137 name_packing = NamePackingBits (name_packing & ~NameEntryPacked);
1142 TimeAxisView::color_handler ()
1144 for (list<GhostRegion*>::iterator i=ghosts.begin(); i != ghosts.end(); i++ ) {
1148 for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
1150 (*i)->rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_SelectionRect.get();
1151 (*i)->rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1153 (*i)->start_trim->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1154 (*i)->start_trim->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1156 (*i)->end_trim->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1157 (*i)->end_trim->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1160 for (list<SelectionRect*>::iterator i = free_selection_rects.begin(); i != free_selection_rects.end(); ++i) {
1162 (*i)->rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_SelectionRect.get();
1163 (*i)->rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1165 (*i)->start_trim->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1166 (*i)->start_trim->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1168 (*i)->end_trim->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1169 (*i)->end_trim->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_Selection.get();
1174 TimeAxisView::covers_y_position (double y)
1180 if (y_position <= y && y < (y_position + height)) {
1184 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1187 if ((tv = (*i)->covers_y_position (y)) != 0) {
1196 TimeAxisView::show_feature_lines (const AnalysisFeatureList& pos)
1198 analysis_features = pos;
1199 reshow_feature_lines ();
1204 TimeAxisView::hide_feature_lines ()
1206 list<ArdourCanvas::SimpleLine*>::iterator l;
1208 for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
1214 TimeAxisView::reshow_feature_lines ()
1216 while (feature_lines.size()< analysis_features.size()) {
1217 ArdourCanvas::SimpleLine* l = new ArdourCanvas::SimpleLine (*canvas_display);
1218 l->property_color_rgba() = (guint) ARDOUR_UI::config()->canvasvar_ZeroLine.get();
1219 feature_lines.push_back (l);
1222 while (feature_lines.size() > analysis_features.size()) {
1223 ArdourCanvas::SimpleLine *line = feature_lines.back();
1224 feature_lines.pop_back ();
1228 AnalysisFeatureList::const_iterator i;
1229 list<ArdourCanvas::SimpleLine*>::iterator l;
1231 for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
1232 (*l)->property_x1() = editor.frame_to_pixel (*i);
1233 (*l)->property_x2() = editor.frame_to_pixel (*i);
1234 (*l)->property_y1() = 0;
1235 (*l)->property_y2() = current_height();
1241 TimeAxisView::resizer_button_press (GdkEventButton* event)
1243 resize_drag_start = event->y_root;
1244 resize_idle_target = current_height();
1245 editor.start_resize_line_ops ();
1250 TimeAxisView::resizer_button_release (GdkEventButton* ev)
1252 resize_drag_start = -1;
1253 editor.end_resize_line_ops ();
1258 TimeAxisView::idle_resize (uint32_t h)
1264 TimeAxisView::resizer_motion (GdkEventMotion* ev)
1266 if (resize_drag_start < 0) {
1270 int32_t delta = (int32_t) floor (resize_drag_start - ev->y_root);
1272 resize_idle_target = std::max (resize_idle_target - delta, (int) hSmall);
1273 editor.add_to_idle_resize (this, resize_idle_target);
1275 resize_drag_start = ev->y_root;
1281 TimeAxisView::resizer_expose (GdkEventExpose* event)
1284 Glib::RefPtr<Gdk::Window> win (resizer.get_window());
1285 Glib::RefPtr<Gdk::GC> dark (resizer.get_style()->get_fg_gc (STATE_NORMAL));
1286 Glib::RefPtr<Gdk::GC> light (resizer.get_style()->get_bg_gc (STATE_NORMAL));
1288 win->draw_rectangle (controls_ebox.get_style()->get_bg_gc(STATE_NORMAL),
1293 event->area.height);
1295 win->get_geometry (x, y, w, h, d);
1297 /* handle/line #1 */
1299 win->draw_line (dark, 0, 0, w - 2, 0);
1300 win->draw_point (dark, 0, 1);
1301 win->draw_line (light, 1, 1, w - 1, 1);
1302 win->draw_point (light, w - 1, 0);
1304 /* handle/line #2 */
1306 win->draw_line (dark, 0, 4, w - 2, 4);
1307 win->draw_point (dark, 0, 5);
1308 win->draw_line (light, 1, 5, w - 1, 5);
1309 win->draw_point (light, w - 1, 4);
1311 /* handle/line #3 */
1313 win->draw_line (dark, 0, 8, w - 2, 8);
1314 win->draw_point (dark, 0, 9);
1315 win->draw_line (light, 1, 9, w - 1, 9);
1316 win->draw_point (light, w - 1, 8);