[Summary]: add possibility of using Tab button to change next (prev) tracks's name from Mixer / MeterBridge

This commit is contained in:
YPozdnyakov 2015-02-23 11:01:11 +02:00
parent 10160029ff
commit e33f90118b
4 changed files with 54 additions and 3 deletions

View file

@ -92,6 +92,8 @@ MixerBridgeView::MixerBridgeView (const std::string& mixer_bridge_script_name, c
signal_configure_event().connect (sigc::mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
Route::SyncOrderKeys.connect (*this, invalidator (*this), boost::bind (&MixerBridgeView::sync_order_keys, this), gui_context());
MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&MixerBridgeView::remove_strip, this, _1), gui_context());
MixerStrip::EndStripNameEdit.connect (*this, invalidator (*this), boost::bind (&MixerBridgeView::begin_strip_name_edit, this, _1, _2), gui_context());
if (dynamic_cast <WavesGrid*> (&_mixer_strips_home)) {
_mixer_strips_home.get_parent()->signal_size_allocate().connect (sigc::mem_fun(*this, &MixerBridgeView::parent_on_size_allocate));
@ -200,6 +202,8 @@ MixerBridgeView::add_strips (RouteList& routes)
bool set_gain_slider_visible = Config->get_output_auto_connect() & AutoConnectMaster;
strip->gain_slider_set_visible (set_gain_slider_visible);
//strip->EndStripNameEdit.connect (*this, invalidator (*this), (sigc::bind (sigc::mem_fun(*this, &MixerBridgeView::begin_strip_name_edit), strip)), gui_context());
_strips [route] = strip;
strip->show();
}
@ -500,3 +504,31 @@ void MixerBridgeView::select_none ()
{
/* does nothing in Tracks */
}
void
MixerBridgeView::begin_strip_name_edit (MixerStrip::TabToStrip edit_next, const MixerStrip* cur_strip)
{
std::vector<Gtk::Widget*> strips = _mixer_strips_home.get_children();
if (edit_next == MixerStrip::TabToNext) {
for (std::vector<Gtk::Widget*>::iterator it = strips.begin (); it != strips.end (); ++it) {
if (*it == cur_strip) {
if (++it != strips.end ()) {
MixerStrip* strip = dynamic_cast<MixerStrip*> (*it);
strip->begin_name_edit ();
}
break;
}
}
} else { // MixerStrip::TabToPrev
for (std::vector<Gtk::Widget*>::iterator it = strips.begin (); it != strips.end (); ++it) {
if (*it == cur_strip) {
if (it != strips.begin ()) {
--it;
MixerStrip* strip = dynamic_cast<MixerStrip*> (*it);
strip->begin_name_edit ();
}
break;
}
}
}
}

View file

@ -79,6 +79,7 @@ class MixerBridgeView :
void follow_editor_selection ();
bool strip_button_release_event (GdkEventButton*, MixerStrip*);
void parent_on_size_allocate (Gtk::Allocation&);
void begin_strip_name_edit (MixerStrip::TabToStrip, const MixerStrip*);
MixerStrip* strip_by_route (boost::shared_ptr<ARDOUR::Route> route);
MixerStrip* strip_under_pointer ();

View file

@ -85,6 +85,7 @@ using namespace ArdourMeter;
int MixerStrip::scrollbar_height = 0;
PBD::Signal1<void,MixerStrip*> MixerStrip::CatchDeletion;
PBD::Signal2<void,MixerStrip::TabToStrip,const MixerStrip*> MixerStrip::EndStripNameEdit;
MixerStrip::MixerStrip (Session* sess, const std::string& layout_script_file, size_t max_name_size)
: AxisView(sess)
@ -301,7 +302,7 @@ MixerStrip::controls_ebox_button_press (GdkEventButton* event)
_name_button_home.translate_coordinates (name_button, event->x, event->y, nlx, nly);
Gtk::Allocation a = name_button.get_allocation ();
if (nlx > 0 && nlx < a.get_width() && nly > 0 && nly < a.get_height()) {
begin_name_edit ();
_begin_name_edit ();
return true;
}
}
@ -373,8 +374,9 @@ MixerStrip::name_entry_focus_out (GdkEventFocus*)
return false;
}
void
MixerStrip::begin_name_edit ()
MixerStrip::_begin_name_edit ()
{
if (!_route)
return;
@ -416,6 +418,9 @@ MixerStrip::on_record_state_changed ()
void
MixerStrip::end_name_edit (int response)
{
bool edit_next = false;
bool edit_prev = false;
switch (response) {
case RESPONSE_CANCEL:
break;
@ -424,8 +429,10 @@ MixerStrip::end_name_edit (int response)
break;
case RESPONSE_ACCEPT:
name_entry_changed ();
edit_next = true;
case RESPONSE_APPLY:
name_entry_changed ();
edit_prev = true;
}
// _name_entry's text and _route->name must be synchronized
@ -435,6 +442,12 @@ MixerStrip::end_name_edit (int response)
name_button.show ();
_name_entry.hide ();
_name_entry_eventbox.hide ();
if (edit_next) {
EndStripNameEdit (TabToNext, this); //EMIT SIGNAL
}
else if (edit_prev) {
EndStripNameEdit (TabToPrev, this); //EMIT SIGNAL
}
}
void

View file

@ -77,6 +77,7 @@ class ArdourWindow;
class MixerStrip : public RouteUI
{
public:
enum TabToStrip { TabToPrev, TabToNext };
MixerStrip (ARDOUR::Session*, boost::shared_ptr<ARDOUR::Route>, const std::string& layout_script_file, size_t max_name_size = 0);
MixerStrip (ARDOUR::Session*, const std::string& layout_script_file, size_t max_name_size = 0);
~MixerStrip ();
@ -112,6 +113,9 @@ class MixerStrip : public RouteUI
PBD::Signal1<void, boost::weak_ptr<ARDOUR::Delivery> > DeliveryChanged;
static PBD::Signal1<void,MixerStrip*> CatchDeletion;
// name of next(true) or prev(false) MixerStrip should be changed
static PBD::Signal2<void, MixerStrip::TabToStrip, const MixerStrip*> EndStripNameEdit;
std::string state_id() const;
@ -129,6 +133,7 @@ class MixerStrip : public RouteUI
void route_rec_enable_changed();
void route_color_changed ();
void begin_name_edit () { _begin_name_edit(); }
protected:
void set_packed (bool yn);
@ -176,7 +181,7 @@ class MixerStrip : public RouteUI
Gtk::Entry& _name_entry;
Gtk::EventBox& _name_entry_eventbox;
void begin_name_edit ();
void _begin_name_edit ();
void end_name_edit (int);
bool name_entry_key_release (GdkEventKey *ev);