Skip to content

Commit f4056d9

Browse files
Flynsarmybitbrain
andauthored
Fade debug nodes back to normal state (#366)
Co-authored-by: miguel <miguel-gonzalez@gmx.de>
1 parent 464cde4 commit f4056d9

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

addons/beehave/debug/new_graph_node.gd

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var titlebar_hbox: HBoxContainer
4040

4141
var frames: RefCounted
4242
var horizontal: bool = false
43+
var panels_tween: Tween
4344

4445

4546
func _init(frames:RefCounted, horizontal: bool = false) -> void:
@@ -147,8 +148,38 @@ func set_output_color(color: Color) -> void:
147148

148149

149150
func _set_stylebox_overrides(panel_stylebox: StyleBox, titlebar_stylebox: StyleBox) -> void:
150-
add_theme_stylebox_override("panel", panel_stylebox)
151-
add_theme_stylebox_override("titlebar", titlebar_stylebox)
151+
# First update and any status change gets immediate panel update
152+
if not has_theme_stylebox_override("panel") or panel_stylebox != frames.panel_normal:
153+
if panels_tween:
154+
panels_tween.kill()
155+
panels_tween = null
156+
157+
add_theme_stylebox_override("panel", panel_stylebox)
158+
add_theme_stylebox_override("titlebar", titlebar_stylebox)
159+
return
160+
161+
# Don't need to do anything if we're already tweening back to normal
162+
if panels_tween:
163+
return
164+
165+
# Don't need to do anything if our colors are already the same as a normal
166+
var cur_panel_stylebox: StyleBox = get_theme_stylebox("panel")
167+
var cur_titlebar_stylebox: StyleBox = get_theme_stylebox("titlebar")
168+
if cur_panel_stylebox.bg_color == frames.panel_normal.bg_color:
169+
return
170+
171+
# Apply a duplicate of our current panels that we can tween
172+
add_theme_stylebox_override("panel", cur_panel_stylebox.duplicate())
173+
add_theme_stylebox_override("titlebar", cur_titlebar_stylebox.duplicate())
174+
cur_panel_stylebox = get_theme_stylebox("panel")
175+
cur_titlebar_stylebox = get_theme_stylebox("titlebar")
176+
177+
# Going back to normal is a fade
178+
panels_tween = create_tween()
179+
panels_tween.parallel().tween_property(cur_panel_stylebox, "bg_color", panel_stylebox.bg_color, 1.0)
180+
panels_tween.parallel().tween_property(cur_panel_stylebox, "border_color", panel_stylebox.border_color, 1.0)
181+
panels_tween.parallel().tween_property(cur_titlebar_stylebox, "bg_color", panel_stylebox.bg_color, 1.0)
182+
panels_tween.parallel().tween_property(cur_titlebar_stylebox, "border_color", panel_stylebox.border_color, 1.0)
152183

153184

154185
func _on_size_changed():

0 commit comments

Comments
 (0)