Polyphase Game Engine
Loading...
Searching...
No Matches
CheckBox.h
Go to the documentation of this file.
1#pragma once
2
4
5class Texture;
6class Quad;
7class Text;
8
10{
11public:
12
14
15 virtual void Create() override;
16 virtual void GatherProperties(std::vector<Property>& props) override;
17 virtual void Tick(float deltaTime) override;
18 virtual void EditorTick(float deltaTime) override;
19 virtual void PreRender() override;
20
21 // State
22 void SetChecked(bool checked);
23 bool IsChecked() const;
24 void Toggle();
25
26 // Text
27 void SetText(const std::string& text);
28 const std::string& GetText() const;
29
30 // Visual
31 void SetCheckedTexture(Texture* texture);
32 Texture* GetCheckedTexture();
33 void SetUncheckedTexture(Texture* texture);
34 Texture* GetUncheckedTexture();
35 void SetCheckedColor(glm::vec4 color);
36 glm::vec4 GetCheckedColor();
37 void SetUncheckedColor(glm::vec4 color);
38 glm::vec4 GetUncheckedColor();
39 void SetTextColor(glm::vec4 color);
40 glm::vec4 GetTextColor();
41 void SetBoxSize(float size);
42 float GetBoxSize() const;
43 void SetSpacing(float spacing);
44 float GetSpacing() const;
45
46 // Children
47 Quad* GetBoxQuad();
48 Text* GetTextWidget();
49
50protected:
51
52 static bool HandlePropChange(Datum* datum, uint32_t index, const void* newValue);
53
54 void UpdateAppearance();
55
56 // State
57 bool mChecked = false;
58
59 // Text
60 std::string mTextContent = "CheckBox";
61
62 // Visual
65 glm::vec4 mCheckedColor = { 0.3f, 0.7f, 0.3f, 1.0f };
66 glm::vec4 mUncheckedColor = { 0.4f, 0.4f, 0.4f, 1.0f };
67 glm::vec4 mHoveredColor = { 0.5f, 0.5f, 0.5f, 1.0f };
68 glm::vec4 mTextColor = { 1.0f, 1.0f, 1.0f, 1.0f };
69 float mBoxSize = 20.0f;
70 float mSpacing = 8.0f;
71
72 // State
73 bool mHovered = false;
74
75 // Children
76 Quad* mBoxQuad = nullptr;
77 Text* mText = nullptr;
78};
#define POLYPHASE_API
Definition PolyphaseAPI.h:31
Definition AssetRef.h:18
Definition CheckBox.h:10
TextureRef mUncheckedTexture
Definition CheckBox.h:64
TextureRef mCheckedTexture
Definition CheckBox.h:63
DECLARE_NODE(CheckBox, Widget)
Definition Datum.h:164
virtual void EditorTick(float deltaTime)
Definition Node.cpp:563
virtual void Create()
Definition Node.cpp:220
virtual void Tick(float deltaTime)
Definition Node.cpp:558
Definition Quad.h:20
Definition Text.h:24
Definition Texture.h:10
Definition Widget.h:53
static bool HandlePropChange(Datum *datum, uint32_t index, const void *newValue)
Definition Widget.cpp:45
virtual void GatherProperties(std::vector< Property > &outProps) override
Definition Widget.cpp:115
virtual void PreRender()
Definition Widget.cpp:226