Plutonium framework API  0.3
Simple UI framework for libnx and SDL2
elm_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/pu_String.hpp>
18 
19 namespace pu::ui::elm
20 {
21  class Button : public Element
22  {
23  public:
24  Button(i32 X, i32 Y, i32 Width, i32 Height, String Content, Color TextColor, Color Color);
26  ~Button();
27 
28  i32 GetX();
29  void SetX(i32 X);
30  i32 GetY();
31  void SetY(i32 Y);
32  i32 GetWidth();
33  void SetWidth(i32 Width);
34  i32 GetHeight();
35  void SetHeight(i32 Height);
37  void SetContent(String Content);
38  Color GetColor();
39  void SetColor(Color Color);
40  void SetContentFont(String font_name);
41  void SetOnClick(std::function<void()> ClickCallback);
42  void OnRender(render::Renderer::Ref &Drawer, i32 X, i32 Y);
43  void OnInput(u64 Down, u64 Up, u64 Held, Touch Pos);
44  private:
45  i32 x;
46  i32 y;
47  i32 w;
48  i32 h;
49  String fnt_name;
50  Color clr;
51  String cnt;
52  std::function<void()> clickcb;
53  bool hover;
54  i32 hoverfact;
55  sdl2::Texture ntex;
56  };
57 }
Definition: elm_Button.hpp:19
Definition: pu_String.hpp:21
void OnRender(render::Renderer::Ref &Drawer, i32 X, i32 Y)
Definition: ui_Types.hpp:24
void SetContentFont(String font_name)
Definition: ui_Types.hpp:38
void SetColor(Color Color)
void SetOnClick(std::function< void()> ClickCallback)
Definition: elm_Button.hpp:21
SDL_Texture * Texture
Definition: sdl2_Types.hpp:11
s32 i32
Definition: pu_Macros.hpp:17
#define PU_SMART_CTOR(type)
Definition: pu_Macros.hpp:8
Button(i32 X, i32 Y, i32 Width, i32 Height, String Content, Color TextColor, Color Color)
void OnInput(u64 Down, u64 Up, u64 Held, Touch Pos)
void SetWidth(i32 Width)
Definition: elm_Element.hpp:34
void SetHeight(i32 Height)
void SetContent(String Content)