15#include "AViewContainer.h"
16#include "AScrollbar.h"
28class API_AUI_VIEWS AScrollAreaViewport:
public AViewContainerBase {
32 AScrollAreaViewport();
33 ~AScrollAreaViewport()
override;
38 const _<AView>& contents()
const noexcept {
48 void setScroll(glm::uvec2 scroll) {
49 if (mScroll == scroll) [[unlikely]] {
53 updateContentsScroll();
56 void setScrollX(
unsigned scroll) {
57 if (mScroll.x == scroll) [[unlikely]] {
61 updateContentsScroll();
64 void setScrollY(
unsigned scroll) {
65 if (mScroll.y == scroll) [[unlikely]] {
69 updateContentsScroll();
73 auto scroll() const noexcept {
76 &AScrollAreaViewport::mScroll,
77 &AScrollAreaViewport::setScroll,
96 template<aui::invocable ApplyLayoutUpdate>
97 void compensateLayoutUpdatesByScroll(_<AView> anchor, ApplyLayoutUpdate&& applyLayoutUpdate, glm::ivec2 diffMask = glm::ivec2(1, 1));
103 glm::uvec2 mScroll = {0, 0};
106 void updateContentsScroll();
109template <aui::invocable ApplyLayoutUpdate>
111 _<AView> anchor, ApplyLayoutUpdate&& applyLayoutUpdate, glm::ivec2 diffMask) {
112 auto queryRelativePosition = [&] {
113 glm::ivec2 accumulator{};
114 for (
auto v = anchor.get(); v !=
nullptr && v->getParent() !=
this; v = v->getParent()) {
115 accumulator += v->getPosition();
119 auto before = queryRelativePosition();
121 auto after = queryRelativePosition();
122 auto diff = after - before;
124 mScroll = glm::max(glm::ivec2(mScroll) + diff, glm::ivec2(0));
125 updateContentsScroll();
void setContents(const _< AViewContainer > &container)
Moves (like via std::move) all children and layout of the specified container to this container.
auto position() const
Top left corner's position relative to top left corner's position of the parent AView.
Definition AView.h:102
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:215
ASignal< Args... > emits
A signal declaration.
Definition ASignal.h:577