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
+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)
}
}
}
}