Plutonium framework API  0.1
Simple UI framework for libnx and SDL2
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 the 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/render/Renderer.hpp>
16 
17 namespace pu::element
18 {
20  {
21  Up,
22  Down,
23  Left,
24  Right,
25  };
26 
27  class Element
28  {
29  public:
30  Element();
31  virtual ~Element();
32  virtual u32 GetX() = 0;
33  virtual u32 GetY() = 0;
34  virtual u32 GetWidth() = 0;
35  virtual u32 GetHeight() = 0;
36  virtual void OnRender(render::Renderer *Drawer) = 0;
37  virtual void OnInput(u64 Down, u64 Up, u64 Held, bool Touch, bool Focus) = 0;
38  void ProcessInput(void *Lyt, u64 Down, u64 Up, u64 Held, bool Touch);
39  bool IsVisible();
40  void SetVisible(bool Visible);
41  bool IsAffectedByFocus();
42  void SetAffectedByFocus(bool Affected);
44  void SetFocusChangeElement(FocusChangeDirection Direction, Element *ToChange);
45  protected:
46  bool visible;
47  bool afocus;
52  };
53 }
Element * GetFocusChangeElement(FocusChangeDirection Direction)
Definition: Renderer.hpp:22
Definition: Button.hpp:18
Element * fup
Definition: Element.hpp:48
bool afocus
Definition: Element.hpp:47
Definition: Element.hpp:27
bool visible
Definition: Element.hpp:46
virtual u32 GetWidth()=0
virtual void OnRender(render::Renderer *Drawer)=0
void SetVisible(bool Visible)
virtual u32 GetHeight()=0
void ProcessInput(void *Lyt, u64 Down, u64 Up, u64 Held, bool Touch)
void SetAffectedByFocus(bool Affected)
virtual u32 GetX()=0
FocusChangeDirection
Definition: Element.hpp:19
virtual void OnInput(u64 Down, u64 Up, u64 Held, bool Touch, bool Focus)=0
Element * fright
Definition: Element.hpp:51
virtual u32 GetY()=0
Element * fdown
Definition: Element.hpp:49
Element * fleft
Definition: Element.hpp:50
void SetFocusChangeElement(FocusChangeDirection Direction, Element *ToChange)