summaryrefslogtreecommitdiffstats
path: root/widget/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-02-02 14:54:56 +0100
committerLibravatar GitHub <noreply@github.com>2024-02-02 14:54:56 +0100
commitaea172543cb49f1f1e3625f60b49336f59e26c00 (patch)
treee99e7a55873678ac37fd695a0f46c1350b30dd2f /widget/src
parent759f0e922598504705b543185bc7140a652b726a (diff)
parentb3adf3184594c9bf60e0548a0362d30c512f3966 (diff)
downloadiced-aea172543cb49f1f1e3625f60b49336f59e26c00.tar.gz
iced-aea172543cb49f1f1e3625f60b49336f59e26c00.tar.bz2
iced-aea172543cb49f1f1e3625f60b49336f59e26c00.zip
Merge pull request #2120 from iced-rs/transform-primitive
`Transform` primitive
Diffstat (limited to '')
-rw-r--r--widget/src/canvas.rs6
-rw-r--r--widget/src/pane_grid.rs31
-rw-r--r--widget/src/qr_code.rs11
3 files changed, 24 insertions, 24 deletions
diff --git a/widget/src/canvas.rs b/widget/src/canvas.rs
index b95e6206..0eda0191 100644
--- a/widget/src/canvas.rs
+++ b/widget/src/canvas.rs
@@ -15,7 +15,7 @@ use crate::core::mouse;
use crate::core::renderer;
use crate::core::widget::tree::{self, Tree};
use crate::core::{
- Clipboard, Element, Length, Rectangle, Shell, Size, Vector, Widget,
+ Clipboard, Element, Length, Rectangle, Shell, Size, Transformation, Widget,
};
use crate::graphics::geometry;
@@ -207,8 +207,8 @@ where
let state = tree.state.downcast_ref::<P::State>();
- renderer.with_translation(
- Vector::new(bounds.x, bounds.y),
+ renderer.with_transformation(
+ Transformation::translate(bounds.x, bounds.y),
|renderer| {
renderer.draw(
self.program.draw(state, renderer, theme, bounds, cursor),
diff --git a/widget/src/pane_grid.rs b/widget/src/pane_grid.rs
index f76c6088..4f9a265a 100644
--- a/widget/src/pane_grid.rs
+++ b/widget/src/pane_grid.rs
@@ -962,22 +962,21 @@ pub fn draw<Theme, Renderer, T>(
if let Some(cursor_position) = cursor.position() {
let bounds = layout.bounds();
- renderer.with_translation(
- cursor_position
- - Point::new(bounds.x + origin.x, bounds.y + origin.y),
- |renderer| {
- renderer.with_layer(bounds, |renderer| {
- draw_pane(
- pane,
- renderer,
- default_style,
- layout,
- pane_cursor,
- viewport,
- );
- });
- },
- );
+ let translation = cursor_position
+ - Point::new(bounds.x + origin.x, bounds.y + origin.y);
+
+ renderer.with_translation(translation, |renderer| {
+ renderer.with_layer(bounds, |renderer| {
+ draw_pane(
+ pane,
+ renderer,
+ default_style,
+ layout,
+ pane_cursor,
+ viewport,
+ );
+ });
+ });
}
}
diff --git a/widget/src/qr_code.rs b/widget/src/qr_code.rs
index 91c0a97b..6a748e63 100644
--- a/widget/src/qr_code.rs
+++ b/widget/src/qr_code.rs
@@ -119,11 +119,12 @@ impl<'a, Message, Theme> Widget<Message, Theme, Renderer> for QRCode<'a> {
});
});
- let translation = Vector::new(bounds.x, bounds.y);
-
- renderer.with_translation(translation, |renderer| {
- renderer.draw(vec![geometry]);
- });
+ renderer.with_translation(
+ bounds.position() - Point::ORIGIN,
+ |renderer| {
+ renderer.draw(vec![geometry]);
+ },
+ );
}
}