offset linked regions to compensate for negative start after trim drag.
- should fix 7105
This commit is contained in:
parent
645441d093
commit
e8b5b4fcf3
@ -4225,10 +4225,7 @@ MidiRegionView::trim_front_starting ()
|
||||
void
|
||||
MidiRegionView::trim_front_ending ()
|
||||
{
|
||||
if (_region->start() < 0) {
|
||||
/* Trim drag made start time -ve; fix this */
|
||||
midi_region()->fix_negative_start ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -463,6 +463,7 @@ private:
|
||||
|
||||
/** connection used to connect to model's ContentChanged signal */
|
||||
PBD::ScopedConnection content_connection;
|
||||
PBD::ScopedConnection content_shift_connection;
|
||||
|
||||
NoteBase* find_canvas_note (boost::shared_ptr<NoteType>);
|
||||
NoteBase* find_canvas_note (Evoral::event_id_t id);
|
||||
|
@ -275,6 +275,7 @@ public:
|
||||
int set_state(const XMLNode&) { return 0; }
|
||||
|
||||
PBD::Signal0<void> ContentsChanged;
|
||||
PBD::Signal1<void, double> ContentsShifted;
|
||||
|
||||
boost::shared_ptr<const MidiSource> midi_source ();
|
||||
void set_midi_source (boost::shared_ptr<MidiSource>);
|
||||
|
@ -153,6 +153,7 @@ class LIBARDOUR_API MidiRegion : public Region
|
||||
void update_length_beats (const int32_t sub_num);
|
||||
|
||||
void model_changed ();
|
||||
void model_shifted (double qn_distance);
|
||||
void model_automation_state_changed (Evoral::Parameter const &);
|
||||
|
||||
void set_start_beats_from_start_frames ();
|
||||
@ -160,8 +161,10 @@ class LIBARDOUR_API MidiRegion : public Region
|
||||
|
||||
std::set<Evoral::Parameter> _filtered_parameters; ///< parameters that we ask our source not to return when reading
|
||||
PBD::ScopedConnection _model_connection;
|
||||
PBD::ScopedConnection _model_shift_connection;
|
||||
PBD::ScopedConnection _source_connection;
|
||||
PBD::ScopedConnection _model_contents_connection;
|
||||
bool _ignore_shift;
|
||||
};
|
||||
|
||||
} /* namespace ARDOUR */
|
||||
|
@ -1979,6 +1979,8 @@ MidiModel::insert_silence_at_start (TimeType t)
|
||||
|
||||
apply_command_as_subcommand (s->session(), c);
|
||||
}
|
||||
|
||||
ContentsShifted (t.to_double());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -80,6 +80,7 @@ MidiRegion::MidiRegion (const SourceList& srcs)
|
||||
: Region (srcs)
|
||||
, _start_beats (Properties::start_beats, 0.0)
|
||||
, _length_beats (Properties::length_beats, midi_source(0)->length_beats().to_double())
|
||||
, _ignore_shift (false)
|
||||
{
|
||||
register_properties ();
|
||||
midi_source(0)->ModelChanged.connect_same_thread (_source_connection, boost::bind (&MidiRegion::model_changed, this));
|
||||
@ -92,6 +93,7 @@ MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other)
|
||||
: Region (other)
|
||||
, _start_beats (Properties::start_beats, other->_start_beats)
|
||||
, _length_beats (Properties::length_beats, other->_length_beats)
|
||||
, _ignore_shift (false)
|
||||
{
|
||||
//update_length_beats ();
|
||||
register_properties ();
|
||||
@ -585,6 +587,24 @@ MidiRegion::model_changed ()
|
||||
midi_source()->AutomationStateChanged.connect_same_thread (
|
||||
_model_connection, boost::bind (&MidiRegion::model_automation_state_changed, this, _1)
|
||||
);
|
||||
|
||||
model()->ContentsShifted.connect_same_thread (_model_shift_connection, boost::bind (&MidiRegion::model_shifted, this, _1));
|
||||
}
|
||||
void
|
||||
MidiRegion::model_shifted (double qn_distance)
|
||||
{
|
||||
if (!model()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_ignore_shift) {
|
||||
_start_beats += qn_distance;
|
||||
framepos_t const new_start = _session.tempo_map().frames_between_quarter_notes (_quarter_note - _start_beats, _quarter_note);
|
||||
_start = new_start;
|
||||
send_change (Properties::start);
|
||||
} else {
|
||||
_ignore_shift = false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -620,7 +640,10 @@ MidiRegion::fix_negative_start ()
|
||||
{
|
||||
BeatsFramesConverter c (_session.tempo_map(), _position);
|
||||
|
||||
model()->insert_silence_at_start (c.from (-_start));
|
||||
_ignore_shift = true;
|
||||
|
||||
model()->insert_silence_at_start (Evoral::Beats (- _start_beats));
|
||||
|
||||
_start = 0;
|
||||
_start_beats = 0.0;
|
||||
}
|
||||
@ -629,6 +652,11 @@ void
|
||||
MidiRegion::set_start_internal (framecnt_t s, const int32_t sub_num)
|
||||
{
|
||||
Region::set_start_internal (s, sub_num);
|
||||
|
||||
if (_start_beats < 0.0) {
|
||||
fix_negative_start();
|
||||
}
|
||||
|
||||
set_start_beats_from_start_frames ();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user