Euphoria
widget.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "base/rect.h"
4 #include "base/size2.h"
5 #include "base/lrud.h"
6 
7 #include "gui/layoutdata.h"
8 
9 
10 namespace eu::render
11 {
12  struct SpriteRenderer;
13 }
14 
15 namespace eu::gui
16 {
17  struct State;
18  struct Visitor;
19 }
20 
21 namespace eu::gui
22 {
23  struct Widget
24  {
25  std::string name;
28 
29  explicit
31 
32  virtual
34 
35  Widget(const Widget& other) = delete;
36  void operator=(const Widget&) = delete;
37  Widget(Widget&& other) = delete;
38  void operator=(Widget&&) = delete;
39 
40  [[nodiscard]] bool
41  is_active() const;
42 
43  [[nodiscard]] bool
44  is_hot() const;
45 
46  virtual
47  void
48  update(float dt) = 0;
49 
50  virtual
51  void
53 
54  [[nodiscard]] Rectf
55  get_client_rect() const;
56 
57  [[nodiscard]] Rectf
58  get_background_rect() const;
59 
60  void
61  set_rect(const Rectf& r);
62 
63  [[nodiscard]] size2f
64  get_preferred_size() const;
65 
66  [[nodiscard]] virtual
67  size2f
68  calc_minimum_size() const = 0;
69 
70  virtual
71  void
72  render(render::SpriteRenderer* renderer) const = 0;
73 
74  virtual
75  void
76  visit(Visitor* visitor) = 0;
77 
78  [[nodiscard]] const gui::State&
79  get_state() const;
80 
81  [[nodiscard]] gui::State*
82  get_state_ptr() const;
83 
85 
88  };
89 }
State
enum to catch adding arguments during parsing in a callback
Definition: argparse.h:23
Definition: rect.h:27
virtual void update(float dt)=0
LayoutData layout
Definition: widget.h:86
virtual ~Widget()
Rectf rect
Definition: widget.h:87
void operator=(Widget &&)=delete
std::string name
Definition: widget.h:25
Lrud< float > padding
Definition: widget.h:27
Rectf get_client_rect() const
Definition: widget.cc:42
virtual void visit(Visitor *visitor)=0
Lrud< float > margin
Definition: widget.h:26
Widget(const Widget &other)=delete
Widget(gui::State *state)
Definition: widget.cc:10
void set_rect(const Rectf &r)
Definition: widget.cc:56
const gui::State & get_state() const
Definition: widget.cc:95
bool is_hot() const
Definition: widget.cc:29
virtual size2f calc_minimum_size() const =0
Widget(Widget &&other)=delete
gui::State * ui_state
Definition: widget.h:84
virtual void on_size_changed()
Definition: widget.cc:36
size2f get_preferred_size() const
Definition: widget.cc:70
Rectf get_background_rect() const
Definition: widget.cc:49
gui::State * get_state_ptr() const
Definition: widget.cc:102
virtual void render(render::SpriteRenderer *renderer) const =0
bool is_active() const
Definition: widget.cc:22
void operator=(const Widget &)=delete
ParserState state
Definition: ui_text.cc:134