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/memento_command.h"
27 #include "pbd/stacktrace.h"
29 #include "ardour/automation_control.h"
30 #include "ardour/event_type_map.h"
31 #include "ardour/profile.h"
32 #include "ardour/route.h"
33 #include "ardour/session.h"
35 #include "canvas/debug.h"
37 #include "ardour_ui.h"
38 #include "automation_time_axis.h"
39 #include "automation_streamview.h"
40 #include "global_signals.h"
41 #include "gui_thread.h"
42 #include "route_time_axis.h"
43 #include "automation_line.h"
44 #include "public_editor.h"
45 #include "selection.h"
46 #include "rgb_macros.h"
47 #include "point_selection.h"
48 #include "control_point.h"
54 using namespace ARDOUR;
55 using namespace ARDOUR_UI_UTILS;
58 using namespace Gtkmm2ext;
59 using namespace Editing;
61 Pango::FontDescription AutomationTimeAxisView::name_font;
62 bool AutomationTimeAxisView::have_name_font = false;
65 /** \a a the automatable object this time axis is to display data for.
66 * For route/track automation (e.g. gain) pass the route for both \r and \a.
67 * For route child (e.g. plugin) automation, pass the child for \a.
68 * For region automation (e.g. MIDI CC), pass null for \a.
70 AutomationTimeAxisView::AutomationTimeAxisView (
72 boost::shared_ptr<Route> r,
73 boost::shared_ptr<Automatable> a,
74 boost::shared_ptr<AutomationControl> c,
79 ArdourCanvas::Canvas& canvas,
81 const string & nomparent
84 , TimeAxisView (s, e, &parent, canvas)
89 , _base_rect (new ArdourCanvas::Rectangle (_canvas_display))
91 , _view (show_regions ? new AutomationStreamView (*this) : 0)
92 , auto_button (X_("")) /* force addition of a label */
93 , _show_regions (show_regions)
96 CANVAS_DEBUG_NAME (_canvas_display, string_compose ("main for auto %2/%1", _name, r->name()));
97 CANVAS_DEBUG_NAME (selection_group, string_compose ("selections for auto %2/%1", _name, r->name()));
98 CANVAS_DEBUG_NAME (_ghost_group, string_compose ("ghosts for auto %2/%1", _name, r->name()));
100 if (!have_name_font) {
101 name_font = get_font_for_style (X_("AutomationTrackName"));
102 have_name_font = true;
105 if (_automatable && _control) {
106 _controller = AutomationController::create (_automatable, _control->parameter(), _control);
114 mode_discrete_item = 0;
117 ignore_state_request = false;
118 first_call_to_set_height = true;
120 CANVAS_DEBUG_NAME (_base_rect, string_compose ("base rect for %1", _name));
121 _base_rect->set_x1 (ArdourCanvas::COORD_MAX);
122 _base_rect->set_outline_color (ARDOUR_UI::config()->get_canvasvar_AutomationTrackOutline());
123 _base_rect->set_outline_what (ArdourCanvas::Rectangle::BOTTOM); // bottom separator
124 _base_rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_AutomationTrackFill());
125 _base_rect->set_data ("trackview", this);
126 _base_rect->Event.connect (sigc::bind (sigc::mem_fun (_editor, &PublicEditor::canvas_automation_track_event), _base_rect, this));
128 _base_rect->lower_to_bottom();
131 hide_button.set_elements ((ArdourButton::Element)(ArdourButton::Edge|ArdourButton::Body|ArdourButton::CloseCross));
132 hide_button.set_tweaks(ArdourButton::TrackHeader);
134 auto_button.set_name ("route button");
135 hide_button.set_name ("route button");
137 auto_button.unset_flags (Gtk::CAN_FOCUS);
138 hide_button.unset_flags (Gtk::CAN_FOCUS);
140 controls_table.set_no_show_all();
142 ARDOUR_UI::instance()->set_tip(auto_button, _("automation state"));
143 ARDOUR_UI::instance()->set_tip(hide_button, _("hide track"));
145 const string str = gui_property ("height");
147 set_height (atoi (str));
149 set_height (preset_height (HeightNormal));
152 //name label isn't editable on an automation track; remove the tooltip
153 ARDOUR_UI::instance()->set_tip (name_label, X_(""));
155 /* repack the name label */
157 if (name_label.get_parent()) {
158 name_label.get_parent()->remove (name_label);
161 name_label.set_text (_name);
162 name_label.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
163 name_label.set_name (X_("TrackParameterName"));
164 name_label.set_ellipsize (Pango::ELLIPSIZE_END);
166 string tipname = nomparent;
167 if (!tipname.empty()) {
171 ARDOUR_UI::instance()->set_tip(controls_ebox, tipname);
173 /* add the buttons */
174 controls_table.set_border_width (1);
175 controls_table.remove (name_hbox);
176 controls_table.attach (hide_button, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
177 controls_table.attach (name_label, 2, 3, 1, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 2, 0);
178 controls_table.attach (auto_button, 3, 4, 2, 3, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
180 Gtk::DrawingArea *blank0 = manage (new Gtk::DrawingArea());
181 Gtk::DrawingArea *blank1 = manage (new Gtk::DrawingArea());
183 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&parent);
184 // TODO use rtv->controls_base_unselected_name
185 // subscribe to route_active_changed, ...
186 if (rtv && rtv->is_audio_track()) {
187 blank0->set_name ("AudioTrackControlsBaseUnselected");
189 else if (rtv && rtv->is_midi_track()) {
190 blank0->set_name ("MidiTrackControlsBaseUnselected");
193 blank0->set_name ("AudioBusControlsBaseUnselected");
195 blank0->set_size_request (-1, -1);
196 blank1->set_size_request (1, 0);
197 VSeparator* separator = manage (new VSeparator());
198 separator->set_name("TrackSeparator");
199 separator->set_size_request (1, -1);
201 controls_button_size_group->add_widget(hide_button);
202 controls_button_size_group->add_widget(*blank0);
204 time_axis_hbox.pack_start (*blank0, false, false);
205 time_axis_hbox.pack_start (*separator, false, false);
206 time_axis_hbox.reorder_child (*blank0, 0);
207 time_axis_hbox.reorder_child (*separator, 1);
208 time_axis_hbox.reorder_child (time_axis_vbox, 2);
210 if (!ARDOUR::Profile->get_mixbus() ) {
211 time_axis_hbox.pack_start (*blank1, false, false);
220 _controller.get()->set_tweaks (PixFader::Tweaks(_controller.get()->tweaks() | PixFader::NoVerticalScroll));
221 controls_table.attach (*_controller.get(), 2, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
224 controls_table.show_all ();
226 hide_button.signal_clicked.connect (sigc::mem_fun(*this, &AutomationTimeAxisView::hide_clicked));
227 auto_button.signal_clicked.connect (sigc::mem_fun(*this, &AutomationTimeAxisView::auto_clicked));
229 controls_base_selected_name = X_("AutomationTrackControlsBaseSelected");
230 controls_base_unselected_name = X_("AutomationTrackControlsBase");
232 controls_ebox.set_name (controls_base_unselected_name);
233 time_axis_frame.set_name (controls_base_unselected_name);
235 /* ask for notifications of any new RegionViews */
243 /* no regions, just a single line for the entire track (e.g. bus gain) */
247 boost::shared_ptr<AutomationLine> line (
249 ARDOUR::EventTypeMap::instance().to_symbol(_parameter),
256 line->set_line_color (ARDOUR_UI::config()->get_canvasvar_ProcessorAutomationLine());
257 line->queue_reset ();
261 /* make sure labels etc. are correct */
263 automation_state_changed ();
264 ColorsChanged.connect (sigc::mem_fun (*this, &AutomationTimeAxisView::color_handler));
266 _route->DropReferences.connect (
267 _route_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::route_going_away, this), gui_context ()
271 AutomationTimeAxisView::~AutomationTimeAxisView ()
277 AutomationTimeAxisView::route_going_away ()
283 AutomationTimeAxisView::auto_clicked ()
285 using namespace Menu_Helpers;
287 if (automation_menu == 0) {
288 automation_menu = manage (new Menu);
289 automation_menu->set_name ("ArdourContextMenu");
290 MenuList& items (automation_menu->items());
292 items.push_back (MenuElem (S_("Automation|Manual"), sigc::bind (sigc::mem_fun(*this,
293 &AutomationTimeAxisView::set_automation_state), (AutoState) ARDOUR::Off)));
294 items.push_back (MenuElem (_("Play"), sigc::bind (sigc::mem_fun(*this,
295 &AutomationTimeAxisView::set_automation_state), (AutoState) Play)));
296 items.push_back (MenuElem (_("Write"), sigc::bind (sigc::mem_fun(*this,
297 &AutomationTimeAxisView::set_automation_state), (AutoState) Write)));
298 items.push_back (MenuElem (_("Touch"), sigc::bind (sigc::mem_fun(*this,
299 &AutomationTimeAxisView::set_automation_state), (AutoState) Touch)));
302 automation_menu->popup (1, gtk_get_current_event_time());
306 AutomationTimeAxisView::set_automation_state (AutoState state)
308 if (ignore_state_request) {
313 _automatable->set_parameter_automation_state (_parameter, state);
317 _view->set_automation_state (state);
319 /* AutomationStreamViews don't signal when their automation state changes, so handle
320 our updates `manually'.
322 automation_state_changed ();
327 AutomationTimeAxisView::automation_state_changed ()
331 /* update button label */
334 state = _view->automation_state ();
337 state = _control->alist()->automation_state ();
342 switch (state & (ARDOUR::Off|Play|Touch|Write)) {
344 auto_button.set_text (S_("Automation|Manual"));
346 ignore_state_request = true;
347 auto_off_item->set_active (true);
348 auto_play_item->set_active (false);
349 auto_touch_item->set_active (false);
350 auto_write_item->set_active (false);
351 ignore_state_request = false;
355 auto_button.set_text (_("Play"));
356 if (auto_play_item) {
357 ignore_state_request = true;
358 auto_play_item->set_active (true);
359 auto_off_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_button.set_text (_("Write"));
367 if (auto_write_item) {
368 ignore_state_request = true;
369 auto_write_item->set_active (true);
370 auto_off_item->set_active (false);
371 auto_play_item->set_active (false);
372 auto_touch_item->set_active (false);
373 ignore_state_request = false;
377 auto_button.set_text (_("Touch"));
378 if (auto_touch_item) {
379 ignore_state_request = true;
380 auto_touch_item->set_active (true);
381 auto_off_item->set_active (false);
382 auto_play_item->set_active (false);
383 auto_write_item->set_active (false);
384 ignore_state_request = false;
388 auto_button.set_text (_("???"));
393 /** The interpolation style of our AutomationList has changed, so update */
395 AutomationTimeAxisView::interpolation_changed (AutomationList::InterpolationStyle s)
397 if (mode_line_item && mode_discrete_item) {
398 if (s == AutomationList::Discrete) {
399 mode_discrete_item->set_active(true);
400 mode_line_item->set_active(false);
402 mode_line_item->set_active(true);
403 mode_discrete_item->set_active(false);
408 /** A menu item has been selected to change our interpolation mode */
410 AutomationTimeAxisView::set_interpolation (AutomationList::InterpolationStyle style)
412 /* Tell our view's list, if we have one, otherwise tell our own.
413 * Everything else will be signalled back from that.
417 _view->set_interpolation (style);
420 _control->list()->set_interpolation (style);
425 AutomationTimeAxisView::clear_clicked ()
427 assert (_line || _view);
429 _session->begin_reversible_command (_("clear automation"));
437 _session->commit_reversible_command ();
438 _session->set_dirty ();
442 AutomationTimeAxisView::set_height (uint32_t h)
444 bool const changed = (height != (uint32_t) h) || first_call_to_set_height;
445 uint32_t const normal = preset_height (HeightNormal);
446 bool const changed_between_small_and_normal = ( (height < normal && h >= normal) || (height >= normal || h < normal) );
448 TimeAxisView::set_height (h);
450 _base_rect->set_y1 (h);
453 _line->set_height(h);
457 _view->set_height(h);
458 _view->update_contents_height();
461 if (changed_between_small_and_normal || first_call_to_set_height) {
463 first_call_to_set_height = false;
465 if (h >= preset_height (HeightNormal)) {
470 } else if (h >= preset_height (HeightSmall)) {
471 controls_table.hide_all ();
478 if (_canvas_display->visible() && _route) {
479 /* only emit the signal if the height really changed and we were visible */
480 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
486 AutomationTimeAxisView::set_samples_per_pixel (double fpp)
488 TimeAxisView::set_samples_per_pixel (fpp);
495 _view->set_samples_per_pixel (fpp);
500 AutomationTimeAxisView::hide_clicked ()
502 hide_button.set_sensitive(false);
503 set_marked_for_display (false);
504 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(parent);
506 rtv->request_redraw ();
508 hide_button.set_sensitive(true);
512 AutomationTimeAxisView::build_display_menu ()
514 using namespace Menu_Helpers;
518 TimeAxisView::build_display_menu ();
520 /* now fill it with our stuff */
522 MenuList& items = display_menu->items();
524 items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &AutomationTimeAxisView::hide_clicked)));
525 items.push_back (SeparatorElem());
526 items.push_back (MenuElem (_("Clear"), sigc::mem_fun(*this, &AutomationTimeAxisView::clear_clicked)));
527 items.push_back (SeparatorElem());
531 Menu* auto_state_menu = manage (new Menu);
532 auto_state_menu->set_name ("ArdourContextMenu");
533 MenuList& as_items = auto_state_menu->items();
535 as_items.push_back (CheckMenuElem (S_("Automation|Manual"), sigc::bind (
536 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
537 (AutoState) ARDOUR::Off)));
538 auto_off_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
540 as_items.push_back (CheckMenuElem (_("Play"), sigc::bind (
541 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
543 auto_play_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
545 as_items.push_back (CheckMenuElem (_("Write"), sigc::bind (
546 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
547 (AutoState) Write)));
548 auto_write_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
550 as_items.push_back (CheckMenuElem (_("Touch"), sigc::bind (
551 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
552 (AutoState) Touch)));
553 auto_touch_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
555 items.push_back (MenuElem (_("State"), *auto_state_menu));
559 /* current interpolation state */
560 AutomationList::InterpolationStyle const s = _view ? _view->interpolation() : _control->list()->interpolation ();
562 if (EventTypeMap::instance().is_midi_parameter(_parameter)) {
564 Menu* auto_mode_menu = manage (new Menu);
565 auto_mode_menu->set_name ("ArdourContextMenu");
566 MenuList& am_items = auto_mode_menu->items();
568 RadioMenuItem::Group group;
570 am_items.push_back (RadioMenuElem (group, _("Discrete"), sigc::bind (
571 sigc::mem_fun(*this, &AutomationTimeAxisView::set_interpolation),
572 AutomationList::Discrete)));
573 mode_discrete_item = dynamic_cast<Gtk::CheckMenuItem*>(&am_items.back());
574 mode_discrete_item->set_active (s == AutomationList::Discrete);
576 am_items.push_back (RadioMenuElem (group, _("Linear"), sigc::bind (
577 sigc::mem_fun(*this, &AutomationTimeAxisView::set_interpolation),
578 AutomationList::Linear)));
579 mode_line_item = dynamic_cast<Gtk::CheckMenuItem*>(&am_items.back());
580 mode_line_item->set_active (s == AutomationList::Linear);
582 items.push_back (MenuElem (_("Mode"), *auto_mode_menu));
585 /* make sure the automation menu state is correct */
587 automation_state_changed ();
588 interpolation_changed (s);
592 AutomationTimeAxisView::add_automation_event (GdkEvent* event, framepos_t when, double y, bool with_guard_points)
598 boost::shared_ptr<AutomationList> list = _line->the_list ();
600 if (list->in_write_pass()) {
601 /* do not allow the GUI to add automation events during an
602 automation write pass.
609 _canvas_display->canvas_to_item (x, y);
611 /* compute vertical fractional position */
613 y = 1.0 - (y / height);
617 _line->view_to_model_coord (x, y);
620 _editor.snap_to_with_modifier (when, event);
622 _session->begin_reversible_command (_("add automation event"));
623 XMLNode& before = list->get_state();
625 list->add (when, y, with_guard_points);
627 XMLNode& after = list->get_state();
628 _session->commit_reversible_command (new MementoCommand<ARDOUR::AutomationList> (*list, &before, &after));
629 _session->set_dirty ();
632 /** Paste a selection.
633 * @param pos Position to paste to (session frames).
634 * @param times Number of times to paste.
635 * @param selection Selection to paste.
636 * @param nth Index of the AutomationList within the selection to paste from.
639 AutomationTimeAxisView::paste (framepos_t pos, float times, Selection& selection, size_t nth)
641 boost::shared_ptr<AutomationLine> line;
646 line = _view->paste_line (pos);
653 return paste_one (*line, pos, times, selection, nth);
657 AutomationTimeAxisView::paste_one (AutomationLine& line, framepos_t pos, float times, Selection& selection, size_t nth)
659 AutomationSelection::iterator p;
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 for (p = selection.lines.begin(); p != selection.lines.end() && nth; ++p, --nth) {}
669 if (p == selection.lines.end()) {
673 double const model_pos = line.time_converter().from (pos - line.time_converter().origin_b ());
675 XMLNode &before = alist->get_state();
676 alist->paste (**p, model_pos, times);
677 _session->add_command (new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
683 AutomationTimeAxisView::get_selectables (framepos_t start, framepos_t end, double top, double bot, list<Selectable*>& results)
685 if (!_line && !_view) {
689 if (touched (top, bot)) {
691 /* remember: this is X Window - coordinate space starts in upper left and moves down.
692 _y_position is the "origin" or "top" of the track.
695 /* bottom of our track */
696 double const mybot = _y_position + height;
701 if (_y_position >= top && mybot <= bot) {
703 /* _y_position is below top, mybot is above bot, so we're fully
712 /* top and bot are within _y_position .. mybot */
714 topfrac = 1.0 - ((top - _y_position) / height);
715 botfrac = 1.0 - ((bot - _y_position) / height);
720 _line->get_selectables (start, end, botfrac, topfrac, results);
722 _view->get_selectables (start, end, botfrac, topfrac, results);
728 AutomationTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& result)
731 _line->get_inverted_selectables (sel, result);
736 AutomationTimeAxisView::set_selected_points (PointSelection& points)
739 _line->set_selected_points (points);
741 _view->set_selected_points (points);
746 AutomationTimeAxisView::clear_lines ()
749 _list_connections.drop_connections ();
753 AutomationTimeAxisView::add_line (boost::shared_ptr<AutomationLine> line)
755 if (_control && line) {
756 assert(line->the_list() == _control->list());
758 _control->alist()->automation_state_changed.connect (
759 _list_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::automation_state_changed, this), gui_context()
762 _control->alist()->InterpolationChanged.connect (
763 _list_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::interpolation_changed, this, _1), gui_context()
769 line->set_height (height);
771 /* pick up the current state */
772 automation_state_changed ();
774 line->add_visibility (AutomationLine::Line);
778 AutomationTimeAxisView::entered()
781 _line->track_entered();
786 AutomationTimeAxisView::exited ()
789 _line->track_exited();
794 AutomationTimeAxisView::color_handler ()
802 AutomationTimeAxisView::set_state_2X (const XMLNode& node, int /*version*/)
804 if (node.name() == X_("gain") && _parameter == Evoral::Parameter (GainAutomation)) {
805 XMLProperty const * shown = node.property (X_("shown"));
807 bool yn = string_is_affirmative (shown->value ());
809 _canvas_display->show (); /* FIXME: necessary? show_at? */
811 set_gui_property ("visible", yn);
813 set_gui_property ("visible", false);
821 AutomationTimeAxisView::set_state (const XMLNode&, int /*version*/)
827 AutomationTimeAxisView::what_has_visible_automation (const boost::shared_ptr<Automatable>& automatable, set<Evoral::Parameter>& visible)
829 /* this keeps "knowledge" of how we store visibility information
830 in XML private to this class.
833 assert (automatable);
835 Automatable::Controls& controls (automatable->controls());
837 for (Automatable::Controls::iterator i = controls.begin(); i != controls.end(); ++i) {
839 boost::shared_ptr<AutomationControl> ac = boost::dynamic_pointer_cast<AutomationControl> (i->second);
843 const XMLNode* gui_node = ac->extra_xml ("GUI");
846 const XMLProperty* prop = gui_node->property ("shown");
848 if (string_is_affirmative (prop->value())) {
849 visible.insert (i->first);
858 /** @return true if this view has any automation data to display */
860 AutomationTimeAxisView::has_automation () const
862 return ( (_line && _line->npoints() > 0) || (_view && _view->has_automation()) );
865 list<boost::shared_ptr<AutomationLine> >
866 AutomationTimeAxisView::lines () const
868 list<boost::shared_ptr<AutomationLine> > lines;
871 lines.push_back (_line);
873 lines = _view->get_lines ();
880 AutomationTimeAxisView::state_id() const
883 return string_compose ("automation %1", _control->id().to_s());
886 return string_compose ("automation %1 %2/%3/%4",
890 (int) _parameter.channel());
894 /** Given a state id string, see if it is one generated by
895 * this class. If so, parse it into its components.
896 * @param state_id State ID string to parse.
897 * @param route_id Filled in with the route's ID if the state ID string is parsed.
898 * @param has_parameter Filled in with true if the state ID has a parameter, otherwise false.
899 * @param parameter Filled in with the state ID's parameter, if it has one.
900 * @return true if this is a state ID generated by this class, otherwise false.
904 AutomationTimeAxisView::parse_state_id (
905 string const & state_id,
907 bool & has_parameter,
908 Evoral::Parameter & parameter)
916 if (a != X_("automation")) {
920 route_id = PBD::ID (b);
923 has_parameter = false;
927 has_parameter = true;
930 boost::split (p, c, boost::is_any_of ("/"));
932 assert (p.size() == 3);
934 parameter = Evoral::Parameter (
935 boost::lexical_cast<int> (p[0]),
936 boost::lexical_cast<int> (p[2]),
937 boost::lexical_cast<int> (p[1])
944 AutomationTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
946 list<boost::shared_ptr<AutomationLine> > lines;
948 lines.push_back (_line);
950 lines = _view->get_lines ();
953 for (list<boost::shared_ptr<AutomationLine> >::iterator i = lines.begin(); i != lines.end(); ++i) {
954 cut_copy_clear_one (**i, selection, op);
959 AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& selection, CutCopyOp op)
961 boost::shared_ptr<Evoral::ControlList> what_we_got;
962 boost::shared_ptr<AutomationList> alist (line.the_list());
964 XMLNode &before = alist->get_state();
966 /* convert time selection to automation list model coordinates */
967 const Evoral::TimeConverter<double, ARDOUR::framepos_t>& tc = line.time_converter ();
968 double const start = tc.from (selection.time.front().start - tc.origin_b ());
969 double const end = tc.from (selection.time.front().end - tc.origin_b ());
973 if (alist->cut (start, end) != 0) {
974 _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
980 if ((what_we_got = alist->cut (start, end)) != 0) {
981 _editor.get_cut_buffer().add (what_we_got);
982 _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
986 if ((what_we_got = alist->copy (start, end)) != 0) {
987 _editor.get_cut_buffer().add (what_we_got);
992 if ((what_we_got = alist->cut (start, end)) != 0) {
993 _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
999 for (AutomationList::iterator x = what_we_got->begin(); x != what_we_got->end(); ++x) {
1000 double when = (*x)->when;
1001 double val = (*x)->value;
1002 line.model_to_view_coord (when, val);