The Battle for Wesnoth  1.19.0-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& id, const bool must_be_active) override;
286 
287  /** See @ref widget::find. */
288  const widget* find(const std::string& id,
289  const bool must_be_active) const override;
290 
291  /** See @ref widget::has_widget. */
292  virtual bool has_widget(const widget& widget) const override;
293 
294  /** See @ref widget::disable_click_dismiss. */
295  bool disable_click_dismiss() const override;
296 
297  /** See @ref widget::create_walker. */
298  virtual iteration::walker_ptr create_walker() override;
299 
300  /***** ***** ***** setters / getters for members ***** ****** *****/
301 
302  void set_rows(const unsigned rows);
303  unsigned int get_rows() const
304  {
305  return rows_;
306  }
307 
308  void set_cols(const unsigned cols);
309  unsigned int get_cols() const
310  {
311  return cols_;
312  }
313 
314  /**
315  * Wrapper to set_rows and set_cols.
316  *
317  * @param rows Parameter to call set_rows with.
318  * @param cols Parameter to call set_cols with.
319  */
320  void set_rows_cols(const unsigned rows, const unsigned cols);
321 
322 private:
323  /** Child item of the grid. */
324  class child
325  {
326  friend struct grid_implementation;
327 
328  public:
329  // Fixme make a class where we can store some properties in the cache
330  // regarding size etc.
331  child() : flags_(0), border_size_(0), widget_(nullptr)
332  {
333  }
334 
335  /**
336  * Move constructor.
337  *
338  * This is necessary in order that the child objects be moved instead
339  * of copied when the grid's child vector is resized. std::vector will
340  * utilize a move constructor as long as a non-throwing one is provided.
341  */
342  child(child&&) noexcept = default;
343 
344  /** Returns the best size for the cell. */
345  point get_best_size() const;
346 
347  /**
348  * Places the widget in the cell.
349  *
350  * @param origin The origin (x, y) for the widget.
351  * @param size The size for the widget.
352  */
353  void place(point origin, point size);
354 
355  /** Forwards @ref grid::layout_initialize to the cell. */
356  void layout_initialize(const bool full_initialization);
357 
358  /** Returns the can_wrap for the cell. */
359  bool can_wrap() const
360  {
361  return widget_ ? widget_->can_wrap() : false;
362  }
363 
364  /** Returns the id of the widget/ */
365  const std::string& id() const;
366 
367  unsigned get_flags() const
368  {
369  return flags_;
370  }
371 
372  void set_flags(const unsigned flags)
373  {
374  flags_ = flags;
375  }
376 
377  unsigned get_border_size() const
378  {
379  return border_size_;
380  }
381 
382  void set_border_size(const unsigned border_size)
383  {
384  border_size_ = border_size;
385  }
386 
387  const widget* get_widget() const
388  {
389  return widget_.get();
390  }
391 
393  {
394  return widget_.get();
395  }
396 
397  /** Acquires an owning reference to the given widget. */
398  void set_widget(std::unique_ptr<widget> widget)
399  {
400  widget_ = std::move(widget);
401  }
402 
403  /**
404  * Releases widget from ownership by this child and returns it in the
405  * form of a new shared_ptr. widget_ will be null after this is called.
406  */
407  std::unique_ptr<widget> free_widget()
408  {
409  return std::exchange(widget_, nullptr);
410  }
411 
412  private:
413  /** The flags for the border and cell setup. */
414  unsigned flags_;
415 
416  /**
417  * The size of the border, the actual configuration of the border
418  * is determined by the flags.
419  */
420  unsigned border_size_;
421 
422  /**
423  * Pointer to the widget.
424  *
425  * Once the widget is assigned to the grid we own the widget and it
426  * will be destroyed with the grid or @ref free_widget is called.
427  */
428  std::unique_ptr<widget> widget_;
429 
430  /** Returns the space needed for the border. */
431  point border_space() const;
432 
433  }; // class child
434 
435 public:
436  /** Iterator for the child items. */
437  class iterator
438  {
439 
440  public:
442  {
443  }
444 
446  {
447  return iterator(++itor_);
448  }
449 
451  {
452  return iterator(--itor_);
453  }
454 
456  {
457  return itor_->get_widget();
458  }
459 
461  {
462  return itor_->get_widget();
463  }
464 
465  bool operator==(const iterator& i) const
466  {
467  return i.itor_ == this->itor_;
468  }
469 
470  bool operator!=(const iterator& i) const
471  {
472  return i.itor_ != this->itor_;
473  }
474 
475  private:
477  };
478 
480  {
481  return iterator(children_.begin());
482  }
484  {
485  return iterator(children_.end());
486  }
487 
488 private:
489  /** The number of grid rows. */
490  unsigned rows_;
491 
492  /** The number of grid columns. */
493  unsigned cols_;
494 
495  /***** ***** ***** ***** size caching ***** ***** ***** *****/
496 
497  /** The row heights in the grid. */
498  mutable std::vector<unsigned> row_height_;
499 
500  /** The column widths in the grid. */
501  mutable std::vector<unsigned> col_width_;
502 
503  /** The grow factor for all rows. */
504  std::vector<unsigned> row_grow_factor_;
505 
506  /** The grow factor for all columns. */
507  std::vector<unsigned> col_grow_factor_;
508 
509  /**
510  * The child items.
511  *
512  * All children are stored in a 1D vector and the formula to access a cell
513  * is: rows_ * col + row. All other vectors use the same access formula.
514  */
515  std::vector<child> children_;
516 
517  /**
518  * Gets the grid child in the specified cell.
519  *
520  * @param row The row of the cell.
521  * @param col The column of the cell.
522  *
523  * @returns A const reference to the specified grid child.
524  */
525  const grid::child& get_child(const unsigned row, const unsigned col) const
526  {
527  return children_[rows_ * col + row];
528  }
529 
530  /**
531  * Gets the grid child in the specified cell.
532  *
533  * @param row The row of the cell.
534  * @param col The column of the cell.
535  *
536  * @returns A const reference to the specified grid child.
537  */
538  grid::child& get_child(const unsigned row, const unsigned col)
539  {
540  return children_[rows_ * col + row];
541  }
542 
543  /**
544  * Gets the grid child containing the specified widget.
545  *
546  * @param w The widget to search for.
547  *
548  * @returns A pointer to the relevant grid child, or nullptr
549  * if no grid cell 'owns' the given widget.
550  */
552 
553  /** Layouts the children in the grid. */
554  void layout(const point& origin);
555 
556  /** See @ref widget::impl_draw_children. */
557  virtual void impl_draw_children() override;
558 };
559 
560 /**
561  * Sets the single child in a grid.
562  *
563  * The function initializes the grid to 1 x 1 and adds the widget with the grow
564  * to client flags.
565  *
566  * @param grid The grid to add the child to.
567  * @param widget The widget to add as child to the grid.
568  */
569 void set_single_child(grid& grid, std::unique_ptr<widget> widget);
570 
571 } // namespace gui2
Child item of the grid.
Definition: grid.hpp:325
void place(point origin, point size)
Places the widget in the cell.
Definition: grid.cpp:754
unsigned border_size_
The size of the border, the actual configuration of the border is determined by the flags.
Definition: grid.hpp:420
void layout_initialize(const bool full_initialization)
Forwards grid::layout_initialize to the cell.
Definition: grid.cpp:882
void set_border_size(const unsigned border_size)
Definition: grid.hpp:382
void set_widget(std::unique_ptr< widget > widget)
Acquires an owning reference to the given widget.
Definition: grid.hpp:398
unsigned get_border_size() const
Definition: grid.hpp:377
unsigned flags_
The flags for the border and cell setup.
Definition: grid.hpp:414
void set_flags(const unsigned flags)
Definition: grid.hpp:372
const std::string & id() const
Returns the id of the widget/.
Definition: grid.cpp:891
widget * get_widget()
Definition: grid.hpp:392
point get_best_size() const
Returns the best size for the cell.
Definition: grid.cpp:730
const widget * get_widget() const
Definition: grid.hpp:387
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:407
point border_space() const
Returns the space needed for the border.
Definition: grid.cpp:897
child(child &&) noexcept=default
Move constructor.
unsigned get_flags() const
Definition: grid.hpp:367
bool can_wrap() const
Returns the can_wrap for the cell.
Definition: grid.hpp:359
std::unique_ptr< widget > widget_
Pointer to the widget.
Definition: grid.hpp:428
Iterator for the child items.
Definition: grid.hpp:438
iterator(std::vector< child >::iterator itor)
Definition: grid.hpp:441
std::vector< child >::iterator itor_
Definition: grid.hpp:476
widget * operator->()
Definition: grid.hpp:455
iterator operator--()
Definition: grid.hpp:450
widget * operator*()
Definition: grid.hpp:460
iterator operator++()
Definition: grid.hpp:445
bool operator==(const iterator &i) const
Definition: grid.hpp:465
bool operator!=(const iterator &i) const
Definition: grid.hpp:470
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:982
virtual bool has_widget(const widget &widget) const override
See widget::has_widget.
Definition: grid.cpp:656
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:671
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:525
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:538
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:689
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:303
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:515
static const unsigned VERTICAL_ALIGN_BOTTOM
Definition: grid.hpp:52
static const unsigned BORDER_TOP
Definition: grid.hpp:62
iterator begin()
Definition: grid.hpp:479
std::vector< unsigned > col_width_
The column widths in the grid.
Definition: grid.hpp:501
void set_cols(const unsigned cols)
Definition: grid.cpp:703
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:694
static const unsigned VERTICAL_GROW_SEND_TO_CLIENT
Definition: grid.hpp:49
static const unsigned BORDER_BOTTOM
Definition: grid.hpp:63
iterator end()
Definition: grid.hpp:483
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:932
void layout(const point &origin)
Layouts the children in the grid.
Definition: grid.cpp:960
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:493
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:712
std::vector< unsigned > col_grow_factor_
The grow factor for all columns.
Definition: grid.hpp:507
widget * find(const std::string &id, const bool must_be_active) override
See widget::find.
Definition: grid.cpp:645
grid & operator=(const grid &)=delete
Delete the move assignment operator.
std::vector< unsigned > row_height_
The row heights in the grid.
Definition: grid.hpp:498
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:309
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:504
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:490
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:53
void queue_redraw()
Indicates that this widget should be redrawn.
Definition: widget.cpp:455
std::size_t i
Definition: function.cpp:968
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:42
Generic file dialog.
void set_single_child(grid &grid, std::unique_ptr< widget > widget)
Sets the single child in a grid.
Definition: grid.cpp:1103
bool grid()
Definition: general.cpp:565
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
std::size_t size(const std::string &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