aboutsummaryrefslogtreecommitdiff
path: root/src/theme_builder/components/MainWindow.cpp
blob: d2a4c7655c05e3fec55df7b42b872d66861bcef3 (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
#include "MainWindow.h"
#include "cru/ui/Base.h"
#include "cru/ui/controls/StackLayout.h"
#include "cru/ui/controls/TextBlock.h"

namespace cru::theme_builder {
using namespace cru::ui;
using namespace cru::ui::controls;
using namespace cru::platform::gui;

MainWindow::MainWindow() {
  window_.GetNativeWindow()->SetTitle(u"CruUI Theme Builder");
  main_layout_.SetFlexDirection(FlexDirection::Horizontal);
  window_.AddChild(&main_layout_);
  main_layout_.AddChild(&preview_layout_);

  preview_button_text_.SetText(u"Preview");
  preview_button_.SetChild(&preview_button_text_);
  preview_layout_.AddChild(&preview_button_);
  preview_layout_.SetChildLayoutData(
      0, StackChildLayoutData{Alignment::Center, Alignment::Center});

  style_rule_set_editor_.BindStyleRuleSet(
      preview_button_.GetStyleRuleSet()->GetParent());
  main_layout_.AddChild(style_rule_set_editor_.GetRootControl());

  main_layout_.SetChildLayoutData(0, {0, 0});
  main_layout_.SetChildLayoutData(1, {1, 1});
}

MainWindow::~MainWindow() {}

void MainWindow::Show() {
  window_.GetNativeWindow()->SetVisibility(WindowVisibilityType::Show);
  window_.GetNativeWindow()->SetToForeground();
}
}  // namespace cru::theme_builder