AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
Selected.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#pragma once
13
14#include <AUI/Util/ADataBinding.h>
15#include "AAssSelector.h"
16
17namespace ass {
19 friend struct Selected;
20 protected:
21 virtual bool selectableIsSelectedImpl() = 0;
22 };
23
25 private:
26 _unique<IAssSubSelector> mWrapped;
27
28 public:
29 template<typename T>
30 Selected(T value): mWrapped(new T(std::move(value))) {}
31
32
33 bool isPossiblyApplicable(AView* view) override {
34 return mWrapped->isPossiblyApplicable(view) && dynamic_cast<ISelectable*>(view);
35 }
36
37 bool isStateApplicable(AView* view) override {
38 if (!mWrapped->isStateApplicable(view))
39 return false;
40
41 if (auto c = dynamic_cast<ISelectable*>(view)) {
42 return c->selectableIsSelectedImpl();
43 }
44 return false;
45 }
46
47 void setupConnections(AView* view, const _<AAssHelper>& helper) override {
48 IAssSubSelector::setupConnections(view, helper);
49 mWrapped->setupConnections(view, helper);
50
51 view->customCssPropertyChanged.clearAllConnectionsWith(helper.get());
52 AObject::connect(view->customCssPropertyChanged, slot(helper)::onInvalidateStateAss);
53 }
54 };
55}
Base class of all UI objects.
Definition: AView.h:77
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:177
Definition: AAssSelector.h:28
Definition: Selected.h:18
#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:90
Definition: Selected.h:24
Definition: class_of.h:57