aboutsummaryrefslogtreecommitdiff
path: root/src/ThemeBuilder/components/StyleRuleEditor.h
blob: 8e3db3def2094dcd036008db3d96a5cf998b8f76 (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
#pragma once
#include "conditions/ConditionEditor.h"
#include "cru/ui/components/Component.h"
#include "cru/ui/controls/Button.h"
#include "cru/ui/controls/Control.h"
#include "cru/ui/controls/FlexLayout.h"
#include "cru/ui/controls/IconButton.h"
#include "cru/ui/controls/TextBlock.h"
#include "cru/ui/style/StyleRule.h"
#include "stylers/StylerEditor.h"

namespace cru::theme_builder::components {
class StyleRuleEditor : public ui::components::Component {
 public:
  StyleRuleEditor();

  CRU_DELETE_COPY(StyleRuleEditor)
  CRU_DELETE_MOVE(StyleRuleEditor)

  ~StyleRuleEditor() override;

 public:
  ui::controls::Control* GetRootControl() override { return &container_; }

  ui::style::StyleRule GetValue() const;
  void SetValue(const ui::style::StyleRule& style_rule,
                bool trigger_change = true);

  IEvent<std::nullptr_t>* ChangeEvent() { return &change_event_; }
  IEvent<std::nullptr_t>* RemoveEvent() { return &remove_event_; }

 private:
  ui::controls::Container container_;
  ui::controls::FlexLayout main_layout_;
  ui::controls::TextBlock label_;
  ui::controls::FlexLayout head_layout_;
  ui::controls::IconButton remove_button_;
  ui::controls::FlexLayout body_layout_;
  std::unique_ptr<components::conditions::ConditionEditor> condition_editor_;
  std::unique_ptr<components::stylers::StylerEditor> styler_editor_;

  Event<std::nullptr_t> change_event_;
  Event<std::nullptr_t> remove_event_;
};
}  // namespace cru::theme_builder::components