The Battle for Wesnoth  1.13.11+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
widget.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 2018 by Mark de Wever <koraq@xs4all.nl>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
17 #include "gui/widgets/grid.hpp"
18 #include "gui/widgets/settings.hpp"
19 #include "gui/widgets/window.hpp"
21 #include "gui/core/log.hpp"
23 #include "sdl/rect.hpp"
24 
25 namespace gui2
26 {
27 
28 /***** ***** ***** Constructor and destructor. ***** ***** *****/
29 
31  : id_("")
32  , parent_(nullptr)
33  , x_(-1)
34  , y_(-1)
35  , width_(0)
36  , height_(0)
37  , layout_size_()
38 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
39  , last_best_size_()
40 #endif
41  , linked_group_()
42  , is_dirty_(true)
43  , visible_(visibility::visible)
44  , redraw_action_(redraw_action::full)
45  , clipping_rectangle_()
46  , debug_border_mode_(0)
47  , debug_border_color_(0,0,0,0)
48 {
49  DBG_GUI_LF << "widget create: " << static_cast<void*>(this) << "\n";
50 }
51 
53  : id_(builder.id)
54  , parent_(nullptr)
55  , x_(-1)
56  , y_(-1)
57  , width_(0)
58  , height_(0)
59  , layout_size_()
60 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
61  , last_best_size_()
62 #endif
63  , linked_group_(builder.linked_group)
64  , is_dirty_(true)
65  , visible_(visibility::visible)
66  , redraw_action_(redraw_action::full)
67  , clipping_rectangle_()
68  , debug_border_mode_(builder.debug_border_mode)
69  , debug_border_color_(builder.debug_border_color)
70 {
71  DBG_GUI_LF << "widget create: " << static_cast<void*>(this) << "\n";
72 }
73 
75 {
77  << "widget destroy: " << static_cast<void*>(this) << " (id: " << id_
78  << ")\n";
79 
80  widget* p = parent();
81  while(p) {
82  fire(event::NOTIFY_REMOVAL, *p, nullptr);
83  p = p->parent();
84  }
85 
86  if(!linked_group_.empty()) {
87  if(window* window = get_window()) {
89  }
90  }
91 }
92 
93 /***** ***** ***** ***** ID functions. ***** ***** ***** *****/
94 
95 void widget::set_id(const std::string& id)
96 {
97  styled_widget* this_ctrl = dynamic_cast<styled_widget*>(this);
98 
100  << "set id of " << static_cast<void*>(this) << " to '" << id << "' "
101  << "(was '" << id_ << "'). Widget type: "
102  << (this_ctrl ? this_ctrl->get_control_type() : typeid(widget).name()) << "\n";
103 
104  id_ = id;
105 }
106 
107 const std::string& widget::id() const
108 {
109  return id_;
110 }
111 
112 /***** ***** ***** ***** Parent functions ***** ***** ***** *****/
113 
115 {
116  // Go up into the parent tree until we find the top level
117  // parent, we can also be the toplevel so start with
118  // ourselves instead of our parent.
119  widget* result = this;
120  while(result->parent_) {
121  result = result->parent_;
122  }
123 
124  // on error dynamic_cast returns nullptr which is what we want.
125  return dynamic_cast<window*>(result);
126 }
127 
129 {
130  // Go up into the parent tree until we find the top level
131  // parent, we can also be the toplevel so start with
132  // ourselves instead of our parent.
133  const widget* result = this;
134  while(result->parent_) {
135  result = result->parent_;
136  }
137 
138  // on error dynamic_cast returns nullptr which is what we want.
139  return dynamic_cast<const window*>(result);
140 }
141 
143 {
144  widget* result = parent_;
145  while(result && dynamic_cast<grid*>(result) == nullptr) {
146  result = result->parent_;
147  }
148 
149  return result ? dynamic_cast<grid*>(result) : nullptr;
150 }
151 
153 {
154  window* window = get_window();
155  return window ? window->dialog() : nullptr;
156 }
157 
159 {
160  parent_ = parent;
161 }
162 
164 {
165  return parent_;
166 }
167 
168 /***** ***** ***** ***** Size and layout functions. ***** ***** ***** *****/
169 
170 void widget::layout_initialize(const bool /*full_initialization*/)
171 {
172  assert(visible_ != visibility::invisible);
173  assert(get_window());
174 
175  layout_size_ = point();
176  if(!linked_group_.empty()) {
178  }
179 }
180 
181 void widget::demand_reduce_width(const unsigned /*maximum_width*/)
182 {
183  /* DO NOTHING */
184 }
185 
186 void widget::request_reduce_height(const unsigned /*maximum_height*/)
187 {
188  /* DO NOTHING */
189 }
190 
191 void widget::demand_reduce_height(const unsigned /*maximum_height*/)
192 {
193  /* DO NOTHING */
194 }
195 
197 {
198  assert(visible_ != visibility::invisible);
199 
200  point result = layout_size_;
201  if(result == point()) {
202  result = calculate_best_size();
203  //Adjust to linked widget size if linked widget size was already calculated.
204  if(!get_window()->get_need_layout() && !linked_group_.empty())
205  {
206  point linked_size = get_window()->get_linked_size(linked_group_);
207  result.x = std::max(result.x, linked_size.x);
208  result.y = std::max(result.y, linked_size.y);
209  }
210  }
211 
212 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
213  last_best_size_ = result;
214 #endif
215 
216  return result;
217 }
218 
219 bool widget::can_wrap() const
220 {
221  return false;
222 }
223 
224 void widget::set_origin(const point& origin)
225 {
226  x_ = origin.x;
227  y_ = origin.y;
228 }
229 
231 {
232  assert(size.x >= 0);
233  assert(size.y >= 0);
234 
235  width_ = size.x;
236  height_ = size.y;
237 
238  set_is_dirty(true);
239 }
240 
241 void widget::place(const point& origin, const point& size)
242 {
243  assert(size.x >= 0);
244  assert(size.y >= 0);
245 
246  x_ = origin.x;
247  y_ = origin.y;
248  width_ = size.x;
249  height_ = size.y;
250 
251 #if 0
252  std::cerr
253  << "Id " << id()
254  << " rect " << get_rectangle()
255  << " parent "
256  << (parent ? parent->get_x() : 0)
257  << ','
258  << (parent ? parent->get_y() : 0)
259  << " screen origin " << x_ << ',' << y_
260  << ".\n";
261 #endif
262 
263  set_is_dirty(true);
264 }
265 
266 void widget::move(const int x_offset, const int y_offset)
267 {
268  x_ += x_offset;
269  y_ += y_offset;
270 }
271 
273 {
274  grid* parent_grid = get_parent_grid();
275  if(!parent_grid) {
276  return;
277  }
278 
280 
281  // TODO: evaluate necessity
282  //get_window()->invalidate_layout();
283 }
284 
286 {
287  grid* parent_grid = get_parent_grid();
288  if(!parent_grid) {
289  return;
290  }
291 
293 
294  // TODO: evaluate necessity
295  //get_window()->invalidate_layout();
296 }
297 
299 {
300  /* DO NOTHING */
301 }
302 
304 {
305  return point(x_, y_);
306 }
307 
309 {
310  return point(width_, height_);
311 }
312 
313 SDL_Rect widget::get_rectangle() const
314 {
315  return create_rect(get_origin(), get_size());
316 }
317 
318 int widget::get_x() const
319 {
320  return x_;
321 }
322 
323 int widget::get_y() const
324 {
325  return y_;
326 }
327 
328 unsigned widget::get_width() const
329 {
330  return width_;
331 }
332 
333 unsigned widget::get_height() const
334 {
335  return height_;
336 }
337 
339 {
340  layout_size_ = size;
341 }
342 
344 {
345  return layout_size_;
346 }
347 
348 void widget::set_linked_group(const std::string& linked_group)
349 {
350  linked_group_ = linked_group;
351 }
352 
353 /***** ***** ***** ***** Drawing functions. ***** ***** ***** *****/
354 
355 SDL_Rect widget::calculate_blitting_rectangle(const int x_offset,
356  const int y_offset)
357 {
358  SDL_Rect result = get_rectangle();
359  result.x += x_offset;
360  result.y += y_offset;
361  return result;
362 }
363 
364 SDL_Rect widget::calculate_clipping_rectangle(const int x_offset,
365  const int y_offset)
366 {
367  SDL_Rect result = clipping_rectangle_;
368  result.x += x_offset;
369  result.y += y_offset;
370  return result;
371 }
372 
373 void widget::draw_background(surface& frame_buffer, int x_offset, int y_offset)
374 {
375  assert(visible_ == visibility::visible);
376 
378  const SDL_Rect clipping_rectangle
379  = calculate_clipping_rectangle(x_offset, y_offset);
380 
381  clip_rect_setter clip(frame_buffer, &clipping_rectangle);
382  draw_debug_border(x_offset, y_offset);
383  impl_draw_background(frame_buffer, x_offset, y_offset);
384  } else {
385  draw_debug_border(x_offset, y_offset);
386  impl_draw_background(frame_buffer, x_offset, y_offset);
387  }
388 }
389 
390 void widget::draw_children(surface& frame_buffer, int x_offset, int y_offset)
391 {
392  assert(visible_ == visibility::visible);
393 
395  const SDL_Rect clipping_rectangle
396  = calculate_clipping_rectangle(x_offset, y_offset);
397 
398  clip_rect_setter clip(frame_buffer, &clipping_rectangle);
399  impl_draw_children(frame_buffer, x_offset, y_offset);
400  } else {
401  impl_draw_children(frame_buffer, x_offset, y_offset);
402  }
403 }
404 
405 void widget::draw_foreground(surface& frame_buffer, int x_offset, int y_offset)
406 {
407  assert(visible_ == visibility::visible);
408 
410  const SDL_Rect clipping_rectangle
411  = calculate_clipping_rectangle(x_offset, y_offset);
412 
413  clip_rect_setter clip(frame_buffer, &clipping_rectangle);
414  impl_draw_foreground(frame_buffer, x_offset, y_offset);
415  } else {
416  impl_draw_foreground(frame_buffer, x_offset, y_offset);
417  }
418 }
419 
421  std::vector<widget*>& call_stack)
422 {
423  assert(call_stack.empty() || call_stack.back() != this);
424 
426  return;
427  }
428 
430  return;
431  }
432 
433  call_stack.push_back(this);
434  if(is_dirty_) {
435  caller.add_to_dirty_list(call_stack);
436  } else {
437  // virtual function which only does something for container items.
438  child_populate_dirty_list(caller, call_stack);
439  }
440 }
441 
442 void
444  ,
445  const std::vector<widget*>& /*call_stack*/)
446 {
447  /* DO NOTHING */
448 }
449 
451 {
454 }
455 
456 void widget::set_visible_rectangle(const SDL_Rect& rectangle)
457 {
459 
462  } else if(clipping_rectangle_ == sdl::empty_rect) {
464  } else {
466  }
467 }
468 
469 void widget::set_is_dirty(const bool is_dirty)
470 {
471  is_dirty_ = is_dirty;
472 }
473 
475 {
476  return is_dirty_;
477 }
478 
479 void widget::set_visible(const visibility visible)
480 {
481  if(visible == visible_) {
482  return;
483  }
484 
485  // Switching to or from invisible should invalidate the layout
486  // if the widget has already been laid out.
487  const bool need_resize = visible_ == visibility::invisible
488  || (visible == visibility::invisible && get_size() != point());
489  visible_ = visible;
490 
491  if(need_resize) {
492  if(visible == visibility::visible && new_widgets) {
494  fire(event::REQUEST_PLACEMENT, *this, message);
495  } else {
496  window* window = get_window();
497  if(window) {
498  window->invalidate_layout();
499  }
500  }
501  } else {
502  set_is_dirty(true);
503  }
504 }
505 
507 {
508  return visible_;
509 }
510 
512 {
513  return (width_ == 0 || height_ == 0) ? redraw_action::none
514  : redraw_action_;
515 }
516 
517 void widget::set_debug_border_mode(const unsigned debug_border_mode)
518 {
519  debug_border_mode_ = debug_border_mode;
520 }
521 
522 void widget::set_debug_border_color(const color_t debug_border_color)
523 {
524  debug_border_color_ = debug_border_color;
525 }
526 
528 {
530  : get_rectangle();
531 
532  switch(debug_border_mode_) {
533  case 0:
534  /* DO NOTHING */
535  break;
536  case 1:
538  break;
539 
540  case 2:
542  break;
543 
544  default:
545  assert(false);
546  }
547 }
548 
549 void
550 widget::draw_debug_border(int x_offset, int y_offset)
551 {
552  SDL_Rect r = redraw_action_ == redraw_action::partly
553  ? calculate_clipping_rectangle(x_offset, y_offset)
554  : calculate_blitting_rectangle(x_offset, y_offset);
555 
556  switch(debug_border_mode_) {
557  case 0:
558  /* DO NOTHING */
559  break;
560 
561  case 1:
563  break;
564 
565  case 2:
567  break;
568 
569  default:
570  assert(false);
571  }
572 }
573 
574 /***** ***** ***** ***** Query functions ***** ***** ***** *****/
575 
576 widget* widget::find_at(const point& coordinate, const bool must_be_active)
577 {
578  return is_at(coordinate, must_be_active) ? this : nullptr;
579 }
580 
582  const bool must_be_active) const
583 {
584  return is_at(coordinate, must_be_active) ? this : nullptr;
585 }
586 
587 widget* widget::find(const std::string& id, const bool /*must_be_active*/)
588 {
589  return id_ == id ? this : nullptr;
590 }
591 
592 const widget* widget::find(const std::string& id,
593  const bool /*must_be_active*/) const
594 {
595  return id_ == id ? this : nullptr;
596 }
597 
598 bool widget::has_widget(const widget& widget) const
599 {
600  return &widget == this;
601 }
602 
603 bool widget::is_at(const point& coordinate) const
604 {
605  return is_at(coordinate, true);
606 }
607 
608 bool widget::recursive_is_visible(const widget* widget, const bool must_be_active) const
609 {
610  while(widget) {
611  if(widget->visible_ == visibility::invisible
612  || (widget->visible_ == visibility::hidden && must_be_active)) {
613  return false;
614  }
615 
616  widget = widget->parent_;
617  }
618 
619  return true;
620 }
621 
622 bool widget::is_at(const point& coordinate, const bool must_be_active) const
623 {
624  if(!recursive_is_visible(this, must_be_active)) {
625  return false;
626  }
627 
628  return sdl::point_in_rect(coordinate, get_rectangle());
629 }
630 
631 } // namespace gui2
Define the common log macros for the gui toolkit.
#define DBG_GUI_LF
Definition: log.hpp:64
Contains the info needed to instantiate a widget.
bool new_widgets
Do we wish to use the new library or not.
Definition: settings.cpp:21
grid * get_parent_grid()
Get the parent grid.
Definition: widget.cpp:142
bool get_is_dirty() const
Definition: widget.cpp:474
SDL_Rect create_rect(const point &origin, const point &size)
Creates a rectangle.
Definition: helper.cpp:32
void set_parent(widget *parent)
Definition: widget.cpp:158
std::vector< char_t > string
virtual bool is_at(const point &coordinate) const override
See event::dispatcher::is_at.
Definition: widget.cpp:603
void set_debug_border_mode(const unsigned debug_border_mode)
Definition: widget.cpp:517
virtual void layout_initialize(const bool full_initialization)
How the layout engine works.
Definition: widget.cpp:170
void set_layout_size(const point &size)
Definition: widget.cpp:338
redraw_action
Visibility set by the engine.
Definition: widget.hpp:103
int get_y() const
Definition: widget.cpp:323
SDL_Rect calculate_blitting_rectangle(const int x_offset, const int y_offset)
Calculates the blitting rectangle of the widget.
Definition: widget.cpp:355
virtual widget * find(const std::string &id, const bool must_be_active)
Returns a widget with the wanted id.
Definition: widget.cpp:587
point get_origin() const
Returns the screen origin of the widget.
Definition: widget.cpp:303
virtual void impl_draw_foreground(surface &, int, int)
See draw_foreground.
Definition: widget.hpp:628
Main class to show messages to the user.
Definition: message.hpp:34
unsigned debug_border_mode_
Mode for drawing the debug border.
Definition: widget.hpp:739
widget * parent_
The parent widget.
Definition: widget.hpp:224
const std::string & id() const
Definition: widget.cpp:107
This file contains the window object, this object is a top level container which has the event manage...
unsigned height_
The height of the widget.
Definition: widget.hpp:487
unsigned get_width() const
Definition: widget.cpp:328
Base class for all widgets.
Definition: widget.hpp:48
virtual void set_visible_rectangle(const SDL_Rect &rectangle)
Sets the visible rectangle for a widget.
Definition: widget.cpp:456
unsigned get_height() const
Definition: widget.cpp:333
redraw_action redraw_action_
Field for the action to do on a drawing request.
Definition: widget.hpp:723
SDL_Rect intersect_rects(const SDL_Rect &rect1, const SDL_Rect &rect2)
Calculates the intersection of two rectangles.
Definition: rect.cpp:39
static const unsigned HORIZONTAL_MASK
Definition: grid.hpp:59
virtual void request_reduce_height(const unsigned maximum_height)
Tries to reduce the height of a widget.
Definition: widget.cpp:186
virtual ~widget() override
Definition: widget.cpp:74
CONSTEXPR const SDL_Rect empty_rect
Definition: rect.hpp:32
void draw_debug_border()
Definition: widget.cpp:527
virtual void demand_reduce_width(const unsigned maximum_width)
Tries to reduce the width of a widget.
Definition: widget.cpp:181
std::string id_
The id is the unique name of the widget in a certain context.
Definition: widget.hpp:169
visibility visible_
Field for the status of the visibility.
Definition: widget.hpp:720
virtual void set_horizontal_alignment(const std::string &alignment)
Sets the horizontal alignment of the widget within its parent grid.
Definition: widget.cpp:272
int x
x coordinate.
Definition: point.hpp:44
Generic file dialog.
Definition: field-fwd.hpp:22
The message callbacks hold a reference to a message.
Definition: message.hpp:46
Base container class.
Definition: grid.hpp:30
virtual void impl_draw_background(surface &)
See draw_background.
Definition: widget.hpp:607
virtual void child_populate_dirty_list(window &caller, const std::vector< widget * > &call_stack)
Tries to add all children of a container to the dirty list.
Definition: widget.cpp:443
Request to place the widget.
Definition: handler.hpp:102
virtual void demand_reduce_height(const unsigned maximum_height)
Tries to reduce the height of a widget.
Definition: widget.cpp:191
This file contains the settings handling of the widget library.
virtual void place(const point &origin, const point &size)
Places the widget.
Definition: widget.cpp:241
The widget is fully visible.
void set_visible(const visibility visible)
Definition: widget.cpp:479
void set_is_dirty(const bool is_dirty)
Definition: widget.cpp:469
virtual void set_origin(const point &origin)
Sets the origin of the widget.
Definition: widget.cpp:224
Sent by a widget to notify others it's being destroyed.
Definition: handler.hpp:95
void draw_rectangle(const SDL_Rect &rect, const color_t &color)
Draw a rectangle outline.
Definition: rect.cpp:57
widget * parent()
Definition: widget.cpp:163
The widget is not visible.
virtual bool has_widget(const widget &widget) const
Does the widget contain the widget.
Definition: widget.cpp:598
virtual point calculate_best_size() const =0
Calculates the best size.
This file contains the definitions for the gui2::event::message class.
point layout_size_
The best size for the widget.
Definition: widget.hpp:499
void draw_background(surface &frame_buffer, int x_offset, int y_offset)
Draws the background of a widget.
Definition: widget.cpp:373
dialogs::modal_dialog * dialog()
Returns the top-level dialog.
Definition: widget.cpp:152
std::string linked_group_
The linked group the widget belongs to.
Definition: widget.hpp:523
int get_x() const
Definition: widget.cpp:318
int y_
The y-coordinate of the widget on the screen.
Definition: widget.hpp:481
virtual void impl_draw_children(surface &, int, int)
See draw_children.
Definition: widget.hpp:619
void add_to_dirty_list(const std::vector< widget * > &call_stack)
Adds an item to the dirty_list_.
Definition: window.hpp:189
bool point_in_rect(int x, int y, const SDL_Rect &rect)
Tests whether a point is inside a rectangle.
Definition: rect.cpp:22
void add_linked_widget(const std::string &id, widget *widget)
Adds a widget to a linked size group.
Definition: window.cpp:846
size_t size(const utf8::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:86
point get_best_size() const
Gets the best size for the widget.
Definition: widget.cpp:196
mock_party p
The user set the widget invisible, that means:
color_t debug_border_color_
The color for the debug border.
Definition: widget.hpp:742
window * get_window()
Get the parent window.
Definition: widget.cpp:114
visibility
Visibility settings done by the user.
Definition: widget.hpp:58
Holds a 2D point.
Definition: point.hpp:23
static const unsigned VERTICAL_MASK
Definition: grid.hpp:52
virtual void layout_children()
Allows a widget to update its children.
Definition: widget.cpp:298
bool recursive_is_visible(const widget *widget, const bool must_be_active) const
Is the widget and every single one of its parents visible?
Definition: widget.cpp:608
Base class for all visible items.
virtual bool can_wrap() const
Can the widget wrap.
Definition: widget.cpp:219
static std::map< std::string, scrollbar_mode > unsigned get_v_align(const std::string &v_align)
Returns the vertical alignment.
Definition: helper.cpp:37
point get_linked_size(const std::string &linked_group_id) const
Definition: window.hpp:424
SDL_Rect clipping_rectangle_
The clipping rectangle if a widget is partly visible.
Definition: widget.hpp:726
unsigned width_
The width of the widget.
Definition: widget.hpp:484
const point & layout_size() const
Definition: widget.cpp:343
Contains the SDL_Rect helper code.
The user sets the widget visible, that means:
The user sets the widget hidden, that means:
void set_child_alignment(widget *widget, unsigned set_flag, unsigned mode_mask)
Modifies the widget alignment data of a child cell containing a specific widget.
Definition: grid.cpp:943
virtual void move(const int x_offset, const int y_offset)
Moves a widget.
Definition: widget.cpp:266
void set_id(const std::string &id)
Definition: widget.cpp:95
void set_debug_border_color(const color_t debug_border_color)
Definition: widget.cpp:522
redraw_action get_drawing_action() const
Definition: widget.cpp:511
Abstract base class for all modal dialogs.
void fill_rectangle(const SDL_Rect &rect, const color_t &color)
Draws a filled rectangle.
Definition: rect.cpp:65
void draw_foreground(surface &frame_buffer, int x_offset, int y_offset)
Draws the foreground of the widget.
Definition: widget.cpp:405
visibility get_visible() const
Definition: widget.cpp:506
bool fire(const ui_event event, widget &target)
Fires an event which has no extra parameters.
Definition: dispatcher.cpp:120
static const char * name(const std::vector< SDL_Joystick * > &joysticks, const size_t index)
Definition: joystick.cpp:48
virtual void set_size(const point &size)
Sets the size of the widget.
Definition: widget.cpp:230
void invalidate_layout()
Updates the size of the window.
Definition: window.cpp:803
virtual void set_vertical_alignment(const std::string &alignment)
Sets the horizontal alignment of the widget within its parent grid.
Definition: widget.cpp:285
virtual const std::string & get_control_type() const =0
Returns the control_type of the styled_widget.
bool is_dirty_
Is the widget dirty?
Definition: widget.hpp:717
dialogs::modal_dialog * dialog()
Inherited from widget.
Definition: window.hpp:260
virtual widget * find_at(const point &coordinate, const bool must_be_active)
Returns the widget at the wanted coordinates.
Definition: widget.cpp:576
void draw_children(surface &frame_buffer, int x_offset, int y_offset)
Draws the children of a widget.
Definition: widget.cpp:390
void remove_linked_widget(const std::string &id, const widget *widget)
Removes a widget from a linked size group.
Definition: window.cpp:860
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
point get_size() const
Returns the size of the widget.
Definition: widget.cpp:308
unsigned get_h_align(const std::string &h_align)
Returns the horizontal alignment.
Definition: helper.cpp:52
The widget is partly visible.
int y
y coordinate.
Definition: point.hpp:47
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
SDL_Rect get_rectangle() const
Gets the bounding rectangle of the widget on the screen.
Definition: widget.cpp:313
int x_
The x-coordinate of the widget on the screen.
Definition: widget.hpp:478
void populate_dirty_list(window &caller, std::vector< widget * > &call_stack)
Adds a widget to the dirty list if it is dirty.
Definition: widget.cpp:420
static std::deque< std::string > call_stack
Definition: function.cpp:39
SDL_Rect calculate_clipping_rectangle(const int x_offset, const int y_offset)
Calculates the clipping rectangle of the widget.
Definition: widget.cpp:364
void set_linked_group(const std::string &linked_group)
Definition: widget.cpp:348
SDL_Rect get_dirty_rectangle() const
Gets the dirty rectangle of the widget.
Definition: widget.cpp:450