Refactor GuiScrollText, GuiScrollFormattedText, GuiAdvancedScrollText, ShipsLog to use GuiScrollContainer#2787
Draft
oznogon wants to merge 11 commits intodaid:masterfrom
Draft
Refactor GuiScrollText, GuiScrollFormattedText, GuiAdvancedScrollText, ShipsLog to use GuiScrollContainer#2787oznogon wants to merge 11 commits intodaid:masterfrom
oznogon wants to merge 11 commits intodaid:masterfrom
Conversation
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.
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.
a834274 to
3edbe8f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, andGuiAdvancedScrollTextto useGuiScrollContainerinstead of their own scrolling and clipping behaviors. Also refactorShipsLogto useGuiScrollContainerto manage scrollbar visibility and scroll positioning.GuiMultilineTextto display multiline text without scrolling. This separates text rendering from scrolling behavior and allows scrolling behavior to be centralized inGuiScrollContainer.GuiAdvancedScrollTextto compose entries within aGuiElement, allowingGuiScrollContainerto scroll them.ShipsLog, the only element that usesGuiAdvancedScrollText, to useGuiScrollContainerfeatures for scrollbar and scroll position management.This coincidentally also solves what #2535 attempted to address.