Implement responsive profile and account data controls
This commit is contained in:
+26
-19
@@ -148,46 +148,53 @@ static func style_chip(button: Button, color: Color) -> void:
|
||||
|
||||
static func refresh_tree(root: Control, was_dark: bool) -> void:
|
||||
apply_app_theme(root)
|
||||
_translate_control(root, DARK_PALETTE if was_dark else LIGHT_PALETTE, LIGHT_PALETTE if was_dark else DARK_PALETTE)
|
||||
_translate_control(
|
||||
root,
|
||||
DARK_PALETTE if was_dark else LIGHT_PALETTE,
|
||||
LIGHT_PALETTE if was_dark else DARK_PALETTE,
|
||||
was_dark
|
||||
)
|
||||
|
||||
|
||||
static func _translate_control(control: Control, source: Dictionary, target: Dictionary) -> void:
|
||||
static func _translate_control(control: Control, source: Dictionary, target: Dictionary, from_dark: bool) -> void:
|
||||
if control is ColorRect:
|
||||
control.color = _translate_color(control.color, source, target)
|
||||
control.color = _translate_color(control.color, source, target, from_dark)
|
||||
for color_name in ["font_color", "font_hover_color", "font_pressed_color", "font_disabled_color", "font_selected_color", "default_color", "font_uneditable_color"]:
|
||||
if control.has_theme_color_override(color_name):
|
||||
control.add_theme_color_override(color_name, _translate_color(control.get_theme_color(color_name), source, target))
|
||||
control.add_theme_color_override(color_name, _translate_color(control.get_theme_color(color_name), source, target, from_dark))
|
||||
for style_name in ["panel", "normal", "hover", "pressed", "disabled", "focus", "fill", "background", "read_only"]:
|
||||
if control.has_theme_stylebox_override(style_name):
|
||||
var box := control.get_theme_stylebox(style_name)
|
||||
if box is StyleBoxFlat:
|
||||
var translated := box.duplicate() as StyleBoxFlat
|
||||
translated.bg_color = _translate_color(translated.bg_color, source, target)
|
||||
translated.border_color = _translate_color(translated.border_color, source, target)
|
||||
translated.bg_color = _translate_color(translated.bg_color, source, target, from_dark)
|
||||
translated.border_color = _translate_color(translated.border_color, source, target, from_dark)
|
||||
control.add_theme_stylebox_override(style_name, translated)
|
||||
for child in control.get_children():
|
||||
if child is Control:
|
||||
_translate_control(child, source, target)
|
||||
_translate_control(child, source, target, from_dark)
|
||||
|
||||
|
||||
static func _translate_color(color: Color, source: Dictionary, target: Dictionary) -> Color:
|
||||
static func _translate_color(color: Color, source: Dictionary, target: Dictionary, from_dark: bool) -> Color:
|
||||
for key in source:
|
||||
var candidate: Color = source[key]
|
||||
if color.is_equal_approx(candidate):
|
||||
var replacement: Color = target[key]
|
||||
replacement.a = color.a
|
||||
return replacement
|
||||
for dark_color in CUSTOM_DARK_TO_LIGHT:
|
||||
if color.is_equal_approx(dark_color):
|
||||
var replacement: Color = CUSTOM_DARK_TO_LIGHT[dark_color]
|
||||
replacement.a = color.a
|
||||
return replacement
|
||||
for dark_color in CUSTOM_DARK_TO_LIGHT:
|
||||
var light_color: Color = CUSTOM_DARK_TO_LIGHT[dark_color]
|
||||
if color.is_equal_approx(light_color):
|
||||
var replacement: Color = dark_color
|
||||
replacement.a = color.a
|
||||
return replacement
|
||||
if from_dark:
|
||||
for dark_color in CUSTOM_DARK_TO_LIGHT:
|
||||
if color.is_equal_approx(dark_color):
|
||||
var replacement: Color = CUSTOM_DARK_TO_LIGHT[dark_color]
|
||||
replacement.a = color.a
|
||||
return replacement
|
||||
else:
|
||||
for dark_color in CUSTOM_DARK_TO_LIGHT:
|
||||
var light_color: Color = CUSTOM_DARK_TO_LIGHT[dark_color]
|
||||
if color.is_equal_approx(light_color):
|
||||
var replacement: Color = dark_color
|
||||
replacement.a = color.a
|
||||
return replacement
|
||||
return color
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user