From 9914d09a5b36d0e2b6ed36346bc301708af139ab Mon Sep 17 00:00:00 2001 From: betalars Date: Thu, 5 Jun 2025 18:40:55 +0200 Subject: [PATCH] fix #192 implement sticky notes attaching to empty panels when dragged onto them. --- src/logic-scenes/board/card-board.gd | 6 +++++- src/logic-scenes/board/empty_sticky_note_panel.gd | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/logic-scenes/board/card-board.gd b/src/logic-scenes/board/card-board.gd index 8233b42..b8721a1 100644 --- a/src/logic-scenes/board/card-board.gd +++ b/src/logic-scenes/board/card-board.gd @@ -253,7 +253,10 @@ func handle_mouse_button(input: InputEventMouseButton, to_handle = currently_act var i: int = 0 for panel: StickyNotePanel in sticky_note_container.get_children(): i += 1 - if panel.is_gapped or i == sticky_note_container.get_child_count(): + if panel.is_empty: + if panel.get_global_rect().intersects(Rect2(to_handle.global_position - Vector2(to_handle.diameter/2, 10), Vector2(to_handle.diameter/2, 10))): + panel.attatch_sticky_note(to_handle, self) + elif panel.is_gapped or i == sticky_note_container.get_child_count(): panel.collapse_gap() var new_panel = StickyNotePanel.new() sticky_note_container.add_child(new_panel) @@ -283,6 +286,7 @@ func handle_mouse_button(input: InputEventMouseButton, to_handle = currently_act func _return_sticky_notes_to_panels(): + return #FIXME this is an early return to prevent race conditions. Check if it is save to be removed. for panel:StickyNotePanel in sticky_note_container.get_children(): panel.reclaim_sticky_note() diff --git a/src/logic-scenes/board/empty_sticky_note_panel.gd b/src/logic-scenes/board/empty_sticky_note_panel.gd index 81d4fa7..e0946d7 100644 --- a/src/logic-scenes/board/empty_sticky_note_panel.gd +++ b/src/logic-scenes/board/empty_sticky_note_panel.gd @@ -28,7 +28,11 @@ func attatch_sticky_note(attatchment: StickyNote, custom_owner: Node, tween:bool await get_tree().process_frame var height_tween: Tween = create_tween() height_tween.tween_property(self, "custom_minimum_size", minimum_size, 0.1) - attatchment.tween_transform_to(Transform2D(0, get_screen_position() + ancor_position - Vector2(0, minimum_size.y))) + var target_post = get_global_transform().origin+ancor_position + for panel: StickyNotePanel in get_parent().get_children(): + if panel.attached_sticky_note == attatchment and panel.get_index() < get_index(): + target_post = get_global_transform().origin+ancor_position - Vector2(0, minimum_size.y) + attatchment.tween_transform_to(Transform2D(0, target_post)) await attatchment.transform_tween_finished await get_tree().process_frame attatchment.reparent(self)