15 #define GETTEXT_DOMAIN "wesnoth-lib" 41 auto win = std::make_unique<window>(definition);
45 if(win->has_linked_size_group(
lg.id)) {
51 win->init_linked_size_group(
lg.id,
lg.fixed_width,
lg.fixed_height);
60 win->init_grid(*conf->grid);
61 win->finalize(*definition.
grid);
63 win->init_grid(*definition.
grid);
66 win->add_to_keyboard_chain(win.get());
71 std::unique_ptr<window>
build(
const std::string&
type)
81 , linked_group(cfg[
"linked_group"])
82 , debug_border_mode(cfg[
"debug_border_mode"])
83 , debug_border_color(
decode_color(cfg[
"debug_border_color"]))
90 VALIDATE(children.size() == 1,
"Grid cell does not have exactly 1 child.");
93 return std::make_shared<builder_grid>(
grid);
96 if(
const config& instance = cfg.
child(
"instance")) {
97 return std::make_shared<implementation::builder_instance>(instance);
101 return std::make_shared<implementation::builder_pane>(
pane);
105 return std::make_shared<implementation::builder_viewport>(
viewport);
109 if(
item.first ==
"window" ||
item.first ==
"tooltip") {
114 return item.second(
c);
131 return builder(cfg)->build();
139 DBG_GUI_P <<
"Window builder: reading data for window " << id_ <<
".\n";
142 VALIDATE(!cfgs.empty(),
_(
"No resolution defined."));
144 for(
const auto&
i : cfgs) {
145 resolutions.emplace_back(
i);
150 : window_width(cfg[
"window_width"])
151 , window_height(cfg[
"window_height"])
152 , automatic_placement(cfg[
"automatic_placement"].to_bool(true))
155 , width(cfg[
"width"])
156 , height(cfg[
"height"])
157 , reevaluate_best_size(cfg[
"reevaluate_best_size"])
161 , maximum_width(cfg[
"maximum_width"], 0u)
162 , maximum_height(cfg[
"maximum_height"], 0u)
163 , click_dismiss(cfg[
"click_dismiss"].to_bool())
164 , definition(cfg[
"definition"])
166 ,
tooltip(cfg.child_or_empty(
"tooltip"),
"tooltip")
167 , helptip(cfg.child_or_empty(
"helptip"),
"helptip")
170 if(!cfg[
"functions"].empty()) {
217 for(
const auto&
c : row.child_range(
"column")) {
231 {
"grid",
id}, {
"row", std::to_string(
rows)}
241 }
else if(col !=
cols) {
242 const t_string msg =
VGETTEXT(
"Grid '$grid' row $row has a differing number of columns ($found found, $expected expected)", {
243 {
"grid",
id}, {
"row", std::to_string(
rows)}, {
"found", std::to_string(col)}, {
"expected", std::to_string(
cols)}
250 DBG_GUI_P <<
"Window builder: grid has " <<
rows <<
" rows and " <<
cols <<
" columns.\n";
261 build(*result, replacements);
273 DBG_GUI_G <<
"Window builder: grid '" <<
id <<
"' has " <<
rows <<
" rows and " <<
cols <<
" columns.\n";
275 for(
unsigned x = 0; x <
rows; ++x) {
278 for(
unsigned y = 0; y <
cols; ++y) {
283 DBG_GUI_G <<
"Window builder: adding child at " << x <<
',' << y <<
".\n";
285 const unsigned int i = x * cols + y;
303 DBG_GUI_G <<
"Window builder: grid '" <<
id <<
"' has " <<
rows <<
" rows and " <<
cols <<
" columns.\n";
305 for(
unsigned x = 0; x <
rows; ++x) {
308 for(
unsigned y = 0; y <
cols; ++y) {
313 DBG_GUI_G <<
"Window builder: adding child at " << x <<
',' << y <<
".\n";
315 const unsigned int i = x * cols + y;
Define the common log macros for the gui toolkit.
virtual grid * build() const override
config & child(config_key_type key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
const builder_window::window_resolution & get_window_builder(const std::string &type)
Returns an reference to the requested builder.
const_all_children_itors all_children_range() const
In-order iteration over all children.
unsigned read_flags(const config &cfg)
Returns the placement/resize flags.
Key Type Default Description window_width unsigned 0 Width of the application window.
void set_row_grow_factor(const unsigned row, const unsigned factor)
Sets the grow factor for a row.
boost::iterator_range< const_all_children_iterator > const_all_children_itors
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
child_itors child_range(config_key_type key)
std::vector< linked_group_definition > parse_linked_group_definitions(const config &cfg)
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
std::function< builder_widget_ptr(const config &)> widget_builder_func_t
Function type alias for register_widget_builder.
static std::string _(const char *str)
std::shared_ptr< builder_widget > builder_widget_ptr
std::string missing_mandatory_wml_key(const std::string §ion, const std::string &key, const std::string &primary_key, const std::string &primary_value)
Returns a standard message for a missing wml key.
std::vector< linked_group_definition > linked_groups
lg::log_domain log_gui_parse("gui/parse")
#define VALIDATE(cond, message)
The macro to use for the validation of WML.
std::vector< unsigned > row_grow_factor
The grow factor for the rows / columns.
This file contains the settings handling of the widget library.
std::vector< unsigned > col_grow_factor
widget * build_single_widget_instance_helper(const std::string &type, const config &cfg)
Helper function to implement build_single_widget_instance.
#define log_scope2(domain, description)
A pane is a container where new members can be added and removed during run-time. ...
builder_grid(const config &cfg)
void set_child(widget *widget, const unsigned row, const unsigned col, const unsigned flags, const unsigned border_size)
Sets a child in the grid.
window_resolution(const config &cfg)
boost::iterator_range< const_child_iterator > const_child_itors
A viewport is an special widget used to view only a part of the widget it 'holds'.
std::vector< unsigned > flags
The flags per grid cell.
void read(const config &cfg)
unsigned get_v_align(const std::string &v_align)
Returns the vertical alignment.
lg::log_domain log_gui_general("gui/general")
void set_rows_cols(const unsigned rows, const unsigned cols)
Wrapper to set_rows and set_cols.
const_all_children_iterator ordered_begin() const
widget_builder_map & widget_builder_lookup()
Returns the list of registered widget builders.
wfl::function_symbol_table functions
std::vector< builder_widget_ptr > widgets
The widgets per grid cell.
std::unique_ptr< window > build(const builder_window::window_resolution &definition)
Builds a window.
void set_column_grow_factor(const unsigned column, const unsigned factor)
Sets the grow factor for a column.
A config object defines a single node in a WML file, with access to child nodes.
unsigned get_h_align(const std::string &h_align)
Returns the horizontal alignment.
base class of top level items, the only item which needs to store the final canvases to draw on...
std::vector< unsigned > border_size
The border size per grid cell.
Contains the implementation details for lexical_cast and shouldn't be used directly.
typed_formula< unsigned > height
std::pair< std::string, unsigned > item
typed_formula< unsigned > width
color_t decode_color(const std::string &color)
Converts a color string to a color.
builder_widget_ptr create_widget_builder(const config &cfg)
Create a widget builder.