More drag'n'drop fixes
Co-Authored-By: Max <max@zed.dev>
This commit is contained in:
parent
e377bd805b
commit
7e5aa5ce77
2 changed files with 23 additions and 17 deletions
|
@ -179,8 +179,8 @@ use project::Fs;
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use settings::{Settings, SettingsStore};
|
use settings::{Settings, SettingsStore};
|
||||||
use ui::{
|
use ui::{
|
||||||
h_stack, v_stack, Avatar, Button, Color, ContextMenu, Icon, IconButton, IconElement, Label,
|
h_stack, v_stack, Avatar, Button, Color, ContextMenu, Icon, IconButton, IconElement, IconSize,
|
||||||
List, ListHeader, ListItem, Toggle, Tooltip,
|
Label, List, ListHeader, ListItem, Toggle, Tooltip,
|
||||||
};
|
};
|
||||||
use util::{maybe, ResultExt, TryFutureExt};
|
use util::{maybe, ResultExt, TryFutureExt};
|
||||||
use workspace::{
|
use workspace::{
|
||||||
|
@ -2802,6 +2802,9 @@ impl CollabPanel {
|
||||||
cx.build_view({ |cx| DraggedChannelView { channel, width } })
|
cx.build_view({ |cx| DraggedChannelView { channel, width } })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.drag_over::<DraggedChannelView>(|style| {
|
||||||
|
style.bg(cx.theme().colors().ghost_element_hover)
|
||||||
|
})
|
||||||
.on_drop(
|
.on_drop(
|
||||||
cx.listener(move |this, view: &View<DraggedChannelView>, cx| {
|
cx.listener(move |this, view: &View<DraggedChannelView>, cx| {
|
||||||
this.channel_store
|
this.channel_store
|
||||||
|
@ -3588,13 +3591,17 @@ impl Render for DraggedChannelView {
|
||||||
.w(self.width)
|
.w(self.width)
|
||||||
.p_1()
|
.p_1()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(IconElement::new(
|
.child(
|
||||||
if self.channel.visibility == proto::ChannelVisibility::Public {
|
IconElement::new(
|
||||||
Icon::Public
|
if self.channel.visibility == proto::ChannelVisibility::Public {
|
||||||
} else {
|
Icon::Public
|
||||||
Icon::Hash
|
} else {
|
||||||
},
|
Icon::Hash
|
||||||
))
|
},
|
||||||
|
)
|
||||||
|
.size(IconSize::Small)
|
||||||
|
.color(Color::Muted),
|
||||||
|
)
|
||||||
.child(Label::new(self.channel.name.clone()))
|
.child(Label::new(self.channel.name.clone()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -824,7 +824,6 @@ impl Interactivity {
|
||||||
.and_then(|group_hover| GroupBounds::get(&group_hover.group, cx));
|
.and_then(|group_hover| GroupBounds::get(&group_hover.group, cx));
|
||||||
|
|
||||||
if let Some(group_bounds) = hover_group_bounds {
|
if let Some(group_bounds) = hover_group_bounds {
|
||||||
// todo!() needs cx.was_top_layer
|
|
||||||
let hovered = group_bounds.contains_point(&cx.mouse_position());
|
let hovered = group_bounds.contains_point(&cx.mouse_position());
|
||||||
cx.on_mouse_event(move |event: &MouseMoveEvent, phase, cx| {
|
cx.on_mouse_event(move |event: &MouseMoveEvent, phase, cx| {
|
||||||
if phase == DispatchPhase::Capture {
|
if phase == DispatchPhase::Capture {
|
||||||
|
@ -836,13 +835,13 @@ impl Interactivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.hover_style.is_some()
|
if self.hover_style.is_some()
|
||||||
|| (cx.active_drag.is_some() && !self.drag_over_styles.is_empty())
|
|| cx.active_drag.is_some() && !self.drag_over_styles.is_empty()
|
||||||
{
|
{
|
||||||
let interactive_bounds = interactive_bounds.clone();
|
let bounds = bounds.intersect(&cx.content_mask().bounds);
|
||||||
let hovered = interactive_bounds.visibly_contains(&cx.mouse_position(), cx);
|
let hovered = bounds.contains_point(&cx.mouse_position());
|
||||||
cx.on_mouse_event(move |event: &MouseMoveEvent, phase, cx| {
|
cx.on_mouse_event(move |event: &MouseMoveEvent, phase, cx| {
|
||||||
if phase == DispatchPhase::Capture {
|
if phase == DispatchPhase::Capture {
|
||||||
if interactive_bounds.visibly_contains(&event.position, cx) != hovered {
|
if bounds.contains_point(&event.position) != hovered {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1143,7 +1142,9 @@ impl Interactivity {
|
||||||
let mouse_position = cx.mouse_position();
|
let mouse_position = cx.mouse_position();
|
||||||
if let Some(group_hover) = self.group_hover_style.as_ref() {
|
if let Some(group_hover) = self.group_hover_style.as_ref() {
|
||||||
if let Some(group_bounds) = GroupBounds::get(&group_hover.group, cx) {
|
if let Some(group_bounds) = GroupBounds::get(&group_hover.group, cx) {
|
||||||
if group_bounds.contains_point(&mouse_position) {
|
if group_bounds.contains_point(&mouse_position)
|
||||||
|
&& cx.was_top_layer(&mouse_position, cx.stacking_order())
|
||||||
|
{
|
||||||
style.refine(&group_hover.style);
|
style.refine(&group_hover.style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1162,7 +1163,6 @@ impl Interactivity {
|
||||||
for (state_type, group_drag_style) in &self.group_drag_over_styles {
|
for (state_type, group_drag_style) in &self.group_drag_over_styles {
|
||||||
if let Some(group_bounds) = GroupBounds::get(&group_drag_style.group, cx) {
|
if let Some(group_bounds) = GroupBounds::get(&group_drag_style.group, cx) {
|
||||||
if *state_type == drag.view.entity_type()
|
if *state_type == drag.view.entity_type()
|
||||||
// todo!() needs to handle cx.content_mask() and cx.is_top()
|
|
||||||
&& group_bounds.contains_point(&mouse_position)
|
&& group_bounds.contains_point(&mouse_position)
|
||||||
{
|
{
|
||||||
style.refine(&group_drag_style.style);
|
style.refine(&group_drag_style.style);
|
||||||
|
@ -1175,7 +1175,6 @@ impl Interactivity {
|
||||||
&& bounds
|
&& bounds
|
||||||
.intersect(&cx.content_mask().bounds)
|
.intersect(&cx.content_mask().bounds)
|
||||||
.contains_point(&mouse_position)
|
.contains_point(&mouse_position)
|
||||||
&& cx.was_top_layer(&mouse_position, cx.stacking_order())
|
|
||||||
{
|
{
|
||||||
style.refine(drag_over_style);
|
style.refine(drag_over_style);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue