2 Copyright (C) 2002-2003 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.
25 #include "pbd/stl_delete.h"
26 #include "pbd/memento_command.h"
27 #include "pbd/stacktrace.h"
29 #include "ardour/automation_list.h"
30 #include "ardour/dB.h"
31 #include "evoral/Curve.hpp"
33 #include "simplerect.h"
34 #include "automation_line.h"
35 #include "control_point.h"
36 #include "gui_thread.h"
37 #include "rgb_macros.h"
38 #include "ardour_ui.h"
39 #include "public_editor.h"
41 #include "selection.h"
42 #include "time_axis_view.h"
43 #include "point_selection.h"
44 #include "automation_time_axis.h"
45 #include "public_editor.h"
47 #include "ardour/event_type_map.h"
48 #include "ardour/session.h"
53 using namespace ARDOUR;
55 using namespace Editing;
56 using namespace Gnome; // for Canvas
58 /** @param converter A TimeConverter whose origin_b is the start time of the AutomationList in session frames.
59 * This will not be deleted by AutomationLine.
61 AutomationLine::AutomationLine (const string& name, TimeAxisView& tv, ArdourCanvas::Group& parent,
62 boost::shared_ptr<AutomationList> al,
63 Evoral::TimeConverter<double, framepos_t>* converter)
67 , _time_converter (converter ? converter : new Evoral::IdentityConverter<double, framepos_t>)
68 , _parent_group (parent)
70 , _maximum_time (max_framepos)
73 _time_converter = converter;
74 _our_time_converter = false;
76 _time_converter = new Evoral::IdentityConverter<double, framepos_t>;
77 _our_time_converter = true;
80 points_visible = false;
81 update_pending = false;
82 _uses_gain_mapping = false;
86 terminal_points_can_slide = true;
89 group = new ArdourCanvas::Group (parent);
90 group->property_x() = 0.0;
91 group->property_y() = 0.0;
93 line = new ArdourCanvas::Line (*group);
94 line->property_width_pixels() = (guint)1;
95 line->set_data ("line", this);
97 line->signal_event().connect (sigc::mem_fun (*this, &AutomationLine::event_handler));
99 trackview.session()->register_with_memento_command_factory(alist->id(), this);
101 if (alist->parameter().type() == GainAutomation ||
102 alist->parameter().type() == EnvelopeAutomation) {
103 set_uses_gain_mapping (true);
106 interpolation_changed (alist->interpolation ());
111 AutomationLine::~AutomationLine ()
113 vector_delete (&control_points);
116 if (_our_time_converter) {
117 delete _time_converter;
122 AutomationLine::event_handler (GdkEvent* event)
124 return PublicEditor::instance().canvas_line_event (event, line, this);
128 AutomationLine::queue_reset ()
130 if (!update_pending) {
131 update_pending = true;
132 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&AutomationLine::reset, this));
137 AutomationLine::show ()
139 if (alist->interpolation() != AutomationList::Discrete) {
143 if (points_visible) {
144 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
153 AutomationLine::hide ()
156 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
163 AutomationLine::control_point_box_size ()
165 if (alist->interpolation() == AutomationList::Discrete) {
166 return max((_height*4.0) / (double)(alist->parameter().max() - alist->parameter().min()),
170 if (_height > TimeAxisView::preset_height (HeightLarger)) {
172 } else if (_height > (guint32) TimeAxisView::preset_height (HeightNormal)) {
179 AutomationLine::set_height (guint32 h)
184 double bsz = control_point_box_size();
186 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
187 (*i)->set_size (bsz);
195 AutomationLine::set_line_color (uint32_t color)
198 line->property_fill_color_rgba() = color;
202 AutomationLine::set_uses_gain_mapping (bool yn)
204 if (yn != _uses_gain_mapping) {
205 _uses_gain_mapping = yn;
211 AutomationLine::nth (uint32_t n)
213 if (n < control_points.size()) {
214 return control_points[n];
221 AutomationLine::nth (uint32_t n) const
223 if (n < control_points.size()) {
224 return control_points[n];
231 AutomationLine::modify_point_y (ControlPoint& cp, double y)
233 /* clamp y-coord appropriately. y is supposed to be a normalized fraction (0.0-1.0),
234 and needs to be converted to a canvas unit distance.
239 y = _height - (y * _height);
241 double const x = trackview.editor().frame_to_unit (_time_converter->to((*cp.model())->when) - _offset);
243 trackview.editor().session()->begin_reversible_command (_("automation event move"));
244 trackview.editor().session()->add_command (
245 new MementoCommand<AutomationList> (memento_command_binder(), &get_state(), 0)
248 cp.move_to (x, y, ControlPoint::Full);
250 reset_line_coords (cp);
252 if (line_points.size() > 1) {
253 line->property_points() = line_points;
257 sync_model_with_view_point (cp, false, 0);
260 update_pending = false;
262 trackview.editor().session()->add_command (
263 new MementoCommand<AutomationList> (memento_command_binder(), 0, &alist->get_state())
266 trackview.editor().session()->commit_reversible_command ();
267 trackview.editor().session()->set_dirty ();
271 AutomationLine::reset_line_coords (ControlPoint& cp)
273 if (cp.view_index() < line_points.size()) {
274 line_points[cp.view_index()].set_x (cp.get_x());
275 line_points[cp.view_index()].set_y (cp.get_y());
280 AutomationLine::sync_model_with_view_points (list<ControlPoint*> cp, bool did_push, int64_t distance)
282 update_pending = true;
284 for (list<ControlPoint*>::iterator i = cp.begin(); i != cp.end(); ++i) {
285 sync_model_with_view_point (**i, did_push, distance);
290 AutomationLine::get_verbose_cursor_string (double fraction) const
292 std::string s = fraction_to_string (fraction);
293 if (_uses_gain_mapping) {
301 * @param fraction y fraction
302 * @return string representation of this value, using dB if appropriate.
305 AutomationLine::fraction_to_string (double fraction) const
309 if (_uses_gain_mapping) {
310 if (fraction == 0.0) {
311 snprintf (buf, sizeof (buf), "-inf");
313 snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain_with_max (fraction, Config->get_max_gain())));
316 view_to_model_coord_y (fraction);
317 if (EventTypeMap::instance().is_integer (alist->parameter())) {
318 snprintf (buf, sizeof (buf), "%d", (int)fraction);
320 snprintf (buf, sizeof (buf), "%.2f", fraction);
329 * @param s Value string in the form as returned by fraction_to_string.
330 * @return Corresponding y fraction.
333 AutomationLine::string_to_fraction (string const & s) const
340 sscanf (s.c_str(), "%lf", &v);
342 if (_uses_gain_mapping) {
343 v = gain_to_slider_position_with_max (dB_to_coefficient (v), Config->get_max_gain());
346 model_to_view_coord (dummy, v);
352 /** Start dragging a single point, possibly adding others if the supplied point is selected and there
353 * are other selected points.
355 * @param cp Point to drag.
356 * @param x Initial x position (units).
357 * @param fraction Initial y position (as a fraction of the track height, where 0 is the bottom and 1 the top)
360 AutomationLine::start_drag_single (ControlPoint* cp, double x, float fraction)
362 trackview.editor().session()->begin_reversible_command (_("automation event move"));
363 trackview.editor().session()->add_command (
364 new MementoCommand<AutomationList> (memento_command_binder(), &get_state(), 0)
367 _drag_points.clear ();
368 _drag_points.push_back (cp);
370 if (cp->get_selected ()) {
371 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
372 if (*i != cp && (*i)->get_selected()) {
373 _drag_points.push_back (*i);
378 start_drag_common (x, fraction);
381 /** Start dragging a line vertically (with no change in x)
382 * @param i1 Control point index of the `left' point on the line.
383 * @param i2 Control point index of the `right' point on the line.
384 * @param fraction Initial y position (as a fraction of the track height, where 0 is the bottom and 1 the top)
387 AutomationLine::start_drag_line (uint32_t i1, uint32_t i2, float fraction)
389 trackview.editor().session()->begin_reversible_command (_("automation range move"));
390 trackview.editor().session()->add_command (
391 new MementoCommand<AutomationList> (memento_command_binder (), &get_state(), 0)
394 _drag_points.clear ();
395 for (uint32_t i = i1; i <= i2; i++) {
396 _drag_points.push_back (nth (i));
399 start_drag_common (0, fraction);
402 /** Start dragging multiple points (with no change in x)
403 * @param cp Points to drag.
404 * @param fraction Initial y position (as a fraction of the track height, where 0 is the bottom and 1 the top)
407 AutomationLine::start_drag_multiple (list<ControlPoint*> cp, float fraction, XMLNode* state)
409 trackview.editor().session()->begin_reversible_command (_("automation range move"));
410 trackview.editor().session()->add_command (
411 new MementoCommand<AutomationList> (memento_command_binder(), state, 0)
415 start_drag_common (0, fraction);
419 struct ControlPointSorter
421 bool operator() (ControlPoint const * a, ControlPoint const * b) {
422 return a->get_x() < b->get_x();
426 /** Common parts of starting a drag.
427 * @param x Starting x position in units, or 0 if x is being ignored.
428 * @param fraction Starting y position (as a fraction of the track height, where 0 is the bottom and 1 the top)
431 AutomationLine::start_drag_common (double x, float fraction)
435 _last_drag_fraction = fraction;
436 _drag_had_movement = false;
439 _drag_points.sort (ControlPointSorter ());
441 /* find the additional points that will be dragged when the user is holding
445 uint32_t i = _drag_points.back()->view_index () + 1;
447 _push_points.clear ();
448 while ((p = nth (i)) != 0 && p->can_slide()) {
449 _push_points.push_back (p);
454 /** Should be called to indicate motion during a drag.
455 * @param x New x position of the drag in units, or undefined if ignore_x == true.
456 * @param fraction New y fraction.
457 * @return x position and y fraction that were actually used (once clamped).
460 AutomationLine::drag_motion (double x, float fraction, bool ignore_x, bool with_push)
462 /* setup the points that are to be moved this time round */
463 list<ControlPoint*> points = _drag_points;
465 copy (_push_points.begin(), _push_points.end(), back_inserter (points));
466 points.sort (ControlPointSorter ());
469 double dx = ignore_x ? 0 : (x - _drag_x);
470 double dy = fraction - _last_drag_fraction;
473 ControlPoint* before = 0;
474 ControlPoint* after = 0;
476 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
477 if ((*i)->get_x() < points.front()->get_x()) {
480 if ((*i)->get_x() > points.back()->get_x() && after == 0) {
485 double const before_x = before ? before->get_x() : 0;
486 double const after_x = after ? after->get_x() : DBL_MAX;
489 for (list<ControlPoint*>::iterator i = points.begin(); i != points.end(); ++i) {
491 if ((*i)->can_slide() && !ignore_x) {
494 double const a = (*i)->get_x() + dx;
495 double const b = before_x + 1;
503 if (after_x - before_x < 2) {
504 /* after and before are very close, so just leave this alone */
507 double const a = (*i)->get_x() + dx;
508 double const b = after_x - 1;
518 for (list<ControlPoint*>::iterator i = points.begin(); i != points.end(); ++i) {
519 double const y = ((_height - (*i)->get_y()) / _height) + dy;
528 pair<double, float> const clamped (_drag_x + dx, _last_drag_fraction + dy);
529 _drag_distance += dx;
531 _last_drag_fraction = fraction;
533 for (list<ControlPoint*>::iterator i = _drag_points.begin(); i != _drag_points.end(); ++i) {
534 (*i)->move_to ((*i)->get_x() + dx, (*i)->get_y() - _height * dy, ControlPoint::Full);
535 reset_line_coords (**i);
539 /* move push points, preserving their y */
540 for (list<ControlPoint*>::iterator i = _push_points.begin(); i != _push_points.end(); ++i) {
541 (*i)->move_to ((*i)->get_x() + dx, (*i)->get_y(), ControlPoint::Full);
542 reset_line_coords (**i);
546 if (line_points.size() > 1) {
547 line->property_points() = line_points;
550 _drag_had_movement = true;
551 did_push = with_push;
556 /** Should be called to indicate the end of a drag */
558 AutomationLine::end_drag ()
560 if (!_drag_had_movement) {
566 /* set up the points that were moved this time round */
567 list<ControlPoint*> points = _drag_points;
569 copy (_push_points.begin(), _push_points.end(), back_inserter (points));
570 points.sort (ControlPointSorter ());
573 sync_model_with_view_points (points, did_push, rint (_drag_distance * trackview.editor().get_current_zoom ()));
577 update_pending = false;
579 trackview.editor().session()->add_command (
580 new MementoCommand<AutomationList>(memento_command_binder (), 0, &alist->get_state())
583 trackview.editor().session()->set_dirty ();
587 AutomationLine::sync_model_with_view_point (ControlPoint& cp, bool did_push, int64_t distance)
589 /* find out where the visual control point is.
590 initial results are in canvas units. ask the
591 line to convert them to something relevant.
594 double view_x = cp.get_x();
595 double view_y = 1.0 - (cp.get_y() / _height);
597 /* if xval has not changed, set it directly from the model to avoid rounding errors */
599 if (view_x == trackview.editor().frame_to_unit (_time_converter->to ((*cp.model())->when)) - _offset) {
600 view_x = (*cp.model())->when - _offset;
602 view_x = trackview.editor().unit_to_frame (view_x);
603 view_x = _time_converter->from (view_x + _offset);
606 update_pending = true;
608 view_to_model_coord_y (view_y);
610 alist->modify (cp.model(), view_x, view_y);
614 /* move all points after cp by the same distance
617 alist->slide (cp.model()++, distance);
622 AutomationLine::control_points_adjacent (double xval, uint32_t & before, uint32_t& after)
624 ControlPoint *bcp = 0;
625 ControlPoint *acp = 0;
628 unit_xval = trackview.editor().frame_to_unit (xval);
630 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
632 if ((*i)->get_x() <= unit_xval) {
634 if (!bcp || (*i)->get_x() > bcp->get_x()) {
636 before = bcp->view_index();
639 } else if ((*i)->get_x() > unit_xval) {
641 after = acp->view_index();
650 AutomationLine::is_last_point (ControlPoint& cp)
652 // If the list is not empty, and the point is the last point in the list
654 if (alist->empty()) {
658 AutomationList::const_iterator i = alist->end();
661 if (cp.model() == i) {
669 AutomationLine::is_first_point (ControlPoint& cp)
671 // If the list is not empty, and the point is the first point in the list
673 if (!alist->empty() && cp.model() == alist->begin()) {
680 // This is copied into AudioRegionGainLine
682 AutomationLine::remove_point (ControlPoint& cp)
684 trackview.editor().session()->begin_reversible_command (_("remove control point"));
685 XMLNode &before = alist->get_state();
687 alist->erase (cp.model());
689 trackview.editor().session()->add_command(
690 new MementoCommand<AutomationList> (memento_command_binder (), &before, &alist->get_state())
693 trackview.editor().session()->commit_reversible_command ();
694 trackview.editor().session()->set_dirty ();
697 /** Get selectable points within an area.
698 * @param start Start position in session frames.
699 * @param end End position in session frames.
700 * @param bot Bottom y range, as a fraction of line height, where 0 is the bottom of the line.
701 * @param top Top y range, as a fraction of line height, where 0 is the bottom of the line.
702 * @param result Filled in with selectable things; in this case, ControlPoints.
705 AutomationLine::get_selectables (
706 framepos_t start, framepos_t end, double botfrac, double topfrac, list<Selectable*>& results
709 /* convert fractions to display coordinates with 0 at the top of the track */
710 double const bot_track = (1 - topfrac) * trackview.current_height ();
711 double const top_track = (1 - botfrac) * trackview.current_height ();
713 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
714 double const model_when = (*(*i)->model())->when;
716 /* model_when is relative to the start of the source, so we just need to add on the origin_b here
717 (as it is the session frame position of the start of the source)
720 framepos_t const session_frames_when = _time_converter->to (model_when) + _time_converter->origin_b ();
722 if (session_frames_when >= start && session_frames_when <= end && (*i)->get_y() >= bot_track && (*i)->get_y() <= top_track) {
723 results.push_back (*i);
729 AutomationLine::get_inverted_selectables (Selection&, list<Selectable*>& /*results*/)
735 AutomationLine::set_selected_points (PointSelection const & points)
737 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
738 (*i)->set_selected (false);
741 for (PointSelection::const_iterator i = points.begin(); i != points.end(); ++i) {
742 (*i)->set_selected (true);
748 void AutomationLine::set_colors ()
750 set_line_color (ARDOUR_UI::config()->canvasvar_AutomationLine.get());
751 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
757 AutomationLine::list_changed ()
763 AutomationLine::reset_callback (const Evoral::ControlList& events)
769 if (events.empty()) {
770 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
773 control_points.clear ();
778 /* hide all existing points, and the line */
780 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
787 Evoral::ControlList& e = const_cast<Evoral::ControlList&> (events);
789 for (AutomationList::iterator ai = e.begin(); ai != e.end(); ++ai, ++pi) {
791 double tx = (*ai)->when;
792 double ty = (*ai)->value;
794 /* convert from model coordinates to canonical view coordinates */
796 model_to_view_coord (tx, ty);
798 if (std::isnan (tx) || std::isnan (ty)) {
799 warning << string_compose (_("Ignoring illegal points on AutomationLine \"%1\""),
804 if (tx >= max_framepos || tx < 0 || tx >= _maximum_time) {
808 /* convert x-coordinate to a canvas unit coordinate (this takes
809 * zoom and scroll into account).
812 tx = trackview.editor().frame_to_unit (tx);
814 /* convert from canonical view height (0..1.0) to actual
815 * height coordinates (using X11's top-left rooted system)
818 ty = _height - (ty * _height);
820 add_visible_control_point (vp, pi, tx, ty, ai, np);
824 /* discard extra CP's to avoid confusing ourselves */
826 while (control_points.size() > vp) {
827 ControlPoint* cp = control_points.back();
828 control_points.pop_back ();
832 if (!terminal_points_can_slide) {
833 control_points.back()->set_can_slide(false);
838 /* reset the line coordinates given to the CanvasLine */
840 while (line_points.size() < vp) {
841 line_points.push_back (Art::Point (0,0));
844 while (line_points.size() > vp) {
845 line_points.pop_back ();
848 for (uint32_t n = 0; n < vp; ++n) {
849 line_points[n].set_x (control_points[n]->get_x());
850 line_points[n].set_y (control_points[n]->get_y());
853 line->property_points() = line_points;
855 if (_visible && alist->interpolation() != AutomationList::Discrete) {
860 set_selected_points (trackview.editor().get_selection().points);
864 AutomationLine::reset ()
866 update_pending = false;
872 alist->apply_to_points (*this, &AutomationLine::reset_callback);
876 AutomationLine::clear ()
878 /* parent must create and commit command */
879 XMLNode &before = alist->get_state();
882 trackview.editor().session()->add_command (
883 new MementoCommand<AutomationList> (memento_command_binder (), &before, &alist->get_state())
888 AutomationLine::change_model (AutomationList::iterator /*i*/, double /*x*/, double /*y*/)
893 AutomationLine::set_list (boost::shared_ptr<ARDOUR::AutomationList> list)
901 AutomationLine::show_all_control_points ()
904 // show the line but don't allow any control points
908 points_visible = true;
910 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
911 if (!(*i)->visible()) {
913 (*i)->set_visible (true);
919 AutomationLine::hide_all_but_selected_control_points ()
921 if (alist->interpolation() == AutomationList::Discrete) {
925 points_visible = false;
927 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
928 if (!(*i)->get_selected()) {
929 (*i)->set_visible (false);
935 AutomationLine::track_entered()
937 if (alist->interpolation() != AutomationList::Discrete) {
938 show_all_control_points();
943 AutomationLine::track_exited()
945 if (alist->interpolation() != AutomationList::Discrete) {
946 hide_all_but_selected_control_points();
951 AutomationLine::get_state (void)
953 /* function as a proxy for the model */
954 return alist->get_state();
958 AutomationLine::set_state (const XMLNode &node, int version)
960 /* function as a proxy for the model */
961 return alist->set_state (node, version);
965 AutomationLine::view_to_model_coord (double& x, double& y) const
967 x = _time_converter->from (x);
968 view_to_model_coord_y (y);
972 AutomationLine::view_to_model_coord_y (double& y) const
974 /* TODO: This should be more generic ... */
975 if (alist->parameter().type() == GainAutomation ||
976 alist->parameter().type() == EnvelopeAutomation) {
977 y = slider_position_to_gain_with_max (y, Config->get_max_gain());
980 } else if (alist->parameter().type() == PanAzimuthAutomation ||
981 alist->parameter().type() == PanElevationAutomation ||
982 alist->parameter().type() == PanWidthAutomation) {
984 } else if (alist->parameter().type() == PluginAutomation) {
985 y = y * (double)(alist->get_max_y()- alist->get_min_y()) + alist->get_min_y();
987 y = rint (y * alist->parameter().max());
992 AutomationLine::model_to_view_coord (double& x, double& y) const
994 /* TODO: This should be more generic ... */
995 if (alist->parameter().type() == GainAutomation ||
996 alist->parameter().type() == EnvelopeAutomation) {
997 y = gain_to_slider_position_with_max (y, Config->get_max_gain());
998 } else if (alist->parameter().type() == PanAzimuthAutomation ||
999 alist->parameter().type() == PanElevationAutomation ||
1000 alist->parameter().type() == PanWidthAutomation) {
1001 // vertical coordinate axis reversal
1003 } else if (alist->parameter().type() == PluginAutomation) {
1004 y = (y - alist->get_min_y()) / (double)(alist->get_max_y()- alist->get_min_y());
1006 y = y / (double)alist->parameter().max(); /* ... like this */
1009 x = _time_converter->to (x) - _offset;
1012 /** Called when our list has announced that its interpolation style has changed */
1014 AutomationLine::interpolation_changed (AutomationList::InterpolationStyle style)
1016 if (style == AutomationList::Discrete) {
1017 show_all_control_points();
1020 hide_all_but_selected_control_points();
1026 AutomationLine::add_visible_control_point (uint32_t view_index, uint32_t pi, double tx, double ty,
1027 AutomationList::iterator model, uint32_t npoints)
1029 ControlPoint::ShapeType shape;
1031 if (view_index >= control_points.size()) {
1033 /* make sure we have enough control points */
1035 ControlPoint* ncp = new ControlPoint (*this);
1036 ncp->set_size (control_point_box_size ());
1038 control_points.push_back (ncp);
1041 if (!terminal_points_can_slide) {
1043 control_points[view_index]->set_can_slide (false);
1045 shape = ControlPoint::Start;
1047 shape = ControlPoint::Full;
1049 } else if (pi == npoints - 1) {
1050 control_points[view_index]->set_can_slide (false);
1051 shape = ControlPoint::End;
1053 control_points[view_index]->set_can_slide (true);
1054 shape = ControlPoint::Full;
1057 control_points[view_index]->set_can_slide (true);
1058 shape = ControlPoint::Full;
1061 control_points[view_index]->reset (tx, ty, model, view_index, shape);
1063 /* finally, control visibility */
1065 if (_visible && points_visible) {
1066 control_points[view_index]->show ();
1067 control_points[view_index]->set_visible (true);
1069 if (!points_visible) {
1070 control_points[view_index]->set_visible (false);
1076 AutomationLine::connect_to_list ()
1078 _list_connections.drop_connections ();
1080 alist->StateChanged.connect (_list_connections, invalidator (*this), boost::bind (&AutomationLine::list_changed, this), gui_context());
1082 alist->InterpolationChanged.connect (
1083 _list_connections, invalidator (*this), boost::bind (&AutomationLine::interpolation_changed, this, _1), gui_context()
1087 MementoCommandBinder<AutomationList>*
1088 AutomationLine::memento_command_binder ()
1090 return new SimpleMementoCommandBinder<AutomationList> (*alist.get());
1093 /** Set the maximum time that points on this line can be at, relative
1094 * to the start of the track or region that it is on.
1097 AutomationLine::set_maximum_time (framecnt_t t)
1099 if (_maximum_time == t) {
1108 /** @return min and max x positions of points that are in the list, in session frames */
1109 pair<framepos_t, framepos_t>
1110 AutomationLine::get_point_x_range () const
1112 pair<framepos_t, framepos_t> r (max_framepos, 0);
1114 for (AutomationList::const_iterator i = the_list()->begin(); i != the_list()->end(); ++i) {
1115 r.first = min (r.first, session_position (i));
1116 r.second = max (r.second, session_position (i));
1123 AutomationLine::session_position (AutomationList::const_iterator p) const
1125 return _time_converter->to ((*p)->when) + _offset + _time_converter->origin_b ();
1129 AutomationLine::set_offset (framepos_t off)
1131 if (_offset == off) {