fix #192 implement sticky notes attaching to empty panels when dragged onto them.
This commit is contained in:
parent
699fb27a6b
commit
9914d09a5b
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue