-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkbox.h
47 lines (36 loc) · 977 Bytes
/
checkbox.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#define CHECKBOX_SIZE 8
class Checkbox : public Element {
public:
// ctor.
__forceinline Checkbox() : m_checked{ false }, m_label{} {
m_flags = ElementFlags::CLICK | ElementFlags::DRAW | ElementFlags::SAVE;
m_w = m_h = m_base_h = CHECKBOX_SIZE;
m_type = ElementTypes::CHECKBOX;
m_use_label = true;
m_show = true;
}
__forceinline void setup(const std::string& label, const std::string& file_id, bool use_label = true, bool default = false) {
m_file_id = file_id;
m_use_label = use_label;
if (m_use_label)
m_label = label;
m_checked = default;
}
__forceinline void set(bool checked) {
bool changed = m_checked != checked;
m_checked = checked;
if (changed && m_callback)
m_callback();
}
__forceinline bool get() {
return m_checked;
}
protected:
bool m_checked;
std::string m_label;
protected:
void draw() override;
void think() override;
void click() override;
};