From 29847cdd4a18ec46c5c1296a5a215089640f0bf5 Mon Sep 17 00:00:00 2001 From: Tiger Jove Date: Fri, 16 Jan 2026 23:36:28 +0100 Subject: [PATCH] fix: stickies no longer clipped by their own scroll container --- src/logic-scenes/board/card-board.gd | 5 +++-- src/logic-scenes/board/physics-board.tscn | 2 ++ src/logic-scenes/board/sticky-note.gd | 4 ++-- src/logic-scenes/board/sticky-note.tscn | 1 + src/logic-scenes/board/sticky_note_panel.gd | 21 +++++++++++++------ src/logic-scenes/board/sticky_note_panel.tscn | 1 + 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/logic-scenes/board/card-board.gd b/src/logic-scenes/board/card-board.gd index 8236032..2008138 100644 --- a/src/logic-scenes/board/card-board.gd +++ b/src/logic-scenes/board/card-board.gd @@ -354,9 +354,10 @@ func _handle_sticky_exchange(new_sticky: StickyNote, card: Card) -> void: var target_panel = sticky_note_container.get_child(current_sticky_note_id) old_sticky.reparent(dropzone) old_sticky.on_board = true + old_sticky.attached_to = dropzone.get_parent() # Detach from card, attach to board temporarily target_panel.attached_sticky_note = old_sticky - old_sticky.attached_to = target_panel - target_panel.attatch_sticky_note(old_sticky, self, false, true) + # Use reclaim to smoothly animate the sticky back to the panel + target_panel.reclaim_sticky_note() else: # New sticky was loose - create new panel for old sticky add_sticky_note(old_sticky) diff --git a/src/logic-scenes/board/physics-board.tscn b/src/logic-scenes/board/physics-board.tscn index 7095990..9922bbd 100644 --- a/src/logic-scenes/board/physics-board.tscn +++ b/src/logic-scenes/board/physics-board.tscn @@ -171,10 +171,12 @@ size_flags_horizontal = 3 mouse_filter = 1 [node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer"] +clip_contents = false layout_mode = 2 horizontal_scroll_mode = 0 [node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer/ScrollContainer"] +z_index = 120 layout_mode = 2 [node name="instructions_panel" type="PanelContainer" parent="."] diff --git a/src/logic-scenes/board/sticky-note.gd b/src/logic-scenes/board/sticky-note.gd index 2ef05ab..3957373 100644 --- a/src/logic-scenes/board/sticky-note.gd +++ b/src/logic-scenes/board/sticky-note.gd @@ -141,7 +141,7 @@ func is_sticky_note_in_panel() -> bool: var transform_tween: Tween -func tween_transform_to(target: Transform2D): +func tween_transform_to(target: Transform2D, duration: float = 0.25): # Validate position to prevent teleporting if not is_finite(target.origin.x) or not is_finite(target.origin.y): push_warning("StickyNote.tween_transform_to: Invalid position, skipping tween") @@ -152,7 +152,7 @@ func tween_transform_to(target: Transform2D): transform_tween.stop() transform_tween = create_tween() - transform_tween.tween_property(self, "transform", target, 0.25) + transform_tween.tween_property(self, "transform", target, duration) await transform_tween.finished transform_tween_finished.emit() diff --git a/src/logic-scenes/board/sticky-note.tscn b/src/logic-scenes/board/sticky-note.tscn index 5448b6f..228c8d8 100644 --- a/src/logic-scenes/board/sticky-note.tscn +++ b/src/logic-scenes/board/sticky-note.tscn @@ -10,6 +10,7 @@ height = 312.0 [node name="sticky-note" type="Area2D"] z_index = 1 +collision_layer = 2 priority = 100 script = ExtResource("1_yvh5n") text = "card" diff --git a/src/logic-scenes/board/sticky_note_panel.gd b/src/logic-scenes/board/sticky_note_panel.gd index d132b66..e362239 100644 --- a/src/logic-scenes/board/sticky_note_panel.gd +++ b/src/logic-scenes/board/sticky_note_panel.gd @@ -51,7 +51,7 @@ func attatch_sticky_note(attatchment: StickyNote, custom_owner: Node, tween:bool var is_gapped: bool = false func create_gap(): - var self_id = get_parent().get_children().find(self) + var self_id := get_parent().get_children().find(self) var next_id = min(self_id + 1, get_parent().get_child_count() - 1) var previous_id = max(self_id - 1, 0) @@ -70,15 +70,24 @@ func collapse_gap(): height_tween.tween_property(self, "custom_minimum_size", minimum_size, 0.1) func reclaim_sticky_note() -> bool: - if is_empty() and attached_sticky_note.attached_to != Card: + # Don't reclaim if sticky is already attached to this panel (prevents double reclaim) + if is_empty() and attached_sticky_note.attached_to != self and attached_sticky_note.attached_to is not Card: is_attatching = true attached_sticky_note.on_board = false - attached_sticky_note.tween_transform_to(Transform2D(0, get_screen_position() + ancor_position)) - await attached_sticky_note.transform_tween_finished - await get_tree().process_frame - attached_sticky_note.reparent(self) + + attached_sticky_note.z_index = 125 # Make sure it's on top of all other stickies' + # Reparent while keeping world position (global transform) + attached_sticky_note.reparent(self, true) attached_sticky_note.attached_to = self attached_sticky_note.owner = self.owner + + # Tween from current position to target anchor position in panel's coordinate space + var tween := create_tween().set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_BACK) + tween.tween_property(attached_sticky_note, "position", ancor_position, 0.7) + await tween.finished + + attached_sticky_note.z_index = 0 + is_attatching = false return true return false diff --git a/src/logic-scenes/board/sticky_note_panel.tscn b/src/logic-scenes/board/sticky_note_panel.tscn index db946ec..0795227 100644 --- a/src/logic-scenes/board/sticky_note_panel.tscn +++ b/src/logic-scenes/board/sticky_note_panel.tscn @@ -11,4 +11,5 @@ mouse_filter = 1 script = ExtResource("1_1dtc4") [node name="sticky-note_anchor" type="Node2D" parent="."] +z_index = 110 position = Vector2(105, 57)