13
0

region/source lists: try to allow primary-(cxv) functionality when editing name/tag fields

This commit is contained in:
Paul Davis 2023-06-12 15:34:54 -06:00
parent a8fdf7315b
commit d742e876d1
2 changed files with 28 additions and 2 deletions

View File

@ -38,6 +38,7 @@
#include "ardour/smf_source.h" #include "ardour/smf_source.h"
#include "gtkmm2ext/colors.h" #include "gtkmm2ext/colors.h"
#include "gtkmm2ext/keyboard.h"
#include "gtkmm2ext/treeutils.h" #include "gtkmm2ext/treeutils.h"
#include "gtkmm2ext/utils.h" #include "gtkmm2ext/utils.h"
@ -159,6 +160,7 @@ RegionListBase::add_name_column ()
region_name_cell->property_editable () = true; region_name_cell->property_editable () = true;
region_name_cell->signal_edited ().connect (sigc::mem_fun (*this, &RegionListBase::name_edit)); region_name_cell->signal_edited ().connect (sigc::mem_fun (*this, &RegionListBase::name_edit));
region_name_cell->signal_editing_started ().connect (sigc::mem_fun (*this, &RegionListBase::name_editing_started)); region_name_cell->signal_editing_started ().connect (sigc::mem_fun (*this, &RegionListBase::name_editing_started));
region_name_cell->signal_editing_canceled ().connect (sigc::mem_fun (*this, &RegionListBase::name_editing_canceled));
/* Region Name: color turns red if source is missing. */ /* Region Name: color turns red if source is missing. */
tvc->add_attribute (region_name_cell->property_text (), _columns.name); tvc->add_attribute (region_name_cell->property_text (), _columns.name);
tvc->add_attribute (region_name_cell->property_foreground_gdk (), _columns.color_); tvc->add_attribute (region_name_cell->property_foreground_gdk (), _columns.color_);
@ -176,6 +178,7 @@ RegionListBase::add_tag_column ()
region_tags_cell->property_editable () = true; region_tags_cell->property_editable () = true;
region_tags_cell->signal_edited ().connect (sigc::mem_fun (*this, &RegionListBase::tag_edit)); region_tags_cell->signal_edited ().connect (sigc::mem_fun (*this, &RegionListBase::tag_edit));
region_tags_cell->signal_editing_started ().connect (sigc::mem_fun (*this, &RegionListBase::tag_editing_started)); region_tags_cell->signal_editing_started ().connect (sigc::mem_fun (*this, &RegionListBase::tag_editing_started));
region_tags_cell->signal_editing_canceled ().connect (sigc::mem_fun (*this, &RegionListBase::tag_editing_canceled));
} }
bool bool
@ -218,17 +221,22 @@ RegionListBase::enter_notify (GdkEventCrossing*)
} }
Keyboard::magic_widget_grab_focus (); Keyboard::magic_widget_grab_focus ();
return false; return false;
} }
bool bool
RegionListBase::leave_notify (GdkEventCrossing*) RegionListBase::leave_notify (GdkEventCrossing* ev)
{ {
if (_old_focus) { if (_old_focus) {
_old_focus->grab_focus (); _old_focus->grab_focus ();
_old_focus = 0; _old_focus = 0;
} }
if (ev->detail != GDK_NOTIFY_INFERIOR && ev->detail != GDK_NOTIFY_ANCESTOR) {
Keyboard::magic_widget_drop_focus (); Keyboard::magic_widget_drop_focus ();
}
return false; return false;
} }
@ -774,6 +782,12 @@ RegionListBase::key_press (GdkEventKey* ev)
return false; return false;
} }
void
RegionListBase::name_editing_canceled ()
{
Keyboard::magic_widget_drop_focus ();
}
void void
RegionListBase::name_editing_started (CellEditable* ce, const Glib::ustring& path) RegionListBase::name_editing_started (CellEditable* ce, const Glib::ustring& path)
{ {
@ -792,6 +806,7 @@ RegionListBase::name_editing_started (CellEditable* ce, const Glib::ustring& pat
if (region) { if (region) {
e->set_text (region->name ()); e->set_text (region->name ());
Keyboard::magic_widget_grab_focus ();
} }
} }
} }
@ -814,9 +829,16 @@ RegionListBase::name_edit (const std::string& path, const std::string& new_text)
region->set_name (new_text); region->set_name (new_text);
populate_row_name (region, (*row_iter)); populate_row_name (region, (*row_iter));
Keyboard::magic_widget_drop_focus ();
} }
} }
void
RegionListBase::tag_editing_canceled ()
{
Keyboard::magic_widget_drop_focus ();
}
void void
RegionListBase::tag_editing_started (CellEditable* ce, const Glib::ustring& path) RegionListBase::tag_editing_started (CellEditable* ce, const Glib::ustring& path)
{ {
@ -835,6 +857,7 @@ RegionListBase::tag_editing_started (CellEditable* ce, const Glib::ustring& path
if (region) { if (region) {
e->set_text (region->tags ()); e->set_text (region->tags ());
Keyboard::magic_widget_grab_focus ();
} }
} }
} }
@ -857,6 +880,7 @@ RegionListBase::tag_edit (const std::string& path, const std::string& new_text)
region->set_tags (new_text); region->set_tags (new_text);
populate_row_name (region, (*row_iter)); populate_row_name (region, (*row_iter));
Keyboard::magic_widget_drop_focus ();
} }
} }

View File

@ -171,7 +171,9 @@ protected:
virtual void regions_changed (std::shared_ptr<ARDOUR::RegionList>, PBD::PropertyChange const&); virtual void regions_changed (std::shared_ptr<ARDOUR::RegionList>, PBD::PropertyChange const&);
void name_editing_started (Gtk::CellEditable*, const Glib::ustring&); void name_editing_started (Gtk::CellEditable*, const Glib::ustring&);
void name_editing_canceled ();
void tag_editing_started (Gtk::CellEditable*, const Glib::ustring&); void tag_editing_started (Gtk::CellEditable*, const Glib::ustring&);
void tag_editing_canceled ();
virtual void name_edit (const std::string&, const std::string&); virtual void name_edit (const std::string&, const std::string&);
virtual void tag_edit (const std::string&, const std::string&); virtual void tag_edit (const std::string&, const std::string&);