The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
styled_widget.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2008 - 2025
3 by Mark de Wever <koraq@xs4all.nl>
4 Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY.
12
13 See the COPYING file for more details.
14*/
15
16#define GETTEXT_DOMAIN "wesnoth-lib"
17
19
21#include "formatter.hpp"
23#include "gettext.hpp"
27#include "gui/core/log.hpp"
31#include "sdl/rect.hpp"
32#include "wml_exception.hpp"
33#include <functional>
34
35#include <algorithm>
36#include <iomanip>
37
38#define LOG_SCOPE_HEADER \
39 "styled_widget(" + get_control_type() + ") [" + id() + "] " + __func__
40#define LOG_HEADER LOG_SCOPE_HEADER + ':'
41
42namespace gui2
43{
44
45// ------------ WIDGET -----------{
46
48 const std::string& control_type)
49 : widget(builder)
50 , definition_(builder.definition)
51 , label_(builder.label_string)
52 , use_markup_(builder.use_markup)
53 , use_tooltip_on_label_overflow_(builder.use_tooltip_on_label_overflow)
54 , tooltip_(builder.tooltip)
55 , help_message_(builder.help)
56 , config_(get_control(control_type, definition_))
57 , canvases_(config_->state.begin(), config_->state.end())
58 , renderer_()
59 , text_alignment_(PANGO_ALIGN_LEFT)
60 , text_ellipse_mode_(PANGO_ELLIPSIZE_END)
61 , shrunken_(false)
62{
63 // Initialize all the canvas variables.
65
66 // Enable hover behavior if a tooltip was provided.
68
69 connect_signal<event::SHOW_TOOLTIP>(std::bind(
70 &styled_widget::signal_handler_show_tooltip, this, std::placeholders::_2, std::placeholders::_3, std::placeholders::_5));
71
72 connect_signal<event::SHOW_HELPTIP>(std::bind(
73 &styled_widget::signal_handler_show_helptip, this, std::placeholders::_2, std::placeholders::_3, std::placeholders::_5));
74
75 connect_signal<event::NOTIFY_REMOVE_TOOLTIP>(std::bind(
76 &styled_widget::signal_handler_notify_remove_tooltip, this, std::placeholders::_2, std::placeholders::_3));
77}
78
80{
81 /** @todo document this feature on the wiki. */
82 /** @todo do we need to add the debug colors here as well? */
83 widget_item::const_iterator itor = data.find("id");
84 if(itor != data.end()) {
85 set_id(itor->second);
86 }
87
88 itor = data.find("linked_group");
89 if(itor != data.end()) {
90 set_linked_group(itor->second);
91 }
92
93 itor = data.find("label");
94 if(itor != data.end()) {
95 set_label(itor->second);
96 }
97
98 itor = data.find("tooltip");
99 if(itor != data.end()) {
100 set_tooltip(itor->second);
101 }
102
103 itor = data.find("help");
104 if(itor != data.end()) {
105 set_help_message(itor->second);
106 }
107
108 itor = data.find("use_markup");
109 if(itor != data.end()) {
110 set_use_markup(utils::string_bool(itor->second));
111 }
112
113 itor = data.find("text_alignment");
114 if(itor != data.end()) {
116 }
117}
118
123
125{
126 return std::make_unique<iteration::walker::widget>(*this);
127}
128
130{
131 assert(config_);
132
133 point result(config_->min_width, config_->min_height);
134
135 DBG_GUI_L << LOG_HEADER << " result " << result << ".";
136 return result;
137}
138
140{
141 assert(config_);
142
143 point result(config_->default_width, config_->default_height);
144
145 DBG_GUI_L << LOG_HEADER << " result " << result << ".";
146 return result;
147}
148
150{
151 assert(config_);
152
153 point result(config_->max_width, config_->max_height);
154
155 DBG_GUI_L << LOG_HEADER << " result " << result << ".";
156 return result;
157}
158
160{
161 return 0;
162}
163
165{
166 return false;
167}
168
173
174void styled_widget::layout_initialize(const bool full_initialization)
175{
176 // Inherited.
177 widget::layout_initialize(full_initialization);
178
179 if(full_initialization) {
180 shrunken_ = false;
181 }
182}
183
184void styled_widget::request_reduce_width(const unsigned maximum_width)
185{
186 assert(config_);
187
188 if(!label_.empty() && can_wrap()) {
189
191 point(), point(maximum_width - config_->text_extra_width, 0));
192
193 size.x += config_->text_extra_width;
194 size.y += config_->text_extra_height;
195
196 set_layout_size(size);
197
198 DBG_GUI_L << LOG_HEADER << " label '" << debug_truncate(label_.str())
199 << "' maximum_width " << maximum_width << " result " << size
200 << ".";
201
202 } else if(label_.empty() || text_can_shrink()) {
203 point size = get_best_size();
204 point min_size = get_config_minimum_size();
205 size.x = std::min(size.x, std::max<int>(maximum_width, min_size.x));
206 set_layout_size(size);
207
208 DBG_GUI_L << LOG_HEADER << " styled_widget " << id()
209 << " maximum_width " << maximum_width << " result " << size
210 << ".";
211 } else {
212 DBG_GUI_L << LOG_HEADER << " label '" << debug_truncate(label_.str())
213 << "' failed; either no label or wrapping not allowed.";
214 }
215}
216
217void styled_widget::request_reduce_height(const unsigned maximum_height)
218{
219 if(label_.empty()) {
220 point size = get_best_size();
221 point min_size = get_config_minimum_size();
222 size.y = std::min(size.y, std::max<int>(maximum_height, min_size.y));
223 set_layout_size(size);
224
225 DBG_GUI_L << LOG_HEADER << " styled_widget " << id()
226 << " maximum_height " << maximum_height << " result " << size
227 << ".";
228 }
229}
230
232{
233 assert(config_);
234 if(label_.empty()) {
235 DBG_GUI_L << LOG_HEADER << " empty label return default.";
237 }
238
239 const point minimum = get_config_default_size();
240 const point maximum = get_config_maximum_size();
241
242 /**
243 * @todo The value send should subtract the border size
244 * and read it after calculation to get the proper result.
245 */
246 point result = get_best_text_size(minimum, maximum);
247 DBG_GUI_L << LOG_HEADER << " label '" << debug_truncate(label_.str())
248 << "' result " << result << ".";
249 return result;
250}
251
252void styled_widget::place(const point& origin, const point& size)
253{
254 // resize canvasses
255 for(auto & canvas : canvases_)
256 {
257 canvas.set_size(size);
258 }
259
260 // Note we assume that the best size has been queried but otherwise it
261 // should return false.
263 && tooltip_.empty()) {
264
266 }
267
268 // inherited
269 widget::place(origin, size);
270
271 // update the state of the canvas after the sizes have been set.
273}
274
275widget* styled_widget::find_at(const point& coordinate, const bool must_be_active)
276{
277 return (widget::find_at(coordinate, must_be_active)
278 && (!must_be_active || get_active()))
279 ? this
280 : nullptr;
281}
282
283const widget* styled_widget::find_at(const point& coordinate,
284 const bool must_be_active) const
285{
286 return (widget::find_at(coordinate, must_be_active)
287 && (!must_be_active || get_active()))
288 ? this
289 : nullptr;
290}
291
292widget* styled_widget::find(const std::string_view id, const bool must_be_active)
293{
294 return (widget::find(id, must_be_active)
295 && (!must_be_active || get_active()))
296 ? this
297 : nullptr;
298}
299
300const widget* styled_widget::find(const std::string_view id, const bool must_be_active)
301 const
302{
303 return (widget::find(id, must_be_active)
304 && (!must_be_active || get_active()))
305 ? this
306 : nullptr;
307}
308
310{
311 if(label == label_) {
312 return;
313 }
314
315 label_ = label;
318 queue_redraw();
319
320 // FIXME: This isn't the most elegant solution. Typically, we don't rely on the text rendering
321 // cache for anything except size calculations, but since we have link awareness now we need to
322 // update its text else `get_label_link` will return old results. I'm not actually sure why the
323 // results seem to only remain one invocation of `set_label` behind the current text, but that
324 // is what testing revealed (see https://github.com/wesnoth/wesnoth/pull/5363).
325 //
326 // -- vultraz, 2020-12-17
328}
329
330void styled_widget::set_use_markup(bool use_markup)
331{
332 if(use_markup == use_markup_) {
333 return;
334 }
335
336 use_markup_ = use_markup;
338 queue_redraw();
339}
340
341void styled_widget::set_text_alignment(const PangoAlignment text_alignment)
342{
343 if(text_alignment_ == text_alignment) {
344 return;
345 }
346
347 text_alignment_ = text_alignment;
349 queue_redraw();
350}
351
352void styled_widget::set_text_ellipse_mode(const PangoEllipsizeMode ellipse_mode)
353{
354 if(text_ellipse_mode_ == ellipse_mode) {
355 return;
356 }
357
358 text_ellipse_mode_ = ellipse_mode;
360 queue_redraw();
361}
362
364{
365 const int max_width = get_text_maximum_width();
366 const int max_height = get_text_maximum_height();
367
368 // set label in canvases
369 for(auto & canvas : canvases_)
370 {
373 canvas.set_variable("text_link_aware", wfl::variant(get_link_aware()));
374
375 // Possible TODO: consider making a formula_callable for colors.
376 color_t link_color = get_link_color();
377 std::vector<wfl::variant> link_color_as_list {
378 wfl::variant(link_color.r),
379 wfl::variant(link_color.g),
380 wfl::variant(link_color.b),
381 wfl::variant(link_color.a)
382 };
383
384 canvas.set_variable("text_link_color", wfl::variant(link_color_as_list));
385 canvas.set_variable("text_alignment",
387 canvas.set_variable("text_maximum_width", wfl::variant(max_width));
388 canvas.set_variable("text_maximum_height", wfl::variant(max_height));
390 canvas.set_variable("text_characters_per_line",
392 }
393}
394
396{
397 if (cached_text_font_size_ == 0) {
398 assert(config_);
399
401 }
403}
404
406{
407 assert(config_);
408
409 return get_width() - config_->text_extra_width;
410}
411
413{
414 assert(config_);
415
416 return get_height() - config_->text_extra_height;
417}
418
420{
421 DBG_GUI_D << LOG_HEADER << " label '" << debug_truncate(label_.str()) << "' size "
422 << get_rectangle() << ".";
423
424 if(!get_canvas(get_state()).update_blur(get_rectangle())) {
425 return false;
426 }
428 return true;
429}
430
432{
433 /* DO NOTHING */
434 return true;
435}
436
437point styled_widget::get_best_text_size(point minimum_size, point maximum_size) const
438{
440
441 assert(!label_.empty());
442
443 // Try with the minimum wanted size.
444 const int maximum_width = maximum_size.x;
445
446 /*
447 * NOTE: text rendering does *not* happen here. That happens in the text_shape
448 * canvas class. Instead, this just leverages the pango text rendering engine to
449 * calculate the area this widget will need to successfully render its text later.
450 */
454 .set_family_class(config_->text_font_family)
456 .set_font_style(config_->text_font_style)
458 .set_maximum_width(maximum_width)
462
463 if(get_characters_per_line() != 0 && !can_wrap()) {
465 << " Limited the number of characters per line, "
466 << "but wrapping is not set, output may not be as expected.";
467 }
468
469 DBG_GUI_L << LOG_HEADER << "\n"
470 << std::boolalpha
471 << "Label: '" << debug_truncate(label_.str()) << "'\n\n"
472 << "Status:\n"
473 << "minimum_size: " << minimum_size << "\n"
474 << "maximum_size: " << maximum_size << "\n"
475 << "can_wrap: " << can_wrap() << "\n"
476 << "characters_per_line: " << get_characters_per_line() << "\n"
477 << "truncated: " << renderer_.is_truncated() << "\n"
478 << "renderer size: " << renderer_.get_size() << "\n"
479 << std::noboolalpha;
480
481 const point border(config_->text_extra_width,
482 config_->text_extra_height);
483
484 // If doesn't fit try the maximum.
485 if(renderer_.is_truncated() && !can_wrap()) {
486 // FIXME if maximum size is defined we should look at that
487 // but also we don't adjust for the extra text space yet!!!
488 maximum_size = point(config_->max_width,
489 config_->max_height);
490
491 renderer_.set_maximum_width(maximum_size.x ? maximum_size.x - border.x : -1);
492 }
493
494 // Get the resulting size.
495 point size = renderer_.get_size() + border;
496 size = point(
497 std::max(size.x, minimum_size.x),
498 std::max(size.y, minimum_size.y));
499
500 DBG_GUI_L << LOG_HEADER << " label '" << debug_truncate(label_.str())
501 << "' result " << size << ".";
502 return size;
503}
504
506 bool& handled,
507 const point& location)
508{
509 DBG_GUI_E << LOG_HEADER << ' ' << event << ".";
510
511 if(!tooltip_.empty()) {
512 std::string tip = tooltip_;
513 if(!help_message_.empty()) {
514 utils::string_map symbols;
515 symbols["hotkey"] = hotkey::get_names(
517
521
523 handled = fire(event::MESSAGE_SHOW_TOOLTIP, *this, message);
524 }
525}
526
528 bool& handled,
529 const point& location)
530{
531 DBG_GUI_E << LOG_HEADER << ' ' << event << ".";
532
533 if(!help_message_.empty()) {
535 handled = fire(event::MESSAGE_SHOW_HELPTIP, *this, message);
536 }
537}
538
540 bool& handled)
541{
542 DBG_GUI_E << LOG_HEADER << ' ' << event << ".";
543
544 /*
545 * This makes the class know the tip code rather intimately. An
546 * alternative is to add a message to the window to remove the tip.
547 * Might be done later.
548 */
550
551 handled = true;
552}
553
554std::string styled_widget::get_label_token(const point& position, std::string_view delim) const
555{
556 return renderer_.get_token(position, delim);
557}
558
559std::string styled_widget::get_label_link(const point& position) const
560{
561 // Without the following line, bounds for links in the case of non-left aligned text
562 // are incorrectly calculated. See issue #8915.
563 if(!label_.empty()) {
565 }
566
567 // Text renderer has no idea of the origin of text, i.e., where the resultant
568 // texture will get blitted. To it, every text chunk sent to it starts at (0,0).
569 // So the mouse coordinates need to be translated by the widget's origin.
570 return renderer_.get_link(position - get_origin());
571}
572
573// }---------- BUILDER -----------{
574
575namespace implementation
576{
577
580 , definition(cfg["definition"])
581 , label_string(cfg["label"].t_str())
582 , tooltip(cfg["tooltip"].t_str())
583 , help(cfg["help"].t_str())
584 , use_tooltip_on_label_overflow(true)
585 , use_markup(cfg["use_markup"].to_bool(false))
586{
587 if(definition.empty()) {
588 definition = "default";
589 }
590
592 help.empty() || !tooltip.empty(),
593 _("Found a widget with a helptip and without a tooltip."),
594 formatter() << "id '" << id << "' label '" << label_string
595 << "' helptip '" << help << "'.");
596
597
598 DBG_GUI_P << "Window builder: found styled_widget with id '" << id
599 << "' and definition '" << definition << "'.";
600}
601
602std::unique_ptr<widget> builder_styled_widget::build(const replacements_map& /*replacements*/) const
603{
604 return build();
605}
606
607} // namespace implementation
608
609// }------------ END --------------
610
611} // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition config.hpp:157
pango_text & set_font_style(const FONT_STYLE font_style)
Definition text.cpp:381
point get_size()
Returns the size of the text, in drawing coordinates.
Definition text.cpp:154
pango_text & set_characters_per_line(const unsigned characters_per_line)
Definition text.cpp:416
std::string get_token(const point &position, std::string_view delimiters=" \n\r\t") const
Gets the largest collection of characters, including the token at position, and not including any cha...
Definition text.cpp:245
pango_text & set_family_class(font::family_class fclass)
Definition text.cpp:359
pango_text & set_ellipse_mode(const PangoEllipsizeMode ellipse_mode)
Definition text.cpp:452
pango_text & set_alignment(const PangoAlignment alignment)
Definition text.cpp:472
pango_text & set_font_size(unsigned font_size)
Definition text.cpp:369
pango_text & set_link_aware(bool b)
Definition text.cpp:495
bool set_text(const std::string &text, const bool markedup)
Sets the text to render.
Definition text.cpp:333
bool is_truncated() const
Has the text been truncated? This happens if it exceeds max width or height.
Definition text.cpp:162
pango_text & set_maximum_width(int width)
Definition text.cpp:400
pango_text & set_link_color(const color_t &color)
Definition text.cpp:504
std::string get_link(const point &position) const
Checks if position points to a character in a link in the text, returns it if so, empty string otherw...
Definition text.cpp:268
std::ostringstream wrapper.
Definition formatter.hpp:40
A simple canvas which can be drawn upon.
Definition canvas.hpp:45
void set_variable(const std::string &key, wfl::variant &&value)
Definition canvas.hpp:165
void draw()
Draw the canvas' shapes onto the screen.
Definition canvas.cpp:786
void set_size(const point &size)
Definition canvas.cpp:862
Main class to show messages to the user.
Definition message.hpp:36
At the moment two kinds of tips are known:
Definition tooltip.cpp:41
bool fire(const ui_event event, widget &target)
Fires an event which has no extra parameters.
void set_wants_mouse_hover(const bool hover=true)
t_string help_message_
Tooltip text.
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
void set_tooltip(const t_string &tooltip)
bool use_markup_
Use markup for the label?
PangoEllipsizeMode text_ellipse_mode_
The ellipsize mode of the text in a styled_widget.
font::pango_text renderer_
Text renderer object used for size calculations.
virtual unsigned get_state() const =0
Returns the id of the state.
point get_config_maximum_size() const
Gets the best size as defined in the config.
t_string tooltip_
Tooltip text.
bool use_tooltip_on_label_overflow_
If the text doesn't fit on the label should the text be used as tooltip?
widget * find(const std::string_view id, const bool must_be_active) override
See widget::find.
int get_text_maximum_width() const
Returns the maximum width available for the text.
virtual unsigned get_characters_per_line() const
Returns the number of characters per line.
canvas & get_canvas(const unsigned index)
point get_config_minimum_size() const
Gets the minimum size as defined in the config.
std::string get_label_link(const point &position) const
int get_text_maximum_height() const
Returns the maximum height available for the text.
void signal_handler_show_helptip(const event::ui_event event, bool &handled, const point &location)
virtual void request_reduce_width(const unsigned maximum_width) override
See widget::request_reduce_width.
virtual void request_reduce_height(const unsigned maximum_height) override
See widget::request_reduce_height.
virtual void layout_initialize(const bool full_initialization) override
See widget::layout_initialize.
virtual void update_canvas()
Updates the canvas(ses).
virtual bool get_link_aware() const
Returns whether the label should be link_aware, in in rendering and in searching for links with get_l...
void set_help_message(const t_string &help_message)
point get_config_default_size() const
Gets the default size as defined in the config.
std::vector< canvas > canvases_
Holds all canvas objects for a styled_widget.
PangoEllipsizeMode get_text_ellipse_mode() const
Get the text's ellipsize mode.
virtual color_t get_link_color() const
Returns the color string to be used with links.
void signal_handler_notify_remove_tooltip(const event::ui_event event, bool &handled)
bool shrunken_
Is the widget smaller as it's best size?
PangoAlignment text_alignment_
The alignment of the text in a styled_widget.
virtual void set_members(const widget_item &data)
Sets the members of the styled_widget.
virtual bool impl_draw_background() override
See widget::impl_draw_background.
point get_best_text_size(point minimum_size, point maximum_size={0, 0}) const
Gets the best size for a text.
virtual void place(const point &origin, const point &size) override
See widget::place.
virtual void set_text_alignment(const PangoAlignment text_alignment)
virtual bool get_active() const =0
Gets the active state of the styled_widget.
resolution_definition_ptr config_
Contains the pointer to the configuration.
virtual iteration::walker_ptr create_walker() override
See widget::create_walker.
std::string get_label_token(const point &position, std::string_view delimiters=" \n\r\t") const
Exposes font::pango_text::get_token, for the text label of this styled_widget.
virtual bool impl_draw_foreground() override
See widget::impl_draw_foreground.
bool disable_click_dismiss() const override
See widget::disable_click_dismiss.
virtual void set_label(const t_string &text)
virtual bool text_can_shrink()
Gets whether a widget can shrink past its optimal size even if it's text-based (such as labels);.
void set_text_ellipse_mode(const PangoEllipsizeMode ellipse_mode)
void signal_handler_show_tooltip(const event::ui_event event, bool &handled, const point &location)
styled_widget(const implementation::builder_styled_widget &builder, const std::string &control_type)
Constructor.
virtual void set_use_markup(bool use_markup)
t_string label_
Contain the non-editable text associated with styled_widget.
virtual point calculate_best_size() const override
See widget::calculate_best_size.
unsigned int get_text_font_size() const
Resolves and returns the text_font_size.
unsigned int cached_text_font_size_
Contains the evaluated text_font_size from the configuration.
Base class for all widgets.
Definition widget.hpp:55
void set_layout_size(const point &size)
Definition widget.cpp:346
point get_best_size() const
Gets the best size for the widget.
Definition widget.cpp:203
virtual void place(const point &origin, const point &size)
Places the widget.
Definition widget.cpp:248
void set_id(const std::string &id)
Definition widget.cpp:98
virtual void layout_initialize(const bool full_initialization)
How the layout engine works.
Definition widget.cpp:177
void set_linked_group(const std::string &linked_group)
Definition widget.cpp:356
void queue_redraw()
Indicates that this widget should be redrawn.
Definition widget.cpp:464
visibility get_visible() const
Definition widget.cpp:506
point get_origin() const
Returns the screen origin of the widget.
Definition widget.cpp:311
virtual widget * find(const std::string_view id, const bool must_be_active)
Returns a widget with the wanted id.
Definition widget.cpp:560
unsigned get_width() const
Definition widget.cpp:336
point get_size() const
Returns the size of the widget.
Definition widget.cpp:316
unsigned get_height() const
Definition widget.cpp:341
const std::string & id() const
Definition widget.cpp:110
@ visible
The user sets the widget visible, that means:
rect get_rectangle() const
Gets the bounding rectangle of the widget on the screen.
Definition widget.cpp:321
virtual widget * find_at(const point &coordinate, const bool must_be_active)
Returns the widget at the wanted coordinates.
Definition widget.cpp:549
virtual bool can_wrap() const
Can the widget wrap.
Definition widget.cpp:225
bool empty() const
Definition tstring.hpp:200
const std::string & str() const
Definition tstring.hpp:204
This file contains the definitions for the gui2::event::message class.
#define LOG_HEADER
@ border
The border of the map.
const config * cfg
static std::string _(const char *str)
Definition gettext.hpp:100
Define the common log macros for the gui toolkit.
#define DBG_GUI_L
Definition log.hpp:55
#define DBG_GUI_P
Definition log.hpp:66
#define WRN_GUI_L
Definition log.hpp:57
#define DBG_GUI_E
Definition log.hpp:35
#define DBG_GUI_D
Definition log.hpp:29
#define LOG_SCOPE_HEADER
Definition button.cpp:34
#define log_scope2(domain, description)
Definition log.hpp:276
const color_t YELLOW_COLOR
void remove()
Removes a tip.
Definition tooltip.cpp:94
ui_event
The event sent to the dispatcher.
Definition handler.hpp:115
@ MESSAGE_SHOW_TOOLTIP
Definition handler.hpp:183
@ MESSAGE_SHOW_HELPTIP
Definition handler.hpp:184
std::unique_ptr< class walker_base > walker_ptr
Definition widget.hpp:44
t_string has_helptip_message
Definition settings.cpp:55
Generic file dialog.
std::string_view debug_truncate(std::string_view text)
Returns a truncated version of the text.
Definition helper.cpp:172
wfl::map_formula_callable get_screen_size_variables()
Gets a formula object with the screen size.
Definition helper.cpp:159
std::map< std::string, t_string > widget_item
Definition widget.hpp:33
PangoAlignment decode_text_alignment(const std::string &alignment)
Converts a text alignment string to a text alignment.
Definition helper.cpp:84
lg::log_domain log_gui_layout("gui/layout")
Definition log.hpp:54
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.
std::string encode_text_alignment(const PangoAlignment alignment)
Converts a PangoAlignment to its string representation.
Definition helper.cpp:130
std::string get_names(const std::string &id)
Returns a comma-separated string of hotkey names.
const hotkey_command & get_hotkey_command(std::string_view command)
Returns the hotkey_command with the given id.
Contains the implementation details for lexical_cast and shouldn't be used directly.
std::string interpolate_variables_into_string(const std::string &str, const string_map *const symbols)
Function which will interpolate variables, starting with '$' in the string 'str' with the equivalent ...
bool string_bool(const std::string &str, bool def)
Convert no, false, off, 0, 0.0 to false, empty to def, and others to true.
std::map< std::string, t_string > string_map
std::string_view data
Definition picture.cpp:188
Contains the SDL_Rect helper code.
This file contains the settings handling of the widget library.
The basic class for representing 8-bit RGB or RGBA colour values.
Definition color.hpp:51
Contains the info needed to instantiate a widget.
std::map< std::string, std::shared_ptr< builder_widget > > replacements_map
The replacements type is used to define replacement types.
The message for MESSAGE_SHOW_HELPTIP.
Definition message.hpp:77
The message for MESSAGE_SHOW_TOOLTIP.
Definition message.hpp:59
virtual std::unique_ptr< widget > build() const=0
std::string definition
Parameters for the styled_widget.
Holds a 2D point.
Definition point.hpp:25
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
#define VALIDATE_WITH_DEV_MESSAGE(cond, message, dev_message)