⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

IconGrid

Struct IconGrid 

Source
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: u32

Horizontal spacing between grid cells (pixels).

§grid_spacing_y: u32

Vertical spacing between grid cells (pixels).

§cell_size: u32

Icon cell size (width = height = ICON_SIZE + padding).

Implementations§

Source§

impl IconGrid

Source

pub fn new(desktop_width: u32, desktop_height: u32) -> Self

Create a new icon grid for a desktop of the given dimensions.

Source

pub fn add_icon(&mut self, icon: DesktopIcon)

Add an icon to the grid.

Source

pub fn remove_icon(&mut self, index: usize) -> Option<DesktopIcon>

Remove an icon by index.

Source

pub fn arrange(&mut self)

Auto-arrange all icons in a grid layout (top-left to bottom-right).

Source

pub fn snap_to_grid(&self, x: i32, y: i32) -> (i32, i32)

Snap a position to the nearest grid cell.

Source

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.

Source

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.

Source

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.

Source

pub fn handle_drag(&mut self, px: i32, py: i32)

Handle drag: move the selected icon to (px, py) with grid snapping.

Source

pub fn deselect_all(&mut self)

Deselect all icons.

Source

pub fn icon_count(&self) -> usize

Number of icons.

Trait Implementations§

Source§

impl Debug for IconGrid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for IconGrid

§

impl RefUnwindSafe for IconGrid

§

impl Send for IconGrid

§

impl Sync for IconGrid

§

impl Unpin for IconGrid

§

impl UnwindSafe for IconGrid

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.