AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
class_of.h
    1/*
    2 * AUI Framework - Declarative UI toolkit for modern C++20
    3 * Copyright (C) 2020-2025 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 {
   30        struct ClassOf: IAssSubSelector {
   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
   57    struct class_of: detail::ClassOf {
   58    public:
   59        class_of(const AStringVector& classes) : ClassOf(classes) {}
   60        class_of(const AString& clazz) : ClassOf(clazz) {}
   61
   62        using hover = ass::hovered<detail::ClassOf>;
   63        using active = ass::activated<detail::ClassOf>;
   64        using focus = ass::focused<detail::ClassOf>;
   65        using disabled = ass::disabled<detail::ClassOf>;
   66    };
   67
   84    using c = class_of;
   85}
An AVector with string-related functions.
Definition AStringVector.h:22
Represents a Unicode character string.
Definition AString.h:38
bool contains(const StoredType &value) const noexcept
Definition AVector.h:148
class_of c
Selects views that are of the specified classes.
Definition class_of.h:84
Definition activated.h:21
Definition class_of.h:57
Definition disabled.h:20
Definition focused.h:21
Definition hovered.h:21