fix: dnd
This commit is contained in:
parent
94ee2c7a63
commit
fa31f42cd8
4 changed files with 48 additions and 2 deletions
2
iced
2
iced
|
|
@ -1 +1 @@
|
||||||
Subproject commit 745d8467647209a9929fe631b2ba784d9cd39832
|
Subproject commit 52187b687876d17fe95441cc27ff42af0a7e70b4
|
||||||
|
|
@ -12,7 +12,7 @@ use iced_core::alignment;
|
||||||
use iced_core::event::{self, Event};
|
use iced_core::event::{self, Event};
|
||||||
use iced_core::widget::{Operation, Tree};
|
use iced_core::widget::{Operation, Tree};
|
||||||
use iced_core::{
|
use iced_core::{
|
||||||
layout, mouse, overlay as iced_overlay, renderer, Clipboard, Color, Layout, Length, Padding,
|
layout, mouse, overlay as iced_overlay, renderer, Clipboard, Layout, Length, Padding,
|
||||||
Rectangle, Shell, Widget,
|
Rectangle, Shell, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -20,6 +20,7 @@ use iced_renderer::core::widget::OperationOutputWrapper;
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub struct ContextDrawer<'a, Message> {
|
pub struct ContextDrawer<'a, Message> {
|
||||||
|
id: Option<iced_core::widget::Id>,
|
||||||
content: Element<'a, Message>,
|
content: Element<'a, Message>,
|
||||||
drawer: Element<'a, Message>,
|
drawer: Element<'a, Message>,
|
||||||
on_close: Option<Message>,
|
on_close: Option<Message>,
|
||||||
|
|
@ -80,6 +81,7 @@ impl<'a, Message: Clone + 'static> ContextDrawer<'a, Message> {
|
||||||
);
|
);
|
||||||
|
|
||||||
ContextDrawer {
|
ContextDrawer {
|
||||||
|
id: None,
|
||||||
content: content.into(),
|
content: content.into(),
|
||||||
// XXX new limits do not exactly handle the max width well for containers
|
// XXX new limits do not exactly handle the max width well for containers
|
||||||
// XXX this is a hack to get around that
|
// XXX this is a hack to get around that
|
||||||
|
|
@ -99,6 +101,12 @@ impl<'a, Message: Clone + 'static> ContextDrawer<'a, Message> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the [`Id`] of the [`ContextDrawer`].
|
||||||
|
pub fn id(mut self, id: iced_core::widget::Id) -> Self {
|
||||||
|
self.id = Some(id);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
// Optionally assigns message to `on_close` event.
|
// Optionally assigns message to `on_close` event.
|
||||||
pub fn on_close_maybe(mut self, message: Option<Message>) -> Self {
|
pub fn on_close_maybe(mut self, message: Option<Message>) -> Self {
|
||||||
self.on_close = message;
|
self.on_close = message;
|
||||||
|
|
@ -233,6 +241,25 @@ impl<'a, Message: Clone> Widget<Message, crate::Theme, Renderer> for ContextDraw
|
||||||
let c_state = &state.children[0];
|
let c_state = &state.children[0];
|
||||||
self.content.as_widget().a11y_nodes(c_layout, c_state, p)
|
self.content.as_widget().a11y_nodes(c_layout, c_state, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn drag_destinations(
|
||||||
|
&self,
|
||||||
|
state: &Tree,
|
||||||
|
layout: Layout<'_>,
|
||||||
|
dnd_rectangles: &mut iced_core::clipboard::DndDestinationRectangles,
|
||||||
|
) {
|
||||||
|
self.content
|
||||||
|
.as_widget()
|
||||||
|
.drag_destinations(&state.children[0], layout, dnd_rectangles);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn id(&self) -> Option<iced_core::widget::Id> {
|
||||||
|
self.id.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_id(&mut self, id: iced_core::widget::Id) {
|
||||||
|
self.id = Some(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Message: 'a + Clone> From<ContextDrawer<'a, Message>> for Element<'a, Message> {
|
impl<'a, Message: 'a + Clone> From<ContextDrawer<'a, Message>> for Element<'a, Message> {
|
||||||
|
|
|
||||||
|
|
@ -261,6 +261,14 @@ where
|
||||||
self.container
|
self.container
|
||||||
.drag_destinations(state, layout, dnd_rectangles);
|
.drag_destinations(state, layout, dnd_rectangles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn id(&self) -> Option<crate::widget::Id> {
|
||||||
|
Widget::id(&self.container)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_id(&mut self, id: crate::widget::Id) {
|
||||||
|
self.container.set_id(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Message, Theme, Renderer> From<LayerContainer<'a, Message, Theme, Renderer>>
|
impl<'a, Message, Theme, Renderer> From<LayerContainer<'a, Message, Theme, Renderer>>
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,17 @@ where
|
||||||
.overlay(&mut tree.children[0], layout, renderer)
|
.overlay(&mut tree.children[0], layout, renderer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn drag_destinations(
|
||||||
|
&self,
|
||||||
|
tree: &Tree,
|
||||||
|
layout: Layout<'_>,
|
||||||
|
dnd_rectangles: &mut iced_core::clipboard::DndDestinationRectangles,
|
||||||
|
) {
|
||||||
|
self.content
|
||||||
|
.as_widget()
|
||||||
|
.drag_destinations(&tree.children[0], layout, dnd_rectangles);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Message, Renderer> From<Popover<'a, Message, Renderer>>
|
impl<'a, Message, Renderer> From<Popover<'a, Message, Renderer>>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue