Jason Lee 2024-11-18 11:35:49 +08:00 committed by GitHub
parent a4abc164bb
commit fa6abe5a9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 45 additions and 39 deletions

25
Cargo.lock generated
View file

@ -474,7 +474,7 @@ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"cexpr", "cexpr",
"clang-sys", "clang-sys",
"itertools 0.13.0", "itertools 0.11.0",
"log", "log",
"prettyplease", "prettyplease",
"proc-macro2", "proc-macro2",
@ -950,7 +950,7 @@ dependencies = [
[[package]] [[package]]
name = "collections" name = "collections"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#543fe4c094abdc5ebc54e8a5f5e9559ee1b30f55" source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
dependencies = [ dependencies = [
"rustc-hash", "rustc-hash",
] ]
@ -1313,7 +1313,7 @@ dependencies = [
[[package]] [[package]]
name = "derive_refineable" name = "derive_refineable"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#543fe4c094abdc5ebc54e8a5f5e9559ee1b30f55" source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2266,7 +2266,7 @@ dependencies = [
[[package]] [[package]]
name = "gpui" name = "gpui"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#543fe4c094abdc5ebc54e8a5f5e9559ee1b30f55" source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"as-raw-xcb-connection", "as-raw-xcb-connection",
@ -2365,7 +2365,7 @@ dependencies = [
[[package]] [[package]]
name = "gpui_macros" name = "gpui_macros"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#543fe4c094abdc5ebc54e8a5f5e9559ee1b30f55" source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2555,7 +2555,7 @@ dependencies = [
[[package]] [[package]]
name = "http_client" name = "http_client"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#543fe4c094abdc5ebc54e8a5f5e9559ee1b30f55" source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -3071,11 +3071,12 @@ dependencies = [
[[package]] [[package]]
name = "media" name = "media"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#543fe4c094abdc5ebc54e8a5f5e9559ee1b30f55" source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bindgen", "bindgen",
"core-foundation 0.9.4", "core-foundation 0.9.4",
"ctor",
"foreign-types", "foreign-types",
"metal", "metal",
"objc", "objc",
@ -3379,7 +3380,7 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
dependencies = [ dependencies = [
"proc-macro-crate 3.2.0", "proc-macro-crate 1.3.1",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.86", "syn 2.0.86",
@ -4350,7 +4351,7 @@ dependencies = [
[[package]] [[package]]
name = "refineable" name = "refineable"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#543fe4c094abdc5ebc54e8a5f5e9559ee1b30f55" source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
dependencies = [ dependencies = [
"derive_refineable", "derive_refineable",
] ]
@ -4671,7 +4672,7 @@ checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a"
[[package]] [[package]]
name = "semantic_version" name = "semantic_version"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#543fe4c094abdc5ebc54e8a5f5e9559ee1b30f55" source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"serde", "serde",
@ -5089,7 +5090,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]] [[package]]
name = "sum_tree" name = "sum_tree"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#543fe4c094abdc5ebc54e8a5f5e9559ee1b30f55" source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"log", "log",
@ -5748,7 +5749,7 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[package]] [[package]]
name = "util" name = "util"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#543fe4c094abdc5ebc54e8a5f5e9559ee1b30f55" source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-fs 1.6.0", "async-fs 1.6.0",

View file

@ -245,7 +245,7 @@ impl Dock {
.when(axis.is_horizontal(), |this| this.h_full().w(HANDLE_SIZE)) .when(axis.is_horizontal(), |this| this.h_full().w(HANDLE_SIZE))
.when(axis.is_vertical(), |this| this.w_full().h(HANDLE_SIZE)), .when(axis.is_vertical(), |this| this.w_full().h(HANDLE_SIZE)),
) )
.on_drag(ResizePanel {}, move |info, cx| { .on_drag(ResizePanel {}, move |info, _, cx| {
cx.stop_propagation(); cx.stop_propagation();
view.update(cx, |view, _| { view.update(cx, |view, _| {
view.is_resizing = true; view.is_resizing = true;

View file

@ -405,7 +405,7 @@ impl TabPanel {
panel: panel.clone(), panel: panel.clone(),
tab_panel: view, tab_panel: view,
}, },
|drag, cx| { |drag, _, cx| {
cx.stop_propagation(); cx.stop_propagation();
cx.new_view(|_| drag.clone()) cx.new_view(|_| drag.clone())
}, },
@ -441,10 +441,13 @@ impl TabPanel {
view.set_active_ix(ix, cx); view.set_active_ix(ix, cx);
})) }))
.when(state.draggable, |this| { .when(state.draggable, |this| {
this.on_drag(DragPanel::new(panel.clone(), view.clone()), |drag, cx| { this.on_drag(
cx.stop_propagation(); DragPanel::new(panel.clone(), view.clone()),
cx.new_view(|_| drag.clone()) |drag, _, cx| {
}) cx.stop_propagation();
cx.new_view(|_| drag.clone())
},
)
}) })
.when(state.droppable, |this| { .when(state.droppable, |this| {
this.drag_over::<DragPanel>(|this, _, cx| { this.drag_over::<DragPanel>(|this, _, cx| {

View file

@ -8,13 +8,13 @@ use crate::{
theme::ActiveTheme, theme::ActiveTheme,
v_flex, IconName, Size, v_flex, IconName, Size,
}; };
use gpui::px;
use gpui::{ use gpui::{
actions, div, prelude::FluentBuilder, uniform_list, AnyElement, AppContext, Entity, actions, div, prelude::FluentBuilder, uniform_list, AnyElement, AppContext, Entity,
FocusHandle, FocusableView, InteractiveElement, IntoElement, KeyBinding, Length, FocusHandle, FocusableView, InteractiveElement, IntoElement, KeyBinding, Length,
ListSizingBehavior, MouseButton, ParentElement, Render, SharedString, Styled, Task, ListSizingBehavior, MouseButton, ParentElement, Render, SharedString, Styled, Task,
UniformListScrollHandle, View, ViewContext, VisualContext, WindowContext, UniformListScrollHandle, View, ViewContext, VisualContext, WindowContext,
}; };
use gpui::{px, ScrollStrategy};
use smol::Timer; use smol::Timer;
actions!(list, [Cancel, Confirm, SelectPrev, SelectNext]); actions!(list, [Cancel, Confirm, SelectPrev, SelectNext]);
@ -209,7 +209,8 @@ where
fn scroll_to_selected_item(&mut self, _cx: &mut ViewContext<Self>) { fn scroll_to_selected_item(&mut self, _cx: &mut ViewContext<Self>) {
if let Some(ix) = self.selected_index { if let Some(ix) = self.selected_index {
self.vertical_scroll_handle.scroll_to_item(ix); self.vertical_scroll_handle
.scroll_to_item(ix, ScrollStrategy::Top);
} }
} }
@ -233,7 +234,8 @@ where
search.await; search.await;
let _ = this.update(&mut cx, |this, _| { let _ = this.update(&mut cx, |this, _| {
this.vertical_scroll_handle.scroll_to_item(0); this.vertical_scroll_handle
.scroll_to_item(0, ScrollStrategy::Top);
this.last_query = Some(text); this.last_query = Some(text);
}); });

View file

@ -150,7 +150,7 @@ impl ResizablePanelGroup {
let view = cx.view().clone(); let view = cx.view().clone();
resize_handle(("resizable-handle", ix), self.axis).on_drag( resize_handle(("resizable-handle", ix), self.axis).on_drag(
DragPanel((cx.entity_id(), ix, self.axis)), DragPanel((cx.entity_id(), ix, self.axis)),
move |drag_panel, cx| { move |drag_panel, _, cx| {
cx.stop_propagation(); cx.stop_propagation();
// Set current resizing panel ix // Set current resizing panel ix
view.update(cx, |view, _| { view.update(cx, |view, _| {

View file

@ -149,7 +149,7 @@ impl Element for ScrollableMask {
} }
if old_offset != scroll_handle.offset() { if old_offset != scroll_handle.offset() {
cx.notify(view_id); cx.notify(Some(view_id));
cx.stop_propagation(); cx.stop_propagation();
} }
} }

View file

@ -493,7 +493,7 @@ impl Element for Scrollbar {
scroll_handle.offset(), scroll_handle.offset(),
Some(Instant::now()), Some(Instant::now()),
)); ));
cx.notify(view_id); cx.notify(Some(view_id));
} }
} }
} }
@ -514,7 +514,7 @@ impl Element for Scrollbar {
state.set(state.get().with_drag_pos(axis, pos)); state.set(state.get().with_drag_pos(axis, pos));
cx.notify(view_id); cx.notify(Some(view_id));
} else { } else {
// click on the scrollbar, jump to the position // click on the scrollbar, jump to the position
// Set the thumb bar center to the click position // Set the thumb bar center to the click position
@ -554,13 +554,13 @@ impl Element for Scrollbar {
if bounds.contains(&event.position) { if bounds.contains(&event.position) {
if state.get().hovered_axis != Some(axis) { if state.get().hovered_axis != Some(axis) {
state.set(state.get().with_hovered(Some(axis))); state.set(state.get().with_hovered(Some(axis)));
cx.notify(view_id); cx.notify(Some(view_id));
} }
} else { } else {
if state.get().hovered_axis == Some(axis) { if state.get().hovered_axis == Some(axis) {
if state.get().hovered_axis.is_some() { if state.get().hovered_axis.is_some() {
state.set(state.get().with_hovered(None)); state.set(state.get().with_hovered(None));
cx.notify(view_id); cx.notify(Some(view_id));
} }
} }
} }
@ -569,13 +569,12 @@ impl Element for Scrollbar {
if thumb_bounds.contains(&event.position) { if thumb_bounds.contains(&event.position) {
if state.get().hovered_on_thumb != Some(axis) { if state.get().hovered_on_thumb != Some(axis) {
state.set(state.get().with_hovered_on_thumb(Some(axis))); state.set(state.get().with_hovered_on_thumb(Some(axis)));
cx.notify(Some(view_id));
cx.notify(view_id);
} }
} else { } else {
if state.get().hovered_on_thumb == Some(axis) { if state.get().hovered_on_thumb == Some(axis) {
state.set(state.get().with_hovered_on_thumb(None)); state.set(state.get().with_hovered_on_thumb(None));
cx.notify(view_id); cx.notify(Some(view_id));
} }
} }
@ -607,7 +606,7 @@ impl Element for Scrollbar {
}; };
scroll_handle.set_offset(offset); scroll_handle.set_offset(offset);
cx.notify(view_id); cx.notify(Some(view_id));
} }
} }
}); });
@ -619,8 +618,7 @@ impl Element for Scrollbar {
move |_event: &MouseUpEvent, phase, cx| { move |_event: &MouseUpEvent, phase, cx| {
if phase.bubble() { if phase.bubble() {
state.set(state.get().with_unset_drag_pos()); state.set(state.get().with_unset_drag_pos());
cx.notify(Some(view_id));
cx.notify(view_id);
} }
} }
}); });

View file

@ -119,7 +119,7 @@ impl Slider {
div() div()
.id("slider-thumb") .id("slider-thumb")
.on_drag(DragThumb(entity_id), |drag, cx| { .on_drag(DragThumb(entity_id), |drag, _, cx| {
cx.stop_propagation(); cx.stop_propagation();
cx.new_view(|_| drag.clone()) cx.new_view(|_| drag.clone())
}) })

View file

@ -12,7 +12,7 @@ use gpui::{
actions, canvas, div, prelude::FluentBuilder, px, uniform_list, AppContext, Bounds, Div, actions, canvas, div, prelude::FluentBuilder, px, uniform_list, AppContext, Bounds, Div,
DragMoveEvent, Edges, Entity, EntityId, EventEmitter, FocusHandle, FocusableView, DragMoveEvent, Edges, Entity, EntityId, EventEmitter, FocusHandle, FocusableView,
InteractiveElement, IntoElement, KeyBinding, MouseButton, ParentElement, Pixels, Point, Render, InteractiveElement, IntoElement, KeyBinding, MouseButton, ParentElement, Pixels, Point, Render,
ScrollHandle, SharedString, Stateful, StatefulInteractiveElement as _, Styled, ScrollHandle, ScrollStrategy, SharedString, Stateful, StatefulInteractiveElement as _, Styled,
UniformListScrollHandle, ViewContext, VisualContext as _, WindowContext, UniformListScrollHandle, ViewContext, VisualContext as _, WindowContext,
}; };
@ -343,7 +343,8 @@ where
} }
fn scroll_to_row(&mut self, row_ix: usize, cx: &mut ViewContext<Self>) { fn scroll_to_row(&mut self, row_ix: usize, cx: &mut ViewContext<Self>) {
self.vertical_scroll_handle.scroll_to_item(row_ix); self.vertical_scroll_handle
.scroll_to_item(row_ix, ScrollStrategy::Top);
cx.notify(); cx.notify();
} }
@ -352,7 +353,8 @@ where
self.right_clicked_row = None; self.right_clicked_row = None;
self.selected_row = Some(row_ix); self.selected_row = Some(row_ix);
if let Some(row_ix) = self.selected_row { if let Some(row_ix) = self.selected_row {
self.vertical_scroll_handle.scroll_to_item(row_ix); self.vertical_scroll_handle
.scroll_to_item(row_ix, ScrollStrategy::Top);
} }
cx.emit(TableEvent::SelectRow(row_ix)); cx.emit(TableEvent::SelectRow(row_ix));
cx.notify(); cx.notify();
@ -707,7 +709,7 @@ where
} }
}; };
})) }))
.on_drag(ResizeCol((cx.entity_id(), ix)), |drag, cx| { .on_drag(ResizeCol((cx.entity_id(), ix)), |drag, _, cx| {
cx.stop_propagation(); cx.stop_propagation();
cx.new_view(|_| drag.clone()) cx.new_view(|_| drag.clone())
}) })
@ -809,7 +811,7 @@ where
name, name,
width: col_group.width, width: col_group.width,
}, },
|drag, cx| { |drag, _, cx| {
cx.stop_propagation(); cx.stop_propagation();
cx.new_view(|_| drag.clone()) cx.new_view(|_| drag.clone())
}, },