Skip to content

Commit

Permalink
Simplify Target enum in widget::pane_grid
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Jul 6, 2023
1 parent f83ee1e commit ecce8bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
9 changes: 4 additions & 5 deletions examples/pane_grid/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
18 changes: 5 additions & 13 deletions widget/src/pane_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 },
Expand Down Expand Up @@ -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`].
Expand Down

0 comments on commit ecce8bb

Please sign in to comment.