fix: stickies smoothly return and don't warp
This commit is contained in:
parent
29847cdd4a
commit
6def38a166
|
|
@ -317,11 +317,14 @@ func _end_drag(draggable: Draggable) -> void:
|
||||||
# Handle exchange result (sticky swapped with card's sticky)
|
# Handle exchange result (sticky swapped with card's sticky)
|
||||||
if result == Draggable.DropResult.EXCHANGED:
|
if result == Draggable.DropResult.EXCHANGED:
|
||||||
_handle_sticky_exchange(draggable, drop_target)
|
_handle_sticky_exchange(draggable, drop_target)
|
||||||
|
# If sticky was dropped on board (not card), reclaim it to panel with animation
|
||||||
|
elif result == Draggable.DropResult.ACCEPTED and draggable is StickyNote and drop_target == self:
|
||||||
|
_reclaim_sticky_to_panel(draggable)
|
||||||
elif draggable is StickyNote and not is_in_dropzone(draggable):
|
elif draggable is StickyNote and not is_in_dropzone(draggable):
|
||||||
# Sticky dropped in panel area but no empty panel found - create one
|
# Sticky dropped in panel area but no empty panel found - reclaim to panel
|
||||||
add_sticky_note(draggable)
|
_reclaim_sticky_to_panel(draggable)
|
||||||
else:
|
else:
|
||||||
# Fallback: use default board drop
|
# Fallback: use default board drop (for cards)
|
||||||
handle_drop(draggable)
|
handle_drop(draggable)
|
||||||
|
|
||||||
# Cleanup and state update
|
# Cleanup and state update
|
||||||
|
|
@ -348,7 +351,7 @@ func _handle_sticky_exchange(new_sticky: StickyNote, card: Card) -> void:
|
||||||
old_sticky.scale = Vector2.ONE
|
old_sticky.scale = Vector2.ONE
|
||||||
old_sticky.z_index = 0
|
old_sticky.z_index = 0
|
||||||
|
|
||||||
# Exchanged sticky always goes to sticky_note_container
|
# Exchanged sticky always goes to sticky_note_container with smooth animation
|
||||||
if new_sticky._came_from_panel and sticky_note_container.get_child_count() > 0:
|
if new_sticky._came_from_panel and sticky_note_container.get_child_count() > 0:
|
||||||
# New sticky came from panel - return old sticky to that panel (swap positions)
|
# New sticky came from panel - return old sticky to that panel (swap positions)
|
||||||
var target_panel = sticky_note_container.get_child(current_sticky_note_id)
|
var target_panel = sticky_note_container.get_child(current_sticky_note_id)
|
||||||
|
|
@ -359,14 +362,60 @@ func _handle_sticky_exchange(new_sticky: StickyNote, card: Card) -> void:
|
||||||
# Use reclaim to smoothly animate the sticky back to the panel
|
# Use reclaim to smoothly animate the sticky back to the panel
|
||||||
target_panel.reclaim_sticky_note()
|
target_panel.reclaim_sticky_note()
|
||||||
else:
|
else:
|
||||||
# New sticky was loose - create new panel for old sticky
|
# New sticky was loose - reclaim old sticky to new panel with animation
|
||||||
add_sticky_note(old_sticky)
|
_reclaim_sticky_to_panel(old_sticky)
|
||||||
|
|
||||||
# Clean up empty panel if the new sticky came from one
|
# Clean up empty panel if the new sticky came from one
|
||||||
if new_sticky._came_from_panel and sticky_note_container.get_child_count() > 0:
|
if new_sticky._came_from_panel and sticky_note_container.get_child_count() > 0:
|
||||||
sticky_note_container.get_child(current_sticky_note_id).clear_if_empty()
|
sticky_note_container.get_child(current_sticky_note_id).clear_if_empty()
|
||||||
|
|
||||||
|
|
||||||
|
## Smoothly reclaims a sticky note to a panel (creates one if needed)
|
||||||
|
func _reclaim_sticky_to_panel(sticky: StickyNote) -> void:
|
||||||
|
var target_panel: StickyNotePanel = null
|
||||||
|
|
||||||
|
# Try to find or create an appropriate panel
|
||||||
|
if sticky._came_from_panel and current_sticky_note_id < sticky_note_container.get_child_count():
|
||||||
|
# Try to use the panel the sticky came from
|
||||||
|
var original_panel = sticky_note_container.get_child(current_sticky_note_id)
|
||||||
|
if original_panel is StickyNotePanel and original_panel.is_empty():
|
||||||
|
target_panel = original_panel
|
||||||
|
|
||||||
|
# If no reusable panel, find any empty one
|
||||||
|
if not target_panel:
|
||||||
|
for panel in sticky_note_container.get_children():
|
||||||
|
if panel is StickyNotePanel and panel.is_empty():
|
||||||
|
target_panel = panel
|
||||||
|
break
|
||||||
|
|
||||||
|
# Create new panel if needed
|
||||||
|
if not target_panel:
|
||||||
|
target_panel = StickyNotePanel.new()
|
||||||
|
sticky_note_container.add_child(target_panel, true, Node.INTERNAL_MODE_DISABLED)
|
||||||
|
target_panel.set_owner(self)
|
||||||
|
|
||||||
|
# Ensure sticky is in dropzone temporarily (for smooth animation from board to panel)
|
||||||
|
if sticky.get_parent() != dropzone:
|
||||||
|
sticky.reparent(dropzone)
|
||||||
|
sticky.on_board = true
|
||||||
|
sticky.attached_to = self
|
||||||
|
sticky.current_handle = self
|
||||||
|
|
||||||
|
# Reset visual state
|
||||||
|
sticky.rotation = 0.0
|
||||||
|
sticky.scale = Vector2.ONE
|
||||||
|
sticky.z_index = 0
|
||||||
|
|
||||||
|
# Set panel reference and trigger smooth reclaim animation
|
||||||
|
target_panel.attached_sticky_note = sticky
|
||||||
|
target_panel.reclaim_sticky_note()
|
||||||
|
|
||||||
|
# Clean up other empty panels
|
||||||
|
for panel in sticky_note_container.get_children():
|
||||||
|
if panel is StickyNotePanel and panel != target_panel:
|
||||||
|
panel.clear_if_empty()
|
||||||
|
|
||||||
|
|
||||||
## Updates focus and navigation state after a drop
|
## Updates focus and navigation state after a drop
|
||||||
func _update_focus_after_drop(draggable: Draggable) -> void:
|
func _update_focus_after_drop(draggable: Draggable) -> void:
|
||||||
# Update focus based on where the item ended up
|
# Update focus based on where the item ended up
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
[node name="Panel" type="Panel"]
|
[node name="Panel" type="Panel"]
|
||||||
self_modulate = Color(1, 1, 1, 0)
|
self_modulate = Color(1, 1, 1, 0)
|
||||||
custom_minimum_size = Vector2(400, 0)
|
custom_minimum_size = Vector2(400, 100)
|
||||||
offset_right = 400.0
|
offset_right = 400.0
|
||||||
offset_bottom = 120.0
|
offset_bottom = 120.0
|
||||||
mouse_filter = 1
|
mouse_filter = 1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue