diff options
author | 2020-05-28 01:37:59 +0200 | |
---|---|---|
committer | 2020-05-28 01:40:30 +0200 | |
commit | 2ca7e3c4b0cb293adebf9a9bf9a26191069d495d (patch) | |
tree | 653a1f24422079231ff5a9f0d868c7d117ca92ed /graphics/src/backend.rs | |
parent | 45511a442f707e93fe6e568d2100756b63af7362 (diff) | |
download | iced-2ca7e3c4b0cb293adebf9a9bf9a26191069d495d.tar.gz iced-2ca7e3c4b0cb293adebf9a9bf9a26191069d495d.tar.bz2 iced-2ca7e3c4b0cb293adebf9a9bf9a26191069d495d.zip |
Write documentation for `iced_graphics`
Diffstat (limited to 'graphics/src/backend.rs')
-rw-r--r-- | graphics/src/backend.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/graphics/src/backend.rs b/graphics/src/backend.rs index ee4eca0a..83510311 100644 --- a/graphics/src/backend.rs +++ b/graphics/src/backend.rs @@ -1,15 +1,33 @@ +//! Write a graphics backend. use iced_native::image; use iced_native::svg; use iced_native::{Font, Size}; +/// The graphics backend of a [`Renderer`]. +/// +/// [`Renderer`]: ../struct.Renderer.html pub trait Backend { + /// Trims the measurements cache. + /// + /// This method is currently necessary to properly trim the text cache in + /// `iced_wgpu` and `iced_glow` because of limitations in the text rendering + /// pipeline. It will be removed in the future. fn trim_measurements(&mut self) {} } +/// A graphics backend that supports text rendering. pub trait Text { + /// The icon font of the backend. const ICON_FONT: Font; + + /// The `char` representing a ✔ icon in the [`ICON_FONT`]. + /// + /// [`ICON_FONT`]: #associatedconst.ICON_FONt const CHECKMARK_ICON: char; + /// Measures the text contents with the given size and font, + /// returning the size of a laid out paragraph that fits in the provided + /// bounds. fn measure( &self, contents: &str, @@ -19,10 +37,14 @@ pub trait Text { ) -> (f32, f32); } +/// A graphics backend that supports image rendering. pub trait Image { + /// Returns the dimensions of the provided image. fn dimensions(&self, handle: &image::Handle) -> (u32, u32); } +/// A graphics backend that supports SVG rendering. pub trait Svg { + /// Returns the viewport dimensions of the provided SVG. fn viewport_dimensions(&self, handle: &svg::Handle) -> (u32, u32); } |