AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
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 {
22 friend struct Selected;
23 protected:
24 virtual bool selectableIsSelectedImpl() = 0;
25 };
26
40 struct Selected: IAssSubSelector {
41 private:
42 _unique<IAssSubSelector> mWrapped;
43
44 public:
45 template<typename T>
46 Selected(T value): mWrapped(new T(std::move(value))) {}
47
48
49 bool isPossiblyApplicable(AView* view) override {
50 return mWrapped->isPossiblyApplicable(view) && dynamic_cast<ISelectable*>(view);
51 }
52
53 bool isStateApplicable(AView* view) override {
54 if (!mWrapped->isStateApplicable(view))
55 return false;
56
57 if (auto c = dynamic_cast<ISelectable*>(view)) {
58 return c->selectableIsSelectedImpl();
59 }
60 return false;
61 }
62
63 void setupConnections(AView* view, const _<AAssHelper>& helper) override {
64 IAssSubSelector::setupConnections(view, helper);
65 mWrapped->setupConnections(view, helper);
66
67 view->customCssPropertyChanged.clearAllConnectionsWith(helper.get());
68 AObject::connect(view->customCssPropertyChanged, slot(helper)::onInvalidateStateAss);
69 }
70 };
71}
Base class of all UI objects.
Definition AView.h:78
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:178
Definition AAssSelector.h:28
Interface to work with ass::Selected selector.
Definition Selected.h:21
class_of c
Selects views that are of the specified classes.
Definition class_of.h:84
#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
static void connect(const Signal &signal, Object *object, Function &&function)
Connects signal to the slot of the specified object.
Definition AObject.h:65