The Battle for Wesnoth  1.15.0+dev
Public Member Functions | Private Member Functions | Private Attributes | List of all members
gui2::dialogs::drop_down_menu Class Reference

Used by the menu_button widget. More...

#include <drop_down_menu.hpp>

Inheritance diagram for gui2::dialogs::drop_down_menu:
Inheritance graph

Public Member Functions

 drop_down_menu (SDL_Rect button_pos, const std::vector< config > &items, int selected_item, bool use_markup, bool keep_open, std::function< void()> callback_toggle_state_change=nullptr)
 
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...
 
- Public Member Functions inherited from gui2::dialogs::modal_dialog
 modal_dialog ()
 
virtual ~modal_dialog ()
 
bool show (const unsigned auto_close_time=0)
 Shows the window. More...
 
windowget_window () const
 Returns a pointer to the dialog's window. More...
 
int get_retval () const
 
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
 Inherited from modal_dialog, implemented by REGISTER_DIALOG. More...
 
virtual void pre_show (window &window) override
 Inherited from modal_dialog. More...
 
virtual void post_show (window &window) override
 Inherited from modal_dialog. More...
 
void mouse_up_callback (window &window, bool &, bool &, const point &coordinate)
 
void mouse_down_callback ()
 

Private Attributes

std::vector< configitems_
 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...
 
std::function< void()> callback_toggle_state_change_
 If toggle buttons are used, this callback is called whenever the state of any toggle button changes. More...
 

Additional Inherited Members

- Protected Member Functions inherited from gui2::dialogs::modal_dialog
field_boolregister_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_boolregister_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_integerregister_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_integerregister_integer (const std::string &id, const bool mandatory, int &linked_variable)
 Creates a new integer field. More...
 
field_textregister_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_textregister_text (const std::string &id, const bool mandatory, std::string &linked_variable, const bool capture_focus=false)
 Creates a new text field. More...
 
field_labelregister_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_labelregister_image (const std::string &id, const bool mandatory, const std::string &filename)
 Registers a new styled_widget as image. More...
 
- Protected Attributes inherited from gui2::dialogs::modal_dialog
std::unique_ptr< windowwindow_
 The window object build for this dialog. More...
 

Detailed Description

Used by the menu_button widget.

Definition at line 31 of file drop_down_menu.hpp.

Constructor & Destructor Documentation

◆ drop_down_menu()

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,
std::function< void()>  callback_toggle_state_change = nullptr 
)
inline

Definition at line 34 of file drop_down_menu.hpp.

References gui2::dialogs::modal_dialog::set_restore().

Member Function Documentation

◆ get_toggle_states()

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 215 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::toggle_state_changed().

◆ mouse_down_callback()

void gui2::dialogs::drop_down_menu::mouse_down_callback ( )
private

Definition at line 106 of file drop_down_menu.cpp.

References mouse_down_happened_.

Referenced by pre_show().

◆ mouse_up_callback()

void gui2::dialogs::drop_down_menu::mouse_up_callback ( window window,
bool &  ,
bool &  ,
const point coordinate 
)
private

◆ post_show()

void gui2::dialogs::drop_down_menu::post_show ( window window)
overrideprivatevirtual

Inherited from modal_dialog.

Reimplemented from gui2::dialogs::modal_dialog.

Definition at line 210 of file drop_down_menu.cpp.

References selected_item_.

◆ pre_show()

void gui2::dialogs::drop_down_menu::pre_show ( window window)
overrideprivatevirtual

◆ selected_item()

int gui2::dialogs::drop_down_menu::selected_item ( ) const
inline

◆ window_id()

virtual const std::string& gui2::dialogs::drop_down_menu::window_id ( ) const
overrideprivatevirtual

Inherited from modal_dialog, implemented by REGISTER_DIALOG.

Implements gui2::dialogs::modal_dialog.

Member Data Documentation

◆ button_pos_

SDL_Rect gui2::dialogs::drop_down_menu::button_pos_
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 63 of file drop_down_menu.hpp.

Referenced by pre_show().

◆ callback_toggle_state_change_

std::function<void()> gui2::dialogs::drop_down_menu::callback_toggle_state_change_
private

If toggle buttons are used, this callback is called whenever the state of any toggle button changes.

Definition at line 85 of file drop_down_menu.hpp.

Referenced by pre_show().

◆ items_

std::vector<config> gui2::dialogs::drop_down_menu::items_
private

Configuration of each row.

Definition at line 56 of file drop_down_menu.hpp.

Referenced by pre_show().

◆ keep_open_

bool gui2::dialogs::drop_down_menu::keep_open_
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 73 of file drop_down_menu.hpp.

Referenced by mouse_up_callback().

◆ mouse_down_happened_

bool gui2::dialogs::drop_down_menu::mouse_down_happened_
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 79 of file drop_down_menu.hpp.

Referenced by mouse_down_callback(), and mouse_up_callback().

◆ selected_item_

int gui2::dialogs::drop_down_menu::selected_item_
private

Definition at line 65 of file drop_down_menu.hpp.

Referenced by post_show(), pre_show(), and selected_item().

◆ use_markup_

bool gui2::dialogs::drop_down_menu::use_markup_
private

Definition at line 67 of file drop_down_menu.hpp.

Referenced by pre_show().


The documentation for this class was generated from the following files: