diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 815acd3e94..882251e1f6 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -3626,6 +3626,8 @@ TempoTwistDrag::TempoTwistDrag (Editor* e, ArdourCanvas::Item* i) , _grab_qn (0.0) , _grab_tempo (0.0) , _tempo (0) + , _next_tempo (0) + , _drag_valid (true) , before_state (0) { DEBUG_TRACE (DEBUG::Drags, "New TempoTwistDrag\n"); @@ -3638,12 +3640,28 @@ TempoTwistDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) Drag::start_grab (event, cursor); TempoMap& map (_editor->session()->tempo_map()); _tempo = const_cast (&map.tempo_section_at_frame (raw_grab_frame())); - _grab_tempo = Tempo (_tempo->note_types_per_minute(), _tempo->note_type()); - ostringstream sstr; - sstr << "start: " << fixed << setprecision(3) << _tempo->note_types_per_minute() << "\n"; - sstr << "end: " << fixed << setprecision(3) << _tempo->end_note_types_per_minute(); - show_verbose_cursor_text (sstr.str()); + _next_tempo = map.next_tempo_section (_tempo); + if (_next_tempo) { + if (!map.next_tempo_section (_next_tempo)) { + _drag_valid = false; + finished (event, false); + + return; + } + _editor->tempo_curve_selected (_tempo, true); + _editor->tempo_curve_selected (_next_tempo, true); + + ostringstream sstr; + sstr << "start: " << fixed << setprecision(3) << _tempo->note_types_per_minute() << "\n"; + sstr << "end: " << fixed << setprecision(3) << _tempo->end_note_types_per_minute() << "\n"; + sstr << "start: " << fixed << setprecision(3) << _next_tempo->note_types_per_minute(); + show_verbose_cursor_text (sstr.str()); + } else { + _drag_valid = false; + } + + _grab_tempo = Tempo (_tempo->note_types_per_minute(), _tempo->note_type()); } void @@ -3673,6 +3691,11 @@ TempoTwistDrag::setup_pointer_frame_offset () void TempoTwistDrag::motion (GdkEvent* event, bool first_move) { + + if (!_next_tempo || !_drag_valid) { + return; + } + TempoMap& map (_editor->session()->tempo_map()); if (first_move) { @@ -3694,19 +3717,23 @@ TempoTwistDrag::motion (GdkEvent* event, bool first_move) _editor->session()->tempo_map().gui_twist_tempi (_tempo, new_bpm, map.frame_at_quarter_note (_grab_qn), pf); ostringstream sstr; - sstr << "start: " << fixed << setprecision(3) << _tempo->note_types_per_minute(); - sstr << "end: " << fixed << setprecision(3) << _tempo->end_note_types_per_minute(); + sstr << "start: " << fixed << setprecision(3) << _tempo->note_types_per_minute() << "\n"; + sstr << "end: " << fixed << setprecision(3) << _tempo->end_note_types_per_minute() << "\n"; + sstr << "start: " << fixed << setprecision(3) << _next_tempo->note_types_per_minute(); show_verbose_cursor_text (sstr.str()); } void TempoTwistDrag::finished (GdkEvent* event, bool movement_occurred) { - if (!movement_occurred) { + TempoMap& map (_editor->session()->tempo_map()); + + if (!movement_occurred || !_drag_valid) { return; } - TempoMap& map (_editor->session()->tempo_map()); + _editor->tempo_curve_selected (_tempo, false); + _editor->tempo_curve_selected (_next_tempo, false); XMLNode &after = map.get_state(); _editor->session()->add_command(new MementoCommand(map, before_state, &after)); diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index d190c54424..bc39220f65 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -849,6 +849,8 @@ private: double _grab_qn; ARDOUR::Tempo _grab_tempo; ARDOUR::TempoSection* _tempo; + ARDOUR::TempoSection* _next_tempo; + bool _drag_valid; XMLNode* before_state; }; diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 872912e6de..008f609474 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -737,8 +737,8 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier) && !ArdourKeyboard::indicates_constraint (event->button.state)) { _drags->set (new CursorDrag (this, *playhead_cursor, false), event); - } else if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier) - && Keyboard::modifier_state_contains (event->button.state, Keyboard::SecondaryModifier)) { + } else if (ArdourKeyboard::indicates_constraint (event->button.state) + && Keyboard::modifier_state_contains (event->button.state, Keyboard::PrimaryModifier)) { _drags->set (new TempoTwistDrag (this, item), event); } else if (ArdourKeyboard::indicates_constraint (event->button.state)) { _drags->set (new BBTRulerDrag (this, item), event); diff --git a/gtk2_ardour/tempo_curve.cc b/gtk2_ardour/tempo_curve.cc index eb187139db..c43e91c9ac 100644 --- a/gtk2_ardour/tempo_curve.cc +++ b/gtk2_ardour/tempo_curve.cc @@ -175,7 +175,7 @@ void TempoCurve::set_color_rgba (uint32_t c) { _color = c; - _curve->set_fill_color (UIConfiguration::instance().color_mod (c, "selection rect")); + _curve->set_fill_color (UIConfiguration::instance().color_mod (_color, "selection rect")); _curve->set_outline_color (_color); }