Skip to content

Commit

Permalink
Merge pull request #24 from Malcolmnixon/viewport-notifications
Browse files Browse the repository at this point in the history
Add viewport visibility change notifications
  • Loading branch information
Malcolmnixon authored Dec 6, 2023
2 parents 07e6855 + 0e3f142 commit ade0de6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
4 changes: 4 additions & 0 deletions VERSIONS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.2.0 (in development)
- Notify viewport scenes of visibility changes
- Add T5ToolsViewport2Din3D class name for gdscript

# 1.1.0
- Update to Godot/T5 Icon
- Migrated TiltFiveTools to latest TiltFiveGodot4 API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public override void _Ready()
body.PointerEvent += OnPointerEvent;

// Update enabled based on visibility
VisibilityChanged += UpdateEnabled;
VisibilityChanged += OnVisibilityChanged;

// Apply physics properties
UpdateScreenSize();
Expand Down Expand Up @@ -494,6 +494,19 @@ public override void _Process(double delta)
}
}

/// <summary>
/// Handle visibility changed
/// </summary>
private void OnVisibilityChanged()
{
// Update enabled state
UpdateEnabled();

// Fire visibility changed in scene
_sceneNode?.PropagateNotification(
(int)CanvasItem.NotificationVisibilityChanged);
}

/// <summary>
/// Handle setting screen size property
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@tool
class_name T5ToolsViewport2Din3D
extends Node3D


Expand Down Expand Up @@ -127,7 +128,7 @@ func _ready():
$StaticBody3D.connect("pointer_event", _on_pointer_event)

# Update enabled based on visibility
visibility_changed.connect(_update_enabled)
visibility_changed.connect(_on_visibility_changed)

# Apply physics properties
_update_screen_size()
Expand Down Expand Up @@ -244,6 +245,17 @@ func _process(delta):
set_process(false)


# Handle visibility changed
func _on_visibility_changed() -> void:
# Update enabled state
_update_enabled()

# Fire visibility changed in scene
if scene_node:
scene_node.propagate_notification(
CanvasItem.NOTIFICATION_VISIBILITY_CHANGED)


## Set screen size property
func set_screen_size(new_size: Vector2) -> void:
screen_size = new_size
Expand Down

0 comments on commit ade0de6

Please sign in to comment.