The Battle for Wesnoth  1.19.5+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  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_text
 Specialized field class for text. More...
 
class  field_label
 Specialized field class for a styled_widget, used for labels and images. More...
 
class  game_tip
 The tips of day structure. More...
 
class  typed_formula
 Template class can hold a value or a formula to calculate the value. More...
 
class  canvas
 A simple canvas which can be drawn upon. More...
 
class  line_shape
 
class  rect_bounded_shape
 
class  rectangle_shape
 
class  round_rectangle_shape
 
class  circle_shape
 
class  image_shape
 
class  text_shape
 
class  gui_definition
 A GUI theme definition. More...
 
struct  window_builder_invalid_id
 Helper struct to signal that get_window_builder failed. More...
 
struct  layout_exception_width_modified
 Exception thrown when the width has been modified during resizing. More...
 
struct  layout_exception_resize_failed
 Basic exception when the layout doesn't fit. More...
 
struct  layout_exception_width_resize_failed
 Exception thrown when the width resizing has failed. More...
 
struct  layout_exception_height_resize_failed
 Exception thrown when the height resizing has failed. More...
 
struct  linked_group_definition
 
class  notifier
 Helper class to implement callbacks with lifetime management. More...
 
class  notifiee
 Helper class to implement callbacks with lifetime management. More...
 
class  placer_base
 Base class for the placement helper. More...
 
struct  registered_widget_parser
 
struct  timer
 
class  executor
 Helper to make removing a timer in a callback safe. More...
 
class  top_level_drawable
 A top-level drawable item (TLD), such as a window. More...
 
struct  state_definition
 Contains the state info for a resolution. More...
 
struct  resolution_definition
 
struct  styled_widget_definition
 
struct  builder_widget
 Contains the info needed to instantiate a widget. More...
 
struct  builder_grid
 
class  builder_window
 
class  lobby_player_list_helper
 
class  player_list_helper
 
struct  grow_direction_defines
 
class  addon_list
 
struct  addon_list_definition
 
class  button
 Simple push button. More...
 
struct  button_definition
 
struct  lobby_chat_window
 
class  chatbox
 
struct  chatbox_definition
 
class  clickable_item
 Small concept class. More...
 
class  combobox
 Class for a combobox. More...
 
struct  combobox_definition
 
class  container_base
 A generic container base class. More...
 
class  drawing
 
struct  drawing_definition
 
class  event_executor
 Event execution calls. More...
 
class  generator_base
 Abstract base class for the generator. More...
 
class  generator
 Basic template class to generate new items. More...
 
class  grid
 Base container class. More...
 
struct  grid_implementation
 Helper to implement private functions without modifying the header. More...
 
class  group
 
class  horizontal_scrollbar
 
struct  horizontal_scrollbar_definition
 
class  image
 
struct  image_definition
 
class  integer_selector
 Small abstract helper class. More...
 
class  label
 
struct  label_definition
 
class  listbox
 The listbox class. More...
 
struct  listbox_definition
 
class  state_default
 
class  control_NEW
 
class  matrix
 
struct  matrix_definition
 
class  menu_button
 
struct  menu_button_definition
 
class  minimap
 
struct  minimap_definition
 
class  multi_page
 
struct  multi_page_definition
 
class  multiline_text
 
struct  multiline_text_definition
 
class  multimenu_button
 
struct  multimenu_button_definition
 
struct  pane_implementation
 Helper to implement private functions without modifying the header. More...
 
class  pane
 A pane is a container where new members can be added and removed during run-time. More...
 
class  panel
 
struct  panel_definition
 
class  password_box
 
class  progress_bar
 
struct  progress_bar_definition
 
class  repeating_button
 
struct  repeating_button_definition
 
class  rich_label
 A rich_label takes marked up text and shows it correctly formatted and wrapped but no scrollbars are provided. More...
 
struct  rich_label_definition
 
class  scroll_label
 
struct  scroll_label_definition
 
class  scroll_text
 
struct  scroll_text_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
 
struct  scrollbar_panel_definition
 
class  selectable_item
 Small abstract helper class. More...
 
class  size_lock
 
struct  size_lock_definition
 
class  slider
 
struct  slider_definition
 
class  slider_base
 Base class for a scroll bar. More...
 
class  spacer
 
struct  spacer_definition
 
class  spinner
 
struct  spinner_definition
 
struct  stacked_widget_implementation
 
class  stacked_widget
 
struct  stacked_widget_definition
 
class  styled_widget
 
class  tab_container
 A container widget that shows one of its pages of widgets depending on which tab the user clicked. More...
 
struct  tab_container_definition
 
class  text_history
 Class for text input history. More...
 
class  text_box
 A widget that allows the user to input text in single line. More...
 
struct  text_box_definition
 
class  text_box_base
 Abstract base class for text items. More...
 
class  toggle_button
 
struct  toggle_button_definition
 
class  toggle_panel
 
struct  toggle_panel_definition
 
class  tree_view
 
struct  tree_view_definition
 
struct  tree_view_node_implementation
 
class  tree_view_node
 
class  unit_preview_pane
 
struct  unit_preview_pane_definition
 
class  vertical_scrollbar
 
struct  vertical_scrollbar_definition
 
struct  viewport_implementation
 Helper to implement private functions without modifying the header. More...
 
class  viewport
 
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_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...
 
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
 
using builder_widget_ptr = std::shared_ptr< builder_widget >
 
using builder_widget_const_ptr = std::shared_ptr< const builder_widget >
 
using builder_grid_ptr = std::shared_ptr< builder_grid >
 
using builder_grid_const_ptr = std::shared_ptr< const builder_grid >
 
using builder_grid_map = std::map< std::string, builder_grid_const_ptr >
 
using grow_direction = string_enums::enum_base< grow_direction_defines >
 
using generator_sort_array = std::array< generator_base::order_func, 2 >
 
typedef control_NEW< state_defaulttbase
 
using widget_item = std::map< std::string, t_string >
 
using widget_data = std::map< std::string, widget_item >
 

Enumerations

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

Functions

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...
 
std::map< std::string, registered_widget_parser > & registered_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...
 
std::map< std::string, widget_builder_func_t > & widget_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 std::chrono::milliseconds &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...
 
builder_widget_ptr create_widget_builder (const config &cfg)
 Create a widget builder. More...
 
std::unique_ptr< widgetbuild_single_widget_instance_helper (const std::string &type, const config &cfg)
 Implementation detail for build_single_widget_instance. More...
 
template<typename T >
std::unique_ptr< T > build_single_widget_instance (const config &cfg={})
 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)
 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 switch_theme (const std::string &current_theme)
 Set and activate the given gui2 theme. More...
 
void set_single_child (grid &grid, std::unique_ptr< widget > widget)
 Sets the single child in a grid. 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...
 
PangoWeight decode_text_weight (const std::string &weight)
 Converts a text weight string to a PangoWeight. More...
 
PangoStyle decode_text_style (const std::string &style)
 Converts a text style string to a PangoStyle. 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_view debug_truncate (std::string_view text)
 Returns a truncated version of the text. More...
 
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 >
t_string default_status_value_getter (const T &w)
 
template<typename W >
std::function< void()> bind_status_label (widget *find_in, const std::string &source_id, const std::function< t_string(const 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 &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, std::unique_ptr< widget > widget, const std::string &id)
 Swaps an item in a grid for another one. More...
 
static bool is_active (const widget *wgt)
 

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...
 
std::mutex timers_mutex
 
static bool executing_id_removed = false
 Did somebody try to remove the timer during its execution? More...
 
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

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

Definition at line 147 of file window_builder.hpp.

◆ builder_grid_map

using gui2::builder_grid_map = typedef std::map<std::string, builder_grid_const_ptr>

Definition at line 148 of file window_builder.hpp.

◆ builder_grid_ptr

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

Definition at line 146 of file window_builder.hpp.

◆ builder_widget_const_ptr

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

Definition at line 69 of file window_builder.hpp.

◆ builder_widget_ptr

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

Definition at line 68 of file window_builder.hpp.

◆ field_integer

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

◆ generator_sort_array

Definition at line 380 of file generator.hpp.

◆ grow_direction

Definition at line 29 of file grow_direction.hpp.

◆ gui_theme_map_t

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

Definition at line 88 of file gui_definition.hpp.

◆ resolution_definition_const_ptr

Definition at line 75 of file widget_definition.hpp.

◆ resolution_definition_ptr

Definition at line 72 of file widget_definition.hpp.

◆ styled_widget_definition_ptr

Definition at line 95 of file widget_definition.hpp.

◆ tbase

Definition at line 96 of file matrix.hpp.

◆ 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 68 of file static_registry.hpp.

◆ widget_data

using gui2::widget_data = typedef std::map<std::string, widget_item>

Definition at line 36 of file widget.hpp.

◆ widget_item

using gui2::widget_item = typedef std::map<std::string, t_string>

Definition at line 33 of file widget.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 45 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 29 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 291 of file gui_definition.cpp.

References current_gui, and registered_widget_types().

Referenced by lua_gui2::intf_add_widget_definition().

◆ add_timer()

std::size_t gui2::add_timer ( const std::chrono::milliseconds &  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 123 of file timer.cpp.

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

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

◆ 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< t_string(const 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 65 of file status_label_helper.hpp.

References gui2::event::connect_signal_notify_modified(), gui2::widget::find_widget(), and gui2::styled_widget::set_label().

◆ build_single_widget_instance()

template<typename T >
std::unique_ptr<T> gui2::build_single_widget_instance ( const config cfg = {})

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.

This is equivalent to calling build() on the result of create_widget_builder.

Template Parameters
TThe final widget type. The widget pointer will be cast to this.
Parameters
cfgData config to pass to the widget's builder.
Returns
A shared_ptr of the given type containing the newly build widget.

Definition at line 111 of file window_builder.hpp.

◆ build_single_widget_instance_helper()

std::unique_ptr< widget > gui2::build_single_widget_instance_helper ( const std::string &  type,
const config cfg 
)

Implementation detail for build_single_widget_instance.

Do not use directly!

Parameters
typeString ID of the widget type.
cfgData config to pass to the widget's builder.
Returns
A shared_ptr of the base widget type containing the newly built widget.

Definition at line 96 of file window_builder.cpp.

References VALIDATE, and widget_builder_lookup().

◆ 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 58 of file window_builder.cpp.

References config::all_children_count(), FAIL, 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_view gui2::debug_truncate ( std::string_view  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 148 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::rich_label::get_parsed_text(), 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.
Returns
The color.

Definition at line 48 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.
Returns
The font style.

Definition at line 31 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.
Returns
The text alignment.

Definition at line 89 of file helper.cpp.

References ERR_GUI_E.

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

◆ decode_text_style()

PangoStyle gui2::decode_text_style ( const std::string &  style)

Converts a text style string to a PangoStyle.

Parameters
styleA style string, possible values: "normal", "italic", "oblique
Returns
The corresponding PangoStyle.

Definition at line 74 of file helper.cpp.

References ERR_GUI_E.

Referenced by gui2::text_shape::draw().

◆ decode_text_weight()

PangoWeight gui2::decode_text_weight ( const std::string &  weight)

Converts a text weight string to a PangoWeight.

Parameters
weightA weight string, possible values: "thin", "light", "normal", "semibold", "bold", "heavy"
Returns
The corresponding PangoWeight.

Definition at line 53 of file helper.cpp.

References ERR_GUI_E.

Referenced by gui2::text_shape::draw().

◆ default_status_value_getter()

template<typename T >
t_string gui2::default_status_value_getter ( const T &  w)

Definition at line 28 of file status_label_helper.hpp.

References _(), and w.

◆ 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 236 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.

Definition at line 104 of file helper.cpp.

Referenced by gui2::rich_label::default_text_config(), and 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 197 of file timer.cpp.

References DBG_GUI_E, get_timers(), LOG_GUI_E, and timers_mutex.

Referenced by controller_base::handle_event(), and gui2::event::sdl_event_handler::handle_event().

◆ 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 203 of file gui_definition.cpp.

References current_gui, default_gui, FAIL, LOG_GUI_G, draw::point(), and VALIDATE.

Referenced by gui2::text_box_base::text_box_base().

◆ get_hp_tooltip()

static std::string gui2::get_hp_tooltip ( const utils::string_map_res 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_screen_size_variables() [1/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 135 of file helper.cpp.

References get_screen_size_variables().

◆ get_screen_size_variables() [2/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 125 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, gui2::settings::screen_pitch_microns, and gui2::settings::screen_width.

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

◆ get_timers()

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

The active timers.

Definition at line 40 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 256 of file gui_definition.cpp.

References current_gui, default_gui, draw::point(), gui2::settings::update_screen_size_variables(), VALIDATE, gui2::builder_window::window_resolution::window_height, and gui2::builder_window::window_resolution::window_width.

◆ 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 1084 of file handler.cpp.

References open_window_stack.

Referenced by controller_base::handle_event(), controller_base::process(), and display::queue_rerender().

◆ 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 347 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 120 of file helper.cpp.

References VGETTEXT.

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

◆ 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()

std::map< std::string, registered_widget_parser > & 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 BOOST_AUTO_TEST_CASE(), gui2::gui_definition::gui_definition(), and register_window().

◆ 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 1074 of file handler.cpp.

References open_window_stack.

Referenced by intf_show_dialog(), and gui2::dialogs::modeless_dialog::show().

◆ 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 308 of file gui_definition.cpp.

References current_gui.

Referenced by lua_kernel_base::~lua_kernel_base().

◆ remove_timer()

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

◆ 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,
std::unique_ptr< 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 1103 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.

◆ 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 201 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(), editor::editor_controller::do_execute_command(), gui2::dialogs::mp_lobby::enter_game(), gui2::dialogs::addon_manager::fetch_addons_list(), editor::context_manager::generate_map_dialog(), gui2::dialogs::title_screen::init_callbacks(), 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::addon_manager::publish_addon(), gui2::dialogs::game_cache_options::purge_cache_callback(), gui2::dialogs::mp_match_history::request_history(), savegame::savegame::save_game(), gui2::dialogs::screenshot_notification::save_screenshot(), sp::select_campaign(), wml_exception::show(), play_controller::to_config(), addons_client::try_fetch_addon(), gui2::dialogs::addon_manager::uninstall_addon(), and gui2::dialogs::editor_edit_pbl::validate().

◆ show_message() [1/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 160 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(), wfl::msg(), 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_message() [2/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 148 of file message.cpp.

References wfl::msg(), 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(), play_controller::check_next_scenario_is_known(), 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(), editor::editor_controller::do_execute_command(), do_gameloop(), addons_client::do_resolve_addon_dependencies(), events::menu_handler::do_search(), events::console_handler::do_undiscover(), events::console_handler::do_unsafe_lua(), network::download(), events::menu_handler::end_turn(), gui2::dialogs::mp_lobby::enter_game(), gui2::dialogs::migrate_version_selection::execute(), gui2::dialogs::addon_manager::execute_default_action(), ng::depcheck::manager::failure_dialog(), playsingle_controller::hotkey_handler::load_autosave(), editor::map_context::map_context(), gui2::dialogs::file_dialog::on_file_delete_cmd(), campaign_controller::play_game(), gui2::dialogs::addon_manager::publish_addon(), gui2::dialogs::game_cache_options::purge_cache_callback(), gui2::dialogs::editor_edit_unit::quit_confirmation(), gui2::dialogs::game_version::report_issue(), editor::context_manager::save_map_as_dialog(), editor::context_manager::save_scenario_as_dialog(), gui2::dialogs::custom_tod::select_file(), gui2::dialogs::editor_edit_unit::select_file(), show_error_message(), gui2::dialogs::game_version::show_manual(), lua_gui2::show_message_box(), quit_confirmation::show_prompt(), gui2::label::signal_handler_left_button_click(), gui2::multiline_text::signal_handler_left_button_down(), gui2::label::signal_handler_right_button_click(), hotkey::command_executor::surrender_game(), and gui2::dialogs::editor_edit_pbl::validate().

◆ 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 72 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 
)

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?

Definition at line 60 of file transient_message.cpp.

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

Referenced by gui2::dialogs::preferences_dialog::add_friend_list_entry(), gui2::dialogs::preferences_dialog::add_hotkey_callback(), editor::location_palette::adjust_size(), editor::context_manager::apply_mask_dialog(), carryover_show_gold(), 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(), playsingle_controller::do_end_level(), 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(), 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_init(), gui2::dialogs::mp_create_game::pre_show(), gui2::dialogs::addon_manager::publish_addon(), events::menu_handler::recall(), events::menu_handler::recruit(), actions::undo_list::redo(), gui2::dialogs::preferences_dialog::remove_friend_list_entry(), gui2::dialogs::preferences_dialog::remove_hotkey_callback(), savegame::savegame::save_game(), events::menu_handler::save_map(), editor::context_manager::save_map_as_dialog(), editor::context_manager::save_scenario_as_dialog(), editor::map_context::save_schedule(), events::mouse_handler::show_attack_dialog(), play_controller::show_objectives(), lua_gui2::show_popup_dialog(), prefs::show_theme_dialog(), show_transient_error_message(), playsingle_controller::show_turn_dialog(), and gui2::dialogs::editor_edit_unit::write().

◆ swap_grid()

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

◆ switch_theme()

void gui2::switch_theme ( const std::string &  current_theme)

◆ 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(), id, TIMER_EVENT, and timers_mutex.

Referenced by add_timer().

◆ widget_builder_lookup()

std::map< std::string, widget_builder_func_t > & 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

◆ current_gui

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

Iterator pointing to the current GUI.

Definition at line 31 of file gui_definition.cpp.

Referenced by add_single_widget_definition(), get_control(), get_window_builder(), remove_single_widget_definition(), and switch_theme().

◆ default_gui

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

Iterator pointing to the default GUI.

Definition at line 32 of file gui_definition.cpp.

Referenced by get_control(), get_window_builder(), init(), and switch_theme().

◆ 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 52 of file timer.cpp.

Referenced by gui2::executor::executor(), remove_timer(), and 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.

Referenced by gui2::executor::executor(), remove_timer(), and gui2::executor::~executor().

◆ guis

gui_theme_map_t gui2::guis

Map of all known GUIs.

Definition at line 30 of file gui_definition.cpp.

Referenced by init(), gui2::dialogs::preferences_dialog::set_gui2_theme_list(), and switch_theme().

◆ log_gui_draw

lg::log_domain gui2::log_gui_draw ( "gui/draw"  )

◆ log_gui_event

lg::log_domain gui2::log_gui_event ( "gui/event"  )

Definition at line 34 of file log.hpp.

◆ log_gui_general

lg::log_domain gui2::log_gui_general ( "gui/general"  )

Definition at line 40 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 ( "gui/iterator"  )

Definition at line 46 of file log.hpp.

◆ log_gui_layout

lg::log_domain gui2::log_gui_layout ( "gui/layout"  )

◆ log_gui_lifetime

lg::log_domain gui2::log_gui_lifetime ( "gui/lifetime"  )

Definition at line 60 of file log.hpp.

◆ log_gui_parse

lg::log_domain gui2::log_gui_parse ( "gui/parse"  )

Definition at line 65 of file log.hpp.

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

◆ new_widgets

bool gui2::new_widgets = false

Do we wish to use the new library or not.

Definition at line 23 of file settings.cpp.

Referenced by game_launcher::game_launcher(), and gui2::widget::set_visible().

◆ next_timer_id

std::size_t gui2::next_timer_id = 0
static

Ids for the timers.

Definition at line 37 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 1072 of file handler.cpp.

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

◆ timers_mutex

std::mutex gui2::timers_mutex

Definition at line 54 of file timer.cpp.

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