Skip to main content

Canvas

Struct Canvas 

Source
pub struct Canvas<'b, B: Backend> { /* private fields */ }

Implementations§

Source§

impl<'b, B: Backend> Canvas<'b, B>

Source

pub fn new(backend: &'b mut B) -> Self

Source

pub fn width(&self) -> u32

Source

pub fn height(&self) -> u32

Source

pub fn size(&self) -> (u32, u32)

Source

pub fn fill_rect(&mut self, x: u32, y: u32, w: u32, h: u32, color: Color)

Source

pub fn draw_text(&mut self, x: u32, y: u32, text: &str, color: Color)

Source

pub fn hline(&mut self, x: u32, y: u32, w: u32, color: Color)

Source

pub fn vline(&mut self, x: u32, y: u32, h: u32, color: Color)

Source

pub fn draw_rect(&mut self, x: u32, y: u32, w: u32, h: u32, color: Color)

Source

pub fn clear(&mut self, color: Color)

Source

pub fn present(&mut self)

Source

pub fn poll_event(&mut self) -> Option<Event>

Source

pub fn panel( &mut self, x: u32, y: u32, w: u32, h: u32, fill: Color, border: Color, )

Draw a filled rectangle with a 1-pixel border.

Source

pub fn title_bar( &mut self, x: u32, y: u32, w: u32, h: u32, title: &str, bg: Color, )

Draw a title bar: filled strip + white text.

Source

pub fn button( &mut self, x: u32, y: u32, w: u32, h: u32, label: &str, fill: Color, border: Color, text_color: Color, )

Draw a simple button with border, fill, and centred label.

Source

pub fn progress_bar( &mut self, x: u32, y: u32, w: u32, h: u32, percent: u32, track: Color, fill: Color, border: Color, )

Draw a horizontal progress bar. percent is clamped to 0–100.

Source

pub fn divider_v(&mut self, x: u32, y: u32, h: u32)

Draw a vertical divider line.

Source

pub fn divider_h(&mut self, x: u32, y: u32, w: u32)

Draw a horizontal divider line.

Source

pub fn centered_text( &mut self, x: u32, y: u32, w: u32, text: &str, color: Color, )

Draw text centered horizontally in a w-wide strip starting at x.

Source

pub fn right_text(&mut self, x: u32, y: u32, w: u32, text: &str, color: Color)

Draw right-aligned text ending at x + w.

Source

pub fn fill_rounded(&mut self, x: u32, y: u32, w: u32, h: u32, color: Color)

Fill a rounded-corner rectangle (corners are clipped by 1 pixel).

Source

pub fn gradient_h( &mut self, x: u32, y: u32, w: u32, h: u32, left: Color, right: Color, )

Fill a horizontal gradient from left to right color across w pixels.

Source

pub fn gradient_v( &mut self, x: u32, y: u32, w: u32, h: u32, top: Color, bottom: Color, )

Fill a vertical gradient from top to bottom color across h pixels.

Source

pub fn shadow_panel( &mut self, x: u32, y: u32, w: u32, h: u32, fill: Color, border: Color, )

Panel with a 4-pixel dark drop shadow behind it.

Source

pub fn accent_bar(&mut self, x: u32, y: u32, h: u32, color: Color)

3-pixel vertical accent bar — used for selection indicators.

Source

pub fn dot(&mut self, x: u32, y: u32, color: Color)

Tiny 4×4 filled status dot.

Source

pub fn icon_tile(&mut self, x: u32, y: u32, size: u32, bg: Color, label: &str)

Colored app icon tile: rounded background + centered label.

Source

pub fn gradient_progress( &mut self, x: u32, y: u32, w: u32, h: u32, percent: u32, track: Color, fill_l: Color, fill_r: Color, border: Color, )

Progress bar with a two-stop horizontal gradient fill.

Source

pub fn fill_round4(&mut self, x: u32, y: u32, w: u32, h: u32, color: Color)

Filled rectangle with 4-pixel rounded corners (AdwPreferencesGroup / card style).

Source

pub fn toggle_switch(&mut self, x: u32, y: u32, on: bool, accent: Color)

GNOME AdwToggleSwitch (52×26 px). Knob slides left=off, right=on.

Source

pub fn action_row( &mut self, x: u32, y: u32, w: u32, title: &str, subtitle: &str, value: &str, hovered: bool, last: bool, ) -> u32

GNOME AdwActionRow — title + optional subtitle on left, text value on right. Set last = true on the final row of a group to skip the separator. Returns the row height (52).

Source

pub fn action_row_toggle( &mut self, x: u32, y: u32, w: u32, title: &str, subtitle: &str, on: bool, accent: Color, hovered: bool, last: bool, ) -> u32

GNOME AdwSwitchRow — action row with a toggle switch on the right. Returns the row height (52).

Source

pub fn action_row_nav( &mut self, x: u32, y: u32, w: u32, title: &str, subtitle: &str, hovered: bool, last: bool, ) -> u32

Navigation action row — chevron on right, no value text. Returns the row height (52).

Source

pub fn search_bar( &mut self, x: u32, y: u32, w: u32, text: &str, focused: bool, accent: Color, )

Pill-shaped search entry (height 36). Draws placeholder or query text.

Source

pub fn gnome_headerbar( &mut self, x: u32, y: u32, w: u32, title: &str, has_back: bool, bg: Color, )

GNOME AdwHeaderBar (48 px tall) — centered title, back button, end menu button.

Source

pub fn spinner(&mut self, cx: u32, cy: u32, frame: u32, color: Color)

8-dot animated spinner. cx/cy is the center. Frame drives rotation.

Source

pub fn toast(&mut self, x: u32, y: u32, w: u32, message: &str, accent: Color)

Pill-shaped in-app notification toast (44 px tall).

Source

pub fn avatar( &mut self, x: u32, y: u32, size: u32, initials: &str, color: Color, )

Circular avatar tile with initials (uses fill_round4 as circle approximation).

Source

pub fn chip(&mut self, x: u32, y: u32, text: &str, bg: Color, fg: Color)

Small pill-shaped chip / badge label.

Source

pub fn backend_mut(&mut self) -> &mut B

Access the underlying backend directly for operations not in Canvas.

Auto Trait Implementations§

§

impl<'b, B> Freeze for Canvas<'b, B>

§

impl<'b, B> RefUnwindSafe for Canvas<'b, B>
where B: RefUnwindSafe,

§

impl<'b, B> Send for Canvas<'b, B>
where B: Send,

§

impl<'b, B> Sync for Canvas<'b, B>
where B: Sync,

§

impl<'b, B> Unpin for Canvas<'b, B>

§

impl<'b, B> UnsafeUnpin for Canvas<'b, B>

§

impl<'b, B> !UnwindSafe for Canvas<'b, B>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.