blob: 13ab77642b6d581c3d029d466dc7c2bad1e9df62 (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#pragma once
#include "../Base.hpp"
#include "cru/common/Base.hpp"
#include "cru/common/ClonablePtr.hpp"
#include "cru/common/Event.hpp"
#include "cru/ui/controls/IClickableControl.hpp"
#include "cru/ui/helper/ClickDetector.hpp"
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
namespace cru::ui::style {
class Condition : public Object {
public:
virtual std::vector<IBaseEvent*> ChangeOn(
controls::Control* control) const = 0;
virtual bool Judge(controls::Control* control) const = 0;
virtual Condition* Clone() const = 0;
};
class CompoundCondition : public Condition {
public:
explicit CompoundCondition(std::vector<ClonablePtr<Condition>> conditions);
std::vector<IBaseEvent*> ChangeOn(controls::Control* control) const override;
protected:
std::vector<ClonablePtr<Condition>> conditions_;
};
class AndCondition : public CompoundCondition {
public:
using CompoundCondition::CompoundCondition;
bool Judge(controls::Control* control) const override;
AndCondition* Clone() const override { return new AndCondition(conditions_); }
};
class OrCondition : public CompoundCondition {
public:
using CompoundCondition::CompoundCondition;
bool Judge(controls::Control* control) const override;
OrCondition* Clone() const override { return new OrCondition(conditions_); }
};
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;
FocusCondition* Clone() const override {
return new FocusCondition(has_focus_);
}
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;
ClickStateCondition* Clone() const override {
return new ClickStateCondition(click_state_);
}
private:
helper::ClickState click_state_;
};
} // namespace cru::ui::style
|