AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
type_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 {
30 template<typename T>
31 struct Type : IAssSubSelector {
32 static_assert(std::is_polymorphic_v<T>, "Your type is not polymorphic! Please define at least virtual "
33 "destructor for using type_of (t) style selector "
34 "(see https://en.cppreference.com/w/cpp/language/object#Polymorphic_objects)");
35 public:
36 bool isPossiblyApplicable(AView* view) override {
37 return dynamic_cast<T*>(view) != nullptr;
38 }
39
40 };
41 }
42
43 template<typename T>
44 struct type_of: detail::Type<T> {
45 public:
46
47 using hover = ass::hovered<detail::Type<T>>;
48 using active = ass::activated<detail::Type<T>>;
49 using focus = ass::activated<detail::Type<T>>;
50 using disabled = ass::disabled<detail::Type<T>>;
51 };
52
70 template<typename T>
71 using t = type_of<T>;
72}
type_of< T > t
Selects views that are of the specified C++ types.
Definition type_of.h:71
Definition activated.h:21
Definition disabled.h:20
Definition hovered.h:21
Definition type_of.h:44