diff options
| author | crupest <crupest@outlook.com> | 2020-12-02 19:19:22 +0800 |
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2020-12-02 19:19:22 +0800 |
| commit | 145cfd5b82d76e0c937eceda707aa22427899943 (patch) | |
| tree | ab98708eea0e0ba7b965e20927303e49a8d9ae23 /include/cru/ui/style/Condition.hpp | |
| parent | 0fb7a0e0b2b9e04ca414b1e47c69cc854c79831b (diff) | |
| download | cru-145cfd5b82d76e0c937eceda707aa22427899943.tar.gz cru-145cfd5b82d76e0c937eceda707aa22427899943.tar.bz2 cru-145cfd5b82d76e0c937eceda707aa22427899943.zip | |
...
Diffstat (limited to 'include/cru/ui/style/Condition.hpp')
| -rw-r--r-- | include/cru/ui/style/Condition.hpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/include/cru/ui/style/Condition.hpp b/include/cru/ui/style/Condition.hpp new file mode 100644 index 00000000..b88a338f --- /dev/null +++ b/include/cru/ui/style/Condition.hpp @@ -0,0 +1,69 @@ +#pragma once +#include "../Base.hpp" +#include "cru/common/Base.hpp" +#include "cru/common/Event.hpp" +#include "cru/ui/controls/IClickableControl.hpp" +#include "cru/ui/helper/ClickDetector.hpp" + +#include <type_traits> +#include <utility> +#include <vector> + +namespace cru::ui::style { +class Condition { + public: + virtual ~Condition() = default; + + virtual std::vector<IBaseEvent*> ChangeOn( + controls::Control* control) const = 0; + virtual bool Judge(controls::Control* control) const = 0; +}; + +class CompoundCondition : public Condition { + public: + explicit CompoundCondition(std::vector<Condition*> conditions); + + const std::vector<Condition*>& GetConditions() const { return conditions_; } + + std::vector<IBaseEvent*> ChangeOn(controls::Control* control) const override; + + private: + std::vector<Condition*> conditions_; +}; + +class AndCondition : public CompoundCondition { + public: + using CompoundCondition::CompoundCondition; + + bool Judge(controls::Control* control) const override; +}; + +class OrCondition : public CompoundCondition { + public: + using CompoundCondition::CompoundCondition; + + bool Judge(controls::Control* control) const override; +}; + +class FocusCondition : public Condition { + public: + explicit FocusCondition(bool has_focus); + + std::vector<IBaseEvent*> ChangeOn(controls::Control* control) const override; + bool Judge(controls::Control* control) const override; + + private: + bool has_focus_; +}; + +class ClickStateCondition : public Condition { + public: + explicit ClickStateCondition(helper::ClickState click_state); + + std::vector<IBaseEvent*> ChangeOn(controls::Control* control) const override; + bool Judge(controls::Control* control) const override; + + private: + helper::ClickState click_state_; +}; +} // namespace cru::ui::style |
