Plutonium framework API 0.3.0
UI framework libraries for libnx
Loading...
Searching...
No Matches
elm_Element.hpp
Go to the documentation of this file.
1
2/*
3
4 Plutonium library
5
6 @file Element.hpp
7 @brief An Element is the base of Plutonium UI's content.
8 @author XorTroll
9
10 @copyright Plutonium project - an easy-to-use UI framework for Nintendo Switch homebrew
11
12*/
13
14#pragma once
15#include <pu/ui/render/render_Renderer.hpp>
16
17namespace pu::ui {
18
19 class Container;
20
21}
22
23namespace pu::ui::elm {
24
25 enum class HorizontalAlign {
26 Left,
27 Center,
28 Right
29 };
30
31 enum class VerticalAlign {
32 Up,
33 Center,
34 Down
35 };
36
37 class Element {
38 protected:
39 bool visible;
43
44 public:
47 virtual ~Element() {}
48
49 virtual i32 GetX() = 0;
50 virtual i32 GetY() = 0;
51 virtual i32 GetWidth() = 0;
52 virtual i32 GetHeight() = 0;
53 virtual void OnRender(render::Renderer::Ref &drawer, const i32 x, const i32 y) = 0;
54 virtual void OnInput(const u64 keys_down, const u64 keys_up, const u64 keys_held, const TouchPoint touch_pos) = 0;
55
56 inline bool IsVisible() {
57 return this->visible;
58 }
59
60 inline void SetVisible(const bool visible) {
61 this->visible = visible;
62 }
63
64 inline void SetHorizontalAlign(const HorizontalAlign align) {
65 this->h_align = align;
66 }
67
69 return this->h_align;
70 }
71
72 inline void SetVerticalAlign(const VerticalAlign align) {
73 this->v_align = align;
74 }
75
77 return this->v_align;
78 }
79
80 inline void SetParentContainer(Container *parent_container) {
81 this->parent_container = parent_container;
82 }
83
86 };
87
88}
Definition ui_Container.hpp:21
Definition elm_Element.hpp:37
virtual void OnRender(render::Renderer::Ref &drawer, const i32 x, const i32 y)=0
virtual i32 GetY()=0
HorizontalAlign h_align
Definition elm_Element.hpp:40
void SetVerticalAlign(const VerticalAlign align)
Definition elm_Element.hpp:72
Container * parent_container
Definition elm_Element.hpp:42
VerticalAlign GetVerticalAlign()
Definition elm_Element.hpp:76
virtual ~Element()
Definition elm_Element.hpp:47
HorizontalAlign GetHorizontalAlign()
Definition elm_Element.hpp:68
void SetVisible(const bool visible)
Definition elm_Element.hpp:60
bool IsVisible()
Definition elm_Element.hpp:56
virtual i32 GetX()=0
virtual i32 GetHeight()=0
void SetHorizontalAlign(const HorizontalAlign align)
Definition elm_Element.hpp:64
VerticalAlign v_align
Definition elm_Element.hpp:41
virtual i32 GetWidth()=0
Element()
Definition elm_Element.hpp:45
bool visible
Definition elm_Element.hpp:39
void SetParentContainer(Container *parent_container)
Definition elm_Element.hpp:80
virtual void OnInput(const u64 keys_down, const u64 keys_up, const u64 keys_held, const TouchPoint touch_pos)=0
Definition render_Renderer.hpp:127
HorizontalAlign
Definition elm_Element.hpp:25
VerticalAlign
Definition elm_Element.hpp:31
Definition render_Renderer.hpp:20
Definition elm_Button.hpp:18
#define PU_SMART_CTOR(type)
Definition pu_Include.hpp:20
Definition ui_Types.hpp:67