1 #include <ardour/curve.h>
2 #include <ardour/audioregion.h>
4 #include "region_gain_line.h"
5 #include "regionview.h"
8 #include "time_axis_view.h"
11 #include <ardour/session.h>
18 using namespace ARDOUR;
20 AudioRegionGainLine::AudioRegionGainLine (string name, Session& s, AudioRegionView& r, ArdourCanvas::Group& parent, Curve& c)
21 : AutomationLine (name, r.get_time_axis_view(), parent, c),
25 group->raise_to_top ();
26 set_verbose_cursor_uses_gain_mapping (true);
27 terminal_points_can_slide = false;
31 AudioRegionGainLine::view_to_model_y (double& y)
33 y = slider_position_to_gain (y);
39 AudioRegionGainLine::model_to_view_y (double& y)
41 y = gain_to_slider_position (y);
45 AudioRegionGainLine::start_drag (ControlPoint* cp, float fraction)
47 AutomationLine::start_drag(cp,fraction);
48 if (!rv.region.envelope_active()) {
49 trackview.session().add_undo( bind( mem_fun(rv.region, &AudioRegion::set_envelope_active), false) );
53 // This is an extended copy from AutomationList
55 AudioRegionGainLine::remove_point (ControlPoint& cp)
57 ModelRepresentation mr;
59 model_representation (cp, mr);
61 trackview.editor.current_session()->begin_reversible_command (_("remove control point"));
62 trackview.editor.current_session()->add_undo (get_memento());
64 if (!rv.region.envelope_active()) {
65 trackview.session().add_undo( bind( mem_fun(rv.region, &AudioRegion::set_envelope_active), false) );
66 trackview.session().add_redo( bind( mem_fun(rv.region, &AudioRegion::set_envelope_active), true) );
67 rv.region.set_envelope_active(true);
70 alist.erase (mr.start, mr.end);
72 trackview.editor.current_session()->add_redo_no_execute (get_memento());
73 trackview.editor.current_session()->commit_reversible_command ();
74 trackview.editor.current_session()->set_dirty ();
78 AudioRegionGainLine::end_drag (ControlPoint* cp)
80 if (!rv.region.envelope_active()) {
81 trackview.session().add_redo( bind( mem_fun(rv.region, &AudioRegion::set_envelope_active), true) );
82 rv.region.set_envelope_active(true);
84 AutomationLine::end_drag(cp);
88 // This is a copy from AutomationList
90 AudioRegionGainLine::get_memento ()
92 return alist.get_memento();