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>
24 #include <boost/lexical_cast.hpp>
26 #include "pbd/error.h"
27 #include "pbd/memento_command.h"
28 #include "pbd/stacktrace.h"
30 #include "ardour/automation_control.h"
31 #include "ardour/event_type_map.h"
32 #include "ardour/parameter_types.h"
33 #include "ardour/profile.h"
34 #include "ardour/route.h"
35 #include "ardour/session.h"
37 #include "canvas/debug.h"
39 #include "ardour_ui.h"
40 #include "automation_time_axis.h"
41 #include "automation_streamview.h"
42 #include "global_signals.h"
43 #include "gui_thread.h"
44 #include "route_time_axis.h"
45 #include "automation_line.h"
46 #include "paste_context.h"
47 #include "public_editor.h"
48 #include "selection.h"
49 #include "rgb_macros.h"
50 #include "point_selection.h"
51 #include "control_point.h"
53 #include "item_counts.h"
58 using namespace ARDOUR;
59 using namespace ARDOUR_UI_UTILS;
62 using namespace Gtkmm2ext;
63 using namespace Editing;
65 Pango::FontDescription AutomationTimeAxisView::name_font;
66 bool AutomationTimeAxisView::have_name_font = false;
69 /** \a a the automatable object this time axis is to display data for.
70 * For route/track automation (e.g. gain) pass the route for both \r and \a.
71 * For route child (e.g. plugin) automation, pass the child for \a.
72 * For region automation (e.g. MIDI CC), pass null for \a.
74 AutomationTimeAxisView::AutomationTimeAxisView (
76 boost::shared_ptr<Route> r,
77 boost::shared_ptr<Automatable> a,
78 boost::shared_ptr<AutomationControl> c,
83 ArdourCanvas::Canvas& canvas,
85 const string & nomparent
88 , TimeAxisView (s, e, &parent, canvas)
93 , _base_rect (new ArdourCanvas::Rectangle (_canvas_display))
95 , _view (show_regions ? new AutomationStreamView (*this) : 0)
96 , auto_button (X_("")) /* force addition of a label */
97 , _show_regions (show_regions)
100 CANVAS_DEBUG_NAME (_canvas_display, string_compose ("main for auto %2/%1", _name, r->name()));
101 CANVAS_DEBUG_NAME (selection_group, string_compose ("selections for auto %2/%1", _name, r->name()));
102 CANVAS_DEBUG_NAME (_ghost_group, string_compose ("ghosts for auto %2/%1", _name, r->name()));
104 if (!have_name_font) {
105 name_font = get_font_for_style (X_("AutomationTrackName"));
106 have_name_font = true;
109 if (_automatable && _control) {
110 _controller = AutomationController::create (_automatable, _control->parameter(), _control->desc(), _control);
113 const std::string fill_color_name = (dynamic_cast<MidiTimeAxisView*>(&parent)
114 ? "midi automation track fill"
115 : "audio automation track fill");
122 mode_discrete_item = 0;
125 ignore_state_request = false;
126 first_call_to_set_height = true;
128 CANVAS_DEBUG_NAME (_base_rect, string_compose ("base rect for %1", _name));
129 _base_rect->set_x1 (ArdourCanvas::COORD_MAX);
130 _base_rect->set_outline (false);
131 _base_rect->set_fill_color (ARDOUR_UI::config()->color_mod (fill_color_name, "automation track fill"));
132 _base_rect->set_data ("trackview", this);
133 _base_rect->Event.connect (sigc::bind (sigc::mem_fun (_editor, &PublicEditor::canvas_automation_track_event), _base_rect, this));
135 _base_rect->lower_to_bottom();
138 hide_button.set_elements ((ArdourButton::Element)(ArdourButton::Edge|ArdourButton::Body|ArdourButton::CloseCross));
139 hide_button.set_tweaks(ArdourButton::TrackHeader);
141 auto_button.set_name ("route button");
142 hide_button.set_name ("route button");
144 auto_button.unset_flags (Gtk::CAN_FOCUS);
145 hide_button.unset_flags (Gtk::CAN_FOCUS);
147 controls_table.set_no_show_all();
149 ARDOUR_UI::instance()->set_tip(auto_button, _("automation state"));
150 ARDOUR_UI::instance()->set_tip(hide_button, _("hide track"));
152 const string str = gui_property ("height");
154 set_height (atoi (str));
156 set_height (preset_height (HeightNormal));
159 //name label isn't editable on an automation track; remove the tooltip
160 ARDOUR_UI::instance()->set_tip (name_label, X_(""));
162 /* repack the name label */
164 if (name_label.get_parent()) {
165 name_label.get_parent()->remove (name_label);
168 name_label.set_text (_name);
169 name_label.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
170 name_label.set_name (X_("TrackParameterName"));
171 name_label.set_ellipsize (Pango::ELLIPSIZE_END);
173 string tipname = nomparent;
174 if (!tipname.empty()) {
178 ARDOUR_UI::instance()->set_tip(controls_ebox, tipname);
180 /* add the buttons */
181 controls_table.set_border_width (1);
182 controls_table.remove (name_hbox);
183 controls_table.attach (hide_button, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
184 controls_table.attach (name_label, 2, 3, 1, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 2, 0);
185 controls_table.attach (auto_button, 3, 4, 2, 3, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
187 Gtk::DrawingArea *blank0 = manage (new Gtk::DrawingArea());
188 Gtk::DrawingArea *blank1 = manage (new Gtk::DrawingArea());
190 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&parent);
191 // TODO use rtv->controls_base_unselected_name
192 // subscribe to route_active_changed, ...
193 if (rtv && rtv->is_audio_track()) {
194 blank0->set_name ("AudioTrackControlsBaseUnselected");
196 else if (rtv && rtv->is_midi_track()) {
197 blank0->set_name ("MidiTrackControlsBaseUnselected");
200 blank0->set_name ("AudioBusControlsBaseUnselected");
202 blank0->set_size_request (-1, -1);
203 blank1->set_size_request (1, 0);
204 VSeparator* separator = manage (new VSeparator());
205 separator->set_name("TrackSeparator");
206 separator->set_size_request (1, -1);
208 controls_button_size_group->add_widget(hide_button);
209 controls_button_size_group->add_widget(*blank0);
211 time_axis_hbox.pack_start (*blank0, false, false);
212 time_axis_hbox.pack_start (*separator, false, false);
213 time_axis_hbox.reorder_child (*blank0, 0);
214 time_axis_hbox.reorder_child (*separator, 1);
215 time_axis_hbox.reorder_child (time_axis_vbox, 2);
217 if (!ARDOUR::Profile->get_mixbus() ) {
218 time_axis_hbox.pack_start (*blank1, false, false);
227 _controller->disable_vertical_scroll ();
228 controls_table.attach (*_controller.get(), 2, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
231 controls_table.show_all ();
233 hide_button.signal_clicked.connect (sigc::mem_fun(*this, &AutomationTimeAxisView::hide_clicked));
234 auto_button.signal_clicked.connect (sigc::mem_fun(*this, &AutomationTimeAxisView::auto_clicked));
236 controls_base_selected_name = X_("AutomationTrackControlsBaseSelected");
237 controls_base_unselected_name = X_("AutomationTrackControlsBase");
239 controls_ebox.set_name (controls_base_unselected_name);
240 time_axis_frame.set_name (controls_base_unselected_name);
242 /* ask for notifications of any new RegionViews */
250 /* no regions, just a single line for the entire track (e.g. bus gain) */
254 boost::shared_ptr<AutomationLine> line (
256 ARDOUR::EventTypeMap::instance().to_symbol(_parameter),
264 line->set_line_color (ARDOUR_UI::config()->color ("processor automation line"));
265 line->queue_reset ();
269 /* make sure labels etc. are correct */
271 automation_state_changed ();
272 ColorsChanged.connect (sigc::mem_fun (*this, &AutomationTimeAxisView::color_handler));
274 _route->DropReferences.connect (
275 _route_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::route_going_away, this), gui_context ()
279 AutomationTimeAxisView::~AutomationTimeAxisView ()
285 AutomationTimeAxisView::route_going_away ()
291 AutomationTimeAxisView::auto_clicked ()
293 using namespace Menu_Helpers;
295 if (automation_menu == 0) {
296 automation_menu = manage (new Menu);
297 automation_menu->set_name ("ArdourContextMenu");
298 MenuList& items (automation_menu->items());
300 items.push_back (MenuElem (S_("Automation|Manual"), sigc::bind (sigc::mem_fun(*this,
301 &AutomationTimeAxisView::set_automation_state), (AutoState) ARDOUR::Off)));
302 items.push_back (MenuElem (_("Play"), sigc::bind (sigc::mem_fun(*this,
303 &AutomationTimeAxisView::set_automation_state), (AutoState) Play)));
304 items.push_back (MenuElem (_("Write"), sigc::bind (sigc::mem_fun(*this,
305 &AutomationTimeAxisView::set_automation_state), (AutoState) Write)));
306 items.push_back (MenuElem (_("Touch"), sigc::bind (sigc::mem_fun(*this,
307 &AutomationTimeAxisView::set_automation_state), (AutoState) Touch)));
310 automation_menu->popup (1, gtk_get_current_event_time());
314 AutomationTimeAxisView::set_automation_state (AutoState state)
316 if (ignore_state_request) {
321 _automatable->set_parameter_automation_state (_parameter, state);
325 _view->set_automation_state (state);
327 /* AutomationStreamViews don't signal when their automation state changes, so handle
328 our updates `manually'.
330 automation_state_changed ();
335 AutomationTimeAxisView::automation_state_changed ()
339 /* update button label */
342 state = _view->automation_state ();
345 state = _control->alist()->automation_state ();
350 switch (state & (ARDOUR::Off|Play|Touch|Write)) {
352 auto_button.set_text (S_("Automation|Manual"));
354 ignore_state_request = true;
355 auto_off_item->set_active (true);
356 auto_play_item->set_active (false);
357 auto_touch_item->set_active (false);
358 auto_write_item->set_active (false);
359 ignore_state_request = false;
363 auto_button.set_text (_("Play"));
364 if (auto_play_item) {
365 ignore_state_request = true;
366 auto_play_item->set_active (true);
367 auto_off_item->set_active (false);
368 auto_touch_item->set_active (false);
369 auto_write_item->set_active (false);
370 ignore_state_request = false;
374 auto_button.set_text (_("Write"));
375 if (auto_write_item) {
376 ignore_state_request = true;
377 auto_write_item->set_active (true);
378 auto_off_item->set_active (false);
379 auto_play_item->set_active (false);
380 auto_touch_item->set_active (false);
381 ignore_state_request = false;
385 auto_button.set_text (_("Touch"));
386 if (auto_touch_item) {
387 ignore_state_request = true;
388 auto_touch_item->set_active (true);
389 auto_off_item->set_active (false);
390 auto_play_item->set_active (false);
391 auto_write_item->set_active (false);
392 ignore_state_request = false;
396 auto_button.set_text (_("???"));
401 /** The interpolation style of our AutomationList has changed, so update */
403 AutomationTimeAxisView::interpolation_changed (AutomationList::InterpolationStyle s)
405 if (mode_line_item && mode_discrete_item) {
406 if (s == AutomationList::Discrete) {
407 mode_discrete_item->set_active(true);
408 mode_line_item->set_active(false);
410 mode_line_item->set_active(true);
411 mode_discrete_item->set_active(false);
416 /** A menu item has been selected to change our interpolation mode */
418 AutomationTimeAxisView::set_interpolation (AutomationList::InterpolationStyle style)
420 /* Tell our view's list, if we have one, otherwise tell our own.
421 * Everything else will be signalled back from that.
425 _view->set_interpolation (style);
428 _control->list()->set_interpolation (style);
433 AutomationTimeAxisView::clear_clicked ()
435 assert (_line || _view);
437 _editor.begin_reversible_command (_("clear automation"));
445 _editor.commit_reversible_command ();
446 _session->set_dirty ();
450 AutomationTimeAxisView::set_height (uint32_t h)
452 bool const changed = (height != (uint32_t) h) || first_call_to_set_height;
453 uint32_t const normal = preset_height (HeightNormal);
454 bool const changed_between_small_and_normal = ( (height < normal && h >= normal) || (height >= normal || h < normal) );
456 TimeAxisView::set_height (h);
458 _base_rect->set_y1 (h);
461 _line->set_height(h);
465 _view->set_height(h);
466 _view->update_contents_height();
469 if (changed_between_small_and_normal || first_call_to_set_height) {
471 first_call_to_set_height = false;
473 if (h >= preset_height (HeightNormal)) {
474 if (!(_parameter.type() >= MidiCCAutomation &&
475 _parameter.type() <= MidiChannelPressureAutomation)) {
481 } else if (h >= preset_height (HeightSmall)) {
482 controls_table.hide_all ();
489 if (_canvas_display->visible() && _route) {
490 /* only emit the signal if the height really changed and we were visible */
491 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
497 AutomationTimeAxisView::set_samples_per_pixel (double fpp)
499 TimeAxisView::set_samples_per_pixel (fpp);
506 _view->set_samples_per_pixel (fpp);
511 AutomationTimeAxisView::hide_clicked ()
513 hide_button.set_sensitive(false);
514 set_marked_for_display (false);
515 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(parent);
517 rtv->request_redraw ();
519 hide_button.set_sensitive(true);
523 AutomationTimeAxisView::build_display_menu ()
525 using namespace Menu_Helpers;
529 TimeAxisView::build_display_menu ();
531 /* now fill it with our stuff */
533 MenuList& items = display_menu->items();
535 items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &AutomationTimeAxisView::hide_clicked)));
536 items.push_back (SeparatorElem());
537 items.push_back (MenuElem (_("Clear"), sigc::mem_fun(*this, &AutomationTimeAxisView::clear_clicked)));
538 items.push_back (SeparatorElem());
542 Menu* auto_state_menu = manage (new Menu);
543 auto_state_menu->set_name ("ArdourContextMenu");
544 MenuList& as_items = auto_state_menu->items();
546 as_items.push_back (CheckMenuElem (S_("Automation|Manual"), sigc::bind (
547 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
548 (AutoState) ARDOUR::Off)));
549 auto_off_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
551 as_items.push_back (CheckMenuElem (_("Play"), sigc::bind (
552 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
554 auto_play_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
556 as_items.push_back (CheckMenuElem (_("Write"), sigc::bind (
557 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
558 (AutoState) Write)));
559 auto_write_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
561 as_items.push_back (CheckMenuElem (_("Touch"), sigc::bind (
562 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
563 (AutoState) Touch)));
564 auto_touch_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
566 if (!(_parameter.type() >= MidiCCAutomation &&
567 _parameter.type() <= MidiChannelPressureAutomation)) {
568 items.push_back (MenuElem (_("State"), *auto_state_menu));
573 /* current interpolation state */
574 AutomationList::InterpolationStyle const s = _view ? _view->interpolation() : _control->list()->interpolation ();
576 if (ARDOUR::parameter_is_midi((AutomationType)_parameter.type())) {
578 Menu* auto_mode_menu = manage (new Menu);
579 auto_mode_menu->set_name ("ArdourContextMenu");
580 MenuList& am_items = auto_mode_menu->items();
582 RadioMenuItem::Group group;
584 am_items.push_back (RadioMenuElem (group, _("Discrete"), sigc::bind (
585 sigc::mem_fun(*this, &AutomationTimeAxisView::set_interpolation),
586 AutomationList::Discrete)));
587 mode_discrete_item = dynamic_cast<Gtk::CheckMenuItem*>(&am_items.back());
588 mode_discrete_item->set_active (s == AutomationList::Discrete);
590 am_items.push_back (RadioMenuElem (group, _("Linear"), sigc::bind (
591 sigc::mem_fun(*this, &AutomationTimeAxisView::set_interpolation),
592 AutomationList::Linear)));
593 mode_line_item = dynamic_cast<Gtk::CheckMenuItem*>(&am_items.back());
594 mode_line_item->set_active (s == AutomationList::Linear);
596 items.push_back (MenuElem (_("Mode"), *auto_mode_menu));
599 /* make sure the automation menu state is correct */
601 automation_state_changed ();
602 interpolation_changed (s);
606 AutomationTimeAxisView::add_automation_event (GdkEvent* event, framepos_t when, double y, bool with_guard_points)
612 boost::shared_ptr<AutomationList> list = _line->the_list ();
614 if (list->in_write_pass()) {
615 /* do not allow the GUI to add automation events during an
616 automation write pass.
623 _canvas_display->canvas_to_item (x, y);
625 /* compute vertical fractional position */
627 y = 1.0 - (y / height);
631 _line->view_to_model_coord (x, y);
634 _editor.snap_to_with_modifier (when, event);
636 _editor.begin_reversible_command (_("add automation event"));
637 XMLNode& before = list->get_state();
639 list->add (when, y, with_guard_points);
641 XMLNode& after = list->get_state();
642 _session->add_command (new MementoCommand<ARDOUR::AutomationList> (*list, &before, &after));
643 _editor.commit_reversible_command ();
644 _session->set_dirty ();
648 AutomationTimeAxisView::paste (framepos_t pos, const Selection& selection, PasteContext& ctx)
651 return paste_one (pos, ctx.count, ctx.times, selection, ctx.counts, ctx.greedy);
653 AutomationSelection::const_iterator l = selection.lines.get_nth(_parameter, ctx.counts.n_lines(_parameter));
654 if (l == selection.lines.end()) {
655 if (ctx.greedy && selection.lines.size() == 1) {
656 l = selection.lines.begin();
659 if (l != selection.lines.end() && _view->paste (pos, ctx.count, ctx.times, *l)) {
660 ctx.counts.increase_n_lines(_parameter);
669 AutomationTimeAxisView::paste_one (framepos_t pos, unsigned paste_count, float times, const Selection& selection, ItemCounts& counts, bool greedy)
671 boost::shared_ptr<AutomationList> alist(_line->the_list());
673 if (_session->transport_rolling() && alist->automation_write()) {
674 /* do not paste if this control is in write mode and we're rolling */
678 /* Get appropriate list from selection. */
679 AutomationSelection::const_iterator p = selection.lines.get_nth(_parameter, counts.n_lines(_parameter));
680 if (p == selection.lines.end()) {
681 if (greedy && selection.lines.size() == 1) {
682 p = selection.lines.begin();
687 counts.increase_n_lines(_parameter);
689 /* add multi-paste offset if applicable */
690 pos += _editor.get_paste_offset(pos, paste_count, (*p)->length());
692 double const model_pos = _line->time_converter().from (pos - _line->time_converter().origin_b ());
694 XMLNode &before = alist->get_state();
695 alist->paste (**p, model_pos, times);
696 _session->add_command (new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
702 AutomationTimeAxisView::get_selectables (framepos_t start, framepos_t end, double top, double bot, list<Selectable*>& results, bool /*within*/)
704 if (!_line && !_view) {
708 if (touched (top, bot)) {
710 /* remember: this is X Window - coordinate space starts in upper left and moves down.
711 _y_position is the "origin" or "top" of the track.
714 /* bottom of our track */
715 double const mybot = _y_position + height;
720 if (_y_position >= top && mybot <= bot) {
722 /* _y_position is below top, mybot is above bot, so we're fully
731 /* top and bot are within _y_position .. mybot */
733 topfrac = 1.0 - ((top - _y_position) / height);
734 botfrac = 1.0 - ((bot - _y_position) / height);
739 _line->get_selectables (start, end, botfrac, topfrac, results);
741 _view->get_selectables (start, end, botfrac, topfrac, results);
747 AutomationTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& result)
750 _line->get_inverted_selectables (sel, result);
755 AutomationTimeAxisView::set_selected_points (PointSelection& points)
758 _line->set_selected_points (points);
760 _view->set_selected_points (points);
765 AutomationTimeAxisView::clear_lines ()
768 _list_connections.drop_connections ();
772 AutomationTimeAxisView::add_line (boost::shared_ptr<AutomationLine> line)
774 if (_control && line) {
775 assert(line->the_list() == _control->list());
777 _control->alist()->automation_state_changed.connect (
778 _list_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::automation_state_changed, this), gui_context()
781 _control->alist()->InterpolationChanged.connect (
782 _list_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::interpolation_changed, this, _1), gui_context()
788 line->set_height (height);
790 /* pick up the current state */
791 automation_state_changed ();
793 line->add_visibility (AutomationLine::Line);
797 AutomationTimeAxisView::entered()
800 _line->track_entered();
805 AutomationTimeAxisView::exited ()
808 _line->track_exited();
813 AutomationTimeAxisView::color_handler ()
821 AutomationTimeAxisView::set_state_2X (const XMLNode& node, int /*version*/)
823 if (node.name() == X_("gain") && _parameter == Evoral::Parameter (GainAutomation)) {
824 XMLProperty const * shown = node.property (X_("shown"));
826 bool yn = string_is_affirmative (shown->value ());
828 _canvas_display->show (); /* FIXME: necessary? show_at? */
830 set_gui_property ("visible", yn);
832 set_gui_property ("visible", false);
840 AutomationTimeAxisView::set_state (const XMLNode&, int /*version*/)
846 AutomationTimeAxisView::what_has_visible_automation (const boost::shared_ptr<Automatable>& automatable, set<Evoral::Parameter>& visible)
848 /* this keeps "knowledge" of how we store visibility information
849 in XML private to this class.
852 assert (automatable);
854 Automatable::Controls& controls (automatable->controls());
856 for (Automatable::Controls::iterator i = controls.begin(); i != controls.end(); ++i) {
858 boost::shared_ptr<AutomationControl> ac = boost::dynamic_pointer_cast<AutomationControl> (i->second);
860 if (ac && ac->alist()) {
862 const XMLNode* gui_node = ac->extra_xml ("GUI");
865 const XMLProperty* prop = gui_node->property ("shown");
867 if (string_is_affirmative (prop->value())) {
868 visible.insert (i->first);
877 /** @return true if this view has any automation data to display */
879 AutomationTimeAxisView::has_automation () const
881 return ( (_line && _line->npoints() > 0) || (_view && _view->has_automation()) );
884 list<boost::shared_ptr<AutomationLine> >
885 AutomationTimeAxisView::lines () const
887 list<boost::shared_ptr<AutomationLine> > lines;
890 lines.push_back (_line);
892 lines = _view->get_lines ();
899 AutomationTimeAxisView::state_id() const
901 if (_automatable != _route && _control) {
902 return string_compose ("automation %1", _control->id().to_s());
903 } else if (_parameter) {
904 return string_compose ("automation %1 %2/%3/%4",
908 (int) _parameter.channel());
910 error << "Automation time axis has no state ID" << endmsg;
915 /** Given a state id string, see if it is one generated by
916 * this class. If so, parse it into its components.
917 * @param state_id State ID string to parse.
918 * @param route_id Filled in with the route's ID if the state ID string is parsed.
919 * @param has_parameter Filled in with true if the state ID has a parameter, otherwise false.
920 * @param parameter Filled in with the state ID's parameter, if it has one.
921 * @return true if this is a state ID generated by this class, otherwise false.
925 AutomationTimeAxisView::parse_state_id (
926 string const & state_id,
928 bool & has_parameter,
929 Evoral::Parameter & parameter)
937 if (a != X_("automation")) {
941 route_id = PBD::ID (b);
944 has_parameter = false;
948 has_parameter = true;
951 boost::split (p, c, boost::is_any_of ("/"));
953 assert (p.size() == 3);
955 parameter = Evoral::Parameter (
956 boost::lexical_cast<int> (p[0]),
957 boost::lexical_cast<int> (p[2]),
958 boost::lexical_cast<int> (p[1])
965 AutomationTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
967 list<boost::shared_ptr<AutomationLine> > lines;
969 lines.push_back (_line);
971 lines = _view->get_lines ();
974 for (list<boost::shared_ptr<AutomationLine> >::iterator i = lines.begin(); i != lines.end(); ++i) {
975 cut_copy_clear_one (**i, selection, op);
980 AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& selection, CutCopyOp op)
982 boost::shared_ptr<Evoral::ControlList> what_we_got;
983 boost::shared_ptr<AutomationList> alist (line.the_list());
985 XMLNode &before = alist->get_state();
987 /* convert time selection to automation list model coordinates */
988 const Evoral::TimeConverter<double, ARDOUR::framepos_t>& tc = line.time_converter ();
989 double const start = tc.from (selection.time.front().start - tc.origin_b ());
990 double const end = tc.from (selection.time.front().end - tc.origin_b ());
994 if (alist->cut (start, end) != 0) {
995 _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
1001 if ((what_we_got = alist->cut (start, end)) != 0) {
1002 _editor.get_cut_buffer().add (what_we_got);
1003 _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
1007 if ((what_we_got = alist->copy (start, end)) != 0) {
1008 _editor.get_cut_buffer().add (what_we_got);
1013 if ((what_we_got = alist->cut (start, end)) != 0) {
1014 _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
1020 for (AutomationList::iterator x = what_we_got->begin(); x != what_we_got->end(); ++x) {
1021 double when = (*x)->when;
1022 double val = (*x)->value;
1023 line.model_to_view_coord (when, val);