remove global LV2 external GUI list, always call LV2 UI cleanup method when appropria...
[ardour2.git] / gtk2_ardour / region_gain_line.cc
blob1e23c2c55df8210f3ea4dd1e4ccd246199091f53
1 /*
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.
20 #include <ardour/curve.h>
21 #include <ardour/audioregion.h>
22 #include <pbd/memento_command.h>
24 #include "region_gain_line.h"
25 #include "audio_region_view.h"
26 #include "utils.h"
28 #include "time_axis_view.h"
29 #include "editor.h"
31 #include <ardour/session.h>
34 #include "i18n.h"
37 using namespace std;
38 using namespace ARDOUR;
39 using namespace PBD;
41 AudioRegionGainLine::AudioRegionGainLine (const string & name, Session& s, AudioRegionView& r, ArdourCanvas::Group& parent, Curve& c)
42 : AutomationLine (name, r.get_time_axis_view(), parent, c),
43 session (s),
44 rv (r)
46 group->raise_to_top ();
47 group->property_y() = 2;
48 set_verbose_cursor_uses_gain_mapping (true);
49 terminal_points_can_slide = false;
52 void
53 AudioRegionGainLine::view_to_model_y (double& y)
55 y = slider_position_to_gain (y);
56 y = max (0.0, y);
57 y = min (2.0, y);
60 void
61 AudioRegionGainLine::model_to_view_y (double& y)
63 if (y < 0) y = 0;
65 y = gain_to_slider_position (y);
68 void
69 AudioRegionGainLine::start_drag (ControlPoint* cp, nframes_t x, float fraction)
71 AutomationLine::start_drag (cp, x, fraction);
72 if (!rv.audio_region()->envelope_active()) {
73 trackview.session().add_command(new MementoCommand<AudioRegion>(*(rv.audio_region().get()), &rv.audio_region()->get_state(), 0));
74 rv.audio_region()->set_envelope_active(false);
78 // This is an extended copy from AutomationList
79 void
80 AudioRegionGainLine::remove_point (ControlPoint& cp)
82 ModelRepresentation mr;
84 model_representation (cp, mr);
86 trackview.editor.current_session()->begin_reversible_command (_("remove control point"));
87 XMLNode &before = alist.get_state();
89 if (!rv.audio_region()->envelope_active()) {
90 XMLNode &region_before = rv.audio_region()->get_state();
91 rv.audio_region()->set_envelope_active(true);
92 XMLNode &region_after = rv.audio_region()->get_state();
93 trackview.session().add_command(new MementoCommand<AudioRegion>(*(rv.audio_region().get()), &region_before, &region_after));
96 alist.erase (mr.start, mr.end);
98 trackview.editor.current_session()->add_command (new MementoCommand<AutomationList>(alist, &before, &alist.get_state()));
99 trackview.editor.current_session()->commit_reversible_command ();
100 trackview.editor.current_session()->set_dirty ();
103 void
104 AudioRegionGainLine::end_drag (ControlPoint* cp)
106 if (!rv.audio_region()->envelope_active()) {
107 rv.audio_region()->set_envelope_active(true);
108 trackview.session().add_command(new MementoCommand<AudioRegion>(*(rv.audio_region().get()), 0, &rv.audio_region()->get_state()));
111 AutomationLine::end_drag(cp);