blob: 6c1beeac434c0241549fe61883d032170be37f82 (
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
53
54
55
56
57
58
59
60
|
#pragma once
#include "ConditionEditor.h"
#include "cru/base/ClonePtr.h"
#include "cru/ui/components/PopupButton.h"
#include "cru/ui/controls/FlexLayout.h"
#include "cru/ui/style/Condition.h"
namespace cru::theme_builder::components::conditions {
class CompoundConditionEditor : public ConditionEditor {
public:
CompoundConditionEditor();
~CompoundConditionEditor();
protected:
std::vector<ClonePtr<ui::style::Condition>> GetChildren();
void SetChildren(std::vector<ClonePtr<ui::style::Condition>> children,
bool trigger_change = true);
private:
ui::components::PopupMenuIconButton add_child_button_;
ui::controls::FlexLayout children_container_;
std::vector<platform::gui::DeleteLaterPtr<ConditionEditor>> children_;
};
class AndConditionEditor : public CompoundConditionEditor {
public:
ClonePtr<ui::style::AndCondition> GetValue() {
return ui::style::AndCondition::Create(GetChildren());
}
void SetValue(ui::style::AndCondition* value, bool trigger_change = true) {
SetChildren(value->GetChildren(), trigger_change);
}
void SetValue(const ClonePtr<ui::style::AndCondition>& value,
bool trigger_change = true) {
SetValue(value.get(), trigger_change);
}
ClonePtr<ui::style::Condition> GetCondition() override {
return GetValue();
}
};
class OrConditionEditor : public CompoundConditionEditor {
public:
ClonePtr<ui::style::OrCondition> GetValue() {
return ui::style::OrCondition::Create(GetChildren());
}
void SetValue(ui::style::OrCondition* value, bool trigger_change = true) {
SetChildren(value->GetChildren(), trigger_change);
}
void SetValue(const ClonePtr<ui::style::OrCondition>& value,
bool trigger_change = true) {
SetValue(value.get(), trigger_change);
}
ClonePtr<ui::style::Condition> GetCondition() override {
return GetValue();
}
};
} // namespace cru::theme_builder::components::conditions
|