diff --git a/Cargo.lock b/Cargo.lock index dadd3575..57c7eb44 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -474,7 +474,7 @@ dependencies = [ "bitflags 2.6.0", "cexpr", "clang-sys", - "itertools 0.13.0", + "itertools 0.11.0", "log", "prettyplease", "proc-macro2", @@ -950,7 +950,7 @@ dependencies = [ [[package]] name = "collections" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861" dependencies = [ "rustc-hash", ] @@ -1313,7 +1313,7 @@ dependencies = [ [[package]] name = "derive_refineable" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861" dependencies = [ "proc-macro2", "quote", @@ -2266,7 +2266,7 @@ dependencies = [ [[package]] name = "gpui" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861" dependencies = [ "anyhow", "as-raw-xcb-connection", @@ -2351,7 +2351,7 @@ dependencies = [ [[package]] name = "gpui_macros" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861" dependencies = [ "proc-macro2", "quote", @@ -2541,7 +2541,7 @@ dependencies = [ [[package]] name = "http_client" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861" dependencies = [ "anyhow", "bytes", @@ -3057,7 +3057,7 @@ dependencies = [ [[package]] name = "media" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861" dependencies = [ "anyhow", "bindgen", @@ -4337,7 +4337,7 @@ dependencies = [ [[package]] name = "refineable" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861" dependencies = [ "derive_refineable", ] @@ -4658,7 +4658,7 @@ checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a" [[package]] name = "semantic_version" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861" dependencies = [ "anyhow", "serde", @@ -5080,7 +5080,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sum_tree" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861" dependencies = [ "arrayvec", "log", @@ -5745,7 +5745,7 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" [[package]] name = "util" version = "0.1.0" -source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc" +source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861" dependencies = [ "anyhow", "async-fs 1.6.0", @@ -5755,7 +5755,6 @@ dependencies = [ "futures", "futures-lite 1.13.0", "globset", - "itertools 0.13.0", "log", "regex", "rust-embed", diff --git a/crates/story/src/list_story.rs b/crates/story/src/list_story.rs index 25fe52cd..fb2560eb 100644 --- a/crates/story/src/list_story.rs +++ b/crates/story/src/list_story.rs @@ -156,7 +156,7 @@ impl ListDelegate for CompanyListDelegate { .cloned() .collect(); - Task::Ready(Some(())) + Task::ready(()) } fn confirm(&mut self, ix: Option, cx: &mut ViewContext>) { diff --git a/crates/story/src/main.rs b/crates/story/src/main.rs index a1b90fbd..37d2a1e7 100644 --- a/crates/story/src/main.rs +++ b/crates/story/src/main.rs @@ -115,7 +115,7 @@ impl StoryWorkspace { let theme_color_picker = cx.new_view(|cx| { let mut picker = ColorPicker::new("theme-color-picker", cx) .xsmall() - .anchor(AnchorCorner::TopRight) + .anchor(Corner::TopRight) .label("Theme Color"); picker.set_value(cx.theme().primary, cx); picker @@ -461,7 +461,7 @@ impl Render for StoryWorkspace { Box::new(AddPanel(DockPlacement::Bottom)), ) }) - .anchor(AnchorCorner::TopRight), + .anchor(Corner::TopRight), ) .child( Button::new("theme-mode") @@ -567,7 +567,7 @@ impl Render for LocaleSelector { Box::new(SelectLocale("zh-CN".into())), ) }) - .anchor(AnchorCorner::TopRight), + .anchor(Corner::TopRight), ) } } @@ -630,7 +630,7 @@ impl Render for FontSizeSelector { Box::new(SelectScrollbarShow(ScrollbarShow::Hover)), ) }) - .anchor(AnchorCorner::TopRight), + .anchor(Corner::TopRight), ) } } diff --git a/crates/story/src/popup_story.rs b/crates/story/src/popup_story.rs index b691f594..0395f3fb 100644 --- a/crates/story/src/popup_story.rs +++ b/crates/story/src/popup_story.rs @@ -1,5 +1,5 @@ use gpui::{ - actions, div, impl_actions, px, AnchorCorner, AppContext, DismissEvent, Element, EventEmitter, + actions, div, impl_actions, px, AppContext, Corner, DismissEvent, Element, EventEmitter, FocusHandle, FocusableView, InteractiveElement, IntoElement, KeyBinding, MouseButton, ParentElement as _, Render, SharedString, Styled as _, View, ViewContext, VisualContext, WindowContext, @@ -234,7 +234,7 @@ impl Render for PopupStory { ) .child( Popover::new("info-top-right") - .anchor(AnchorCorner::TopRight) + .anchor(Corner::TopRight) .trigger(Button::new("info-top-right").label("Top Right")) .content(|cx| { cx.new_view(|cx| { @@ -302,7 +302,7 @@ impl Render for PopupStory { .child( Button::new("popup-menu-11112") .label("Scrollable Menu") - .popup_menu_with_anchor(AnchorCorner::TopRight, move |this, _| { + .popup_menu_with_anchor(Corner::TopRight, move |this, _| { let mut this = this.scrollable(); for i in 0..100 { this = this.menu( @@ -323,13 +323,13 @@ impl Render for PopupStory { .justify_between() .child( Popover::new("info-bottom-left") - .anchor(AnchorCorner::BottomLeft) + .anchor(Corner::BottomLeft) .trigger(Button::new("pop").label("Popup with Form").w(px(300.))) .content(move |_| form.clone()), ) .child( Popover::new("info-bottom-right") - .anchor(AnchorCorner::BottomRight) + .anchor(Corner::BottomRight) .mouse_button(MouseButton::Right) .trigger(Button::new("pop").label("Mouse Right Click").w(px(300.))) .content(|cx| { diff --git a/crates/ui/src/color_picker.rs b/crates/ui/src/color_picker.rs index 9bf6eb4e..0bc81f52 100644 --- a/crates/ui/src/color_picker.rs +++ b/crates/ui/src/color_picker.rs @@ -1,9 +1,8 @@ use gpui::{ - anchored, canvas, deferred, div, prelude::FluentBuilder as _, px, relative, AnchorCorner, - AppContext, Bounds, ElementId, EventEmitter, FocusHandle, FocusableView, Hsla, - InteractiveElement as _, IntoElement, KeyBinding, MouseButton, ParentElement, Pixels, Point, - Render, SharedString, StatefulInteractiveElement as _, Styled, View, ViewContext, - VisualContext, + anchored, canvas, deferred, div, prelude::FluentBuilder as _, px, relative, AppContext, Bounds, + Corner, ElementId, EventEmitter, FocusHandle, FocusableView, Hsla, InteractiveElement as _, + IntoElement, KeyBinding, MouseButton, ParentElement, Pixels, Point, Render, SharedString, + StatefulInteractiveElement as _, Styled, View, ViewContext, VisualContext, }; use crate::{ @@ -63,7 +62,7 @@ pub struct ColorPicker { hovered_color: Option, label: Option, size: Size, - anchor: AnchorCorner, + anchor: Corner, color_input: View, open: bool, @@ -112,7 +111,7 @@ impl ColorPicker { hovered_color: None, size: Size::Medium, label: None, - anchor: AnchorCorner::TopLeft, + anchor: Corner::TopLeft, color_input, open: false, bounds: Bounds::default(), @@ -149,8 +148,8 @@ impl ColorPicker { /// Set the anchor corner of the color picker. /// - /// Default is `AnchorCorner::TopLeft`. - pub fn anchor(mut self, anchor: AnchorCorner) -> Self { + /// Default is `Corner::TopLeft`. + pub fn anchor(mut self, anchor: Corner) -> Self { self.anchor = anchor; self } @@ -262,13 +261,12 @@ impl ColorPicker { } fn resolved_corner(&self, bounds: Bounds) -> Point { - match self.anchor { - AnchorCorner::TopLeft => AnchorCorner::BottomLeft, - AnchorCorner::TopRight => AnchorCorner::BottomRight, - AnchorCorner::BottomLeft => AnchorCorner::TopLeft, - AnchorCorner::BottomRight => AnchorCorner::TopRight, - } - .corner(bounds) + bounds.corner(match self.anchor { + Corner::TopLeft => Corner::BottomLeft, + Corner::TopRight => Corner::BottomRight, + Corner::BottomLeft => Corner::TopLeft, + Corner::BottomRight => Corner::TopRight, + }) } } @@ -347,12 +345,8 @@ impl Render for ColorPicker { div() .occlude() .map(|this| match self.anchor { - AnchorCorner::TopLeft | AnchorCorner::TopRight => { - this.mt_1p5() - } - AnchorCorner::BottomLeft | AnchorCorner::BottomRight => { - this.mb_1p5() - } + Corner::TopLeft | Corner::TopRight => this.mt_1p5(), + Corner::BottomLeft | Corner::BottomRight => this.mb_1p5(), }) .w_72() .overflow_hidden() diff --git a/crates/ui/src/context_menu.rs b/crates/ui/src/context_menu.rs index 83633d56..235d0c2f 100644 --- a/crates/ui/src/context_menu.rs +++ b/crates/ui/src/context_menu.rs @@ -1,7 +1,7 @@ use std::{cell::RefCell, rc::Rc}; use gpui::{ - anchored, deferred, div, prelude::FluentBuilder, px, relative, AnchorCorner, AnyElement, + anchored, deferred, div, prelude::FluentBuilder, px, relative, AnyElement, Corner, DismissEvent, DispatchPhase, Element, ElementId, Focusable, GlobalElementId, InteractiveElement, IntoElement, MouseButton, MouseDownEvent, ParentElement, Pixels, Point, Position, Stateful, Style, View, ViewContext, WindowContext, @@ -25,7 +25,7 @@ impl ContextMenuExt for Focusable where E: ParentElement {} pub struct ContextMenu { id: ElementId, menu: Option) -> PopupMenu + 'static>>, - anchor: AnchorCorner, + anchor: Corner, } impl ContextMenu { @@ -33,7 +33,7 @@ impl ContextMenu { Self { id: id.into(), menu: None, - anchor: AnchorCorner::TopLeft, + anchor: Corner::TopLeft, } } diff --git a/crates/ui/src/dock/tab_panel.rs b/crates/ui/src/dock/tab_panel.rs index 732f34aa..02715738 100644 --- a/crates/ui/src/dock/tab_panel.rs +++ b/crates/ui/src/dock/tab_panel.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use gpui::{ - div, prelude::FluentBuilder, px, rems, AnchorCorner, AppContext, DefiniteLength, DismissEvent, + div, prelude::FluentBuilder, px, rems, AppContext, Corner, DefiniteLength, DismissEvent, DragMoveEvent, Empty, Entity, EventEmitter, FocusHandle, FocusableView, InteractiveElement as _, IntoElement, ParentElement, Pixels, Render, ScrollHandle, SharedString, StatefulInteractiveElement, Styled, View, ViewContext, VisualContext as _, @@ -375,7 +375,7 @@ impl TabPanel { .menu(t!("Dock.Close"), Box::new(ClosePanel)) }) }) - .anchor(AnchorCorner::TopRight), + .anchor(Corner::TopRight), ) } diff --git a/crates/ui/src/dropdown.rs b/crates/ui/src/dropdown.rs index 16bfa45c..6e177a17 100644 --- a/crates/ui/src/dropdown.rs +++ b/crates/ui/src/dropdown.rs @@ -82,7 +82,7 @@ pub trait DropdownDelegate: Sized { } fn perform_search(&mut self, _query: &str, _cx: &mut ViewContext>) -> Task<()> { - Task::Ready(Some(())) + Task::ready(()) } } @@ -179,11 +179,9 @@ where } fn perform_search(&mut self, query: &str, cx: &mut ViewContext>) -> Task<()> { - self.dropdown - .upgrade() - .map_or(Task::Ready(None), |dropdown| { - dropdown.update(cx, |_, cx| self.delegate.perform_search(query, cx)) - }) + self.dropdown.upgrade().map_or(Task::ready(()), |dropdown| { + dropdown.update(cx, |_, cx| self.delegate.perform_search(query, cx)) + }) } fn set_selected_index(&mut self, ix: Option, _: &mut ViewContext>) { @@ -284,7 +282,7 @@ impl DropdownDelegate for SearchableVec { .cloned() .collect(); - Task::Ready(Some(())) + Task::ready(()) } } diff --git a/crates/ui/src/list/list.rs b/crates/ui/src/list/list.rs index 0eca616f..eb3240ef 100644 --- a/crates/ui/src/list/list.rs +++ b/crates/ui/src/list/list.rs @@ -37,7 +37,7 @@ pub trait ListDelegate: Sized + 'static { /// When Query Input change, this method will be called. /// You can perform search here. fn perform_search(&mut self, query: &str, cx: &mut ViewContext>) -> Task<()> { - Task::Ready(Some(())) + Task::ready(()) } /// Return the number of items in the list. @@ -126,7 +126,7 @@ where enable_scrollbar: true, loading: false, size: Size::default(), - _search_task: Task::Ready(None), + _search_task: Task::ready(()), } } diff --git a/crates/ui/src/popover.rs b/crates/ui/src/popover.rs index 33fd3d62..38bc3ac7 100644 --- a/crates/ui/src/popover.rs +++ b/crates/ui/src/popover.rs @@ -1,6 +1,6 @@ use gpui::{ - actions, anchored, deferred, div, prelude::FluentBuilder as _, px, AnchorCorner, AnyElement, - AppContext, Bounds, DismissEvent, DispatchPhase, Element, ElementId, EventEmitter, FocusHandle, + actions, anchored, deferred, div, prelude::FluentBuilder as _, px, AnyElement, AppContext, + Bounds, Corner, DismissEvent, DispatchPhase, Element, ElementId, EventEmitter, FocusHandle, FocusableView, GlobalElementId, Hitbox, InteractiveElement as _, IntoElement, KeyBinding, LayoutId, ManagedView, MouseButton, MouseDownEvent, ParentElement, Pixels, Point, Render, Style, StyleRefinement, Styled, View, ViewContext, VisualContext, WindowContext, @@ -64,7 +64,7 @@ impl Render for PopoverContent { pub struct Popover { id: ElementId, - anchor: AnchorCorner, + anchor: Corner, trigger: Option AnyElement + 'static>>, content: Option View + 'static>>, /// Style for trigger element. @@ -82,7 +82,7 @@ where pub fn new(id: impl Into) -> Self { Self { id: id.into(), - anchor: AnchorCorner::TopLeft, + anchor: Corner::TopLeft, trigger: None, trigger_style: None, content: None, @@ -91,7 +91,7 @@ where } } - pub fn anchor(mut self, anchor: AnchorCorner) -> Self { + pub fn anchor(mut self, anchor: Corner) -> Self { self.anchor = anchor; self } @@ -148,13 +148,12 @@ where } fn resolved_corner(&self, bounds: Bounds) -> Point { - match self.anchor { - AnchorCorner::TopLeft => AnchorCorner::BottomLeft, - AnchorCorner::TopRight => AnchorCorner::BottomRight, - AnchorCorner::BottomLeft => AnchorCorner::TopLeft, - AnchorCorner::BottomRight => AnchorCorner::TopRight, - } - .corner(bounds) + bounds.corner(match self.anchor { + Corner::TopLeft => Corner::BottomLeft, + Corner::TopRight => Corner::BottomRight, + Corner::BottomLeft => Corner::TopLeft, + Corner::BottomRight => Corner::TopRight, + }) } fn with_element_state( @@ -268,12 +267,8 @@ impl Element for Popover { .occlude() .when(!no_style, |this| this.popover_style(cx)) .map(|this| match anchor { - AnchorCorner::TopLeft | AnchorCorner::TopRight => { - this.top_1p5() - } - AnchorCorner::BottomLeft | AnchorCorner::BottomRight => { - this.bottom_1p5() - } + Corner::TopLeft | Corner::TopRight => this.top_1p5(), + Corner::BottomLeft | Corner::BottomRight => this.bottom_1p5(), }) .child(content_view.clone()) .when(!no_style, |this| { diff --git a/crates/ui/src/popup_menu.rs b/crates/ui/src/popup_menu.rs index 9bc9da02..01b07273 100644 --- a/crates/ui/src/popup_menu.rs +++ b/crates/ui/src/popup_menu.rs @@ -8,7 +8,7 @@ use gpui::{ SharedString, View, ViewContext, VisualContext as _, WindowContext, }; use gpui::{ - anchored, canvas, rems, AnchorCorner, AnyElement, Bounds, Edges, FocusableView, Keystroke, + anchored, canvas, rems, AnyElement, Bounds, Corner, Edges, FocusableView, Keystroke, ScrollHandle, StatefulInteractiveElement, Styled, WeakView, }; @@ -37,13 +37,13 @@ pub trait PopupMenuExt: Styled + Selectable + IntoElement + 'static { self, f: impl Fn(PopupMenu, &mut ViewContext) -> PopupMenu + 'static, ) -> Popover { - self.popup_menu_with_anchor(AnchorCorner::TopLeft, f) + self.popup_menu_with_anchor(Corner::TopLeft, f) } /// Create a popup menu with the given items, anchored to the given corner fn popup_menu_with_anchor( mut self, - anchor: impl Into, + anchor: impl Into, f: impl Fn(PopupMenu, &mut ViewContext) -> PopupMenu + 'static, ) -> Popover { let style = self.style().clone(); @@ -649,13 +649,10 @@ impl Render for PopupMenu { - bounds.origin.x < max_width { - ( - AnchorCorner::TopRight, - -px(15.), - ) + (Corner::TopRight, -px(15.)) } else { ( - AnchorCorner::TopLeft, + Corner::TopLeft, bounds.size.width - px(10.), ) diff --git a/crates/ui/src/virtual_list.rs b/crates/ui/src/virtual_list.rs index 5b46a6a0..6cdf27ce 100644 --- a/crates/ui/src/virtual_list.rs +++ b/crates/ui/src/virtual_list.rs @@ -261,7 +261,7 @@ impl Element for VirtualList { let padded_bounds = Bounds::from_corners( bounds.origin + point(border.left + padding.left, border.top + padding.top), - bounds.lower_right() + bounds.bottom_right() - point(border.right + padding.right, border.bottom + padding.bottom), ); @@ -297,7 +297,7 @@ impl Element for VirtualList { let padded_bounds = Bounds::from_corners( bounds.origin + point(border.left + padding.left, border.top), - bounds.lower_right() - point(border.right + padding.right, border.bottom), + bounds.bottom_right() - point(border.right + padding.right, border.bottom), ); if self.items_count > 0 {