AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
ATreeView.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 7/1/2021.
14//
15
16
17#pragma once
18
19
20#include "AUI/Model/ATreeModelIndex.h"
21#include "AViewContainer.h"
22#include "AScrollbar.h"
23#include <AUI/Model/ITreeModel.h>
24
31class API_AUI_VIEWS ATreeView: public AViewContainerBase {
32private:
33 class ContainerView;
34 class ItemView;
35
36public:
37 ATreeView();
38 ATreeView(const _<ITreeModel<AString>>& model);
39 void setModel(const _<ITreeModel<AString>>& model);
40 void onScroll(const AScrollEvent& event) override;
41 void setSize(glm::ivec2 size) override;
42 int getContentMinimumHeight() override;
43 void handleMouseMove(ItemView* pView);
44
45 void setViewFactory(const std::function<_<AView>(const _<ITreeModel<AString>>&, const ATreeModelIndex&)>& viewFactory) {
46 mViewFactory = viewFactory;
47 }
48
49 void select(const ATreeModelIndex& indexToSelect);
50
51signals:
52 emits<ATreeModelIndex> itemSelected;
53 emits<ATreeModelIndex> itemMouseClicked;
54 emits<ATreeModelIndex> itemMouseDoubleClicked;
55 emits<ATreeModelIndex> itemMouseHover;
56
57private:
59 _<ContainerView> mContent;
60 _<AScrollbar> mScrollbar;
61 _weak<ItemView> mPrevSelection;
62
63 std::function<_<AView>(const _<ITreeModel<AString>>&, const ATreeModelIndex& index)> mViewFactory;
64
65
66 void updateScrollbarDimensions();
67 void handleMousePressed(ItemView* v);
68 void handleMouseDoubleClicked(ItemView* v);
69 void handleSelected(ItemView* v);
70
71 void fillViewsRecursively(const _<AViewContainer>& content, const ATreeModelIndexOrRoot& index);
72 void makeElement(const _<AViewContainer>& container, const ATreeModelIndex& childIndex, bool isGroup, const _<ATreeView::ItemView>& itemView);
73 _<ItemView> indexToView(const ATreeModelIndex& target);
74};
75
76
Valid index of ITreeModel.
Definition: ATreeModelIndex.h:10
Definition: ATreeView.cpp:27
Definition: ATreeView.cpp:57
Displays a tree model of strings.
Definition: ATreeView.h:31
A view that represents a set of views.
Definition: AViewContainerBase.h:68
void onScroll(const AScrollEvent &event) override
Definition: AViewContainerBase.cpp:359
int getContentMinimumHeight() override
Definition: AViewContainerBase.cpp:280
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:177
Pointing method scroll event.
Definition: AScrollEvent.h:20
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:51