The Battle for Wesnoth  1.17.4+dev
widget.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 2022
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 #pragma once
17 
18 #include "color.hpp"
21 #include "scripting/lua_ptr.hpp"
22 #include "sdl/point.hpp"
23 
24 #include <string>
25 
26 class surface;
27 
28 typedef std::map<std::string, t_string> string_map;
29 
30 namespace gui2
31 {
32 
33 struct builder_widget;
34 class window;
35 class grid;
36 
37 namespace iteration
38 {
39 using walker_ptr = std::unique_ptr<class walker_base>;
40 } // namespace iteration
41 
42 /**
43  * Base class for all widgets.
44  *
45  * From this abstract all other widgets should derive. It contains the minimal
46  * info needed for a real widget and some pure abstract functions which need to
47  * be implemented by classes deriving from this class.
48  */
49 class widget : public event_executor, public event::dispatcher, public enable_lua_ptr<widget>
50 {
51  friend class debug_layout_graph;
52  friend class window; // needed for modifying the layout_size.
53 
54 
55  /***** ***** ***** ***** ***** Types. ***** ***** ***** ***** *****/
56 
57 public:
58  /** Visibility settings done by the user. */
59  enum class visibility
60  {
61  /**
62  * The user sets the widget visible, that means:
63  * * The widget is visible.
64  * * @ref find_at always 'sees' the widget (the active flag is
65  * tested later).
66  * * The widget (if active) handles events (and sends events to
67  * its children).
68  * * The widget is drawn (and sends the call to
69  * @ref populate_dirty_list to children).
70  */
71  visible,
72 
73  /**
74  * The user sets the widget hidden, that means:
75  * * The widget is invisible but keeps its size.
76  * * @ref find_at 'sees' the widget if active is @c false.
77  * * The widget doesn't handle events (and doesn't send events to
78  * its children).
79  * * The widget doesn't add itself @ref window::dirty_list_ when
80  * @ref populate_dirty_list is called (nor does it send the
81  * request to its children).
82  */
83  hidden,
84 
85  /**
86  * The user set the widget invisible, that means:
87  * * The widget is invisible and its grid cell has size 0,0.
88  * * @ref find_at never 'sees' the widget.
89  * * The widget doesn't handle events (and doesn't send events to
90  * its children).
91  * * The widget doesn't add itself @ref window::dirty_list_ when
92  * @ref populate_dirty_list is called (nor does it send the
93  * request to its children).
94  */
95  invisible
96  };
97 
98  /**
99  * Visibility set by the engine.
100  *
101  * This state only will be used if @ref visible_ is @ref visibility::visible
102  * depending on this state the widget might not be visible after all.
103  */
104  enum class redraw_action
105  {
106  /**
107  * The widget is fully visible.
108  *
109  * The widget should be drawn if dirty_ is @c true. The entire
110  * widget's rectangle should be redrawn.
111  */
112  full,
113 
114  /**
115  * The widget is partly visible.
116  *
117  * The should be drawn if dirty_ is @c true. The rectangle to
118  * redraw in determined by @ref clipping_rectangle_
119  */
120  partly,
121 
122  /**
123  * The widget is not visible.
124  *
125  * The widget should not be drawn if dirty_ is @c true.
126  */
127  none
128  };
129 
130  enum class debug_border {
131  /** No border. */
132  none,
133  /** Single-pixel outline. */
134  outline,
135  /** Flood-filled rectangle. */
136  fill,
137  };
138 
139  /***** ***** ***** Constructor and destructor. ***** ***** *****/
140 
141 public:
142  widget(const widget&) = delete;
143  widget& operator=(const widget&) = delete;
144 
145  /** @deprecated use the second overload. */
146  widget();
147 
148  /**
149  * Constructor.
150  *
151  * @param builder The builder object with the settings for the
152  * object.
153  */
154  explicit widget(const builder_widget& builder);
155 
156  virtual ~widget() override;
157 
158 
159  /***** ***** ***** ***** ID functions. ***** ***** ***** *****/
160 
161 public:
162  /*** *** *** *** *** *** Setters and getters. *** *** *** *** *** ***/
163 
164  void set_id(const std::string& id);
165  const std::string& id() const;
166 
167  /*** *** *** *** *** *** *** *** Members. *** *** *** *** *** *** *** ***/
168 
169 private:
170  /**
171  * The id is the unique name of the widget in a certain context.
172  *
173  * This is needed for certain widgets so the engine knows which widget is
174  * which. E.g. it knows which button is pressed and thus which engine action
175  * is connected to the button. This doesn't mean that the id is unique in a
176  * window, e.g. a listbox can have the same id for every row.
177  */
178  std::string id_;
179 
180 
181  /***** ***** ***** ***** Parent functions ***** ***** ***** *****/
182 
183 public:
184  /**
185  * Get the parent window.
186  *
187  * @returns Pointer to parent window.
188  * @retval nullptr No parent window found.
189  */
190  window* get_window();
191 
192  /** The constant version of @ref get_window. */
193  const window* get_window() const;
194 
195  /**
196  * Get the parent grid.
197  *
198  * @returns Pointer to parent grid.
199  * @retval nullptr No parent grid found.
200  */
201  grid* get_parent_grid();
202 
203  /*** *** *** *** *** *** Setters and getters. *** *** *** *** *** ***/
204 
205  void set_parent(widget* parent);
206  widget* parent();
207 
208  /*** *** *** *** *** *** *** *** Members. *** *** *** *** *** *** *** ***/
209 
210 private:
211  /**
212  * The parent widget.
213  *
214  * If the widget has a parent it contains a pointer to the parent, else it
215  * is set to @c nullptr.
216  */
218 
219 
220  /***** ***** ***** ***** Size and layout functions. ***** ***** ***** *****/
221 
222 public:
223  /**
224  * How the layout engine works.
225  *
226  * Every widget has a member @ref layout_size_ which holds the best size in
227  * the current layout phase. When the windows starts the layout phase it
228  * calls @ref layout_initialize which resets this value.
229  *
230  * Every widget has two function to get the best size. @ref get_best_size
231  * tests whether layout_size_ is set and if so returns that value otherwise
232  * it calls @ref calculate_best_size so the size can be updated.
233  *
234  * During the layout phase some functions can modify layout_size_ so the
235  * next call to @ref get_best_size returns the currently best size. This
236  * means that after the layout phase @ref get_best_size still returns this
237  * value.
238  */
239 
240  /**
241  * Initialises the layout phase.
242  *
243  * Clears the initial best size for the widgets.
244  *
245  * See @ref layout_algorithm for more information.
246  *
247  * @param full_initialization For widgets with scrollbars it hides them
248  * unless the mode is
249  * scrollbar_mode::ALWAYS_VISIBLE. For
250  * other widgets this flag is a @em NOP.
251  */
252  virtual void layout_initialize(const bool full_initialization);
253 
254  /**
255  * Tries to reduce the width of a widget.
256  *
257  * This function tries to do it 'friendly' and only use scrollbars or
258  * tries to wrap the widget.
259  *
260  * See @ref layout_algorithm for more information.
261  *
262  * @param maximum_width The wanted maximum width.
263  */
264  virtual void request_reduce_width(const unsigned maximum_width) = 0;
265 
266  /**
267  * Tries to reduce the width of a widget.
268  *
269  * This function does it more aggressively and should only be used when
270  * using scrollbars and wrapping failed.
271  *
272  * @todo Make pure virtual.
273  *
274  * See @ref layout_algorithm for more information.
275  *
276  * @param maximum_width The wanted maximum width.
277  */
278  virtual void demand_reduce_width(const unsigned maximum_width);
279 
280  /**
281  * Tries to reduce the height of a widget.
282  *
283  * This function tries to do it 'friendly' and only use scrollbars.
284  *
285  * @todo Make pure virtual.
286  *
287  * See @ref layout_algorithm for more information.
288  *
289  * @param maximum_height The wanted maximum height.
290  */
291  virtual void request_reduce_height(const unsigned maximum_height);
292 
293  /**
294  * Tries to reduce the height of a widget.
295  *
296  * This function does it more aggressively and should only be used when
297  * using scrollbars failed.
298  *
299  * @todo Make pure virtual.
300  *
301  * See @ref layout_algorithm for more information.
302  *
303  * @param maximum_height The wanted maximum height.
304  */
305  virtual void demand_reduce_height(const unsigned maximum_height);
306 
307  /**
308  * Gets the best size for the widget.
309  *
310  * During the layout phase a best size will be determined, several stages
311  * might change the best size. This function will return the currently best
312  * size as determined during the layout phase.
313  *
314  * @returns The best size for the widget.
315  */
316  point get_best_size() const;
317 
318 private:
319  /**
320  * Calculates the best size.
321  *
322  * This function calculates the best size and ignores the current values in
323  * the layout phase. Note containers can call the @ref get_best_size() of
324  * their children since it is meant to update itself.
325  *
326  * @returns The best size for the widget.
327  */
328  virtual point calculate_best_size() const = 0;
329 
330 public:
331  /**
332  * Whether the mouse move/click event go 'through' this widget.
333  */
334  virtual bool can_mouse_focus() const { return true; }
335  /**
336  * Can the widget wrap.
337  *
338  * When a widget can wrap it can reduce its width by increasing its
339  * height. When a layout is too wide it should first try to wrap and if
340  * that fails it should check the vertical scrollbar status. After wrapping
341  * the height might (probably will) change so the layout engine needs to
342  * recalculate the height after wrapping.
343  */
344  virtual bool can_wrap() const;
345 
346  /**
347  * Sets the origin of the widget.
348  *
349  * This function can be used to move the widget without dirtying it. The
350  * location is an absolute position, if a relative more is required use
351  * @ref move.
352  *
353  *
354  * @param origin The new origin.
355  */
356  virtual void set_origin(const point& origin);
357 
358  /**
359  * Sets the size of the widget.
360  *
361  * This version is meant to resize a widget, since the origin isn't
362  * modified. This can be used if a widget needs to change its size and the
363  * layout will be fixed later.
364  *
365  * @param size The size of the widget.
366  */
367  virtual void set_size(const point& size);
368 
369  /**
370  * Places the widget.
371  *
372  * This function is normally called by a layout function to do the
373  * placement of a widget.
374  *
375  * @param origin The position of top left of the widget.
376  * @param size The size of the widget.
377  */
378  virtual void place(const point& origin, const point& size);
379 
380  /**
381  * Moves a widget.
382  *
383  * This function can be used to move the widget without dirtying it.
384  *
385  * @todo Implement the function to all derived classes.
386  *
387  * @param x_offset The amount of pixels to move the widget in
388  * the x-direction.
389  * @param y_offset The amount of pixels to move the widget in
390  * the y-direction.
391  */
392  virtual void move(const int x_offset, const int y_offset);
393 
394  /**
395  * Sets the horizontal alignment of the widget within its parent grid.
396  *
397  * @param alignment The new alignment.
398  */
399  virtual void set_horizontal_alignment(const std::string& alignment);
400 
401  /**
402  * Sets the horizontal alignment of the widget within its parent grid.
403  *
404  * @param alignment The new alignment.
405  */
406  virtual void set_vertical_alignment(const std::string& alignment);
407 
408  /**
409  * Allows a widget to update its children.
410  *
411  * Before the window is populating the dirty list the widgets can update
412  * their content, which allows delayed initialization. This delayed
413  * initialization is only allowed if the widget resizes itself, not when
414  * being placed.
415  */
416  virtual void layout_children();
417 
418  /**
419  * Returns the screen origin of the widget.
420  *
421  * @returns The origin of the widget.
422  */
423  point get_origin() const;
424 
425  /**
426  * Returns the size of the widget.
427  *
428  * @returns The size of the widget.
429  */
430  point get_size() const;
431 
432  /**
433  * Gets the bounding rectangle of the widget on the screen.
434  *
435  * @returns The bounding rectangle of the widget.
436  */
437  SDL_Rect get_rectangle() const;
438 
439  /*** *** *** *** *** *** Setters and getters. *** *** *** *** *** ***/
440 
441  int get_x() const;
442 
443  int get_y() const;
444 
445  unsigned get_width() const;
446 
447  unsigned get_height() const;
448 
449 protected:
450  void set_layout_size(const point& size);
451  const point& layout_size() const;
452 
453  /**
454  * Throws away @ref layout_size_.
455  *
456  * Use with care: this function does not recurse to child widgets.
457  *
458  * See @ref layout_algorithm for more information.
459  */
460  void clear_layout_size() { set_layout_size(point()); }
461 
462 public:
463  void set_linked_group(const std::string& linked_group);
464 
465  /*** *** *** *** *** *** *** *** Members. *** *** *** *** *** *** *** ***/
466 
467 private:
468  /** The x-coordinate of the widget on the screen. */
469  int x_;
470 
471  /** The y-coordinate of the widget on the screen. */
472  int y_;
473 
474  /** The width of the widget. */
475  unsigned width_;
476 
477  /** The height of the widget. */
478  unsigned height_;
479 
480  /**
481  * The best size for the widget.
482  *
483  * When 0,0 the real best size is returned, but in the layout phase a
484  * wrapping or a scrollbar might change the best size for that widget.
485  * This variable holds that best value.
486  *
487  * If the widget size hasn't been changed from the default that
488  * calculate_best_size() returns, layout_size_ is (0,0).
489  */
491 
492 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
493 
494  /**
495  * Debug helper to store last value of get_best_size().
496  *
497  * We're mutable so calls can stay const and this is disabled in
498  * production code.
499  */
500  mutable point last_best_size_;
501 
502 #endif
503 
504  /**
505  * The linked group the widget belongs to.
506  *
507  * @todo For now the linked group is initialized when the layout of the
508  * widget is initialized. The best time to set it would be upon adding the
509  * widget in the window. Need to look whether it is possible in a clean way.
510  * Maybe a signal just prior to showing a window where the widget can do
511  * some of it's on things, would also be nice for widgets that need a
512  * finalizer function.
513  */
514  std::string linked_group_;
515 
516 
517  /***** ***** ***** ***** Drawing functions. ***** ***** ***** *****/
518 
519 public:
520  /**
521  * Calculates the blitting rectangle of the widget.
522  *
523  * The blitting rectangle is the entire widget rectangle, but offsetted for
524  * drawing position.
525  *
526  * @param x_offset The offset in the x-direction when drawn.
527  * @param y_offset The offset in the y-direction when drawn.
528  *
529  * @returns The drawing rectangle.
530  */
531  SDL_Rect calculate_blitting_rectangle(const int x_offset,
532  const int y_offset);
533 
534  /**
535  * Calculates the clipping rectangle of the widget.
536  *
537  * The clipping rectangle is used then the @ref redraw_action_ is
538  * @ref redraw_action::partly. Since the drawing can be offsetted it also
539  * needs offset parameters.
540  *
541  * @param x_offset The offset in the x-direction when drawn.
542  * @param y_offset The offset in the y-direction when drawn.
543  *
544  * @returns The clipping rectangle.
545  */
546  SDL_Rect calculate_clipping_rectangle(const int x_offset,
547  const int y_offset);
548 
549  /**
550  * Draws the background of a widget.
551  *
552  * Derived should override @ref impl_draw_background instead of changing
553  * this function.
554  *
555  * @param x_offset The offset in the x-direction in the
556  * @p frame_buffer to draw.
557  * @param y_offset The offset in the y-direction in the
558  * @p frame_buffer to draw.
559  */
560  void draw_background(int x_offset, int y_offset);
561 
562  /**
563  * Draws the children of a widget.
564  *
565  * Containers should draw their children when they get this request.
566  *
567  * Derived should override @ref impl_draw_children instead of changing
568  * this function.
569  *
570  * @param x_offset The offset in the x-direction in the
571  * @p frame_buffer to draw.
572  * @param y_offset The offset in the y-direction in the
573  * @p frame_buffer to draw.
574  */
575  void draw_children(int x_offset, int y_offset);
576 
577  /**
578  * Draws the foreground of the widget.
579  *
580  * Some widgets e.g. panel and window have a back and foreground layer this
581  * function requests the drawing of the foreground.
582  *
583  * Derived should override @ref impl_draw_foreground instead of changing
584  * this function.
585  *
586  * @param x_offset The offset in the x-direction in the
587  * @p frame_buffer to draw.
588  * @param y_offset The offset in the y-direction in the
589  * @p frame_buffer to draw.
590  */
591  void draw_foreground(int x_offset, int y_offset);
592 
593 private:
594  /** See @ref draw_background. */
595  virtual void impl_draw_background()
596  {
597  }
598 
599  virtual void impl_draw_background(int /*x_offset*/, int /*y_offset*/)
600  {
601  }
602 
603  /** See @ref draw_children. */
604  virtual void impl_draw_children(int /*x_offset*/, int /*y_offset*/)
605  {
606  }
607 
608  /** See @ref draw_foreground. */
609  virtual void impl_draw_foreground(int /*x_offset*/, int /*y_offset*/)
610  {
611  }
612 
613 public:
614  /**
615  * Adds a widget to the dirty list if it is dirty.
616  *
617  * See @ref window::dirty_list_ for more information regarding the dirty
618  * list.
619  *
620  * If the widget is not dirty and has children it should add itself to the
621  * call_stack and call child_populate_dirty_list with the new call_stack.
622  *
623  * @param caller The parent window, if dirty it should
624  * register itself to this window.
625  * @param call_stack The call-stack of widgets traversed to reach
626  * this function.
627  */
628  void populate_dirty_list(window& caller,
629  std::vector<widget*>& call_stack);
630 
631 private:
632  /**
633  * Tries to add all children of a container to the dirty list.
634  *
635  * @note The function is private since everybody should call
636  * @ref populate_dirty_list instead.
637  *
638  * @param caller The parent window, if dirty it should
639  * register itself to this window.
640  * @param call_stack The call-stack of widgets traversed to reach
641  * this function.
642  */
643  virtual void
644  child_populate_dirty_list(window& caller,
645  const std::vector<widget*>& call_stack);
646 
647 public:
648  /**
649  * Gets the dirty rectangle of the widget.
650  *
651  * Depending on the @ref redraw_action_ it returns the rectangle this
652  * widget dirties while redrawing.
653  *
654  * @returns The dirty rectangle.
655  */
656  SDL_Rect get_dirty_rectangle() const;
657 
658  /**
659  * Sets the visible rectangle for a widget.
660  *
661  * This function sets the @ref redraw_action_ and the
662  * @ref clipping_rectangle_.
663  *
664  * @param rectangle The visible rectangle in screen coordinates.
665  */
666  virtual void set_visible_rectangle(const SDL_Rect& rectangle);
667 
668  /*** *** *** *** *** *** Setters and getters. *** *** *** *** *** ***/
669 
670  void set_is_dirty(const bool is_dirty);
671  bool get_is_dirty() const;
672 
673  void set_visible(const visibility visible);
674  visibility get_visible() const;
675 
676  redraw_action get_drawing_action() const;
677 
678  void set_debug_border_mode(const debug_border debug_border_mode);
679 
680  void set_debug_border_color(const color_t debug_border_color);
681 
682  /*** *** *** *** *** *** *** *** Members. *** *** *** *** *** *** *** ***/
683 
684 private:
685  /**
686  * Is the widget dirty?
687  *
688  * When a widget is dirty it needs to be redrawn at the next drawing cycle.
689  *
690  * The top-level window will use @ref populate_dirty_list and
691  * @ref child_populate_dirty_list to find al dirty widgets, so the widget
692  * doesn't need to inform its parent regarding it being marked dirty.
693  */
694  bool is_dirty_;
695 
696  /** Field for the status of the visibility. */
698 
699  /** Field for the action to do on a drawing request. */
701 
702  /** The clipping rectangle if a widget is partly visible. */
704 
705  /**
706  * Mode for drawing the debug border.
707  *
708  * The debug border is a helper border to determine where a widget is
709  * placed. It is only intended for debugging purposes.
710  */
712 
713  /** The color for the debug border. */
715 
716  void draw_debug_border();
717  void draw_debug_border(int x_offset, int y_offset);
718 
719  /***** ***** ***** ***** Query functions ***** ***** ***** *****/
720 
721 public:
722  /**
723  * Returns the widget at the wanted coordinates.
724  *
725  * @param coordinate The coordinate which should be inside the
726  * widget.
727  * @param must_be_active The widget should be active, not all widgets
728  * have an active flag, those who don't ignore
729  * flag.
730  *
731  * @returns The widget with the id.
732  * @retval nullptr No widget at the wanted coordinate found (or
733  * not active if must_be_active was set).
734  */
735  virtual widget* find_at(const point& coordinate,
736  const bool must_be_active);
737 
738  /** The constant version of @ref find_at. */
739  virtual const widget* find_at(const point& coordinate,
740  const bool must_be_active) const;
741 
742  /**
743  * Returns @em a widget with the wanted id.
744  *
745  * @note Since the id might not be unique inside a container there is no
746  * guarantee which widget is returned.
747  *
748  * @param id The id of the widget to find.
749  * @param must_be_active The widget should be active, not all widgets
750  * have an active flag, those who don't ignore
751  * flag.
752  *
753  * @returns The widget with the id.
754  * @retval nullptr No widget with the id found (or not active if
755  * must_be_active was set).
756  */
757  virtual widget* find(const std::string& id, const bool must_be_active);
758 
759  /** The constant version of @ref find. */
760  virtual const widget* find(const std::string& id,
761  const bool must_be_active) const;
762 
763  /**
764  * Does the widget contain the widget.
765  *
766  * Widgets can be containers which have more widgets inside them, this
767  * function will traverse in those child widgets and tries to find the
768  * wanted widget.
769  *
770  * @param widget Pointer to the widget to find.
771  *
772  * @returns Whether or not the @p widget was found.
773  */
774  virtual bool has_widget(const widget& widget) const;
775 
776 private:
777  /** See @ref event::dispatcher::is_at. */
778  virtual bool is_at(const point& coordinate) const override;
779 
780  /**
781  * Is the coordinate inside our area.
782  *
783  * Helper for find_at so also looks at our visibility.
784  *
785  * @param coordinate The coordinate which should be inside the
786  * widget.
787  * @param must_be_active The widget should be active, not all widgets
788  * have an active flag, those who don't ignore
789  * flag.
790  *
791  * @returns Status.
792  */
793  bool is_at(const point& coordinate, const bool must_be_active) const;
794 
795  /**
796  * Is the widget and every single one of its parents visible?
797  *
798  * @param widget Widget where to start the check.
799  * @param must_be_active The widget should be active, not all widgets
800  * have an active flag, those who don't ignore
801  * flag.
802  *
803  * @returns Status.
804  */
805  bool recursive_is_visible(const widget* widget, const bool must_be_active) const;
806 
807  /***** ***** ***** ***** Miscellaneous ***** ***** ****** *****/
808 
809 public:
810  /** Does the widget disable easy close? */
811  virtual bool disable_click_dismiss() const = 0;
812 
813  /** Creates a new walker object on the heap. */
814  virtual iteration::walker_ptr create_walker() = 0;
815 };
816 
817 } // namespace gui2
Contains the info needed to instantiate a widget.
virtual void impl_draw_background()
See draw_background.
Definition: widget.hpp:595
std::unique_ptr< class walker_base > walker_ptr
Definition: widget.hpp:39
redraw_action
Visibility set by the engine.
Definition: widget.hpp:104
Base class for event handling.
Definition: dispatcher.hpp:151
widget * parent_
The parent widget.
Definition: widget.hpp:217
static void draw_background(surface screen, const SDL_Rect &area, const std::string &image)
Definition: display.cpp:1470
unsigned height_
The height of the widget.
Definition: widget.hpp:478
Base class for all widgets.
Definition: widget.hpp:49
redraw_action redraw_action_
Field for the action to do on a drawing request.
Definition: widget.hpp:700
virtual void impl_draw_foreground(int, int)
See draw_foreground.
Definition: widget.hpp:609
std::string id_
The id is the unique name of the widget in a certain context.
Definition: widget.hpp:178
visibility visible_
Field for the status of the visibility.
Definition: widget.hpp:697
Generic file dialog.
Definition: field-fwd.hpp:23
Base container class.
Definition: grid.hpp:31
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:87
static thread_local std::deque< std::string > call_stack
For printing error messages when WFL parsing or evaluation fails, this contains the names of the WFL ...
Definition: function.cpp:47
point layout_size_
The best size for the widget.
Definition: widget.hpp:490
std::string linked_group_
The linked group the widget belongs to.
Definition: widget.hpp:514
int y_
The y-coordinate of the widget on the screen.
Definition: widget.hpp:472
Event execution calls.
virtual bool can_mouse_focus() const
Whether the mouse move/click event go &#39;through&#39; this widget.
Definition: widget.hpp:334
virtual void impl_draw_background(int, int)
Definition: widget.hpp:599
std::string id
Text to match against addon_info.tags()
Definition: manager.cpp:215
debug_border debug_border_mode_
Mode for drawing the debug border.
Definition: widget.hpp:711
color_t debug_border_color_
The color for the debug border.
Definition: widget.hpp:714
std::map< std::string, t_string > string_map
Definition: widget.hpp:26
visibility
Visibility settings done by the user.
Definition: widget.hpp:59
Holds a 2D point.
Definition: point.hpp:24
void clear_layout_size()
Throws away layout_size_.
Definition: widget.hpp:460
bool grid()
Definition: general.cpp:562
SDL_Rect clipping_rectangle_
The clipping rectangle if a widget is partly visible.
Definition: widget.hpp:703
unsigned width_
The width of the widget.
Definition: widget.hpp:475
virtual void impl_draw_children(int, int)
See draw_children.
Definition: widget.hpp:604
bool is_dirty_
Is the widget dirty?
Definition: widget.hpp:694
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:65
int x_
The x-coordinate of the widget on the screen.
Definition: widget.hpp:469