aboutsummaryrefslogtreecommitdiff
path: root/CruUI/main.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2018-09-08 23:31:20 +0800
committercrupest <crupest@outlook.com>2018-09-08 23:31:20 +0800
commit74031db4b8c366531db5be8fa8d765483ab377b0 (patch)
tree558ed98f22eb182b7d7017e5a51bdb14d5e92268 /CruUI/main.cpp
parent7cbe80c19170c8c742fd280c555eafbd2a51b4da (diff)
downloadcru-74031db4b8c366531db5be8fa8d765483ab377b0.tar.gz
cru-74031db4b8c366531db5be8fa8d765483ab377b0.tar.bz2
cru-74031db4b8c366531db5be8fa8d765483ab377b0.zip
...
Diffstat (limited to 'CruUI/main.cpp')
-rw-r--r--CruUI/main.cpp62
1 files changed, 40 insertions, 22 deletions
diff --git a/CruUI/main.cpp b/CruUI/main.cpp
index 77ee44c0..bd0d3247 100644
--- a/CruUI/main.cpp
+++ b/CruUI/main.cpp
@@ -1,14 +1,13 @@
-#include <random>
-
#include "application.h"
#include "ui/window.h"
-#include "timer.h"
+#include "ui/controls/linear_layout.h"
#include "ui/controls/text_block.h"
using cru::Application;
using cru::ui::Window;
-
+using cru::ui::controls::LinearLayout;
+using cru::ui::controls::TextBlock;
int APIENTRY wWinMain(
@@ -17,9 +16,11 @@ int APIENTRY wWinMain(
LPWSTR lpCmdLine,
int nCmdShow) {
- Application application(hInstance);
+ Application application(hInstance);
Window window;
+ /*
+ // test1
cru::ui::controls::TextBlock text_block;
text_block.SetText(L"Hello world!");
text_block.SetSize(cru::ui::Size(200, 30));
@@ -38,29 +39,46 @@ int APIENTRY wWinMain(
std::uniform_int_distribution<decltype(colors.size())> uni(0, colors.size() - 1); // guaranteed unbiased
- window.draw_event.AddHandler([&](cru::ui::events::DrawEventArgs& args) {
- auto device_context = args.GetDeviceContext();
+ window.draw_event.AddHandler([&](cru::ui::events::DrawEventArgs& args) {
+ auto device_context = args.GetDeviceContext();
+
+ ID2D1SolidColorBrush* brush;
+ device_context->CreateSolidColorBrush(colors[uni(rng)], &brush);
+
+ device_context->FillRectangle(D2D1::RectF(100.0f, 100.0f, 300.0f, 200.0f), brush);
+
+ brush->Release();
+ });
+
+ cru::SetTimeout(2.0, [&window]() {
+ window.Repaint();
- ID2D1SolidColorBrush* brush;
- device_context->CreateSolidColorBrush(colors[uni(rng)], &brush);
+ auto task = cru::SetInterval(0.5, [&window]() {
+ window.Repaint();
+ });
- device_context->FillRectangle(D2D1::RectF(100.0f, 100.0f, 300.0f, 200.0f), brush);
+ cru::SetTimeout(4, [task]() {
+ task->Cancel();
+ task->Cancel(); // test for idempotency.
+ });
+ });
+ */
- brush->Release();
- });
+ //test 2
- cru::SetTimeout(2.0, [&window]() {
- window.Repaint();
+ LinearLayout layout;
+ TextBlock text_block_1;
+ text_block_1.SetText(L"Hello World!!!");
+ TextBlock text_block_2;
+ text_block_2.SetText(L"This is a very very very very very long sentence!!!");
+ TextBlock text_block_3;
+ text_block_3.SetText(L"By crupest!!!");
- auto task = cru::SetInterval(0.5, [&window]() {
- window.Repaint();
- });
+ layout.AddChild(&text_block_1);
+ layout.AddChild(&text_block_2);
+ layout.AddChild(&text_block_3);
- cru::SetTimeout(4, [task]() {
- task->Cancel();
- task->Cancel(); // test for idempotency.
- });
- });
+ window.AddChild(&layout);
window.Show();