pub struct IconGrid {
pub icons: Vec<DesktopIcon>,
pub grid_spacing_x: u32,
pub grid_spacing_y: u32,
pub cell_size: u32,
/* private fields */
}Expand description
Grid-based layout manager for desktop icons.
Fields§
§icons: Vec<DesktopIcon>All desktop icons.
grid_spacing_x: u32Horizontal spacing between grid cells (pixels).
grid_spacing_y: u32Vertical spacing between grid cells (pixels).
cell_size: u32Icon cell size (width = height = ICON_SIZE + padding).
Implementations§
Source§impl IconGrid
impl IconGrid
Sourcepub fn new(desktop_width: u32, desktop_height: u32) -> Self
pub fn new(desktop_width: u32, desktop_height: u32) -> Self
Create a new icon grid for a desktop of the given dimensions.
Sourcepub fn add_icon(&mut self, icon: DesktopIcon)
pub fn add_icon(&mut self, icon: DesktopIcon)
Add an icon to the grid.
Sourcepub fn remove_icon(&mut self, index: usize) -> Option<DesktopIcon>
pub fn remove_icon(&mut self, index: usize) -> Option<DesktopIcon>
Remove an icon by index.
Sourcepub fn snap_to_grid(&self, x: i32, y: i32) -> (i32, i32)
pub fn snap_to_grid(&self, x: i32, y: i32) -> (i32, i32)
Snap a position to the nearest grid cell.
Sourcepub fn render_icon(
icon: &DesktopIcon,
buf: &mut [u32],
buf_width: u32,
buf_height: u32,
)
pub fn render_icon( icon: &DesktopIcon, buf: &mut [u32], buf_width: u32, buf_height: u32, )
Render a single icon into a pixel buffer.
buf is buf_width x buf_height, ARGB8888 row-major.
Sourcepub fn handle_click(&mut self, px: i32, py: i32) -> Option<usize>
pub fn handle_click(&mut self, px: i32, py: i32) -> Option<usize>
Handle a click at (px, py).
Returns the index of the clicked icon (if any). Deselects all others.
Sourcepub fn handle_double_click(&mut self, px: i32, py: i32) -> Option<String>
pub fn handle_double_click(&mut self, px: i32, py: i32) -> Option<String>
Handle a double-click at (px, py).
Returns the exec command of the double-clicked icon, if any.
Sourcepub fn handle_drag(&mut self, px: i32, py: i32)
pub fn handle_drag(&mut self, px: i32, py: i32)
Handle drag: move the selected icon to (px, py) with grid snapping.
Sourcepub fn deselect_all(&mut self)
pub fn deselect_all(&mut self)
Deselect all icons.
Sourcepub fn icon_count(&self) -> usize
pub fn icon_count(&self) -> usize
Number of icons.