aboutsummaryrefslogtreecommitdiff
path: root/demos/main/main.cpp
blob: a0d4cd884a345fd95fa33e62f473e7c9ff8defbd (plain)
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
#include "cru/platform/HeapDebug.hpp"
#include "cru/platform/native/UiApplication.hpp"
#include "cru/platform/native/Window.hpp"
#include "cru/ui/UiHost.hpp"
#include "cru/ui/Window.hpp"
#include "cru/ui/controls/Button.hpp"
#include "cru/ui/controls/FlexLayout.hpp"
#include "cru/ui/controls/StackLayout.hpp"
#include "cru/ui/controls/TextBlock.hpp"
#include "cru/ui/controls/TextBox.hpp"

using cru::platform::native::CreateUiApplication;
using cru::ui::Rect;
using cru::ui::Thickness;
using cru::ui::Window;
using cru::ui::controls::Button;
using cru::ui::controls::FlexLayout;
using cru::ui::controls::StackLayout;
using cru::ui::controls::TextBlock;
using cru::ui::controls::TextBox;

int main() {
#ifdef CRU_DEBUG
  cru::platform::SetupHeapDebug();
#endif

  auto application = CreateUiApplication();

  const auto window = Window::CreateOverlapped();

  const auto flex_layout = FlexLayout::Create();

  window->SetChild(flex_layout);

  const auto button = Button::Create();
  const auto text_block1 = TextBlock::Create();
  text_block1->SetText(u"Hello World!");
  button->SetChild(text_block1);
  flex_layout->AddChild(button, 0);

  const auto text_block2 = TextBlock::Create();
  text_block2->SetText(u"Hello World!");

  const auto text_block3 = TextBlock::Create();
  text_block3->SetText(u"Overlapped text");

  const auto stack_layout = StackLayout::Create();
  stack_layout->AddChild(text_block2, 0);
  stack_layout->AddChild(text_block3, 1);
  flex_layout->AddChild(stack_layout, 1);

  const auto text_block4 = TextBlock::Create();
  text_block4->SetText(u"Hello World!!!");
  flex_layout->AddChild(text_block4, 2);

  window->GetUiHost()->GetNativeWindowResolver()->Resolve()->SetVisible(true);

  return application->Run();
}