AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
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);
45 ~ADropdownList() override;
46
47 void setModel(const _<IListModel<AString>>& model);
48 void render(ARenderContext context) override;
49
50 [[nodiscard]] int getSelectionId() const {
51 return mSelectionId;
52 }
53 int getSelectedId() const {
54 return mSelectionId;
55 }
56 void setSelectionId(int id);
57 int getContentMinimumWidth() override;
58
59 void onPointerReleased(const APointerReleasedEvent& event) override;
60
61 void destroyWindow();
62
63 [[nodiscard]]
64 const _<IListModel<AString>>& getModel() const {
65 return mModel;
66 }
67
68signals:
69 emits<int> selectionChanged;
70};
71
72
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
Button with text, which can be pushed to make some action.
Definition: AButton.h:27
A button with dropdown list.
Definition: ADropdownList.h:27
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:177
Pointing method press event.
Definition: APointerReleasedEvent.h:19
Render context passed to AView::render.
Definition: ARenderContext.h:43
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:51