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:
2026-11-17 09:49:10 +07:00
parent 71f4ec0b6b
commit 8f96a2cc16
80 changed files with 1524 additions and 2037 deletions
-153
View File
@@ -274,156 +274,3 @@ fn active_theme() -> String {
fn base_dirs() -> Vec<PathBuf> {
Vec::new()
}
#[cfg(test)]
mod tests {
use super::*;
fn scratch(name: &str) -> PathBuf {
let root =
std::env::temp_dir().join(format!("gpui-native-icons-{name}-{}", std::process::id()));
// NotFound is the expected first run; anything else is a setup failure.
if let Err(error) = std::fs::remove_dir_all(&root)
&& error.kind() != std::io::ErrorKind::NotFound
{
panic!("failed to clear scratch dir {root:?}: {error}");
}
std::fs::create_dir_all(&root).expect("scratch dir");
root
}
fn write(path: &Path, contents: &str) {
std::fs::create_dir_all(path.parent().expect("parent")).expect("dirs");
std::fs::write(path, contents).expect("write");
}
#[test]
fn the_theme_beats_hicolor() {
let base = scratch("precedence");
write(
&base.join("mytheme/scalable/actions/object-select-symbolic.svg"),
"<svg/>",
);
write(
&base.join("hicolor/scalable/actions/object-select-symbolic.svg"),
"<svg/>",
);
assert_eq!(
lookup(
&["object-select-symbolic"],
"mytheme",
16,
std::slice::from_ref(&base)
),
Some(base.join("mytheme/scalable/actions/object-select-symbolic.svg"))
);
std::fs::remove_dir_all(&base).expect("cleanup");
}
#[test]
fn a_missing_glyph_falls_through_to_hicolor() {
let base = scratch("hicolor");
write(&base.join("hicolor/24/actions/search.svg"), "<svg/>");
assert_eq!(
lookup(&["search"], "breeze", 24, std::slice::from_ref(&base)),
Some(base.join("hicolor/24/actions/search.svg"))
);
std::fs::remove_dir_all(&base).expect("cleanup");
}
#[test]
fn the_inherits_chain_is_walked() {
let base = scratch("inherits");
write(&base.join("parent/scalable/actions/add.svg"), "<svg/>");
write(
&base.join("child/index.theme"),
"[Icon Theme]\nInherits=parent\n",
);
assert_eq!(
lookup(&["add"], "child", 16, std::slice::from_ref(&base)),
Some(base.join("parent/scalable/actions/add.svg"))
);
std::fs::remove_dir_all(&base).expect("cleanup");
}
#[test]
fn scalable_wins_and_the_closest_size_wins_without_it() {
let base = scratch("sizes");
write(&base.join("theme/16x16/actions/check.svg"), "<svg/>");
write(&base.join("theme/48x48/actions/check.svg"), "<svg/>");
write(&base.join("theme/scalable/actions/check.svg"), "<svg/>");
assert_eq!(
lookup(&["check"], "theme", 16, std::slice::from_ref(&base)),
Some(base.join("theme/scalable/actions/check.svg"))
);
let base = scratch("sizes-plain");
write(&base.join("theme/16x16/actions/check.svg"), "<svg/>");
write(&base.join("theme/48x48/actions/check.svg"), "<svg/>");
assert_eq!(
lookup(&["check"], "theme", 16, std::slice::from_ref(&base)),
Some(base.join("theme/16x16/actions/check.svg"))
);
std::fs::remove_dir_all(&base).expect("cleanup");
}
#[test]
fn both_theme_layouts_are_searched() {
let adwaita = scratch("layout-adwaita");
write(&adwaita.join("theme/scalable/actions/check.svg"), "<svg/>");
assert_eq!(
lookup(&["check"], "theme", 16, std::slice::from_ref(&adwaita)),
Some(adwaita.join("theme/scalable/actions/check.svg"))
);
let breeze = scratch("layout-breeze");
write(&breeze.join("theme/actions/16/check.svg"), "<svg/>");
assert_eq!(
lookup(&["check"], "theme", 16, std::slice::from_ref(&breeze)),
Some(breeze.join("theme/actions/16/check.svg"))
);
std::fs::remove_dir_all(&adwaita).expect("cleanup");
std::fs::remove_dir_all(&breeze).expect("cleanup");
}
#[test]
fn png_only_themes_are_skipped() {
let base = scratch("png");
write(&base.join("theme/16x16/actions/check.png"), "png");
assert_eq!(
lookup(&["check"], "theme", 16, std::slice::from_ref(&base)),
None
);
std::fs::remove_dir_all(&base).expect("cleanup");
}
#[test]
fn a_themes_second_candidate_beats_hicolors_first() {
let base = scratch("candidates");
write(
&base.join("mytheme/scalable/actions/emblem-ok-symbolic.svg"),
"<svg/>",
);
write(
&base.join("hicolor/scalable/actions/object-select-symbolic.svg"),
"<svg/>",
);
assert_eq!(
lookup(
&["object-select-symbolic", "emblem-ok-symbolic"],
"mytheme",
16,
std::slice::from_ref(&base)
),
Some(base.join("mytheme/scalable/actions/emblem-ok-symbolic.svg"))
);
std::fs::remove_dir_all(&base).expect("cleanup");
}
}
-28
View File
@@ -865,31 +865,3 @@ impl AssetSource for Assets {
.collect())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn every_role_has_a_unique_slug() {
for (index, role) in IconRole::all().iter().enumerate() {
for other in &IconRole::all()[index + 1..] {
assert_ne!(
role.slug(),
other.slug(),
"{role:?} and {other:?} share a slug"
);
}
}
}
#[test]
fn every_role_resolves_to_a_bundled_asset() {
for role in IconRole::all() {
assert!(
asset_bytes(role.asset_path()).is_some(),
"missing bundled asset for {role:?}"
);
}
}
}
-15
View File
@@ -107,18 +107,3 @@ pub(crate) fn glyph(role: IconRole) -> Option<&'static str> {
/// The system font the codepoints resolve against (Windows 11+).
pub(crate) const FONT_FAMILY: &str = "Segoe Fluent Icons";
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn every_role_maps_a_codepoint_or_falls_back_to_the_bundled_svg() {
for role in crate::icons::IconRole::all() {
assert!(
glyph(*role).is_some() || crate::icons::asset_bytes(role.asset_path()).is_some(),
"no Segoe codepoint or bundled asset for {role:?}"
);
}
}
}