Skip to content

Refactor GuiListbox to use GuiToggleButton and GuiScrollContainer#2777

Draft
oznogon wants to merge 5 commits intodaid:masterfrom
oznogon:guiscrollcontainer-guilistbox
Draft

Refactor GuiListbox to use GuiToggleButton and GuiScrollContainer#2777
oznogon wants to merge 5 commits intodaid:masterfrom
oznogon:guiscrollcontainer-guilistbox

Conversation

@oznogon
Copy link
Contributor

@oznogon oznogon commented Mar 10, 2026

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

Replace the bespoke audio, rendering, theming, clipping, and scrolling behaviors in GuiListbox with GuiToggleButton (audio, rendering, theming) and GuiScrollContainer (clipping, scrolling).

This changes the appearance and sfx of GuiListbox buttons to align with GuiToggleButton. To accommodate icons, GuiButton is also extended to allow customizing its icon size factor (setIconSize()), which is otherwise hardcoded to 0.8 vs. GuiListbox's default of 0.6.

If the old GuiListbox's different layout when using icons (centered text, some left pad on the icon) is preferred over GuiToggleButton's defaults, additional customization functions for GuiButton might be useful.

Theme styles defined for listbox are still used, but are now applied via GuiButton->setStyle() instead of using its own theme application logic.

Before (left) and after:

Screenshot 2026-03-10 114659 Screenshot 2026-03-10 114745

This also fixes disappearing icons in GuiListbox when a button is partially clipped.

Before:

Screenshot 2026-03-10 123106

After:

Screenshot 2026-03-10 123151

oznogon added 2 commits March 12, 2026 01:11
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
@oznogon oznogon force-pushed the guiscrollcontainer-guilistbox branch from 2c14af6 to b63d472 Compare March 12, 2026 08:12
oznogon and others added 3 commits March 12, 2026 01:44
Increase the default scrollbar click_change on GuiScrollContainer
to 50, matching mousewheel scroll increments.
- Replace bespoke button rendering and audio management with
  GuiToggleButtons. This aligns audio sfx with GuiButton, and aligns
  icon and text positioning in listboxes that use icons with GuiButton.
- Replace bespoke theme application with GuiButton->setStyle().
- Replace bespoke clipping/scrolling implementation with
  GuiScrollContainer.
- Document functions.
@oznogon oznogon force-pushed the guiscrollcontainer-guilistbox branch from b63d472 to 116b9d8 Compare March 12, 2026 08:46
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