aboutsummaryrefslogtreecommitdiff
path: root/src/ui/style/Condition.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/style/Condition.cpp')
-rw-r--r--src/ui/style/Condition.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/ui/style/Condition.cpp b/src/ui/style/Condition.cpp
index bc24e265..2b51bde3 100644
--- a/src/ui/style/Condition.cpp
+++ b/src/ui/style/Condition.cpp
@@ -1,4 +1,5 @@
#include "cru/ui/style/Condition.hpp"
+#include <memory>
#include "cru/common/Event.hpp"
#include "cru/ui/controls/Control.hpp"
@@ -6,8 +7,11 @@
#include "cru/ui/helper/ClickDetector.hpp"
namespace cru::ui::style {
-CompoundCondition::CompoundCondition(std::vector<Condition*> conditions)
- : conditions_(std::move(conditions)) {}
+CompoundCondition::CompoundCondition(
+ std::vector<std::unique_ptr<Condition>> conditions)
+ : conditions_(std::move(conditions)) {
+ for (const auto& p : conditions_) readonly_conditions_.push_back(p.get());
+}
std::vector<IBaseEvent*> CompoundCondition::ChangeOn(
controls::Control* control) const {
@@ -22,6 +26,15 @@ std::vector<IBaseEvent*> CompoundCondition::ChangeOn(
return result;
}
+std::vector<std::unique_ptr<Condition>> CompoundCondition::CloneConditions()
+ const {
+ std::vector<std::unique_ptr<Condition>> result;
+ for (auto condition : GetConditions()) {
+ result.push_back(condition->Clone());
+ }
+ return result;
+}
+
bool AndCondition::Judge(controls::Control* control) const {
for (auto condition : GetConditions()) {
if (!condition->Judge(control)) return false;