chore: Update GPUI with AnchorCorner renamed to Corner. (#497)
Ref https://github.com/zed-industries/zed/pull/22119
This commit is contained in:
parent
24982fb78c
commit
d4819b34aa
12 changed files with 69 additions and 86 deletions
23
Cargo.lock
generated
23
Cargo.lock
generated
|
|
@ -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#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc"
|
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861"
|
||||||
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#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc"
|
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861"
|
||||||
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#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc"
|
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"as-raw-xcb-connection",
|
"as-raw-xcb-connection",
|
||||||
|
|
@ -2351,7 +2351,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#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc"
|
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
@ -2541,7 +2541,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#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc"
|
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
|
@ -3057,7 +3057,7 @@ 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#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc"
|
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bindgen",
|
"bindgen",
|
||||||
|
|
@ -4337,7 +4337,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#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc"
|
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_refineable",
|
"derive_refineable",
|
||||||
]
|
]
|
||||||
|
|
@ -4658,7 +4658,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#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc"
|
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
@ -5080,7 +5080,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#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc"
|
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"log",
|
"log",
|
||||||
|
|
@ -5745,7 +5745,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#0ae1603610ab6b265bdfbee7b8dbc23c5ab06edc"
|
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#65da76c2df8887f2ff699365c95ea8205bf65861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-fs 1.6.0",
|
"async-fs 1.6.0",
|
||||||
|
|
@ -5755,7 +5755,6 @@ dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"futures-lite 1.13.0",
|
"futures-lite 1.13.0",
|
||||||
"globset",
|
"globset",
|
||||||
"itertools 0.13.0",
|
|
||||||
"log",
|
"log",
|
||||||
"regex",
|
"regex",
|
||||||
"rust-embed",
|
"rust-embed",
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ impl ListDelegate for CompanyListDelegate {
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Task::Ready(Some(()))
|
Task::ready(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn confirm(&mut self, ix: Option<usize>, cx: &mut ViewContext<List<Self>>) {
|
fn confirm(&mut self, ix: Option<usize>, cx: &mut ViewContext<List<Self>>) {
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ impl StoryWorkspace {
|
||||||
let theme_color_picker = cx.new_view(|cx| {
|
let theme_color_picker = cx.new_view(|cx| {
|
||||||
let mut picker = ColorPicker::new("theme-color-picker", cx)
|
let mut picker = ColorPicker::new("theme-color-picker", cx)
|
||||||
.xsmall()
|
.xsmall()
|
||||||
.anchor(AnchorCorner::TopRight)
|
.anchor(Corner::TopRight)
|
||||||
.label("Theme Color");
|
.label("Theme Color");
|
||||||
picker.set_value(cx.theme().primary, cx);
|
picker.set_value(cx.theme().primary, cx);
|
||||||
picker
|
picker
|
||||||
|
|
@ -461,7 +461,7 @@ impl Render for StoryWorkspace {
|
||||||
Box::new(AddPanel(DockPlacement::Bottom)),
|
Box::new(AddPanel(DockPlacement::Bottom)),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.anchor(AnchorCorner::TopRight),
|
.anchor(Corner::TopRight),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new("theme-mode")
|
Button::new("theme-mode")
|
||||||
|
|
@ -567,7 +567,7 @@ impl Render for LocaleSelector {
|
||||||
Box::new(SelectLocale("zh-CN".into())),
|
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)),
|
Box::new(SelectScrollbarShow(ScrollbarShow::Hover)),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.anchor(AnchorCorner::TopRight),
|
.anchor(Corner::TopRight),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use gpui::{
|
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,
|
FocusHandle, FocusableView, InteractiveElement, IntoElement, KeyBinding, MouseButton,
|
||||||
ParentElement as _, Render, SharedString, Styled as _, View, ViewContext, VisualContext,
|
ParentElement as _, Render, SharedString, Styled as _, View, ViewContext, VisualContext,
|
||||||
WindowContext,
|
WindowContext,
|
||||||
|
|
@ -234,7 +234,7 @@ impl Render for PopupStory {
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Popover::new("info-top-right")
|
Popover::new("info-top-right")
|
||||||
.anchor(AnchorCorner::TopRight)
|
.anchor(Corner::TopRight)
|
||||||
.trigger(Button::new("info-top-right").label("Top Right"))
|
.trigger(Button::new("info-top-right").label("Top Right"))
|
||||||
.content(|cx| {
|
.content(|cx| {
|
||||||
cx.new_view(|cx| {
|
cx.new_view(|cx| {
|
||||||
|
|
@ -302,7 +302,7 @@ impl Render for PopupStory {
|
||||||
.child(
|
.child(
|
||||||
Button::new("popup-menu-11112")
|
Button::new("popup-menu-11112")
|
||||||
.label("Scrollable Menu")
|
.label("Scrollable Menu")
|
||||||
.popup_menu_with_anchor(AnchorCorner::TopRight, move |this, _| {
|
.popup_menu_with_anchor(Corner::TopRight, move |this, _| {
|
||||||
let mut this = this.scrollable();
|
let mut this = this.scrollable();
|
||||||
for i in 0..100 {
|
for i in 0..100 {
|
||||||
this = this.menu(
|
this = this.menu(
|
||||||
|
|
@ -323,13 +323,13 @@ impl Render for PopupStory {
|
||||||
.justify_between()
|
.justify_between()
|
||||||
.child(
|
.child(
|
||||||
Popover::new("info-bottom-left")
|
Popover::new("info-bottom-left")
|
||||||
.anchor(AnchorCorner::BottomLeft)
|
.anchor(Corner::BottomLeft)
|
||||||
.trigger(Button::new("pop").label("Popup with Form").w(px(300.)))
|
.trigger(Button::new("pop").label("Popup with Form").w(px(300.)))
|
||||||
.content(move |_| form.clone()),
|
.content(move |_| form.clone()),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Popover::new("info-bottom-right")
|
Popover::new("info-bottom-right")
|
||||||
.anchor(AnchorCorner::BottomRight)
|
.anchor(Corner::BottomRight)
|
||||||
.mouse_button(MouseButton::Right)
|
.mouse_button(MouseButton::Right)
|
||||||
.trigger(Button::new("pop").label("Mouse Right Click").w(px(300.)))
|
.trigger(Button::new("pop").label("Mouse Right Click").w(px(300.)))
|
||||||
.content(|cx| {
|
.content(|cx| {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
use gpui::{
|
use gpui::{
|
||||||
anchored, canvas, deferred, div, prelude::FluentBuilder as _, px, relative, AnchorCorner,
|
anchored, canvas, deferred, div, prelude::FluentBuilder as _, px, relative, AppContext, Bounds,
|
||||||
AppContext, Bounds, ElementId, EventEmitter, FocusHandle, FocusableView, Hsla,
|
Corner, ElementId, EventEmitter, FocusHandle, FocusableView, Hsla, InteractiveElement as _,
|
||||||
InteractiveElement as _, IntoElement, KeyBinding, MouseButton, ParentElement, Pixels, Point,
|
IntoElement, KeyBinding, MouseButton, ParentElement, Pixels, Point, Render, SharedString,
|
||||||
Render, SharedString, StatefulInteractiveElement as _, Styled, View, ViewContext,
|
StatefulInteractiveElement as _, Styled, View, ViewContext, VisualContext,
|
||||||
VisualContext,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
@ -63,7 +62,7 @@ pub struct ColorPicker {
|
||||||
hovered_color: Option<Hsla>,
|
hovered_color: Option<Hsla>,
|
||||||
label: Option<SharedString>,
|
label: Option<SharedString>,
|
||||||
size: Size,
|
size: Size,
|
||||||
anchor: AnchorCorner,
|
anchor: Corner,
|
||||||
color_input: View<TextInput>,
|
color_input: View<TextInput>,
|
||||||
|
|
||||||
open: bool,
|
open: bool,
|
||||||
|
|
@ -112,7 +111,7 @@ impl ColorPicker {
|
||||||
hovered_color: None,
|
hovered_color: None,
|
||||||
size: Size::Medium,
|
size: Size::Medium,
|
||||||
label: None,
|
label: None,
|
||||||
anchor: AnchorCorner::TopLeft,
|
anchor: Corner::TopLeft,
|
||||||
color_input,
|
color_input,
|
||||||
open: false,
|
open: false,
|
||||||
bounds: Bounds::default(),
|
bounds: Bounds::default(),
|
||||||
|
|
@ -149,8 +148,8 @@ impl ColorPicker {
|
||||||
|
|
||||||
/// Set the anchor corner of the color picker.
|
/// Set the anchor corner of the color picker.
|
||||||
///
|
///
|
||||||
/// Default is `AnchorCorner::TopLeft`.
|
/// Default is `Corner::TopLeft`.
|
||||||
pub fn anchor(mut self, anchor: AnchorCorner) -> Self {
|
pub fn anchor(mut self, anchor: Corner) -> Self {
|
||||||
self.anchor = anchor;
|
self.anchor = anchor;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -262,13 +261,12 @@ impl ColorPicker {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolved_corner(&self, bounds: Bounds<Pixels>) -> Point<Pixels> {
|
fn resolved_corner(&self, bounds: Bounds<Pixels>) -> Point<Pixels> {
|
||||||
match self.anchor {
|
bounds.corner(match self.anchor {
|
||||||
AnchorCorner::TopLeft => AnchorCorner::BottomLeft,
|
Corner::TopLeft => Corner::BottomLeft,
|
||||||
AnchorCorner::TopRight => AnchorCorner::BottomRight,
|
Corner::TopRight => Corner::BottomRight,
|
||||||
AnchorCorner::BottomLeft => AnchorCorner::TopLeft,
|
Corner::BottomLeft => Corner::TopLeft,
|
||||||
AnchorCorner::BottomRight => AnchorCorner::TopRight,
|
Corner::BottomRight => Corner::TopRight,
|
||||||
}
|
})
|
||||||
.corner(bounds)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -347,12 +345,8 @@ impl Render for ColorPicker {
|
||||||
div()
|
div()
|
||||||
.occlude()
|
.occlude()
|
||||||
.map(|this| match self.anchor {
|
.map(|this| match self.anchor {
|
||||||
AnchorCorner::TopLeft | AnchorCorner::TopRight => {
|
Corner::TopLeft | Corner::TopRight => this.mt_1p5(),
|
||||||
this.mt_1p5()
|
Corner::BottomLeft | Corner::BottomRight => this.mb_1p5(),
|
||||||
}
|
|
||||||
AnchorCorner::BottomLeft | AnchorCorner::BottomRight => {
|
|
||||||
this.mb_1p5()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.w_72()
|
.w_72()
|
||||||
.overflow_hidden()
|
.overflow_hidden()
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::{cell::RefCell, rc::Rc};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
|
|
||||||
use gpui::{
|
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,
|
DismissEvent, DispatchPhase, Element, ElementId, Focusable, GlobalElementId,
|
||||||
InteractiveElement, IntoElement, MouseButton, MouseDownEvent, ParentElement, Pixels, Point,
|
InteractiveElement, IntoElement, MouseButton, MouseDownEvent, ParentElement, Pixels, Point,
|
||||||
Position, Stateful, Style, View, ViewContext, WindowContext,
|
Position, Stateful, Style, View, ViewContext, WindowContext,
|
||||||
|
|
@ -25,7 +25,7 @@ impl<E> ContextMenuExt for Focusable<E> where E: ParentElement {}
|
||||||
pub struct ContextMenu {
|
pub struct ContextMenu {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
menu: Option<Box<dyn Fn(PopupMenu, &mut ViewContext<PopupMenu>) -> PopupMenu + 'static>>,
|
menu: Option<Box<dyn Fn(PopupMenu, &mut ViewContext<PopupMenu>) -> PopupMenu + 'static>>,
|
||||||
anchor: AnchorCorner,
|
anchor: Corner,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ContextMenu {
|
impl ContextMenu {
|
||||||
|
|
@ -33,7 +33,7 @@ impl ContextMenu {
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
menu: None,
|
menu: None,
|
||||||
anchor: AnchorCorner::TopLeft,
|
anchor: Corner::TopLeft,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use gpui::{
|
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,
|
DragMoveEvent, Empty, Entity, EventEmitter, FocusHandle, FocusableView,
|
||||||
InteractiveElement as _, IntoElement, ParentElement, Pixels, Render, ScrollHandle,
|
InteractiveElement as _, IntoElement, ParentElement, Pixels, Render, ScrollHandle,
|
||||||
SharedString, StatefulInteractiveElement, Styled, View, ViewContext, VisualContext as _,
|
SharedString, StatefulInteractiveElement, Styled, View, ViewContext, VisualContext as _,
|
||||||
|
|
@ -375,7 +375,7 @@ impl TabPanel {
|
||||||
.menu(t!("Dock.Close"), Box::new(ClosePanel))
|
.menu(t!("Dock.Close"), Box::new(ClosePanel))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.anchor(AnchorCorner::TopRight),
|
.anchor(Corner::TopRight),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ pub trait DropdownDelegate: Sized {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn perform_search(&mut self, _query: &str, _cx: &mut ViewContext<Dropdown<Self>>) -> Task<()> {
|
fn perform_search(&mut self, _query: &str, _cx: &mut ViewContext<Dropdown<Self>>) -> Task<()> {
|
||||||
Task::Ready(Some(()))
|
Task::ready(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,11 +179,9 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn perform_search(&mut self, query: &str, cx: &mut ViewContext<List<Self>>) -> Task<()> {
|
fn perform_search(&mut self, query: &str, cx: &mut ViewContext<List<Self>>) -> Task<()> {
|
||||||
self.dropdown
|
self.dropdown.upgrade().map_or(Task::ready(()), |dropdown| {
|
||||||
.upgrade()
|
dropdown.update(cx, |_, cx| self.delegate.perform_search(query, cx))
|
||||||
.map_or(Task::Ready(None), |dropdown| {
|
})
|
||||||
dropdown.update(cx, |_, cx| self.delegate.perform_search(query, cx))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_selected_index(&mut self, ix: Option<usize>, _: &mut ViewContext<List<Self>>) {
|
fn set_selected_index(&mut self, ix: Option<usize>, _: &mut ViewContext<List<Self>>) {
|
||||||
|
|
@ -284,7 +282,7 @@ impl<T: DropdownItem + Clone> DropdownDelegate for SearchableVec<T> {
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Task::Ready(Some(()))
|
Task::ready(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ pub trait ListDelegate: Sized + 'static {
|
||||||
/// When Query Input change, this method will be called.
|
/// When Query Input change, this method will be called.
|
||||||
/// You can perform search here.
|
/// You can perform search here.
|
||||||
fn perform_search(&mut self, query: &str, cx: &mut ViewContext<List<Self>>) -> Task<()> {
|
fn perform_search(&mut self, query: &str, cx: &mut ViewContext<List<Self>>) -> Task<()> {
|
||||||
Task::Ready(Some(()))
|
Task::ready(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the number of items in the list.
|
/// Return the number of items in the list.
|
||||||
|
|
@ -126,7 +126,7 @@ where
|
||||||
enable_scrollbar: true,
|
enable_scrollbar: true,
|
||||||
loading: false,
|
loading: false,
|
||||||
size: Size::default(),
|
size: Size::default(),
|
||||||
_search_task: Task::Ready(None),
|
_search_task: Task::ready(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, anchored, deferred, div, prelude::FluentBuilder as _, px, AnchorCorner, AnyElement,
|
actions, anchored, deferred, div, prelude::FluentBuilder as _, px, AnyElement, AppContext,
|
||||||
AppContext, Bounds, DismissEvent, DispatchPhase, Element, ElementId, EventEmitter, FocusHandle,
|
Bounds, Corner, DismissEvent, DispatchPhase, Element, ElementId, EventEmitter, FocusHandle,
|
||||||
FocusableView, GlobalElementId, Hitbox, InteractiveElement as _, IntoElement, KeyBinding,
|
FocusableView, GlobalElementId, Hitbox, InteractiveElement as _, IntoElement, KeyBinding,
|
||||||
LayoutId, ManagedView, MouseButton, MouseDownEvent, ParentElement, Pixels, Point, Render,
|
LayoutId, ManagedView, MouseButton, MouseDownEvent, ParentElement, Pixels, Point, Render,
|
||||||
Style, StyleRefinement, Styled, View, ViewContext, VisualContext, WindowContext,
|
Style, StyleRefinement, Styled, View, ViewContext, VisualContext, WindowContext,
|
||||||
|
|
@ -64,7 +64,7 @@ impl Render for PopoverContent {
|
||||||
|
|
||||||
pub struct Popover<M: ManagedView> {
|
pub struct Popover<M: ManagedView> {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
anchor: AnchorCorner,
|
anchor: Corner,
|
||||||
trigger: Option<Box<dyn FnOnce(bool, &WindowContext) -> AnyElement + 'static>>,
|
trigger: Option<Box<dyn FnOnce(bool, &WindowContext) -> AnyElement + 'static>>,
|
||||||
content: Option<Rc<dyn Fn(&mut WindowContext) -> View<M> + 'static>>,
|
content: Option<Rc<dyn Fn(&mut WindowContext) -> View<M> + 'static>>,
|
||||||
/// Style for trigger element.
|
/// Style for trigger element.
|
||||||
|
|
@ -82,7 +82,7 @@ where
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
anchor: AnchorCorner::TopLeft,
|
anchor: Corner::TopLeft,
|
||||||
trigger: None,
|
trigger: None,
|
||||||
trigger_style: None,
|
trigger_style: None,
|
||||||
content: 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.anchor = anchor;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -148,13 +148,12 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolved_corner(&self, bounds: Bounds<Pixels>) -> Point<Pixels> {
|
fn resolved_corner(&self, bounds: Bounds<Pixels>) -> Point<Pixels> {
|
||||||
match self.anchor {
|
bounds.corner(match self.anchor {
|
||||||
AnchorCorner::TopLeft => AnchorCorner::BottomLeft,
|
Corner::TopLeft => Corner::BottomLeft,
|
||||||
AnchorCorner::TopRight => AnchorCorner::BottomRight,
|
Corner::TopRight => Corner::BottomRight,
|
||||||
AnchorCorner::BottomLeft => AnchorCorner::TopLeft,
|
Corner::BottomLeft => Corner::TopLeft,
|
||||||
AnchorCorner::BottomRight => AnchorCorner::TopRight,
|
Corner::BottomRight => Corner::TopRight,
|
||||||
}
|
})
|
||||||
.corner(bounds)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn with_element_state<R>(
|
fn with_element_state<R>(
|
||||||
|
|
@ -268,12 +267,8 @@ impl<M: ManagedView> Element for Popover<M> {
|
||||||
.occlude()
|
.occlude()
|
||||||
.when(!no_style, |this| this.popover_style(cx))
|
.when(!no_style, |this| this.popover_style(cx))
|
||||||
.map(|this| match anchor {
|
.map(|this| match anchor {
|
||||||
AnchorCorner::TopLeft | AnchorCorner::TopRight => {
|
Corner::TopLeft | Corner::TopRight => this.top_1p5(),
|
||||||
this.top_1p5()
|
Corner::BottomLeft | Corner::BottomRight => this.bottom_1p5(),
|
||||||
}
|
|
||||||
AnchorCorner::BottomLeft | AnchorCorner::BottomRight => {
|
|
||||||
this.bottom_1p5()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.child(content_view.clone())
|
.child(content_view.clone())
|
||||||
.when(!no_style, |this| {
|
.when(!no_style, |this| {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use gpui::{
|
||||||
SharedString, View, ViewContext, VisualContext as _, WindowContext,
|
SharedString, View, ViewContext, VisualContext as _, WindowContext,
|
||||||
};
|
};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
anchored, canvas, rems, AnchorCorner, AnyElement, Bounds, Edges, FocusableView, Keystroke,
|
anchored, canvas, rems, AnyElement, Bounds, Corner, Edges, FocusableView, Keystroke,
|
||||||
ScrollHandle, StatefulInteractiveElement, Styled, WeakView,
|
ScrollHandle, StatefulInteractiveElement, Styled, WeakView,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -37,13 +37,13 @@ pub trait PopupMenuExt: Styled + Selectable + IntoElement + 'static {
|
||||||
self,
|
self,
|
||||||
f: impl Fn(PopupMenu, &mut ViewContext<PopupMenu>) -> PopupMenu + 'static,
|
f: impl Fn(PopupMenu, &mut ViewContext<PopupMenu>) -> PopupMenu + 'static,
|
||||||
) -> Popover<PopupMenu> {
|
) -> Popover<PopupMenu> {
|
||||||
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
|
/// Create a popup menu with the given items, anchored to the given corner
|
||||||
fn popup_menu_with_anchor(
|
fn popup_menu_with_anchor(
|
||||||
mut self,
|
mut self,
|
||||||
anchor: impl Into<AnchorCorner>,
|
anchor: impl Into<Corner>,
|
||||||
f: impl Fn(PopupMenu, &mut ViewContext<PopupMenu>) -> PopupMenu + 'static,
|
f: impl Fn(PopupMenu, &mut ViewContext<PopupMenu>) -> PopupMenu + 'static,
|
||||||
) -> Popover<PopupMenu> {
|
) -> Popover<PopupMenu> {
|
||||||
let style = self.style().clone();
|
let style = self.style().clone();
|
||||||
|
|
@ -649,13 +649,10 @@ impl Render for PopupMenu {
|
||||||
- bounds.origin.x
|
- bounds.origin.x
|
||||||
< max_width
|
< max_width
|
||||||
{
|
{
|
||||||
(
|
(Corner::TopRight, -px(15.))
|
||||||
AnchorCorner::TopRight,
|
|
||||||
-px(15.),
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
(
|
(
|
||||||
AnchorCorner::TopLeft,
|
Corner::TopLeft,
|
||||||
bounds.size.width
|
bounds.size.width
|
||||||
- px(10.),
|
- px(10.),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -261,7 +261,7 @@ impl Element for VirtualList {
|
||||||
|
|
||||||
let padded_bounds = Bounds::from_corners(
|
let padded_bounds = Bounds::from_corners(
|
||||||
bounds.origin + point(border.left + padding.left, border.top + padding.top),
|
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),
|
- point(border.right + padding.right, border.bottom + padding.bottom),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -297,7 +297,7 @@ impl Element for VirtualList {
|
||||||
|
|
||||||
let padded_bounds = Bounds::from_corners(
|
let padded_bounds = Bounds::from_corners(
|
||||||
bounds.origin + point(border.left + padding.left, border.top),
|
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 {
|
if self.items_count > 0 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue