Plutonium framework API 0.3.0
UI framework libraries for libnx
ui_Container.hpp
Go to the documentation of this file.
1
2/*
3
4 Plutonium library
5
6 @file ui_Container.hpp
7 @brief A Container is a basic object which contains a bunch of Elements.
8 @author XorTroll
9
10 @copyright Plutonium project - an easy-to-use UI framework for Nintendo Switch homebrew
11
12*/
13
14#pragma once
16#include <vector>
17#include <bits/stdc++.h>
18
19namespace pu::ui {
20
21 class Container {
22 protected:
27 std::vector<elm::Element::Ref> elems;
28
29 public:
30 Container(const i32 x, const i32 y, const i32 width, const i32 height) : x(x), y(y), w(width), h(height), elems() {}
32
33 inline void Add(elm::Element::Ref elem) {
34 this->elems.push_back(elem);
35 }
36
37 inline elm::Element::Ref &At(const i32 idx) {
38 return this->elems.at(idx);
39 }
40
41 inline bool Has(elm::Element::Ref &elem) {
42 return std::find(this->elems.begin(), this->elems.end(), elem) != this->elems.end();
43 }
44
45 inline void Clear() {
46 this->elems.clear();
47 }
48
49 inline size_t GetCount() {
50 return this->elems.size();
51 }
52
53 inline void SetX(const i32 x) {
54 this->x = x;
55 }
56
57 inline i32 GetX() {
58 return this->x;
59 }
60
61 inline void SetY(const i32 y) {
62 this->y = y;
63 }
64
65 inline i32 GetY() {
66 return this->y;
67 }
68
69 inline void SetWidth(const i32 width) {
70 this->w = width;
71 }
72
73 inline i32 GetWidth() {
74 return this->w;
75 }
76
77 inline void SetHeight(const i32 height) {
78 this->h = height;
79 }
80
81 inline i32 GetHeight() {
82 return this->h;
83 }
84
85 void PreRender();
86 };
87
88}
Definition: ui_Container.hpp:21
i32 x
Definition: ui_Container.hpp:23
std::vector< elm::Element::Ref > elems
Definition: ui_Container.hpp:27
i32 w
Definition: ui_Container.hpp:25
size_t GetCount()
Definition: ui_Container.hpp:49
bool Has(elm::Element::Ref &elem)
Definition: ui_Container.hpp:41
void Clear()
Definition: ui_Container.hpp:45
Container(const i32 x, const i32 y, const i32 width, const i32 height)
Definition: ui_Container.hpp:30
i32 y
Definition: ui_Container.hpp:24
elm::Element::Ref & At(const i32 idx)
Definition: ui_Container.hpp:37
i32 GetX()
Definition: ui_Container.hpp:57
void SetY(const i32 y)
Definition: ui_Container.hpp:61
void SetHeight(const i32 height)
Definition: ui_Container.hpp:77
i32 GetHeight()
Definition: ui_Container.hpp:81
i32 h
Definition: ui_Container.hpp:26
void SetX(const i32 x)
Definition: ui_Container.hpp:53
void Add(elm::Element::Ref elem)
Definition: ui_Container.hpp:33
void SetWidth(const i32 width)
Definition: ui_Container.hpp:69
i32 GetY()
Definition: ui_Container.hpp:65
i32 GetWidth()
Definition: ui_Container.hpp:73
Definition: elm_Button.hpp:18
s32 i32
Definition: pu_Include.hpp:28
#define PU_SMART_CTOR(type)
Definition: pu_Include.hpp:19