The Battle for Wesnoth  1.15.0-dev
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
gui2 Namespace Reference

Generic file dialog. More...

Namespaces

 dialogs
 
 event
 
 implementation
 
 iteration
 
 policy
 Contains the policies for the generator class.
 
 settings
 This namespace contains the 'global' settings.
 
 tip_of_the_day
 

Classes

class  addon_list
 
struct  addon_list_definition
 
struct  builder_grid
 
struct  builder_widget
 Contains the info needed to instantiate a widget. More...
 
class  builder_window
 
class  button
 Simple push button. More...
 
struct  button_definition
 
class  canvas
 A simple canvas which can be drawn upon. More...
 
class  chatbox
 
struct  chatbox_definition
 
class  circle_shape
 Definition of a circle shape. More...
 
class  clickable_item
 Small concept class. More...
 
class  container_base
 A generic container base class. More...
 
class  control_NEW
 
class  drawing
 A widget to draw upon. More...
 
struct  drawing_definition
 
class  event_executor
 Event execution calls. More...
 
class  executor
 Helper to make removing a timer in a callback safe. More...
 
class  field
 Template class to implement the generic field implementation. More...
 
class  field_base
 Abstract base class for the fields. More...
 
class  field_bool
 Specialized field class for boolean. More...
 
class  field_label
 Specialized field class for a styled_widget, used for labels and images. More...
 
class  field_text
 Specialized field class for text. More...
 
class  game_tip
 The tips of day structure. More...
 
class  generator
 Basic template class to generate new items. More...
 
class  generator_base
 Abstract base class for the generator. More...
 
class  grid
 Base container class. More...
 
struct  grid_implementation
 Helper to implement private functions without modifying the header. More...
 
class  group
 
class  gui_definition
 A GUI theme definition. More...
 
class  horizontal_scrollbar
 A horizontal scrollbar. More...
 
struct  horizontal_scrollbar_definition
 
class  image
 An image. More...
 
struct  image_definition
 
class  image_shape
 Definition of an image shape. More...
 
class  integer_selector
 Small abstract helper class. More...
 
struct  key_type
 Key type for the cache. More...
 
class  label
 Label showing a text. More...
 
struct  label_definition
 
struct  layout_exception_height_resize_failed
 Exception thrown when the height resizing has failed. More...
 
struct  layout_exception_resize_failed
 Basic exception when the layout doesn't fit. More...
 
struct  layout_exception_width_modified
 Exception thrown when the width has been modified during resizing. More...
 
struct  layout_exception_width_resize_failed
 Exception thrown when the width resizing has failed. More...
 
class  legacy_menu_item
 Implements simple parsing of legacy GUI1 item markup. More...
 
class  line_shape
 Definition of a line shape. More...
 
struct  linked_group_definition
 
class  listbox
 The listbox class. More...
 
struct  listbox_definition
 
struct  lobby_chat_window
 
class  matrix
 The matrix class. More...
 
struct  matrix_definition
 
class  menu_button
 Simple push button. More...
 
struct  menu_button_definition
 
class  minimap
 The basic minimap class. More...
 
struct  minimap_definition
 
class  multi_page
 The multi page class. More...
 
struct  multi_page_definition
 
class  multimenu_button
 Simple push button. More...
 
struct  multimenu_button_definition
 
class  notifiee
 Helper class to implement callbacks with lifetime management. More...
 
class  notifier
 Helper class to implement callbacks with lifetime management. More...
 
class  pane
 
struct  pane_implementation
 Helper to implement private functions without modifying the header. More...
 
class  panel
 Visible container to hold multiple widgets. More...
 
struct  panel_definition
 
class  password_box
 
class  placer_base
 Base class for the placement helper. More...
 
class  player_list_helper
 
class  progress_bar
 
struct  progress_bar_definition
 
class  rectangle_shape
 Definition of a rectangle shape. More...
 
struct  registered_widget_parser
 
class  repeating_button
 
struct  repeating_button_definition
 
struct  resolution_definition
 Base class of a resolution, contains the common keys for a resolution. More...
 
class  round_rectangle_shape
 Definition of a rounded rectangle shape. More...
 
class  scroll_label
 Label showing a text. More...
 
struct  scroll_label_definition
 
class  scrollbar_base
 Base class for a scroll bar. More...
 
class  scrollbar_container
 Base class for creating containers with one or two scrollbar(s). More...
 
struct  scrollbar_container_implementation
 Helper to implement private functions without modifying the header. More...
 
class  scrollbar_panel
 Visible container to hold multiple widgets. More...
 
struct  scrollbar_panel_definition
 
class  selectable_item
 Small abstract helper class. More...
 
class  size_lock
 
struct  size_lock_definition
 
class  slider
 A slider. More...
 
class  slider_base
 Base class for a scroll bar. More...
 
struct  slider_definition
 
class  spacer
 An empty widget. More...
 
struct  spacer_definition
 
class  stacked_widget
 
struct  stacked_widget_definition
 
struct  stacked_widget_implementation
 
class  state_default
 
struct  state_definition
 Contains the state info for a resolution. More...
 
class  styled_widget
 Base class for all visible items. More...
 
struct  styled_widget_definition
 
class  text_box
 Class for a single line text area. More...
 
class  text_box_base
 Abstract base class for text items. More...
 
struct  text_box_definition
 
class  text_history
 Class for text input history. More...
 
class  text_shape
 Definition of a text shape. More...
 
struct  timer
 
class  toggle_button
 Class for a toggle button. More...
 
struct  toggle_button_definition
 
class  toggle_panel
 Class for a toggle button. More...
 
struct  toggle_panel_definition
 
class  tree_view
 
struct  tree_view_definition
 
class  tree_view_node
 
struct  tree_view_node_implementation
 
class  typed_formula
 Template class can hold a value or a formula to calculate the value. More...
 
class  unit_preview_pane
 
struct  unit_preview_pane_definition
 
struct  value_type
 Value type for the cache. More...
 
class  vertical_scrollbar
 A vertical scrollbar. More...
 
struct  vertical_scrollbar_definition
 
class  viewport
 
struct  viewport_implementation
 Helper to implement private functions without modifying the header. More...
 
class  widget
 Base class for all widgets. More...
 
class  window
 base class of top level items, the only item which needs to store the final canvases to draw on More...
 
struct  window_builder_invalid_id
 Helper struct to signal that get_window_builder failed. More...
 
struct  window_definition
 
struct  window_implementation
 Helper to implement private functions without modifying the header. More...
 

Typedefs

typedef field< int, integer_selectorfield_integer
 
using gui_theme_map_t = std::map< std::string, gui_definition >
 
using widget_parser_t = std::function< styled_widget_definition_ptr(const config &)>
 Function type alias for register_widget. More...
 
using widget_builder_func_t = std::function< builder_widget_ptr(const config &)>
 Function type alias for register_widget_builder. More...
 
using registered_widget_map = std::map< std::string, registered_widget_parser >
 
using widget_builder_map = std::map< std::string, widget_builder_func_t >
 
typedef std::shared_ptr< resolution_definitionresolution_definition_ptr
 
typedef std::shared_ptr< const resolution_definitionresolution_definition_const_ptr
 
typedef std::shared_ptr< styled_widget_definitionstyled_widget_definition_ptr
 
typedef std::shared_ptr< builder_widgetbuilder_widget_ptr
 
typedef std::shared_ptr< const builder_widgetbuilder_widget_const_ptr
 
typedef std::shared_ptr< builder_gridbuilder_grid_ptr
 
typedef std::shared_ptr< const builder_gridbuilder_grid_const_ptr
 
using generator_sort_array = std::array< generator_base::order_func, 2 >
 
typedef control_NEW< state_defaulttbase
 
typedef std::map< key_type, value_typetcache
 The cache. More...
 

Enumerations

enum  retval : int { NONE = 0, OK = -1, CANCEL = -2, AUTO_CLOSE = -3 }
 Default window/dialog return values. More...
 

Functions

template<class T >
bool sort (const pane::item &lhs, const pane::item &rhs, const std::string &tag, const bool ascending)
 
bool contains (const pane::item &item, const std::string &tag, const text_box &text_box)
 A filter testing whether a search string is used in a text. More...
 
template<class T >
T & get_parent (widget &child)
 Returns the first parent of a widget with a certain type. More...
 
template<class T >
T * find_widget (utils::const_clone_ptr< widget, T > widget, const std::string &id, const bool must_be_active, const bool must_exist)
 Gets a widget with the wanted id. More...
 
template<class T >
T & find_widget (utils::const_clone_ptr< widget, T > widget, const std::string &id, const bool must_be_active)
 Gets a widget with the wanted id. More...
 
void remove_from_window_stack (window *window)
 Removes a entry from the open_window_stack list. More...
 
bool is_in_dialog ()
 Is a dialog open? More...
 
resolution_definition_ptr get_control (const std::string &control_type, const std::string &definition)
 Returns the appropriate config data for a widget instance fom the active GUI definition. More...
 
const builder_window::window_resolutionget_window_builder (const std::string &type)
 Returns an reference to the requested builder. More...
 
bool add_single_widget_definition (const std::string &widget_type, const std::string &definition_id, const config &cfg)
 Adds a widget definition to the default GUI. More...
 
void remove_single_widget_definition (const std::string &widget_type, const std::string &definition_id)
 Removes a widget definition from the default GUI. More...
 
std::vector< linked_group_definitionparse_linked_group_definitions (const config &cfg)
 
std::set< std::string > & registered_window_types ()
 Returns the list of registered windows. More...
 
void register_window (const std::string &id)
 Registers a window. More...
 
registered_widget_mapregistered_widget_types ()
 Returns the list of registered widgets and their parsers. More...
 
void register_widget (const std::string &type, widget_parser_t f, const char *key=nullptr)
 Registers a widget type. More...
 
widget_builder_mapwidget_builder_lookup ()
 Returns the list of registered widget builders. More...
 
void register_widget_builder (const std::string &type, widget_builder_func_t functor)
 Registers a widget builder. More...
 
static std::map< std::size_t, timer > & get_timers ()
 The active timers. More...
 
static uint32_t timer_callback (uint32_t, void *id)
 
std::size_t add_timer (const uint32_t interval, const std::function< void(std::size_t id)> &callback, const bool repeat=false)
 Adds a new timer. More...
 
bool remove_timer (const std::size_t id)
 Removes a timer. More...
 
bool execute_timer (const std::size_t id)
 Executes a timer. More...
 
windowbuild (const builder_window::window_resolution *res)
 Builds a window. More...
 
windowbuild (const std::string &type)
 Builds a window. More...
 
builder_widget_ptr create_widget_builder (const config &cfg)
 Create a widget builder. More...
 
widgetbuild_single_widget_instance_helper (const std::string &type, const config &cfg)
 Helper function to implement build_single_widget_instance. More...
 
template<typename T >
T * build_single_widget_instance (const config &cfg=config())
 Builds a single widget instance of the given type with the specified attributes. More...
 
void show_message (const std::string &title, const std::string &message, const std::string &button_caption="", const bool auto_close=true, const bool message_use_markup=false, const bool title_use_markup=false)
 Shows a message to the user. More...
 
int show_message (const std::string &title, const std::string &message, const dialogs::message::button_style button_style, bool message_use_markup=false, bool title_use_markup=false)
 Shows a message to the user. More...
 
void show_error_message (const std::string &message, bool message_use_markup=false)
 Shows an error message to the user. More...
 
void show_transient_message (const std::string &title, const std::string &message, const std::string &image=std::string(), const bool message_use_markup=false, const bool title_use_markup=false, const bool restore_background=false)
 Shows a transient message to the user. More...
 
void show_transient_error_message (const std::string &message, const std::string &image=std::string(), const bool message_use_markup=false)
 Shows a transient error message to the user. More...
 
void init ()
 Initializes the GUI subsystems. More...
 
void set_single_child (grid &grid, widget *widget)
 Sets the single child in a grid. More...
 
SDL_Rect create_rect (const point &origin, const point &size)
 Creates a rectangle. More...
 
font::pango_text::FONT_STYLE decode_font_style (const std::string &style)
 Converts a font style string to a font style. More...
 
color_t decode_color (const std::string &color)
 Converts a color string to a color. More...
 
PangoAlignment decode_text_alignment (const std::string &alignment)
 Converts a text alignment string to a text alignment. More...
 
std::string encode_text_alignment (const PangoAlignment alignment)
 Converts a text alignment to its string representation. More...
 
t_string missing_widget (const std::string &id)
 Returns a default error message if a mandatory widget is omitted. More...
 
void get_screen_size_variables (wfl::map_formula_callable &variable)
 Gets a formula object with the screen size. More...
 
wfl::map_formula_callable get_screen_size_variables ()
 Gets a formula object with the screen size. More...
 
point get_mouse_position ()
 Returns the current mouse position. More...
 
std::string debug_truncate (const std::string &text)
 Returns a truncated version of the text. More...
 
static bool operator< (const key_type &lhs, const key_type &rhs)
 
static bool compare (const std::pair< unsigned, tcache::iterator > &lhs, const std::pair< unsigned, tcache::iterator > &rhs)
 
static void shrink_cache ()
 
static void set_scrollbar_mode (grid *scrollbar_grid, scrollbar_base *scrollbar, scrollbar_container::scrollbar_mode &scrollbar_mode, const unsigned items, const unsigned visible_items, grid *content_grid)
 
static bool is_inserted_before (unsigned insertion_pos, unsigned old_item_count, unsigned old_position, unsigned visible_items)
 
static void adjust_scrollbar_mode (grid *scrollbar_grid, scrollbar_base *scrollbar, scrollbar_container::scrollbar_mode &scrollbar_mode, const unsigned items_before, const unsigned items_after, const int insertion_pos, const unsigned visible_items)
 
static t_string default_value_label_generator (const std::vector< t_string > &value_labels, int item_position, int max)
 
template<typename T >
static std::enable_if_t< std::is_base_of< selectable_item, T >::value, std::string > default_status_value_getter (T &w)
 Default value getter for selectable widgets (like toggle buttons) More...
 
template<typename T >
static std::enable_if_t< std::is_base_of< integer_selector, T >::value, std::string > default_status_value_getter (T &w)
 Default value getter for integer-based widgets (like sliders) More...
 
template<typename W >
std::function< void()> bind_status_label (widget *find_in, const std::string &source_id, const std::function< std::string(W &)> value_getter=default_status_value_getter< W >, const std::string &label_id="")
 Creates a bound status label that will reflect the label state of a widget. More...
 
static tree_view_nodeadd_name_tree_node (tree_view_node &header_node, const std::string &type, const t_string &label, const t_string &tooltip="")
 
static std::string get_hp_tooltip (const utils::string_map &res, const std::function< int(const std::string &, bool)> &get)
 
static std::string get_mp_tooltip (int total_movement, std::function< int(t_translation::terrain_code)> get)
 
void swap_grid (grid *g, grid *content_grid, widget *widget, const std::string &id)
 Swaps an item in a grid for another one. More...
 
static bool is_active (const widget *wgt)
 
static std::set< std::string > & unit_test_registered_window_list ()
 

Variables

std::vector< window * > open_window_stack {}
 Keeps track of any open windows of any type (modal, non-modal, or tooltip) in the order in which they were opened. More...
 
gui_theme_map_t guis
 Map of all known GUIs. More...
 
gui_theme_map_t::iterator current_gui = guis.end()
 Iterator pointing to the current GUI. More...
 
gui_theme_map_t::iterator default_gui = guis.end()
 Iterator pointing to the default GUI. More...
 
lg::log_domain log_gui_draw ("gui/draw")
 
lg::log_domain log_gui_event ("gui/event")
 
lg::log_domain log_gui_general ("gui/general")
 
lg::log_domain log_gui_iterator ("gui/iterator")
 
lg::log_domain log_gui_lifetime ("gui/lifetime")
 
lg::log_domain log_gui_layout ("gui/layout")
 
lg::log_domain log_gui_parse ("gui/parse")
 
static std::size_t next_timer_id = 0
 Ids for the timers. More...
 
static std::size_t executing_id = 0
 The id of the event being executed, 0 if none. More...
 
static bool executing_id_removed = false
 Did somebody try to remove the timer during its execution? More...
 
static bool initialized = false
 
static const size_t cache_max_size = 100
 Maximum number of items in the cache (multiple of 4). More...
 
static const ::configterrain = nullptr
 The terrain used to create the cache. More...
 
static tcache cache
 
bool new_widgets = false
 Do we wish to use the new library or not. More...
 

Detailed Description

Generic file dialog.

A class inherited from text_box that displays its input as stars.

Todo:
The items below are not implemented yet.
Note
it might be that tooltips will be shown independent of a window and in their own window, therefore the code will be cleaned up after that has been determined.

This provides UI elements for browsing the filesystem and choosing a file path to open or create, and optionally allows creating new directories or deleting existing files and directories.

Because of the sheer amount of unrelated options provided by this dialog, no parameter-based constructors or static execute() functions are provided. Use individual property setters after construction and before invoking show(), instead.

Todo:
This implementation is quite a hack that needs to be rewritten cleanly

Typedef Documentation

◆ builder_grid_const_ptr

typedef std::shared_ptr< const builder_grid > gui2::builder_grid_const_ptr

Definition at line 139 of file window_builder.hpp.

◆ builder_grid_ptr

typedef std::shared_ptr<builder_grid> gui2::builder_grid_ptr

Definition at line 138 of file window_builder.hpp.

◆ builder_widget_const_ptr

typedef std::shared_ptr<const builder_widget> gui2::builder_widget_const_ptr

Definition at line 72 of file window_builder.hpp.

◆ builder_widget_ptr

typedef std::shared_ptr<builder_widget> gui2::builder_widget_ptr

Definition at line 71 of file window_builder.hpp.

◆ field_integer

Definition at line 36 of file field-fwd.hpp.

◆ generator_sort_array

Definition at line 381 of file generator.hpp.

◆ gui_theme_map_t

using gui2::gui_theme_map_t = typedef std::map<std::string, gui_definition>

Definition at line 83 of file gui_definition.hpp.

◆ registered_widget_map

using gui2::registered_widget_map = typedef std::map<std::string, registered_widget_parser>

Definition at line 113 of file static_registry.hpp.

◆ resolution_definition_const_ptr

Definition at line 74 of file widget_definition.hpp.

◆ resolution_definition_ptr

Definition at line 71 of file widget_definition.hpp.

◆ styled_widget_definition_ptr

Definition at line 94 of file widget_definition.hpp.

◆ tbase

Definition at line 96 of file matrix.hpp.

◆ tcache

typedef std::map<key_type, value_type> gui2::tcache

The cache.

Definition at line 133 of file minimap.cpp.

◆ widget_builder_func_t

using gui2::widget_builder_func_t = typedef std::function<builder_widget_ptr(const config&)>

Function type alias for register_widget_builder.

Definition at line 67 of file static_registry.hpp.

◆ widget_builder_map

using gui2::widget_builder_map = typedef std::map<std::string, widget_builder_func_t>

Definition at line 118 of file static_registry.hpp.

◆ widget_parser_t

using gui2::widget_parser_t = typedef std::function<styled_widget_definition_ptr(const config&)>

Function type alias for register_widget.

Definition at line 44 of file static_registry.hpp.

Enumeration Type Documentation

◆ retval

enum gui2::retval : int

Default window/dialog return values.

These values are named return values and most are assigned to a widget automatically when using a certain id for that widget (ie, a widget with the id "ok" will be assigned the OK return value.

The automatic return values are always a negative number.

Enumerator
NONE 

Default, unset return value.

OK 

Dialog was closed with the OK button.

CANCEL 

Dialog was closed with the CANCEL button.

AUTO_CLOSE 

The dialog was closed automatically as its timeout had been reached.

Definition at line 28 of file retval.hpp.

Function Documentation

◆ add_name_tree_node()

static tree_view_node& gui2::add_name_tree_node ( tree_view_node header_node,
const std::string &  type,
const t_string label,
const t_string tooltip = "" 
)
inlinestatic

◆ add_single_widget_definition()

bool gui2::add_single_widget_definition ( const std::string &  widget_type,
const std::string &  definition_id,
const config cfg 
)

Adds a widget definition to the default GUI.

Definition at line 290 of file gui_definition.cpp.

References registered_widget_types().

Referenced by lua_gui2::intf_add_widget_definition().

◆ add_timer()

std::size_t gui2::add_timer ( const uint32_t  interval,
const std::function< void(std::size_t id)> &  callback,
const bool  repeat = false 
)

Adds a new timer.

Parameters
intervalThe timer interval in ms.
callbackThe function to call when the timer expires, the id send as parameter is the id of the timer.
repeatIf true the timer will restart after it expires.
Returns
The id of the timer.
Return values
[0]Failed to create a timer.

Definition at line 117 of file timer.cpp.

References gui2::timer::callback, DBG_GUI_E, gui2::event::find(), get_timers(), gui2::timer::interval, next_timer_id, gui2::timer::sdl_id, gui2::timer::timer(), timer_callback(), and WRN_GUI_E.

Referenced by gui2::dialogs::outro::draw_callback(), gui2::dialogs::story_viewer::draw_floating_image(), gui2::dialogs::plugin_executor::plugin_executor(), gui2::dialogs::mp_staging::pre_show(), gui2::dialogs::mp_join_game::pre_show(), gui2::dialogs::mp_lobby::pre_show(), gui2::repeating_button::signal_handler_left_button_down(), gui2::event::mouse_motion::start_hover_timer(), and gui2::text_box_base::toggle_cursor_timer().

◆ adjust_scrollbar_mode()

static void gui2::adjust_scrollbar_mode ( grid scrollbar_grid,
scrollbar_base scrollbar,
scrollbar_container::scrollbar_mode scrollbar_mode,
const unsigned  items_before,
const unsigned  items_after,
const int  insertion_pos,
const unsigned  visible_items 
)
static

◆ bind_status_label()

template<typename W >
std::function<void()> gui2::bind_status_label ( widget find_in,
const std::string &  source_id,
const std::function< std::string(W &)>  value_getter = default_status_value_getter<W>,
const std::string &  label_id = "" 
)

Creates a bound status label that will reflect the label state of a widget.

The initial label value is set here, and then again any time the widget is modified. A function is also returned that can be called to update the label manually.

This relies on hooking into the NOTIFY_MODIFIED event, so can only be used with widgets that fire that event.

Parameters
find_inThe containing widget (usually a window or grid) in which to find the source and status label widgets.
source_idThe ID of the source widget.
value_getterFunctor to process the value of the source widget.
label_idThe ID of the status label widget.
Returns
The callback function used to update the status label's value.

Definition at line 63 of file status_label_helper.hpp.

References gui2::event::connect_signal_notify_modified().

◆ build() [1/2]

window * gui2::build ( const builder_window::window_resolution definition)

◆ build() [2/2]

window * gui2::build ( const std::string &  type)

Builds a window.

Parameters
typeThe type id string of the window, this window must be registered at startup.

Definition at line 83 of file window_builder.cpp.

References build(), get_window_builder(), and gui2::widget::set_id().

◆ build_single_widget_instance()

template<typename T >
T* gui2::build_single_widget_instance ( const config cfg = config())

Builds a single widget instance of the given type with the specified attributes.

This should be used in place of creating a widget object directly, as it allows the widget-specific builder code to be executed.

Template Parameters
TThe final widget type. The widget pointer will be cast to this.
Parameters
cfgData config to pass to the widget's builder.

Definition at line 105 of file window_builder.hpp.

References build_single_widget_instance_helper().

◆ build_single_widget_instance_helper()

widget * gui2::build_single_widget_instance_helper ( const std::string &  type,
const config cfg 
)

Helper function to implement build_single_widget_instance.

This keeps the main logic in the implementation despite said function being a template and therefor needing to be fully implemented in the declaration.

Definition at line 137 of file window_builder.cpp.

References VALIDATE, and widget_builder_lookup().

Referenced by build_single_widget_instance().

◆ compare()

static bool gui2::compare ( const std::pair< unsigned, tcache::iterator > &  lhs,
const std::pair< unsigned, tcache::iterator > &  rhs 
)
static

Definition at line 136 of file minimap.cpp.

Referenced by shrink_cache().

◆ contains()

bool gui2::contains ( const pane::item item,
const std::string &  tag,
const text_box text_box 
)
inline

A filter testing whether a search string is used in a text.

The comparison is a lower-case comparison.

The function is expected to be used as a functor for gui2::pane::filter().

Parameters
itemThe pane item to search in.
tagThe tag of the field containing the text to search in.
Note
This text field should already contain lower-cased text only.
Parameters
text_boxA text box object whose text is the search string. The text in the text box will be converted to lower-cased text before the comparison is done.
Returns
Whether or not the comparison found a match.

Definition at line 63 of file filter.hpp.

References utf8::lowercase(), gui2::pane::item::tags, and gui2::text_box_base::text().

Referenced by arrow::path_contains().

◆ create_rect()

SDL_Rect gui2::create_rect ( const point origin,
const point size 
)

Creates a rectangle.

Parameters
originThe top left corner.
sizeThe width (x) and height (y).
Returns
SDL_Rect with the proper rectangle.

Definition at line 32 of file helper.cpp.

References point::x, and point::y.

Referenced by gui2::widget::get_rectangle().

◆ create_widget_builder()

builder_widget_ptr gui2::create_widget_builder ( const config cfg)

Create a widget builder.

This object holds the instance builder for a single widget.

Parameters
cfgThe config object holding the information regarding the widget instance.
Returns
The builder for the widget instance.

Definition at line 99 of file window_builder.cpp.

References config::all_children_range(), c, config::child(), FAIL, preferences::grid(), config::ordered_begin(), VALIDATE, and widget_builder_lookup().

Referenced by gui2::builder_grid::builder_grid(), and gui2::implementation::builder_size_lock::builder_size_lock().

◆ debug_truncate()

std::string gui2::debug_truncate ( const std::string &  text)

Returns a truncated version of the text.

For debugging it's sometimes useful to get a part of the label of the widget. This function shows the first part.

Parameters
textThe text to truncate.
Returns
The truncated text.

Definition at line 124 of file helper.cpp.

Referenced by gui2::styled_widget::calculate_best_size(), font::pango_text::calculate_size(), gui2::styled_widget::get_best_text_size(), gui2::styled_widget::impl_draw_background(), and gui2::styled_widget::request_reduce_width().

◆ decode_color()

color_t gui2::decode_color ( const std::string &  color)

Converts a color string to a color.

Parameters
colorA color string see https://www.wesnoth.org/wiki/GUIVariable for more info.
Returns
The color.

Definition at line 58 of file helper.cpp.

References color_t::from_rgba_string().

◆ decode_font_style()

font::pango_text::FONT_STYLE gui2::decode_font_style ( const std::string &  style)

Converts a font style string to a font style.

Parameters
styleA font style string see https://www.wesnoth.org/wiki/GUIVariable for more info.
Returns
The font style.

Definition at line 37 of file helper.cpp.

References ERR_GUI_G, font::pango_text::STYLE_BOLD, font::pango_text::STYLE_ITALIC, font::pango_text::STYLE_NORMAL, and font::pango_text::STYLE_UNDERLINE.

◆ decode_text_alignment()

PangoAlignment gui2::decode_text_alignment ( const std::string &  alignment)

Converts a text alignment string to a text alignment.

Parameters
alignmentAn alignment string see https://www.wesnoth.org/wiki/GUIVariable for more info.
Returns
The text alignment.

Definition at line 63 of file helper.cpp.

References ERR_GUI_E.

Referenced by gui2::typed_formula< bool >::convert(), gui2::dialogs::story_viewer::display_part(), gui2::typed_formula< bool >::execute(), and gui2::styled_widget::set_members().

◆ default_status_value_getter() [1/2]

template<typename T >
static std::enable_if_t<std::is_base_of<selectable_item, T>::value, std::string> gui2::default_status_value_getter ( T &  w)
inlinestatic

Default value getter for selectable widgets (like toggle buttons)

Definition at line 31 of file status_label_helper.hpp.

References _().

◆ default_status_value_getter() [2/2]

template<typename T >
static std::enable_if_t<std::is_base_of<integer_selector, T>::value, std::string> gui2::default_status_value_getter ( T &  w)
inlinestatic

Default value getter for integer-based widgets (like sliders)

Definition at line 41 of file status_label_helper.hpp.

◆ default_value_label_generator()

static t_string gui2::default_value_label_generator ( const std::vector< t_string > &  value_labels,
int  item_position,
int  max 
)
static

Definition at line 240 of file slider.cpp.

Referenced by gui2::slider::set_value_labels().

◆ encode_text_alignment()

std::string gui2::encode_text_alignment ( const PangoAlignment  alignment)

Converts a text alignment to its string representation.

Parameters
alignmentAn alignment.
Returns
An alignment string see https://www.wesnoth.org/wiki/GUIVariable for more info.

Definition at line 78 of file helper.cpp.

Referenced by gui2::styled_widget::update_canvas().

◆ execute_timer()

bool gui2::execute_timer ( const std::size_t  id)

Executes a timer.

Note
this function is only meant to be executed by the event handling system.
Parameters
idThe id of the timer to execute, this is the id returned by add_timer.
Returns
Status, false if the timer couldn't be executed.

Definition at line 180 of file timer.cpp.

References DBG_GUI_E, get_timers(), and LOG_GUI_E.

Referenced by gui2::event::sdl_event_handler::handle_event().

◆ find_widget() [1/2]

template<class T >
T* gui2::find_widget ( utils::const_clone_ptr< widget, T >  widget,
const std::string &  id,
const bool  must_be_active,
const bool  must_exist 
)

Gets a widget with the wanted id.

This template function doesn't return a pointer to a generic widget but returns the wanted type and tests for its existence if required.

Parameters
widgetThe widget test or find a child with the wanted id.
idThe id of the widget to find.
must_be_activeThe widget should be active, not all widgets have an active flag, those who don't ignore flag.
must_existThe widget should be exist, the function will fail if the widget doesn't exist or is inactive and must be active. Upon failure a wml_error is thrown.
Returns
The widget with the id.

Definition at line 68 of file find_widget.hpp.

References missing_widget(), and VALIDATE.

◆ find_widget() [2/2]

template<class T >
T& gui2::find_widget ( utils::const_clone_ptr< widget, T >  widget,
const std::string &  id,
const bool  must_be_active 
)

Gets a widget with the wanted id.

This template function doesn't return a reference to a generic widget but returns a reference to the wanted type

Parameters
widgetThe widget test or find a child with the wanted id.
idThe id of the widget to find.
must_be_activeThe widget should be active, not all widgets have an active flag, those who don't ignore flag.
Returns
The widget with the id.

Definition at line 95 of file find_widget.hpp.

◆ get_control()

resolution_definition_ptr gui2::get_control ( const std::string &  control_type,
const std::string &  definition 
)

Returns the appropriate config data for a widget instance fom the active GUI definition.

Parameters
control_typeThe widget type.
definitionThe definition ID.
Returns
A pointer to the specified definition data struct for the widget type, accounting for the current screen resolution.

Definition at line 202 of file gui_definition.cpp.

References FAIL, LOG_GUI_G, and VALIDATE.

◆ get_hp_tooltip()

static std::string gui2::get_hp_tooltip ( const utils::string_map res,
const std::function< int(const std::string &, bool)> &  get 
)
inlinestatic

◆ get_mouse_position()

point gui2::get_mouse_position ( )

◆ get_mp_tooltip()

static std::string gui2::get_mp_tooltip ( int  total_movement,
std::function< int(t_translation::terrain_code)>  get 
)
inlinestatic

◆ get_parent()

template<class T >
T& gui2::get_parent ( widget child)

Returns the first parent of a widget with a certain type.

Parameters
childThe widget to get the parent from,
Template Parameters
TThe class of the widget to return.
Returns
The parent widget.

Definition at line 34 of file find_widget.hpp.

References gui2::widget::parent(), and w.

◆ get_screen_size_variables() [1/2]

void gui2::get_screen_size_variables ( wfl::map_formula_callable variable)

Gets a formula object with the screen size.

Parameters
variableA formula object in which the screen_width, screen_height, gamemap_width and gamemap_height variable will set to the current values of these in settings. It modifies the object send.

Definition at line 99 of file helper.cpp.

References wfl::map_formula_callable::add(), gui2::settings::gamemap_height, gui2::settings::gamemap_width, gui2::settings::gamemap_x_offset, gui2::settings::screen_height, and gui2::settings::screen_width.

Referenced by gui2::implementation::builder_drawing::build(), gui2::spacer::calculate_best_size(), gui2::size_lock::calculate_best_size(), gui2::canvas::draw(), get_screen_size_variables(), and gui2::window::layout().

◆ get_screen_size_variables() [2/2]

wfl::map_formula_callable gui2::get_screen_size_variables ( )

Gets a formula object with the screen size.

Returns
Formula object with the screen_width, screen_height, gamemap_width and gamemap_height variable set to the current values of these in settings.

Definition at line 108 of file helper.cpp.

References get_screen_size_variables().

◆ get_timers()

static std::map<std::size_t, timer>& gui2::get_timers ( )
static

The active timers.

Definition at line 42 of file timer.cpp.

Referenced by add_timer(), execute_timer(), remove_timer(), and timer_callback().

◆ get_window_builder()

const builder_window::window_resolution & gui2::get_window_builder ( const std::string &  type)

Returns an reference to the requested builder.

The builder is determined by the type and the current screen resolution.

Precondition
There is a valid builder for type at the current resolution.
Exceptions
window_builder_invalid_idWhen the precondition is violated.
Parameters
typeThe type of builder window to get.
Returns
An iterator to the requested builder.

Definition at line 255 of file gui_definition.cpp.

References gui2::settings::update_screen_size_variables(), VALIDATE, gui2::builder_window::window_resolution::window_height, and gui2::builder_window::window_resolution::window_width.

Referenced by build().

◆ init()

void gui2::init ( )

◆ is_active()

static bool gui2::is_active ( const widget wgt)
static

◆ is_in_dialog()

bool gui2::is_in_dialog ( )

Is a dialog open?

Note
added as backwards compatibility for gui::is_in_dialog.

Definition at line 1034 of file handler.cpp.

References open_window_stack.

Referenced by gui::dialog_manager::dialog_manager(), gui::in_dialog(), controller_base::process(), gui2::window::window(), and gui::dialog_manager::~dialog_manager().

◆ is_inserted_before()

static bool gui2::is_inserted_before ( unsigned  insertion_pos,
unsigned  old_item_count,
unsigned  old_position,
unsigned  visible_items 
)
static

Definition at line 338 of file scrollbar_container.cpp.

Referenced by adjust_scrollbar_mode().

◆ missing_widget()

t_string gui2::missing_widget ( const std::string &  id)

Returns a default error message if a mandatory widget is omitted.

Parameters
idThe id of the omitted widget.
Returns
The error message.

Definition at line 94 of file helper.cpp.

References VGETTEXT.

Referenced by gui2::dialogs::mp_options_helper::add_node_and_get_widget(), and find_widget().

◆ operator<()

static bool gui2::operator< ( const key_type lhs,
const key_type rhs 
)
static

Definition at line 90 of file minimap.cpp.

References gui2::key_type::h, gui2::key_type::map_data, and gui2::key_type::w.

◆ parse_linked_group_definitions()

std::vector< linked_group_definition > gui2::parse_linked_group_definitions ( const config cfg)

◆ register_widget()

void gui2::register_widget ( const std::string &  type,
widget_parser_t  f,
const char *  key = nullptr 
)

Registers a widget type.

This function is utilized by the REGISTER_WIDGET macro and sets the the parser function used to process the widget type's WML when a GUI definition is initialized.

All widgets need to register themselves before gui2::init is called.

Warning
This function runs before main() so needs to be careful regarding the static initialization problem.
Parameters
typeThe type of the widget to register.
fThe function to parse the definition config.
keyThe tagname from which to read the widget's definition in the game config. If nullptr the default [<id>_definition] is used.

Definition at line 49 of file static_registry.cpp.

References f, and registered_widget_types().

◆ register_widget_builder()

void gui2::register_widget_builder ( const std::string &  type,
widget_builder_func_t  functor 
)

Registers a widget builder.

A widget builder simply creates and returns a pointer to a widget type's builder struct. This is part of the static registry since widget builders are simply used to instantiate a widget object when a dialog is being assembled.

If the widget inherits from styled_widget, any theme-dependent info will be fetched from the current GUI theme upon construction.

Warning
This function runs before main() so needs to be careful regarding the static initialization problem.
Parameters
typeThe type of the widget as used in WML.
functorThe functor to create the widget.

Definition at line 60 of file static_registry.cpp.

References widget_builder_lookup().

◆ register_window()

void gui2::register_window ( const std::string &  id)

Registers a window.

This function is utilized by the REGISTER_WINDOW macro and notes a window to look for when a GUI definition is initialized.

All windows need to register themselves before gui2::init is called.

Warning
This function runs before main() so needs to be careful regarding the static initialization problem.
Note
A window can't be registered twice. Any subsequently added windows with duplicate IDs will be ignored. Might be worth looking into adding an unregister function in the future if this becomes an issue.
Parameters
idThe id of the window to register.

Definition at line 33 of file static_registry.cpp.

References registered_window_types(), and WRN_GUI_P.

◆ registered_widget_types()

registered_widget_map & gui2::registered_widget_types ( )

Returns the list of registered widgets and their parsers.

Definition at line 43 of file static_registry.cpp.

Referenced by add_single_widget_definition(), gui2::gui_definition::gui_definition(), and register_widget().

◆ registered_window_types()

std::set< std::string > & gui2::registered_window_types ( )

Returns the list of registered windows.

Definition at line 27 of file static_registry.cpp.

Referenced by gui2::gui_definition::gui_definition(), register_window(), and unit_test_registered_window_list().

◆ remove_from_window_stack()

void gui2::remove_from_window_stack ( window window)

Removes a entry from the open_window_stack list.

This should be used instead of pop_back.

Definition at line 1024 of file handler.cpp.

References next, and open_window_stack.

Referenced by gui2::dialogs::modeless_dialog::hide(), and gui2::dialogs::modal_dialog::~modal_dialog().

◆ remove_single_widget_definition()

void gui2::remove_single_widget_definition ( const std::string &  widget_type,
const std::string &  definition_id 
)

Removes a widget definition from the default GUI.

Definition at line 307 of file gui_definition.cpp.

Referenced by lua_kernel_base::~lua_kernel_base().

◆ remove_timer()

bool gui2::remove_timer ( const std::size_t  id)

Removes a timer.

It's save to remove a timer in its own callback, only the value returned might not be accurate. The destruction is postponed until the execution is finished and the return value is whether the postponing was successful.

Parameters
idThe id of the timer to remove, this is the id returned by add_timer.
Returns
Status, false if the timer couldn't be removed.

Definition at line 149 of file timer.cpp.

References DBG_GUI_E, get_timers(), and LOG_GUI_E.

Referenced by gui2::dialogs::outro::post_show(), gui2::dialogs::mp_staging::post_show(), gui2::dialogs::mp_join_game::post_show(), gui2::dialogs::mp_lobby::post_show(), gui2::repeating_button::set_state(), gui2::repeating_button::signal_handler_left_button_up(), gui2::event::mouse_motion::stop_hover_timer(), gui2::text_box_base::toggle_cursor_timer(), gui2::executor::~executor(), gui2::dialogs::mp_join_game::~mp_join_game(), gui2::dialogs::mp_lobby::~mp_lobby(), gui2::dialogs::mp_staging::~mp_staging(), gui2::dialogs::plugin_executor::~plugin_executor(), gui2::repeating_button::~repeating_button(), and gui2::dialogs::story_viewer::~story_viewer().

◆ set_scrollbar_mode()

static void gui2::set_scrollbar_mode ( grid scrollbar_grid,
scrollbar_base scrollbar,
scrollbar_container::scrollbar_mode scrollbar_mode,
const unsigned  items,
const unsigned  visible_items,
grid content_grid 
)
static

◆ set_single_child()

void gui2::set_single_child ( grid grid,
widget widget 
)

Sets the single child in a grid.

The function initializes the grid to 1 x 1 and adds the widget with the grow to client flags.

Parameters
gridThe grid to add the child to.
widgetThe widget to add as child to the grid.

Definition at line 1106 of file grid.cpp.

References gui2::grid::HORIZONTAL_GROW_SEND_TO_CLIENT, gui2::grid::set_child(), gui2::grid::set_rows_cols(), and gui2::grid::VERTICAL_GROW_SEND_TO_CLIENT.

Referenced by gui2::grid::get_child().

◆ show_error_message()

void gui2::show_error_message ( const std::string &  message,
bool  message_use_markup = false 
)

Shows an error message to the user.

Parameters
messageThe message to show in the dialog.
message_use_markupUse markup for the message?

Definition at line 205 of file message.cpp.

References _(), lg::err(), lg::general(), LOG_STREAM, wfl::msg(), gui2::dialogs::message::ok_button, and show_message().

Referenced by ad_hoc_addon_fetch_session(), editor::context_manager::apply_mask_dialog(), savegame::savegame::check_filename(), savegame::loadgame::check_version_compatibility(), gui2::dialogs::game_cache_options::clean_cache_callback(), editor::context_manager::create_mask_to_dialog(), editor::editor_controller::custom_tods_dialog(), gui2::dialogs::addon_manager::delete_addon(), sp::enter_create_mode(), gui2::dialogs::mp_lobby::enter_game(), gui2::dialogs::addon_manager::fetch_addons_list(), editor::context_manager::generate_map_dialog(), game_launcher::init_lua_script(), addons_client::install_addon(), game_launcher::launch_game(), playsingle_controller::hotkey_handler::load_autosave(), game_launcher::load_game(), savegame::loadgame::load_game(), savegame::loadgame::load_game_ingame(), savegame::loadgame::load_multiplayer_game(), campaign_controller::play_game(), game_launcher::play_multiplayer(), gui2::dialogs::title_screen::pre_show(), gui2::dialogs::addon_manager::publish_addon(), gui2::dialogs::game_cache_options::purge_cache_callback(), savegame::savegame::save_game(), gui2::dialogs::screenshot_notification::save_screenshot(), wml_exception::show(), addons_client::try_fetch_addon(), and gui2::dialogs::addon_manager::uninstall_addon().

◆ show_message() [1/2]

void gui2::show_message ( const std::string &  title,
const std::string &  message,
const std::string &  button_caption = "",
const bool  auto_close = true,
const bool  message_use_markup = false,
const bool  title_use_markup = false 
)

Shows a message to the user.

Normally the dialog won't have a button only when the text doesn't fit in the dialog and a scrollbar is used the button will be shown.

Parameters
titleThe title of the dialog.
messageThe message to show in the dialog.
button_captionThe caption of the close button.
auto_closeWhen true the window will hide the ok button when the message doesn't need a scrollbar to show itself.
message_use_markupUse markup for the message?
title_use_markupUse markup for the title?

Definition at line 152 of file message.cpp.

References gui2::dialogs::message::ok, gui2::dialogs::message::set_button_caption(), and gui2::dialogs::modal_dialog::show().

Referenced by gui2::dialogs::preferences_dialog::add_hotkey_callback(), savegame::savegame::check_overwrite(), savegame::loadgame::check_version_compatibility(), gui2::dialogs::game_cache_options::clean_cache_callback(), events::menu_handler::clear_labels(), editor::context_manager::confirm_discard(), gui2::dialogs::file_dialog::confirm_overwrite(), gui2::dialogs::addon_manager::delete_addon(), gui2::dialogs::unit_recall::dismiss_unit(), addons_client::do_check_before_overwriting_addon(), addons_client::do_resolve_addon_dependencies(), events::menu_handler::do_search(), events::console_handler::do_undiscover(), events::console_handler::do_unsafe_lua(), events::menu_handler::end_turn(), gui2::dialogs::addon_manager::execute_default_action(), gui2::dialogs::file_dialog::on_file_delete_cmd(), campaign_controller::play_game(), gui2::dialogs::mp_lobby::post_build(), gui2::dialogs::addon_manager::publish_addon(), gui2::dialogs::game_cache_options::purge_cache_callback(), show_error_message(), lua_gui2::show_message_box(), quit_confirmation::show_prompt(), gui2::label::signal_handler_left_button_click(), gui2::label::signal_handler_right_button_click(), and hotkey::command_executor::surrender_game().

◆ show_message() [2/2]

int gui2::show_message ( const std::string &  title,
const std::string &  message,
const dialogs::message::button_style  button_style,
bool  message_use_markup = false,
bool  title_use_markup = false 
)

Shows a message to the user.

Note
this function is rather untested, and the API might change in the near future.
Parameters
titleThe title of the dialog.
messageThe message to show in the dialog.
button_styleThe style of the button(s) shown.
message_use_markupUse markup for the message?
title_use_markupUse markup for the title?
Returns
The retval of the dialog shown.

Definition at line 164 of file message.cpp.

References _(), gui2::dialogs::message::auto_close, gui2::dialogs::message::cancel, gui2::dialogs::message::cancel_button, gui2::dialogs::message::close_button, gui2::dialogs::modal_dialog::get_retval(), gui2::dialogs::message::ok, gui2::dialogs::message::ok_button, gui2::dialogs::message::ok_cancel_buttons, gui2::dialogs::message::set_button_caption(), gui2::dialogs::message::set_button_visible(), gui2::dialogs::modal_dialog::show(), gui2::widget::visible, and gui2::dialogs::message::yes_no_buttons.

◆ show_transient_error_message()

void gui2::show_transient_error_message ( const std::string &  message,
const std::string &  image = std::string(),
const bool  message_use_markup = false 
)

Shows a transient error message to the user.

This shows a dialog with a short message which can be dismissed with a single click.

Parameters
messageThe message to show in the dialog.
imageAn image to show in the dialog.
message_use_markupUse markup for the message?

Definition at line 73 of file transient_message.cpp.

References _(), lg::err(), lg::general(), LOG_STREAM, and show_transient_message().

Referenced by gui2::dialogs::mp_create_game::dialog_exit_hook(), savegame::loadgame::load_multiplayer_game(), gui2::dialogs::file_dialog::on_dir_create_cmd(), gui2::dialogs::file_dialog::on_file_delete_cmd(), gui2::dialogs::file_dialog::process_submit_common(), gui2::dialogs::preferences_dialog::remove_friend_list_entry(), and events::menu_handler::save_map().

◆ show_transient_message()

void gui2::show_transient_message ( const std::string &  title,
const std::string &  message,
const std::string &  image = std::string(),
const bool  message_use_markup = false,
const bool  title_use_markup = false,
const bool  restore_background = false 
)

Shows a transient message to the user.

This shows a dialog with a short message which can be dismissed with a single click.

Note
The message should be small enough to fit on the window, the text can contain newlines and will wrap when needed.
Parameters
titleThe title of the dialog.
messageThe message to show in the dialog.
imageAn image to show in the dialog.
message_use_markupUse markup for the message?
title_use_markupUse markup for the title?
restore_backgroundRestore the background to the state it was before the message appeared

Definition at line 59 of file transient_message.cpp.

References gui2::dialogs::modal_dialog::set_restore(), and gui2::dialogs::modal_dialog::show().

Referenced by gui2::dialogs::preferences_dialog::add_friend_list_entry(), editor::location_palette::adjust_size(), editor::context_manager::apply_mask_dialog(), editor::context_manager::check_switch_open_map(), editor::context_manager::create_mask_to_dialog(), gui2::dialogs::preferences_dialog::default_hotkey_callback(), gui2::dialogs::addon_manager::delete_addon(), events::menu_handler::do_recruit(), events::console_handler::do_show_var(), events::menu_handler::end_turn(), gui2::dialogs::game_load::execute(), gui2::dialogs::game_stats::execute(), gui2::dialogs::unit_list::execute(), editor::context_manager::generate_map_dialog(), help::help_browser::handle_event(), gui2::dialogs::addon_manager::load_addon_list(), editor::context_manager::load_map(), savegame::loadgame::load_multiplayer_game(), editor::editor_controller::main_loop(), events::mouse_handler::move_unit_along_route(), gui2::dialogs::mp_join_game::network_handler(), game_launcher::play_multiplayer(), playsingle_controller::play_scenario(), playsingle_controller::play_scenario_init(), gui2::dialogs::mp_create_game::pre_show(), gui2::dialogs::addon_manager::publish_addon(), events::menu_handler::recall(), events::menu_handler::recruit(), gui2::dialogs::preferences_dialog::remove_friend_list_entry(), savegame::savegame::save_game(), events::menu_handler::save_map(), editor::context_manager::save_map_as(), editor::context_manager::save_scenario_as(), events::mouse_handler::show_attack_dialog(), campaign_controller::show_carryover_message(), help::show_help(), play_controller::show_objectives(), lua_gui2::show_popup_dialog(), preferences::show_theme_dialog(), show_transient_error_message(), playsingle_controller::show_turn_dialog(), editor::context_manager::write_map(), and editor::context_manager::write_scenario().

◆ shrink_cache()

static void gui2::shrink_cache ( )
static

Definition at line 142 of file minimap.cpp.

References cache, cache_max_size, compare(), DBG_GUI_D, and mp_ui_alerts::items.

Referenced by gui2::minimap::get_image().

◆ sort()

template<class T >
bool gui2::sort ( const pane::item lhs,
const pane::item rhs,
const std::string &  tag,
const bool  ascending 
)
inline

Definition at line 30 of file filter.hpp.

References lexical_cast(), and gui2::pane::item::tags.

◆ swap_grid()

void gui2::swap_grid ( grid g,
grid content_grid,
widget widget,
const std::string &  id 
)

Swaps an item in a grid for another one.

Definition at line 25 of file widget_helpers.cpp.

References g, and gui2::widget::set_id().

Referenced by gui2::stacked_widget::finalize(), gui2::multi_page::finalize(), and gui2::listbox::finalize().

◆ timer_callback()

static uint32_t gui2::timer_callback ( uint32_t  ,
void *  id 
)
static

Definition at line 93 of file timer.cpp.

References DBG_GUI_E, get_timers(), and TIMER_EVENT.

Referenced by add_timer().

◆ unit_test_registered_window_list()

static std::set<std::string>& gui2::unit_test_registered_window_list ( )
static

◆ widget_builder_lookup()

widget_builder_map & gui2::widget_builder_lookup ( )

Returns the list of registered widget builders.

Definition at line 54 of file static_registry.cpp.

Referenced by build_single_widget_instance_helper(), create_widget_builder(), and register_widget_builder().

Variable Documentation

◆ cache

tcache gui2::cache
static

◆ cache_max_size

const size_t gui2::cache_max_size = 100
static

Maximum number of items in the cache (multiple of 4).

No testing on the optimal number is done, just seems a nice number.

Definition at line 121 of file minimap.cpp.

Referenced by gui2::minimap::get_image(), and shrink_cache().

◆ current_gui

gui_theme_map_t::iterator gui2::current_gui = guis.end()

Iterator pointing to the current GUI.

Definition at line 29 of file gui_definition.cpp.

Referenced by init().

◆ default_gui

gui_theme_map_t::iterator gui2::default_gui = guis.end()

Iterator pointing to the default GUI.

Definition at line 30 of file gui_definition.cpp.

Referenced by init().

◆ executing_id

std::size_t gui2::executing_id = 0
static

The id of the event being executed, 0 if none.

NOTE: it is possible that multiple timers are executed at the same time if one of the timer starts an event loop for example if its handler shows a dialog. In that case code that relies on this breaks. This could probably fixed my making this a list/stack of ids.

Definition at line 54 of file timer.cpp.

Referenced by gui2::executor::~executor().

◆ executing_id_removed

bool gui2::executing_id_removed = false
static

Did somebody try to remove the timer during its execution?

Definition at line 57 of file timer.cpp.

◆ guis

gui_theme_map_t gui2::guis

Map of all known GUIs.

Definition at line 28 of file gui_definition.cpp.

Referenced by init().

◆ initialized

bool gui2::initialized = false
static

Definition at line 33 of file gui.cpp.

◆ log_gui_draw

lg::log_domain gui2::log_gui_draw

◆ log_gui_event

lg::log_domain gui2::log_gui_event

Definition at line 33 of file log.hpp.

◆ log_gui_general

lg::log_domain gui2::log_gui_general

Definition at line 39 of file log.hpp.

Referenced by gui2::builder_grid::build(), and gui2::container_base::init_grid().

◆ log_gui_iterator

lg::log_domain gui2::log_gui_iterator

Definition at line 45 of file log.hpp.

◆ log_gui_layout

lg::log_domain gui2::log_gui_layout

◆ log_gui_lifetime

lg::log_domain gui2::log_gui_lifetime

Definition at line 62 of file log.hpp.

◆ log_gui_parse

lg::log_domain gui2::log_gui_parse

Definition at line 67 of file log.hpp.

Referenced by gui2::builder_grid::builder_grid(), and gui2::canvas::parse_cfg().

◆ new_widgets

bool gui2::new_widgets = false

◆ next_timer_id

std::size_t gui2::next_timer_id = 0
static

Ids for the timers.

Definition at line 39 of file timer.cpp.

Referenced by add_timer().

◆ open_window_stack

std::vector< window * > gui2::open_window_stack {}

Keeps track of any open windows of any type (modal, non-modal, or tooltip) in the order in which they were opened.

Currently only used as a helper for is_in_dialog(), but could potentially be useful for other things in the future.

Definition at line 1022 of file handler.cpp.

Referenced by gui2::text_box_base::cursor_timer_callback(), is_in_dialog(), remove_from_window_stack(), gui2::dialogs::modeless_dialog::show(), and gui2::dialogs::modal_dialog::~modal_dialog().

◆ terrain

const ::config* gui2::terrain = nullptr
static

The terrain used to create the cache.

If another terrain config is used the cache needs to be cleared, this normally doesn't happen a lot so the clearing of the cache is rather unusual.

Definition at line 130 of file minimap.cpp.

Referenced by editor::map_context::add_to_playlist(), movetype::terrain_info::data::calc_value(), game_board::change_terrain(), ai::ai_default_rca::move_cost_calculator::cost(), pathfind::shortest_path_calculator::cost(), pathfind::move_type_path_calculator::cost(), create_terrain_maps(), default_map_generator_job::default_generate_map(), editor::terrain_palette::draw_item(), editor::map_context::draw_terrain(), preferences::encounter_map_terrain(), ai::default_recruitment::recruitment::get_average_defense(), editor::editor_map::get_contiguous_terrain_tiles(), gui2::minimap::get_image(), get_mp_tooltip(), editor::unit_palette::get_selected_bg_items(), terrain_type_data::get_underlying_terrain_string(), image::getMinimap(), game_lua_kernel::intf_terrain_mask(), unit_animation_component::invalidate(), preferences::manager::manager(), editor::terrain_palette::map(), t_translation::max_map_size(), help::unit_topic_generator::operator()(), terrain_builder::parse_mapstring(), placing_score(), ai::readonly_context_impl::power_projection(), ai::ai_default_rca::aspect_attacks_base::rate_terrain(), ai::default_ai_context_impl::rate_terrain(), unit_drawer::redraw_unit(), REPORT_GENERATOR(), editor::terrain_palette::select_bg_item(), editor::terrain_palette::select_fg_item(), unit::set_attacks(), gui2::minimap::set_config(), unit_type_data::set_config(), gui2::unit_preview_pane::set_displayed_type(), gui2::unit_preview_pane::set_displayed_unit(), terrain_type_data::underlying_def_terrain(), terrain_type_data::underlying_mvt_terrain(), terrain_type_data::underlying_union_terrain(), unit_box_at(), unit_defense(), unit_moves(), movetype::terrain_info::data::value(), and preferences::manager::~manager().