diff --git a/config/layouts/Main.cfg b/config/layouts/Main.cfg index 351159b..667d41d 100644 --- a/config/layouts/Main.cfg +++ b/config/layouts/Main.cfg @@ -1,7 +1,7 @@ [layout] name="Main" -saved_at="2026-05-21T09:03:37" +saved_at="2026-05-21T09:09:37" [tiles] @@ -27,6 +27,6 @@ h=1 id="system_monitor/testing" col=2 -row=1 +row=0 w=1 h=2 diff --git a/scripts/dashboard_grid.gd b/scripts/dashboard_grid.gd index b9ecf37..8233ba1 100644 --- a/scripts/dashboard_grid.gd +++ b/scripts/dashboard_grid.gd @@ -548,15 +548,20 @@ func _end_drag(mouse_pos: Vector2) -> void: _drag_module.modulate = Color(1, 1, 1, 1) var d := _get_module_grid_data(_drag_module) - var cell_pos := _cell_at_position(mouse_pos) + # Calculate target cell from the module's visual position (which already + # accounts for the grab offset), not from the raw mouse position. + # This ensures multi-cell tiles snap to the grid based on where the + # module's top-left would logically land, not where the pointer is. + var snap_pos := _drag_module.position + Vector2(_cell_w * 0.5, _cell_h * 0.5) + var cell_pos := _cell_at_position(snap_pos) var target_col := cell_pos.x var target_row := cell_pos.y - # Check if mouse is actually inside the cell bounds + # Check if the module's center is actually inside the cell bounds var on_cell := false if _is_valid_cell(target_col, target_row): var cell_ref: PanelContainer = _cells[target_row][target_col] - on_cell = Rect2(Vector2.ZERO, cell_ref.size).has_point(mouse_pos - cell_ref.position) + on_cell = Rect2(Vector2.ZERO, cell_ref.size).has_point(snap_pos - cell_ref.position) if not on_cell or not _is_valid_cell(target_col, target_row): _drop_to_source()