Add ComboBox like active API to ArdourDropdown
This commit is contained in:
@@ -79,6 +79,37 @@ ArdourDropdown::on_button_press_event (GdkEventButton* ev)
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ArdourDropdown::set_active (int c)
|
||||
{
|
||||
for (auto& i : _menu.items()) {
|
||||
if (0 == c--) {
|
||||
_menu.set_active (c);
|
||||
_menu.activate_item (i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
ArdourDropdown::get_active_row_number () const
|
||||
{
|
||||
const MenuItem* current_active = _menu.get_active();
|
||||
|
||||
if (!current_active) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int c = 0;
|
||||
for (auto const& i : _menu.items ()) {
|
||||
if (&i == current_active) {
|
||||
return c;
|
||||
}
|
||||
++c;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
ArdourDropdown::set_active (std::string const& text)
|
||||
{
|
||||
|
||||
@@ -57,6 +57,9 @@ public:
|
||||
|
||||
void set_active (std::string const& text);
|
||||
|
||||
void set_active (int);
|
||||
int get_active_row_number () const;
|
||||
|
||||
protected:
|
||||
void default_text_handler (std::string const&);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user