forked from gilzoide/godot-dockable-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockable_panel_reference_control.gd
47 lines (34 loc) · 1.33 KB
/
dockable_panel_reference_control.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
@tool
extends Container
# Control that mimics its own visibility and rect into another Control.
var reference_to: Control :
get:
return _reference_to
set(control):
if _reference_to != control:
if _reference_to:
_reference_to.disconnect("renamed",Callable(self,"_on_reference_to_renamed"))
_reference_to.disconnect("minimum_size_changed",Callable(self,"minimum_size_changed"))
_reference_to = control
emit_signal("minimum_size_changed")
if not _reference_to:
return
_reference_to.connect("renamed",Callable(self,"_on_reference_to_renamed"))
_reference_to.connect("minimum_size_changed",Callable(self, "minimum_size_changed"))
_reference_to.visible = visible
var _reference_to: Control = null
func _ready() -> void:
mouse_filter = MOUSE_FILTER_IGNORE
set_notify_transform(true)
func _notification(what: int) -> void:
if what == NOTIFICATION_VISIBILITY_CHANGED and _reference_to:
_reference_to.visible = visible
elif what == NOTIFICATION_TRANSFORM_CHANGED and _reference_to:
_reposition_reference()
func _get_minimum_size() -> Vector2:
return _reference_to.get_combined_minimum_size() if _reference_to else Vector2.ZERO
func _reposition_reference() -> void:
_reference_to.global_position = global_position
_reference_to.size = size
func _on_reference_to_renamed() -> void:
name = _reference_to.name