AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
AStylesheet.h
1/*
2 * AUI Framework - Declarative UI toolkit for modern C++20
3 * Copyright (C) 2020-2024 Alex2772 and Contributors
4 *
5 * SPDX-License-Identifier: MPL-2.0
6 *
7 * This Source Code Form is subject to the terms of the Mozilla Public
8 * License, v. 2.0. If a copy of the MPL was not distributed with this
9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 */
11
12//
13// Created by alex2 on 29.12.2020.
14//
15
16#pragma once
17
18#include <initializer_list>
19#include "Rule.h"
20
21class API_AUI_VIEWS AStylesheet {
22private:
23 AVector<ass::Rule> mRules;
24 bool mIgnoreRules = false;
25
26public:
28 AStylesheet(std::initializer_list<ass::Rule> rules) {
29 addRules(rules);
30 }
31
32 void addRules(std::initializer_list<ass::Rule> rules) {
33 if (mIgnoreRules) {
34 return;
35 }
36 for (auto& constRule : rules) {
37 auto& rule = const_cast<ass::Rule&>(constRule);
38 mRules << std::move(rule);
39 }
40 }
41
42 void addRule(const ass::Rule& r) {
43 if (mIgnoreRules) {
44 return;
45 }
46 mRules << r;
47 }
48
49
50 void addRule(ass::Rule&& r) {
51 if (mIgnoreRules) {
52 return;
53 }
54 mRules << std::forward<ass::Rule>(r);
55 }
56
57 void setIgnoreRules(bool ignoreRules) {
58 mIgnoreRules = ignoreRules;
59 }
60
61
62 [[nodiscard]] const AVector<ass::Rule>& getRules() const {
63 return mRules;
64 }
65
66 static AColor getOsThemeColor();
67
68 static AStylesheet& global();
69
70 void setRules(AVector<ass::Rule> rules) {
71 mRules = std::move(rules);
72 }
73
74private:
75 static _<AStylesheet>& globalStorage();
76};
Represents a 4-component floating point color.
Definition: AColor.h:27
Definition: AStylesheet.h:21
A std::vector with AUI extensions.
Definition: AVector.h:38
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:177
Definition: Rule.h:17