Skip to content

Commit

Permalink
Add drag destinations for pane grid
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonrhansen authored and jackpot51 committed Aug 19, 2024
1 parent 018051e commit 44407b8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
22 changes: 22 additions & 0 deletions widget/src/pane_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,28 @@ where

(!children.is_empty()).then(|| Group::with_children(children).overlay())
}

fn drag_destinations(
&self,
state: &Tree,
layout: Layout<'_>,
renderer: &Renderer,
dnd_rectangles: &mut iced_style::core::clipboard::DndDestinationRectangles,
) {
for (((_pane, content), child_layout), child_tree) in self
.contents
.iter()
.zip(layout.children())
.zip(state.children.iter())
{
content.drag_destinations(
child_tree,
child_layout,
renderer,
dnd_rectangles,
);
}
}
}

impl<'a, Message, Theme, Renderer> From<PaneGrid<'a, Message, Theme, Renderer>>
Expand Down
19 changes: 19 additions & 0 deletions widget/src/pane_grid/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,25 @@ where
)
}
}

pub(crate) fn drag_destinations(
&self,
state: &Tree,
layout: Layout<'_>,
renderer: &Renderer,
dnd_rectangles: &mut iced_style::core::clipboard::DndDestinationRectangles,
) {
if let Some((child_tree, child_layout)) =
state.children.iter().zip(layout.children()).next()
{
self.body.as_widget().drag_destinations(
child_tree,
child_layout,
renderer,
dnd_rectangles,
);
}
}
}

impl<'a, Message, Theme, Renderer> Draggable
Expand Down

0 comments on commit 44407b8

Please sign in to comment.