From ecce8bbcee45dddedef8a33bf3dc086d76c27b39 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:51 +0200 Subject: [PATCH] Simplify `Target` enum in `widget::pane_grid` --- examples/pane_grid/src/main.rs | 9 ++++----- widget/src/pane_grid.rs | 18 +++++------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs index c5652e2d32..1361eeb960 100644 --- a/examples/pane_grid/src/main.rs +++ b/examples/pane_grid/src/main.rs @@ -109,13 +109,12 @@ impl Application for Example { pane, target, }) => match target { - pane_grid::Target::PaneGrid(edge) => { + pane_grid::Target::Edge(edge) => { self.panes.move_to_edge(&pane, edge) } - pane_grid::Target::Pane { - pane: target, - region, - } => self.panes.split_with(&target, &pane, region), + pane_grid::Target::Pane(target, region) => { + self.panes.split_with(&target, &pane, region) + } }, Message::Dragged(_) => {} Message::TogglePin(pane) => { diff --git a/widget/src/pane_grid.rs b/widget/src/pane_grid.rs index 213460a543..23ab4181e3 100644 --- a/widget/src/pane_grid.rs +++ b/widget/src/pane_grid.rs @@ -587,7 +587,7 @@ pub fn update<'a, Message, T: Draggable>( { DragEvent::Dropped { pane, - target: Target::PaneGrid(edge), + target: Target::Edge(edge), } } else { let dropped_region = contents @@ -604,10 +604,7 @@ pub fn update<'a, Message, T: Draggable>( { DragEvent::Dropped { pane, - target: Target::Pane { - pane: target, - region, - }, + target: Target::Pane(target, region), } } _ => DragEvent::Canceled { pane }, @@ -1094,15 +1091,10 @@ pub enum DragEvent { /// The [`Target`] area a pane can be dropped on. #[derive(Debug, Clone, Copy)] pub enum Target { - /// The [`Edge`} of the full [`PaneGrid`]. - PaneGrid(Edge), + /// An [`Edge`] of the full [`PaneGrid`]. + Edge(Edge), /// A single [`Pane`] of the [`PaneGrid`]. - Pane { - /// The targetted [`Pane`]. - pane: Pane, - /// The targetted area of the [`Pane`]. - region: Region, - }, + Pane(Pane, Region), } /// The region of a [`Pane`].