virtualize event handling methods for EditingContext

This commit is contained in:
Paul Davis 2024-01-29 14:32:18 -07:00
parent 9dbdf0eb43
commit a2f04a3104
7 changed files with 138 additions and 47 deletions

View file

@ -102,7 +102,6 @@ class CueEditor : public EditingContext
size_t push_canvas_cursor (Gdk::Cursor*); size_t push_canvas_cursor (Gdk::Cursor*);
void pop_canvas_cursor (); void pop_canvas_cursor ();
void reset_x_origin_to_follow_playhead (); void reset_x_origin_to_follow_playhead ();
}; };
#endif /* __gtk_ardour_cue_editor_h__ */ #endif /* __gtk_ardour_cue_editor_h__ */

View file

@ -1593,3 +1593,48 @@ EditingContext::start_local_tempo_map (std::shared_ptr<Temporal::TempoMap>)
/* default is a no-op */ /* default is a no-op */
return Temporal::TempoMap::use (); return Temporal::TempoMap::use ();
} }
bool
EditingContext::typed_event (ArdourCanvas::Item* item, GdkEvent *event, ItemType type)
{
if (!session () || session()->loading () || session()->deletion_in_progress ()) {
return false;
}
gint ret = FALSE;
switch (event->type) {
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
ret = button_press_handler (item, event, type);
break;
case GDK_BUTTON_RELEASE:
ret = button_release_handler (item, event, type);
break;
case GDK_MOTION_NOTIFY:
ret = motion_handler (item, event);
break;
case GDK_ENTER_NOTIFY:
ret = enter_handler (item, event, type);
break;
case GDK_LEAVE_NOTIFY:
ret = leave_handler (item, event, type);
break;
case GDK_KEY_PRESS:
ret = key_press_handler (item, event, type);
break;
case GDK_KEY_RELEASE:
ret = key_release_handler (item, event, type);
break;
default:
break;
}
return ret;
}

View file

@ -321,6 +321,8 @@ public:
virtual ArdourCanvas::ScrollGroup* get_cursor_scroll_group () const = 0; virtual ArdourCanvas::ScrollGroup* get_cursor_scroll_group () const = 0;
virtual bool canvas_playhead_cursor_event (GdkEvent* event, ArdourCanvas::Item*) { return false; } virtual bool canvas_playhead_cursor_event (GdkEvent* event, ArdourCanvas::Item*) { return false; }
bool typed_event (ArdourCanvas::Item*, GdkEvent*, ItemType);
protected: protected:
Glib::RefPtr<Gtk::ActionGroup> _midi_actions; Glib::RefPtr<Gtk::ActionGroup> _midi_actions;
@ -455,6 +457,19 @@ public:
friend class TempoMapScope; friend class TempoMapScope;
virtual std::shared_ptr<Temporal::TempoMap const> start_local_tempo_map (std::shared_ptr<Temporal::TempoMap>); virtual std::shared_ptr<Temporal::TempoMap const> start_local_tempo_map (std::shared_ptr<Temporal::TempoMap>);
virtual void end_local_tempo_map (std::shared_ptr<Temporal::TempoMap const>) { /* no-op by default */ } virtual void end_local_tempo_map (std::shared_ptr<Temporal::TempoMap const>) { /* no-op by default */ }
virtual bool button_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType) = 0;
virtual bool button_press_handler_1 (ArdourCanvas::Item*, GdkEvent*, ItemType) = 0;
virtual bool button_press_handler_2 (ArdourCanvas::Item*, GdkEvent*, ItemType) = 0;
virtual bool button_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType) = 0;
virtual bool button_press_dispatch (GdkEventButton*) = 0;
virtual bool button_release_dispatch (GdkEventButton*) = 0;
virtual bool motion_handler (ArdourCanvas::Item*, GdkEvent*, bool from_autoscroll = false) = 0;
virtual bool enter_handler (ArdourCanvas::Item*, GdkEvent*, ItemType) = 0;
virtual bool leave_handler (ArdourCanvas::Item*, GdkEvent*, ItemType) = 0;
virtual bool key_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType) = 0;
virtual bool key_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType) = 0;
}; };

View file

@ -1150,12 +1150,10 @@ private:
std::weak_ptr<ARDOUR::Trimmable> _trimmable; std::weak_ptr<ARDOUR::Trimmable> _trimmable;
std::weak_ptr<ARDOUR::Movable> _movable; std::weak_ptr<ARDOUR::Movable> _movable;
bool typed_event (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool button_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType); bool button_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool button_press_handler_1 (ArdourCanvas::Item*, GdkEvent*, ItemType); bool button_press_handler_1 (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool button_press_handler_2 (ArdourCanvas::Item*, GdkEvent*, ItemType); bool button_press_handler_2 (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool button_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType); bool button_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool button_double_click_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool button_press_dispatch (GdkEventButton*); bool button_press_dispatch (GdkEventButton*);
bool button_release_dispatch (GdkEventButton*); bool button_release_dispatch (GdkEventButton*);
bool motion_handler (ArdourCanvas::Item*, GdkEvent*, bool from_autoscroll = false); bool motion_handler (ArdourCanvas::Item*, GdkEvent*, bool from_autoscroll = false);

View file

@ -202,50 +202,6 @@ Editor::track_canvas_motion_notify_event (GdkEventMotion */*event*/)
return false; return false;
} }
bool
Editor::typed_event (ArdourCanvas::Item* item, GdkEvent *event, ItemType type)
{
if (!session () || session()->loading () || session()->deletion_in_progress ()) {
return false;
}
gint ret = FALSE;
switch (event->type) {
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
ret = button_press_handler (item, event, type);
break;
case GDK_BUTTON_RELEASE:
ret = button_release_handler (item, event, type);
break;
case GDK_MOTION_NOTIFY:
ret = motion_handler (item, event);
break;
case GDK_ENTER_NOTIFY:
ret = enter_handler (item, event, type);
break;
case GDK_LEAVE_NOTIFY:
ret = leave_handler (item, event, type);
break;
case GDK_KEY_PRESS:
ret = key_press_handler (item, event, type);
break;
case GDK_KEY_RELEASE:
ret = key_release_handler (item, event, type);
break;
default:
break;
}
return ret;
}
bool bool
Editor::canvas_region_view_event (GdkEvent *event, ArdourCanvas::Item* item, RegionView *rv) Editor::canvas_region_view_event (GdkEvent *event, ArdourCanvas::Item* item, RegionView *rv)
{ {

View file

@ -249,3 +249,69 @@ MidiCueEditor::set_region (std::shared_ptr<ARDOUR::MidiTrack> t, std::shared_ptr
} }
} }
bool
MidiCueEditor::button_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType)
{
return true;
}
bool
MidiCueEditor::button_press_handler_1 (ArdourCanvas::Item*, GdkEvent*, ItemType)
{
return true;
}
bool
MidiCueEditor::button_press_handler_2 (ArdourCanvas::Item*, GdkEvent*, ItemType)
{
return true;
}
bool
MidiCueEditor::button_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType)
{
return true;
}
bool
MidiCueEditor::button_press_dispatch (GdkEventButton*)
{
return true;
}
bool
MidiCueEditor::button_release_dispatch (GdkEventButton*)
{
return true;
}
bool
MidiCueEditor::motion_handler (ArdourCanvas::Item*, GdkEvent*, bool from_autoscroll)
{
return true;
}
bool
MidiCueEditor::enter_handler (ArdourCanvas::Item*, GdkEvent*, ItemType)
{
return true;
}
bool
MidiCueEditor::leave_handler (ArdourCanvas::Item*, GdkEvent*, ItemType)
{
return true;
}
bool
MidiCueEditor::key_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType)
{
return true;
}
bool
MidiCueEditor::key_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType)
{
return true;
}

View file

@ -79,6 +79,18 @@ class MidiCueEditor : public CueEditor
ARDOUR::SnapPref gpref = ARDOUR::SnapToAny_Visual, ARDOUR::SnapPref gpref = ARDOUR::SnapToAny_Visual,
bool ensure_snap = false) const; bool ensure_snap = false) const;
bool button_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool button_press_handler_1 (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool button_press_handler_2 (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool button_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool button_press_dispatch (GdkEventButton*);
bool button_release_dispatch (GdkEventButton*);
bool motion_handler (ArdourCanvas::Item*, GdkEvent*, bool from_autoscroll = false);
bool enter_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool leave_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool key_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool key_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
private: private:
Gtk::Adjustment vertical_adjustment; Gtk::Adjustment vertical_adjustment;
Gtk::Adjustment horizontal_adjustment; Gtk::Adjustment horizontal_adjustment;