blob: e7f4d390d01f7f95782d616c05b94008cc6bff3a (
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
|
#pragma once
#include "../Base.h"
#include "Condition.h"
#include "Styler.h"
#include "cru/base/ClonablePtr.h"
namespace cru::ui::style {
/**
* \brief An immutable style rule contains a condition and a styler.
* \remarks This class is immutable and has value semantics.
*/
class CRU_UI_API StyleRule : public Object {
public:
static ClonablePtr<StyleRule> Create(ClonablePtr<Condition> condition,
ClonablePtr<Styler> styler,
std::string name = {}) {
return ClonablePtr<StyleRule>(new StyleRule(
std::move(condition), std::move(styler), std::move(name)));
}
StyleRule(ClonablePtr<Condition> condition, ClonablePtr<Styler> styler,
std::string name = {});
CRU_DEFAULT_COPY(StyleRule)
CRU_DEFAULT_MOVE(StyleRule)
~StyleRule() override = default;
public:
std::string GetName() const { return name_; }
Condition* GetCondition() const { return condition_.get(); }
Styler* GetStyler() const { return styler_.get(); }
StyleRule WithNewCondition(ClonablePtr<Condition> condition,
std::string name = {}) const {
return StyleRule{std::move(condition), styler_, std::move(name)};
}
StyleRule WithNewStyler(ClonablePtr<Styler> styler,
std::string name = {}) const {
return StyleRule{condition_, std::move(styler), std::move(name)};
}
bool CheckAndApply(controls::Control* control) const;
private:
ClonablePtr<Condition> condition_;
ClonablePtr<Styler> styler_;
std::string name_;
};
} // namespace cru::ui::style
|