iced: propagate pane drag destinations
This commit is contained in:
parent
1fb7e08f23
commit
a489a6b790
9 changed files with 142 additions and 15 deletions
|
|
@ -90,6 +90,7 @@ use crate::core::{
|
|||
self, Background, Border, Clipboard, Color, Element, Event, Layout, Length,
|
||||
Pixels, Point, Rectangle, Shell, Size, Theme, Vector, Widget,
|
||||
};
|
||||
use log::trace;
|
||||
|
||||
const DRAG_DEADBAND_DISTANCE: f32 = 10.0;
|
||||
const THICKNESS_RATIO: f32 = 25.0;
|
||||
|
|
@ -1030,6 +1031,35 @@ where
|
|||
|
||||
(!children.is_empty()).then(|| Group::with_children(children).overlay())
|
||||
}
|
||||
|
||||
fn drag_destinations(
|
||||
&self,
|
||||
state: &Tree,
|
||||
layout: Layout<'_>,
|
||||
renderer: &Renderer,
|
||||
dnd_rectangles: &mut crate::core::clipboard::DndDestinationRectangles,
|
||||
) {
|
||||
self.contents
|
||||
.iter()
|
||||
.zip(state.children.iter())
|
||||
.zip(layout.children())
|
||||
.for_each(|((content, tree), child_layout)| {
|
||||
trace!(
|
||||
target: "iced::widget::pane_grid",
|
||||
"pane drag layout bounds=({:.2},{:.2},{:.2},{:.2})",
|
||||
child_layout.bounds().x,
|
||||
child_layout.bounds().y,
|
||||
child_layout.bounds().width,
|
||||
child_layout.bounds().height
|
||||
);
|
||||
content.drag_destinations(
|
||||
tree,
|
||||
child_layout.with_virtual_offset(layout.virtual_offset()),
|
||||
renderer,
|
||||
dnd_rectangles,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Message, Theme, Renderer> From<PaneGrid<'a, Message, Theme, Renderer>>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::core::renderer;
|
|||
use crate::core::widget::{self, Tree};
|
||||
use crate::core::{
|
||||
self, Clipboard, Element, Event, Layout, Point, Rectangle, Shell, Size,
|
||||
Vector,
|
||||
Vector, event,
|
||||
};
|
||||
use crate::pane_grid::{Draggable, TitleBar};
|
||||
|
||||
|
|
@ -308,6 +308,51 @@ where
|
|||
None
|
||||
}
|
||||
|
||||
pub(crate) fn drag_destinations(
|
||||
&self,
|
||||
tree: &Tree,
|
||||
layout: Layout<'_>,
|
||||
renderer: &Renderer,
|
||||
dnd_rectangles: &mut core::clipboard::DndDestinationRectangles,
|
||||
) {
|
||||
let mut body_layout = layout;
|
||||
if self.title_bar.is_some() {
|
||||
let mut children = layout.children();
|
||||
let title_bar_layout = children.next();
|
||||
body_layout = children.next().unwrap_or(layout);
|
||||
if let Some(title_bar_layout) = title_bar_layout {
|
||||
log::trace!(
|
||||
target: "iced::widget::pane_grid::content",
|
||||
"title_bar bounds=({:.2},{:.2},{:.2},{:.2}) body_bounds=({:.2},{:.2},{:.2},{:.2})",
|
||||
title_bar_layout.bounds().x,
|
||||
title_bar_layout.bounds().y,
|
||||
title_bar_layout.bounds().width,
|
||||
title_bar_layout.bounds().height,
|
||||
body_layout.bounds().x,
|
||||
body_layout.bounds().y,
|
||||
body_layout.bounds().width,
|
||||
body_layout.bounds().height,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
log::trace!(
|
||||
target: "iced::widget::pane_grid::content",
|
||||
"body_bounds=({:.2},{:.2},{:.2},{:.2})",
|
||||
body_layout.bounds().x,
|
||||
body_layout.bounds().y,
|
||||
body_layout.bounds().width,
|
||||
body_layout.bounds().height,
|
||||
);
|
||||
}
|
||||
|
||||
self.body.as_widget().drag_destinations(
|
||||
&tree.children[0],
|
||||
body_layout,
|
||||
renderer,
|
||||
dnd_rectangles,
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn mouse_interaction(
|
||||
&self,
|
||||
tree: &Tree,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue