From 9adf74392acff9c270073f9eb0de829ecbc43d7d Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Sat, 1 Oct 2022 01:51:01 +0300 Subject: [PATCH] Use notifications for theme and translation changes to update ValueSlider --- src/Preferences/HandleThemes.gd | 3 --- src/UI/Nodes/ValueSlider.gd | 10 +++++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Preferences/HandleThemes.gd b/src/Preferences/HandleThemes.gd index f4f891ade..247fd5460 100644 --- a/src/Preferences/HandleThemes.gd +++ b/src/Preferences/HandleThemes.gd @@ -1,7 +1,5 @@ extends Node -signal theme_changed - var theme_index := 0 var theme_button_group := ButtonGroup.new() @@ -100,7 +98,6 @@ func change_theme(id: int) -> void: # Sets disabled theme color on palette swatches Global.palette_panel.reset_empty_palette_swatches_color() - emit_signal("theme_changed") func change_clear_color() -> void: diff --git a/src/UI/Nodes/ValueSlider.gd b/src/UI/Nodes/ValueSlider.gd index 6c8774bd5..1c393d90e 100644 --- a/src/UI/Nodes/ValueSlider.gd +++ b/src/UI/Nodes/ValueSlider.gd @@ -26,9 +26,11 @@ onready var line_edit: LineEdit = $LineEdit func _ready() -> void: reset_display() - if not Engine.editor_hint: - yield(get_tree(), "idle_frame") - Global.preferences_dialog.themes.connect("theme_changed", self, "reset_display") + + +func _notification(what: int) -> void: + if what == NOTIFICATION_THEME_CHANGED or what == NOTIFICATION_TRANSLATION_CHANGED: + reset_display() func _gui_input(event: InputEvent) -> void: @@ -133,6 +135,8 @@ func _confirm_text(confirm := true) -> void: func reset_display() -> void: + if not line_edit: + return line_edit.selecting_enabled = false # Remove the selection line_edit.editable = false tint_under = get_color("under_color", "ValueSlider")