Plutonium framework API  0.3
Simple UI framework for libnx and SDL2
ui_Types.hpp
Go to the documentation of this file.
1 
2 /*
3 
4  Plutonium library
5 
6  @file ui_Types.hpp
7  @brief Several basic types helpful for UI and rendering, such as Color
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>
16 #include <string>
17 #include <array>
18 
19 namespace pu::ui
20 {
21  // Default font sizes Plutonium components use by default
22  static inline constexpr std::array<u32, 4> DefaultFontSizes = { 18, 20, 25, 30 };
23 
24  struct Color
25  {
26  u8 R;
27  u8 G;
28  u8 B;
29  u8 A;
30 
31  constexpr Color() : R(0), G(0), B(0), A(0xFF) {}
32 
33  constexpr Color(u8 R, u8 G, u8 B, u8 A) : R(R), G(G), B(B), A(A) {}
34 
35  static Color FromHex(std::string HexFmt);
36  };
37 
38  struct Touch
39  {
40  i32 X;
41  i32 Y;
42 
43  inline constexpr bool IsEmpty()
44  {
45  if(X < 0)
46  {
47  if(Y < 0)
48  {
49  return true;
50  }
51  }
52  return false;
53  }
54 
55  static const Touch Empty;
56  };
57 
58  inline constexpr const Touch Touch::Empty = { -1, -1 };
59 }
u8 R
Definition: ui_Types.hpp:26
i32 Y
Definition: ui_Types.hpp:41
Definition: ui_Types.hpp:24
u8 A
Definition: ui_Types.hpp:29
static Color FromHex(std::string HexFmt)
i32 X
Definition: ui_Types.hpp:40
Definition: ui_Types.hpp:38
u8 G
Definition: ui_Types.hpp:27
constexpr bool IsEmpty()
Definition: ui_Types.hpp:43
constexpr Color()
Definition: ui_Types.hpp:31
constexpr Color(u8 R, u8 G, u8 B, u8 A)
Definition: ui_Types.hpp:33
static constexpr std::array< u32, 4 > DefaultFontSizes
Definition: ui_Types.hpp:22
static const Touch Empty
Definition: ui_Types.hpp:55
s32 i32
Definition: pu_Macros.hpp:17
u8 B
Definition: ui_Types.hpp:28