The Battle for Wesnoth  1.19.7+dev
grid.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
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 "gui/widgets/widget.hpp"
19 
20 #include <cassert>
21 
22 namespace gui2
23 {
24 
25 /**
26  * Base container class.
27  *
28  * This class holds a number of widgets and their wanted layout parameters. It
29  * also layouts the items in the grid and handles their drawing.
30  */
31 class grid : public widget
32 {
33  friend class debug_layout_graph;
34  friend struct grid_implementation;
35 
36 public:
37  explicit grid(const unsigned rows = 0, const unsigned cols = 0);
38 
39  /** Delete the copy constructor. */
40  grid(const grid&) = delete;
41 
42  /** Delete the move assignment operator. */
43  grid& operator=(const grid&) = delete;
44 
45  virtual ~grid();
46 
47  /***** ***** ***** ***** LAYOUT FLAGS ***** ***** ***** *****/
48  static const unsigned VERTICAL_SHIFT = 0;
49  static const unsigned VERTICAL_GROW_SEND_TO_CLIENT = 1 << VERTICAL_SHIFT;
50  static const unsigned VERTICAL_ALIGN_TOP = 2 << VERTICAL_SHIFT;
51  static const unsigned VERTICAL_ALIGN_CENTER = 3 << VERTICAL_SHIFT;
52  static const unsigned VERTICAL_ALIGN_BOTTOM = 4 << VERTICAL_SHIFT;
53  static const unsigned VERTICAL_MASK = 7 << VERTICAL_SHIFT;
54 
55  static const unsigned HORIZONTAL_SHIFT = 3;
56  static const unsigned HORIZONTAL_GROW_SEND_TO_CLIENT = 1 << HORIZONTAL_SHIFT;
57  static const unsigned HORIZONTAL_ALIGN_LEFT = 2 << HORIZONTAL_SHIFT;
58  static const unsigned HORIZONTAL_ALIGN_CENTER = 3 << HORIZONTAL_SHIFT;
59  static const unsigned HORIZONTAL_ALIGN_RIGHT = 4 << HORIZONTAL_SHIFT;
60  static const unsigned HORIZONTAL_MASK = 7 << HORIZONTAL_SHIFT;
61 
62  static const unsigned BORDER_TOP = 1 << 6;
63  static const unsigned BORDER_BOTTOM = 1 << 7;
64  static const unsigned BORDER_LEFT = 1 << 8;
65  static const unsigned BORDER_RIGHT = 1 << 9;
67 
68  /***** ***** ***** ***** ROW COLUMN MANIPULATION ***** ***** ***** *****/
69 
70  /**
71  * Adds a row to end of the grid.
72  *
73  * @param count Number of rows to add, should be > 0.
74  *
75  * @returns The row number of the first row added.
76  */
77  unsigned add_row(const unsigned count = 1);
78 
79  /**
80  * Sets the grow factor for a row.
81  *
82  * @todo refer to a page with the layout manipulation info.
83  *
84  * @param row The row to modify.
85  * @param factor The grow factor.
86  */
87  void set_row_grow_factor(const unsigned row, const unsigned factor)
88  {
89  assert(row < row_grow_factor_.size());
90  row_grow_factor_[row] = factor;
91  queue_redraw(); // TODO: draw_manager - relayout?
92  }
93 
94  /**
95  * Sets the grow factor for a column.
96  *
97  * @todo refer to a page with the layout manipulation info.
98  *
99  * @param column The column to modify.
100  * @param factor The grow factor.
101  */
102  void set_column_grow_factor(const unsigned column, const unsigned factor)
103  {
104  assert(column < col_grow_factor_.size());
105  col_grow_factor_[column] = factor;
106  queue_redraw(); // TODO: draw_manager - relayout?
107  }
108 
109  /***** ***** ***** ***** CHILD MANIPULATION ***** ***** ***** *****/
110 
111  /**
112  * Sets a child in the grid.
113  *
114  * When the child is added to the grid the grid 'owns' the widget.
115  * The widget is put in a cell, and every cell can only contain 1 widget if
116  * the wanted cell already contains a widget, that widget is freed and
117  * removed.
118  *
119  * @param widget The widget to put in the grid.
120  * @param row The row of the cell.
121  * @param col The column of the cell.
122  * @param flags The flags for the widget in the cell.
123  * @param border_size The size of the border for the cell, how the
124  * border is applied depends on the flags.
125  */
126  void set_child(std::unique_ptr<widget> widget,
127  const unsigned row,
128  const unsigned col,
129  const unsigned flags,
130  const unsigned border_size);
131 
132  /**
133  * Exchanges a child in the grid.
134  *
135  * It replaced the child with a certain id with the new widget but doesn't
136  * touch the other settings of the child.
137  *
138  * @param id The id of the widget to free.
139  * @param w The widget to put in the grid.
140  * @param recurse Do we want to decent into the child grids.
141  * @param new_parent The new parent for the swapped out widget.
142  *
143  * @returns The widget which got removed (the parent of
144  * the widget is cleared), or @ref w if no matching
145  * widget was found.
146  */
147  std::unique_ptr<widget> swap_child(const std::string& id,
148  std::unique_ptr<widget> w,
149  const bool recurse,
150  widget* new_parent = nullptr);
151 
152  /**
153  * Removes and frees a widget in a cell.
154  *
155  * @param row The row of the cell.
156  * @param col The column of the cell.
157  */
158  void remove_child(const unsigned row, const unsigned col);
159 
160  /**
161  * Removes and frees a widget in a cell by it's id.
162  *
163  * @param id The id of the widget to free.
164  * @param find_all If true if removes all items with the id,
165  * otherwise it stops after removing the first
166  * item (or once all children have been tested).
167  */
168  void remove_child(const std::string& id, const bool find_all = false);
169 
170  /**
171  * Activates all children.
172  *
173  * If a child inherits from styled_widget or is a grid it will call
174  * set_active() for the child otherwise it ignores the widget.
175  *
176  * @param active Parameter for set_active.
177  */
178  void set_active(const bool active);
179 
180  /** Returns the widget in the selected cell. */
181  const widget* get_widget(const unsigned row, const unsigned col) const
182  {
183  return get_child(row, col).get_widget();
184  }
185 
186  /** Returns the widget in the selected cell. */
187  widget* get_widget(const unsigned row, const unsigned col)
188  {
189  return get_child(row, col).get_widget();
190  }
191 
192  virtual bool can_mouse_focus() const override { return false; }
193  /***** ***** ***** ***** layout functions ***** ***** ***** *****/
194 
195  /** See @ref widget::layout_initialize. */
196  virtual void layout_initialize(const bool full_initialization) override;
197 
198  /**
199  * Tries to reduce the width of a container.
200  *
201  * See @ref layout_algorithm for more information.
202  *
203  * @param maximum_width The wanted maximum width.
204  */
205  void reduce_width(const unsigned maximum_width);
206 
207  /** See @ref widget::request_reduce_width. */
208  virtual void request_reduce_width(const unsigned maximum_width) override;
209 
210  /** See @ref widget::demand_reduce_width. */
211  virtual void demand_reduce_width(const unsigned maximum_width) override;
212 
213  /**
214  * Tries to reduce the height of a container.
215  *
216  * See @ref layout_algorithm for more information.
217  *
218  * @param maximum_height The wanted maximum height.
219  */
220  void reduce_height(const unsigned maximum_height);
221 
222  /** See @ref widget::request_reduce_height. */
223  virtual void request_reduce_height(const unsigned maximum_height) override;
224 
225  /** See @ref widget::demand_reduce_height. */
226  virtual void demand_reduce_height(const unsigned maximum_height) override;
227 
228  /**
229  * Recalculates the best size.
230  *
231  * This is used for scrollbar containers when they try to update their
232  * contents size before falling back to the 'global' invalidate_layout.
233  *
234  * @returns The newly calculated size.
235  */
237 
238  /**
239  * Modifies the widget alignment data of a child cell containing a specific widget.
240  *
241  * @param widget The widget whose cell to modify.
242  * @param set_flag The alignment flag to set.
243  * @param mode_mask Whether to affect horizontal or vertical alignment.
244  * Use either HORIZONTAL_MASK or VERTICAL_MASK
245  */
246  void set_child_alignment(widget* widget, unsigned set_flag, unsigned mode_mask);
247 
248 private:
249  /** See @ref widget::calculate_best_size. */
250  virtual point calculate_best_size() const override;
251 
252  /**
253  * Attempts to lay out the grid without laying out the entire window.
254  */
255  void request_placement(dispatcher& dispatcher, const event::ui_event event, bool& handled, bool& halt);
256 
257 public:
258  /** See @ref widget::can_wrap. */
259  virtual bool can_wrap() const override;
260 
261 public:
262  /** See @ref widget::place. */
263  virtual void place(const point& origin, const point& size) override;
264 
265  /***** ***** ***** ***** Inherited ***** ***** ***** *****/
266 
267  /** See @ref widget::set_origin. */
268  virtual void set_origin(const point& origin) override;
269 
270  /** See @ref widget::set_visible_rectangle. */
271  virtual void set_visible_rectangle(const SDL_Rect& rectangle) override;
272 
273  /** See @ref widget::layout_children. */
274  virtual void layout_children() override;
275 
276  /** See @ref widget::find_at. */
277  virtual widget* find_at(const point& coordinate,
278  const bool must_be_active) override;
279 
280  /** See @ref widget::find_at. */
281  virtual const widget* find_at(const point& coordinate,
282  const bool must_be_active) const override;
283 
284  /** See @ref widget::find. */
285  widget* find(const std::string_view id, const bool must_be_active) override;
286 
287  /** See @ref widget::find. */
288  const widget* find(const std::string_view id, const bool must_be_active) const override;
289 
290  /** See @ref widget::has_widget. */
291  virtual bool has_widget(const widget& widget) const override;
292 
293  /** See @ref widget::disable_click_dismiss. */
294  bool disable_click_dismiss() const override;
295 
296  /** See @ref widget::create_walker. */
297  virtual iteration::walker_ptr create_walker() override;
298 
299  /***** ***** ***** setters / getters for members ***** ****** *****/
300 
301  void set_rows(const unsigned rows);
302  unsigned int get_rows() const
303  {
304  return rows_;
305  }
306 
307  void set_cols(const unsigned cols);
308  unsigned int get_cols() const
309  {
310  return cols_;
311  }
312 
313  /**
314  * Wrapper to set_rows and set_cols.
315  *
316  * @param rows Parameter to call set_rows with.
317  * @param cols Parameter to call set_cols with.
318  */
319  void set_rows_cols(const unsigned rows, const unsigned cols);
320 
321 private:
322  /** Child item of the grid. */
323  class child
324  {
325  friend struct grid_implementation;
326 
327  public:
328  // Fixme make a class where we can store some properties in the cache
329  // regarding size etc.
330  child() : flags_(0), border_size_(0), widget_(nullptr)
331  {
332  }
333 
334  /**
335  * Move constructor.
336  *
337  * This is necessary in order that the child objects be moved instead
338  * of copied when the grid's child vector is resized. std::vector will
339  * utilize a move constructor as long as a non-throwing one is provided.
340  */
341  child(child&&) noexcept = default;
342 
343  /** Returns the best size for the cell. */
344  point get_best_size() const;
345 
346  /**
347  * Places the widget in the cell.
348  *
349  * @param origin The origin (x, y) for the widget.
350  * @param size The size for the widget.
351  */
352  void place(point origin, point size);
353 
354  /** Forwards @ref grid::layout_initialize to the cell. */
355  void layout_initialize(const bool full_initialization);
356 
357  /** Returns the can_wrap for the cell. */
358  bool can_wrap() const
359  {
360  return widget_ ? widget_->can_wrap() : false;
361  }
362 
363  /** Returns the id of the widget/ */
364  const std::string& id() const;
365 
366  unsigned get_flags() const
367  {
368  return flags_;
369  }
370 
371  void set_flags(const unsigned flags)
372  {
373  flags_ = flags;
374  }
375 
376  unsigned get_border_size() const
377  {
378  return border_size_;
379  }
380 
381  void set_border_size(const unsigned border_size)
382  {
383  border_size_ = border_size;
384  }
385 
386  const widget* get_widget() const
387  {
388  return widget_.get();
389  }
390 
392  {
393  return widget_.get();
394  }
395 
396  /** Acquires an owning reference to the given widget. */
397  void set_widget(std::unique_ptr<widget> widget)
398  {
399  widget_ = std::move(widget);
400  }
401 
402  /**
403  * Releases widget from ownership by this child and returns it in the
404  * form of a new shared_ptr. widget_ will be null after this is called.
405  */
406  std::unique_ptr<widget> free_widget()
407  {
408  return std::exchange(widget_, nullptr);
409  }
410 
411  private:
412  /** The flags for the border and cell setup. */
413  unsigned flags_;
414 
415  /**
416  * The size of the border, the actual configuration of the border
417  * is determined by the flags.
418  */
419  unsigned border_size_;
420 
421  /**
422  * Pointer to the widget.
423  *
424  * Once the widget is assigned to the grid we own the widget and it
425  * will be destroyed with the grid or @ref free_widget is called.
426  */
427  std::unique_ptr<widget> widget_;
428 
429  /** Returns the space needed for the border. */
430  point border_space() const;
431 
432  }; // class child
433 
434 public:
435  /** Iterator for the child items. */
436  class iterator
437  {
438 
439  public:
441  {
442  }
443 
445  {
446  return iterator(++itor_);
447  }
448 
450  {
451  return iterator(--itor_);
452  }
453 
455  {
456  return itor_->get_widget();
457  }
458 
460  {
461  return itor_->get_widget();
462  }
463 
464  bool operator==(const iterator& i) const
465  {
466  return i.itor_ == this->itor_;
467  }
468 
469  bool operator!=(const iterator& i) const
470  {
471  return i.itor_ != this->itor_;
472  }
473 
474  private:
476  };
477 
479  {
480  return iterator(children_.begin());
481  }
483  {
484  return iterator(children_.end());
485  }
486 
487 private:
488  /** The number of grid rows. */
489  unsigned rows_;
490 
491  /** The number of grid columns. */
492  unsigned cols_;
493 
494  /***** ***** ***** ***** size caching ***** ***** ***** *****/
495 
496  /** The row heights in the grid. */
497  mutable std::vector<unsigned> row_height_;
498 
499  /** The column widths in the grid. */
500  mutable std::vector<unsigned> col_width_;
501 
502  /** The grow factor for all rows. */
503  std::vector<unsigned> row_grow_factor_;
504 
505  /** The grow factor for all columns. */
506  std::vector<unsigned> col_grow_factor_;
507 
508  /**
509  * The child items.
510  *
511  * All children are stored in a 1D vector and the formula to access a cell
512  * is: rows_ * col + row. All other vectors use the same access formula.
513  */
514  std::vector<child> children_;
515 
516  /**
517  * Gets the grid child in the specified cell.
518  *
519  * @param row The row of the cell.
520  * @param col The column of the cell.
521  *
522  * @returns A const reference to the specified grid child.
523  */
524  const grid::child& get_child(const unsigned row, const unsigned col) const
525  {
526  return children_[rows_ * col + row];
527  }
528 
529  /**
530  * Gets the grid child in the specified cell.
531  *
532  * @param row The row of the cell.
533  * @param col The column of the cell.
534  *
535  * @returns A const reference to the specified grid child.
536  */
537  grid::child& get_child(const unsigned row, const unsigned col)
538  {
539  return children_[rows_ * col + row];
540  }
541 
542  /**
543  * Gets the grid child containing the specified widget.
544  *
545  * @param w The widget to search for.
546  *
547  * @returns A pointer to the relevant grid child, or nullptr
548  * if no grid cell 'owns' the given widget.
549  */
551 
552  /** Layouts the children in the grid. */
553  void layout(const point& origin);
554 
555  /** See @ref widget::impl_draw_children. */
556  virtual void impl_draw_children() override;
557 };
558 
559 /**
560  * Sets the single child in a grid.
561  *
562  * The function initializes the grid to 1 x 1 and adds the widget with the grow
563  * to client flags.
564  *
565  * @param grid The grid to add the child to.
566  * @param widget The widget to add as child to the grid.
567  */
568 void set_single_child(grid& grid, std::unique_ptr<widget> widget);
569 
570 } // namespace gui2
Child item of the grid.
Definition: grid.hpp:324
void place(point origin, point size)
Places the widget in the cell.
Definition: grid.cpp:753
unsigned border_size_
The size of the border, the actual configuration of the border is determined by the flags.
Definition: grid.hpp:419
void layout_initialize(const bool full_initialization)
Forwards grid::layout_initialize to the cell.
Definition: grid.cpp:881
void set_border_size(const unsigned border_size)
Definition: grid.hpp:381
void set_widget(std::unique_ptr< widget > widget)
Acquires an owning reference to the given widget.
Definition: grid.hpp:397
unsigned get_border_size() const
Definition: grid.hpp:376
unsigned flags_
The flags for the border and cell setup.
Definition: grid.hpp:413
void set_flags(const unsigned flags)
Definition: grid.hpp:371
const std::string & id() const
Returns the id of the widget/.
Definition: grid.cpp:890
widget * get_widget()
Definition: grid.hpp:391
point get_best_size() const
Returns the best size for the cell.
Definition: grid.cpp:729
const widget * get_widget() const
Definition: grid.hpp:386
std::unique_ptr< widget > free_widget()
Releases widget from ownership by this child and returns it in the form of a new shared_ptr.
Definition: grid.hpp:406
point border_space() const
Returns the space needed for the border.
Definition: grid.cpp:896
child(child &&) noexcept=default
Move constructor.
unsigned get_flags() const
Definition: grid.hpp:366
bool can_wrap() const
Returns the can_wrap for the cell.
Definition: grid.hpp:358
std::unique_ptr< widget > widget_
Pointer to the widget.
Definition: grid.hpp:427
Iterator for the child items.
Definition: grid.hpp:437
iterator(std::vector< child >::iterator itor)
Definition: grid.hpp:440
std::vector< child >::iterator itor_
Definition: grid.hpp:475
widget * operator->()
Definition: grid.hpp:454
iterator operator--()
Definition: grid.hpp:449
widget * operator*()
Definition: grid.hpp:459
iterator operator++()
Definition: grid.hpp:444
bool operator==(const iterator &i) const
Definition: grid.hpp:464
bool operator!=(const iterator &i) const
Definition: grid.hpp:469
Base container class.
Definition: grid.hpp:32
void set_active(const bool active)
Activates all children.
Definition: grid.cpp:167
virtual void impl_draw_children() override
See widget::impl_draw_children.
Definition: grid.cpp:981
virtual bool has_widget(const widget &widget) const override
See widget::has_widget.
Definition: grid.cpp:655
void request_placement(dispatcher &dispatcher, const event::ui_event event, bool &handled, bool &halt)
Attempts to lay out the grid without laying out the entire window.
Definition: grid.cpp:379
virtual point calculate_best_size() const override
See widget::calculate_best_size.
Definition: grid.cpp:427
std::unique_ptr< widget > swap_child(const std::string &id, std::unique_ptr< widget > w, const bool recurse, widget *new_parent=nullptr)
Exchanges a child in the grid.
Definition: grid.cpp:101
bool disable_click_dismiss() const override
See widget::disable_click_dismiss.
Definition: grid.cpp:670
static const unsigned HORIZONTAL_GROW_SEND_TO_CLIENT
Definition: grid.hpp:56
static const unsigned HORIZONTAL_ALIGN_RIGHT
Definition: grid.hpp:59
const grid::child & get_child(const unsigned row, const unsigned col) const
Gets the grid child in the specified cell.
Definition: grid.hpp:524
virtual void place(const point &origin, const point &size) override
See widget::place.
Definition: grid.cpp:484
void set_row_grow_factor(const unsigned row, const unsigned factor)
Sets the grow factor for a row.
Definition: grid.hpp:87
void reduce_height(const unsigned maximum_height)
Tries to reduce the height of a container.
Definition: grid.cpp:281
grid::child & get_child(const unsigned row, const unsigned col)
Gets the grid child in the specified cell.
Definition: grid.hpp:537
virtual void set_visible_rectangle(const SDL_Rect &rectangle) override
See widget::set_visible_rectangle.
Definition: grid.cpp:608
virtual iteration::walker_ptr create_walker() override
See widget::create_walker.
Definition: grid.cpp:688
unsigned add_row(const unsigned count=1)
Adds a row to end of the grid.
Definition: grid.cpp:60
const widget * get_widget(const unsigned row, const unsigned col) const
Returns the widget in the selected cell.
Definition: grid.hpp:181
static const unsigned HORIZONTAL_SHIFT
Definition: grid.hpp:55
void reduce_width(const unsigned maximum_width)
Tries to reduce the width of a container.
Definition: grid.cpp:203
unsigned int get_rows() const
Definition: grid.hpp:302
static const unsigned HORIZONTAL_MASK
Definition: grid.hpp:60
point recalculate_best_size()
Recalculates the best size.
Definition: grid.cpp:420
void set_column_grow_factor(const unsigned column, const unsigned factor)
Sets the grow factor for a column.
Definition: grid.hpp:102
std::vector< child > children_
The child items.
Definition: grid.hpp:514
static const unsigned VERTICAL_ALIGN_BOTTOM
Definition: grid.hpp:52
static const unsigned BORDER_TOP
Definition: grid.hpp:62
iterator begin()
Definition: grid.hpp:478
std::vector< unsigned > col_width_
The column widths in the grid.
Definition: grid.hpp:500
void set_cols(const unsigned cols)
Definition: grid.cpp:702
static const unsigned VERTICAL_ALIGN_CENTER
Definition: grid.hpp:51
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
Definition: grid.cpp:632
void set_rows(const unsigned rows)
Definition: grid.cpp:693
static const unsigned VERTICAL_GROW_SEND_TO_CLIENT
Definition: grid.hpp:49
widget * find(const std::string_view id, const bool must_be_active) override
See widget::find.
Definition: grid.cpp:645
static const unsigned BORDER_BOTTOM
Definition: grid.hpp:63
iterator end()
Definition: grid.hpp:482
static const unsigned BORDER_RIGHT
Definition: grid.hpp:65
static const unsigned HORIZONTAL_ALIGN_CENTER
Definition: grid.hpp:58
void remove_child(const unsigned row, const unsigned col)
Removes and frees a widget in a cell.
Definition: grid.cpp:145
friend class debug_layout_graph
Definition: grid.hpp:33
grid(const unsigned rows=0, const unsigned cols=0)
Definition: grid.cpp:40
virtual bool can_mouse_focus() const override
Whether the mouse move/click event go 'through' this widget.
Definition: grid.hpp:192
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:931
void layout(const point &origin)
Layouts the children in the grid.
Definition: grid.cpp:959
widget * get_widget(const unsigned row, const unsigned col)
Returns the widget in the selected cell.
Definition: grid.hpp:187
unsigned cols_
The number of grid columns.
Definition: grid.hpp:492
static const unsigned VERTICAL_MASK
Definition: grid.hpp:53
void set_rows_cols(const unsigned rows, const unsigned cols)
Wrapper to set_rows and set_cols.
Definition: grid.cpp:711
std::vector< unsigned > col_grow_factor_
The grow factor for all columns.
Definition: grid.hpp:506
grid & operator=(const grid &)=delete
Delete the move assignment operator.
std::vector< unsigned > row_height_
The row heights in the grid.
Definition: grid.hpp:497
static const unsigned VERTICAL_ALIGN_TOP
Definition: grid.hpp:50
static const unsigned BORDER_LEFT
Definition: grid.hpp:64
virtual ~grid()
Definition: grid.cpp:56
void set_child(std::unique_ptr< widget > widget, const unsigned row, const unsigned col, const unsigned flags, const unsigned border_size)
Sets a child in the grid.
Definition: grid.cpp:71
unsigned int get_cols() const
Definition: grid.hpp:308
static const unsigned BORDER_ALL
Definition: grid.hpp:66
virtual void set_origin(const point &origin) override
See widget::set_origin.
Definition: grid.cpp:591
virtual void demand_reduce_height(const unsigned maximum_height) override
See widget::demand_reduce_height.
Definition: grid.cpp:374
grid(const grid &)=delete
Delete the copy constructor.
virtual bool can_wrap() const override
See widget::can_wrap.
Definition: grid.cpp:471
virtual void layout_children() override
See widget::layout_children.
Definition: grid.cpp:623
virtual void layout_initialize(const bool full_initialization) override
See widget::layout_initialize.
Definition: grid.cpp:190
virtual void request_reduce_width(const unsigned maximum_width) override
See widget::request_reduce_width.
Definition: grid.cpp:236
std::vector< unsigned > row_grow_factor_
The grow factor for all rows.
Definition: grid.hpp:503
virtual void request_reduce_height(const unsigned maximum_height) override
See widget::request_reduce_height.
Definition: grid.cpp:314
unsigned rows_
The number of grid rows.
Definition: grid.hpp:489
static const unsigned HORIZONTAL_ALIGN_LEFT
Definition: grid.hpp:57
static const unsigned VERTICAL_SHIFT
Definition: grid.hpp:48
virtual void demand_reduce_width(const unsigned maximum_width) override
See widget::demand_reduce_width.
Definition: grid.cpp:276
Base class for all widgets.
Definition: widget.hpp:55
void queue_redraw()
Indicates that this widget should be redrawn.
Definition: widget.cpp:464
std::size_t i
Definition: function.cpp:1029
int w
ui_event
The event sent to the dispatcher.
Definition: handler.hpp:115
std::unique_ptr< class walker_base > walker_ptr
Definition: widget.hpp:44
Generic file dialog.
void set_single_child(grid &grid, std::unique_ptr< widget > widget)
Sets the single child in a grid.
Definition: grid.cpp:1102
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::const_iterator iterator
Definition: tokenizer.hpp:25
Helper to implement private functions without modifying the header.
Holds a 2D point.
Definition: point.hpp:25