# Plutonium framework API: Plutonium/include/pu/ui/elm/elm_Element.hpp Source File

elm_Element.hpp
Go to the documentation of this file.
/*
Plutonium library
@file Element.hpp
@brief An Element is the base of Plutonium UI's content.
@author XorTroll
@copyright Plutonium project - an easy-to-use UI framework for Nintendo Switch homebrew
*/
#pragma once
#include <pu/ui/render/render_Renderer.hpp>
namespace pu::ui {
class Container;
}
namespace pu::ui::elm {
enum class HorizontalAlign {
Left,
Center,
Right
};
enum class VerticalAlign {
Up,
Center,
Down
};
class Element {
protected:
bool visible;
HorizontalAlign h_align;
VerticalAlign v_align;
Container *parent_container;
public:
Element() : visible(true), h_align(HorizontalAlign::Left), v_align(VerticalAlign::Up), parent_container(nullptr) {}
PU_SMART_CTOR(Element)
virtual ~Element() {}
virtual i32 GetX() = 0;
virtual i32 GetY() = 0;
virtual i32 GetWidth() = 0;
virtual i32 GetHeight() = 0;
virtual void OnRender(render::Renderer::Ref &drawer, const i32 x, const i32 y) = 0;
virtual void OnInput(const u64 keys_down, const u64 keys_up, const u64 keys_held, const TouchPoint touch_pos) = 0;
inline bool IsVisible() {
return this->visible;
}
inline void SetVisible(const bool visible) {
this->visible = visible;
}
inline void SetHorizontalAlign(const HorizontalAlign align) {
this->h_align = align;
}
inline HorizontalAlign GetHorizontalAlign() {
return this->h_align;
}
inline void SetVerticalAlign(const VerticalAlign align) {
this->v_align = align;
}
inline VerticalAlign GetVerticalAlign() {
return this->v_align;
}
inline void SetParentContainer(Container *parent_container) {
this->parent_container = parent_container;
}
i32 GetProcessedX();
i32 GetProcessedY();
};
}
pu::ui::Container
Definition: ui_Container.hpp:21
pu::ui::elm::Element
Definition: elm_Element.hpp:37
pu::ui::elm::Element::OnRender
virtual void OnRender(render::Renderer::Ref &drawer, const i32 x, const i32 y)=0
pu::ui::elm::Element::GetY
virtual i32 GetY()=0
pu::ui::elm::Element::GetProcessedY
i32 GetProcessedY()
pu::ui::elm::Element::h_align
HorizontalAlign h_align
Definition: elm_Element.hpp:40
pu::ui::elm::Element::SetVerticalAlign
void SetVerticalAlign(const VerticalAlign align)
Definition: elm_Element.hpp:72
pu::ui::elm::Element::parent_container
Container * parent_container
Definition: elm_Element.hpp:42
pu::ui::elm::Element::GetVerticalAlign
VerticalAlign GetVerticalAlign()
Definition: elm_Element.hpp:76
pu::ui::elm::Element::GetProcessedX
i32 GetProcessedX()
pu::ui::elm::Element::GetHorizontalAlign
HorizontalAlign GetHorizontalAlign()
Definition: elm_Element.hpp:68
pu::ui::elm::Element::SetVisible
void SetVisible(const bool visible)
Definition: elm_Element.hpp:60
pu::ui::elm::Element::IsVisible
bool IsVisible()
Definition: elm_Element.hpp:56
pu::ui::elm::Element::GetX
virtual i32 GetX()=0
pu::ui::elm::Element::GetHeight
virtual i32 GetHeight()=0
pu::ui::elm::Element::SetHorizontalAlign
void SetHorizontalAlign(const HorizontalAlign align)
Definition: elm_Element.hpp:64
pu::ui::elm::Element::v_align
VerticalAlign v_align
Definition: elm_Element.hpp:41
pu::ui::elm::Element::GetWidth
virtual i32 GetWidth()=0
pu::ui::elm::Element::Element
Element()
Definition: elm_Element.hpp:45
pu::ui::elm::Element::visible
bool visible
Definition: elm_Element.hpp:39
pu::ui::elm::Element::SetParentContainer
void SetParentContainer(Container *parent_container)
Definition: elm_Element.hpp:80
pu::ui::elm::Element::OnInput
virtual void OnInput(const u64 keys_down, const u64 keys_up, const u64 keys_held, const TouchPoint touch_pos)=0
pu::ui::elm
Definition: elm_Button.hpp:18
pu::ui::elm::HorizontalAlign
HorizontalAlign
Definition: elm_Element.hpp:25
pu::ui::elm::HorizontalAlign::Center
@ Center
pu::ui::elm::HorizontalAlign::Right
@ Right
pu::ui::elm::HorizontalAlign::Left
@ Left
pu::ui::elm::VerticalAlign
VerticalAlign
Definition: elm_Element.hpp:31
pu::ui::elm::VerticalAlign::Down
@ Down
pu::ui::elm::VerticalAlign::Up
@ Up
pu::ui
Definition: elm_Button.hpp:18
pu::i32
s32 i32
Definition: pu_Include.hpp:28
PU_SMART_CTOR
#define PU_SMART_CTOR(type)
Definition: pu_Include.hpp:19
render_Renderer.hpp
pu::ui::TouchPoint
Definition: ui_Types.hpp:62