Style the rest of the interface: panels, sliders, scrollbars, cards
ci / verify (push) Successful in 48s
ci / verify (push) Successful in 48s
Buttons were the easy half. This is everything else. Dialogs sit on panels now rather than being text over a dimmed world -- the pause menu, character select, upgrades, settings and credits all root through UiTheme.dialog_panel(). The panel stylebox is the pack's frame MODULATED DARK. The set is cream throughout, which is right for buttons and wrong for a dialog over a dark dungeon; tinting keeps the pixel border and the corner shape and lets every label the game already draws in light colours stay readable, instead of recolouring every label in five screens to suit the art. Sliders and scrollbars are the pack's too, section headings sit on its banner ribbon, and an upgrade card's rarity is now its frame rather than a word on it -- three choices are compared at a glance and a colour reads faster than a label. Two bugs of the same shape, and neither was findable without looking at the screen. A Slider and a ScrollBar take their THICKNESS from the stylebox's minimum size, which for a StyleBoxTexture is its content margins. Mine were zero, so both resolved the correct stylebox, reported the correct texture, and drew a groove zero pixels tall. A probe confirmed the theme was resolving perfectly while the track was invisible. Tests now assert every slider and scrollbar stylebox has a non-zero minimum, and it is gotcha 7 in CLAUDE.md. The first attempt at the slider groove also used the pack's HOLLOW bar sprite, whose middle is transparent -- tinting it dark left an outline and nothing else. It uses the solid one. tools/screenshot.tscn gained the upgrade screen, which it has to stage: the game scene owns that screen's visibility and re-asserts it every frame, so setting `visible` lasted exactly one frame, and standing the player at the NPC client-side lasted until reconciliation pulled them back. It now moves the player on both sides and holds it until the shot. That tool has caught four bugs the automated gates all passed. check.sh clean, 468 tests, SMOKE PASS, all four diagnostics green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -138,3 +138,77 @@ func test_every_screen_actually_gets_the_theme() -> void:
|
||||
for b: Button in buttons:
|
||||
assert_eq(b.get_theme_stylebox("normal", "Button"), wanted,
|
||||
"%s: '%s' is not themed" % [name, b.text])
|
||||
|
||||
|
||||
## A Slider draws its groove in a band whose thickness is the stylebox's own
|
||||
## minimum size -- which for a StyleBoxTexture is its content margins. With
|
||||
## those at zero the track resolves, reports the right texture, and draws
|
||||
## nothing, which is exactly what it did.
|
||||
func test_slider_styleboxes_have_a_thickness() -> void:
|
||||
var t := UiTheme.get_theme()
|
||||
for key in ["slider", "grabber_area", "grabber_area_highlight"]:
|
||||
var sb := t.get_stylebox(key, "HSlider")
|
||||
assert_gt(sb.get_minimum_size().y, 0.0,
|
||||
"HSlider/%s would draw with no height" % key)
|
||||
|
||||
|
||||
## The filled portion has to sit inside the groove, not overhang it.
|
||||
func test_the_filled_portion_is_no_thicker_than_the_groove() -> void:
|
||||
var t := UiTheme.get_theme()
|
||||
assert_lte(t.get_stylebox("grabber_area", "HSlider").get_minimum_size().y,
|
||||
t.get_stylebox("slider", "HSlider").get_minimum_size().y)
|
||||
|
||||
|
||||
func test_the_slider_grabber_is_big_enough_to_aim_at() -> void:
|
||||
var grab := UiTheme.get_theme().get_icon("grabber", "HSlider")
|
||||
assert_not_null(grab)
|
||||
assert_gte(grab.get_width(), 12, "an 8px grabber is a speck at this scale")
|
||||
assert_lte(grab.get_height(), 26, "and one taller than its row overflows it")
|
||||
|
||||
|
||||
## Nearest-neighbour and a whole multiple, or the pixel art turns to mush.
|
||||
func test_scaling_a_sprite_keeps_it_a_whole_multiple() -> void:
|
||||
var src := UiTheme.texture("grabber")
|
||||
var out := UiTheme.scaled("grabber", 2)
|
||||
assert_eq(out.get_width(), src.get_width() * 2)
|
||||
assert_eq(out.get_height(), src.get_height() * 2)
|
||||
|
||||
|
||||
## Every scrollbar piece has to be styled or the default grey chrome shows
|
||||
## through on the two screens that scroll.
|
||||
func test_scrollbars_are_styled() -> void:
|
||||
var t := UiTheme.get_theme()
|
||||
for bar_class in ["VScrollBar", "HScrollBar"]:
|
||||
for key in ["scroll", "grabber", "grabber_highlight", "grabber_pressed"]:
|
||||
assert_true(t.has_stylebox(key, bar_class),
|
||||
"%s/%s is unstyled" % [bar_class, key])
|
||||
|
||||
|
||||
## And they need a thickness, for the same reason sliders do: a ScrollBar sizes
|
||||
## itself from its styleboxes' minimum size, so styling one with no content
|
||||
## margins produces a bar zero pixels wide -- which looks exactly like having
|
||||
## no scrollbar, and did.
|
||||
func test_scrollbars_have_a_thickness_in_both_directions() -> void:
|
||||
var t := UiTheme.get_theme()
|
||||
for bar_class in ["VScrollBar", "HScrollBar"]:
|
||||
for key in ["scroll", "grabber"]:
|
||||
var size := t.get_stylebox(key, bar_class).get_minimum_size()
|
||||
assert_gt(size.x, 0.0, "%s/%s has no width" % [bar_class, key])
|
||||
assert_gt(size.y, 0.0, "%s/%s has no height" % [bar_class, key])
|
||||
|
||||
|
||||
## Panels are the pack's shape in this game's colours: the art is cream, and a
|
||||
## cream dialog over a dark dungeon would need every label in five screens
|
||||
## recoloured. Tinting the stylebox keeps the border and the existing text.
|
||||
func test_dialog_panels_are_tinted_dark() -> void:
|
||||
var sb := UiTheme.get_theme().get_stylebox("panel", "PanelContainer") as StyleBoxTexture
|
||||
assert_lt(sb.modulate_color.get_luminance(), 0.35,
|
||||
"a bright panel would make every light label on it unreadable")
|
||||
assert_gt(sb.get_minimum_size().x, 0.0, "a dialog needs padding")
|
||||
|
||||
|
||||
func test_a_card_panel_carries_its_tint() -> void:
|
||||
var card: PanelContainer = autofree(UiTheme.card_panel(Color(0.9, 0.2, 0.2)))
|
||||
var sb := card.get_theme_stylebox("panel") as StyleBoxTexture
|
||||
assert_not_null(sb)
|
||||
assert_almost_eq(sb.modulate_color.r, 0.9, 0.001)
|
||||
|
||||
Reference in New Issue
Block a user