13
0

refactor end-of-rb-selection for EditingContext

Whhat the main editor and the cue editor do with a click varies significantly
This commit is contained in:
Paul Davis 2024-10-08 11:54:43 -06:00
parent db30a7d040
commit e6c0fcf98f
6 changed files with 39 additions and 20 deletions

View File

@ -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 &);

View File

@ -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;
};

View File

@ -5306,27 +5306,9 @@ RubberbandSelectDrag::finished (GdkEvent* event, bool movement_occurred)
do_select_things (event, false);
} else {
Editor* editor = dynamic_cast<Editor*> (&editing_context);
assert (editor);
/* just a click */
bool do_deselect = true;
MidiTimeAxisView* mtv;
AutomationTimeAxisView* atv;
if ((mtv = dynamic_cast<MidiTimeAxisView*> (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<AutomationTimeAxisView*> (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.

View File

@ -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<MidiTimeAxisView*> (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<AutomationTimeAxisView*> (clicked_axisview)) != 0) {
atv->add_automation_event (event, where, event->button.y, false);
do_deselect = false;
}
return do_deselect;
}

View File

@ -1652,3 +1652,9 @@ MidiCueEditor::selectable_owners()
return std::list<SelectableOwner*> ();
}
bool
MidiCueEditor::rb_click (GdkEvent*, timepos_t const &)
{
return false;
}

View File

@ -100,6 +100,8 @@ class MidiCueEditor : public CueEditor
std::list<SelectableOwner*> 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;