mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-11 09:06:33 +01:00
Replace positioning function with popup helper
Because all uses of the function positioning menus anchored to a widget were as callback argument to Gtk::Menu::popup() where the caller needed to correctly bind arguments, this led to repeated and a bit obscure code. Wrap the logic into an helper function that takes care of all that, and update the callers.
This commit is contained in:
parent
46710a75de
commit
6a985df81e
5 changed files with 21 additions and 18 deletions
|
|
@ -67,17 +67,11 @@ ArdourDropdown::menu_size_request(Requisition *req) {
|
||||||
req->width = max(req->width, get_allocation().get_width());
|
req->width = max(req->width, get_allocation().get_width());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ArdourDropdown::position_menu(int& x, int& y, bool& push_in) {
|
|
||||||
Gtkmm2ext::position_menu_anchored (&_menu, this, get_text(), x, y, push_in);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ArdourDropdown::on_button_press_event (GdkEventButton* ev)
|
ArdourDropdown::on_button_press_event (GdkEventButton* ev)
|
||||||
{
|
{
|
||||||
if (ev->type == GDK_BUTTON_PRESS) {
|
if (ev->type == GDK_BUTTON_PRESS) {
|
||||||
_menu.popup (sigc::mem_fun(this, &ArdourDropdown::position_menu),
|
Gtkmm2ext::anchored_menu_popup(&_menu, this, get_text(), 1, ev->time);
|
||||||
1, ev->time);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ class ArdourDropdown : public ArdourButton
|
||||||
|
|
||||||
bool on_button_press_event (GdkEventButton*);
|
bool on_button_press_event (GdkEventButton*);
|
||||||
bool on_scroll_event (GdkEventScroll*);
|
bool on_scroll_event (GdkEventScroll*);
|
||||||
void position_menu(int&, int&, bool&);
|
|
||||||
void menu_size_request(Gtk::Requisition*);
|
void menu_size_request(Gtk::Requisition*);
|
||||||
|
|
||||||
void clear_items ();
|
void clear_items ();
|
||||||
|
|
|
||||||
|
|
@ -955,9 +955,7 @@ GenericPluginUI::astate_clicked (ControlUI* cui)
|
||||||
items.push_back (MenuElem (_("Touch"),
|
items.push_back (MenuElem (_("Touch"),
|
||||||
sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::set_automation_state), (AutoState) Touch, cui)));
|
sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::set_automation_state), (AutoState) Touch, cui)));
|
||||||
|
|
||||||
automation_menu->popup (
|
anchored_menu_popup(automation_menu, &cui->automate_button, "", 1, gtk_get_current_event_time());
|
||||||
boost::bind (&Gtkmm2ext::position_menu_anchored, automation_menu, &cui->automate_button, "", _1, _2, _3),
|
|
||||||
1, gtk_get_current_event_time());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -97,10 +97,10 @@ namespace Gtkmm2ext {
|
||||||
int clip_height,
|
int clip_height,
|
||||||
Gdk::Color fg);
|
Gdk::Color fg);
|
||||||
|
|
||||||
LIBGTKMM2EXT_API void position_menu_anchored (const Gtk::Menu* const menu,
|
LIBGTKMM2EXT_API void anchored_menu_popup (Gtk::Menu* const menu,
|
||||||
Gtk::Widget* const anchor,
|
Gtk::Widget* const anchor,
|
||||||
const std::string& selected,
|
const std::string& selected,
|
||||||
int& x, int& y, bool& push_in);
|
guint button, guint32 time);
|
||||||
|
|
||||||
LIBGTKMM2EXT_API void set_popdown_strings (Gtk::ComboBoxText&,
|
LIBGTKMM2EXT_API void set_popdown_strings (Gtk::ComboBoxText&,
|
||||||
const std::vector<std::string>&);
|
const std::vector<std::string>&);
|
||||||
|
|
|
||||||
|
|
@ -310,10 +310,10 @@ Gtkmm2ext::pixbuf_from_string(const string& name, const Pango::FontDescription&
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Gtkmm2ext::position_menu_anchored (const Gtk::Menu* const menu,
|
_position_menu_anchored (int& x, int& y, bool& push_in,
|
||||||
|
const Gtk::Menu* const menu,
|
||||||
Gtk::Widget* const anchor,
|
Gtk::Widget* const anchor,
|
||||||
const std::string& selected,
|
const std::string& selected) {
|
||||||
int& x, int& y, bool& push_in) {
|
|
||||||
using namespace Gdk;
|
using namespace Gdk;
|
||||||
using namespace Gtk;
|
using namespace Gtk;
|
||||||
using namespace Gtk::Menu_Helpers;
|
using namespace Gtk::Menu_Helpers;
|
||||||
|
|
@ -416,6 +416,18 @@ Gtkmm2ext::position_menu_anchored (const Gtk::Menu* const menu,
|
||||||
push_in = false;
|
push_in = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Gtkmm2ext::anchored_menu_popup (Gtk::Menu* const menu,
|
||||||
|
Gtk::Widget* const anchor,
|
||||||
|
const std::string& selected,
|
||||||
|
guint button, guint32 time) {
|
||||||
|
menu->popup(
|
||||||
|
sigc::bind (sigc::ptr_fun(&_position_menu_anchored),
|
||||||
|
menu, anchor, selected),
|
||||||
|
button,
|
||||||
|
time);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Gtkmm2ext::set_popdown_strings (Gtk::ComboBoxText& cr, const vector<string>& strings)
|
Gtkmm2ext::set_popdown_strings (Gtk::ComboBoxText& cr, const vector<string>& strings)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue