Skip to content

Commit 6913d60

Browse files
Merge pull request #16 from murikistudio/extra-signals
Add new singleton signals - show_started - hide_started - transition_started - transition_completed
2 parents 7c80266 + 679a548 commit 6913d60

3 files changed

Lines changed: 37 additions & 4 deletions

File tree

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,19 +197,31 @@ Ease curve of the animations. Same as `Tween.EaseType`.
197197
The singleton `GuiTransitions` allows to trigger the transitions globally and swap GUI layouts.
198198

199199
### Signals
200+
#### show_started
201+
Emitted when a layout is about to be shown.
202+
200203
#### show_completed
201-
The signal `show_completed` is emited after a layout has been shown.
204+
Emitted after a layout has been shown.
205+
206+
#### hide_started
207+
Emited when a layout is about to be hidden.
202208

203209
#### hide_completed
204-
The signal `hide_completed` is emited after a layout has been hidden.
210+
Emitted after a layout has been hidden.
211+
212+
#### transition_started
213+
Emmited when a layout is about to be shown or hidden.
214+
215+
#### transition_completed
216+
Emited after a layout has been shown or hidden.
205217

206218
### Public Methods
207219
**Note**: Optional arguments in the methods below are suffixed with `?` (e.g. `function?`).
208220

209221
#### go_to(id: String, function?: Callable)
210222
The method `go_to` hides the current layout and shows the layout with the given `id`.
211223
If `function` (optional) is passed in, the `function` will be executed halfway through.
212-
Both signals `hide_completed` and `show_completed` are emited accordingly.
224+
Both signals `hide_completed` and `show_completed` are emitted accordingly.
213225

214226
#### update(function?: Callable)
215227
The method `update` hides and shows the current layout.

addons/simple-gui-transitions/singleton.gd

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,24 @@ extends Node
33

44

55
# Signals
6+
## Emited when a layout is about to be shown.
7+
signal show_started
8+
69
## Emited after a layout has been shown.
710
signal show_completed
811

12+
## Emited when a layout is about to be hidden.
13+
signal hide_started
14+
915
## Emited after a layout has been hidden.
1016
signal hide_completed
1117

18+
## Emmited when a layout is about to be shown or hidden.
19+
signal transition_started
20+
21+
## Emited after a layout has been shown or hidden.
22+
signal transition_completed
23+
1224

1325
# Variables
1426
## GUI layout references affected by transitions.

addons/simple-gui-transitions/transition.gd

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class NodeInfo extends RefCounted:
101101
func init_tween() -> void:
102102
if not is_instance_valid(node):
103103
return
104-
104+
105105
if tween and tween.is_valid():
106106
tween.kill()
107107

@@ -522,12 +522,17 @@ func _show(id := ""):
522522
else:
523523
_slide_in(node_info)
524524

525+
GuiTransitions.transition_started.emit()
526+
GuiTransitions.show_started.emit()
527+
525528
if _tween and _tween.is_valid():
526529
await _tween.finished
530+
527531
_is_shown = true
528532
_status = Status.OK
529533

530534
if GuiTransitions.is_shown(layout_id):
535+
GuiTransitions.transition_completed.emit()
531536
GuiTransitions.show_completed.emit()
532537

533538

@@ -547,6 +552,9 @@ func _hide(id := "", function = null):
547552
else:
548553
_slide_out(node_info)
549554

555+
GuiTransitions.transition_started.emit()
556+
GuiTransitions.hide_started.emit()
557+
550558
if _tween and _tween.is_valid():
551559
await _tween.finished
552560

@@ -558,6 +566,7 @@ func _hide(id := "", function = null):
558566
_status = Status.OK
559567

560568
if GuiTransitions.is_hidden(layout_id):
569+
GuiTransitions.transition_completed.emit()
561570
GuiTransitions.hide_completed.emit()
562571

563572

0 commit comments

Comments
 (0)