AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
disabled.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
   18namespace ass {
   19    template<typename Base>
   20    struct disabled: Base { // ignore ass_selectors it's used in compound by class_of or t
   21        template<typename... Args>
   22        disabled(Args&&... args):
   23            Base(std::forward<Args>(args)...)
   24        {
   25
   26        }
   27
   28        bool isStateApplicable(AView* view) override {
   29            return Base::isStateApplicable(view) && !*view->enabled();
   30        }
   31
   32        void setupConnections(AView* view, const _<AAssHelper>& helper) override {
   33            Base::setupConnections(view, helper);
   34            view->enabled().changed.clearAllOutgoingConnectionsWith(helper.get());
   35            AObject::connect(view->enabled().changed, slot(helper)::onInvalidateStateAss);
   36        }
   37    };
   38}
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