@@ -140,11 +140,11 @@ func undo_redo_register_change(action_name : String, previous_state : Dictionary
140140 if new_state .hash () == previous_state .hash ():
141141 return
142142 get_parent ().undoredo_create_step (action_name , generator .get_hier_name (), previous_state , new_state )
143-
144- func move_parameter ( widget_name : String , offset : int ) -> void :
143+
144+ func rearrange_parameter ( from : int , to : int , is_after : bool ) -> void :
145145 old_state = generator .serialize ().duplicate (true )
146- generator .move_parameter ( widget_name , offset )
147- undo_redo_register_change ("Move parameter" , old_state )
146+ generator .rearrange_parameter ( from , to , is_after )
147+ undo_redo_register_change ("Rearrange parameter" , old_state )
148148
149149func remove_parameter (widget_name : String ) -> void :
150150 old_state = generator .serialize ().duplicate (true )
@@ -269,12 +269,10 @@ func on_exit_widget(widget) -> void:
269269 l .queue_free ()
270270 links .erase (widget )
271271
272-
273272func modulate_row_controls (row_index : int , color : Color ):
274273 for i in range (grid .columns * row_index , grid .columns * row_index + grid .columns ):
275274 grid .get_child (i ).modulate = color
276275
277-
278276func row_get_data (_at_pos : Vector2 , index : int , widget_name : String ) -> Dictionary :
279277 var preview_root := Control .new ()
280278
@@ -315,13 +313,13 @@ func row_get_data(_at_pos: Vector2, index: int, widget_name: String) -> Dictiona
315313
316314 return { "row_index" : row_index , "widget_name" : widget_name , "node_name" : name }
317315
318-
319316func row_can_drop (_at_pos : Vector2 , data : Dictionary , index : int ) -> bool :
320317 return data .row_index != floor (index / grid .columns ) and data .node_name == name
321318
322-
323- func row_drop_data (_at_pos : Vector2 , data : Dictionary , index : int ) -> void :
324- move_parameter (data .widget_name , floor (index / grid .columns ) - data .row_index )
319+ func row_drop_data (at_pos : Vector2 , data : Dictionary , index : int ) -> void :
320+ var row_index := int (index / grid .columns )
321+ var drop_pos_y : float = at_pos .y / grid .get_child (row_index ).size .y
322+ rearrange_parameter (data .row_index , row_index , drop_pos_y > 0.5 )
325323
326324 # workaround FloatEdits' focused state when dropping rows
327325 await get_tree ().process_frame
@@ -332,7 +330,6 @@ func row_drop_data(_at_pos: Vector2, data: Dictionary, index: int) -> void:
332330 float_edit .get_child (0 ).add_theme_stylebox_override (
333331 "background" , get_theme_stylebox ("normal" ,"MM_NodeFloatEdit" ))
334332
335-
336333func _notification (what : int ) -> void :
337334 match what :
338335 NOTIFICATION_DRAG_END :
0 commit comments