The Battle for Wesnoth  1.19.10+dev
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 
20 #include "font/standard_colors.hpp"
21 #include "formatter.hpp"
22 #include "formula/string_utils.hpp"
23 #include "gettext.hpp"
27 #include "gui/core/log.hpp"
28 #include "gui/dialogs/tooltip.hpp"
29 #include "gui/widgets/settings.hpp"
30 #include "hotkey/hotkey_item.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 
42 namespace 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.
64  update_canvas();
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 
120 {
122 }
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 
170 {
171  return font::YELLOW_COLOR;
172 }
173 
174 void 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 
184 void 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 
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()) {
205  size.x = std::min(size.x, std::max<int>(maximum_width, min_size.x));
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 
217 void styled_widget::request_reduce_height(const unsigned maximum_height)
218 {
219  if(label_.empty()) {
222  size.y = std::min(size.y, std::max<int>(maximum_height, min_size.y));
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.";
236  return get_config_default_size();
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 
252 void styled_widget::place(const point& origin, const point& size)
253 {
254  // resize canvasses
255  for(auto & canvas : canvases_)
256  {
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.
272  update_canvas();
273 }
274 
275 widget* 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 
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 
292 widget* 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 
300 const 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;
317  update_canvas();
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 
330 void styled_widget::set_use_markup(bool use_markup)
331 {
332  if(use_markup == use_markup_) {
333  return;
334  }
335 
336  use_markup_ = use_markup;
337  update_canvas();
338  queue_redraw();
339 }
340 
341 void 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;
348  update_canvas();
349  queue_redraw();
350 }
351 
352 void 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;
359  update_canvas();
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  {
372  canvas.set_variable("text_markup", wfl::variant(use_markup_));
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  }
402  return cached_text_font_size_;
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 
437 point 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  */
451  renderer_
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.
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(
518 
521  }
522 
524  handled = fire(event::MESSAGE_SHOW_TOOLTIP, *this, message);
525  }
526 }
527 
529  bool& handled,
530  const point& location)
531 {
532  DBG_GUI_E << LOG_HEADER << ' ' << event << ".";
533 
534  if(!help_message_.empty()) {
536  handled = fire(event::MESSAGE_SHOW_HELPTIP, *this, message);
537  }
538 }
539 
541  bool& handled)
542 {
543  DBG_GUI_E << LOG_HEADER << ' ' << event << ".";
544 
545  /*
546  * This makes the class know the tip code rather intimately. An
547  * alternative is to add a message to the window to remove the tip.
548  * Might be done later.
549  */
551 
552  handled = true;
553 }
554 
555 std::string styled_widget::get_label_token(const point& position, std::string_view delim) const
556 {
557  return renderer_.get_token(position, delim);
558 }
559 
560 std::string styled_widget::get_label_link(const point& position) const
561 {
562  // Without the following line, bounds for links in the case of non-left aligned text
563  // are incorrectly calculated. See issue #8915.
565 
566  // Text renderer has no idea of the origin of text, i.e., where the resultant
567  // texture will get blitted. To it, every text chunk sent to it starts at (0,0).
568  // So the mouse coordinates need to be translated by the widget's origin.
569  return renderer_.get_link(position - get_origin());
570 }
571 
572 // }---------- BUILDER -----------{
573 
574 namespace implementation
575 {
576 
578  : builder_widget(cfg)
579  , definition(cfg["definition"])
580  , label_string(cfg["label"].t_str())
581  , tooltip(cfg["tooltip"].t_str())
582  , help(cfg["help"].t_str())
583  , use_tooltip_on_label_overflow(true)
584  , use_markup(cfg["use_markup"].to_bool(false))
585 {
586  if(definition.empty()) {
587  definition = "default";
588  }
589 
591  help.empty() || !tooltip.empty(),
592  _("Found a widget with a helptip and without a tooltip."),
593  formatter() << "id '" << id << "' label '" << label_string
594  << "' helptip '" << help << "'.");
595 
596 
597  DBG_GUI_P << "Window builder: found styled_widget with id '" << id
598  << "' and definition '" << definition << "'.";
599 }
600 
601 std::unique_ptr<widget> builder_styled_widget::build(const replacements_map& /*replacements*/) const
602 {
603  return build();
604 }
605 
606 } // namespace implementation
607 
608 // }------------ END --------------
609 
610 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:158
pango_text & set_font_style(const FONT_STYLE font_style)
Definition: text.cpp:386
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:421
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:364
pango_text & set_ellipse_mode(const PangoEllipsizeMode ellipse_mode)
Definition: text.cpp:457
pango_text & set_alignment(const PangoAlignment alignment)
Definition: text.cpp:477
pango_text & set_font_size(unsigned font_size)
Definition: text.cpp:374
pango_text & set_link_aware(bool b)
Definition: text.cpp:500
bool set_text(const std::string &text, const bool markedup)
Sets the text to render.
Definition: text.cpp:338
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:405
pango_text & set_link_color(const color_t &color)
Definition: text.cpp:509
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:157
void draw()
Draw the canvas' shapes onto the screen.
Definition: canvas.cpp:643
void set_size(const point &size)
Definition: canvas.cpp:718
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.
Definition: dispatcher.cpp:74
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.
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)
canvas & get_canvas(const unsigned index)
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:197
const std::string & str() const
Definition: tstring.hpp:201
This file contains the definitions for the gui2::event::message class.
@ border
The border of the map.
static std::string _(const char *str)
Definition: gettext.hpp:97
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
std::string label
What to show in the filter's drop-down list.
Definition: manager.cpp:201
#define log_scope2(domain, description)
Definition: log.hpp:276
void point(int x, int y)
Draw a single point.
Definition: draw.cpp:211
const color_t YELLOW_COLOR
void remove()
Removes a tip.
Definition: tooltip.cpp:94
static std::unique_ptr< tooltip > tip
Definition: tooltip.cpp:62
ui_event
The event sent to the dispatcher.
Definition: handler.hpp:115
@ MESSAGE_SHOW_TOOLTIP
Definition: handler.hpp:164
@ MESSAGE_SHOW_HELPTIP
Definition: handler.hpp:165
std::unique_ptr< class walker_base > walker_ptr
Definition: widget.hpp:44
t_string has_helptip_message
Definition: settings.cpp:45
Generic file dialog.
void get_screen_size_variables(wfl::map_formula_callable &variable)
Gets a formula object with the screen size.
Definition: helper.cpp:151
std::string_view debug_truncate(std::string_view text)
Returns a truncated version of the text.
Definition: helper.cpp:173
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.
Contains the implementation details for lexical_cast and shouldn't be used directly.
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
std::size_t size(std::string_view str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:85
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:178
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:61
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
std::string definition
Parameters for the styled_widget.
virtual std::unique_ptr< widget > build() const=0
static const hotkey_command & get_command_by_command(HOTKEY_COMMAND command)
the execute_command argument was changed from HOTKEY_COMMAND to hotkey_command, to be able to call it...
Holds a 2D point.
Definition: point.hpp:25
#define LOG_HEADER
#define LOG_SCOPE_HEADER
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)