Re-vendor the native UI kit at 278430d
- Upstream merged core, data, editor, and utils into a single `components` crate: `ui::button`, `ui::tabs`, `ui::code`, `ui::tree`, `ui::sidebar` are flat, and `h_flex`/`v_flex`/`StyledExt` live in `ui::common` and `ui::layout`. - Adopts the new wrapper-less component module tree, the merged theme/icon updates, and the relocated editor grammars. - Titlebar repo tabs use the new `TabsVariant::Titlebar` capsule sizing. - Doc examples now import from `ui::`, so all 44 doctests compile; the clipboard sample no longer names the kit crate. - docs/ui-gaps.md records that `ui` has no dock/view-registry API instead of the deleted `DockState`.
This commit is contained in:
@@ -1,6 +1,28 @@
|
||||
//! Renders a floating panel anchored below its trigger, closed by outside
|
||||
//! clicks and Escape.
|
||||
//!
|
||||
//! # Examples
|
||||
//!
|
||||
//! ```no_run
|
||||
//! use gpui::{IntoElement as _, ParentElement as _, SharedString, div};
|
||||
//! use ui::popover::Popover;
|
||||
//!
|
||||
//! let popover = Popover::new("options")
|
||||
//! .trigger(|_window, _cx| {
|
||||
//! div().child(SharedString::from("Options")).into_any_element()
|
||||
//! })
|
||||
//! .content(|_window, _cx| {
|
||||
//! div()
|
||||
//! .child(SharedString::from("Panel body"))
|
||||
//! .into_any_element()
|
||||
//! })
|
||||
//! .on_change(|open, _window, _cx| println!("open: {open}"));
|
||||
//! ```
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::theme::{ActiveTheme as _, POPOVER_MIN_WIDTH};
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
Animation, AnimationExt as _, AnyElement, App, Bounds, DispatchPhase, ElementId,
|
||||
@@ -10,11 +32,12 @@ use gpui::{
|
||||
};
|
||||
|
||||
use crate::components::common::{OVERLAY_LAYER, StyledExt as _, v_flex};
|
||||
use crate::theme::{ActiveTheme as _, POPOVER_MIN_WIDTH};
|
||||
|
||||
/// Reports the next open state of a [`Popover`]: `true` to open, `false` to close.
|
||||
type ChangeHandler = Rc<dyn Fn(bool, &mut Window, &mut App)>;
|
||||
/// The element the panel anchors below, built during render.
|
||||
type TriggerFn = Box<dyn FnOnce(&mut Window, &mut App) -> AnyElement>;
|
||||
/// The panel's contents, built when it opens.
|
||||
type ContentFn = Box<dyn FnOnce(&mut Window, &mut App) -> AnyElement>;
|
||||
/// Bounds captured during the last paint, shared with the dismissal listener.
|
||||
type BoundsCell = Rc<RefCell<Option<Bounds<Pixels>>>>;
|
||||
@@ -171,7 +194,7 @@ impl RenderOnce for Popover {
|
||||
.when(self.open, |wrapper| {
|
||||
let on_change = self.on_change;
|
||||
let label = fallback_label.clone();
|
||||
let focus = crate::utils::focus_handle(&self.id, window, cx);
|
||||
let focus = crate::components::common::focus_handle(&self.id, window, cx);
|
||||
let content = self.content.map(|content| content(window, cx));
|
||||
|
||||
let panel = v_flex()
|
||||
|
||||
Reference in New Issue
Block a user