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;
21 AudioRegionGainLine::AudioRegionGainLine (const string & name, Session& s, AudioRegionView& r, ArdourCanvas::Group& parent, Curve& c)
22 : AutomationLine (name, r.get_time_axis_view(), parent, c),
26 group->raise_to_top ();
27 set_verbose_cursor_uses_gain_mapping (true);
28 terminal_points_can_slide = false;
32 AudioRegionGainLine::view_to_model_y (double& y)
34 y = slider_position_to_gain (y);
40 AudioRegionGainLine::model_to_view_y (double& y)
42 y = gain_to_slider_position (y);
46 AudioRegionGainLine::start_drag (ControlPoint* cp, float fraction)
48 AutomationLine::start_drag(cp,fraction);
49 if (!rv.region.envelope_active()) {
50 trackview.session().add_undo( bind( mem_fun(rv.region, &AudioRegion::set_envelope_active), false) );
54 // This is an extended copy from AutomationList
56 AudioRegionGainLine::remove_point (ControlPoint& cp)
58 ModelRepresentation mr;
60 model_representation (cp, mr);
62 trackview.editor.current_session()->begin_reversible_command (_("remove control point"));
63 trackview.editor.current_session()->add_undo (get_memento());
65 if (!rv.region.envelope_active()) {
66 trackview.session().add_undo( bind( mem_fun(rv.region, &AudioRegion::set_envelope_active), false) );
67 trackview.session().add_redo( bind( mem_fun(rv.region, &AudioRegion::set_envelope_active), true) );
68 rv.region.set_envelope_active(true);
71 alist.erase (mr.start, mr.end);
73 trackview.editor.current_session()->add_redo_no_execute (get_memento());
74 trackview.editor.current_session()->commit_reversible_command ();
75 trackview.editor.current_session()->set_dirty ();
79 AudioRegionGainLine::end_drag (ControlPoint* cp)
81 if (!rv.region.envelope_active()) {
82 trackview.session().add_redo( bind( mem_fun(rv.region, &AudioRegion::set_envelope_active), true) );
83 rv.region.set_envelope_active(true);
85 AutomationLine::end_drag(cp);
89 // This is a copy from AutomationList
91 AudioRegionGainLine::get_memento ()
93 return alist.get_memento();