From 35022caf4f799f3e8b101fb99c111879f873d26a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 18 May 2021 22:24:56 +0200 Subject: [PATCH] Tweak record-time axis name edit #8712 This allow to use the entry context menu, and also cancels edit when clicking outside of the entry --- gtk2_ardour/track_record_axis.cc | 35 +++++++++++++++++++++++++++++++- gtk2_ardour/track_record_axis.h | 4 ++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/track_record_axis.cc b/gtk2_ardour/track_record_axis.cc index a93506c854..f7c8477051 100644 --- a/gtk2_ardour/track_record_axis.cc +++ b/gtk2_ardour/track_record_axis.cc @@ -48,6 +48,7 @@ #include "editor_cursors.h" #include "group_tabs.h" #include "gui_thread.h" +#include "keyboard.h" #include "level_meter.h" #include "meter_patterns.h" #include "public_editor.h" @@ -83,6 +84,7 @@ TrackRecordAxis::TrackRecordAxis (Session* s, boost::shared_ptr r , _clear_meters (true) , _route_ops_menu (0) , _renaming (false) + , _nameentry_ctx (false) , _input_button (true) , _playlist_button (S_("RTAV|P")) , _name_frame (ArdourWidgets::Frame::Horizontal, true) @@ -532,7 +534,10 @@ TrackRecordAxis::start_rename () _entry_connections.push_back (_nameentry.signal_activate().connect (sigc::mem_fun (*this, &TrackRecordAxis::entry_activated))); _entry_connections.push_back (_nameentry.signal_key_press_event().connect (sigc::mem_fun (*this, &TrackRecordAxis::entry_key_press), false)); _entry_connections.push_back (_nameentry.signal_key_release_event().connect (sigc::mem_fun (*this, &TrackRecordAxis::entry_key_release), false)); + _entry_connections.push_back (_nameentry.signal_button_press_event ().connect (sigc::mem_fun (*this, &TrackRecordAxis::entry_button_press), false)); + _entry_connections.push_back (_nameentry.signal_focus_in_event ().connect (sigc::mem_fun (*this, &TrackRecordAxis::entry_focus_in))); _entry_connections.push_back (_nameentry.signal_focus_out_event ().connect (sigc::mem_fun (*this, &TrackRecordAxis::entry_focus_out))); + _entry_connections.push_back (_nameentry.signal_populate_popup ().connect (sigc::mem_fun (*this, &TrackRecordAxis::entry_populate_popup))); return true; } @@ -570,13 +575,41 @@ TrackRecordAxis::entry_activated () end_rename (false); } +void +TrackRecordAxis::entry_populate_popup (Gtk::Menu*) +{ + _nameentry_ctx = true; +} + +bool +TrackRecordAxis::entry_focus_in (GdkEventFocus*) +{ + _nameentry_ctx = false; + return false; +} + bool TrackRecordAxis::entry_focus_out (GdkEventFocus*) { - end_rename (false); + if (!_nameentry_ctx) { + end_rename (false); + } return false; } +bool +TrackRecordAxis::entry_button_press (GdkEventButton* ev) +{ + if (Keyboard::is_context_menu_event (ev)) { + return false; + } else if (Gtkmm2ext::event_inside_widget_window (_namebox, (GdkEvent*) ev)) { + return false; + } else { + end_rename (false); + return false; + } +} + bool TrackRecordAxis::entry_key_press (GdkEventKey* ev) { diff --git a/gtk2_ardour/track_record_axis.h b/gtk2_ardour/track_record_axis.h index 424312c835..8073fc3646 100644 --- a/gtk2_ardour/track_record_axis.h +++ b/gtk2_ardour/track_record_axis.h @@ -116,9 +116,12 @@ private: void end_rename (bool); void entry_changed (); void entry_activated (); + bool entry_focus_in (GdkEventFocus*); bool entry_focus_out (GdkEventFocus*); bool entry_key_press (GdkEventKey*); bool entry_key_release (GdkEventKey*); + bool entry_button_press (GdkEventButton*); + void entry_populate_popup (Gtk::Menu*); void disconnect_entry_signals (); /* RouteUI */ @@ -134,6 +137,7 @@ private: bool _renaming; Gtk::EventBox _namebox; Gtk::Entry _nameentry; + bool _nameentry_ctx; LevelMeterVBox* _level_meter; IOButton _input_button;