diff --git a/gtk2_ardour/editing_context.h b/gtk2_ardour/editing_context.h index 6487ca6367..5202561b53 100644 --- a/gtk2_ardour/editing_context.h +++ b/gtk2_ardour/editing_context.h @@ -421,6 +421,8 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider */ void redo (uint32_t n = 1) { do_redo (n); } + virtual bool rb_click (GdkEvent*, Temporal::timepos_t const &) = 0; + virtual void history_changed() = 0; static void update_undo_redo_actions (PBD::UndoHistory const &); diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 599e9fb3d0..26293a3ef6 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -508,6 +508,8 @@ public: void remove_region_marker (ARDOUR::CueMarker&); void make_region_markers_global (bool as_cd_markers); + bool rb_click (GdkEvent*, Temporal::timepos_t const &); + protected: void map_transport_state (); void map_position_change (samplepos_t); @@ -2338,4 +2340,3 @@ private: friend class EditorRoutes; friend class RhythmFerret; }; - diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 5d78541e62..570efaee97 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -5306,27 +5306,9 @@ RubberbandSelectDrag::finished (GdkEvent* event, bool movement_occurred) do_select_things (event, false); } else { - Editor* editor = dynamic_cast (&editing_context); - assert (editor); - /* just a click */ - bool do_deselect = true; - MidiTimeAxisView* mtv; - AutomationTimeAxisView* atv; - - if ((mtv = dynamic_cast (editor->clicked_axisview)) != 0) { - /* MIDI track */ - if (editing_context.get_selection().empty () && editing_context.current_mouse_mode() == MouseDraw) { - /* nothing selected */ - add_midi_region (mtv, true); - do_deselect = false; - } - } else if ((atv = dynamic_cast (editor->clicked_axisview)) != 0) { - timepos_t where = grab_time (); - atv->add_automation_event (event, where, event->button.y, false); - do_deselect = false; - } + bool do_deselect = editing_context.rb_click (event, grab_time()); /* do not deselect if Primary or Tertiary (toggle-select or * extend-select are pressed. diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index def211c310..700f2322d3 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -2591,3 +2591,29 @@ Editor::choose_mapping_drag (ArdourCanvas::Item* item, GdkEvent* event) abort_tempo_mapping (); /* NOTREACHED */ } } + +bool +Editor::rb_click (GdkEvent* event, timepos_t const & where) +{ + bool do_deselect = true; + MidiTimeAxisView* mtv; + AutomationTimeAxisView* atv; + + if ((mtv = dynamic_cast (clicked_axisview)) != 0) { + /* MIDI track */ + if (get_selection().empty () && current_mouse_mode() == MouseDraw) { + + /* nothing selected */ + + const timepos_t pos (where.beats ()); + const timecnt_t len = pos.distance (max (timepos_t::zero (Temporal::BeatTime), timepos_t (pos.beats () + Beats (1, 0)))); + mtv->add_region (pos, len, true); + do_deselect = false; + } + } else if ((atv = dynamic_cast (clicked_axisview)) != 0) { + atv->add_automation_event (event, where, event->button.y, false); + do_deselect = false; + } + + return do_deselect; +} diff --git a/gtk2_ardour/midi_cue_editor.cc b/gtk2_ardour/midi_cue_editor.cc index 0cb888097d..f0c0c73264 100644 --- a/gtk2_ardour/midi_cue_editor.cc +++ b/gtk2_ardour/midi_cue_editor.cc @@ -1652,3 +1652,9 @@ MidiCueEditor::selectable_owners() return std::list (); } + +bool +MidiCueEditor::rb_click (GdkEvent*, timepos_t const &) +{ + return false; +} diff --git a/gtk2_ardour/midi_cue_editor.h b/gtk2_ardour/midi_cue_editor.h index b09b9d3c88..0f8b6006d0 100644 --- a/gtk2_ardour/midi_cue_editor.h +++ b/gtk2_ardour/midi_cue_editor.h @@ -100,6 +100,8 @@ class MidiCueEditor : public CueEditor std::list selectable_owners(); + bool rb_click (GdkEvent*, Temporal::timepos_t const &); + Gdk::Cursor* which_track_cursor () const; Gdk::Cursor* which_mode_cursor () const; Gdk::Cursor* which_trim_cursor (bool left_side) const;