Add Wrapping field to RadioGroup for long option strings (#5656)#6382
Open
mohsenm4 wants to merge 3 commits into
Open
Add Wrapping field to RadioGroup for long option strings (#5656)#6382mohsenm4 wants to merge 3 commits into
mohsenm4 wants to merge 3 commits into
Conversation
Switch the internal label of each radio item from canvas.Text to RichText so future work can drive a TextWrap setting. RichText.inset is set to InnerPadding so the label keeps the previous geometry. Theme tests now read RichText MinSize because TextSize no longer exists; markup fixtures are regenerated to reflect the new label widget node (positions and sizes are unchanged).
Add a public Wrapping field on RadioGroup (Since: 2.9) that is propagated to each radio item and forwarded to the underlying RichText label. When wrapping is enabled, Layout uses the assigned size to size each item to the available width and reads its content height back so wrapped lines stay inside the group. With the default TextWrapOff the previous layout path is preserved unchanged.
* Drop the redundant inset assignment in CreateRenderer; update() already sets it and runs immediately after. * Document why label.inset is set to InnerPadding (negate RichText's built-in padding so geometry stays compatible with the old canvas.Text-based renderer). * Add a Scroll hint to RadioGroup.Wrapping's godoc for when the parent does not give the group enough room. * Note in radioGroupRenderer.MinSize that per-item MinSize shrinks with Wrapping enabled, mirroring widget.Label. * Add a horizontal-wrap test that asserts items keep equal width and height and are placed side by side.
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.
Summary
Adds a
Wrapping fyne.TextWrapfield onRadioGroup(since 2.9) so a longoption string can wrap to a new line instead of being clipped.
Fixes #5656
Example from the issue now wraps at the right edge of the group:
Approach
radioItemlabel is converted fromcanvas.TexttoRichTextsothe existing wrap implementation can be reused.
RichText.insetisset to
InnerPaddingso the geometry the renderer produces is thesame as before.
RadioGroup.Wrappingis propagated to eachradioItem.wrappingandforwarded to the label inside
Refresh, so changes after creationapply immediately.
radioGroupRenderer.Layoutuses theassigned size as the available width and reads each item's height
back from
MinSizeso wrapped lines stay inside the group. With thedefault
TextWrapOff, the previous layout path is kept unchanged,so existing apps are not affected.
Notes for review
fyne.TextWrap, matchingwidget.Label.*widget.RichTextnode wrapping a<text>child. Positions andsizes did not change.
takes a smaller approach: it keeps the no-wrap layout path bit-for-
bit identical and only adds a separate wrap-aware path, instead of
rewriting the existing one.
Test plan
go test ./widget/ -run TestRadio(all radio tests pass)TestRadioGroup_Wrapping_PropagatesToItemsverifies thefield is forwarded to each item on create and on
Refresh.TestRadioGroup_Wrapping_WrapsLongOptionverifies that along option is taller with
TextWrapBreakthan without.