pub struct Canvas<'b, B: Backend> { /* private fields */ }Implementations§
Source§impl<'b, B: Backend> Canvas<'b, B>
impl<'b, B: Backend> Canvas<'b, B>
pub fn new(backend: &'b mut B) -> Self
pub fn width(&self) -> u32
pub fn height(&self) -> u32
pub fn size(&self) -> (u32, u32)
pub fn fill_rect(&mut self, x: u32, y: u32, w: u32, h: u32, color: Color)
pub fn draw_text(&mut self, x: u32, y: u32, text: &str, color: Color)
pub fn hline(&mut self, x: u32, y: u32, w: u32, color: Color)
pub fn vline(&mut self, x: u32, y: u32, h: u32, color: Color)
pub fn draw_rect(&mut self, x: u32, y: u32, w: u32, h: u32, color: Color)
pub fn clear(&mut self, color: Color)
pub fn present(&mut self)
pub fn poll_event(&mut self) -> Option<Event>
Sourcepub fn panel(
&mut self,
x: u32,
y: u32,
w: u32,
h: u32,
fill: Color,
border: Color,
)
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.
Sourcepub fn title_bar(
&mut self,
x: u32,
y: u32,
w: u32,
h: u32,
title: &str,
bg: Color,
)
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.
Draw a simple button with border, fill, and centred label.
Sourcepub fn progress_bar(
&mut self,
x: u32,
y: u32,
w: u32,
h: u32,
percent: u32,
track: Color,
fill: Color,
border: Color,
)
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.
Sourcepub fn centered_text(
&mut self,
x: u32,
y: u32,
w: u32,
text: &str,
color: Color,
)
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.
Sourcepub fn right_text(&mut self, x: u32, y: u32, w: u32, text: &str, color: Color)
pub fn right_text(&mut self, x: u32, y: u32, w: u32, text: &str, color: Color)
Draw right-aligned text ending at x + w.
Sourcepub fn fill_rounded(&mut self, x: u32, y: u32, w: u32, h: u32, color: Color)
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).
Sourcepub fn gradient_h(
&mut self,
x: u32,
y: u32,
w: u32,
h: u32,
left: Color,
right: Color,
)
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.
Sourcepub fn gradient_v(
&mut self,
x: u32,
y: u32,
w: u32,
h: u32,
top: Color,
bottom: Color,
)
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.
Sourcepub fn shadow_panel(
&mut self,
x: u32,
y: u32,
w: u32,
h: u32,
fill: Color,
border: Color,
)
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.
Sourcepub fn accent_bar(&mut self, x: u32, y: u32, h: u32, color: Color)
pub fn accent_bar(&mut self, x: u32, y: u32, h: u32, color: Color)
3-pixel vertical accent bar — used for selection indicators.
Sourcepub fn icon_tile(&mut self, x: u32, y: u32, size: u32, bg: Color, label: &str)
pub fn icon_tile(&mut self, x: u32, y: u32, size: u32, bg: Color, label: &str)
Colored app icon tile: rounded background + centered label.
Sourcepub 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,
)
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.
Sourcepub fn fill_round4(&mut self, x: u32, y: u32, w: u32, h: u32, color: Color)
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).
Sourcepub fn toggle_switch(&mut self, x: u32, y: u32, on: bool, accent: Color)
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.
Sourcepub fn action_row(
&mut self,
x: u32,
y: u32,
w: u32,
title: &str,
subtitle: &str,
value: &str,
hovered: bool,
last: bool,
) -> u32
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).
Sourcepub 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
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).
Navigation action row — chevron on right, no value text. Returns the row height (52).
Sourcepub fn search_bar(
&mut self,
x: u32,
y: u32,
w: u32,
text: &str,
focused: bool,
accent: Color,
)
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.
Sourcepub fn gnome_headerbar(
&mut self,
x: u32,
y: u32,
w: u32,
title: &str,
has_back: bool,
bg: Color,
)
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.
Sourcepub fn spinner(&mut self, cx: u32, cy: u32, frame: u32, color: Color)
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.
Sourcepub fn toast(&mut self, x: u32, y: u32, w: u32, message: &str, accent: Color)
pub fn toast(&mut self, x: u32, y: u32, w: u32, message: &str, accent: Color)
Pill-shaped in-app notification toast (44 px tall).
Sourcepub fn avatar(
&mut self,
x: u32,
y: u32,
size: u32,
initials: &str,
color: Color,
)
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).
Sourcepub fn chip(&mut self, x: u32, y: u32, text: &str, bg: Color, fg: Color)
pub fn chip(&mut self, x: u32, y: u32, text: &str, bg: Color, fg: Color)
Small pill-shaped chip / badge label.
Sourcepub fn backend_mut(&mut self) -> &mut B
pub fn backend_mut(&mut self) -> &mut B
Access the underlying backend directly for operations not in Canvas.