Plutonium framework API  0.1
Simple UI framework for libnx and SDL2
Button.hpp
Go to the documentation of this file.
1 
2 /*
3 
4  Plutonium library
5 
6  @file Button.hpp
7  @brief A Button is an Element for option selecting.
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 <functional>
16 #include <pu/element/Element.hpp>
17 
18 namespace pu::element
19 {
20  class Button : public Element
21  {
22  public:
23  Button(u32 X, u32 Y, u32 Width, u32 Height, std::string Content, draw::Color TextColor, draw::Color Color);
24  ~Button();
25  u32 GetX();
26  void SetX(u32 X);
27  u32 GetY();
28  void SetY(u32 Y);
29  u32 GetWidth();
30  void SetWidth(u32 Width);
31  u32 GetHeight();
32  void SetHeight(u32 Height);
33  std::string GetContent();
34  void SetContent(std::string Content);
36  void SetColor(draw::Color Color);
38  void SetOnClick(std::function<void()> ClickCallback);
39  void OnRender(render::Renderer *Drawer);
40  void OnInput(u64 Down, u64 Up, u64 Held, bool Touch, bool Focus);
41  private:
42  u32 x;
43  u32 y;
44  u32 w;
45  u32 h;
47  draw::Color clr;
48  std::string cnt;
49  std::function<void()> clickcb;
50  bool hover;
51  s32 hoverfact;
53  };
54 }
Definition: Renderer.hpp:22
void SetContentFont(render::NativeFont Font)
Font
Definition: Font.hpp:18
void SetWidth(u32 Width)
TTF_Font * NativeFont
Definition: SDL2.hpp:17
Definition: Button.hpp:18
draw::Color GetColor()
Definition: Element.hpp:27
void SetContent(std::string Content)
void SetOnClick(std::function< void()> ClickCallback)
std::string GetContent()
void OnInput(u64 Down, u64 Up, u64 Held, bool Touch, bool Focus)
SDL_Texture * NativeTexture
Definition: SDL2.hpp:16
void SetColor(draw::Color Color)
Definition: Color.hpp:19
void SetHeight(u32 Height)
Definition: Button.hpp:20
void OnRender(render::Renderer *Drawer)
Button(u32 X, u32 Y, u32 Width, u32 Height, std::string Content, draw::Color TextColor, draw::Color Color)