Used by the menu_button widget. More...
#include <drop_down_menu.hpp>
Classes | |
struct | entry_data |
Public Member Functions | |
drop_down_menu (styled_widget *parent, const std::vector< config > &items, int selected_item, bool keep_open) | |
Menu was invoked from a widget (currently a [multi]menu_button). More... | |
drop_down_menu (SDL_Rect button_pos, const std::vector< config > &items, int selected_item, bool use_markup, bool keep_open) | |
Menu was invoked manually. More... | |
int | selected_item () const |
boost::dynamic_bitset | get_toggle_states () const |
If a toggle button widget is present, returns the toggled state of each row's button. More... | |
![]() | |
modal_dialog () | |
virtual | ~modal_dialog () |
bool | show (const unsigned auto_close_time=0) |
Shows the window. More... | |
window * | get_window () const |
Returns a pointer to the dialog's window. More... | |
int | get_retval () const |
Returns the cached window exit code. More... | |
void | set_retval (int retval) |
Convenience wrapper to set the window's exit code. More... | |
void | set_always_save_fields (const bool always_save_fields) |
void | set_restore (const bool restore) |
void | set_allow_plugin_skip (const bool allow_plugin_skip) |
void | set_show_even_without_video (const bool show_even_without_video) |
Private Member Functions | |
virtual const std::string & | window_id () const override |
The id of the window to build. More... | |
virtual void | pre_show (window &window) override |
Actions to be taken before showing the window. More... | |
virtual void | post_show (window &window) override |
Actions to be taken after the window has been shown. More... | |
void | mouse_up_callback (bool &, bool &, const point &coordinate) |
void | mouse_down_callback () |
Private Attributes | |
styled_widget * | parent_ |
The widget that invoked this dialog, if applicable. More... | |
std::vector< entry_data > | items_ |
Configuration of each row. More... | |
SDL_Rect | button_pos_ |
The screen location of the menu_button button that triggered this droplist. More... | |
int | selected_item_ |
bool | use_markup_ |
bool | keep_open_ |
Whether to keep this dialog open after a click occurs not handled by special exceptions such as scrollbars and toggle buttons. More... | |
bool | mouse_down_happened_ |
When menu is invoked on a long-touch timer, a following mouse-up event will close it. More... | |
Additional Inherited Members | |
![]() | |
template<typename T , typename... Args> | |
T * | register_field (Args &&... args) |
Creates a new field of given type with given arguments. More... | |
field_bool * | register_bool (const std::string &id, const bool mandatory, const std::function< bool()> callback_load_value=nullptr, const std::function< void(bool)> callback_save_value=nullptr, const std::function< void(widget &)> callback_change=nullptr, const bool initial_fire=false) |
Creates a new boolean field. More... | |
field_bool * | register_bool (const std::string &id, const bool mandatory, bool &linked_variable, const std::function< void(widget &)> callback_change=nullptr, const bool initial_fire=false) |
Creates a new boolean field. More... | |
field_integer * | register_integer (const std::string &id, const bool mandatory, const std::function< int()> callback_load_value=nullptr, const std::function< void(int)> callback_save_value=nullptr) |
Creates a new integer field. More... | |
field_integer * | register_integer (const std::string &id, const bool mandatory, int &linked_variable) |
Creates a new integer field. More... | |
field_text * | register_text (const std::string &id, const bool mandatory, const std::function< std::string()> callback_load_value=nullptr, const std::function< void(const std::string &)> callback_save_value=nullptr, const bool capture_focus=false) |
Creates a new text field. More... | |
field_text * | register_text (const std::string &id, const bool mandatory, std::string &linked_variable, const bool capture_focus=false) |
Creates a new text field. More... | |
field_label * | register_label (const std::string &id, const bool mandatory, const std::string &text, const bool use_markup=false) |
Registers a new styled_widget as a label. More... | |
field_label * | register_image (const std::string &id, const bool mandatory, const std::string &filename) |
Registers a new styled_widget as image. More... | |
![]() | |
std::unique_ptr< window > | window_ |
The window object build for this dialog. More... | |
Used by the menu_button widget.
Definition at line 35 of file drop_down_menu.hpp.
gui2::dialogs::drop_down_menu::drop_down_menu | ( | styled_widget * | parent, |
const std::vector< config > & | items, | ||
int | selected_item, | ||
bool | keep_open | ||
) |
Menu was invoked from a widget (currently a [multi]menu_button).
Its position and markup settings will be derived from there.
Definition at line 85 of file drop_down_menu.cpp.
References gui2::dialogs::modal_dialog::set_restore().
gui2::dialogs::drop_down_menu::drop_down_menu | ( | SDL_Rect | button_pos, |
const std::vector< config > & | items, | ||
int | selected_item, | ||
bool | use_markup, | ||
bool | keep_open | ||
) |
Menu was invoked manually.
Position and markup settings must be provided here.
Definition at line 97 of file drop_down_menu.cpp.
References gui2::dialogs::modal_dialog::set_restore().
boost::dynamic_bitset gui2::dialogs::drop_down_menu::get_toggle_states | ( | ) | const |
If a toggle button widget is present, returns the toggled state of each row's button.
Definition at line 251 of file drop_down_menu.cpp.
References gui2::listbox::get_item_count(), gui2::listbox::get_row_grid(), gui2::dialogs::modal_dialog::get_window(), and i.
Referenced by selected_item(), and gui2::multimenu_button::signal_handler_notify_changed().
|
private |
Definition at line 155 of file drop_down_menu.cpp.
References mouse_down_happened_.
Referenced by pre_show().
|
private |
Definition at line 109 of file drop_down_menu.cpp.
References gui2::CANCEL, gui2::widget::get_rectangle(), gui2::listbox::get_selected_row(), gui2::scrollbar_base::get_state(), gui2::dialogs::modal_dialog::get_window(), keep_open_, mouse_down_happened_, gui2::OK, sdl::point_in_rect(), gui2::scrollbar_base::PRESSED, gui2::listbox::select_row(), gui2::dialogs::modal_dialog::set_retval(), and gui2::scrollbar_container::vertical_scrollbar().
Referenced by pre_show().
|
overrideprivatevirtual |
Actions to be taken after the window has been shown.
At this point the registered fields already stored their values (if the OK has been pressed).
window | The window which has been shown. |
Reimplemented from gui2::dialogs::modal_dialog.
Definition at line 246 of file drop_down_menu.cpp.
References selected_item_.
|
overrideprivatevirtual |
Actions to be taken before showing the window.
At this point the registered fields are registered and initialized with their initial values.
window | The window to be shown. |
Reimplemented from gui2::dialogs::modal_dialog.
Definition at line 160 of file drop_down_menu.cpp.
References gui2::listbox::add_row(), utils::bool_string(), button_pos_, gui2::event::connect_signal_notify_modified(), gui2::event::dispatcher::fire(), gui2::event::dispatcher::front_child, gui2::listbox::get_item_count(), items_, mouse_down_callback(), mouse_up_callback(), gui2::event::NOTIFY_MODIFIED, parent_, gui2::event::SDL_LEFT_BUTTON_DOWN, gui2::event::SDL_LEFT_BUTTON_UP, gui2::event::SDL_RIGHT_BUTTON_UP, gui2::event::SDL_VIDEO_RESIZE, gui2::listbox::select_row(), selected_item_, gui2::window::set_variable(), gui2::grid::swap_child(), and use_markup_.
|
inline |
Definition at line 44 of file drop_down_menu.hpp.
References get_toggle_states(), and selected_item_.
Referenced by hotkey::command_executor::show_menu(), lua_gui2::show_menu(), and gui2::menu_button::signal_handler_left_button_click().
|
overrideprivatevirtual |
The id of the window to build.
Implements gui2::dialogs::modal_dialog.
|
private |
The screen location of the menu_button button that triggered this droplist.
Note: we don't adjust the location of this dialog to when resizing the window. Instead this dialog automatically closes itself on resizing.
Definition at line 88 of file drop_down_menu.hpp.
Referenced by pre_show().
|
private |
Configuration of each row.
Definition at line 81 of file drop_down_menu.hpp.
Referenced by pre_show().
|
private |
Whether to keep this dialog open after a click occurs not handled by special exceptions such as scrollbars and toggle buttons.
Definition at line 98 of file drop_down_menu.hpp.
Referenced by mouse_up_callback().
|
private |
When menu is invoked on a long-touch timer, a following mouse-up event will close it.
This flag prevents that: the menu will only be closed on a mouse-up that follows a mouse-down.
Definition at line 104 of file drop_down_menu.hpp.
Referenced by mouse_down_callback(), and mouse_up_callback().
|
private |
The widget that invoked this dialog, if applicable.
Definition at line 78 of file drop_down_menu.hpp.
Referenced by pre_show().
|
private |
Definition at line 90 of file drop_down_menu.hpp.
Referenced by post_show(), pre_show(), and selected_item().
|
private |
Definition at line 92 of file drop_down_menu.hpp.
Referenced by pre_show().