Skip to main content

orbital_datatable/core/
column_drag.rs

1/// Floating preview shown while drag-reordering a column.
2#[derive(Clone, Debug, PartialEq)]
3pub struct ColumnDragGhost {
4    pub label: String,
5    pub width_px: f32,
6    pub x: f32,
7    pub y: f32,
8}
9
10const GHOST_OFFSET_X: f32 = 12.0;
11const GHOST_OFFSET_Y: f32 = 12.0;
12
13pub fn column_drag_ghost_at_pointer(
14    label: String,
15    width_px: f32,
16    x: f32,
17    y: f32,
18) -> ColumnDragGhost {
19    ColumnDragGhost {
20        label,
21        width_px,
22        x: x - GHOST_OFFSET_X,
23        y: y - GHOST_OFFSET_Y,
24    }
25}
26
27pub fn move_column_drag_ghost(ghost: &mut ColumnDragGhost, x: f32, y: f32) {
28    ghost.x = x - GHOST_OFFSET_X;
29    ghost.y = y - GHOST_OFFSET_Y;
30}