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);
118 mode_discrete_item = 0;
121 ignore_state_request = false;
122 first_call_to_set_height = true;
124 CANVAS_DEBUG_NAME (_base_rect, string_compose ("base rect for %1", _name));
125 _base_rect->set_x1 (ArdourCanvas::COORD_MAX);
126 _base_rect->set_outline (false);
127 _base_rect->set_fill_color (ARDOUR_UI::config()->color ("automation track fill"));
128 _base_rect->set_data ("trackview", this);
129 _base_rect->Event.connect (sigc::bind (sigc::mem_fun (_editor, &PublicEditor::canvas_automation_track_event), _base_rect, this));
131 _base_rect->lower_to_bottom();
134 hide_button.set_elements ((ArdourButton::Element)(ArdourButton::Edge|ArdourButton::Body|ArdourButton::CloseCross));
135 hide_button.set_tweaks(ArdourButton::TrackHeader);
137 auto_button.set_name ("route button");
138 hide_button.set_name ("route button");
140 auto_button.unset_flags (Gtk::CAN_FOCUS);
141 hide_button.unset_flags (Gtk::CAN_FOCUS);
143 controls_table.set_no_show_all();
145 ARDOUR_UI::instance()->set_tip(auto_button, _("automation state"));
146 ARDOUR_UI::instance()->set_tip(hide_button, _("hide track"));
148 const string str = gui_property ("height");
150 set_height (atoi (str));
152 set_height (preset_height (HeightNormal));
155 //name label isn't editable on an automation track; remove the tooltip
156 ARDOUR_UI::instance()->set_tip (name_label, X_(""));
158 /* repack the name label */
160 if (name_label.get_parent()) {
161 name_label.get_parent()->remove (name_label);
164 name_label.set_text (_name);
165 name_label.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
166 name_label.set_name (X_("TrackParameterName"));
167 name_label.set_ellipsize (Pango::ELLIPSIZE_END);
169 string tipname = nomparent;
170 if (!tipname.empty()) {
174 ARDOUR_UI::instance()->set_tip(controls_ebox, tipname);
176 /* add the buttons */
177 controls_table.set_border_width (1);
178 controls_table.remove (name_hbox);
179 controls_table.attach (hide_button, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
180 controls_table.attach (name_label, 2, 3, 1, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 2, 0);
181 controls_table.attach (auto_button, 3, 4, 2, 3, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
183 Gtk::DrawingArea *blank0 = manage (new Gtk::DrawingArea());
184 Gtk::DrawingArea *blank1 = manage (new Gtk::DrawingArea());
186 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&parent);
187 // TODO use rtv->controls_base_unselected_name
188 // subscribe to route_active_changed, ...
189 if (rtv && rtv->is_audio_track()) {
190 blank0->set_name ("AudioTrackControlsBaseUnselected");
192 else if (rtv && rtv->is_midi_track()) {
193 blank0->set_name ("MidiTrackControlsBaseUnselected");
196 blank0->set_name ("AudioBusControlsBaseUnselected");
198 blank0->set_size_request (-1, -1);
199 blank1->set_size_request (1, 0);
200 VSeparator* separator = manage (new VSeparator());
201 separator->set_name("TrackSeparator");
202 separator->set_size_request (1, -1);
204 controls_button_size_group->add_widget(hide_button);
205 controls_button_size_group->add_widget(*blank0);
207 time_axis_hbox.pack_start (*blank0, false, false);
208 time_axis_hbox.pack_start (*separator, false, false);
209 time_axis_hbox.reorder_child (*blank0, 0);
210 time_axis_hbox.reorder_child (*separator, 1);
211 time_axis_hbox.reorder_child (time_axis_vbox, 2);
213 if (!ARDOUR::Profile->get_mixbus() ) {
214 time_axis_hbox.pack_start (*blank1, false, false);
223 _controller->disable_vertical_scroll ();
224 controls_table.attach (*_controller.get(), 2, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
227 controls_table.show_all ();
229 hide_button.signal_clicked.connect (sigc::mem_fun(*this, &AutomationTimeAxisView::hide_clicked));
230 auto_button.signal_clicked.connect (sigc::mem_fun(*this, &AutomationTimeAxisView::auto_clicked));
232 controls_base_selected_name = X_("AutomationTrackControlsBaseSelected");
233 controls_base_unselected_name = X_("AutomationTrackControlsBase");
235 controls_ebox.set_name (controls_base_unselected_name);
236 time_axis_frame.set_name (controls_base_unselected_name);
238 /* ask for notifications of any new RegionViews */
246 /* no regions, just a single line for the entire track (e.g. bus gain) */
250 boost::shared_ptr<AutomationLine> line (
252 ARDOUR::EventTypeMap::instance().to_symbol(_parameter),
260 line->set_line_color (ARDOUR_UI::config()->color ("processor automation line"));
261 line->queue_reset ();
265 /* make sure labels etc. are correct */
267 automation_state_changed ();
268 ColorsChanged.connect (sigc::mem_fun (*this, &AutomationTimeAxisView::color_handler));
270 _route->DropReferences.connect (
271 _route_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::route_going_away, this), gui_context ()
275 AutomationTimeAxisView::~AutomationTimeAxisView ()
281 AutomationTimeAxisView::route_going_away ()
287 AutomationTimeAxisView::auto_clicked ()
289 using namespace Menu_Helpers;
291 if (automation_menu == 0) {
292 automation_menu = manage (new Menu);
293 automation_menu->set_name ("ArdourContextMenu");
294 MenuList& items (automation_menu->items());
296 items.push_back (MenuElem (S_("Automation|Manual"), sigc::bind (sigc::mem_fun(*this,
297 &AutomationTimeAxisView::set_automation_state), (AutoState) ARDOUR::Off)));
298 items.push_back (MenuElem (_("Play"), sigc::bind (sigc::mem_fun(*this,
299 &AutomationTimeAxisView::set_automation_state), (AutoState) Play)));
300 items.push_back (MenuElem (_("Write"), sigc::bind (sigc::mem_fun(*this,
301 &AutomationTimeAxisView::set_automation_state), (AutoState) Write)));
302 items.push_back (MenuElem (_("Touch"), sigc::bind (sigc::mem_fun(*this,
303 &AutomationTimeAxisView::set_automation_state), (AutoState) Touch)));
306 automation_menu->popup (1, gtk_get_current_event_time());
310 AutomationTimeAxisView::set_automation_state (AutoState state)
312 if (ignore_state_request) {
317 _automatable->set_parameter_automation_state (_parameter, state);
321 _view->set_automation_state (state);
323 /* AutomationStreamViews don't signal when their automation state changes, so handle
324 our updates `manually'.
326 automation_state_changed ();
331 AutomationTimeAxisView::automation_state_changed ()
335 /* update button label */
338 state = _view->automation_state ();
341 state = _control->alist()->automation_state ();
346 switch (state & (ARDOUR::Off|Play|Touch|Write)) {
348 auto_button.set_text (S_("Automation|Manual"));
350 ignore_state_request = true;
351 auto_off_item->set_active (true);
352 auto_play_item->set_active (false);
353 auto_touch_item->set_active (false);
354 auto_write_item->set_active (false);
355 ignore_state_request = false;
359 auto_button.set_text (_("Play"));
360 if (auto_play_item) {
361 ignore_state_request = true;
362 auto_play_item->set_active (true);
363 auto_off_item->set_active (false);
364 auto_touch_item->set_active (false);
365 auto_write_item->set_active (false);
366 ignore_state_request = false;
370 auto_button.set_text (_("Write"));
371 if (auto_write_item) {
372 ignore_state_request = true;
373 auto_write_item->set_active (true);
374 auto_off_item->set_active (false);
375 auto_play_item->set_active (false);
376 auto_touch_item->set_active (false);
377 ignore_state_request = false;
381 auto_button.set_text (_("Touch"));
382 if (auto_touch_item) {
383 ignore_state_request = true;
384 auto_touch_item->set_active (true);
385 auto_off_item->set_active (false);
386 auto_play_item->set_active (false);
387 auto_write_item->set_active (false);
388 ignore_state_request = false;
392 auto_button.set_text (_("???"));
397 /** The interpolation style of our AutomationList has changed, so update */
399 AutomationTimeAxisView::interpolation_changed (AutomationList::InterpolationStyle s)
401 if (mode_line_item && mode_discrete_item) {
402 if (s == AutomationList::Discrete) {
403 mode_discrete_item->set_active(true);
404 mode_line_item->set_active(false);
406 mode_line_item->set_active(true);
407 mode_discrete_item->set_active(false);
412 /** A menu item has been selected to change our interpolation mode */
414 AutomationTimeAxisView::set_interpolation (AutomationList::InterpolationStyle style)
416 /* Tell our view's list, if we have one, otherwise tell our own.
417 * Everything else will be signalled back from that.
421 _view->set_interpolation (style);
424 _control->list()->set_interpolation (style);
429 AutomationTimeAxisView::clear_clicked ()
431 assert (_line || _view);
433 _session->begin_reversible_command (_("clear automation"));
441 _session->commit_reversible_command ();
442 _session->set_dirty ();
446 AutomationTimeAxisView::set_height (uint32_t h)
448 bool const changed = (height != (uint32_t) h) || first_call_to_set_height;
449 uint32_t const normal = preset_height (HeightNormal);
450 bool const changed_between_small_and_normal = ( (height < normal && h >= normal) || (height >= normal || h < normal) );
452 TimeAxisView::set_height (h);
454 _base_rect->set_y1 (h);
457 _line->set_height(h);
461 _view->set_height(h);
462 _view->update_contents_height();
465 if (changed_between_small_and_normal || first_call_to_set_height) {
467 first_call_to_set_height = false;
469 if (h >= preset_height (HeightNormal)) {
474 } else if (h >= preset_height (HeightSmall)) {
475 controls_table.hide_all ();
482 if (_canvas_display->visible() && _route) {
483 /* only emit the signal if the height really changed and we were visible */
484 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
490 AutomationTimeAxisView::set_samples_per_pixel (double fpp)
492 TimeAxisView::set_samples_per_pixel (fpp);
499 _view->set_samples_per_pixel (fpp);
504 AutomationTimeAxisView::hide_clicked ()
506 hide_button.set_sensitive(false);
507 set_marked_for_display (false);
508 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(parent);
510 rtv->request_redraw ();
512 hide_button.set_sensitive(true);
516 AutomationTimeAxisView::build_display_menu ()
518 using namespace Menu_Helpers;
522 TimeAxisView::build_display_menu ();
524 /* now fill it with our stuff */
526 MenuList& items = display_menu->items();
528 items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &AutomationTimeAxisView::hide_clicked)));
529 items.push_back (SeparatorElem());
530 items.push_back (MenuElem (_("Clear"), sigc::mem_fun(*this, &AutomationTimeAxisView::clear_clicked)));
531 items.push_back (SeparatorElem());
535 Menu* auto_state_menu = manage (new Menu);
536 auto_state_menu->set_name ("ArdourContextMenu");
537 MenuList& as_items = auto_state_menu->items();
539 as_items.push_back (CheckMenuElem (S_("Automation|Manual"), sigc::bind (
540 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
541 (AutoState) ARDOUR::Off)));
542 auto_off_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
544 as_items.push_back (CheckMenuElem (_("Play"), sigc::bind (
545 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
547 auto_play_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
549 as_items.push_back (CheckMenuElem (_("Write"), sigc::bind (
550 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
551 (AutoState) Write)));
552 auto_write_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
554 as_items.push_back (CheckMenuElem (_("Touch"), sigc::bind (
555 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
556 (AutoState) Touch)));
557 auto_touch_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
559 items.push_back (MenuElem (_("State"), *auto_state_menu));
563 /* current interpolation state */
564 AutomationList::InterpolationStyle const s = _view ? _view->interpolation() : _control->list()->interpolation ();
566 if (ARDOUR::parameter_is_midi((AutomationType)_parameter.type())) {
568 Menu* auto_mode_menu = manage (new Menu);
569 auto_mode_menu->set_name ("ArdourContextMenu");
570 MenuList& am_items = auto_mode_menu->items();
572 RadioMenuItem::Group group;
574 am_items.push_back (RadioMenuElem (group, _("Discrete"), sigc::bind (
575 sigc::mem_fun(*this, &AutomationTimeAxisView::set_interpolation),
576 AutomationList::Discrete)));
577 mode_discrete_item = dynamic_cast<Gtk::CheckMenuItem*>(&am_items.back());
578 mode_discrete_item->set_active (s == AutomationList::Discrete);
580 am_items.push_back (RadioMenuElem (group, _("Linear"), sigc::bind (
581 sigc::mem_fun(*this, &AutomationTimeAxisView::set_interpolation),
582 AutomationList::Linear)));
583 mode_line_item = dynamic_cast<Gtk::CheckMenuItem*>(&am_items.back());
584 mode_line_item->set_active (s == AutomationList::Linear);
586 items.push_back (MenuElem (_("Mode"), *auto_mode_menu));
589 /* make sure the automation menu state is correct */
591 automation_state_changed ();
592 interpolation_changed (s);
596 AutomationTimeAxisView::add_automation_event (GdkEvent* event, framepos_t when, double y, bool with_guard_points)
602 boost::shared_ptr<AutomationList> list = _line->the_list ();
604 if (list->in_write_pass()) {
605 /* do not allow the GUI to add automation events during an
606 automation write pass.
613 _canvas_display->canvas_to_item (x, y);
615 /* compute vertical fractional position */
617 y = 1.0 - (y / height);
621 _line->view_to_model_coord (x, y);
624 _editor.snap_to_with_modifier (when, event);
626 _session->begin_reversible_command (_("add automation event"));
627 XMLNode& before = list->get_state();
629 list->add (when, y, with_guard_points);
631 XMLNode& after = list->get_state();
632 _session->commit_reversible_command (new MementoCommand<ARDOUR::AutomationList> (*list, &before, &after));
633 _session->set_dirty ();
637 AutomationTimeAxisView::paste (framepos_t pos, const Selection& selection, PasteContext& ctx)
640 return paste_one (pos, ctx.count, ctx.times, selection, ctx.counts, ctx.greedy);
642 AutomationSelection::const_iterator l = selection.lines.get_nth(_parameter, ctx.counts.n_lines(_parameter));
643 if (l == selection.lines.end()) {
644 if (ctx.greedy && selection.lines.size() == 1) {
645 l = selection.lines.begin();
648 if (l != selection.lines.end() && _view->paste (pos, ctx.count, ctx.times, *l)) {
649 ctx.counts.increase_n_lines(_parameter);
658 AutomationTimeAxisView::paste_one (framepos_t pos, unsigned paste_count, float times, const Selection& selection, ItemCounts& counts, bool greedy)
660 boost::shared_ptr<AutomationList> alist(_line->the_list());
662 if (_session->transport_rolling() && alist->automation_write()) {
663 /* do not paste if this control is in write mode and we're rolling */
667 /* Get appropriate list from selection. */
668 AutomationSelection::const_iterator p = selection.lines.get_nth(_parameter, counts.n_lines(_parameter));
669 if (p == selection.lines.end()) {
670 if (greedy && selection.lines.size() == 1) {
671 p = selection.lines.begin();
676 counts.increase_n_lines(_parameter);
678 /* add multi-paste offset if applicable */
679 pos += _editor.get_paste_offset(pos, paste_count, (*p)->length());
681 double const model_pos = _line->time_converter().from (pos - _line->time_converter().origin_b ());
683 XMLNode &before = alist->get_state();
684 alist->paste (**p, model_pos, times);
685 _session->add_command (new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
691 AutomationTimeAxisView::get_selectables (framepos_t start, framepos_t end, double top, double bot, list<Selectable*>& results)
693 if (!_line && !_view) {
697 if (touched (top, bot)) {
699 /* remember: this is X Window - coordinate space starts in upper left and moves down.
700 _y_position is the "origin" or "top" of the track.
703 /* bottom of our track */
704 double const mybot = _y_position + height;
709 if (_y_position >= top && mybot <= bot) {
711 /* _y_position is below top, mybot is above bot, so we're fully
720 /* top and bot are within _y_position .. mybot */
722 topfrac = 1.0 - ((top - _y_position) / height);
723 botfrac = 1.0 - ((bot - _y_position) / height);
728 _line->get_selectables (start, end, botfrac, topfrac, results);
730 _view->get_selectables (start, end, botfrac, topfrac, results);
736 AutomationTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& result)
739 _line->get_inverted_selectables (sel, result);
744 AutomationTimeAxisView::set_selected_points (PointSelection& points)
747 _line->set_selected_points (points);
749 _view->set_selected_points (points);
754 AutomationTimeAxisView::clear_lines ()
757 _list_connections.drop_connections ();
761 AutomationTimeAxisView::add_line (boost::shared_ptr<AutomationLine> line)
763 if (_control && line) {
764 assert(line->the_list() == _control->list());
766 _control->alist()->automation_state_changed.connect (
767 _list_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::automation_state_changed, this), gui_context()
770 _control->alist()->InterpolationChanged.connect (
771 _list_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::interpolation_changed, this, _1), gui_context()
777 line->set_height (height);
779 /* pick up the current state */
780 automation_state_changed ();
782 line->add_visibility (AutomationLine::Line);
786 AutomationTimeAxisView::entered()
789 _line->track_entered();
794 AutomationTimeAxisView::exited ()
797 _line->track_exited();
802 AutomationTimeAxisView::color_handler ()
810 AutomationTimeAxisView::set_state_2X (const XMLNode& node, int /*version*/)
812 if (node.name() == X_("gain") && _parameter == Evoral::Parameter (GainAutomation)) {
813 XMLProperty const * shown = node.property (X_("shown"));
815 bool yn = string_is_affirmative (shown->value ());
817 _canvas_display->show (); /* FIXME: necessary? show_at? */
819 set_gui_property ("visible", yn);
821 set_gui_property ("visible", false);
829 AutomationTimeAxisView::set_state (const XMLNode&, int /*version*/)
835 AutomationTimeAxisView::what_has_visible_automation (const boost::shared_ptr<Automatable>& automatable, set<Evoral::Parameter>& visible)
837 /* this keeps "knowledge" of how we store visibility information
838 in XML private to this class.
841 assert (automatable);
843 Automatable::Controls& controls (automatable->controls());
845 for (Automatable::Controls::iterator i = controls.begin(); i != controls.end(); ++i) {
847 boost::shared_ptr<AutomationControl> ac = boost::dynamic_pointer_cast<AutomationControl> (i->second);
849 if (ac && ac->alist()) {
851 const XMLNode* gui_node = ac->extra_xml ("GUI");
854 const XMLProperty* prop = gui_node->property ("shown");
856 if (string_is_affirmative (prop->value())) {
857 visible.insert (i->first);
866 /** @return true if this view has any automation data to display */
868 AutomationTimeAxisView::has_automation () const
870 return ( (_line && _line->npoints() > 0) || (_view && _view->has_automation()) );
873 list<boost::shared_ptr<AutomationLine> >
874 AutomationTimeAxisView::lines () const
876 list<boost::shared_ptr<AutomationLine> > lines;
879 lines.push_back (_line);
881 lines = _view->get_lines ();
888 AutomationTimeAxisView::state_id() const
890 if (_automatable != _route && _control) {
891 return string_compose ("automation %1", _control->id().to_s());
892 } else if (_parameter) {
893 return string_compose ("automation %1 %2/%3/%4",
897 (int) _parameter.channel());
899 error << "Automation time axis has no state ID" << endmsg;
904 /** Given a state id string, see if it is one generated by
905 * this class. If so, parse it into its components.
906 * @param state_id State ID string to parse.
907 * @param route_id Filled in with the route's ID if the state ID string is parsed.
908 * @param has_parameter Filled in with true if the state ID has a parameter, otherwise false.
909 * @param parameter Filled in with the state ID's parameter, if it has one.
910 * @return true if this is a state ID generated by this class, otherwise false.
914 AutomationTimeAxisView::parse_state_id (
915 string const & state_id,
917 bool & has_parameter,
918 Evoral::Parameter & parameter)
926 if (a != X_("automation")) {
930 route_id = PBD::ID (b);
933 has_parameter = false;
937 has_parameter = true;
940 boost::split (p, c, boost::is_any_of ("/"));
942 assert (p.size() == 3);
944 parameter = Evoral::Parameter (
945 boost::lexical_cast<int> (p[0]),
946 boost::lexical_cast<int> (p[2]),
947 boost::lexical_cast<int> (p[1])
954 AutomationTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
956 list<boost::shared_ptr<AutomationLine> > lines;
958 lines.push_back (_line);
960 lines = _view->get_lines ();
963 for (list<boost::shared_ptr<AutomationLine> >::iterator i = lines.begin(); i != lines.end(); ++i) {
964 cut_copy_clear_one (**i, selection, op);
969 AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& selection, CutCopyOp op)
971 boost::shared_ptr<Evoral::ControlList> what_we_got;
972 boost::shared_ptr<AutomationList> alist (line.the_list());
974 XMLNode &before = alist->get_state();
976 /* convert time selection to automation list model coordinates */
977 const Evoral::TimeConverter<double, ARDOUR::framepos_t>& tc = line.time_converter ();
978 double const start = tc.from (selection.time.front().start - tc.origin_b ());
979 double const end = tc.from (selection.time.front().end - tc.origin_b ());
983 if (alist->cut (start, end) != 0) {
984 _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
990 if ((what_we_got = alist->cut (start, end)) != 0) {
991 _editor.get_cut_buffer().add (what_we_got);
992 _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
996 if ((what_we_got = alist->copy (start, end)) != 0) {
997 _editor.get_cut_buffer().add (what_we_got);
1002 if ((what_we_got = alist->cut (start, end)) != 0) {
1003 _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
1009 for (AutomationList::iterator x = what_we_got->begin(); x != what_we_got->end(); ++x) {
1010 double when = (*x)->when;
1011 double val = (*x)->value;
1012 line.model_to_view_coord (when, val);