CYD-UI
A C++ library for building native graphic user interfaces
Loading...
Searching...
No Matches
selectors.cppm
Go to the documentation of this file.
1
5
6export module cydui.styling.selectors;
7
8import std;
9import reflect;
10
11import fabric.logging;
12
13namespace cydui {
14 export struct StyleRuleSelector {
15 std::size_t specificity() const {
16 return compute_specificity();
17 }
18
19 std::size_t specificity() {
20 if (not specificity_.has_value()) {
21 specificity_ = compute_specificity();
22 }
23 return specificity_.value();
24 }
25
26 std::string component{};
27 std::unordered_set<std::string> tags{};
28 std::unordered_set<std::string> pseudo_states{};
29 private:
30 std::size_t compute_specificity() const {
31 return tags.size() + pseudo_states.size();
32 }
33 [[refl::ignore]]
34 std::optional<std::size_t> specificity_ {std::nullopt};
35 };
36
37
44
45 std::size_t specificity() const {
46 return compute_specificity();
47 }
48
49 std::size_t specificity() {
50 if (not specificity_.has_value()) {
51 specificity_ = compute_specificity();
52 }
53 return specificity_.value();
54 }
55
56 std::list<std::pair<kind_e, StyleRuleSelector>> selectors{};
57 private:
58 std::size_t compute_specificity() const {
59 std::size_t s = 0;
60 for (const auto & selector : selectors) {
61 s += selector.second.specificity();
62 }
63 return selectors.size() + s;
64 }
65 [[refl::ignore]]
66 std::optional<std::size_t> specificity_ {std::nullopt};
67 };
68}
std::list< std::pair< kind_e, StyleRuleSelector > > selectors
std::size_t specificity() const
std::size_t specificity() const
std::unordered_set< std::string > tags
std::size_t specificity()
std::unordered_set< std::string > pseudo_states