Add pane splitting by dragged item. Works, but the overlay doesn't clear quite right
This commit is contained in:
@@ -21,6 +21,7 @@ pub struct MouseEventHandler<Tag: 'static> {
|
||||
cursor_style: Option<CursorStyle>,
|
||||
handlers: HandlerSet,
|
||||
hoverable: bool,
|
||||
notify_on_move: bool,
|
||||
notify_on_hover: bool,
|
||||
notify_on_click: bool,
|
||||
above: bool,
|
||||
@@ -28,9 +29,8 @@ pub struct MouseEventHandler<Tag: 'static> {
|
||||
_tag: PhantomData<Tag>,
|
||||
}
|
||||
|
||||
// MouseEventHandler::new
|
||||
// MouseEventHandler::above
|
||||
|
||||
/// Element which provides a render_child callback with a MouseState and paints a mouse
|
||||
/// region under (or above) it for easy mouse event handling.
|
||||
impl<Tag> MouseEventHandler<Tag> {
|
||||
pub fn new<V, F>(region_id: usize, cx: &mut RenderContext<V>, render_child: F) -> Self
|
||||
where
|
||||
@@ -39,6 +39,7 @@ impl<Tag> MouseEventHandler<Tag> {
|
||||
{
|
||||
let mut mouse_state = cx.mouse_state::<Tag>(region_id);
|
||||
let child = render_child(&mut mouse_state, cx);
|
||||
let notify_on_move = mouse_state.accessed_mouse_position();
|
||||
let notify_on_hover = mouse_state.accessed_hovered();
|
||||
let notify_on_click = mouse_state.accessed_clicked();
|
||||
Self {
|
||||
@@ -46,6 +47,7 @@ impl<Tag> MouseEventHandler<Tag> {
|
||||
region_id,
|
||||
cursor_style: None,
|
||||
handlers: Default::default(),
|
||||
notify_on_move,
|
||||
notify_on_hover,
|
||||
notify_on_click,
|
||||
hoverable: true,
|
||||
@@ -55,6 +57,9 @@ impl<Tag> MouseEventHandler<Tag> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Modifies the MouseEventHandler to render the MouseRegion above the child element. Useful
|
||||
/// for drag and drop handling and similar events which should be captured before the child
|
||||
/// gets the opportunity
|
||||
pub fn above<V, F>(region_id: usize, cx: &mut RenderContext<V>, render_child: F) -> Self
|
||||
where
|
||||
V: View,
|
||||
@@ -183,6 +188,7 @@ impl<Tag> MouseEventHandler<Tag> {
|
||||
self.handlers.clone(),
|
||||
)
|
||||
.with_hoverable(self.hoverable)
|
||||
.with_notify_on_move(self.notify_on_move)
|
||||
.with_notify_on_hover(self.notify_on_hover)
|
||||
.with_notify_on_click(self.notify_on_click),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user