aboutsummaryrefslogtreecommitdiff
path: root/src/ThemeBuilder/components/stylers/ContentBrushStylerEditor.cpp
blob: bd649c671ba8fa8e4ad5275b0231193903ecd260 (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
#include "ContentBrushStylerEditor.h"
#include "cru/platform/graphics/Factory.h"
#include "cru/platform/gui/UiApplication.h"
#include "cru/ui/style/Styler.h"

namespace cru::theme_builder::components::stylers {
ContentBrushStylerEditor::ContentBrushStylerEditor() {
  GetContainer()->AddChild(color_editor_.GetRootControl());

  ConnectChangeEvent(color_editor_);
}

ContentBrushStylerEditor::~ContentBrushStylerEditor() {}

ClonablePtr<ui::style::ContentBrushStyler> ContentBrushStylerEditor::GetValue()
    const {
  return ui::style::ContentBrushStyler::Create(
      platform::gui::IUiApplication::GetInstance()
          ->GetGraphicsFactory()
          ->CreateSolidColorBrush(color_editor_.GetValue()));
}

void ContentBrushStylerEditor::SetValue(ui::style::ContentBrushStyler* value,
                                        bool trigger_change) {
  color_editor_.SetValue(
      std::dynamic_pointer_cast<platform::graphics::ISolidColorBrush>(
          value->GetBrush())
          ->GetColor(),
      trigger_change);
}
}  // namespace cru::theme_builder::components::stylers