WIP
This commit is contained in:
parent
e6cc132b19
commit
d9e4136b02
14 changed files with 235 additions and 150 deletions
|
@ -5,7 +5,8 @@ use gpui::{
|
|||
geometry::{rect::RectF, vector::Vector2F},
|
||||
platform::MouseButton,
|
||||
scene::MouseUp,
|
||||
AppContext, Element, ElementBox, MouseState, Quad, ViewContext, WeakViewHandle,
|
||||
AppContext, Element, ElementBox, EventContext, MouseState, Quad, View, ViewContext,
|
||||
WeakViewHandle,
|
||||
};
|
||||
use project::ProjectEntryId;
|
||||
use settings::Settings;
|
||||
|
@ -29,7 +30,7 @@ where
|
|||
Tag: 'static,
|
||||
F: FnOnce(&mut MouseState, &mut ViewContext<Pane>) -> ElementBox<Pane>,
|
||||
{
|
||||
MouseEventHandler::<Tag>::above(region_id, cx, |state, _, cx| {
|
||||
MouseEventHandler::<Tag, _>::above(region_id, cx, |state, cx| {
|
||||
// Observing hovered will cause a render when the mouse enters regardless
|
||||
// of if mouse position was accessed before
|
||||
let drag_position = if state.hovered() {
|
||||
|
@ -48,7 +49,7 @@ where
|
|||
Stack::new()
|
||||
.with_child(render_child(state, cx))
|
||||
.with_children(drag_position.map(|drag_position| {
|
||||
Canvas::new(move |scene, bounds, _, cx| {
|
||||
Canvas::new(move |scene, bounds, _, _, cx| {
|
||||
if bounds.contains_point(drag_position) {
|
||||
let overlay_region = split_margin
|
||||
.and_then(|split_margin| {
|
||||
|
@ -58,7 +59,7 @@ where
|
|||
.map(|(dir, margin)| dir.along_edge(bounds, margin))
|
||||
.unwrap_or(bounds);
|
||||
|
||||
scene.paint_stacking_context(None, None, |cx| {
|
||||
scene.paint_stacking_context(None, None, |scene| {
|
||||
scene.push_quad(Quad {
|
||||
bounds: overlay_region,
|
||||
background: Some(overlay_color(cx)),
|
||||
|
@ -73,13 +74,13 @@ where
|
|||
.boxed()
|
||||
})
|
||||
.on_up(MouseButton::Left, {
|
||||
let pane = cx.handle();
|
||||
move |event, cx| {
|
||||
let pane = cx.handle().downgrade();
|
||||
move |event, _, cx| {
|
||||
handle_dropped_item(event, &pane, drop_index, allow_same_pane, split_margin, cx);
|
||||
cx.notify();
|
||||
}
|
||||
})
|
||||
.on_move(|_, cx| {
|
||||
.on_move(|_, _, cx| {
|
||||
let drag_and_drop = cx.global::<DragAndDrop<Workspace>>();
|
||||
|
||||
if drag_and_drop
|
||||
|
@ -96,13 +97,13 @@ where
|
|||
})
|
||||
}
|
||||
|
||||
pub fn handle_dropped_item(
|
||||
pub fn handle_dropped_item<V: View>(
|
||||
event: MouseUp,
|
||||
pane: &WeakViewHandle<Pane>,
|
||||
index: usize,
|
||||
allow_same_pane: bool,
|
||||
split_margin: Option<f32>,
|
||||
cx: &mut ViewContext<Pane>,
|
||||
cx: &mut EventContext<V>,
|
||||
) {
|
||||
enum Action {
|
||||
Move(WeakViewHandle<Pane>, usize),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue