28class API_AUI_VIEWS AScrollAreaViewport:
public AViewContainerBase {
32 AScrollAreaViewport();
33 ~AScrollAreaViewport()
override;
38 const _<AView>& contents()
const noexcept {
42 void applyGeometryToChildren()
override;
44 void setScroll(glm::uvec2 scroll) {
45 if (mScroll == scroll) [[unlikely]] {
49 updateContentsScroll();
52 void setScrollX(
unsigned scroll) {
53 if (mScroll.x == scroll) [[unlikely]] {
57 updateContentsScroll();
60 void setScrollY(
unsigned scroll) {
61 if (mScroll.y == scroll) [[unlikely]] {
65 updateContentsScroll();
69 auto scroll()
const noexcept {
72 &AScrollAreaViewport::mScroll,
73 &AScrollAreaViewport::setScroll,
92 template<aui::invocable ApplyLayoutUpdate>
99 glm::uvec2 mScroll = {0, 0};
102 void updateContentsScroll();
107 _<AView> anchor, ApplyLayoutUpdate&& applyLayoutUpdate, glm::ivec2 diffMask) {
108 auto queryRelativePosition = [&] {
109 glm::ivec2 accumulator{};
110 for (
auto v = anchor.get(); v !=
nullptr && v->getParent() !=
this; v = v->getParent()) {
111 accumulator += v->getPosition();
115 auto before = queryRelativePosition();
117 auto after = queryRelativePosition();
118 auto diff = after - before;
120 mScroll = glm::max(glm::ivec2(mScroll) + diff, glm::ivec2(0));
121 updateContentsScroll();