AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
class_of.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 02.01.2021.
14//
15
16#pragma once
17
18#include <AUI/Util/kAUI.h>
19#include <AUI/View/AView.h>
20#include <AUI/ASS/AAssHelper.h>
21
22#include "hovered.h"
23#include "activated.h"
24#include "focused.h"
25#include "disabled.h"
26
27namespace ass {
28
29 namespace detail {
31 private:
32 AStringVector mClasses;
33
34 public:
35 ClassOf(const AStringVector& classes) : mClasses(classes) {}
36 ClassOf(const AString& clazz) : mClasses({clazz}) {}
37
38 bool isPossiblyApplicable(AView* view) override {
39 for (auto& v : mClasses) {
40 if (view->getAssNames().contains(v)) {
41 return true;
42 }
43 }
44 return false;
45 }
46
47 bool isStateApplicable(AView* view) override {
48 return isPossiblyApplicable(view);
49 }
50
51 const AStringVector& getClasses() const {
52 return mClasses;
53 }
54 };
55 }
56
58 public:
59 class_of(const AStringVector& classes) : ClassOf(classes) {}
60 class_of(const AString& clazz) : ClassOf(clazz) {}
61
66 };
67
68 using c = class_of;
69}
An AVector with string-related functions.
Definition: AStringVector.h:22
Represents a Unicode character string.
Definition: AString.h:37
bool contains(const StoredType &value) const noexcept
Definition: AVector.h:147
Base class of all UI objects.
Definition: AView.h:77
Definition: AAssSelector.h:28
Definition: activated.h:21
Definition: class_of.h:57
Definition: class_of.h:30
Definition: disabled.h:20
Definition: focused.h:21
Definition: hovered.h:21