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"
46 #include "ardour/event_type_map.h"
47 #include "ardour/session.h"
52 using namespace ARDOUR;
54 using namespace Editing;
55 using namespace Gnome; // for Canvas
57 /** @param converter A TimeConverter whose origin_b is the start time of the AutomationList in session frames.
58 * This will not be deleted by AutomationLine.
60 AutomationLine::AutomationLine (const string& name, TimeAxisView& tv, ArdourCanvas::Group& parent,
61 boost::shared_ptr<AutomationList> al,
62 Evoral::TimeConverter<double, framepos_t>* converter)
66 , _time_converter (converter ? converter : new Evoral::IdentityConverter<double, framepos_t>)
67 , _parent_group (parent)
69 , _maximum_time (max_framepos)
72 _time_converter = converter;
73 _our_time_converter = false;
75 _time_converter = new Evoral::IdentityConverter<double, framepos_t>;
76 _our_time_converter = true;
81 update_pending = false;
82 _uses_gain_mapping = false;
85 terminal_points_can_slide = true;
88 group = new ArdourCanvas::Group (parent);
89 group->property_x() = 0.0;
90 group->property_y() = 0.0;
92 line = new ArdourCanvas::Line (*group);
93 line->property_width_pixels() = (guint)1;
94 line->set_data ("line", this);
96 line->signal_event().connect (sigc::mem_fun (*this, &AutomationLine::event_handler));
98 trackview.session()->register_with_memento_command_factory(alist->id(), this);
100 if (alist->parameter().type() == GainAutomation ||
101 alist->parameter().type() == EnvelopeAutomation) {
102 set_uses_gain_mapping (true);
105 interpolation_changed (alist->interpolation ());
110 AutomationLine::~AutomationLine ()
112 vector_delete (&control_points);
115 if (_our_time_converter) {
116 delete _time_converter;
121 AutomationLine::event_handler (GdkEvent* event)
123 return PublicEditor::instance().canvas_line_event (event, line, this);
127 AutomationLine::queue_reset ()
129 if (!update_pending) {
130 update_pending = true;
131 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&AutomationLine::reset, this));
136 AutomationLine::show ()
138 if (_visible & Line) {
139 /* Only show the line there are some points, otherwise we may show an out-of-date line
140 when automation points have been removed (the line will still follow the shape of the
143 if (alist->interpolation() != AutomationList::Discrete && control_points.size() >= 2) {
152 if (_visible & ControlPoints) {
153 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
154 (*i)->set_visible (true);
157 } else if (_visible & SelectedControlPoints) {
158 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
159 (*i)->set_visible ((*i)->get_selected());
162 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
163 (*i)->set_visible (false);
169 AutomationLine::hide ()
171 set_visibility (VisibleAspects (0));
175 AutomationLine::control_point_box_size ()
177 if (alist->interpolation() == AutomationList::Discrete) {
178 return max((_height*4.0) / (double)(alist->parameter().max() - alist->parameter().min()),
182 if (_height > TimeAxisView::preset_height (HeightLarger)) {
184 } else if (_height > (guint32) TimeAxisView::preset_height (HeightNormal)) {
191 AutomationLine::set_height (guint32 h)
196 double bsz = control_point_box_size();
198 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
199 (*i)->set_size (bsz);
207 AutomationLine::set_line_color (uint32_t color)
210 line->property_fill_color_rgba() = color;
214 AutomationLine::set_uses_gain_mapping (bool yn)
216 if (yn != _uses_gain_mapping) {
217 _uses_gain_mapping = yn;
223 AutomationLine::nth (uint32_t n)
225 if (n < control_points.size()) {
226 return control_points[n];
233 AutomationLine::nth (uint32_t n) const
235 if (n < control_points.size()) {
236 return control_points[n];
243 AutomationLine::modify_point_y (ControlPoint& cp, double y)
245 /* clamp y-coord appropriately. y is supposed to be a normalized fraction (0.0-1.0),
246 and needs to be converted to a canvas unit distance.
251 y = _height - (y * _height);
253 double const x = trackview.editor().frame_to_unit_unrounded (_time_converter->to((*cp.model())->when) - _offset);
255 trackview.editor().session()->begin_reversible_command (_("automation event move"));
256 trackview.editor().session()->add_command (
257 new MementoCommand<AutomationList> (memento_command_binder(), &get_state(), 0)
260 cp.move_to (x, y, ControlPoint::Full);
262 reset_line_coords (cp);
264 if (line_points.size() > 1) {
265 line->property_points() = line_points;
269 sync_model_with_view_point (cp, 0);
272 update_pending = false;
274 trackview.editor().session()->add_command (
275 new MementoCommand<AutomationList> (memento_command_binder(), 0, &alist->get_state())
278 trackview.editor().session()->commit_reversible_command ();
279 trackview.editor().session()->set_dirty ();
283 AutomationLine::reset_line_coords (ControlPoint& cp)
285 if (cp.view_index() < line_points.size()) {
286 line_points[cp.view_index()].set_x (cp.get_x());
287 line_points[cp.view_index()].set_y (cp.get_y());
292 AutomationLine::sync_model_with_view_points (list<ControlPoint*> cp, int64_t distance)
294 update_pending = true;
296 for (list<ControlPoint*>::iterator i = cp.begin(); i != cp.end(); ++i) {
297 sync_model_with_view_point (**i, distance);
302 AutomationLine::get_verbose_cursor_string (double fraction) const
304 std::string s = fraction_to_string (fraction);
305 if (_uses_gain_mapping) {
313 * @param fraction y fraction
314 * @return string representation of this value, using dB if appropriate.
317 AutomationLine::fraction_to_string (double fraction) const
321 if (_uses_gain_mapping) {
322 if (fraction == 0.0) {
323 snprintf (buf, sizeof (buf), "-inf");
325 snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain_with_max (fraction, Config->get_max_gain())));
328 view_to_model_coord_y (fraction);
329 if (EventTypeMap::instance().is_integer (alist->parameter())) {
330 snprintf (buf, sizeof (buf), "%d", (int)fraction);
332 snprintf (buf, sizeof (buf), "%.2f", fraction);
341 * @param s Value string in the form as returned by fraction_to_string.
342 * @return Corresponding y fraction.
345 AutomationLine::string_to_fraction (string const & s) const
352 sscanf (s.c_str(), "%lf", &v);
354 if (_uses_gain_mapping) {
355 v = gain_to_slider_position_with_max (dB_to_coefficient (v), Config->get_max_gain());
358 model_to_view_coord (dummy, v);
364 /** Start dragging a single point, possibly adding others if the supplied point is selected and there
365 * are other selected points.
367 * @param cp Point to drag.
368 * @param x Initial x position (units).
369 * @param fraction Initial y position (as a fraction of the track height, where 0 is the bottom and 1 the top)
372 AutomationLine::start_drag_single (ControlPoint* cp, double x, float fraction)
374 trackview.editor().session()->begin_reversible_command (_("automation event move"));
375 trackview.editor().session()->add_command (
376 new MementoCommand<AutomationList> (memento_command_binder(), &get_state(), 0)
379 _drag_points.clear ();
380 _drag_points.push_back (cp);
382 if (cp->get_selected ()) {
383 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
384 if (*i != cp && (*i)->get_selected()) {
385 _drag_points.push_back (*i);
390 start_drag_common (x, fraction);
393 /** Start dragging a line vertically (with no change in x)
394 * @param i1 Control point index of the `left' point on the line.
395 * @param i2 Control point index of the `right' point on the line.
396 * @param fraction Initial y position (as a fraction of the track height, where 0 is the bottom and 1 the top)
399 AutomationLine::start_drag_line (uint32_t i1, uint32_t i2, float fraction)
401 trackview.editor().session()->begin_reversible_command (_("automation range move"));
402 trackview.editor().session()->add_command (
403 new MementoCommand<AutomationList> (memento_command_binder (), &get_state(), 0)
406 _drag_points.clear ();
407 for (uint32_t i = i1; i <= i2; i++) {
408 _drag_points.push_back (nth (i));
411 start_drag_common (0, fraction);
414 /** Start dragging multiple points (with no change in x)
415 * @param cp Points to drag.
416 * @param fraction Initial y position (as a fraction of the track height, where 0 is the bottom and 1 the top)
419 AutomationLine::start_drag_multiple (list<ControlPoint*> cp, float fraction, XMLNode* state)
421 trackview.editor().session()->begin_reversible_command (_("automation range move"));
422 trackview.editor().session()->add_command (
423 new MementoCommand<AutomationList> (memento_command_binder(), state, 0)
427 start_drag_common (0, fraction);
431 struct ControlPointSorter
433 bool operator() (ControlPoint const * a, ControlPoint const * b) {
434 return a->get_x() < b->get_x();
438 /** Common parts of starting a drag.
439 * @param x Starting x position in units, or 0 if x is being ignored.
440 * @param fraction Starting y position (as a fraction of the track height, where 0 is the bottom and 1 the top)
443 AutomationLine::start_drag_common (double x, float fraction)
447 _last_drag_fraction = fraction;
448 _drag_had_movement = false;
451 _drag_points.sort (ControlPointSorter ());
453 /* find the additional points that will be dragged when the user is holding
457 uint32_t i = _drag_points.back()->view_index () + 1;
459 _push_points.clear ();
460 while ((p = nth (i)) != 0 && p->can_slide()) {
461 _push_points.push_back (p);
466 /** Should be called to indicate motion during a drag.
467 * @param x New x position of the drag in canvas units, or undefined if ignore_x == true.
468 * @param fraction New y fraction.
469 * @return x position and y fraction that were actually used (once clamped).
472 AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool with_push)
474 /* setup the points that are to be moved this time round */
475 list<ControlPoint*> points = _drag_points;
477 copy (_push_points.begin(), _push_points.end(), back_inserter (points));
478 points.sort (ControlPointSorter ());
481 double dx = ignore_x ? 0 : (x - _drag_x);
482 double dy = fraction - _last_drag_fraction;
484 for (list<ControlPoint*>::iterator i = points.begin(); i != points.end(); ++i) {
485 /* Find the points that aren't being moved before and after
486 this one on the control_points list
489 ControlPoint* before = 0;
490 ControlPoint* after = 0;
492 ControlPoint* last = 0;
493 for (vector<ControlPoint*>::iterator j = control_points.begin(); j != control_points.end(); ++j) {
499 vector<ControlPoint*>::iterator k = j;
504 /* Now move past any points that are being moved this time */
505 while (find (points.begin(), points.end(), *k) != points.end() && k != control_points.end ()) {
509 if (k != control_points.end()) {
515 if (find (points.begin(), points.end(), *j) == points.end ()) {
516 /* This point isn't being moved, so it's the `last' point we've seen */
521 /* Clamp dx for this point */
522 double const before_x = before ? before->get_x() : 0;
523 double const after_x = after ? after->get_x() : DBL_MAX;
525 double tx = (*i)->get_x() + dx;
526 tx = max (tx, before_x);
527 tx = min (tx, after_x);
528 dx = tx - (*i)->get_x ();
532 for (list<ControlPoint*>::iterator i = points.begin(); i != points.end(); ++i) {
533 double const y = ((_height - (*i)->get_y()) / _height) + dy;
542 pair<double, float> const clamped (_drag_x + dx, _last_drag_fraction + dy);
543 _drag_distance += dx;
545 _last_drag_fraction = fraction;
547 for (list<ControlPoint*>::iterator i = _drag_points.begin(); i != _drag_points.end(); ++i) {
548 (*i)->move_to ((*i)->get_x() + dx, (*i)->get_y() - _height * dy, ControlPoint::Full);
549 reset_line_coords (**i);
553 /* move push points, preserving their y */
554 for (list<ControlPoint*>::iterator i = _push_points.begin(); i != _push_points.end(); ++i) {
555 (*i)->move_to ((*i)->get_x() + dx, (*i)->get_y(), ControlPoint::Full);
556 reset_line_coords (**i);
560 if (line_points.size() > 1) {
561 line->property_points() = line_points;
564 _drag_had_movement = true;
566 did_push = with_push;
572 /** Should be called to indicate the end of a drag */
574 AutomationLine::end_drag ()
576 if (!_drag_had_movement) {
582 /* set up the points that were moved this time round */
583 list<ControlPoint*> points = _drag_points;
585 copy (_push_points.begin(), _push_points.end(), back_inserter (points));
586 points.sort (ControlPointSorter ());
589 sync_model_with_view_points (points, trackview.editor().unit_to_frame (_drag_distance));
593 update_pending = false;
595 trackview.editor().session()->add_command (
596 new MementoCommand<AutomationList>(memento_command_binder (), 0, &alist->get_state())
599 trackview.editor().session()->set_dirty ();
604 AutomationLine::sync_model_with_view_point (ControlPoint& cp, framecnt_t distance)
606 /* find out where the visual control point is.
607 initial results are in canvas units. ask the
608 line to convert them to something relevant.
611 double view_x = cp.get_x();
612 double view_y = 1.0 - (cp.get_y() / _height);
614 /* if xval has not changed, set it directly from the model to avoid rounding errors */
616 if (view_x == trackview.editor().frame_to_unit_unrounded (_time_converter->to ((*cp.model())->when)) - _offset) {
617 view_x = (*cp.model())->when - _offset;
619 view_x = trackview.editor().unit_to_frame (view_x);
620 view_x = _time_converter->from (view_x + _offset);
623 update_pending = true;
625 view_to_model_coord_y (view_y);
627 alist->modify (cp.model(), view_x, view_y);
631 AutomationLine::control_points_adjacent (double xval, uint32_t & before, uint32_t& after)
633 ControlPoint *bcp = 0;
634 ControlPoint *acp = 0;
637 unit_xval = trackview.editor().frame_to_unit_unrounded (xval);
639 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
641 if ((*i)->get_x() <= unit_xval) {
643 if (!bcp || (*i)->get_x() > bcp->get_x()) {
645 before = bcp->view_index();
648 } else if ((*i)->get_x() > unit_xval) {
650 after = acp->view_index();
659 AutomationLine::is_last_point (ControlPoint& cp)
661 // If the list is not empty, and the point is the last point in the list
663 if (alist->empty()) {
667 AutomationList::const_iterator i = alist->end();
670 if (cp.model() == i) {
678 AutomationLine::is_first_point (ControlPoint& cp)
680 // If the list is not empty, and the point is the first point in the list
682 if (!alist->empty() && cp.model() == alist->begin()) {
689 // This is copied into AudioRegionGainLine
691 AutomationLine::remove_point (ControlPoint& cp)
693 trackview.editor().session()->begin_reversible_command (_("remove control point"));
694 XMLNode &before = alist->get_state();
696 alist->erase (cp.model());
698 trackview.editor().session()->add_command(
699 new MementoCommand<AutomationList> (memento_command_binder (), &before, &alist->get_state())
702 trackview.editor().session()->commit_reversible_command ();
703 trackview.editor().session()->set_dirty ();
706 /** Get selectable points within an area.
707 * @param start Start position in session frames.
708 * @param end End position in session frames.
709 * @param bot Bottom y range, as a fraction of line height, where 0 is the bottom of the line.
710 * @param top Top y range, as a fraction of line height, where 0 is the bottom of the line.
711 * @param result Filled in with selectable things; in this case, ControlPoints.
714 AutomationLine::get_selectables (
715 framepos_t start, framepos_t end, double botfrac, double topfrac, list<Selectable*>& results
718 /* convert fractions to display coordinates with 0 at the top of the track */
719 double const bot_track = (1 - topfrac) * trackview.current_height ();
720 double const top_track = (1 - botfrac) * trackview.current_height ();
722 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
723 double const model_when = (*(*i)->model())->when;
725 /* model_when is relative to the start of the source, so we just need to add on the origin_b here
726 (as it is the session frame position of the start of the source)
729 framepos_t const session_frames_when = _time_converter->to (model_when) + _time_converter->origin_b ();
731 if (session_frames_when >= start && session_frames_when <= end && (*i)->get_y() >= bot_track && (*i)->get_y() <= top_track) {
732 results.push_back (*i);
738 AutomationLine::get_inverted_selectables (Selection&, list<Selectable*>& /*results*/)
744 AutomationLine::set_selected_points (PointSelection const & points)
746 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
747 (*i)->set_selected (false);
750 for (PointSelection::const_iterator i = points.begin(); i != points.end(); ++i) {
751 (*i)->set_selected (true);
757 void AutomationLine::set_colors ()
759 set_line_color (ARDOUR_UI::config()->canvasvar_AutomationLine.get());
760 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
766 AutomationLine::list_changed ()
772 AutomationLine::reset_callback (const Evoral::ControlList& events)
778 if (events.empty()) {
779 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
782 control_points.clear ();
787 /* hide all existing points, and the line */
789 for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
796 Evoral::ControlList& e = const_cast<Evoral::ControlList&> (events);
798 for (AutomationList::iterator ai = e.begin(); ai != e.end(); ++ai, ++pi) {
800 double tx = (*ai)->when;
801 double ty = (*ai)->value;
803 /* convert from model coordinates to canonical view coordinates */
805 model_to_view_coord (tx, ty);
807 if (std::isnan (tx) || std::isnan (ty)) {
808 warning << string_compose (_("Ignoring illegal points on AutomationLine \"%1\""),
813 if (tx >= max_framepos || tx < 0 || tx >= _maximum_time) {
817 /* convert x-coordinate to a canvas unit coordinate (this takes
818 * zoom and scroll into account).
821 tx = trackview.editor().frame_to_unit_unrounded (tx);
823 /* convert from canonical view height (0..1.0) to actual
824 * height coordinates (using X11's top-left rooted system)
827 ty = _height - (ty * _height);
829 add_visible_control_point (vp, pi, tx, ty, ai, np);
833 /* discard extra CP's to avoid confusing ourselves */
835 while (control_points.size() > vp) {
836 ControlPoint* cp = control_points.back();
837 control_points.pop_back ();
841 if (!terminal_points_can_slide) {
842 control_points.back()->set_can_slide(false);
847 /* reset the line coordinates given to the CanvasLine */
849 while (line_points.size() < vp) {
850 line_points.push_back (Art::Point (0,0));
853 while (line_points.size() > vp) {
854 line_points.pop_back ();
857 for (uint32_t n = 0; n < vp; ++n) {
858 line_points[n].set_x (control_points[n]->get_x());
859 line_points[n].set_y (control_points[n]->get_y());
862 line->property_points() = line_points;
864 if (_visible && alist->interpolation() != AutomationList::Discrete) {
869 set_selected_points (trackview.editor().get_selection().points);
873 AutomationLine::reset ()
875 update_pending = false;
881 alist->apply_to_points (*this, &AutomationLine::reset_callback);
885 AutomationLine::clear ()
887 /* parent must create and commit command */
888 XMLNode &before = alist->get_state();
891 trackview.editor().session()->add_command (
892 new MementoCommand<AutomationList> (memento_command_binder (), &before, &alist->get_state())
897 AutomationLine::change_model (AutomationList::iterator /*i*/, double /*x*/, double /*y*/)
902 AutomationLine::set_list (boost::shared_ptr<ARDOUR::AutomationList> list)
910 AutomationLine::add_visibility (VisibleAspects va)
912 _visible = VisibleAspects (_visible | va);
917 AutomationLine::set_visibility (VisibleAspects va)
924 AutomationLine::remove_visibility (VisibleAspects va)
926 _visible = VisibleAspects (_visible & ~va);
931 AutomationLine::track_entered()
933 if (alist->interpolation() != AutomationList::Discrete) {
934 add_visibility (ControlPoints);
939 AutomationLine::track_exited()
941 if (alist->interpolation() != AutomationList::Discrete) {
942 remove_visibility (ControlPoints);
947 AutomationLine::get_state (void)
949 /* function as a proxy for the model */
950 return alist->get_state();
954 AutomationLine::set_state (const XMLNode &node, int version)
956 /* function as a proxy for the model */
957 return alist->set_state (node, version);
961 AutomationLine::view_to_model_coord (double& x, double& y) const
963 x = _time_converter->from (x);
964 view_to_model_coord_y (y);
968 AutomationLine::view_to_model_coord_y (double& y) const
970 /* TODO: This should be more generic ... */
971 if (alist->parameter().type() == GainAutomation ||
972 alist->parameter().type() == EnvelopeAutomation) {
973 y = slider_position_to_gain_with_max (y, Config->get_max_gain());
976 } else if (alist->parameter().type() == PanAzimuthAutomation ||
977 alist->parameter().type() == PanElevationAutomation ||
978 alist->parameter().type() == PanWidthAutomation) {
980 } else if (alist->parameter().type() == PluginAutomation) {
981 y = y * (double)(alist->get_max_y()- alist->get_min_y()) + alist->get_min_y();
983 y = rint (y * alist->parameter().max());
988 AutomationLine::model_to_view_coord (double& x, double& y) const
990 /* TODO: This should be more generic ... */
991 if (alist->parameter().type() == GainAutomation ||
992 alist->parameter().type() == EnvelopeAutomation) {
993 y = gain_to_slider_position_with_max (y, Config->get_max_gain());
994 } else if (alist->parameter().type() == PanAzimuthAutomation ||
995 alist->parameter().type() == PanElevationAutomation ||
996 alist->parameter().type() == PanWidthAutomation) {
997 // vertical coordinate axis reversal
999 } else if (alist->parameter().type() == PluginAutomation) {
1000 y = (y - alist->get_min_y()) / (double)(alist->get_max_y()- alist->get_min_y());
1002 y = y / (double)alist->parameter().max(); /* ... like this */
1005 x = _time_converter->to (x) - _offset;
1008 /** Called when our list has announced that its interpolation style has changed */
1010 AutomationLine::interpolation_changed (AutomationList::InterpolationStyle style)
1012 if (style == AutomationList::Discrete) {
1013 set_visibility (ControlPoints);
1016 set_visibility (Line);
1021 AutomationLine::add_visible_control_point (uint32_t view_index, uint32_t pi, double tx, double ty,
1022 AutomationList::iterator model, uint32_t npoints)
1024 ControlPoint::ShapeType shape;
1026 if (view_index >= control_points.size()) {
1028 /* make sure we have enough control points */
1030 ControlPoint* ncp = new ControlPoint (*this);
1031 ncp->set_size (control_point_box_size ());
1033 control_points.push_back (ncp);
1036 if (!terminal_points_can_slide) {
1038 control_points[view_index]->set_can_slide (false);
1040 shape = ControlPoint::Start;
1042 shape = ControlPoint::Full;
1044 } else if (pi == npoints - 1) {
1045 control_points[view_index]->set_can_slide (false);
1046 shape = ControlPoint::End;
1048 control_points[view_index]->set_can_slide (true);
1049 shape = ControlPoint::Full;
1052 control_points[view_index]->set_can_slide (true);
1053 shape = ControlPoint::Full;
1056 control_points[view_index]->reset (tx, ty, model, view_index, shape);
1058 /* finally, control visibility */
1060 if (_visible & ControlPoints) {
1061 control_points[view_index]->show ();
1062 control_points[view_index]->set_visible (true);
1064 control_points[view_index]->set_visible (false);
1069 AutomationLine::connect_to_list ()
1071 _list_connections.drop_connections ();
1073 alist->StateChanged.connect (_list_connections, invalidator (*this), boost::bind (&AutomationLine::list_changed, this), gui_context());
1075 alist->InterpolationChanged.connect (
1076 _list_connections, invalidator (*this), boost::bind (&AutomationLine::interpolation_changed, this, _1), gui_context()
1080 MementoCommandBinder<AutomationList>*
1081 AutomationLine::memento_command_binder ()
1083 return new SimpleMementoCommandBinder<AutomationList> (*alist.get());
1086 /** Set the maximum time that points on this line can be at, relative
1087 * to the start of the track or region that it is on.
1090 AutomationLine::set_maximum_time (framecnt_t t)
1092 if (_maximum_time == t) {
1101 /** @return min and max x positions of points that are in the list, in session frames */
1102 pair<framepos_t, framepos_t>
1103 AutomationLine::get_point_x_range () const
1105 pair<framepos_t, framepos_t> r (max_framepos, 0);
1107 for (AutomationList::const_iterator i = the_list()->begin(); i != the_list()->end(); ++i) {
1108 r.first = min (r.first, session_position (i));
1109 r.second = max (r.second, session_position (i));
1116 AutomationLine::session_position (AutomationList::const_iterator p) const
1118 return _time_converter->to ((*p)->when) + _offset + _time_converter->origin_b ();
1122 AutomationLine::set_offset (framepos_t off)
1124 if (_offset == off) {