summaryrefslogtreecommitdiffstats
path: root/wgpu/src/geometry.rs
diff options
context:
space:
mode:
authorLibravatar Michal Lebeda <MichalLebeda@users.noreply.github.com>2023-08-02 14:35:53 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-31 19:00:02 +0100
commitf1c63398b35d651de54d36fbd2091f07ccf44cc6 (patch)
tree413f931e04ff54c63f5d0233941b1d94da23dd81 /wgpu/src/geometry.rs
parent5540ac07e4695cc4e268979eca4efeb604b7c77f (diff)
downloadiced-f1c63398b35d651de54d36fbd2091f07ccf44cc6.tar.gz
iced-f1c63398b35d651de54d36fbd2091f07ccf44cc6.tar.bz2
iced-f1c63398b35d651de54d36fbd2091f07ccf44cc6.zip
Add return values to Frame::with_clip() and Frame::with_save()
Diffstat (limited to 'wgpu/src/geometry.rs')
-rw-r--r--wgpu/src/geometry.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/wgpu/src/geometry.rs b/wgpu/src/geometry.rs
index 4d7f443e..a4d4fb1f 100644
--- a/wgpu/src/geometry.rs
+++ b/wgpu/src/geometry.rs
@@ -388,12 +388,14 @@ impl Frame {
/// This method is useful to compose transforms and perform drawing
/// operations in different coordinate systems.
#[inline]
- pub fn with_save(&mut self, f: impl FnOnce(&mut Frame)) {
+ pub fn with_save<R>(&mut self, f: impl FnOnce(&mut Frame) -> R) -> R {
self.push_transform();
- f(self);
+ let result = f(self);
self.pop_transform();
+
+ result
}
/// Pushes the current transform in the transform stack.
@@ -413,14 +415,20 @@ impl Frame {
/// This method is useful to perform drawing operations that need to be
/// clipped.
#[inline]
- pub fn with_clip(&mut self, region: Rectangle, f: impl FnOnce(&mut Frame)) {
+ pub fn with_clip<R>(
+ &mut self,
+ region: Rectangle,
+ f: impl FnOnce(&mut Frame) -> R,
+ ) -> R {
let mut frame = Frame::new(region.size());
- f(&mut frame);
+ let result = f(&mut frame);
let origin = Point::new(region.x, region.y);
self.clip(frame, origin);
+
+ result
}
/// Draws the clipped contents of the given [`Frame`] with origin at the given [`Point`].