Fix toolbar gaps and theme toggle shape
- A toolbar icon that hides itself at runtime (labs, notes, flashcard, bookmark) left its text label behind, showing as an orphaned label floating in a gap. The label's wrapper now tracks the button's own visibility. - The theme toggle used a distinct circular pill shape; changed it to match the same rounded-square box every other toolbar icon uses.
This commit is contained in:
@@ -898,27 +898,17 @@ func _toolbar_box(dark: bool, active: bool = false) -> StyleBoxFlat:
|
||||
return box
|
||||
|
||||
|
||||
func _theme_toggle_box(dark: bool, hovered: bool = false) -> StyleBoxFlat:
|
||||
var box := StyleBoxFlat.new()
|
||||
box.bg_color = Color("111b30") if dark else Brand.LIGHT_SURFACE
|
||||
box.border_color = Brand.AMBER if hovered else (Color("33415d") if dark else Brand.LIGHT_BORDER)
|
||||
box.set_border_width_all(1)
|
||||
box.set_corner_radius_all(22)
|
||||
box.content_margin_left = 0
|
||||
box.content_margin_right = 0
|
||||
box.content_margin_top = 0
|
||||
box.content_margin_bottom = 0
|
||||
return box
|
||||
|
||||
|
||||
func _style_theme_toggle_button(dark: bool) -> void:
|
||||
if theme_button == null:
|
||||
return
|
||||
Brand.set_theme_toggle_icon(theme_button, dark)
|
||||
theme_button.tooltip_text = "Switch to light mode" if dark else "Switch to dark mode"
|
||||
theme_button.add_theme_stylebox_override("normal", _theme_toggle_box(dark))
|
||||
theme_button.add_theme_stylebox_override("hover", _theme_toggle_box(dark, true))
|
||||
theme_button.add_theme_stylebox_override("pressed", _theme_toggle_box(dark, true))
|
||||
# Match the same rounded-square box every other toolbar icon uses, rather than
|
||||
# the distinct circular pill shape - it should read as one of the toolbar, not
|
||||
# a visually separate control.
|
||||
theme_button.add_theme_stylebox_override("normal", _toolbar_box(dark))
|
||||
theme_button.add_theme_stylebox_override("hover", _toolbar_box(dark, true))
|
||||
theme_button.add_theme_stylebox_override("pressed", _toolbar_box(dark, true))
|
||||
theme_button.add_theme_stylebox_override("focus", StyleBoxEmpty.new())
|
||||
theme_button.add_theme_constant_override("h_separation", 0)
|
||||
|
||||
@@ -2146,6 +2136,7 @@ func _toolbar_labeled_button(button: Button, label_text: String) -> Control:
|
||||
wrap.add_theme_constant_override("separation", 2)
|
||||
wrap.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
wrap.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
|
||||
wrap.visible = button.visible
|
||||
wrap.add_child(button)
|
||||
var label := Label.new()
|
||||
label.name = "ToolbarLabel"
|
||||
@@ -2154,6 +2145,10 @@ func _toolbar_labeled_button(button: Button, label_text: String) -> Control:
|
||||
label.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
|
||||
_set_scaled_label(label, 11, Brand.SLATE)
|
||||
wrap.add_child(label)
|
||||
# Some buttons (labs, notes, flashcard, bookmark) toggle their own .visible at
|
||||
# runtime depending on the question/session - without this, the icon disappears
|
||||
# but its label stays behind, leaving an orphaned label floating in a gap.
|
||||
button.visibility_changed.connect(func(): wrap.visible = button.visible)
|
||||
return wrap
|
||||
|
||||
|
||||
|
||||
@@ -376,7 +376,7 @@ func _test_player_runtime_construction() -> void:
|
||||
_assert(player.report_button.icon == player.REPORT_QUESTION_LIGHT_ICON, "report question should support its light-mode artwork")
|
||||
var toggle_box := player.theme_button.get_theme_stylebox("normal") as StyleBoxFlat
|
||||
_assert(player.theme_button.custom_minimum_size == Vector2(44, 44), "question theme toggle should retain the shared square footprint")
|
||||
_assert(toggle_box != null and toggle_box.corner_radius_top_left == 22, "question theme toggle should use the shared circular treatment")
|
||||
_assert(toggle_box != null and toggle_box.corner_radius_top_left == 7, "question theme toggle should match the other toolbar icons' rounded-square treatment")
|
||||
_assert(player.theme_button.icon in [Brand.SUN_ICON, Brand.MOON_ICON], "question theme toggle should use the shared sun or moon icon")
|
||||
_assert(player.choice_badges.size() == 5, "question player should construct an answer badge for every visible choice slot")
|
||||
_assert(player.choice_followup_panels[2].get_parent() == player.choice_rows[2], "distractor remediation should remain nested inside its answer choice")
|
||||
|
||||
Reference in New Issue
Block a user