Use key bindings for region property (Fx) box

This is required to allow to delete RegionFX plugins
when the region-editor is shown in the main window, rather
than its own window.

Otherwise the Editor would handle delete/backspace and
instead remove the region.
This commit is contained in:
Robin Gareus 2024-11-23 10:53:10 +01:00
parent 23ba0f8338
commit 9f6d3baa93
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
5 changed files with 73 additions and 15 deletions

View file

@ -64,6 +64,10 @@ using namespace PBD;
using namespace std; using namespace std;
using namespace Gtkmm2ext; using namespace Gtkmm2ext;
Glib::RefPtr<Gtk::ActionGroup> RegionEditor::RegionFxBox::rfx_box_actions;
Gtkmm2ext::Bindings* RegionEditor::RegionFxBox::bindings = 0;
RegionEditor::RegionFxBox* RegionEditor::RegionFxBox::current_rfx_box = 0;
RegionEditor::RegionEditor (Session* s, RegionView* rv) RegionEditor::RegionEditor (Session* s, RegionView* rv)
: SessionHandlePtr (s) : SessionHandlePtr (s)
, _table (9, 3) , _table (9, 3)
@ -512,12 +516,41 @@ drag_targets ()
return tmp; return tmp;
} }
void
RegionEditor::RegionFxBox::load_bindings ()
{
bindings = Bindings::get_bindings (X_("RegionFx Box"));
}
void
RegionEditor::RegionFxBox::register_actions ()
{
load_bindings ();
rfx_box_actions = ActionManager::create_action_group (bindings, X_("RegionFxMenu"));
ActionManager::register_action (rfx_box_actions, X_("delete"), _("Delete"), sigc::ptr_fun (RegionEditor::RegionFxBox::static_delete));
ActionManager::register_action (rfx_box_actions, X_("backspace"), _("Delete"), sigc::ptr_fun (RegionEditor::RegionFxBox::static_delete));
}
void
RegionEditor::RegionFxBox::static_delete ()
{
if (current_rfx_box) {
current_rfx_box->delete_selected ();
}
}
RegionEditor::RegionFxBox::RegionFxBox (std::shared_ptr<ARDOUR::Region> r) RegionEditor::RegionFxBox::RegionFxBox (std::shared_ptr<ARDOUR::Region> r)
: _region (r) : _region (r)
, _display (drop_targets (), Gdk::ACTION_COPY | Gdk::ACTION_MOVE) , _display (drop_targets (), Gdk::ACTION_COPY | Gdk::ACTION_MOVE)
, _no_redisplay (false) , _no_redisplay (false)
, _placement (-1) , _placement (-1)
{ {
if (!rfx_box_actions) {
register_actions ();
}
_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); _scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
_scroller.set_name ("ProcessorScroller"); _scroller.set_name ("ProcessorScroller");
_scroller.add (_display); _scroller.add (_display);
@ -526,6 +559,7 @@ RegionEditor::RegionFxBox::RegionFxBox (std::shared_ptr<ARDOUR::Region> r)
_display.set_can_focus (); _display.set_can_focus ();
_display.set_name ("ProcessorList"); _display.set_name ("ProcessorList");
_display.set_data ("regionfxbox", this); _display.set_data ("regionfxbox", this);
_display.set_data ("ardour-bindings", bindings);
_display.set_size_request (104, -1); // TODO UI scale _display.set_size_request (104, -1); // TODO UI scale
_display.set_spacing (0); _display.set_spacing (0);
@ -537,7 +571,8 @@ RegionEditor::RegionFxBox::RegionFxBox (std::shared_ptr<ARDOUR::Region> r)
_display.DropFromExternal.connect (sigc::mem_fun (*this, &RegionFxBox::plugin_drop)); _display.DropFromExternal.connect (sigc::mem_fun (*this, &RegionFxBox::plugin_drop));
_display.DragRefuse.connect (sigc::mem_fun (*this, &RegionFxBox::drag_refuse)); _display.DragRefuse.connect (sigc::mem_fun (*this, &RegionFxBox::drag_refuse));
_display.signal_key_press_event ().connect (sigc::mem_fun (*this, &RegionFxBox::on_key_press), false); _display.signal_enter_notify_event().connect (sigc::mem_fun(*this, &RegionFxBox::enter_notify), false);
_display.signal_leave_notify_event().connect (sigc::mem_fun(*this, &RegionFxBox::leave_notify), false);
screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun (*this, &RegionFxBox::update_controls)); screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun (*this, &RegionFxBox::update_controls));
@ -719,21 +754,27 @@ RegionEditor::RegionFxBox::fxe_button_release_event (GdkEventButton* ev, RegionF
return false; return false;
} }
bool void
RegionEditor::RegionFxBox::on_key_press (GdkEventKey* ev) RegionEditor::RegionFxBox::delete_selected ()
{ {
switch (ev->keyval) {
case GDK_KEY_Delete:
break;
case GDK_KEY_BackSpace:
break;
default:
return false;
}
for (auto const& i : _display.selection (true)) { for (auto const& i : _display.selection (true)) {
queue_delete_region_fx (std::weak_ptr<RegionFxPlugin> (i->region_fx_plugin ())); queue_delete_region_fx (std::weak_ptr<RegionFxPlugin> (i->region_fx_plugin ()));
} }
return true; }
bool
RegionEditor::RegionFxBox::enter_notify (GdkEventCrossing* ev)
{
_display.grab_focus ();
current_rfx_box = this;
return false;
}
bool
RegionEditor::RegionFxBox::leave_notify (GdkEventCrossing* ev)
{
current_rfx_box = 0;
return false;
} }
void void

View file

@ -38,6 +38,7 @@
#include <gtkmm/listviewtext.h> #include <gtkmm/listviewtext.h>
#include <gtkmm/scrolledwindow.h> #include <gtkmm/scrolledwindow.h>
#include "gtkmm2ext/bindings.h"
#include "gtkmm2ext/dndtreeview.h" #include "gtkmm2ext/dndtreeview.h"
#include "gtkmm2ext/dndvbox.h" #include "gtkmm2ext/dndvbox.h"
@ -104,14 +105,24 @@ private:
void redisplay_plugins (); void redisplay_plugins ();
private: private:
static void register_actions();
static void load_bindings ();
static void static_delete ();
static Glib::RefPtr<Gtk::ActionGroup> rfx_box_actions;
static Gtkmm2ext::Bindings* bindings;
static RegionFxBox* current_rfx_box;
void add_fx_to_display (std::weak_ptr<ARDOUR::RegionFxPlugin>); void add_fx_to_display (std::weak_ptr<ARDOUR::RegionFxPlugin>);
void show_plugin_gui (std::weak_ptr<ARDOUR::RegionFxPlugin>, bool custom_ui = true); void show_plugin_gui (std::weak_ptr<ARDOUR::RegionFxPlugin>, bool custom_ui = true);
void queue_delete_region_fx (std::weak_ptr<ARDOUR::RegionFxPlugin>); void queue_delete_region_fx (std::weak_ptr<ARDOUR::RegionFxPlugin>);
bool idle_delete_region_fx (std::weak_ptr<ARDOUR::RegionFxPlugin>); bool idle_delete_region_fx (std::weak_ptr<ARDOUR::RegionFxPlugin>);
void notify_plugin_load_fail (uint32_t cnt = 1); void notify_plugin_load_fail (uint32_t cnt = 1);
bool on_key_press (GdkEventKey*); bool enter_notify (GdkEventCrossing*);
bool leave_notify (GdkEventCrossing*);
void clear_automation (std::weak_ptr<ARDOUR::RegionFxPlugin>); void clear_automation (std::weak_ptr<ARDOUR::RegionFxPlugin>);
void update_controls (); void update_controls ();
void delete_selected ();
/* PluginInterestedObject */ /* PluginInterestedObject */
bool use_plugins (SelectedPlugins const&); bool use_plugins (SelectedPlugins const&);

View file

@ -0,0 +1,6 @@
<Bindings name="RegionFx Box">
<Press>
<Binding key="Delete" action="RegionFxMenu/delete"/>
<Binding key="BackSpace" action="RegionFxMenu/backspace"/>
</Press>
</Bindings>

View file

@ -931,7 +931,7 @@ def build(bld):
for b in [ 'ardour' ] : for b in [ 'ardour' ] :
obj = bld( obj = bld(
target = b + '.keys', target = b + '.keys',
source = [ b + '.keys.in', 'mixer.bindings', 'processor_box.bindings', 'step_editing.bindings', 'monitor.bindings', 'trigger.bindings' ], source = [ b + '.keys.in', 'mixer.bindings', 'processor_box.bindings', 'step_editing.bindings', 'monitor.bindings', 'trigger.bindings', 'regionfx_box.bindings' ],
rule = a_rule rule = a_rule
) )
obj.install_path = bld.env['CONFDIR'] obj.install_path = bld.env['CONFDIR']

View file

@ -337,7 +337,7 @@ if ($make_accelmap) {
# merge in the "fixed" bindings that are not defined by the argument given to this program # merge in the "fixed" bindings that are not defined by the argument given to this program
# this covers things like the step editor, monitor and processor box bindings # this covers things like the step editor, monitor and processor box bindings
foreach $hardcoded_bindings ("mixer.bindings", "step_editing.bindings", "monitor.bindings", "processor_box.bindings", "trigger.bindings", "pianoroll.bindings") { foreach $hardcoded_bindings ("mixer.bindings", "step_editing.bindings", "monitor.bindings", "processor_box.bindings", "trigger.bindings", "pianoroll.bindings", "regionfx_box.bindings") {
$path = File::Spec->catfile (dirname ($ARGV[0]), $hardcoded_bindings); $path = File::Spec->catfile (dirname ($ARGV[0]), $hardcoded_bindings);
open HARDCODED, "<", $path or die $!; open HARDCODED, "<", $path or die $!;
while (<HARDCODED>) { while (<HARDCODED>) {