From f4d66486016076bb339a338bc589645119962d1e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 24 Oct 2023 05:34:03 +0200 Subject: Introduce `with_transformation` to `Renderer` trait --- widget/src/pane_grid.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'widget/src/pane_grid.rs') diff --git a/widget/src/pane_grid.rs b/widget/src/pane_grid.rs index f76c6088..24389462 100644 --- a/widget/src/pane_grid.rs +++ b/widget/src/pane_grid.rs @@ -43,7 +43,7 @@ use crate::core::widget; use crate::core::widget::tree::{self, Tree}; use crate::core::{ Clipboard, Element, Layout, Length, Pixels, Point, Rectangle, Shell, Size, - Vector, Widget, + Transformation, Vector, Widget, }; /// A collection of panes distributed using either vertical or horizontal splits @@ -962,9 +962,11 @@ pub fn draw( 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), + let translation = cursor_position + - Point::new(bounds.x + origin.x, bounds.y + origin.y); + + renderer.with_transformation( + Transformation::translate(translation.x, translation.y), |renderer| { renderer.with_layer(bounds, |renderer| { draw_pane( -- cgit From a06682ff420678f7068265191738ab70ebe30b4c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 2 Feb 2024 14:31:17 +0100 Subject: Use `with_translation` wherever possible --- widget/src/pane_grid.rs | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'widget/src/pane_grid.rs') diff --git a/widget/src/pane_grid.rs b/widget/src/pane_grid.rs index 24389462..4f9a265a 100644 --- a/widget/src/pane_grid.rs +++ b/widget/src/pane_grid.rs @@ -43,7 +43,7 @@ use crate::core::widget; use crate::core::widget::tree::{self, Tree}; use crate::core::{ Clipboard, Element, Layout, Length, Pixels, Point, Rectangle, Shell, Size, - Transformation, Vector, Widget, + Vector, Widget, }; /// A collection of panes distributed using either vertical or horizontal splits @@ -965,21 +965,18 @@ pub fn draw( let translation = cursor_position - Point::new(bounds.x + origin.x, bounds.y + origin.y); - renderer.with_transformation( - Transformation::translate(translation.x, translation.y), - |renderer| { - renderer.with_layer(bounds, |renderer| { - draw_pane( - pane, - renderer, - default_style, - layout, - pane_cursor, - viewport, - ); - }); - }, - ); + renderer.with_translation(translation, |renderer| { + renderer.with_layer(bounds, |renderer| { + draw_pane( + pane, + renderer, + default_style, + layout, + pane_cursor, + viewport, + ); + }); + }); } } -- cgit