aboutsummaryrefslogtreecommitdiff
path: root/src/theme_builder/components/stylers/StylerEditor.cpp
blob: 030a37523a470a09d699ab8deb869d79e966388a (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
#include "StylerEditor.h"
#include "BorderStylerEditor.h"
#include "CompoundStylerEditor.h"
#include "CursorStylerEditor.h"
#include "MarginStylerEditor.h"
#include "PaddingStylerEditor.h"
#include "PreferredSizeStylerEditor.h"
#include "cru/ui/style/Styler.h"

namespace cru::theme_builder::components::stylers {
StylerEditor::StylerEditor() {
  container_.SetFlexDirection(ui::controls::FlexDirection::Vertical);
  container_.AddChild(&label_);
}

StylerEditor::~StylerEditor() {}

std::unique_ptr<StylerEditor> CreateStylerEditor(ui::style::Styler* styler) {
  if (auto compound_styler = dynamic_cast<ui::style::CompoundStyler*>(styler)) {
    auto result = std::make_unique<CompoundStylerEditor>();
    result->SetValue(compound_styler);
    return result;
  } else if (auto border_styler =
                 dynamic_cast<ui::style::BorderStyler*>(styler)) {
    auto editor = std::make_unique<BorderStylerEditor>();
    editor->SetValue(border_styler);
    return editor;
  } else if (auto cursor_styler =
                 dynamic_cast<ui::style::CursorStyler*>(styler)) {
    auto editor = std::make_unique<CursorStylerEditor>();
    editor->SetValue(cursor_styler);
    return editor;
  } else if (auto preferred_size_styler =
                 dynamic_cast<ui::style::PreferredSizeStyler*>(styler)) {
    auto editor = std::make_unique<PreferredSizeStylerEditor>();
    editor->SetValue(preferred_size_styler);
    return editor;
  } else if (auto margin_styler =
                 dynamic_cast<ui::style::MarginStyler*>(styler)) {
    auto editor = std::make_unique<MarginStylerEditor>();
    editor->SetValue(margin_styler);
    return editor;
  } else if (auto padding_styler =
                 dynamic_cast<ui::style::PaddingStyler*>(styler)) {
    auto editor = std::make_unique<PaddingStylerEditor>();
    editor->SetValue(padding_styler);
    return editor;
  } else {
    throw Exception(u"Unknown styler type");
  }
}
}  // namespace cru::theme_builder::components::stylers