Skip to content

Refactor GuiScrollText, GuiScrollFormattedText, GuiAdvancedScrollText, ShipsLog to use GuiScrollContainer#2787

Draft
oznogon wants to merge 11 commits intodaid:masterfrom
oznogon:refactor-guiscrolltext
Draft

Refactor GuiScrollText, GuiScrollFormattedText, GuiAdvancedScrollText, ShipsLog to use GuiScrollContainer#2787
oznogon wants to merge 11 commits intodaid:masterfrom
oznogon:refactor-guiscrolltext

Conversation

@oznogon
Copy link
Contributor

@oznogon oznogon commented Mar 14, 2026

This draft demonstrates usage of #2775 and stacks on that PR. 2775 requires daid/SeriousProton#300, and CI will fail without SP 300.

Refactor GuiScrollText, GuiScrollFormattedText, and GuiAdvancedScrollText to use GuiScrollContainer instead of their own scrolling and clipping behaviors. Also refactor ShipsLog to use GuiScrollContainer to manage scrollbar visibility and scroll positioning.

  • Add GuiMultilineText to display multiline text without scrolling. This separates text rendering from scrolling behavior and allows scrolling behavior to be centralized in GuiScrollContainer.
  • Refactor GuiAdvancedScrollText to compose entries within a GuiElement, allowing GuiScrollContainer to scroll them.
  • Refactor ShipsLog, the only element that uses GuiAdvancedScrollText, to use GuiScrollContainer features for scrollbar and scroll position management.

This coincidentally also solves what #2535 attempted to address.

oznogon and others added 5 commits March 13, 2026 17:35
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.
- Use pragma once guard
- Internal consistency in formatting
- Expand terse varnames
- Remove redundant public/protected sections in the header
Increase the default scrollbar click_change on GuiScrollContainer
to 50, matching mousewheel scroll increments.
If mode is ScrollMode::None, hide the scrollbar. This allows hiding
the scrollbar by setting the mode, as in ShipsLog.
@oznogon oznogon changed the title [skip ci] Refactor GuiScrollText, GuiScrollFormattedText, GuiAdvancedScrollText, ShipsLog to use GuiScrollContainer Refactor GuiScrollText, GuiScrollFormattedText, GuiAdvancedScrollText, ShipsLog to use GuiScrollContainer Mar 14, 2026
oznogon added 5 commits March 13, 2026 18:35
Add a GuiElement subclass for rendering multiline text, using the
rendering logic from GuiScrollText, but without the font clipping
flag enabled.

This allows for multiline text to be rendered separately from
scrolling implementations.
Refactor scrolling text elements to use GuiScrollContainer and
GuiMultilineText. This replaces the bespoke scrolling and clipping
behaviors with those of GuiScrollContainer, and works around font
preparation sizing issues with descenders by building in a buffer
for them.

While this reimplementation has the same interface as the prior
GuiScrollText elements, its reparenting to GuiScrollContainer forces
a change to method chaining order in the GM chat dialog.
Refactor GuiAdvancedScrollText as a subclass of GuiScrollContainer,
and replace its bespoke clipping and scrolling behaviors with
GuiScrollContainer's.

This implements an EntryCanvas subelement as a subclass of GuiElement
to serve as the child element being scrolled, and render the prefix
and entry text into the canvas.
@oznogon oznogon force-pushed the refactor-guiscrolltext branch from a834274 to 3edbe8f Compare March 14, 2026 01:36
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.

1 participant