2005-09-25 14:42:24 -04:00
|
|
|
#include <ardour/curve.h>
|
|
|
|
#include <ardour/audioregion.h>
|
2006-07-28 23:17:11 -04:00
|
|
|
#include <pbd/memento_command.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "region_gain_line.h"
|
2006-08-03 22:18:45 -04:00
|
|
|
#include "audio_region_view.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
#include "time_axis_view.h"
|
|
|
|
#include "editor.h"
|
|
|
|
|
|
|
|
#include <ardour/session.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
2006-06-22 19:40:55 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-12-22 07:23:54 -05:00
|
|
|
AudioRegionGainLine::AudioRegionGainLine (const string & name, Session& s, AudioRegionView& r, ArdourCanvas::Group& parent, Curve& c)
|
2005-11-23 12:21:12 -05:00
|
|
|
: AutomationLine (name, r.get_time_axis_view(), parent, c),
|
2005-09-25 14:42:24 -04:00
|
|
|
session (s),
|
|
|
|
rv (r)
|
|
|
|
{
|
2005-11-12 22:53:51 -05:00
|
|
|
group->raise_to_top ();
|
2005-09-25 14:42:24 -04:00
|
|
|
set_verbose_cursor_uses_gain_mapping (true);
|
|
|
|
terminal_points_can_slide = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionGainLine::view_to_model_y (double& y)
|
|
|
|
{
|
|
|
|
y = slider_position_to_gain (y);
|
|
|
|
y = max (0.0, y);
|
|
|
|
y = min (2.0, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionGainLine::model_to_view_y (double& y)
|
|
|
|
{
|
|
|
|
y = gain_to_slider_position (y);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-11-28 12:52:09 -05:00
|
|
|
AudioRegionGainLine::start_drag (ControlPoint* cp, nframes_t x, float fraction)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-11-28 12:52:09 -05:00
|
|
|
AutomationLine::start_drag (cp, x, fraction);
|
2006-08-24 21:07:15 -04:00
|
|
|
if (!rv.audio_region()->envelope_active()) {
|
|
|
|
trackview.session().add_command(new MementoCommand<AudioRegion>(*(rv.audio_region().get()), &rv.audio_region()->get_state(), 0));
|
|
|
|
rv.audio_region()->set_envelope_active(false);
|
2006-10-30 21:40:08 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// This is an extended copy from AutomationList
|
|
|
|
void
|
|
|
|
AudioRegionGainLine::remove_point (ControlPoint& cp)
|
|
|
|
{
|
|
|
|
ModelRepresentation mr;
|
|
|
|
|
|
|
|
model_representation (cp, mr);
|
|
|
|
|
|
|
|
trackview.editor.current_session()->begin_reversible_command (_("remove control point"));
|
2006-11-11 10:41:33 -05:00
|
|
|
XMLNode &before = alist.get_state();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-24 21:07:15 -04:00
|
|
|
if (!rv.audio_region()->envelope_active()) {
|
2006-10-30 21:40:08 -05:00
|
|
|
XMLNode ®ion_before = rv.audio_region()->get_state();
|
2006-08-24 21:07:15 -04:00
|
|
|
rv.audio_region()->set_envelope_active(true);
|
2006-10-30 21:40:08 -05:00
|
|
|
XMLNode ®ion_after = rv.audio_region()->get_state();
|
|
|
|
trackview.session().add_command(new MementoCommand<AudioRegion>(*(rv.audio_region().get()), ®ion_before, ®ion_after));
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
alist.erase (mr.start, mr.end);
|
|
|
|
|
2006-11-11 10:41:33 -05:00
|
|
|
trackview.editor.current_session()->add_command (new MementoCommand<AutomationList>(alist, &before, &alist.get_state()));
|
2005-09-25 14:42:24 -04:00
|
|
|
trackview.editor.current_session()->commit_reversible_command ();
|
|
|
|
trackview.editor.current_session()->set_dirty ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioRegionGainLine::end_drag (ControlPoint* cp)
|
|
|
|
{
|
2006-08-24 21:07:15 -04:00
|
|
|
if (!rv.audio_region()->envelope_active()) {
|
|
|
|
rv.audio_region()->set_envelope_active(true);
|
|
|
|
trackview.session().add_command(new MementoCommand<AudioRegion>(*(rv.audio_region().get()), 0, &rv.audio_region()->get_state()));
|
2006-10-30 21:40:08 -05:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
AutomationLine::end_drag(cp);
|
|
|
|
}
|
|
|
|
|
|
|
|
|