GUI2/Menu Button: allow changing selections with the scrollwheel (closes #3251)'
The changelog entry is under 1.14.3+dev since this is going to be backported.
(cherry-picked from commit a5169f7c50
)
This commit is contained in:
parent
247750e598
commit
b5344a7991
3 changed files with 48 additions and 8 deletions
|
@ -44,6 +44,7 @@
|
|||
## Version 1.14.3+dev
|
||||
### User interface
|
||||
* Improved the layout of the Statistics dialog.
|
||||
* Allow changing dropdown menu selections with the scrollwheel (FR #3251).
|
||||
### Graphics
|
||||
* Tweaked the Ruffian's attack animation timing.
|
||||
* New attack animation for the Peasant.
|
||||
|
|
|
@ -48,16 +48,27 @@ menu_button::menu_button(const implementation::builder_menu_button& builder)
|
|||
values_.emplace_back(::config {"label", this->get_label()});
|
||||
|
||||
connect_signal<event::MOUSE_ENTER>(
|
||||
std::bind(&menu_button::signal_handler_mouse_enter, this, _2, _3));
|
||||
connect_signal<event::MOUSE_LEAVE>(
|
||||
std::bind(&menu_button::signal_handler_mouse_leave, this, _2, _3));
|
||||
std::bind(&menu_button::signal_handler_mouse_enter, this, _2, _3));
|
||||
|
||||
connect_signal<event::MOUSE_LEAVE>(
|
||||
std::bind(&menu_button::signal_handler_mouse_leave, this, _2, _3));
|
||||
|
||||
connect_signal<event::LEFT_BUTTON_DOWN>(
|
||||
std::bind(&menu_button::signal_handler_left_button_down, this, _2, _3));
|
||||
|
||||
connect_signal<event::LEFT_BUTTON_DOWN>(std::bind(
|
||||
&menu_button::signal_handler_left_button_down, this, _2, _3));
|
||||
connect_signal<event::LEFT_BUTTON_UP>(
|
||||
std::bind(&menu_button::signal_handler_left_button_up, this, _2, _3));
|
||||
connect_signal<event::LEFT_BUTTON_CLICK>(std::bind(
|
||||
&menu_button::signal_handler_left_button_click, this, _2, _3));
|
||||
std::bind(&menu_button::signal_handler_left_button_up, this, _2, _3));
|
||||
|
||||
connect_signal<event::LEFT_BUTTON_CLICK>(
|
||||
std::bind(&menu_button::signal_handler_left_button_click, this, _2, _3));
|
||||
|
||||
connect_signal<event::SDL_WHEEL_UP>(
|
||||
std::bind(&menu_button::signal_handler_sdl_wheel_up, this, _2, _3),
|
||||
event::dispatcher::back_post_child);
|
||||
|
||||
connect_signal<event::SDL_WHEEL_DOWN>(
|
||||
std::bind(&menu_button::signal_handler_sdl_wheel_down, this, _2, _3),
|
||||
event::dispatcher::back_post_child);
|
||||
}
|
||||
|
||||
void menu_button::set_active(const bool active)
|
||||
|
@ -148,6 +159,30 @@ void menu_button::signal_handler_left_button_click(const event::ui_event event,
|
|||
handled = true;
|
||||
}
|
||||
|
||||
void menu_button::signal_handler_sdl_wheel_up(const event::ui_event event, bool& handled)
|
||||
{
|
||||
DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";
|
||||
|
||||
// TODO: should values wrap?
|
||||
if(selected_ > 0) {
|
||||
set_selected(selected_ - 1);
|
||||
}
|
||||
|
||||
handled = true;
|
||||
}
|
||||
|
||||
void menu_button::signal_handler_sdl_wheel_down(const event::ui_event event, bool& handled)
|
||||
{
|
||||
DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";
|
||||
|
||||
// TODO: should values wrap?
|
||||
if(selected_ < values_.size() - 1) {
|
||||
set_selected(selected_ + 1);
|
||||
}
|
||||
|
||||
handled = true;
|
||||
}
|
||||
|
||||
void menu_button::set_values(const std::vector<::config>& values, int selected)
|
||||
{
|
||||
assert(static_cast<std::size_t>(selected) < values.size());
|
||||
|
|
|
@ -134,6 +134,10 @@ private:
|
|||
void signal_handler_left_button_up(const event::ui_event event, bool& handled);
|
||||
|
||||
void signal_handler_left_button_click(const event::ui_event event, bool& handled);
|
||||
|
||||
void signal_handler_sdl_wheel_up(const event::ui_event event, bool& handled);
|
||||
|
||||
void signal_handler_sdl_wheel_down(const event::ui_event event, bool& handled);
|
||||
};
|
||||
|
||||
// }---------- DEFINITION ---------{
|
||||
|
|
Loading…
Add table
Reference in a new issue