feat: add drag_destinations for container widgets

This commit is contained in:
Ashley Wulber 2024-04-01 16:12:45 -04:00 committed by Michael Murphy
parent b9cc88c492
commit 745cba1c2c
5 changed files with 72 additions and 1 deletions

View file

@ -4,7 +4,7 @@
use crate::{ext::CollectionWidget, widget, Element};
use apply::Apply;
use derive_setters::Setters;
use iced::{window, Length};
use iced::Length;
use iced_core::{widget::tree, Widget};
use std::borrow::Cow;
@ -232,6 +232,23 @@ impl<'a, Message: Clone + 'static> Widget<Message, crate::Theme, crate::Renderer
.as_widget_mut()
.overlay(child_tree, child_layout, renderer)
}
fn drag_destinations(
&self,
state: &tree::Tree,
layout: iced_core::Layout<'_>,
dnd_rectangles: &mut iced_style::core::clipboard::DndDestinationRectangles,
) {
if let Some((child_tree, child_layout)) =
state.children.iter().zip(layout.children()).next()
{
self.header_bar_inner.as_widget().drag_destinations(
child_tree,
child_layout,
dnd_rectangles,
);
}
}
}
impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {