Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): Add TextArea for auto-scrollable wrapped text support #9786

Merged
merged 13 commits into from
Jun 29, 2024

Conversation

thewierdnut
Copy link
Contributor

Feature

Add the ability to scroll the contents of a dialog

Summary

This PR adds the TextArea class, along with some Panel changes needed to support it. This class will wrap text to draw, and will automatically add controls to scroll it if needed.

As an initial implementation, I have used this TextArea to fix an issue in the Dialog class, which at high zoom levels can cause the dialog to be taller than the screen. This is easily reproducible by using the highest ui zoom level and scanning a carrier.

The TextArea can be used anywhere else where multiple lines of text need to be formatted and displayed, and can be modified in the future to handle RTL or BIDI text.

Screenshots

Before:
image

After:

textarea.mp4

Testing Done

Tested entry, ok-cancel, and ok dialogs using the scanner and the shop panel.

Performance Impact

This requires an extra texture allocation the same size as the dialog text, which gets freed when the dialog is dismissed. It will improve the cpu performance, as the rendered text will be cached from frame to frame if no scrolling has occurred.

Copy link
Member

@Hurleveur Hurleveur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks ok, I'll try to test it
Here are a few comments but I only took a quick look and dont know much about UI if I'm being honest

Edit: that showcase video looks good

source/MissionPanel.cpp Outdated Show resolved Hide resolved
source/Animate.h Show resolved Hide resolved
source/Animate.h Show resolved Hide resolved
@tibetiroka tibetiroka added enhancement A suggestion for new content or functionality that requires code changes UI Everything related to the User Interface & Design (both artwork and code) labels Feb 9, 2024
So that we don't have to use the scope resolution oprerator to tell them
apart.
Copy link
Member

@Hurleveur Hurleveur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small thing
I dont know enough about whats going on for dialog and the like to know if the inheritance is good how its currently implemented, might be good to get someone who knows about that
Probably not required to test it

source/Dialog.cpp Show resolved Hide resolved
@thewierdnut
Copy link
Contributor Author

Just a small thing I dont know enough about whats going on for dialog and the like to know if the inheritance is good how its currently implemented, might be good to get someone who knows about that Probably not required to test it

Currently, the TextArea is its own class, and it only supports text. It may be useful in the future to extract a base class that allows you to render anything in the scrollable area, which might have been a useful way to render all of the checkboxes for the plugin list and other similar scrollable things. That would be a future merge though.

Copy link
Member

@TomGoodIdea TomGoodIdea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style

source/TextArea.cpp Outdated Show resolved Hide resolved
source/TextArea.h Outdated Show resolved Hide resolved
source/TextArea.h Show resolved Hide resolved
source/TextArea.h Show resolved Hide resolved
source/TextArea.h Show resolved Hide resolved
source/TextArea.h Show resolved Hide resolved
source/Animate.h Outdated Show resolved Hide resolved
source/Panel.cpp Outdated Show resolved Hide resolved
source/Panel.cpp Outdated Show resolved Hide resolved
source/Panel.h Outdated Show resolved Hide resolved
source/Panel.h Outdated Show resolved Hide resolved
source/Panel.h Outdated Show resolved Hide resolved
source/TextArea.cpp Outdated Show resolved Hide resolved
Copy link
Member

@TomGoodIdea TomGoodIdea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dialog doesn't switch to using a TextArea when the game window is resized. Not necessarily a bug, but something that could be added for a better user experience. And I think the wide mode works the same (it's set in Dialog::Init, too), so we don't have to change it in this PR.

source/Panel.h Outdated Show resolved Hide resolved
Co-authored-by: TomGoodIdea <108272452+TomGoodIdea@users.noreply.github.com>
Copy link
Member

@TomGoodIdea TomGoodIdea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@TomGoodIdea TomGoodIdea added the waiting on dev A developer needs to do something, e.g. reviewing, merging, resolving disputes, etc. label Apr 30, 2024
@petervdmeer petervdmeer changed the title Add TextArea for auto-scrollable wrapped text support feat(scrolling): Add TextArea for auto-scrollable wrapped text support Jun 29, 2024
@petervdmeer petervdmeer changed the title feat(scrolling): Add TextArea for auto-scrollable wrapped text support feat(ui): Add TextArea for auto-scrollable wrapped text support Jun 29, 2024
@petervdmeer
Copy link
Member

All open comments seem to be handled, and reviewers seem positive: Merging.

@petervdmeer petervdmeer merged commit 55accab into endless-sky:master Jun 29, 2024
20 checks passed
@thewierdnut thewierdnut deleted the wrapped_text_buffer branch June 29, 2024 21:15
@tibetiroka tibetiroka removed the waiting on dev A developer needs to do something, e.g. reviewing, merging, resolving disputes, etc. label Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A suggestion for new content or functionality that requires code changes UI Everything related to the User Interface & Design (both artwork and code)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants