diff options
author | 2024-03-22 05:41:15 +0100 | |
---|---|---|
committer | 2024-03-22 05:41:15 +0100 | |
commit | 4f2f40c68b4647f281d34034beb159a41422aa06 (patch) | |
tree | 1fa11b5c4ed1bab19d5feff1beb122aa6a4955f5 /graphics | |
parent | 1f13a91361258a1607c71f4840a26a6437f88612 (diff) | |
download | iced-4f2f40c68b4647f281d34034beb159a41422aa06.tar.gz iced-4f2f40c68b4647f281d34034beb159a41422aa06.tar.bz2 iced-4f2f40c68b4647f281d34034beb159a41422aa06.zip |
Fix standalone compilation of `iced_widget` crate
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/src/cached.rs | 9 | ||||
-rw-r--r-- | graphics/src/geometry.rs | 10 | ||||
-rw-r--r-- | graphics/src/geometry/frame.rs | 46 |
3 files changed, 65 insertions, 0 deletions
diff --git a/graphics/src/cached.rs b/graphics/src/cached.rs index f7968c9f..b52f9d9d 100644 --- a/graphics/src/cached.rs +++ b/graphics/src/cached.rs @@ -31,3 +31,12 @@ impl<T> Cached for Primitive<T> { Arc::new(self) } } + +#[cfg(debug_assertions)] +impl Cached for () { + type Cache = (); + + fn load(_cache: &Self::Cache) -> Self {} + + fn cache(self) -> Self::Cache {} +} diff --git a/graphics/src/geometry.rs b/graphics/src/geometry.rs index 194f37b2..d251efb8 100644 --- a/graphics/src/geometry.rs +++ b/graphics/src/geometry.rs @@ -44,3 +44,13 @@ pub trait Backend { /// Creates a new [`Self::Frame`]. fn new_frame(&self, size: Size) -> Self::Frame; } + +#[cfg(debug_assertions)] +impl Renderer for () { + type Geometry = (); + type Frame = (); + + fn new_frame(&self, _size: Size) -> Self::Frame {} + + fn draw_geometry(&mut self, _geometry: Self::Geometry) {} +} diff --git a/graphics/src/geometry/frame.rs b/graphics/src/geometry/frame.rs index 635012d0..ad35e8ec 100644 --- a/graphics/src/geometry/frame.rs +++ b/graphics/src/geometry/frame.rs @@ -203,3 +203,49 @@ pub trait Backend: Sized { fn into_geometry(self) -> Self::Geometry; } + +#[cfg(debug_assertions)] +impl Backend for () { + type Geometry = (); + + fn width(&self) -> f32 { + 0.0 + } + + fn height(&self) -> f32 { + 0.0 + } + + fn size(&self) -> Size { + Size::ZERO + } + + fn center(&self) -> Point { + Point::ORIGIN + } + + fn push_transform(&mut self) {} + fn pop_transform(&mut self) {} + + fn translate(&mut self, _translation: Vector) {} + fn rotate(&mut self, _angle: impl Into<Radians>) {} + fn scale(&mut self, _scale: impl Into<f32>) {} + fn scale_nonuniform(&mut self, _scale: impl Into<Vector>) {} + + fn draft(&mut self, _size: Size) -> Self {} + fn paste(&mut self, _frame: Self, _at: Point) {} + + fn stroke<'a>(&mut self, _path: &Path, _stroke: impl Into<Stroke<'a>>) {} + + fn fill(&mut self, _path: &Path, _fill: impl Into<Fill>) {} + fn fill_text(&mut self, _text: impl Into<Text>) {} + fn fill_rectangle( + &mut self, + _top_left: Point, + _size: Size, + _fill: impl Into<Fill>, + ) { + } + + fn into_geometry(self) -> Self::Geometry {} +} |