attach bindings to boxes in livetrax view, and steal focus appropriately

This commit is contained in:
Paul Davis 2024-03-25 18:36:11 -06:00
parent 3a0f41a28a
commit 5ec2c6d691
9 changed files with 53 additions and 18 deletions

View File

@ -399,6 +399,7 @@ ARDOUR_UI::livetrax_setup_windows ()
Gtk::VBox* vb;
Gtk::HBox* hb;
ArdourButton::Element elements (ArdourButton::Element (ArdourButton::Text|ArdourButton::VectorIcon));
Gtkmm2ext::Bindings* bindings;
livetrax_top_bar.set_spacing (12);
livetrax_top_bar.set_border_width (12);
@ -474,7 +475,7 @@ ARDOUR_UI::livetrax_setup_windows ()
livetrax_edit_vscrollbar->show ();
hb->pack_start (editor->contents(), true, true);
hb->pack_start (*livetrax_edit_vscrollbar, false, false);
vb = manage (new Gtk::VBox);
livetrax_edit_hscrollbar = manage (new Gtk::HScrollbar (editor->horizontal_adjustment));
livetrax_edit_hscrollbar->show ();
@ -499,6 +500,11 @@ ARDOUR_UI::livetrax_setup_windows ()
setup_tooltips ();
build_menu_bar ();
bindings = Bindings::get_bindings (X_("Editor"));
livetrax_editor_bar.set_data ("ardour-bindings", bindings);
bindings = Bindings::get_bindings (X_("Mixer"));
livetrax_mixer_bar.set_data ("ardour-bindings", bindings);
// setup_tooltips ();
_main_window.signal_delete_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::main_window_delete_event));

View File

@ -143,7 +143,7 @@ ARDOUR_UI::key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey
}
}
DEBUG_TRACE (DEBUG::Accelerators, string_compose ("Win = %1 [title = %9] focus = %7 (%8) Key event: code = %2 [%10] state = %3 special handling ? %4 magic widget focus ? %5 focus widget %6 named %7 mods ? %8\n",
DEBUG_TRACE (DEBUG::Accelerators, string_compose ("Win = %1 [title = %9] focus = %7 (mods %8) Key event: code = %2 [%10] state = %3 special handling ? %4 magic widget focus ? %5 focus widget %6 named %7 mods ? %8\n",
win,
ev->keyval,
Gtkmm2ext::show_gdk_event_state (ev->state),

View File

@ -1316,7 +1316,7 @@ private:
void register_actions ();
void register_region_actions ();
void register_midi_actions (Gtkmm2ext::Bindings*);
void register_midi_actions ();
void load_bindings ();

View File

@ -790,7 +790,7 @@ Editor::register_actions ()
}
void
Editor::register_midi_actions (Bindings* midi_bindings)
Editor::register_midi_actions ()
{
_midi_actions = ActionManager::create_action_group (midi_bindings, X_("Notes"));
@ -985,7 +985,9 @@ void
Editor::load_bindings ()
{
bindings = Bindings::get_bindings (X_("Editor"));
global_hpacker.set_data ("ardour-bindings", bindings);
midi_bindings = Bindings::get_bindings (X_("MIDI"));
register_midi_actions ();
/* This set of bindings may expand in the future to include things
* other than MIDI editing, but for now this is all we've got as far as
@ -993,11 +995,11 @@ Editor::load_bindings ()
* the keys may overlap.
*/
Bindings* midi_bindings = Bindings::get_bindings (X_("MIDI"));
register_midi_actions (midi_bindings);
_track_canvas_viewport->canvas()->set_data ("ardour-bindings", midi_bindings);
if (!Profile->get_livetrax()) {
global_hpacker.set_data ("ardour-bindings", bindings);
_track_canvas_viewport->canvas()->set_data ("ardour-bindings", midi_bindings);
}
}
void

View File

@ -975,7 +975,7 @@ Editor::entered_track_canvas (GdkEventCrossing* ev)
if (!was_within) {
if (internal_editing()) {
if (internal_editing() || Profile->get_livetrax()) {
/* ensure that key events go here because there are
internal editing bindings associated only with the
canvas. if the focus is elsewhere, we cannot find them.

View File

@ -453,7 +453,7 @@ MixerStrip::~MixerStrip ()
void
MixerStrip::vca_assign (std::shared_ptr<ARDOUR::VCA> vca)
{
std::shared_ptr<Slavable> sl = std::dynamic_pointer_cast<Slavable> ( route() );
std::shared_ptr<Slavable> sl = std::dynamic_pointer_cast<Slavable> (route());
if (sl)
sl->assign(vca);
}
@ -461,14 +461,19 @@ MixerStrip::vca_assign (std::shared_ptr<ARDOUR::VCA> vca)
void
MixerStrip::vca_unassign (std::shared_ptr<ARDOUR::VCA> vca)
{
std::shared_ptr<Slavable> sl = std::dynamic_pointer_cast<Slavable> ( route() );
if (sl)
std::shared_ptr<Slavable> sl = std::dynamic_pointer_cast<Slavable> (route());
if (sl) {
sl->unassign(vca);
}
}
bool
MixerStrip::mixer_strip_enter_event (GdkEventCrossing* /*ev*/)
MixerStrip::mixer_strip_enter_event (GdkEventCrossing* ev)
{
if (ev->detail != GDK_NOTIFY_INFERIOR) {
_mixer.steal_focus ();
}
_entered_mixer_strip = this;
return false;
@ -478,7 +483,7 @@ bool
MixerStrip::mixer_strip_leave_event (GdkEventCrossing *ev)
{
//if we have moved outside our strip, but not into a child view, then deselect ourselves
if ( !(ev->detail == GDK_NOTIFY_INFERIOR) ) {
if (ev->detail != GDK_NOTIFY_INFERIOR) {
_entered_mixer_strip= 0;
//clear keyboard focus in the gain display. this is cheesy but fixes a longstanding "bug" where the user starts typing in the gain entry, and leaves it active, thereby prohibiting other keybindings from working

View File

@ -165,6 +165,8 @@ Mixer_UI::Mixer_UI ()
scroller_base.set_name ("MixerWindow");
scroller_base.signal_button_press_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_event));
scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_event));
scroller_base.signal_enter_notify_event ().connect (sigc::mem_fun (*this, &Mixer_UI::scroller_enter), false);
/* set up drag-n-drop */
vector<TargetEntry> target_table;
@ -521,8 +523,17 @@ Mixer_UI::show_window ()
ms->parameter_changed (X_("mixer-element-visibility"));
}
/* force focus into main area */
scroller_base.grab_focus ();
if (!Profile->get_livetrax()) {
/* force focus into main area */
scroller_base.grab_focus ();
}
}
bool
Mixer_UI::scroller_enter (GdkEventCrossing* ev)
{
steal_focus ();
return false;
}
void
@ -4436,3 +4447,11 @@ Mixer_UI::sync_surround_action ()
Glib::RefPtr<Action> surround_export = ActionManager::get_action (X_("Main"), X_("SurroundExport"));
surround_export->set_sensitive (have_sm && _session->vapor_export_barrier ());
}
void
Mixer_UI::steal_focus ()
{
if (Profile->get_livetrax()) {
scroller_base.grab_focus ();
}
}

View File

@ -169,7 +169,7 @@ public:
void toggle_monitor_action (ARDOUR::MonitorChoice monitor_choice, bool group_override = false, bool all = false);
Gtk::ScrolledWindow scroller;
void steal_focus ();
protected:
void set_axis_targets_for_operation ();
@ -181,6 +181,7 @@ private:
Gtk::VBox _content;
Gtk::HBox global_hpacker;
Gtk::VBox global_vpacker;
Gtk::ScrolledWindow scroller;
Gtk::EventBox scroller_base;
Gtk::HBox scroller_hpacker;
Gtk::VBox mixer_scroller_vpacker;
@ -235,6 +236,7 @@ private:
void scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>&, int, int, const Gtk::SelectionData&, guint, guint);
bool strip_scroller_button_event (GdkEventButton*);
bool scroller_enter (GdkEventCrossing*);
void scroll_left ();
void scroll_right ();
void vca_scroll_left ();

View File

@ -600,6 +600,7 @@ public:
PBD::Signal0<void> MouseModeChanged;
Gtkmm2ext::Bindings* bindings;
Gtkmm2ext::Bindings* midi_bindings;
virtual SelectionPropertiesBox& properties_box() const = 0;
Gtk::HBox* mouse_mode_hbox;