Skip to content

[#2771] Implement GuiScrollContainer, a scrolling GuiContainer#2775

Open
oznogon wants to merge 6 commits intodaid:masterfrom
oznogon:generic-scrolling-guicontainer
Open

[#2771] Implement GuiScrollContainer, a scrolling GuiContainer#2775
oznogon wants to merge 6 commits intodaid:masterfrom
oznogon:generic-scrolling-guicontainer

Conversation

@oznogon
Copy link
Contributor

@oznogon oznogon commented Mar 9, 2026

Implements #2771. Requires daid/SeriousProton#300.

Add GuiScrollContainer, a subclass of GuiElement that further modifies its drawing functions to support clipping and vertical scrolling.

  • Add static helper functions for subclass access to protected GuiContainer members related to this purpose (ownership, hover/focus, drawing, clicking, and scroll behavior).
    • Update GuiContainer style and formatting for consistency.
  • Add a GuiScrollContainer subclass of GuiElement.
    • Implement RenderTarget features added in Define arbitrary clipping regions SeriousProton#300 to mask rendering visibility to the element's rect.
    • Implement a scroll offset for GuiScrollContainer contents, and apply the scroll offset recursively to child elements to allow nesting of elements that use GuiScrollContainer.

This also modifies GuiSelector to apply scroll translation to the popup generated by GuiSelector, which is created outside of the tree.

Closes #2652.

@oznogon
Copy link
Contributor Author

oznogon commented Mar 9, 2026

I've been using this implementation for a while in a branch focused on expanding ECS GM tweaks. This also has implications for the HotkeyMenu, and I've also tested replacing the bespoke scrolling and text/image clipping code in GuiListbox by using GuiScrollContainer as a parent. This can likely also be applied to the scrolling and clipping code in text boxes. Will file additional PRs for the HotkeyMenu and GuiListbox (#2777) to demonstrate the behavior.

@oznogon oznogon force-pushed the generic-scrolling-guicontainer branch 2 times, most recently from 5659439 to 7dec195 Compare March 10, 2026 19:14
@oznogon oznogon force-pushed the generic-scrolling-guicontainer branch from f0cb26d to 8b62ab9 Compare March 12, 2026 08:44
@oznogon oznogon force-pushed the generic-scrolling-guicontainer branch from 7abb9fd to 386f4fc Compare March 14, 2026 00:35
@oznogon oznogon marked this pull request as draft March 14, 2026 01:11
@oznogon oznogon force-pushed the generic-scrolling-guicontainer branch 2 times, most recently from 0f4bdeb to 4d6a029 Compare March 14, 2026 01:15
oznogon added 2 commits March 13, 2026 18:28
Add GuiScrollContainer, a subclass of GuiContainer to support
arbitrary and nested scrolling elements. This relies on changes in
SeriousProton to implement GL_SCISSOR_TEST in RenderTarget.

Child element positions and click/hover handling are translated
relative to the scroll position. These containers can be nested, and
mousewheel and scroll events are passed down the tree.

This container element can also replace the bespoke scrolling behaviors
in other element types, such as GuiListbox.

- Pass focus, text input through GuiScrollContainer.
- Position nested GuiSelector popups relative to scroll translation
- Add scrollToOffset() function to allow other elements to control
  scroll position.
- Handle layout padding in scissor rects.
- Hide scrollbar if ScrollMode is None.
- Use pragma once guard
- Internal consistency in formatting
- Expand terse varnames
- Remove redundant public/protected sections in the header
oznogon added 4 commits March 21, 2026 11:46
Remove use of SP-based translation/reprojection and implement
scrolling by recursively manipulating descendant rects.

- Add GuiContainer::offsetElementRect() to recursively apply the
  given positional offset.
- Replace SP translation methods in GuiScrollContainer with
  GuiContainer::offsetElementRect().
- Update GuiSelector popup handling.
Remove offsetElementRect() (which recursively loops child elements)
and instead move elements by scroll_offset in updateLayout() (which
already recursively loops child elements).
@oznogon
Copy link
Contributor Author

oznogon commented Mar 22, 2026

Moved the scrolling implementation from RenderTarget to GuiContainer and especially GuiScrollContainer::updateLayout(). Instead of translating the render, it now recursively applies the scroll offset to child rects to keep it all within the layout system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Implement GuiKeyValueDisplay container that supports scrolling or pagination

1 participant