AUI Framework  master
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
hovered.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
   19namespace ass {
   20    template<typename Base>
   21    struct hovered: Base { // ignore ass_selectors it's used in compound by class_of or t
   22        template<typename... Args>
   23        hovered(Args&&... args):
   24            Base(std::forward<Args>(args)...)
   25        {
   26
   27        }
   28
   29        bool isStateApplicable(AView* view) override {
   30            return Base::isStateApplicable(view) && *view->enabled() && view->isMouseHover();
   31        }
   32
   33        void setupConnections(AView* view, const _<AAssHelper>& helper) override {
   34            Base::setupConnections(view, helper);
   35            view->hoveredState.clearAllOutgoingConnectionsWith(helper.get());
   36            AObject::connect(view->hoveredState, slot(helper)::onInvalidateStateAss);
   37        }
   38    };
   39}
Base class of all UI objects.
Definition AView.h:78
auto enabled() const
Whether view is enabled (i.e., reacts to user).
Definition AView.h:90
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:179
static decltype(auto) connect(const Signal &signal, Object *object, Function &&function)
Connects signal to the slot of the specified object.
Definition AObject.h:86
#define slot(v)
Passes some variable and type of the variable separated by comma. It's convenient to use with the con...
Definition kAUI.h:88