gpui: bump dependency pin to latest main

This commit is contained in:
2026-11-16 09:46:45 +07:00
parent 5d28046d4a
commit 1df87c65a1
7 changed files with 106 additions and 112 deletions
+2 -2
View File
@@ -87,6 +87,6 @@ select = ["menu"]
dialog = ["button", "scroll_area", "grain"]
empty_state = []
grain = ["dep:image"]
alert = []
toast = []
alert = ["button"]
toast = ["button"]
speech = ["spinner", "tooltip", "dep:flume", "dep:cpal"]
+6 -10
View File
@@ -8,8 +8,8 @@ use gpui::prelude::FluentBuilder as _;
use gpui::{
Animation, AnimationElement, AnimationExt as _, App, Canvas, ElementId, Hsla,
InteractiveElement as _, IntoElement, ParentElement as _, Path, PathBuilder, Pixels, Point,
RenderOnce, Role, SharedString, StatefulInteractiveElement as _, Styled as _, Transformation,
Window, canvas, div, percentage, point, px,
RenderOnce, Role, SharedString, StatefulInteractiveElement as _, Styled as _, Window, canvas,
div, point, px,
};
use gpui_native_icons::{Icon, IconRole, icon};
use gpui_native_theme::{ActiveTheme as _, SPINNER_PERIOD, Size};
@@ -184,15 +184,11 @@ fn spinning_ring(side: Pixels, stroke: Pixels, accent: Hsla) -> AnimationElement
)
}
fn spinning_icon(side: Pixels, accent: Hsla) -> AnimationElement<Icon> {
fn spinning_icon(side: Pixels, accent: Hsla) -> Icon {
icon(IconRole::Loader)
.size(side)
.color(accent)
.with_animation(
"spin",
Animation::new(SPINNER_PERIOD).repeat().with_max_fps(60.),
|glyph, delta| glyph.with_transformation(Transformation::rotate(percentage(delta))),
)
.with_rotation_animation(SPINNER_PERIOD)
}
fn paint_circle(
@@ -222,7 +218,7 @@ fn arc_path(
stroke: Pixels,
start: f32,
sweep: f32,
) -> Option<Path<Pixels>> {
) -> Option<Path> {
let mut builder = PathBuilder::stroke(stroke);
builder.move_to(ring_point(center, radius, start));
builder.arc_to(
@@ -236,7 +232,7 @@ fn arc_path(
}
/// A stroked full circle; `None` on degenerate geometry.
fn circle_path(center: Point<Pixels>, radius: Pixels, stroke: Pixels) -> Option<Path<Pixels>> {
fn circle_path(center: Point<Pixels>, radius: Pixels, stroke: Pixels) -> Option<Path> {
let mut builder = PathBuilder::stroke(stroke);
builder.move_to(ring_point(center, radius, 0.0));
builder.arc_to(
+36 -5
View File
@@ -2,10 +2,12 @@
//! and the crate resolves each role to a glyph for the current platform.
//! Apps ship their own icon set by implementing [`IconNamed`].
use std::time::Duration;
use gpui::prelude::FluentBuilder as _;
use gpui::{
AnyElement, AssetSource, Hsla, IntoElement, ParentElement as _, Pixels, RenderOnce,
SharedString, Styled as _, Transformation, Window, div, px, svg,
SharedString, Styled as _, TimedTransformation, Transformation, Window, div, px, svg,
};
#[cfg_attr(not(target_os = "linux"), allow(dead_code))]
@@ -16,6 +18,8 @@ mod segoe;
const SMALL_ICON_SIZE: Pixels = px(14.0);
const DEFAULT_ICON_SIZE: Pixels = px(16.0);
const LARGE_ICON_SIZE: Pixels = px(20.0);
/// The spin presents at most this rate, rotating a sprite needs no more frames.
const SPIN_MAX_FPS: f32 = 60.0;
/// The semantic glyphs UI components need.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -539,6 +543,7 @@ pub struct Icon {
size: Pixels,
color: Option<Hsla>,
transformation: Option<Transformation>,
rotation_period: Option<Duration>,
}
/// Creates an icon for the role at the default size.
@@ -548,6 +553,7 @@ pub fn icon(role: IconRole) -> Icon {
size: DEFAULT_ICON_SIZE,
color: None,
transformation: None,
rotation_period: None,
}
}
@@ -562,6 +568,7 @@ impl Icon {
size: DEFAULT_ICON_SIZE,
color: None,
transformation: None,
rotation_period: None,
}
}
@@ -593,12 +600,18 @@ impl Icon {
self
}
/// An extra SVG transformation, e.g. a spinner's rotation.
/// An extra static SVG transformation.
pub fn with_transformation(mut self, transformation: Transformation) -> Self {
self.transformation = Some(transformation);
self
}
/// Spins the icon clockwise, one full turn per `period`.
pub fn with_rotation_animation(mut self, period: Duration) -> Self {
self.rotation_period = Some(period);
self
}
/// The asset key a resolved freedesktop file is served under.
#[cfg(target_os = "linux")]
fn freedesktop_asset_path(size: Pixels, role: &IconRole) -> Option<SharedString> {
@@ -611,6 +624,7 @@ impl Icon {
size: Pixels,
color: Option<Hsla>,
transformation: Option<Transformation>,
rotation_period: Option<Duration>,
role: IconRole,
) -> AnyElement {
#[cfg(target_os = "windows")]
@@ -619,12 +633,14 @@ impl Icon {
}
#[cfg(target_os = "linux")]
if let Some(path) = Self::freedesktop_asset_path(size, &role) {
return Self::render_svg_path(size, color, transformation, path).into_any_element();
return Self::render_svg_path(size, color, transformation, rotation_period, path)
.into_any_element();
}
Self::render_svg_path(
size,
color,
transformation,
rotation_period,
SharedString::from(role.asset_path()),
)
.into_any_element()
@@ -653,6 +669,7 @@ impl Icon {
size: Pixels,
color: Option<Hsla>,
transformation: Option<Transformation>,
rotation_period: Option<Duration>,
path: SharedString,
) -> AnyElement {
div()
@@ -665,6 +682,15 @@ impl Icon {
.when_some(color, |el, color| el.text_color(color))
.when_some(transformation, |el, transformation| {
el.with_transformation(transformation)
})
.when_some(rotation_period, |el, period| {
el.with_timed_transformation(
TimedTransformation::rotation(
period,
transformation.unwrap_or_default(),
)
.with_max_fps(SPIN_MAX_FPS),
)
}),
)
.into_any_element()
@@ -687,13 +713,18 @@ impl RenderOnce for Icon {
size,
color,
transformation,
rotation_period,
} = self;
let color = color.unwrap_or_else(|| window.text_style().color);
match glyph {
Glyph::Named(path) => Self::render_svg_path(size, Some(color), transformation, path),
Glyph::Role(role) => Self::render_role(size, Some(color), transformation, role),
Glyph::Named(path) => {
Self::render_svg_path(size, Some(color), transformation, rotation_period, path)
}
Glyph::Role(role) => {
Self::render_role(size, Some(color), transformation, rotation_period, role)
}
}
}
}
+2 -1
View File
@@ -124,7 +124,8 @@ fn dragging_the_divider_resizes_the_panels(cx: &mut TestAppContext) {
.expect("main panel laid out");
// Press the divider between the islands and drag it 100px to the right.
let seam = point(before.right() + px(13.0), px(400.0));
let handle = cx.debug_bounds("resize-handle").expect("divider laid out");
let seam = point(handle.center().x, px(400.0));
cx.simulate_event(MouseDownEvent {
position: seam,
button: MouseButton::Left,