code consolidation

This commit is contained in:
Paul Davis 2016-05-18 14:15:39 -04:00
parent 2886b9659b
commit 0b4d9c9d63
2 changed files with 30 additions and 5 deletions

View file

@ -425,17 +425,31 @@ VCAMasterStrip::vca_button_release (GdkEventButton* ev)
bool bool
VCAMasterStrip::vertical_box_press (GdkEventButton* ev) VCAMasterStrip::vertical_box_press (GdkEventButton* ev)
{ {
return name_button_press (ev); if (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
start_name_edit ();
return true;
}
if (Keyboard::is_context_menu_event (ev)) {
if (!context_menu) {
build_context_menu ();
}
context_menu->popup (1, ev->time);
return true;
}
if (ev->button == 1) {
// spill ();
}
return true;
} }
bool bool
VCAMasterStrip::name_button_press (GdkEventButton* ev) VCAMasterStrip::name_button_press (GdkEventButton* ev)
{ {
if (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) { if (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
Gtk::Window* win = dynamic_cast<Gtk::Window*>(get_toplevel()); start_name_edit ();
FloatingTextEntry* fte = new FloatingTextEntry (win, _vca->name());
fte->use_text.connect (sigc::mem_fun (*this, &VCAMasterStrip::finish_name_edit));
fte->present ();
return true; return true;
} }
@ -450,6 +464,15 @@ VCAMasterStrip::name_button_press (GdkEventButton* ev)
return false; return false;
} }
void
VCAMasterStrip::start_name_edit ()
{
Gtk::Window* win = dynamic_cast<Gtk::Window*>(get_toplevel());
FloatingTextEntry* fte = new FloatingTextEntry (win, _vca->name());
fte->use_text.connect (sigc::mem_fun (*this, &VCAMasterStrip::finish_name_edit));
fte->present ();
}
void void
VCAMasterStrip::finish_name_edit (std::string str) VCAMasterStrip::finish_name_edit (std::string str)
{ {
@ -476,5 +499,6 @@ VCAMasterStrip::build_context_menu ()
using namespace Gtk::Menu_Helpers; using namespace Gtk::Menu_Helpers;
context_menu = new Menu; context_menu = new Menu;
MenuList& items = context_menu->items(); MenuList& items = context_menu->items();
items.push_back (MenuElem (_("Rename"), sigc::mem_fun (*this, &VCAMasterStrip::start_name_edit)));
items.push_back (MenuElem (_("Remove"))); items.push_back (MenuElem (_("Remove")));
} }

View file

@ -85,6 +85,7 @@ class VCAMasterStrip : public AxisView, public Gtk::EventBox
void unassign (); void unassign ();
bool vca_button_release (GdkEventButton*); bool vca_button_release (GdkEventButton*);
void update_vca_display (); void update_vca_display ();
void start_name_edit ();
void finish_name_edit (std::string); void finish_name_edit (std::string);
bool name_button_press (GdkEventButton*); bool name_button_press (GdkEventButton*);
bool vertical_box_press (GdkEventButton*); bool vertical_box_press (GdkEventButton*);