From f83ee1e9f99d1ec5621b4dba35ce0d0fced95442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 6 Jul 2023 07:37:25 +0200 Subject: [PATCH] Call `in_edge` only when `picked_pane.is_some()` --- widget/src/pane_grid.rs | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/widget/src/pane_grid.rs b/widget/src/pane_grid.rs index 0a8500dc5e..213460a543 100644 --- a/widget/src/pane_grid.rs +++ b/widget/src/pane_grid.rs @@ -843,9 +843,13 @@ pub fn draw( let mut render_picked_pane = None; - let cursor_in_edge = cursor - .position() - .and_then(|cursor_position| in_edge(layout, cursor_position)); + let pane_in_edge = if picked_pane.is_some() { + cursor + .position() + .and_then(|cursor_position| in_edge(layout, cursor_position)) + } else { + None + }; for ((id, pane), pane_layout) in contents.zip(layout.children()) { match picked_pane { @@ -862,7 +866,7 @@ pub fn draw( viewport, ); - if picked_pane.is_some() && cursor_in_edge.is_none() { + if picked_pane.is_some() && pane_in_edge.is_none() { if let Some(region) = cursor.position().and_then(|cursor_position| { layout_region(pane_layout, cursor_position) @@ -897,21 +901,19 @@ pub fn draw( } } - if picked_pane.is_some() { - if let Some(edge) = cursor_in_edge { - let hovered_region_style = theme.hovered_region(style); - let bounds = edge_bounds(layout, edge); - - renderer.fill_quad( - renderer::Quad { - bounds, - border_radius: hovered_region_style.border_radius.into(), - border_width: hovered_region_style.border_width, - border_color: hovered_region_style.border_color, - }, - theme.hovered_region(style).background, - ); - } + if let Some(edge) = pane_in_edge { + let hovered_region_style = theme.hovered_region(style); + let bounds = edge_bounds(layout, edge); + + renderer.fill_quad( + renderer::Quad { + bounds, + border_radius: hovered_region_style.border_radius.into(), + border_width: hovered_region_style.border_width, + border_color: hovered_region_style.border_color, + }, + theme.hovered_region(style).background, + ); } // Render picked pane last