AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
ADropdownList.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 21.09.2020.
14//
15
16#pragma once
17
18
19#include "AButton.h"
20#include <AUI/Model/IListModel.h>
21#include <AUI/Platform/AOverlappingSurface.h>
22
27class API_AUI_VIEWS ADropdownList: public AButton {
28private:
30 int mSelectionId = 0;
31 bool mPopup = false;
32 _weak<AOverlappingSurface> mComboWindow;
33
34protected:
35 virtual void updateText();
36 virtual void onComboBoxWindowCreated();
37
38 _<AViewContainer> comboWindow() {
39 return mComboWindow.lock();
40 }
41
42public:
43 explicit ADropdownList(const _<IListModel<AString>>& model);
44 ADropdownList();
45 ~ADropdownList() override;
46
50 auto selectionId() const {
51 return APropertyDef {
52 this,
53 &ADropdownList::getSelectionId,
54 &ADropdownList::setSelectionId,
55 selectionChanged,
56 };
57 }
58
59 void setModel(const _<IListModel<AString>>& model);
60 void render(ARenderContext context) override;
61
62 [[nodiscard]] int getSelectionId() const {
63 return mSelectionId;
64 }
65 int getSelectedId() const {
66 return mSelectionId;
67 }
68 void setSelectionId(int id);
69 int getContentMinimumWidth() override;
70
71 void onPointerReleased(const APointerReleasedEvent& event) override;
72
73 void destroyWindow();
74
75 [[nodiscard]]
76 const _<IListModel<AString>>& getModel() const {
77 return mModel;
78 }
79
80signals:
81 emits<int> selectionChanged;
82};
83
84
void render(ARenderContext context) override
Draws this AView. Noone should call this function except rendering routine.
Definition AAbstractLabel.cpp:28
int getContentMinimumWidth() override
Definition AAbstractLabel.cpp:34
auto selectionId() const
Selected id property.
Definition ADropdownList.h:50
virtual void onPointerReleased(const APointerReleasedEvent &event)
Called on pointer (mouse) released event.
Definition AView.cpp:366
Definition IListModel.h:23
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:178
ASignal< Args... > emits
A signal declaration.
Definition ASignal.h:348
Property implementation to use with custom getter/setter.
Definition AProperty.h:308
Render context passed to AView::render.
Definition ARenderContext.h:43
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:51