aboutsummaryrefslogtreecommitdiff
path: root/src/ThemeBuilder/components/stylers/PreferredSizeStylerEditor.cpp
blob: fb713c8caee6780d32506552bbb93726753f415a (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
#include "PreferredSizeStylerEditor.h"
#include "cru/ui/style/Styler.h"

namespace cru::theme_builder::components::stylers {
PreferredSizeStylerEditor::PreferredSizeStylerEditor() {
  SetLabel(u"Preferred Size Styler");
  GetContainer()->AddChild(width_editor_.GetRootControl());
  GetContainer()->AddChild(height_editor_.GetRootControl());

  width_editor_.SetLabel(u"Width");
  height_editor_.SetLabel(u"Height");

  ConnectChangeEvent(width_editor_);
  ConnectChangeEvent(height_editor_);
}

PreferredSizeStylerEditor::~PreferredSizeStylerEditor() {}

ClonablePtr<ui::style::PreferredSizeStyler>
PreferredSizeStylerEditor::GetValue() {
  return ui::style::PreferredSizeStyler::Create(ui::render::MeasureSize{
      width_editor_.GetValue(), height_editor_.GetValue()});
}

void PreferredSizeStylerEditor::SetValue(ui::style::PreferredSizeStyler* styler,
                                         bool trigger_change) {
  width_editor_.SetValue(styler->GetPreferredSize().width, false);
  height_editor_.SetValue(styler->GetPreferredSize().height, false);

  if (trigger_change) {
    RaiseChangeEvent();
  }
}
}  // namespace cru::theme_builder::components::stylers