Repository navigation
Fix UIFlatButton border gap, single-style error, and UITextArea styles - #2946
Merged
Merged
Conversation
- UIFlatButton drew its border outline inset by a full border width, but outlines are centered on their rectangle, leaving a gap of half the border width at the edge (also on UIDropdown) (#2868). - Passing a single style to a styled widget raised a confusing TypeError from DictProperty. It now says a dict of styles per state is needed, and how to start from DEFAULT_STYLE (#2817). - UITextArea set its font and color over the whole document, replacing styles set in ATTRIBUTED and HTML text. Those now win, and the arguments fill in the rest, also replacing the HTML decoder's own defaults (#2441). bold and italic set keys pyglet 3 doesn't read, so they now set weight and style. The 2_widgets example's attributed text used the old bold key too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Three GUI fixes found while triaging issues, plus a related
UITextAreabug found while fixing one of them.Gap between
UIFlatButton's border and its edge (fixes #2868)draw_lbwh_rectangle_outlinecenters the stroke on the rectangle's edge, so this left a gap of half the border width all around.UIDropdownusesUIFlatButton, so it had the gap too.Confusing error when passing a single style (fixes #2817)
Before:
UIFlatButton(style=UIFlatButton.UIStyle())raisedTypeError: attribute name must be string, not 'int'from deep insideDictProperty.After: styled widgets check for a single style and raise a
TypeErrorthat explains what to pass:Wrapping a single style as
{"normal": style}automatically wouldn't work: the hover and press states would have no style and fail later. Every styled widget has aDEFAULT_STYLE, so the suggestion works for all of them.UITextAreareplaced styles set in the text (fixes #2441)document_mode="ATTRIBUTED"or"HTML", the widget decoded the text and then set its font and color over the whole document, wiping out inline styles. It also used the length of the raw markup instead of the decoded text.font_name,font_size,text_color,boldanditalicfill in the rest. In HTML mode they also replace pyglet's HTML defaults, such as Times New Roman 12 pt. Before, those applied wherever the HTML didn't set a style.Also:
UITextArea(bold=True, italic=True)had no effectboldanditalicstyle keys, but pyglet 3 readsweightandstyle, so the text was drawn plain in every mode. It now setsweightandstyle, asarcade.Textalready does.gui/2_widgetsexample used{bold True}in its attributed text, so its labels weren't bold either. The markup now uses{weight "bold"}.Tests
test_uiflatbutton_border.py: renders a button into a GUI surface and reads the pixels across its middle. The border must reach both edges. On development the first pixel is background color.test_uistyle.py: a single style raises the new error, and the suggested{**DEFAULT_STYLE, "normal": style}works. The error test fails on development.test_uitextarea_styles.py: bold and italic, plain text, attributed text keeping an inline color, and HTML keeping<b>and<font color>while the arguments apply to the rest. 3 of the 4 fail on development.Full suite: 1764 passed. ruff, mypy and pyright all pass.
The changelog has entries under Unreleased → Fixes.
🤖 Generated with Claude Code