fix issue where empty pane is created
This commit is contained in:
parent
cfde3e348c
commit
d7b8a189e4
3 changed files with 25 additions and 21 deletions
|
@ -391,7 +391,7 @@ impl Presenter {
|
||||||
//Ensure that hover entrance events aren't sent twice
|
//Ensure that hover entrance events aren't sent twice
|
||||||
if self.hovered_region_ids.insert(region.id()) {
|
if self.hovered_region_ids.insert(region.id()) {
|
||||||
valid_regions.push(region.clone());
|
valid_regions.push(region.clone());
|
||||||
if region.notify_on_hover {
|
if region.notify_on_hover || region.notify_on_move {
|
||||||
notified_views.insert(region.id().view_id());
|
notified_views.insert(region.id().view_id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -399,7 +399,7 @@ impl Presenter {
|
||||||
// Ensure that hover exit events aren't sent twice
|
// Ensure that hover exit events aren't sent twice
|
||||||
if self.hovered_region_ids.remove(®ion.id()) {
|
if self.hovered_region_ids.remove(®ion.id()) {
|
||||||
valid_regions.push(region.clone());
|
valid_regions.push(region.clone());
|
||||||
if region.notify_on_hover {
|
if region.notify_on_hover || region.notify_on_move {
|
||||||
notified_views.insert(region.id().view_id());
|
notified_views.insert(region.id().view_id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1373,6 +1373,7 @@ impl Pane {
|
||||||
.and_then(|margin| Self::drop_split_direction(event.position, event.region, margin))
|
.and_then(|margin| Self::drop_split_direction(event.position, event.region, margin))
|
||||||
{
|
{
|
||||||
cx.dispatch_action(SplitWithItem {
|
cx.dispatch_action(SplitWithItem {
|
||||||
|
from: dragged_item.pane.clone(),
|
||||||
item_id_to_move: dragged_item.item.id(),
|
item_id_to_move: dragged_item.item.id(),
|
||||||
pane_to_split: pane.clone(),
|
pane_to_split: pane.clone(),
|
||||||
split_direction,
|
split_direction,
|
||||||
|
@ -1476,9 +1477,13 @@ impl View for Pane {
|
||||||
cx,
|
cx,
|
||||||
|state, cx| {
|
|state, cx| {
|
||||||
let overlay_color = Self::tab_overlay_color(true, cx);
|
let overlay_color = Self::tab_overlay_color(true, cx);
|
||||||
|
// Hovered will cause a render when the mouse enters regardless
|
||||||
|
// of if mouse position was accessed before
|
||||||
|
let hovered = state.hovered();
|
||||||
let drag_position = cx
|
let drag_position = cx
|
||||||
.global::<DragAndDrop<Workspace>>()
|
.global::<DragAndDrop<Workspace>>()
|
||||||
.currently_dragged::<DraggedItem>(cx.window_id())
|
.currently_dragged::<DraggedItem>(cx.window_id())
|
||||||
|
.filter(|_| hovered)
|
||||||
.map(|_| state.mouse_position());
|
.map(|_| state.mouse_position());
|
||||||
|
|
||||||
Stack::new()
|
Stack::new()
|
||||||
|
@ -1498,25 +1503,27 @@ impl View for Pane {
|
||||||
)
|
)
|
||||||
.with_children(drag_position.map(|drag_position| {
|
.with_children(drag_position.map(|drag_position| {
|
||||||
Canvas::new(move |region, _, cx| {
|
Canvas::new(move |region, _, cx| {
|
||||||
let overlay_region =
|
if region.contains_point(drag_position) {
|
||||||
if let Some(split_direction) =
|
let overlay_region = if let Some(
|
||||||
|
split_direction,
|
||||||
|
) =
|
||||||
Self::drop_split_direction(
|
Self::drop_split_direction(
|
||||||
drag_position,
|
drag_position,
|
||||||
region,
|
region,
|
||||||
100., /* Replace with theme value */
|
100., /* Replace with theme value */
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
split_direction.along_edge(region, 100.)
|
split_direction.along_edge(region, 100.)
|
||||||
} else {
|
} else {
|
||||||
region
|
region
|
||||||
};
|
};
|
||||||
|
|
||||||
cx.scene.push_quad(Quad {
|
cx.scene.push_quad(Quad {
|
||||||
bounds: overlay_region,
|
bounds: overlay_region,
|
||||||
background: overlay_color,
|
background: overlay_color,
|
||||||
border: Default::default(),
|
border: Default::default(),
|
||||||
corner_radius: 0.,
|
corner_radius: 0.,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.boxed()
|
.boxed()
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -127,6 +127,7 @@ pub struct OpenSharedScreen {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SplitWithItem {
|
pub struct SplitWithItem {
|
||||||
|
from: WeakViewHandle<Pane>,
|
||||||
pane_to_split: WeakViewHandle<Pane>,
|
pane_to_split: WeakViewHandle<Pane>,
|
||||||
split_direction: SplitDirection,
|
split_direction: SplitDirection,
|
||||||
item_id_to_move: usize,
|
item_id_to_move: usize,
|
||||||
|
@ -216,12 +217,14 @@ pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
|
||||||
cx.add_action(
|
cx.add_action(
|
||||||
|workspace: &mut Workspace,
|
|workspace: &mut Workspace,
|
||||||
SplitWithItem {
|
SplitWithItem {
|
||||||
|
from,
|
||||||
pane_to_split,
|
pane_to_split,
|
||||||
item_id_to_move,
|
item_id_to_move,
|
||||||
split_direction,
|
split_direction,
|
||||||
}: &_,
|
}: &_,
|
||||||
cx| {
|
cx| {
|
||||||
workspace.split_pane_with_item(
|
workspace.split_pane_with_item(
|
||||||
|
from.clone(),
|
||||||
pane_to_split.clone(),
|
pane_to_split.clone(),
|
||||||
*item_id_to_move,
|
*item_id_to_move,
|
||||||
*split_direction,
|
*split_direction,
|
||||||
|
@ -1975,26 +1978,20 @@ impl Workspace {
|
||||||
|
|
||||||
pub fn split_pane_with_item(
|
pub fn split_pane_with_item(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
from: WeakViewHandle<Pane>,
|
||||||
pane_to_split: WeakViewHandle<Pane>,
|
pane_to_split: WeakViewHandle<Pane>,
|
||||||
item_id_to_move: usize,
|
item_id_to_move: usize,
|
||||||
split_direction: SplitDirection,
|
split_direction: SplitDirection,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
if let Some(pane_to_split) = pane_to_split.upgrade(cx) {
|
if let Some((pane_to_split, from)) = pane_to_split.upgrade(cx).zip(from.upgrade(cx)) {
|
||||||
if &pane_to_split == self.dock_pane() {
|
if &pane_to_split == self.dock_pane() {
|
||||||
warn!("Can't split dock pane.");
|
warn!("Can't split dock pane.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let new_pane = self.add_pane(cx);
|
let new_pane = self.add_pane(cx);
|
||||||
Pane::move_item(
|
Pane::move_item(self, from.clone(), new_pane.clone(), item_id_to_move, 0, cx);
|
||||||
self,
|
|
||||||
pane_to_split.clone(),
|
|
||||||
new_pane.clone(),
|
|
||||||
item_id_to_move,
|
|
||||||
0,
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
self.center
|
self.center
|
||||||
.split(&pane_to_split, &new_pane, split_direction)
|
.split(&pane_to_split, &new_pane, split_direction)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue