-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo4Scene.cpp
More file actions
118 lines (80 loc) · 2.43 KB
/
Copy pathDemo4Scene.cpp
File metadata and controls
118 lines (80 loc) · 2.43 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include "Demo4Scene.h"
Demo4Scene::Demo4Scene()
{
}
Demo4Scene::~Demo4Scene()
{
}
//###########################################################################
void Demo4Scene::onInitialize(caDraw::Window& owner)
{
auto winSize = owner.getSize();
m_panel = caFactory->createPanel();
m_panel->transform.position = { 0, 0 };
m_panel->size = static_cast<caDraw::SizeF>(winSize);
m_font = caFactory->createFont();
m_font->loadFromFile("NanumGothic.ttf");
m_font->setCharacterSize(64);
m_font->setStyle(caDraw::FontStyles::Bold);
m_smallFont = caFactory->createFont();
m_smallFont->loadFromFile("NanumGothic.ttf");
m_smallFont->setCharacterSize(18);
m_panelListBox = caFactory->createPanel();
m_panelListBox->transform.position = { 32, 32 };
m_panelListBox->size = { 512, 300 };
m_listBox = canew<caUI::ListBox>();
m_listBox->setFont(m_smallFont);
m_listBox->setBackColor(caDraw::Color::White);
m_listBox->setSize(m_panelListBox->size);
m_listBox->setItemMargin({ 4, 32 });
m_textBox = canew<caUI::TextBox>();
m_textBox->setFont(m_smallFont);
m_textBox->setTextMargin({ 4, 6 });
m_textBox->setBackColor(caDraw::Color::Silver);
m_textBox->setPosition({ 32, 350 });
m_textBox->setSize({ 400, 32 });
m_buttonAdd = canew<caUI::Button>();
m_buttonAdd->setFont(m_smallFont);
m_buttonAdd->setText(L"Add");
m_buttonAdd->setBackColor(caDraw::Color::Gray);
m_buttonAdd->setPosition({ 448, 350 });
m_buttonAdd->setSize({ 96, 32 });
m_buttonAdd->WhenClick = [&textBox = m_textBox, &listBox = m_listBox]
(const caUI::EventArgs& args)
{
auto& text = textBox->getText();
if (text.getLength() > 0)
{
listBox->addItem(text);
textBox->setText(L"");
}
};
m_buttonNext = canew<caUI::Button>();
m_buttonNext->setFont(m_font);
m_buttonNext->setText(L"Exit");
m_buttonNext->setBackColor(caDraw::Color::Gray);
m_buttonNext->setPosition({ static_cast<f32>(winSize.width / 2 - 165), 600 });
m_buttonNext->setSize({ 330, 100 });
m_buttonNext->WhenClick = [me = this](const caUI::EventArgs& args)
{
me->reserveNextScene(nullptr);
};
m_panelListBox->addControl(m_listBox);
m_panel->addControl(m_textBox);
m_panel->addControl(m_buttonAdd);
m_panel->addControl(m_buttonNext);
addPanel(m_panel);
addPanel(m_panelListBox);
}
void Demo4Scene::onRelease()
{
}
void Demo4Scene::onUpdate(caDraw::Window& owner)
{
}
void Demo4Scene::onDrawBack(caDraw::Graphics& g)
{
}
void Demo4Scene::onDrawFront(caDraw::Graphics& g)
{
}