AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
AScrollAreaViewport.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
15#include "AViewContainer.h"
16#include "AScrollbar.h"
17#include "glm/fwd.hpp"
18
19
28class API_AUI_VIEWS AScrollAreaViewport: public AViewContainerBase {
29public:
30 AScrollAreaViewport();
31 ~AScrollAreaViewport() override;
32
33 void setContents(_<AView> content);
34
35 [[nodiscard]]
36 const _<AView>& contents() const noexcept {
37 return mContents;
38 }
39
40 void applyGeometryToChildren() override;
41
42 void setScroll(glm::uvec2 scroll) {
43 if (mScroll == scroll) [[unlikely]] {
44 return;
45 }
46 mScroll = scroll;
47 updateContentsScroll();
48 }
49
50 void setScrollX(unsigned scroll) {
51 if (mScroll.x == scroll) [[unlikely]] {
52 return;
53 }
54 mScroll.x = scroll;
55 updateContentsScroll();
56 }
57
58 void setScrollY(unsigned scroll) {
59 if (mScroll.y == scroll) [[unlikely]] {
60 return;
61 }
62 mScroll.y = scroll;
63 updateContentsScroll();
64 }
65
66 [[nodiscard]]
67 glm::uvec2 scroll() const noexcept {
68 return mScroll;
69 }
70
71private:
72 class Inner;
73 _<Inner> mInner;
74 _<AView> mContents;
75
76 glm::uvec2 mScroll = {0, 0};
77
78 void updateContentsScroll();
79};
80
Definition AScrollAreaViewport.cpp:21
void setContents(const _< AViewContainer > &container)
Moves (like via std::move) all children and layout of the specified container to this container.
Definition AViewContainerBase.cpp:515
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:178