13
0

Fix region-gain envelope auto-enable when dragging

When using freehand drawing of automation, the line itself
is not notified (no ::start_drag(), ::end_drag() calls).

This adds a end_draw() call which allows the AutomatioLine
to perform additional actions.
This commit is contained in:
Robin Gareus 2024-04-14 19:37:09 +02:00
parent b04fa05f20
commit ad9a3ae103
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
4 changed files with 40 additions and 0 deletions

View File

@ -94,6 +94,7 @@ public:
virtual void start_drag_multiple (std::list<ControlPoint*>, float, XMLNode *); virtual void start_drag_multiple (std::list<ControlPoint*>, float, XMLNode *);
virtual std::pair<float, float> drag_motion (Temporal::timecnt_t const &, float, bool, bool with_push, uint32_t& final_index); virtual std::pair<float, float> drag_motion (Temporal::timecnt_t const &, float, bool, bool with_push, uint32_t& final_index);
virtual void end_drag (bool with_push, uint32_t final_index); virtual void end_drag (bool with_push, uint32_t final_index);
virtual void end_draw_merge () {}
ControlPoint* nth (uint32_t); ControlPoint* nth (uint32_t);
ControlPoint const * nth (uint32_t) const; ControlPoint const * nth (uint32_t) const;

View File

@ -103,6 +103,8 @@ MergeableLine::merge_drawn_line (Editor& e, Session& s, Evoral::ControlList::Ord
e.begin_reversible_command (_("draw automation")); e.begin_reversible_command (_("draw automation"));
s.add_command (new MementoCommand<ARDOUR::AutomationList> (*list.get (), &before, &after)); s.add_command (new MementoCommand<ARDOUR::AutomationList> (*list.get (), &before, &after));
_line->end_draw_merge ();
_line->get_selectables (earliest, latest, 0.0, 1.0, results); _line->get_selectables (earliest, latest, 0.0, 1.0, results);
e.get_selection ().set (results); e.get_selection ().set (results);

View File

@ -77,6 +77,28 @@ AudioRegionGainLine::start_drag_single (ControlPoint* cp, double x, float fracti
} }
} }
void
AudioRegionGainLine::start_drag_line (uint32_t i1, uint32_t i2, float fraction)
{
AutomationLine::start_drag_line (i1, i2, fraction);
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);
}
}
void
AudioRegionGainLine::start_drag_multiple (list<ControlPoint*> cp, float fraction, XMLNode* state)
{
AutomationLine::start_drag_multiple (cp, fraction, state);
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);
}
}
// This is an extended copy from AutomationList // This is an extended copy from AutomationList
void void
AudioRegionGainLine::remove_point (ControlPoint& cp) AudioRegionGainLine::remove_point (ControlPoint& cp)
@ -109,6 +131,18 @@ AudioRegionGainLine::end_drag (bool with_push, uint32_t final_index)
AutomationLine::end_drag (with_push, final_index); AutomationLine::end_drag (with_push, final_index);
} }
void
AudioRegionGainLine::end_draw_merge ()
{
if (!rv.audio_region()->envelope_active()) {
XMLNode& before = rv.audio_region()->get_state();
rv.audio_region()->set_envelope_active(true);
trackview.session()->add_command(new MementoCommand<AudioRegion>(*(rv.audio_region().get()), &before, &rv.audio_region()->get_state()));
}
AutomationLine::end_draw_merge ();
}
void void
AudioRegionGainLine::region_changed (const PropertyChange& what_changed) AudioRegionGainLine::region_changed (const PropertyChange& what_changed)
{ {

View File

@ -45,7 +45,10 @@ public:
Temporal::timepos_t get_origin() const; Temporal::timepos_t get_origin() const;
void start_drag_single (ControlPoint*, double, float); void start_drag_single (ControlPoint*, double, float);
void start_drag_line (uint32_t, uint32_t, float);
void start_drag_multiple (std::list<ControlPoint*>, float, XMLNode*);
void end_drag (bool with_push, uint32_t final_index); void end_drag (bool with_push, uint32_t final_index);
void end_draw_merge ();
void remove_point (ControlPoint&); void remove_point (ControlPoint&);
AudioRegionView& region_view () { return rv; } AudioRegionView& region_view () { return rv; }