Settings has a Theme row listing Settings.THEMES: Classic (main_theme.tres, still the default) and Original web (original_web_theme.tres), which looks like MusicFrontend: orange-bordered buttons, a #333 header and popups, #424242 panels, #4e4e4e alternating rows, a yellow playing song and a light grey player bar. Picking one sets the root window's theme at once and saves it as theme_id in settings.cfg, and it is applied at start. The popup backdrop and score graph follow a theme switch. The top bar has its own TopBarBackground style. test_theme.gd checks that every theme has everything main_theme.tres has. The screenshot tool takes a theme id. Closes #42 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.4 KiB
GDScript
38 lines
1.4 KiB
GDScript
class_name PopupBackdrop
|
|
extends ColorRect
|
|
## Dims everything behind an open popup and keeps clicks from reaching the buttons
|
|
## under it.
|
|
##
|
|
## The backdrop sits above the rest of its parent and below the popups it belongs to.
|
|
## Popups close themselves when clicked outside, and the backdrop keeps that click from
|
|
## reaching the buttons behind them.
|
|
|
|
var _popups: Array[BasePopup] = []
|
|
|
|
|
|
## Adds a backdrop to [param parent] and moves [param popups] above it. The backdrop
|
|
## shows while any of them is open.
|
|
static func add_to(parent: Control, popups: Array[BasePopup]) -> PopupBackdrop:
|
|
var backdrop: PopupBackdrop = PopupBackdrop.new()
|
|
backdrop.name = "PopupBackdrop"
|
|
backdrop.mouse_filter = Control.MOUSE_FILTER_STOP
|
|
backdrop._popups = popups
|
|
parent.add_child(backdrop)
|
|
backdrop.color = backdrop.get_theme_color(&"backdrop", &"Palette")
|
|
backdrop.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
for popup: BasePopup in popups:
|
|
parent.move_child(popup, -1)
|
|
popup.visibility_changed.connect(backdrop._update)
|
|
backdrop._update()
|
|
return backdrop
|
|
|
|
|
|
func _notification(what: int) -> void:
|
|
# The dimming colour comes from the theme, which can be switched in Settings
|
|
if what == NOTIFICATION_THEME_CHANGED:
|
|
color = get_theme_color(&"backdrop", &"Palette")
|
|
|
|
|
|
func _update() -> void:
|
|
visible = _popups.any(func(popup: BasePopup) -> bool: return popup.visible)
|