Skip to content

Commit f690020

Browse files
CopilotLexian-droid
andcommitted
Fix external drop positioning and action/condition drag in groups
Co-authored-by: Lexian-droid <[email protected]>
1 parent c606455 commit f690020

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

addons/flowkit/ui/editor.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,8 @@ func _connect_group_signals(group) -> void:
11891189
group.edit_event_requested.connect(func(row): _on_row_edit(row, row))
11901190
group.add_condition_requested.connect(func(row): _on_row_add_condition(row, row))
11911191
group.add_action_requested.connect(func(row): _on_row_add_action(row, row))
1192+
group.condition_dropped.connect(_on_condition_dropped)
1193+
group.action_dropped.connect(_on_action_dropped)
11921194

11931195
func _on_group_add_event_requested(group_node) -> void:
11941196
"""Handle request to add an event inside a group."""

addons/flowkit/ui/workspace/group.gd

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ signal replace_event_requested(row) ## Emitted when replacing event
2323
signal edit_event_requested(row) ## Emitted when editing event
2424
signal add_condition_requested(row) ## Emitted when adding condition to event
2525
signal add_action_requested(row) ## Emitted when adding action to event
26+
signal condition_dropped(source_row, condition_data, target_row) ## Emitted when condition is dropped on an event
27+
signal action_dropped(source_row, action_data, target_row) ## Emitted when action is dropped on an event
2628

2729
# === Constants ===
2830
const EVENT_ROW_SCENE = preload("res://addons/flowkit/ui/workspace/event_row.tscn")
@@ -241,6 +243,8 @@ func _instantiate_event_row(data: FKEventBlock) -> Control:
241243
row.edit_event_requested.connect(func(r): edit_event_requested.emit(r))
242244
row.add_condition_requested.connect(func(r): add_condition_requested.emit(r))
243245
row.add_action_requested.connect(func(r): add_action_requested.emit(r))
246+
row.condition_dropped.connect(func(src, cond, tgt): condition_dropped.emit(src, cond, tgt))
247+
row.action_dropped.connect(func(src, act, tgt): action_dropped.emit(src, act, tgt))
244248
row.data_changed.connect(_on_child_modified)
245249
row.before_data_changed.connect(func(): before_data_changed.emit())
246250

@@ -288,6 +292,8 @@ func _instantiate_group(data: FKGroupBlock) -> Control:
288292
nested.edit_event_requested.connect(func(r): edit_event_requested.emit(r))
289293
nested.add_condition_requested.connect(func(r): add_condition_requested.emit(r))
290294
nested.add_action_requested.connect(func(r): add_action_requested.emit(r))
295+
nested.condition_dropped.connect(func(src, cond, tgt): condition_dropped.emit(src, cond, tgt))
296+
nested.action_dropped.connect(func(src, act, tgt): action_dropped.emit(src, act, tgt))
291297

292298
return nested
293299

@@ -833,17 +839,11 @@ func _calculate_drop_index(dragged_node: Node) -> int:
833839
var mid_y = rect.position.y + rect.size.y * 0.5
834840

835841
if local_y < mid_y:
836-
# Insert before this child - find its position in group_data
837-
# Iterate through data to find the matching visual child
838-
for data_idx in range(group_data.children.size()):
839-
var child_obj = _get_child_node_at_data_index(data_idx)
840-
if child_obj == child:
841-
return data_idx
842-
# Fallback if not found
842+
# Insert at this position (i is the visual index which maps to data index)
843843
return i
844844

845845
# Insert at end (after all visible children)
846-
return group_data.children.size()
846+
return visible_children.size()
847847

848848

849849
func _get_child_node_at_data_index(data_idx: int) -> Node:

0 commit comments

Comments
 (0)