fix: stickies no longer clipped by their own scroll container

This commit is contained in:
tiger tiger tiger 2026-01-16 23:36:28 +01:00
parent 1027e5f20a
commit 29847cdd4a
6 changed files with 24 additions and 10 deletions

View File

@ -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) var target_panel = sticky_note_container.get_child(current_sticky_note_id)
old_sticky.reparent(dropzone) old_sticky.reparent(dropzone)
old_sticky.on_board = true 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 target_panel.attached_sticky_note = old_sticky
old_sticky.attached_to = target_panel # Use reclaim to smoothly animate the sticky back to the panel
target_panel.attatch_sticky_note(old_sticky, self, false, true) target_panel.reclaim_sticky_note()
else: else:
# New sticky was loose - create new panel for old sticky # New sticky was loose - create new panel for old sticky
add_sticky_note(old_sticky) add_sticky_note(old_sticky)

View File

@ -171,10 +171,12 @@ size_flags_horizontal = 3
mouse_filter = 1 mouse_filter = 1
[node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer"] [node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer"]
clip_contents = false
layout_mode = 2 layout_mode = 2
horizontal_scroll_mode = 0 horizontal_scroll_mode = 0
[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer/ScrollContainer"] [node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer/ScrollContainer"]
z_index = 120
layout_mode = 2 layout_mode = 2
[node name="instructions_panel" type="PanelContainer" parent="."] [node name="instructions_panel" type="PanelContainer" parent="."]

View File

@ -141,7 +141,7 @@ func is_sticky_note_in_panel() -> bool:
var transform_tween: Tween 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 # Validate position to prevent teleporting
if not is_finite(target.origin.x) or not is_finite(target.origin.y): if not is_finite(target.origin.x) or not is_finite(target.origin.y):
push_warning("StickyNote.tween_transform_to: Invalid position, skipping tween") 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.stop()
transform_tween = create_tween() 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 await transform_tween.finished
transform_tween_finished.emit() transform_tween_finished.emit()

View File

@ -10,6 +10,7 @@ height = 312.0
[node name="sticky-note" type="Area2D"] [node name="sticky-note" type="Area2D"]
z_index = 1 z_index = 1
collision_layer = 2
priority = 100 priority = 100
script = ExtResource("1_yvh5n") script = ExtResource("1_yvh5n")
text = "card" text = "card"

View File

@ -51,7 +51,7 @@ func attatch_sticky_note(attatchment: StickyNote, custom_owner: Node, tween:bool
var is_gapped: bool = false var is_gapped: bool = false
func create_gap(): 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 next_id = min(self_id + 1, get_parent().get_child_count() - 1)
var previous_id = max(self_id - 1, 0) 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) height_tween.tween_property(self, "custom_minimum_size", minimum_size, 0.1)
func reclaim_sticky_note() -> bool: 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 is_attatching = true
attached_sticky_note.on_board = false 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 attached_sticky_note.z_index = 125 # Make sure it's on top of all other stickies'
await get_tree().process_frame # Reparent while keeping world position (global transform)
attached_sticky_note.reparent(self) attached_sticky_note.reparent(self, true)
attached_sticky_note.attached_to = self attached_sticky_note.attached_to = self
attached_sticky_note.owner = self.owner 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 is_attatching = false
return true return true
return false return false

View File

@ -11,4 +11,5 @@ mouse_filter = 1
script = ExtResource("1_1dtc4") script = ExtResource("1_1dtc4")
[node name="sticky-note_anchor" type="Node2D" parent="."] [node name="sticky-note_anchor" type="Node2D" parent="."]
z_index = 110
position = Vector2(105, 57) position = Vector2(105, 57)