diff options
author | crupest <crupest@outlook.com> | 2022-05-15 14:15:31 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-05-15 14:15:31 +0800 |
commit | 34a64e6ffefaab007578932ddbab931a25f1d56e (patch) | |
tree | 541fdb8279e829a129df62288d09916bf23c9200 /src/ThemeBuilder/components/conditions/CompoundConditionEditor.h | |
parent | 8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6 (diff) | |
download | cru-34a64e6ffefaab007578932ddbab931a25f1d56e.tar.gz cru-34a64e6ffefaab007578932ddbab931a25f1d56e.tar.bz2 cru-34a64e6ffefaab007578932ddbab931a25f1d56e.zip |
...
Diffstat (limited to 'src/ThemeBuilder/components/conditions/CompoundConditionEditor.h')
-rw-r--r-- | src/ThemeBuilder/components/conditions/CompoundConditionEditor.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/ThemeBuilder/components/conditions/CompoundConditionEditor.h b/src/ThemeBuilder/components/conditions/CompoundConditionEditor.h new file mode 100644 index 00000000..e1398514 --- /dev/null +++ b/src/ThemeBuilder/components/conditions/CompoundConditionEditor.h @@ -0,0 +1,72 @@ +#pragma once +#include "ConditionEditor.h" +#include "cru/common/ClonablePtr.h" +#include "cru/common/Event.h" +#include "cru/ui/components/Component.h" +#include "cru/ui/components/PopupButton.h" +#include "cru/ui/controls/Button.h" +#include "cru/ui/controls/FlexLayout.h" +#include "cru/ui/controls/TextBlock.h" +#include "cru/ui/style/Condition.h" + +namespace cru::theme_builder::components::conditions { +class CompoundConditionEditor : public ConditionEditor { + public: + CompoundConditionEditor(); + ~CompoundConditionEditor(); + + protected: + std::vector<ClonablePtr<ui::style::Condition>> GetChildren(); + void SetChildren(std::vector<ClonablePtr<ui::style::Condition>> children, + bool trigger_change = true); + + private: + ui::components::PopupMenuIconButton add_child_button_; + ui::controls::FlexLayout children_container_; + std::vector<ui::DeleteLaterPtr<ConditionEditor>> children_; +}; + +class AndConditionEditor : public CompoundConditionEditor { + public: + AndConditionEditor() = default; + ~AndConditionEditor() override = default; + + public: + ClonablePtr<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 ClonablePtr<ui::style::AndCondition>& value, + bool trigger_change = true) { + SetValue(value.get(), trigger_change); + } + + ClonablePtr<ui::style::Condition> GetCondition() override { + return GetValue(); + } +}; + +class OrConditionEditor : public CompoundConditionEditor { + public: + OrConditionEditor() = default; + ~OrConditionEditor() override = default; + + public: + ClonablePtr<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 ClonablePtr<ui::style::OrCondition>& value, + bool trigger_change = true) { + SetValue(value.get(), trigger_change); + } + + ClonablePtr<ui::style::Condition> GetCondition() override { + return GetValue(); + } +}; +} // namespace cru::theme_builder::components::conditions |