The Battle for Wesnoth  1.17.0-dev
viewport.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2021
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 
19 #include "gui/widgets/widget.hpp"
20 
21 namespace gui2
22 {
23 
24 // ------------ WIDGET -----------{
25 
26 namespace implementation
27 {
28 struct builder_viewport;
29 } // namespace implementation
30 
31 class grid;
32 
33 /**
34  * @ingroup GUIWidgetWML
35  *
36  * A viewport is an special widget used to view only a part of the widget it 'holds'.
37  *
38  * List with the viewport specific variables:
39  * Key |Type |Default |Description
40  * ---------------|------------------------------------------------|---------|-----------
41  * grow_direction | @ref guivartype_grow_direction "grow_direction"|mandatory|The direction in which new items grow.
42  * parallel_items | @ref guivartype_unsigned "unsigned" |mandatory|The number of items that are growing in parallel.
43  * item_definition| @ref guivartype_section "section" |mandatory|The definition of a new item.
44  */
45 class viewport : public widget
46 {
47  friend struct viewport_implementation;
48 
49 private:
51  const builder_widget::replacements_map& replacements);
52 
53 public:
54  static viewport* build(const implementation::builder_viewport& builder,
55  const builder_widget::replacements_map& replacements);
56 
57  ~viewport();
58 
59  /** See @ref widget::place. */
60  virtual void place(const point& origin, const point& size) override;
61 
62  /** See @ref widget::layout_initialize. */
63  virtual void layout_initialize(const bool full_initialization) override;
64 
65  /** See @ref widget::impl_draw_children. */
66  virtual void impl_draw_children(surface& frame_buffer,
67  int x_offset,
68  int y_offset) override;
69 
70  /** See @ref widget::child_populate_dirty_list. */
71  virtual void
72  child_populate_dirty_list(window& caller,
73  const std::vector<widget*>& call_stack) override;
74 
75  /** See @ref widget::request_reduce_width. */
76  virtual void request_reduce_width(const unsigned maximum_width) override;
77 
78  /** See @ref widget::find_at. */
79  virtual widget* find_at(const point& coordinate,
80  const bool must_be_active) override;
81 
82  /** See @ref widget::find_at. */
83  virtual const widget* find_at(const point& coordinate,
84  const bool must_be_active) const override;
85 
86  /** See @ref widget::find. */
87  widget* find(const std::string& id, const bool must_be_active) override;
88 
89  /** See @ref widget::find. */
90  const widget* find(const std::string& id,
91  const bool must_be_active) const override;
92 
93 private:
94  /** See @ref widget::calculate_best_size. */
95  virtual point calculate_best_size() const override;
96 
97 public:
98  /** See @ref widget::disable_click_dismiss. */
99  bool disable_click_dismiss() const override;
100 
101  /** See @ref widget::create_walker. */
102  virtual iteration::walker_base* create_walker() override;
103 
104 private:
106 
108 };
109 
110 // }---------- BUILDER -----------{
111 
112 namespace implementation
113 {
114 
116 {
117  explicit builder_viewport(const config& cfg);
118 
119  virtual widget* build() const override;
120 
121  virtual widget* build(const replacements_map& replacements) const override;
122 
124 };
125 
126 } // namespace implementation
127 
128 // }------------ END --------------
129 
130 } // namespace gui2
Contains the info needed to instantiate a widget.
Helper to implement private functions without modifying the header.
Definition: viewport.cpp:39
Base class for all widgets.
Definition: widget.hpp:49
std::shared_ptr< builder_widget > builder_widget_ptr
Generic file dialog.
Definition: field-fwd.hpp:23
widget & widget_
Definition: viewport.hpp:105
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:87
std::map< std::string, std::shared_ptr< builder_widget > > replacements_map
The replacements type is used to define replacement types.
The walker abstract base class.
Definition: walker.hpp:27
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
A viewport is an special widget used to view only a part of the widget it &#39;holds&#39;.
Definition: viewport.hpp:45
Holds a 2D point.
Definition: point.hpp:24
bool grid()
Definition: general.cpp:525
std::unique_ptr< window > build(const builder_window::window_resolution &definition)
Builds a window.
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:61
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:65
Contains the implementation details for lexical_cast and shouldn&#39;t be used directly.