Plutonium framework API  0.3
Simple UI framework for libnx and SDL2
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/pu_Macros.hpp>
17 
18 namespace pu::ui::elm
19 {
20  enum class HorizontalAlign
21  {
22  Left,
23  Center,
24  Right,
25  };
26 
27  enum class VerticalAlign
28  {
29  Up,
30  Center,
31  Down,
32  };
33 
34  class Element
35  {
36  public:
37  Element();
39  virtual ~Element();
40 
41  // In order to make custom UI Elements, need to implement this functions
42  virtual i32 GetX() = 0;
43  virtual i32 GetY() = 0;
44  virtual i32 GetWidth() = 0;
45  virtual i32 GetHeight() = 0;
46  virtual void OnRender(render::Renderer::Ref &Drawer, i32 X, i32 Y) = 0;
47  virtual void OnInput(u64 Down, u64 Up, u64 Held, Touch Pos) = 0;
48 
49  bool IsVisible();
50  void SetVisible(bool Visible);
51  void SetParent(void *Base);
52  void *GetParent();
53  void SetHorizontalAlign(HorizontalAlign Align);
54  HorizontalAlign GetHorizontalAlign();
55  void SetVerticalAlign(VerticalAlign Align);
56  VerticalAlign GetVerticalAlign();
57  bool HasParent();
58  i32 GetProcessedX();
59  i32 GetProcessedY();
60  protected:
61  bool visible;
64  void *parent;
65  };
66 }
Definition: elm_Button.hpp:19
bool visible
Definition: elm_Element.hpp:61
VerticalAlign
Definition: elm_Element.hpp:27
HorizontalAlign halign
Definition: elm_Element.hpp:62
Definition: ui_Types.hpp:38
s32 i32
Definition: pu_Macros.hpp:17
#define PU_SMART_CTOR(type)
Definition: pu_Macros.hpp:8
VerticalAlign valign
Definition: elm_Element.hpp:63
HorizontalAlign
Definition: elm_Element.hpp:20
void * parent
Definition: elm_Element.hpp:64
Definition: elm_Element.hpp:34