Handle tab drag end on pane items to insert after active item
Co-Authored-By: Kay Simmons <kay@zed.dev>
This commit is contained in:
parent
c295f943ba
commit
b9f9819637
5 changed files with 66 additions and 24 deletions
|
@ -172,26 +172,28 @@ impl<Tag> Element for MouseEventHandler<Tag> {
|
||||||
) -> Self::PaintState {
|
) -> Self::PaintState {
|
||||||
let visible_bounds = visible_bounds.intersection(bounds).unwrap_or_default();
|
let visible_bounds = visible_bounds.intersection(bounds).unwrap_or_default();
|
||||||
let hit_bounds = self.hit_bounds(visible_bounds);
|
let hit_bounds = self.hit_bounds(visible_bounds);
|
||||||
if let Some(style) = self.cursor_style {
|
|
||||||
cx.scene.push_cursor_region(CursorRegion {
|
|
||||||
bounds: hit_bounds,
|
|
||||||
style,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
cx.scene.push_mouse_region(
|
|
||||||
MouseRegion::from_handlers::<Tag>(
|
|
||||||
cx.current_view_id(),
|
|
||||||
self.region_id,
|
|
||||||
hit_bounds,
|
|
||||||
self.handlers.clone(),
|
|
||||||
)
|
|
||||||
.with_hoverable(self.hoverable)
|
|
||||||
.with_notify_on_hover(self.notify_on_hover)
|
|
||||||
.with_notify_on_click(self.notify_on_click),
|
|
||||||
);
|
|
||||||
|
|
||||||
self.child.paint(bounds.origin(), visible_bounds, cx);
|
self.child.paint(bounds.origin(), visible_bounds, cx);
|
||||||
|
|
||||||
|
cx.paint_stacking_context(None, |cx| {
|
||||||
|
if let Some(style) = self.cursor_style {
|
||||||
|
cx.scene.push_cursor_region(CursorRegion {
|
||||||
|
bounds: hit_bounds,
|
||||||
|
style,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
cx.scene.push_mouse_region(
|
||||||
|
MouseRegion::from_handlers::<Tag>(
|
||||||
|
cx.current_view_id(),
|
||||||
|
self.region_id,
|
||||||
|
hit_bounds,
|
||||||
|
self.handlers.clone(),
|
||||||
|
)
|
||||||
|
.with_hoverable(self.hoverable)
|
||||||
|
.with_notify_on_hover(self.notify_on_hover)
|
||||||
|
.with_notify_on_click(self.notify_on_click),
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rect_for_text_range(
|
fn rect_for_text_range(
|
||||||
|
|
|
@ -42,9 +42,9 @@ impl Element for Stack {
|
||||||
cx: &mut PaintContext,
|
cx: &mut PaintContext,
|
||||||
) -> Self::PaintState {
|
) -> Self::PaintState {
|
||||||
for child in &mut self.children {
|
for child in &mut self.children {
|
||||||
cx.scene.push_layer(None);
|
cx.paint_layer(None, |cx| {
|
||||||
child.paint(bounds.origin(), visible_bounds, cx);
|
child.paint(bounds.origin(), visible_bounds, cx);
|
||||||
cx.scene.pop_layer();
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -707,6 +707,16 @@ impl<'a> PaintContext<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn paint_stacking_context<F>(&mut self, clip_bounds: Option<RectF>, f: F)
|
||||||
|
where
|
||||||
|
F: FnOnce(&mut Self),
|
||||||
|
{
|
||||||
|
self.scene.push_stacking_context(clip_bounds);
|
||||||
|
f(self);
|
||||||
|
self.scene.pop_stacking_context();
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn paint_layer<F>(&mut self, clip_bounds: Option<RectF>, f: F)
|
pub fn paint_layer<F>(&mut self, clip_bounds: Option<RectF>, f: F)
|
||||||
where
|
where
|
||||||
|
|
|
@ -362,6 +362,7 @@ impl View for ToggleDockButton {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.with_cursor_style(CursorStyle::PointingHand);
|
.with_cursor_style(CursorStyle::PointingHand);
|
||||||
|
.on_
|
||||||
|
|
||||||
if dock_position.is_visible() {
|
if dock_position.is_visible() {
|
||||||
button
|
button
|
||||||
|
|
|
@ -1373,10 +1373,12 @@ impl View for Pane {
|
||||||
.with_child(
|
.with_child(
|
||||||
MouseEventHandler::<MouseNavigationHandler>::new(0, cx, |_, cx| {
|
MouseEventHandler::<MouseNavigationHandler>::new(0, cx, |_, cx| {
|
||||||
if let Some(active_item) = self.active_item() {
|
if let Some(active_item) = self.active_item() {
|
||||||
|
enum PaneContentTabDropTarget {}
|
||||||
|
|
||||||
Flex::column()
|
Flex::column()
|
||||||
.with_child({
|
.with_child({
|
||||||
let mut tab_row = Flex::row()
|
let mut tab_row = Flex::row()
|
||||||
.with_child(self.render_tabs(cx).flex(1.0, true).named("tabs"));
|
.with_child(self.render_tabs(cx).flex(1., true).named("tabs"));
|
||||||
|
|
||||||
// Render pane buttons
|
// Render pane buttons
|
||||||
let theme = cx.global::<Settings>().theme.clone();
|
let theme = cx.global::<Settings>().theme.clone();
|
||||||
|
@ -1440,8 +1442,35 @@ impl View for Pane {
|
||||||
.flex(1., false)
|
.flex(1., false)
|
||||||
.named("tab bar")
|
.named("tab bar")
|
||||||
})
|
})
|
||||||
.with_child(ChildView::new(&self.toolbar, cx).expanded().boxed())
|
.with_child({
|
||||||
.with_child(ChildView::new(active_item, cx).flex(1., true).boxed())
|
let drop_index = self.active_item_index + 1;
|
||||||
|
MouseEventHandler::<PaneContentTabDropTarget>::new(
|
||||||
|
0,
|
||||||
|
cx,
|
||||||
|
|_, cx| {
|
||||||
|
Flex::column()
|
||||||
|
.with_child(
|
||||||
|
ChildView::new(&self.toolbar, cx)
|
||||||
|
.expanded()
|
||||||
|
.boxed(),
|
||||||
|
)
|
||||||
|
.with_child(
|
||||||
|
ChildView::new(active_item, cx)
|
||||||
|
.flex(1., true)
|
||||||
|
.boxed(),
|
||||||
|
)
|
||||||
|
.boxed()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.on_up(MouseButton::Left, {
|
||||||
|
let pane = cx.handle();
|
||||||
|
move |_, cx: &mut EventContext| {
|
||||||
|
Pane::handle_dropped_item(&pane, drop_index, cx)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.flex(1., true)
|
||||||
|
.boxed()
|
||||||
|
})
|
||||||
.boxed()
|
.boxed()
|
||||||
} else {
|
} else {
|
||||||
enum EmptyPane {}
|
enum EmptyPane {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue