Allow non-musical snap when dragging bbt ruler.

- probably not what the user wants,
	  unless snapping beats to timecode frames.
This commit is contained in:
nick_m 2016-05-28 06:50:22 +10:00
parent 0d17c21410
commit a924e938aa
3 changed files with 22 additions and 12 deletions

View File

@ -3415,7 +3415,6 @@ TempoMarkerDrag::aborted (bool moved)
BBTRulerDrag::BBTRulerDrag (Editor* e, ArdourCanvas::Item* i)
: Drag (e, i)
, _pulse (0.0)
, _beat (0.0)
, _tempo (0)
, before_state (0)
{
@ -3427,11 +3426,10 @@ void
BBTRulerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
{
Drag::start_grab (event, cursor);
TempoMap& map (_editor->session()->tempo_map());
_tempo = const_cast<TempoSection*> (&map.tempo_section_at_frame (raw_grab_frame()));
ostringstream sstr;
_tempo = const_cast<TempoSection*> (&map.tempo_section_at_frame (raw_grab_frame()));
sstr << "^" << fixed << setprecision(3) << map.tempo_at_frame (adjusted_current_frame (event)).beats_per_minute() << "\n";
sstr << "<" << fixed << setprecision(3) << _tempo->beats_per_minute();
show_verbose_cursor_text (sstr.str());
@ -3444,17 +3442,22 @@ BBTRulerDrag::setup_pointer_frame_offset ()
TempoMap& map (_editor->session()->tempo_map());
const double beat_at_frame = map.beat_at_frame (raw_grab_frame());
const uint32_t divisions = _editor->get_grid_beat_divisions (0);
double beat = 0.0;
if (divisions > 0) {
_beat = floor (beat_at_frame) + (floor (((beat_at_frame - floor (beat_at_frame)) * divisions)) / divisions);
beat = floor (beat_at_frame) + (floor (((beat_at_frame - floor (beat_at_frame)) * divisions)) / divisions);
} else {
/* while it makes some sense for the user to determine the division to 'grab',
grabbing a bar often leads to confusing results wrt the actual tempo section being altered
and the result over steep tempo curves. Use sixteenths.
*/
_beat = floor (beat_at_frame) + (floor (((beat_at_frame - floor (beat_at_frame)) * 4)) / 4);
beat = floor (beat_at_frame) + (floor (((beat_at_frame - floor (beat_at_frame)) * 4)) / 4);
}
_pulse = map.pulse_at_beat (_beat);
_pointer_frame_offset = raw_grab_frame() - map.frame_at_beat (_beat);
_pulse = map.pulse_at_beat (beat);
_pointer_frame_offset = raw_grab_frame() - map.frame_at_pulse (_pulse);
}
void
@ -3468,7 +3471,13 @@ BBTRulerDrag::motion (GdkEvent* event, bool first_move)
_editor->begin_reversible_command (_("dilate tempo"));
}
framepos_t const pf = adjusted_current_frame (event, false);
framepos_t pf;
if (_editor->snap_musical()) {
pf = adjusted_current_frame (event, false);
} else {
pf = adjusted_current_frame (event);
}
if (Keyboard::modifier_state_contains (event->button.state, ArdourKeyboard::constraint_modifier())) {
/* adjust previous tempo to match pointer frame */

View File

@ -767,7 +767,6 @@ public:
private:
double _pulse;
double _beat;
ARDOUR::TempoSection* _tempo;
XMLNode* before_state;
};

View File

@ -2673,14 +2673,16 @@ TempoMap::gui_dilate_tempo (TempoSection* ts, const framepos_t& frame, const fra
constant to constant is straightforward, as the tempo prev to prev_t has constant slope.
*/
double contribution = 0.0;
double start_pulse = prev_t->pulse_at_frame (frame, _frame_rate);
if (next_t && prev_to_prev_t && prev_to_prev_t->type() == TempoSection::Ramp) {
contribution = (prev_t->frame() - prev_to_prev_t->frame()) / (double) (next_t->frame() - prev_to_prev_t->frame());
}
frameoffset_t prev_t_frame_contribution = fr_off - (contribution * (double) fr_off);
double end_pulse = prev_t->pulse_at_frame (end_frame, _frame_rate);
const frameoffset_t prev_t_frame_contribution = fr_off - (contribution * (double) fr_off);
const double start_pulse = prev_t->pulse_at_frame (frame, _frame_rate);
const double end_pulse = prev_t->pulse_at_frame (end_frame, _frame_rate);
double new_bpm;
if (prev_t->type() == TempoSection::Constant || prev_t->c_func() == 0.0) {