[Summary] Progressing dropdown

This commit is contained in:
Valeriy Kamyshniy 2014-09-03 18:14:34 +03:00
parent e59ebf02bb
commit 96003844c0
3 changed files with 7 additions and 18 deletions

View file

@ -41,14 +41,18 @@ WavesDropdown::add_menu_item (const std::string& item, void* cookie)
{ {
Gtk::Menu_Helpers::MenuList& items = _menu.items (); Gtk::Menu_Helpers::MenuList& items = _menu.items ();
items.push_back (Gtk::Menu_Helpers::MenuElem (item, sigc::bind (sigc::mem_fun(*this, &WavesDropdown::_on_menu_item), cookie))); items.push_back (Gtk::Menu_Helpers::MenuElem (item, sigc::bind (sigc::mem_fun(*this, &WavesDropdown::_on_menu_item), items.size (), cookie)));
return _menu.items ().back (); return _menu.items ().back ();
} }
void void
WavesDropdown::_on_menu_item (void* cookie) WavesDropdown::_on_menu_item (size_t item_number, void* cookie)
{ {
Gtk::Menu_Helpers::MenuList& items = _menu.items ();
Gtk::Menu_Helpers::MenuList::iterator i = items.begin();
std::advance (i, item_number);
set_text ((*i).get_label());
signal_menu_item_clicked (this, cookie); signal_menu_item_clicked (this, cookie);
} }
@ -71,18 +75,4 @@ WavesDropdown::_on_popup_menu_position (int& x, int& y, bool& push_in)
x += xo; x += xo;
y += yo; y += yo;
} }
/*
if (get_window ()) {
Gtk::Allocation a = get_allocation ();
int xo;
int yo;
get_window ()->get_origin (xo, yo);
x = xo;
y = yo + a.get_height ();
}
*/
} }

View file

@ -40,7 +40,7 @@ class WavesDropdown : public WavesIconButton
private: private:
Gtk::Menu _menu; Gtk::Menu _menu;
void _on_menu_item (void* cookie); void _on_menu_item (size_t item_number, void* cookie);
void _on_popup_menu_position (int& x, int& y, bool& push_in); void _on_popup_menu_position (int& x, int& y, bool& push_in);
}; };

View file

@ -463,7 +463,6 @@ WavesUI::create_ui (const XMLNodeList& definition, const XMLNodeMap& styles, Gtk
WavesDropdown* dropdown = dynamic_cast<WavesDropdown*> (&root); WavesDropdown* dropdown = dynamic_cast<WavesDropdown*> (&root);
if (dropdown) { if (dropdown) {
dbg_msg ("launching dropdown->create_menu ()");
add_dropdown_items (*dropdown, definition, styles); add_dropdown_items (*dropdown, definition, styles);
} else { } else {
for (XMLNodeList::const_iterator i = definition.begin (); i != definition.end (); ++i) { for (XMLNodeList::const_iterator i = definition.begin (); i != definition.end (); ++i) {