2 Copyright (C) 2000-2007 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <gtkmm2ext/barcontroller.h>
22 #include <gtkmm2ext/utils.h>
23 #include <boost/algorithm/string.hpp>
25 #include "pbd/error.h"
26 #include "pbd/memento_command.h"
27 #include "pbd/stacktrace.h"
28 #include "pbd/string_convert.h"
29 #include "pbd/types_convert.h"
31 #include "ardour/automation_control.h"
32 #include "ardour/event_type_map.h"
33 #include "ardour/parameter_types.h"
34 #include "ardour/profile.h"
35 #include "ardour/route.h"
36 #include "ardour/session.h"
38 #include "canvas/debug.h"
40 #include "automation_time_axis.h"
41 #include "automation_streamview.h"
42 #include "gui_thread.h"
43 #include "route_time_axis.h"
44 #include "automation_line.h"
45 #include "paste_context.h"
46 #include "public_editor.h"
47 #include "selection.h"
49 #include "rgb_macros.h"
50 #include "point_selection.h"
51 #include "control_point.h"
53 #include "item_counts.h"
54 #include "ui_config.h"
59 using namespace ARDOUR;
60 using namespace ARDOUR_UI_UTILS;
63 using namespace Gtkmm2ext;
64 using namespace Editing;
66 Pango::FontDescription AutomationTimeAxisView::name_font;
67 bool AutomationTimeAxisView::have_name_font = false;
70 /** \a a the automatable object this time axis is to display data for.
71 * For route/track automation (e.g. gain) pass the route for both \r and \a.
72 * For route child (e.g. plugin) automation, pass the child for \a.
73 * For region automation (e.g. MIDI CC), pass null for \a.
75 AutomationTimeAxisView::AutomationTimeAxisView (
77 boost::shared_ptr<Route> r,
78 boost::shared_ptr<Automatable> a,
79 boost::shared_ptr<AutomationControl> c,
84 ArdourCanvas::Canvas& canvas,
86 const string & nomparent
88 : SessionHandlePtr (s)
89 , TimeAxisView (s, e, &parent, canvas)
94 , _base_rect (new ArdourCanvas::Rectangle (_canvas_display))
95 , _view (show_regions ? new AutomationStreamView (*this) : 0)
97 , _show_regions (show_regions)
99 //concatenate plugin name and param name into the tooltip
100 string tipname = nomparent;
101 if (!tipname.empty()) {
105 set_tooltip(controls_ebox, tipname);
107 //plugin name and param name appear on 2 separate lines in the track header
109 if (!tipname.empty()) {
115 CANVAS_DEBUG_NAME (_canvas_display, string_compose ("main for auto %2/%1", _name, r->name()));
116 CANVAS_DEBUG_NAME (selection_group, string_compose ("selections for auto %2/%1", _name, r->name()));
117 CANVAS_DEBUG_NAME (_ghost_group, string_compose ("ghosts for auto %2/%1", _name, r->name()));
119 if (!have_name_font) {
120 name_font = get_font_for_style (X_("AutomationTrackName"));
121 have_name_font = true;
124 if (_automatable && _control) {
125 _controller = AutomationController::create (_automatable, _control->parameter(), _control->desc(), _control);
128 const std::string fill_color_name = (dynamic_cast<MidiTimeAxisView*>(&parent)
129 ? "midi automation track fill"
130 : "audio automation track fill");
136 mode_discrete_item = 0;
139 ignore_state_request = false;
140 first_call_to_set_height = true;
142 CANVAS_DEBUG_NAME (_base_rect, string_compose ("base rect for %1", _name));
143 _base_rect->set_x1 (ArdourCanvas::COORD_MAX);
144 _base_rect->set_outline (false);
145 _base_rect->set_fill_color (UIConfiguration::instance().color_mod (fill_color_name, "automation track fill"));
146 _base_rect->set_data ("trackview", this);
147 _base_rect->Event.connect (sigc::bind (sigc::mem_fun (_editor, &PublicEditor::canvas_automation_track_event), _base_rect, this));
149 _base_rect->lower_to_bottom();
152 using namespace Menu_Helpers;
154 auto_dropdown.AddMenuElem (MenuElem (S_("Automation|Manual"), sigc::bind (sigc::mem_fun(*this,
155 &AutomationTimeAxisView::set_automation_state), (AutoState) ARDOUR::Off)));
156 auto_dropdown.AddMenuElem (MenuElem (_("Play"), sigc::bind (sigc::mem_fun(*this,
157 &AutomationTimeAxisView::set_automation_state), (AutoState) Play)));
158 auto_dropdown.AddMenuElem (MenuElem (_("Write"), sigc::bind (sigc::mem_fun(*this,
159 &AutomationTimeAxisView::set_automation_state), (AutoState) Write)));
160 auto_dropdown.AddMenuElem (MenuElem (_("Touch"), sigc::bind (sigc::mem_fun(*this,
161 &AutomationTimeAxisView::set_automation_state), (AutoState) Touch)));
163 /* XXX translators: use a string here that will be at least as long
164 as the longest automation label (see ::automation_state_changed()
165 below). be sure to include a descender.
167 auto_dropdown.set_sizing_text(_("Mgnual"));
169 hide_button.set_icon (ArdourIcon::CloseCross);
170 hide_button.set_tweaks(ArdourButton::TrackHeader);
172 auto_dropdown.set_name ("route button");
173 hide_button.set_name ("route button");
175 auto_dropdown.unset_flags (Gtk::CAN_FOCUS);
176 hide_button.unset_flags (Gtk::CAN_FOCUS);
178 controls_table.set_no_show_all();
180 set_tooltip(auto_dropdown, _("automation state"));
181 set_tooltip(hide_button, _("hide track"));
184 if (get_gui_property ("height", height)) {
187 set_height (preset_height (HeightNormal));
190 //name label isn't editable on an automation track; remove the tooltip
191 set_tooltip (name_label, X_(""));
193 /* repack the name label, which TimeAxisView has already attached to
197 if (name_label.get_parent()) {
198 name_label.get_parent()->remove (name_label);
201 name_label.set_text (_name);
202 name_label.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
203 name_label.set_name (X_("TrackParameterName"));
204 name_label.set_ellipsize (Pango::ELLIPSIZE_END);
206 /* add the buttons */
207 controls_table.set_border_width (1);
208 controls_table.attach (hide_button, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
209 controls_table.attach (name_label, 2, 3, 1, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 2, 0);
210 controls_table.attach (auto_dropdown, 3, 4, 2, 3, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
212 Gtk::DrawingArea *blank0 = manage (new Gtk::DrawingArea());
213 Gtk::DrawingArea *blank1 = manage (new Gtk::DrawingArea());
215 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&parent);
216 // TODO use rtv->controls_base_unselected_name
217 // subscribe to route_active_changed, ...
218 if (rtv && rtv->is_audio_track()) {
219 blank0->set_name ("AudioTrackControlsBaseUnselected");
220 } else if (rtv && rtv->is_midi_track()) {
221 blank0->set_name ("MidiTrackControlsBaseUnselected");
223 blank0->set_name ("AudioBusControlsBaseUnselected");
225 blank0->set_name ("UnknownControlsBaseUnselected");
227 blank0->set_size_request (-1, -1);
228 blank1->set_size_request (1, 0);
229 VSeparator* separator = manage (new VSeparator());
230 separator->set_name("TrackSeparator");
231 separator->set_size_request (1, -1);
233 controls_button_size_group->add_widget(hide_button);
234 controls_button_size_group->add_widget(*blank0);
236 time_axis_hbox.pack_start (*blank0, false, false);
237 time_axis_hbox.pack_start (*separator, false, false);
238 time_axis_hbox.reorder_child (*blank0, 0);
239 time_axis_hbox.reorder_child (*separator, 1);
240 time_axis_hbox.reorder_child (time_axis_vbox, 2);
242 if (!ARDOUR::Profile->get_mixbus() ) {
243 time_axis_hbox.pack_start (*blank1, false, false);
252 _controller->disable_vertical_scroll ();
253 controls_table.attach (*_controller.get(), 2, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
256 controls_table.show_all ();
258 hide_button.signal_clicked.connect (sigc::mem_fun(*this, &AutomationTimeAxisView::hide_clicked));
260 controls_base_selected_name = X_("AutomationTrackControlsBaseSelected");
261 controls_base_unselected_name = X_("AutomationTrackControlsBase");
263 controls_ebox.set_name (controls_base_unselected_name);
264 time_axis_frame.set_name (controls_base_unselected_name);
266 /* ask for notifications of any new RegionViews */
274 /* no regions, just a single line for the entire track (e.g. bus gain) */
278 boost::shared_ptr<AutomationLine> line (
280 ARDOUR::EventTypeMap::instance().to_symbol(_parameter),
288 line->set_line_color (UIConfiguration::instance().color ("processor automation line"));
289 line->set_fill (true);
290 line->queue_reset ();
294 /* make sure labels etc. are correct */
296 automation_state_changed ();
297 UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &AutomationTimeAxisView::color_handler));
299 _route->DropReferences.connect (
300 _route_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::route_going_away, this), gui_context ()
304 AutomationTimeAxisView::~AutomationTimeAxisView ()
306 cleanup_gui_properties ();
311 AutomationTimeAxisView::route_going_away ()
317 AutomationTimeAxisView::set_automation_state (AutoState state)
319 if (ignore_state_request) {
324 _automatable->set_parameter_automation_state (_parameter, state);
328 _view->set_automation_state (state);
330 /* AutomationStreamViews don't signal when their automation state changes, so handle
331 our updates `manually'.
333 automation_state_changed ();
338 AutomationTimeAxisView::automation_state_changed ()
342 /* update button label */
345 state = _view->automation_state ();
348 state = _control->alist()->automation_state ();
353 switch (state & (ARDOUR::Off|Play|Touch|Write)) {
355 auto_dropdown.set_text (S_("Automation|Manual"));
357 ignore_state_request = true;
358 auto_off_item->set_active (true);
359 auto_play_item->set_active (false);
360 auto_touch_item->set_active (false);
361 auto_write_item->set_active (false);
362 ignore_state_request = false;
366 auto_dropdown.set_text (_("Play"));
367 if (auto_play_item) {
368 ignore_state_request = true;
369 auto_play_item->set_active (true);
370 auto_off_item->set_active (false);
371 auto_touch_item->set_active (false);
372 auto_write_item->set_active (false);
373 ignore_state_request = false;
377 auto_dropdown.set_text (_("Write"));
378 if (auto_write_item) {
379 ignore_state_request = true;
380 auto_write_item->set_active (true);
381 auto_off_item->set_active (false);
382 auto_play_item->set_active (false);
383 auto_touch_item->set_active (false);
384 ignore_state_request = false;
388 auto_dropdown.set_text (_("Touch"));
389 if (auto_touch_item) {
390 ignore_state_request = true;
391 auto_touch_item->set_active (true);
392 auto_off_item->set_active (false);
393 auto_play_item->set_active (false);
394 auto_write_item->set_active (false);
395 ignore_state_request = false;
399 auto_dropdown.set_text (_("???"));
404 /** The interpolation style of our AutomationList has changed, so update */
406 AutomationTimeAxisView::interpolation_changed (AutomationList::InterpolationStyle s)
408 if (mode_line_item && mode_discrete_item) {
409 if (s == AutomationList::Discrete) {
410 mode_discrete_item->set_active(true);
411 mode_line_item->set_active(false);
413 mode_line_item->set_active(true);
414 mode_discrete_item->set_active(false);
419 /** A menu item has been selected to change our interpolation mode */
421 AutomationTimeAxisView::set_interpolation (AutomationList::InterpolationStyle style)
423 /* Tell our view's list, if we have one, otherwise tell our own.
424 * Everything else will be signalled back from that.
428 _view->set_interpolation (style);
431 _control->list()->set_interpolation (style);
436 AutomationTimeAxisView::clear_clicked ()
438 assert (_line || _view);
440 _editor.begin_reversible_command (_("clear automation"));
447 set_automation_state ((AutoState) ARDOUR::Off);
448 _editor.commit_reversible_command ();
449 _session->set_dirty ();
453 AutomationTimeAxisView::set_height (uint32_t h, TrackHeightMode m)
455 bool const changed = (height != (uint32_t) h) || first_call_to_set_height;
456 uint32_t const normal = preset_height (HeightNormal);
457 bool const changed_between_small_and_normal = ( (height < normal && h >= normal) || (height >= normal || h < normal) );
459 TimeAxisView::set_height (h, m);
461 _base_rect->set_y1 (h);
464 _line->set_height(h - 2.5);
468 _view->set_height(h);
469 _view->update_contents_height();
472 if (changed_between_small_and_normal || first_call_to_set_height) {
474 first_call_to_set_height = false;
476 if (h >= preset_height (HeightNormal)) {
477 if (!(_parameter.type() >= MidiCCAutomation &&
478 _parameter.type() <= MidiChannelPressureAutomation)) {
479 auto_dropdown.show();
484 } else if (h >= preset_height (HeightSmall)) {
485 controls_table.hide_all ();
486 auto_dropdown.hide();
492 if (_canvas_display->visible() && _route) {
493 /* only emit the signal if the height really changed and we were visible */
494 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
500 AutomationTimeAxisView::set_samples_per_pixel (double fpp)
502 TimeAxisView::set_samples_per_pixel (fpp);
509 _view->set_samples_per_pixel (fpp);
514 AutomationTimeAxisView::hide_clicked ()
516 hide_button.set_sensitive(false);
517 set_marked_for_display (false);
518 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(parent);
520 rtv->request_redraw ();
522 hide_button.set_sensitive(true);
526 AutomationTimeAxisView::build_display_menu ()
528 using namespace Menu_Helpers;
532 TimeAxisView::build_display_menu ();
534 /* now fill it with our stuff */
536 MenuList& items = display_menu->items();
538 items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &AutomationTimeAxisView::hide_clicked)));
539 items.push_back (SeparatorElem());
540 items.push_back (MenuElem (_("Clear"), sigc::mem_fun(*this, &AutomationTimeAxisView::clear_clicked)));
541 items.push_back (SeparatorElem());
545 Menu* auto_state_menu = manage (new Menu);
546 auto_state_menu->set_name ("ArdourContextMenu");
547 MenuList& as_items = auto_state_menu->items();
549 as_items.push_back (CheckMenuElem (S_("Automation|Manual"), sigc::bind (
550 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
551 (AutoState) ARDOUR::Off)));
552 auto_off_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
554 as_items.push_back (CheckMenuElem (_("Play"), sigc::bind (
555 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
557 auto_play_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
559 as_items.push_back (CheckMenuElem (_("Write"), sigc::bind (
560 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
561 (AutoState) Write)));
562 auto_write_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
564 as_items.push_back (CheckMenuElem (_("Touch"), sigc::bind (
565 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
566 (AutoState) Touch)));
567 auto_touch_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
569 if (!(_parameter.type() >= MidiCCAutomation &&
570 _parameter.type() <= MidiChannelPressureAutomation)) {
571 items.push_back (MenuElem (_("State"), *auto_state_menu));
576 /* current interpolation state */
577 AutomationList::InterpolationStyle const s = _view ? _view->interpolation() : _control->list()->interpolation ();
579 if (ARDOUR::parameter_is_midi((AutomationType)_parameter.type())) {
581 Menu* auto_mode_menu = manage (new Menu);
582 auto_mode_menu->set_name ("ArdourContextMenu");
583 MenuList& am_items = auto_mode_menu->items();
585 RadioMenuItem::Group group;
587 am_items.push_back (RadioMenuElem (group, _("Discrete"), sigc::bind (
588 sigc::mem_fun(*this, &AutomationTimeAxisView::set_interpolation),
589 AutomationList::Discrete)));
590 mode_discrete_item = dynamic_cast<Gtk::CheckMenuItem*>(&am_items.back());
591 mode_discrete_item->set_active (s == AutomationList::Discrete);
593 am_items.push_back (RadioMenuElem (group, _("Linear"), sigc::bind (
594 sigc::mem_fun(*this, &AutomationTimeAxisView::set_interpolation),
595 AutomationList::Linear)));
596 mode_line_item = dynamic_cast<Gtk::CheckMenuItem*>(&am_items.back());
597 mode_line_item->set_active (s == AutomationList::Linear);
599 items.push_back (MenuElem (_("Mode"), *auto_mode_menu));
602 /* make sure the automation menu state is correct */
604 automation_state_changed ();
605 interpolation_changed (s);
609 AutomationTimeAxisView::add_automation_event (GdkEvent* event, framepos_t frame, double y, bool with_guard_points)
615 boost::shared_ptr<AutomationList> list = _line->the_list ();
617 if (list->in_write_pass()) {
618 /* do not allow the GUI to add automation events during an
619 automation write pass.
626 _line->grab_item().canvas_to_item (x, y);
628 /* compute vertical fractional position */
630 y = 1.0 - (y / _line->height());
634 _line->view_to_model_coord (x, y);
636 MusicFrame when (frame, 0);
637 _editor.snap_to_with_modifier (when, event);
639 XMLNode& before = list->get_state();
640 std::list<Selectable*> results;
642 if (list->editor_add (when.frame, y, with_guard_points)) {
643 XMLNode& after = list->get_state();
644 _editor.begin_reversible_command (_("add automation event"));
645 _session->add_command (new MementoCommand<ARDOUR::AutomationList> (*list.get (), &before, &after));
647 _line->get_selectables (when.frame, when.frame, 0.0, 1.0, results);
648 _editor.get_selection ().set (results);
650 _editor.commit_reversible_command ();
651 _session->set_dirty ();
656 AutomationTimeAxisView::paste (framepos_t pos, const Selection& selection, PasteContext& ctx, const int32_t divisions)
659 return paste_one (pos, ctx.count, ctx.times, selection, ctx.counts, ctx.greedy);
661 AutomationSelection::const_iterator l = selection.lines.get_nth(_parameter, ctx.counts.n_lines(_parameter));
662 if (l == selection.lines.end()) {
663 if (ctx.greedy && selection.lines.size() == 1) {
664 l = selection.lines.begin();
667 if (l != selection.lines.end() && _view->paste (pos, ctx.count, ctx.times, *l)) {
668 ctx.counts.increase_n_lines(_parameter);
677 AutomationTimeAxisView::paste_one (framepos_t pos, unsigned paste_count, float times, const Selection& selection, ItemCounts& counts, bool greedy)
679 boost::shared_ptr<AutomationList> alist(_line->the_list());
681 if (_session->transport_rolling() && alist->automation_write()) {
682 /* do not paste if this control is in write mode and we're rolling */
686 /* Get appropriate list from selection. */
687 AutomationSelection::const_iterator p = selection.lines.get_nth(_parameter, counts.n_lines(_parameter));
688 if (p == selection.lines.end()) {
689 if (greedy && selection.lines.size() == 1) {
690 p = selection.lines.begin();
695 counts.increase_n_lines(_parameter);
697 /* add multi-paste offset if applicable */
698 pos += _editor.get_paste_offset(pos, paste_count, (*p)->length());
700 double const model_pos = _line->time_converter().from (pos - _line->time_converter().origin_b ());
702 XMLNode &before = alist->get_state();
703 alist->paste (**p, model_pos, times);
704 _session->add_command (new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
710 AutomationTimeAxisView::get_selectables (framepos_t start, framepos_t end, double top, double bot, list<Selectable*>& results, bool /*within*/)
712 if (!_line && !_view) {
716 if (touched (top, bot)) {
718 /* remember: this is X Window - coordinate space starts in upper left and moves down.
719 _y_position is the "origin" or "top" of the track.
722 /* bottom of our track */
723 double const mybot = _y_position + height;
728 if (_y_position >= top && mybot <= bot) {
730 /* _y_position is below top, mybot is above bot, so we're fully
739 /* top and bot are within _y_position .. mybot */
741 topfrac = 1.0 - ((top - _y_position) / height);
742 botfrac = 1.0 - ((bot - _y_position) / height);
747 _line->get_selectables (start, end, botfrac, topfrac, results);
749 _view->get_selectables (start, end, botfrac, topfrac, results);
755 AutomationTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& result)
758 _line->get_inverted_selectables (sel, result);
763 AutomationTimeAxisView::set_selected_points (PointSelection& points)
766 _line->set_selected_points (points);
768 _view->set_selected_points (points);
773 AutomationTimeAxisView::clear_lines ()
776 _list_connections.drop_connections ();
780 AutomationTimeAxisView::add_line (boost::shared_ptr<AutomationLine> line)
782 if (_control && line) {
783 assert(line->the_list() == _control->list());
785 _control->alist()->automation_state_changed.connect (
786 _list_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::automation_state_changed, this), gui_context()
789 _control->alist()->InterpolationChanged.connect (
790 _list_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::interpolation_changed, this, _1), gui_context()
796 line->set_height (height - 2.5);
798 /* pick up the current state */
799 automation_state_changed ();
801 line->add_visibility (AutomationLine::Line);
805 AutomationTimeAxisView::entered()
808 _line->track_entered();
813 AutomationTimeAxisView::exited ()
816 _line->track_exited();
821 AutomationTimeAxisView::color_handler ()
829 AutomationTimeAxisView::set_state_2X (const XMLNode& node, int /*version*/)
831 if (node.name() == X_("gain") && _parameter == Evoral::Parameter (GainAutomation)) {
834 if (node.get_property (X_("shown"), shown)) {
836 _canvas_display->show (); /* FIXME: necessary? show_at? */
837 set_gui_property ("visible", shown);
840 set_gui_property ("visible", false);
848 AutomationTimeAxisView::set_state (const XMLNode&, int /*version*/)
854 AutomationTimeAxisView::what_has_visible_automation (const boost::shared_ptr<Automatable>& automatable, set<Evoral::Parameter>& visible)
856 /* this keeps "knowledge" of how we store visibility information
857 in XML private to this class.
860 assert (automatable);
862 Automatable::Controls& controls (automatable->controls());
864 for (Automatable::Controls::iterator i = controls.begin(); i != controls.end(); ++i) {
866 boost::shared_ptr<AutomationControl> ac = boost::dynamic_pointer_cast<AutomationControl> (i->second);
868 if (ac && ac->alist()) {
870 const XMLNode* gui_node = ac->extra_xml ("GUI");
874 if (gui_node->get_property ("shown", shown) && shown) {
875 visible.insert (i->first);
883 /** @return true if this view has any automation data to display */
885 AutomationTimeAxisView::has_automation () const
887 return ( (_line && _line->npoints() > 0) || (_view && _view->has_automation()) );
890 list<boost::shared_ptr<AutomationLine> >
891 AutomationTimeAxisView::lines () const
893 list<boost::shared_ptr<AutomationLine> > lines;
896 lines.push_back (_line);
898 lines = _view->get_lines ();
905 AutomationTimeAxisView::state_id() const
907 if (_automatable != _route && _control) {
908 return string("automation ") + _control->id().to_s();
909 } else if (_parameter) {
910 const string parameter_str = PBD::to_string (_parameter.type()) + "/" +
911 PBD::to_string (_parameter.id()) + "/" +
912 PBD::to_string (_parameter.channel ());
914 return string("automation ") + PBD::to_string(_route->id()) + " " + parameter_str;
916 error << "Automation time axis has no state ID" << endmsg;
921 /** Given a state id string, see if it is one generated by
922 * this class. If so, parse it into its components.
923 * @param state_id State ID string to parse.
924 * @param route_id Filled in with the route's ID if the state ID string is parsed.
925 * @param has_parameter Filled in with true if the state ID has a parameter, otherwise false.
926 * @param parameter Filled in with the state ID's parameter, if it has one.
927 * @return true if this is a state ID generated by this class, otherwise false.
931 AutomationTimeAxisView::parse_state_id (
932 string const & state_id,
934 bool & has_parameter,
935 Evoral::Parameter & parameter)
943 if (a != X_("automation")) {
947 route_id = PBD::ID (b);
950 has_parameter = false;
954 has_parameter = true;
957 boost::split (p, c, boost::is_any_of ("/"));
959 assert (p.size() == 3);
961 parameter = Evoral::Parameter (
962 PBD::string_to<uint32_t>(p[0]), // type
963 PBD::string_to<uint8_t>(p[2]), // channel
964 PBD::string_to<uint32_t>(p[1]) // id
971 AutomationTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
973 list<boost::shared_ptr<AutomationLine> > lines;
975 lines.push_back (_line);
977 lines = _view->get_lines ();
980 for (list<boost::shared_ptr<AutomationLine> >::iterator i = lines.begin(); i != lines.end(); ++i) {
981 cut_copy_clear_one (**i, selection, op);
986 AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& selection, CutCopyOp op)
988 boost::shared_ptr<Evoral::ControlList> what_we_got;
989 boost::shared_ptr<AutomationList> alist (line.the_list());
991 XMLNode &before = alist->get_state();
993 /* convert time selection to automation list model coordinates */
994 const Evoral::TimeConverter<double, ARDOUR::framepos_t>& tc = line.time_converter ();
995 double const start = tc.from (selection.time.front().start - tc.origin_b ());
996 double const end = tc.from (selection.time.front().end - tc.origin_b ());
1000 if (alist->cut (start, end) != 0) {
1001 _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
1007 if ((what_we_got = alist->cut (start, end)) != 0) {
1008 _editor.get_cut_buffer().add (what_we_got);
1009 _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
1013 if ((what_we_got = alist->copy (start, end)) != 0) {
1014 _editor.get_cut_buffer().add (what_we_got);
1019 if ((what_we_got = alist->cut (start, end)) != 0) {
1020 _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
1026 for (AutomationList::iterator x = what_we_got->begin(); x != what_we_got->end(); ++x) {
1027 double when = (*x)->when;
1028 double val = (*x)->value;
1029 line.model_to_view_coord (when, val);
1036 PresentationInfo const &
1037 AutomationTimeAxisView::presentation_info () const
1039 return _route->presentation_info();
1042 boost::shared_ptr<Stripable>
1043 AutomationTimeAxisView::stripable () const
1049 AutomationTimeAxisView::color () const
1051 return gdk_color_from_rgb (_route->presentation_info().color());