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 "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"
48 #include "rgb_macros.h"
49 #include "point_selection.h"
50 #include "control_point.h"
52 #include "item_counts.h"
57 using namespace ARDOUR;
58 using namespace ARDOUR_UI_UTILS;
61 using namespace Gtkmm2ext;
62 using namespace Editing;
64 Pango::FontDescription AutomationTimeAxisView::name_font;
65 bool AutomationTimeAxisView::have_name_font = false;
68 /** \a a the automatable object this time axis is to display data for.
69 * For route/track automation (e.g. gain) pass the route for both \r and \a.
70 * For route child (e.g. plugin) automation, pass the child for \a.
71 * For region automation (e.g. MIDI CC), pass null for \a.
73 AutomationTimeAxisView::AutomationTimeAxisView (
75 boost::shared_ptr<Route> r,
76 boost::shared_ptr<Automatable> a,
77 boost::shared_ptr<AutomationControl> c,
82 ArdourCanvas::Canvas& canvas,
84 const string & nomparent
87 , TimeAxisView (s, e, &parent, canvas)
92 , _base_rect (new ArdourCanvas::Rectangle (_canvas_display))
93 , _view (show_regions ? new AutomationStreamView (*this) : 0)
94 , auto_button (X_("")) /* force addition of a label */
95 , _show_regions (show_regions)
97 //concatenate plugin name and param name into the tooltip
98 string tipname = nomparent;
99 if (!tipname.empty()) {
103 ARDOUR_UI::instance()->set_tip(controls_ebox, tipname);
105 //plugin name and param name appear on 2 separate lines in the track header
107 if (!tipname.empty()) {
113 CANVAS_DEBUG_NAME (_canvas_display, string_compose ("main for auto %2/%1", _name, r->name()));
114 CANVAS_DEBUG_NAME (selection_group, string_compose ("selections for auto %2/%1", _name, r->name()));
115 CANVAS_DEBUG_NAME (_ghost_group, string_compose ("ghosts for auto %2/%1", _name, r->name()));
117 if (!have_name_font) {
118 name_font = get_font_for_style (X_("AutomationTrackName"));
119 have_name_font = true;
122 if (_automatable && _control) {
123 _controller = AutomationController::create (_automatable, _control->parameter(), _control->desc(), _control);
126 const std::string fill_color_name = (dynamic_cast<MidiTimeAxisView*>(&parent)
127 ? "midi automation track fill"
128 : "audio automation track fill");
135 mode_discrete_item = 0;
138 ignore_state_request = false;
139 first_call_to_set_height = true;
141 CANVAS_DEBUG_NAME (_base_rect, string_compose ("base rect for %1", _name));
142 _base_rect->set_x1 (ArdourCanvas::COORD_MAX);
143 _base_rect->set_outline (false);
144 _base_rect->set_fill_color (ARDOUR_UI::config()->color_mod (fill_color_name, "automation track fill"));
145 _base_rect->set_data ("trackview", this);
146 _base_rect->Event.connect (sigc::bind (sigc::mem_fun (_editor, &PublicEditor::canvas_automation_track_event), _base_rect, this));
148 _base_rect->lower_to_bottom();
151 hide_button.set_icon (ArdourIcon::CloseCross);
152 hide_button.set_tweaks(ArdourButton::TrackHeader);
154 auto_button.set_name ("route button");
155 hide_button.set_name ("route button");
157 auto_button.unset_flags (Gtk::CAN_FOCUS);
158 hide_button.unset_flags (Gtk::CAN_FOCUS);
160 controls_table.set_no_show_all();
162 ARDOUR_UI::instance()->set_tip(auto_button, _("automation state"));
163 ARDOUR_UI::instance()->set_tip(hide_button, _("hide track"));
165 const string str = gui_property ("height");
167 set_height (atoi (str));
169 set_height (preset_height (HeightNormal));
172 //name label isn't editable on an automation track; remove the tooltip
173 ARDOUR_UI::instance()->set_tip (name_label, X_(""));
175 /* repack the name label */
177 if (name_label.get_parent()) {
178 name_label.get_parent()->remove (name_label);
181 name_label.set_text (_name);
182 name_label.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
183 name_label.set_name (X_("TrackParameterName"));
184 name_label.set_ellipsize (Pango::ELLIPSIZE_END);
186 /* add the buttons */
187 controls_table.set_border_width (1);
188 controls_table.remove (name_hbox);
189 controls_table.attach (hide_button, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
190 controls_table.attach (name_label, 2, 3, 1, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 2, 0);
191 controls_table.attach (auto_button, 3, 4, 2, 3, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
193 Gtk::DrawingArea *blank0 = manage (new Gtk::DrawingArea());
194 Gtk::DrawingArea *blank1 = manage (new Gtk::DrawingArea());
196 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&parent);
197 // TODO use rtv->controls_base_unselected_name
198 // subscribe to route_active_changed, ...
199 if (rtv && rtv->is_audio_track()) {
200 blank0->set_name ("AudioTrackControlsBaseUnselected");
202 else if (rtv && rtv->is_midi_track()) {
203 blank0->set_name ("MidiTrackControlsBaseUnselected");
206 blank0->set_name ("AudioBusControlsBaseUnselected");
208 blank0->set_size_request (-1, -1);
209 blank1->set_size_request (1, 0);
210 VSeparator* separator = manage (new VSeparator());
211 separator->set_name("TrackSeparator");
212 separator->set_size_request (1, -1);
214 controls_button_size_group->add_widget(hide_button);
215 controls_button_size_group->add_widget(*blank0);
217 time_axis_hbox.pack_start (*blank0, false, false);
218 time_axis_hbox.pack_start (*separator, false, false);
219 time_axis_hbox.reorder_child (*blank0, 0);
220 time_axis_hbox.reorder_child (*separator, 1);
221 time_axis_hbox.reorder_child (time_axis_vbox, 2);
223 if (!ARDOUR::Profile->get_mixbus() ) {
224 time_axis_hbox.pack_start (*blank1, false, false);
233 _controller->disable_vertical_scroll ();
234 controls_table.attach (*_controller.get(), 2, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
237 controls_table.show_all ();
239 hide_button.signal_clicked.connect (sigc::mem_fun(*this, &AutomationTimeAxisView::hide_clicked));
240 auto_button.signal_clicked.connect (sigc::mem_fun(*this, &AutomationTimeAxisView::auto_clicked));
242 controls_base_selected_name = X_("AutomationTrackControlsBaseSelected");
243 controls_base_unselected_name = X_("AutomationTrackControlsBase");
245 controls_ebox.set_name (controls_base_unselected_name);
246 time_axis_frame.set_name (controls_base_unselected_name);
248 /* ask for notifications of any new RegionViews */
256 /* no regions, just a single line for the entire track (e.g. bus gain) */
260 boost::shared_ptr<AutomationLine> line (
262 ARDOUR::EventTypeMap::instance().to_symbol(_parameter),
270 line->set_line_color (ARDOUR_UI::config()->color ("processor automation line"));
271 line->queue_reset ();
275 /* make sure labels etc. are correct */
277 automation_state_changed ();
278 UIConfiguration::ColorsChanged.connect (sigc::mem_fun (*this, &AutomationTimeAxisView::color_handler));
280 _route->DropReferences.connect (
281 _route_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::route_going_away, this), gui_context ()
285 AutomationTimeAxisView::~AutomationTimeAxisView ()
287 cleanup_gui_properties ();
292 AutomationTimeAxisView::route_going_away ()
298 AutomationTimeAxisView::auto_clicked ()
300 using namespace Menu_Helpers;
302 if (automation_menu == 0) {
303 automation_menu = manage (new Menu);
304 automation_menu->set_name ("ArdourContextMenu");
305 MenuList& items (automation_menu->items());
307 items.push_back (MenuElem (S_("Automation|Manual"), sigc::bind (sigc::mem_fun(*this,
308 &AutomationTimeAxisView::set_automation_state), (AutoState) ARDOUR::Off)));
309 items.push_back (MenuElem (_("Play"), sigc::bind (sigc::mem_fun(*this,
310 &AutomationTimeAxisView::set_automation_state), (AutoState) Play)));
311 items.push_back (MenuElem (_("Write"), sigc::bind (sigc::mem_fun(*this,
312 &AutomationTimeAxisView::set_automation_state), (AutoState) Write)));
313 items.push_back (MenuElem (_("Touch"), sigc::bind (sigc::mem_fun(*this,
314 &AutomationTimeAxisView::set_automation_state), (AutoState) Touch)));
317 automation_menu->popup (1, gtk_get_current_event_time());
321 AutomationTimeAxisView::set_automation_state (AutoState state)
323 if (ignore_state_request) {
328 _automatable->set_parameter_automation_state (_parameter, state);
332 _view->set_automation_state (state);
334 /* AutomationStreamViews don't signal when their automation state changes, so handle
335 our updates `manually'.
337 automation_state_changed ();
342 AutomationTimeAxisView::automation_state_changed ()
346 /* update button label */
349 state = _view->automation_state ();
352 state = _control->alist()->automation_state ();
357 switch (state & (ARDOUR::Off|Play|Touch|Write)) {
359 auto_button.set_text (S_("Automation|Manual"));
361 ignore_state_request = true;
362 auto_off_item->set_active (true);
363 auto_play_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 (_("Play"));
371 if (auto_play_item) {
372 ignore_state_request = true;
373 auto_play_item->set_active (true);
374 auto_off_item->set_active (false);
375 auto_touch_item->set_active (false);
376 auto_write_item->set_active (false);
377 ignore_state_request = false;
381 auto_button.set_text (_("Write"));
382 if (auto_write_item) {
383 ignore_state_request = true;
384 auto_write_item->set_active (true);
385 auto_off_item->set_active (false);
386 auto_play_item->set_active (false);
387 auto_touch_item->set_active (false);
388 ignore_state_request = false;
392 auto_button.set_text (_("Touch"));
393 if (auto_touch_item) {
394 ignore_state_request = true;
395 auto_touch_item->set_active (true);
396 auto_off_item->set_active (false);
397 auto_play_item->set_active (false);
398 auto_write_item->set_active (false);
399 ignore_state_request = false;
403 auto_button.set_text (_("???"));
408 /** The interpolation style of our AutomationList has changed, so update */
410 AutomationTimeAxisView::interpolation_changed (AutomationList::InterpolationStyle s)
412 if (mode_line_item && mode_discrete_item) {
413 if (s == AutomationList::Discrete) {
414 mode_discrete_item->set_active(true);
415 mode_line_item->set_active(false);
417 mode_line_item->set_active(true);
418 mode_discrete_item->set_active(false);
423 /** A menu item has been selected to change our interpolation mode */
425 AutomationTimeAxisView::set_interpolation (AutomationList::InterpolationStyle style)
427 /* Tell our view's list, if we have one, otherwise tell our own.
428 * Everything else will be signalled back from that.
432 _view->set_interpolation (style);
435 _control->list()->set_interpolation (style);
440 AutomationTimeAxisView::clear_clicked ()
442 assert (_line || _view);
444 _editor.begin_reversible_command (_("clear automation"));
451 set_automation_state ((AutoState) ARDOUR::Off);
452 _editor.commit_reversible_command ();
453 _session->set_dirty ();
457 AutomationTimeAxisView::set_height (uint32_t h, TrackHeightMode m)
459 bool const changed = (height != (uint32_t) h) || first_call_to_set_height;
460 uint32_t const normal = preset_height (HeightNormal);
461 bool const changed_between_small_and_normal = ( (height < normal && h >= normal) || (height >= normal || h < normal) );
463 TimeAxisView::set_height (h, m);
465 _base_rect->set_y1 (h);
468 _line->set_height(h - 2.5);
472 _view->set_height(h);
473 _view->update_contents_height();
476 if (changed_between_small_and_normal || first_call_to_set_height) {
478 first_call_to_set_height = false;
480 if (h >= preset_height (HeightNormal)) {
481 if (!(_parameter.type() >= MidiCCAutomation &&
482 _parameter.type() <= MidiChannelPressureAutomation)) {
488 } else if (h >= preset_height (HeightSmall)) {
489 controls_table.hide_all ();
496 if (_canvas_display->visible() && _route) {
497 /* only emit the signal if the height really changed and we were visible */
498 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
504 AutomationTimeAxisView::set_samples_per_pixel (double fpp)
506 TimeAxisView::set_samples_per_pixel (fpp);
513 _view->set_samples_per_pixel (fpp);
518 AutomationTimeAxisView::hide_clicked ()
520 hide_button.set_sensitive(false);
521 set_marked_for_display (false);
522 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(parent);
524 rtv->request_redraw ();
526 hide_button.set_sensitive(true);
530 AutomationTimeAxisView::build_display_menu ()
532 using namespace Menu_Helpers;
536 TimeAxisView::build_display_menu ();
538 /* now fill it with our stuff */
540 MenuList& items = display_menu->items();
542 items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &AutomationTimeAxisView::hide_clicked)));
543 items.push_back (SeparatorElem());
544 items.push_back (MenuElem (_("Clear"), sigc::mem_fun(*this, &AutomationTimeAxisView::clear_clicked)));
545 items.push_back (SeparatorElem());
549 Menu* auto_state_menu = manage (new Menu);
550 auto_state_menu->set_name ("ArdourContextMenu");
551 MenuList& as_items = auto_state_menu->items();
553 as_items.push_back (CheckMenuElem (S_("Automation|Manual"), sigc::bind (
554 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
555 (AutoState) ARDOUR::Off)));
556 auto_off_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
558 as_items.push_back (CheckMenuElem (_("Play"), sigc::bind (
559 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
561 auto_play_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
563 as_items.push_back (CheckMenuElem (_("Write"), sigc::bind (
564 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
565 (AutoState) Write)));
566 auto_write_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
568 as_items.push_back (CheckMenuElem (_("Touch"), sigc::bind (
569 sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
570 (AutoState) Touch)));
571 auto_touch_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
573 if (!(_parameter.type() >= MidiCCAutomation &&
574 _parameter.type() <= MidiChannelPressureAutomation)) {
575 items.push_back (MenuElem (_("State"), *auto_state_menu));
580 /* current interpolation state */
581 AutomationList::InterpolationStyle const s = _view ? _view->interpolation() : _control->list()->interpolation ();
583 if (ARDOUR::parameter_is_midi((AutomationType)_parameter.type())) {
585 Menu* auto_mode_menu = manage (new Menu);
586 auto_mode_menu->set_name ("ArdourContextMenu");
587 MenuList& am_items = auto_mode_menu->items();
589 RadioMenuItem::Group group;
591 am_items.push_back (RadioMenuElem (group, _("Discrete"), sigc::bind (
592 sigc::mem_fun(*this, &AutomationTimeAxisView::set_interpolation),
593 AutomationList::Discrete)));
594 mode_discrete_item = dynamic_cast<Gtk::CheckMenuItem*>(&am_items.back());
595 mode_discrete_item->set_active (s == AutomationList::Discrete);
597 am_items.push_back (RadioMenuElem (group, _("Linear"), sigc::bind (
598 sigc::mem_fun(*this, &AutomationTimeAxisView::set_interpolation),
599 AutomationList::Linear)));
600 mode_line_item = dynamic_cast<Gtk::CheckMenuItem*>(&am_items.back());
601 mode_line_item->set_active (s == AutomationList::Linear);
603 items.push_back (MenuElem (_("Mode"), *auto_mode_menu));
606 /* make sure the automation menu state is correct */
608 automation_state_changed ();
609 interpolation_changed (s);
613 AutomationTimeAxisView::add_automation_event (GdkEvent* event, framepos_t when, double y, bool with_guard_points)
619 boost::shared_ptr<AutomationList> list = _line->the_list ();
621 if (list->in_write_pass()) {
622 /* do not allow the GUI to add automation events during an
623 automation write pass.
630 _canvas_display->canvas_to_item (x, y);
632 /* compute vertical fractional position */
634 y = 1.0 - (y / height);
638 _line->view_to_model_coord (x, y);
641 _editor.snap_to_with_modifier (when, event);
643 _editor.begin_reversible_command (_("add automation event"));
644 XMLNode& before = list->get_state();
646 list->editor_add (when, y, with_guard_points);
648 XMLNode& after = list->get_state();
649 _session->add_command (new MementoCommand<ARDOUR::AutomationList> (*list.get (), &before, &after));
650 _editor.commit_reversible_command ();
651 _session->set_dirty ();
655 AutomationTimeAxisView::paste (framepos_t pos, const Selection& selection, PasteContext& ctx)
658 return paste_one (pos, ctx.count, ctx.times, selection, ctx.counts, ctx.greedy);
660 AutomationSelection::const_iterator l = selection.lines.get_nth(_parameter, ctx.counts.n_lines(_parameter));
661 if (l == selection.lines.end()) {
662 if (ctx.greedy && selection.lines.size() == 1) {
663 l = selection.lines.begin();
666 if (l != selection.lines.end() && _view->paste (pos, ctx.count, ctx.times, *l)) {
667 ctx.counts.increase_n_lines(_parameter);
676 AutomationTimeAxisView::paste_one (framepos_t pos, unsigned paste_count, float times, const Selection& selection, ItemCounts& counts, bool greedy)
678 boost::shared_ptr<AutomationList> alist(_line->the_list());
680 if (_session->transport_rolling() && alist->automation_write()) {
681 /* do not paste if this control is in write mode and we're rolling */
685 /* Get appropriate list from selection. */
686 AutomationSelection::const_iterator p = selection.lines.get_nth(_parameter, counts.n_lines(_parameter));
687 if (p == selection.lines.end()) {
688 if (greedy && selection.lines.size() == 1) {
689 p = selection.lines.begin();
694 counts.increase_n_lines(_parameter);
696 /* add multi-paste offset if applicable */
697 pos += _editor.get_paste_offset(pos, paste_count, (*p)->length());
699 double const model_pos = _line->time_converter().from (pos - _line->time_converter().origin_b ());
701 XMLNode &before = alist->get_state();
702 alist->paste (**p, model_pos, times);
703 _session->add_command (new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
709 AutomationTimeAxisView::get_selectables (framepos_t start, framepos_t end, double top, double bot, list<Selectable*>& results, bool /*within*/)
711 if (!_line && !_view) {
715 if (touched (top, bot)) {
717 /* remember: this is X Window - coordinate space starts in upper left and moves down.
718 _y_position is the "origin" or "top" of the track.
721 /* bottom of our track */
722 double const mybot = _y_position + height;
727 if (_y_position >= top && mybot <= bot) {
729 /* _y_position is below top, mybot is above bot, so we're fully
738 /* top and bot are within _y_position .. mybot */
740 topfrac = 1.0 - ((top - _y_position) / height);
741 botfrac = 1.0 - ((bot - _y_position) / height);
746 _line->get_selectables (start, end, botfrac, topfrac, results);
748 _view->get_selectables (start, end, botfrac, topfrac, results);
754 AutomationTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& result)
757 _line->get_inverted_selectables (sel, result);
762 AutomationTimeAxisView::set_selected_points (PointSelection& points)
765 _line->set_selected_points (points);
767 _view->set_selected_points (points);
772 AutomationTimeAxisView::clear_lines ()
775 _list_connections.drop_connections ();
779 AutomationTimeAxisView::add_line (boost::shared_ptr<AutomationLine> line)
781 if (_control && line) {
782 assert(line->the_list() == _control->list());
784 _control->alist()->automation_state_changed.connect (
785 _list_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::automation_state_changed, this), gui_context()
788 _control->alist()->InterpolationChanged.connect (
789 _list_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::interpolation_changed, this, _1), gui_context()
795 line->set_height (height);
797 /* pick up the current state */
798 automation_state_changed ();
800 line->add_visibility (AutomationLine::Line);
804 AutomationTimeAxisView::entered()
807 _line->track_entered();
812 AutomationTimeAxisView::exited ()
815 _line->track_exited();
820 AutomationTimeAxisView::color_handler ()
828 AutomationTimeAxisView::set_state_2X (const XMLNode& node, int /*version*/)
830 if (node.name() == X_("gain") && _parameter == Evoral::Parameter (GainAutomation)) {
831 XMLProperty const * shown = node.property (X_("shown"));
833 bool yn = string_is_affirmative (shown->value ());
835 _canvas_display->show (); /* FIXME: necessary? show_at? */
837 set_gui_property ("visible", yn);
839 set_gui_property ("visible", false);
847 AutomationTimeAxisView::set_state (const XMLNode&, int /*version*/)
853 AutomationTimeAxisView::what_has_visible_automation (const boost::shared_ptr<Automatable>& automatable, set<Evoral::Parameter>& visible)
855 /* this keeps "knowledge" of how we store visibility information
856 in XML private to this class.
859 assert (automatable);
861 Automatable::Controls& controls (automatable->controls());
863 for (Automatable::Controls::iterator i = controls.begin(); i != controls.end(); ++i) {
865 boost::shared_ptr<AutomationControl> ac = boost::dynamic_pointer_cast<AutomationControl> (i->second);
867 if (ac && ac->alist()) {
869 const XMLNode* gui_node = ac->extra_xml ("GUI");
872 const XMLProperty* prop = gui_node->property ("shown");
874 if (string_is_affirmative (prop->value())) {
875 visible.insert (i->first);
884 /** @return true if this view has any automation data to display */
886 AutomationTimeAxisView::has_automation () const
888 return ( (_line && _line->npoints() > 0) || (_view && _view->has_automation()) );
891 list<boost::shared_ptr<AutomationLine> >
892 AutomationTimeAxisView::lines () const
894 list<boost::shared_ptr<AutomationLine> > lines;
897 lines.push_back (_line);
899 lines = _view->get_lines ();
906 AutomationTimeAxisView::state_id() const
908 if (_automatable != _route && _control) {
909 return string_compose ("automation %1", _control->id().to_s());
910 } else if (_parameter) {
911 return string_compose ("automation %1 %2/%3/%4",
915 (int) _parameter.channel());
917 error << "Automation time axis has no state ID" << endmsg;
922 /** Given a state id string, see if it is one generated by
923 * this class. If so, parse it into its components.
924 * @param state_id State ID string to parse.
925 * @param route_id Filled in with the route's ID if the state ID string is parsed.
926 * @param has_parameter Filled in with true if the state ID has a parameter, otherwise false.
927 * @param parameter Filled in with the state ID's parameter, if it has one.
928 * @return true if this is a state ID generated by this class, otherwise false.
932 AutomationTimeAxisView::parse_state_id (
933 string const & state_id,
935 bool & has_parameter,
936 Evoral::Parameter & parameter)
944 if (a != X_("automation")) {
948 route_id = PBD::ID (b);
951 has_parameter = false;
955 has_parameter = true;
958 boost::split (p, c, boost::is_any_of ("/"));
960 assert (p.size() == 3);
962 parameter = Evoral::Parameter (
963 boost::lexical_cast<int> (p[0]),
964 boost::lexical_cast<int> (p[2]),
965 boost::lexical_cast<int> (p[1])
972 AutomationTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
974 list<boost::shared_ptr<AutomationLine> > lines;
976 lines.push_back (_line);
978 lines = _view->get_lines ();
981 for (list<boost::shared_ptr<AutomationLine> >::iterator i = lines.begin(); i != lines.end(); ++i) {
982 cut_copy_clear_one (**i, selection, op);
987 AutomationTimeAxisView::cut_copy_clear_one (AutomationLine& line, Selection& selection, CutCopyOp op)
989 boost::shared_ptr<Evoral::ControlList> what_we_got;
990 boost::shared_ptr<AutomationList> alist (line.the_list());
992 XMLNode &before = alist->get_state();
994 /* convert time selection to automation list model coordinates */
995 const Evoral::TimeConverter<double, ARDOUR::framepos_t>& tc = line.time_converter ();
996 double const start = tc.from (selection.time.front().start - tc.origin_b ());
997 double const end = tc.from (selection.time.front().end - tc.origin_b ());
1001 if (alist->cut (start, end) != 0) {
1002 _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
1008 if ((what_we_got = alist->cut (start, end)) != 0) {
1009 _editor.get_cut_buffer().add (what_we_got);
1010 _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
1014 if ((what_we_got = alist->copy (start, end)) != 0) {
1015 _editor.get_cut_buffer().add (what_we_got);
1020 if ((what_we_got = alist->cut (start, end)) != 0) {
1021 _session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
1027 for (AutomationList::iterator x = what_we_got->begin(); x != what_we_got->end(); ++x) {
1028 double when = (*x)->when;
1029 double val = (*x)->value;
1030 line.model_to_view_coord (when, val);