Use an alternative solution to TileSetEditor expanded view problem to fix broken resource pickers

pull/39/head
passivestar 2025-03-29 20:15:39 +07:00
parent c82b2dbbe5
commit 846b6fdde4
1 changed files with 28 additions and 3 deletions

@ -733,9 +733,13 @@ func _init() -> void:
set_constant('relationship_line_width', 'Tree', 0)
set_constant('v_separation', 'Tree', int(base_margin * 0.25 * scale))
sb = base_sb.duplicate()
sb.set_content_margin_all(base_margin * 2 * scale)
set_stylebox('panel', 'Tree', sb)
# Using empty stylebox for trees to avoid drawing unnecessary borders in docks.
# Note that using opaque color that is the same as dock background
# doesn't work because EditorPropertyResource is using Tree panel
# stylebox to draw its background as well, making it look broken
empty_sb = base_empty_sb.duplicate()
empty_sb.set_content_margin_all(base_margin * 2 * scale)
set_stylebox('panel', 'Tree', empty_sb)
# Leaving focus empty for trees and scroll containers because there's no way to
# make focus indication look not janky when only a part of a dock is highlighted
@ -777,6 +781,27 @@ func _init() -> void:
set_stylebox('panel', 'TreeSecondary', sb)
set_stylebox('panel', 'ItemListSecondary', sb)
# HACKS
# This section is for workarounds for unthemable UI
# These could be fixed on the engine side in the future
# TilesetEditor
# Tileset editor is using Tree panel for the panel container of expanded view, while minimal theme
# needs trees to be transparent, so it needs to have an explicitly set style for the theme
# to still be able to support transparent Trees
# See https://github.com/godotengine/godot/issues/99118
(func():
var tileset_editor : Control = EditorInterface.get_base_control().find_children('', 'TileSetEditor', true, false)[0]
var expand_panel : Control = tileset_editor.get_child(3)
sb = base_sb.duplicate()
sb.set_corner_radius_all(0)
expand_panel.add_theme_stylebox_override('panel', sb)
tileset_editor.theme_changed.connect(func():
expand_panel.add_theme_stylebox_override('panel', sb)
)
).call_deferred()
# Lighten base color in dark theme, darken in light theme, clamp
func _get_base_color(brightness_offset: float = 0, saturation_multiplier: float = 1) -> Color:
var dark : bool = dark_theme if brightness_offset >= 0 else !dark_theme