Render library: Appearances card with a sphere grid, scopes, favourites and recents (#6429)

This commit is contained in:
Nathan Dane
2026-10-28 13:41:24 +00:00
committed by GitHub
parent 9bcb2ffe68
commit 2897d3b22e
21 changed files with 1694 additions and 222 deletions
@@ -0,0 +1,236 @@
{
"en": {
"render.appearances": "Appearances",
"render.category_metal": "Metal",
"render.category_paint": "Paint",
"render.category_plastic": "Plastic",
"render.category_wood": "Wood",
"render.environment_tiles_require_raytrace": "Environments require CPU or GPU ray tracing. Select it in the Output editor.",
"render.frame_presets": "Frame presets",
"render.frame_presets_pending": "Arrives with the Shot editor",
"render.library_appearance_available": "Available appearance",
"render.library_applicable": "Applicable resources",
"render.library_apply_appearance": "Apply appearance",
"render.library_apply_hint": "Click to apply · drag onto the model",
"render.library_filters": "Catalog and availability",
"render.library_grid": "Grid",
"render.library_in_design": "In Design",
"render.library_ior": "IOR",
"render.library_list": "List",
"render.library_metallic": "Metallic",
"render.library_opacity": "Opacity",
"render.library_other": "Other appearances",
"render.library_roughness": "Roughness",
"render.library_users": "Users",
"render.search_appearances": "Search {count} appearances",
"render.size_presets": "Size presets",
"render.size_presets_pending": "Arrives with the Output editor",
"render.studio_tiles_require_gpu": "Studios require GPU path tracing. Select GPU in the Output editor.",
"render.studios_environments": "Studios and Environments"
},
"de": {
"render.appearances": "Erscheinungsbilder",
"render.category_metal": "Metall",
"render.category_paint": "Lack",
"render.category_plastic": "Kunststoff",
"render.category_wood": "Holz",
"render.environment_tiles_require_raytrace": "Umgebungen benötigen CPU- oder GPU-Raytracing. Im Ausgabeeditor wählen.",
"render.frame_presets": "Bildvorlagen",
"render.frame_presets_pending": "Kommt mit dem Aufnahmeeditor",
"render.library_appearance_available": "Verfügbares Erscheinungsbild",
"render.library_applicable": "Passende Ressourcen",
"render.library_apply_appearance": "Erscheinungsbild anwenden",
"render.library_apply_hint": "Klicken zum Anwenden · auf das Modell ziehen",
"render.library_filters": "Katalog und Verfügbarkeit",
"render.library_grid": "Raster",
"render.library_in_design": "Im Design",
"render.library_inspect_only": "Zum Prüfen wählen · Im Inspektor anwenden",
"render.library_ior": "Brechungsindex",
"render.library_list": "Liste",
"render.library_metallic": "Metallisch",
"render.library_opacity": "Deckkraft",
"render.library_other": "Weitere Erscheinungsbilder",
"render.library_roughness": "Rauheit",
"render.library_users": "Verwendungen",
"render.search_appearances": "{count} Erscheinungsbilder durchsuchen",
"render.size_presets": "Größenvorlagen",
"render.size_presets_pending": "Kommt mit dem Ausgabeeditor",
"render.studio_tiles_require_gpu": "Studios benötigen GPU-Pfadverfolgung. Im Ausgabeeditor GPU wählen.",
"render.studios_environments": "Studios und Umgebungen"
},
"ja": {
"render.appearances": "外観",
"render.category_metal": "金属",
"render.category_paint": "塗装",
"render.category_plastic": "プラスチック",
"render.category_wood": "木材",
"render.environment_tiles_require_raytrace": "環境には CPU または GPU レイトレーシングが必要です。出力エディターで選択してください。",
"render.frame_presets": "構図プリセット",
"render.frame_presets_pending": "ショットエディターとともに追加予定",
"render.library_appearance_available": "利用可能な外観",
"render.library_applicable": "適用に適したリソース",
"render.library_apply_appearance": "外観を適用",
"render.library_apply_hint": "クリックで適用 · モデルにドラッグ",
"render.library_filters": "カタログと利用状況",
"render.library_grid": "グリッド",
"render.library_in_design": "デザイン内",
"render.library_ior": "屈折率",
"render.library_list": "リスト",
"render.library_metallic": "金属度",
"render.library_opacity": "不透明度",
"render.library_other": "その他の外観",
"render.library_roughness": "粗さ",
"render.library_users": "使用箇所",
"render.search_appearances": "{count} 件の外観を検索",
"render.size_presets": "サイズプリセット",
"render.size_presets_pending": "出力エディターとともに追加予定",
"render.studio_tiles_require_gpu": "スタジオには GPU パストレーシングが必要です。出力エディターで GPU を選択してください。",
"render.studios_environments": "スタジオと環境"
},
"zh": {
"render.appearances": "外观",
"render.category_metal": "金属",
"render.category_paint": "涂漆",
"render.category_plastic": "塑料",
"render.category_wood": "木材",
"render.environment_tiles_require_raytrace": "环境需要 CPU 或 GPU 光线追踪。请在输出编辑器中选择。",
"render.frame_presets": "构图预设",
"render.frame_presets_pending": "随镜头编辑器推出",
"render.library_appearance_available": "可用外观",
"render.library_applicable": "适用资源",
"render.library_apply_appearance": "应用外观",
"render.library_apply_hint": "点击应用 · 拖到模型上",
"render.library_filters": "目录与可用性",
"render.library_grid": "网格",
"render.library_in_design": "设计中",
"render.library_ior": "折射率",
"render.library_list": "列表",
"render.library_metallic": "金属度",
"render.library_opacity": "不透明度",
"render.library_other": "其他外观",
"render.library_roughness": "粗糙度",
"render.library_users": "使用位置",
"render.search_appearances": "搜索 {count} 种外观",
"render.size_presets": "尺寸预设",
"render.size_presets_pending": "随输出编辑器推出",
"render.studio_tiles_require_gpu": "摄影棚需要 GPU 路径追踪。请在输出编辑器中选择 GPU。",
"render.studios_environments": "摄影棚和环境"
},
"ko": {
"render.appearances": "외관",
"render.category_metal": "금속",
"render.category_paint": "페인트",
"render.category_plastic": "플라스틱",
"render.category_wood": "목재",
"render.environment_tiles_require_raytrace": "환경에는 CPU 또는 GPU 광선 추적이 필요합니다. 출력 편집기에서 선택하세요.",
"render.frame_presets": "구도 프리셋",
"render.frame_presets_pending": "샷 편집기와 함께 제공 예정",
"render.library_appearance_available": "사용 가능한 외관",
"render.library_applicable": "적용 가능한 리소스",
"render.library_apply_appearance": "외관 적용",
"render.library_apply_hint": "클릭하여 적용 · 모델로 드래그",
"render.library_filters": "카탈로그 및 사용 가능 여부",
"render.library_grid": "격자",
"render.library_in_design": "디자인 내",
"render.library_inspect_only": "선택하여 확인 · 검사기에서 적용",
"render.library_ior": "굴절률",
"render.library_list": "목록",
"render.library_metallic": "금속성",
"render.library_opacity": "불투명도",
"render.library_other": "기타 외관",
"render.library_roughness": "거칠기",
"render.library_users": "사용 위치",
"render.search_appearances": "외관 {count}개 검색",
"render.size_presets": "크기 프리셋",
"render.size_presets_pending": "출력 편집기와 함께 제공 예정",
"render.studio_tiles_require_gpu": "스튜디오에는 GPU 경로 추적이 필요합니다. 출력 편집기에서 GPU를 선택하세요.",
"render.studios_environments": "스튜디오 및 환경"
},
"ar": {
"render.appearances": "المظاهر",
"render.category_metal": "معدن",
"render.category_paint": "طلاء",
"render.category_plastic": "بلاستيك",
"render.category_wood": "خشب",
"render.environment_tiles_require_raytrace": "تتطلب البيئات تتبّع الأشعة على المعالج أو بطاقة الرسومات. اخترْه في محرر المخرجات.",
"render.frame_presets": "إعدادات مسبقة للإطار",
"render.frame_presets_pending": "تصل مع محرر اللقطة",
"render.library_appearance_available": "مظهر متاح",
"render.library_applicable": "الموارد القابلة للتطبيق",
"render.library_apply_appearance": "تطبيق المظهر",
"render.library_apply_hint": "انقر للتطبيق · اسحب إلى النموذج",
"render.library_filters": "الفهرس والتوفر",
"render.library_grid": "شبكة",
"render.library_in_design": "في التصميم",
"render.library_ior": "معامل الانكسار",
"render.library_list": "قائمة",
"render.library_metallic": "معدنية",
"render.library_opacity": "العتامة",
"render.library_other": "مظاهر أخرى",
"render.library_roughness": "الخشونة",
"render.library_users": "المستخدمون",
"render.search_appearances": "ابحث في {count} مظهرًا",
"render.size_presets": "إعدادات الحجم المسبقة",
"render.size_presets_pending": "تصل مع محرر المخرجات",
"render.studio_tiles_require_gpu": "تتطلب الاستوديوهات تتبّع المسار على بطاقة الرسومات. اخترْ GPU في محرر المخرجات.",
"render.studios_environments": "الاستوديوهات والبيئات"
},
"he": {
"render.appearances": "מראות",
"render.category_metal": "מתכת",
"render.category_paint": "צבע",
"render.category_plastic": "פלסטיק",
"render.category_wood": "עץ",
"render.environment_tiles_require_raytrace": "סביבות דורשות מעקב קרניים במעבד או בכרטיס המסך. בחר זאת בעורך הפלט.",
"render.frame_presets": "הגדרות מסגרת מוכנות",
"render.frame_presets_pending": "יגיע עם עורך הצילום",
"render.library_appearance_available": "מראה זמין",
"render.library_applicable": "משאבים ישימים",
"render.library_apply_appearance": "החל מראה",
"render.library_apply_hint": "לחץ להחלה · גרור אל המודל",
"render.library_filters": "קטלוג וזמינות",
"render.library_grid": "רשת",
"render.library_in_design": "בתכנון",
"render.library_ior": "מקדם שבירה",
"render.library_list": "רשימה",
"render.library_metallic": "מתכתיות",
"render.library_opacity": "אטימות",
"render.library_other": "מראות אחרים",
"render.library_roughness": "חספוס",
"render.library_users": "משתמשים",
"render.search_appearances": "חפש בין {count} מראות",
"render.size_presets": "הגדרות גודל מוכנות",
"render.size_presets_pending": "יגיע עם עורך הפלט",
"render.studio_tiles_require_gpu": "סטודיו דורש מעקב נתיב במעבד הגרפי. בחר GPU בעורך הפלט.",
"render.studios_environments": "סטודיו וסביבות"
},
"vi": {
"render.appearances": "Diện mạo",
"render.category_metal": "Kim loại",
"render.category_paint": "Sơn",
"render.category_plastic": "Nhựa",
"render.category_wood": "Gỗ",
"render.environment_tiles_require_raytrace": "Môi trường cần dò tia trên CPU hoặc GPU. Chọn trong trình chỉnh Đầu ra.",
"render.frame_presets": "Khung đặt sẵn",
"render.frame_presets_pending": "Sẽ có cùng trình chỉnh cảnh chụp",
"render.library_appearance_available": "Diện mạo khả dụng",
"render.library_applicable": "Tài nguyên áp dụng được",
"render.library_apply_appearance": "Áp dụng diện mạo",
"render.library_apply_hint": "Bấm để áp dụng · kéo vào mô hình",
"render.library_filters": "Danh mục và tình trạng sẵn có",
"render.library_grid": "Lưới",
"render.library_in_design": "Trong thiết kế",
"render.library_ior": "Chiết suất",
"render.library_list": "Danh sách",
"render.library_metallic": "Độ kim loại",
"render.library_opacity": "Độ đục",
"render.library_other": "Diện mạo khác",
"render.library_roughness": "Độ nhám",
"render.library_users": "Người dùng",
"render.search_appearances": "Tìm trong {count} diện mạo",
"render.size_presets": "Cỡ đặt sẵn",
"render.size_presets_pending": "Sẽ có cùng trình chỉnh Đầu ra",
"render.studio_tiles_require_gpu": "Studio cần dò đường đi của tia bằng GPU. Chọn GPU trong trình chỉnh Đầu ra.",
"render.studios_environments": "Studio và môi trường"
}
}
+7 -1
View File
@@ -882,6 +882,7 @@ fn render_card(app: &mut SolveApp, ui: &mut egui::Ui, acts: &mut Actions) {
if narrow && !app.shell.render_browser_open {
app.shell.browser = None;
crate::shell::register_panel(app, "render:browser", None, None);
crate::shell::register_panel(app, "render:appearances", None, None);
crate::render_ui::dock_chip(app, ui, "render:browser:show", "ui.browser_title", "view.render_browser", json!({"open":true}));
return;
}
@@ -898,9 +899,11 @@ fn render_card(app: &mut SolveApp, ui: &mut egui::Ui, acts: &mut Actions) {
id: "render:browser",
title: &title,
icon: "list",
bounds,
bounds: crate::ui_kit::Panel::stack_first_bounds(bounds),
fill_height: true,
compact: crate::render_ui::compact(app, bounds.width()),
enabled: true,
header_actions: None,
},
&mut side,
&mut width,
@@ -944,6 +947,9 @@ fn render_card(app: &mut SolveApp, ui: &mut egui::Ui, acts: &mut Actions) {
);
if let Some(rect) = rect {
crate::scenario::publish_rect("browser:card", rect);
crate::render_workspace::appearances_card(app, ui, crate::ui_kit::Panel::stack_next_bounds(bounds, rect));
} else {
crate::shell::register_panel(app, "render:appearances", None, None);
}
}
@@ -147,6 +147,8 @@ const ALLOWED_LITERALS: &[(&str, usize, &str)] = &[
("dialogs_appearance.rs", 1, "a design appearance: the colour is the fact"),
("dialogs_save_mesh.rs", 1, "an installed slicer's own icon, drawn untinted"),
("dialogs_library.rs", 1, "a library appearance's swatch: the colour is the fact"),
("render_ui/scene.rs", 2, "Browser appearance swatches: the colours are document data"),
("render_workspace_library.rs", 1, "a catalog appearance preview: the colour is authored data"),
("render_workspace_materials.rs", 1, "an authored material swatch: the displayed colour is the material data"),
("dialogs_assembly.rs", 1, "the interference fill, shaded from its token"),
("dialogs_motion.rs", 1, "a white outline"),
+11
View File
@@ -710,6 +710,17 @@ mod tests {
"render.tree_browser",
"render.tree_search",
"render.tree_more",
"render.studios_environments",
"render.frame_presets",
"render.size_presets",
"render.frame_presets_pending",
"render.size_presets_pending",
"render.search_appearances",
"render.library_applicable",
"render.library_other",
"render.library_apply_hint",
"render.studio_tiles_require_gpu",
"render.environment_tiles_require_raytrace",
] {
assert_ne!(locale.text(id), Locale::for_language("en").text(id), "{language}: {id}");
}
+1
View File
@@ -2342,6 +2342,7 @@ impl SolveApp {
if !self.ui.show_browser || render_ui::focused(self) {
self.shell.browser = None;
shell::register_panel(self, "render:browser", None, None);
shell::register_panel(self, "render:appearances", None, None);
}
if floating || left_timeline || !show_timeline {
self.shell.history = None;
+6
View File
@@ -881,6 +881,9 @@ preference_settings! {
render_inspector_width: f32 = 305.0;
render_browser_side: String = "left".into();
render_browser_width: f32 = 266.0;
/// Resource identities and history belong to the user, never the design.
render_library_favorites: std::collections::BTreeSet<(String, String)> = Default::default();
render_library_recent: std::collections::VecDeque<(String, String)> = Default::default();
/// Draw the parts browser on a translucent card over the 3D view instead of a column of its
/// own, so the workspace keeps the whole window width.
browser_float: bool = false, PAGE_INTERFACE;
@@ -2670,6 +2673,9 @@ pub fn migrate(mut p: Prefs) -> Prefs {
if p.agent_chat_turn_limit == crate::agent_chat::gate::OLD_DEFAULT_TURN_LIMIT {
p.agent_chat_turn_limit = 0;
}
let valid_resource = |(kind, id): &(String, String)| !kind.is_empty() && kind.len() <= 64 && !id.is_empty() && id.len() <= 4096;
p.render_library_favorites = p.render_library_favorites.into_iter().filter(valid_resource).take(256).collect();
p.render_library_recent = p.render_library_recent.into_iter().filter(valid_resource).take(32).collect();
if p.orbit_cursor {
p.orbit_around = OrbitAround::Cursor;
p.orbit_cursor = false;
+6 -8
View File
@@ -625,11 +625,9 @@ pub(crate) fn apply_browser_controls(app: &mut SolveApp, value: &serde_json::Val
let view = &mut app.render_workspace.view;
if let Some(by_look) = value.get("by_look").and_then(serde_json::Value::as_bool) {
view.by_look = by_look;
view.inspector.library_open = false;
}
if let Some(search) = value.get("search").and_then(serde_json::Value::as_bool) {
view.search_objects = search;
view.inspector.library_open = false;
}
if let Some(query) = value.get("query").and_then(serde_json::Value::as_str) {
view.object_query = query.into();
@@ -649,12 +647,12 @@ pub(crate) fn browser_mode(app: &mut SolveApp, ui: &mut egui::Ui) -> bool {
}
});
}
if app.render_workspace.view.inspector.library_open {
crate::ui_kit::scope(ui, |ui| library::browse(app, ui));
true
} else {
false
}
false
}
/// Per-stage companion sharing the Browser's dock policy.
pub(crate) fn appearances_card(app: &mut SolveApp, ui: &mut egui::Ui, bounds: egui::Rect) {
library::card(app, ui, bounds);
}
fn image_host(app: &SolveApp, method: ImageMethod) -> Result<&ImageHost, String> {
@@ -86,7 +86,6 @@ pub(super) struct View {
pub effects: super::effects::View,
pub page: Page,
reveal: Option<&'static str>,
pub library_open: bool,
pending: Option<Pending>,
shot_name: String,
scene_review: Option<Review>,
@@ -192,7 +191,6 @@ impl Default for View {
effects: Default::default(),
page: Page::Scene,
reveal: None,
library_open: false,
pending: None,
shot_name: String::new(),
scene_review: None,
@@ -234,6 +232,8 @@ pub(super) fn panel(app: &mut SolveApp, ui: &mut egui::Ui) {
bounds,
fill_height: true,
compact: crate::render_ui::compact(app, bounds.width()),
enabled: true,
header_actions: None,
},
&mut side,
&mut width,
File diff suppressed because it is too large Load Diff
+32 -8
View File
@@ -2917,7 +2917,7 @@ fn render_workspace_stage_shell_degrades_without_overlap_at_small_window_sizes()
["render:browser", "render:inspector"].iter().filter_map(|id| h.app.shell.workspace_panels.get(id).map(|(r, _)| *r)).collect();
if let [browser, inspector] = docks.as_slice() {
assert!((browser.top() - inspector.top()).abs() < 1.0);
assert!((browser.bottom() - inspector.bottom()).abs() < 1.0);
assert!(browser.bottom() < inspector.bottom());
assert!(!browser.intersect(*inspector).is_positive());
if width >= 800 {
let compact = crate::render_ui::compact(&h.app, width as f32);
@@ -2925,7 +2925,9 @@ fn render_workspace_stage_shell_degrades_without_overlap_at_small_window_sizes()
assert_eq!(inspector.width(), if compact { crate::frame::DIALOG_MIN_W } else { 305.0 });
assert_eq!(browser.top() - bar.bottom(), 8.0);
let (strip, _) = h.app.shell.workspace_panels.get("render:shots_strip").unwrap();
assert_eq!(strip.top() - browser.bottom(), 8.0);
let library = h.app.shell.workspace_panels["render:appearances"].0;
assert_eq!(strip.top() - library.bottom(), 8.0);
assert_eq!(library.top() - browser.bottom(), 8.0);
assert_eq!(strip.height(), 48.0);
}
}
@@ -2938,6 +2940,13 @@ fn render_workspace_stage_shell_degrades_without_overlap_at_small_window_sizes()
assert!(!dock.x_range().contains(h.app.viewport.rect.unwrap().center().x), "{width}: {dock:?}");
}
}
let mut docks = docks;
if let Some((panel, _)) = h.app.shell.workspace_panels.get("render:appearances") {
for dock in &docks {
assert!(!panel.intersect(*dock).is_positive());
}
docks.push(*panel);
}
for dock in docks {
assert!(!dock.intersect(bar).is_positive(), "{width}×{height}: {dock:?} {bar:?}");
if let Some((strip, _)) = h.app.shell.workspace_panels.get("render:shots_strip") {
@@ -2974,7 +2983,7 @@ fn render_workspace_focus_restores_docks_without_design_history_or_camera_change
assert!(crate::render_ui::focused(&h.app));
crate::shell::register_panel(&mut h.app, "render:stage_panel", Some(before), Some(crate::ui_kit::Edge::Left));
assert!(!h.app.shell.workspace_panels.contains_key("render:stage_panel"));
for id in ["render:browser", "render:inspector", "render:shots_strip", "render:shots:show"] {
for id in ["render:browser", "render:appearances", "render:inspector", "render:shots_strip", "render:shots:show"] {
assert!(!h.app.shell.workspace_panels.contains_key(id));
assert!(crate::scenario::rect_of(id).is_none());
}
@@ -3387,16 +3396,18 @@ fn render_workspace_hosts_float_and_shield_input_in_both_ribbon_layouts() {
&& (shots.bottom() - history.bottom()).abs() < 1.0,
"Shots must reuse History's floating placement: {shots:?} {history:?}"
);
for key in ["render:inspector", "render:browser", "render:shots_strip"] {
for key in ["render:inspector", "render:browser", "render:appearances", "render:shots_strip"] {
let (card, _) = h.app.shell.workspace_panels.get(key).unwrap();
assert!(viewport.contains_rect(*card), "{layout:?} {key}: {card:?} outside {viewport:?}");
assert!(crate::shell::covered(&h.app, card.center()), "{key} must shield the viewport");
}
let inspector = h.app.shell.workspace_panels["render:inspector"].0;
let browser = h.app.shell.workspace_panels["render:browser"].0;
let appearances = h.app.shell.workspace_panels["render:appearances"].0;
let ribbon_bottom = h.app.shell.cards.iter().map(|r| r.bottom()).fold(0.0, f32::max);
assert!((browser.top() - inspector.top()).abs() < 1.0);
assert!((browser.bottom() - inspector.bottom()).abs() < 1.0);
assert!((appearances.bottom() - inspector.bottom()).abs() < 1.0);
assert!(browser.height() <= 330.0, "Browser must stay within the fixed tree height: {browser:?}");
for key in ["render:browser", "render:inspector"] {
let card = h.app.shell.workspace_panels[key].0;
assert!(
@@ -3405,12 +3416,19 @@ fn render_workspace_hosts_float_and_shield_input_in_both_ribbon_layouts() {
card.top() - ribbon_bottom
);
}
for key in ["render:browser", "render:inspector"] {
for key in ["render:browser", "render:appearances", "render:inspector"] {
let card = h.app.shell.workspace_panels[key].0;
let header = crate::scenario::rect_of(&format!("{key}:header")).unwrap();
assert!((header.height() - crate::ui_kit::header_height()).abs() < 0.1, "{key}: {header:?}");
assert!((header.top() - card.top()).abs() <= 1.0, "header must have no outer content padding");
let control = crate::scenario::rect_of(if key == "render:browser" { "render:tree:by-look" } else { "render:page:output" }).unwrap();
let control = crate::scenario::rect_of(if key == "render:browser" {
"render:tree:by-look"
} else if key == "render:appearances" {
"render:library-search"
} else {
"render:page:output"
})
.unwrap();
if key == "render:browser" {
assert!(header.contains_rect(control), "Scene lens belongs in the title band");
} else {
@@ -3418,6 +3436,9 @@ fn render_workspace_hosts_float_and_shield_input_in_both_ribbon_layouts() {
}
}
assert!((browser.width() - appearances.width()).abs() < 1.0);
assert!((appearances.top() - browser.bottom() - Tokens::get().space_8).abs() < 1.0);
assert!(appearances.bottom() < shots.top());
assert!(browser.left() > viewport.left() && inspector.right() < viewport.right());
assert!(inspector.bottom() < shots.top() && browser.bottom() < shots.top());
let camera = h.app.cam;
@@ -4180,8 +4201,11 @@ fn render_workspace_browser_compact_geometry_search_and_theme_evidence() {
let card = crate::scenario::rect_of("browser:card").unwrap();
assert!((card.width() - 266.0).abs() < 0.1);
let inspector = crate::scenario::rect_of("render:inspector").unwrap();
let stage_panel = h.app.shell.workspace_panels["render:appearances"].0;
assert!((card.top() - inspector.top()).abs() < 0.1);
assert!((card.bottom() - inspector.bottom()).abs() < 0.1);
assert!((stage_panel.bottom() - inspector.bottom()).abs() < 0.1);
assert!((stage_panel.top() - card.bottom() - Tokens::get().space_8).abs() < 0.1);
assert!(card.height() <= 330.0, "Browser must stay within the fixed tree height: {card:?}");
let header = crate::scenario::rect_of("render:browser:header").unwrap();
assert!(header.contains_rect(crate::scenario::rect_of("render:tree:by-look").unwrap()));
assert!(crate::scenario::handle_at("render:browser-model").is_none());
+49 -8
View File
@@ -36,7 +36,8 @@ pub(crate) fn segmented(ui: &mut Ui, selected: &mut usize, options: &[&str], con
let Segments { targets, icons, workspace_accent, dense, small, states, compact, primary, intrinsic, proportional } = config;
let accent = crate::theme::TabAccent::current(ui.ctx());
let t = Tokens::get();
let font_size = if small { t.font_small } else { t.font_label };
let catalog = super::layout::in_catalog(ui);
let font_size = if small || catalog { t.font_small } else { t.font_label };
let natural: Vec<_> = options
.iter()
.enumerate()
@@ -64,7 +65,9 @@ pub(crate) fn segmented(ui: &mut Ui, selected: &mut usize, options: &[&str], con
let (rect, _) = ui.allocate_exact_size(
vec2(
desired,
if small {
if catalog {
t.space_16
} else if small {
t.control_height - t.space_4
} else if dense {
t.control_height - t.space_2
@@ -175,8 +178,13 @@ pub(crate) struct IconSegment {
/// Equal icon choices with mixed state. Tokens: `segmented tokens, space_4/12, icon/fill, accent; icon palette`.
pub(crate) fn segmented_icons(ui: &mut Ui, selected: &mut usize, options: &[IconSegment], states: &[bool]) -> bool {
let t = Tokens::get();
let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), row_height()), egui::Sense::hover());
ui.painter().rect_filled(rect, t.control_radius, t.control_fill);
let catalog = super::layout::in_catalog(ui);
let accent = crate::theme::TabAccent::current(ui.ctx());
let (rect, _) =
ui.allocate_exact_size(vec2(dimension(ui.available_width()), if catalog { t.space_24 } else { row_height() }), egui::Sense::hover());
if !catalog {
ui.painter().rect_filled(rect, t.control_radius, t.control_fill);
}
let width = rect.width() / options.len().max(1) as f32;
let mut clicked = false;
for (index, option) in options.iter().enumerate() {
@@ -190,25 +198,41 @@ pub(crate) fn segmented_icons(ui: &mut Ui, selected: &mut usize, options: &[Icon
se: if index + 1 == options.len() { t.control_radius } else { 0 },
};
if on || response.hovered() {
ui.painter().rect_filled(segment, rounding, if on { t.selected_bg } else { t.hover });
ui.painter().rect_filled(
segment,
rounding,
if on && catalog {
accent.soft
} else if on {
t.selected_bg
} else {
t.hover
},
);
}
if index > 0 {
if index > 0 && !catalog {
ui.painter().vline(segment.left(), segment.y_range(), t.control_border_stroke(t.control_border));
}
// A square icon area inside the segment: dash gaps and dots need the room to read apart.
let side = (segment.width().min(segment.height()) - t.space_4).max(t.space_12);
let icon_rect = egui::Rect::from_center_size(segment.center(), vec2(side, side));
crate::icons::paint_icon(ui.painter(), icon_rect, option.icon, f32::from(t.icon.a()) / 255.0);
if catalog {
let icon_rect = egui::Rect::from_center_size(segment.center(), vec2(t.space_14, t.space_14));
crate::icons::paint_ink(ui.painter(), icon_rect, option.icon, if on { accent.ink } else { t.form_dim });
} else {
crate::icons::paint_icon(ui.painter(), icon_rect, option.icon, f32::from(t.icon.a()) / 255.0);
}
t.button_bevel_with_radius(ui, &response, on, rounding);
response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), on, option.key));
scenario::publish_handle(&format!("dialog:{}:{}", label(ui), option.key), segment.center());
scenario::publish_target(option.key, segment);
let response = response.on_hover_text(&option.tip);
if response.clicked() {
*selected = index;
clicked = true;
}
}
if t.borders.bevel.is_none() {
if !catalog && t.borders.bevel.is_none() {
ui.painter().rect_stroke(rect, t.control_radius, t.control_border_stroke(t.control_border), egui::StrokeKind::Inside);
}
scenario::publish_target_as(&format!("dialog:{}", label(ui)), &format!("dialog:segments:{}", label(ui)), rect);
@@ -356,6 +380,23 @@ pub(crate) fn list_picker(ui: &mut Ui, key: &str, text: &str, selected: bool) ->
/// Intrinsic-width selection chip for horizontal lists, sharing list-picker styling.
pub(crate) fn choice_chip(ui: &mut Ui, key: &str, text: &str, selected: bool) -> egui::Response {
let t = Tokens::get();
if super::layout::in_catalog(ui) {
let accent = crate::theme::TabAccent::current(ui.ctx());
let width = ui.painter().layout_no_wrap(text.to_string(), crate::fonts::semibold(t.font_small), t.form_ink).size().x + t.space_16;
let (rect, response) = ui.allocate_exact_size(vec2(width, t.space_16 + t.space_4), egui::Sense::click());
ui.painter().rect_filled(rect, t.radius_xl, if selected { accent.soft } else { t.control_fill });
paint_text(
ui,
rect.shrink2(vec2(t.space_8, 0.0)),
text,
if selected { crate::fonts::semibold(t.font_small) } else { egui::FontId::proportional(t.font_small) },
if selected { accent.ink } else { t.form_ink },
false,
);
response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), selected, text));
crate::scenario::publish_target(&format!("dialog:list:{key}"), rect);
return response;
}
let width = (ui.painter().layout_no_wrap(text.to_owned(), crate::fonts::semibold(t.font_label), t.text).size().x + t.space_24)
.clamp(t.control_height * 2.0, t.form_card_width);
let response = ui.add_sized(vec2(width, super::row_height()), egui::Button::selectable(selected, text).truncate());
+17 -1
View File
@@ -455,7 +455,23 @@ fn cell_editor_frame(ui: &mut Ui, id: egui::Id, value: &mut String, hint: &str,
/// Search input with native accessibility and a stable caller ID. Tokens: cell_editor tokens.
pub(crate) fn search_field(ui: &mut Ui, id: egui::Id, value: &mut String, hint: &str) -> Response {
cell_editor(ui, id, value, hint, false)
if !super::layout::in_catalog(ui) {
return cell_editor(ui, id, value, hint, false);
}
let t = Tokens::get();
let editor = text_input(egui::TextEdit::singleline(value))
.id(id)
.char_limit(128)
.hint_text(hint)
.min_size(vec2(0.0, t.space_16 + t.space_2))
.margin(egui::Margin { left: t.space_24 as i8, right: t.space_8 as i8, top: 0, bottom: 0 })
.font(egui::FontId::proportional(t.font_small))
.text_color(t.form_ink);
let response = ui.add_sized(vec2(dimension(ui.available_width()), t.space_16 + t.space_2), editor);
let icon = egui::Rect::from_center_size(egui::pos2(response.rect.left() + t.space_12, response.rect.center().y), vec2(t.space_12, t.space_12));
crate::icons::paint_ink(ui.painter(), icon, "zoom", t.form_dim);
super::layout::publish_geometry(ui, &response);
response
}
/// Behaviour of the one kit slider. Appearance is always owned by `slider`.
+42
View File
@@ -163,6 +163,48 @@ const ELEMENTS: &[Element] = &[
[TreeAction { icon: "lookat", hover_only: true, label: "Solo", reason: Some("Not available yet"), target: "gallery:tree:solo" }];
tree_row(ui, ui.id().with("tree_actions"), &Row { label: "Light", actions: &actions, ..Default::default() });
}),
element!("catalog_scope", |ui, state| {
catalog_scope(ui, |ui| {
search_field(ui, ui.id().with("catalog_search"), &mut state.value, "Search appearances");
segmented(
ui,
&mut state.selected,
&["In Design", "Library", "Recent", "★"],
Segments { compact: true, proportional: true, workspace_accent: true, ..Default::default() },
);
ui.horizontal(|ui| {
choice_chip(ui, "catalog_all", "All", true);
choice_chip(ui, "catalog_metal", "Metal", false);
});
catalog_footer(ui, "Click to apply · drag onto the model");
});
}),
element!("catalog_footer", |ui, _| {
catalog_footer(ui, "Click to apply · drag onto the model");
}),
element!("sphere_grid", |ui, _| {
let sphere = Sphere { color: Tokens::get().render_accent, kind: FinishKind::Satin, opacity: None };
let tiles = ["gallery:grid:a", "gallery:grid:b", "gallery:grid:c"].map(|id| SphereTile {
id,
name: "Satin",
sphere,
selected: id.ends_with('b'),
users: 1,
tip: "Satin",
});
sphere_grid(ui, &tiles);
}),
element!("sphere_tile", "gallery:tile", Some("gallery:tile"), |ui, _| {
SphereTile {
id: "gallery:tile",
name: "Satin metal",
sphere: Sphere { color: Tokens::get().render_accent, kind: FinishKind::Metal, opacity: None },
selected: true,
users: 3,
tip: "Satin metal",
}
.show(ui);
}),
element!("settings_form", |ui, state| {
settings_form(ui, Tokens::get().form_label_width, |ui| {
row(ui, "Sample", |ui| {
+33
View File
@@ -44,6 +44,37 @@ pub(crate) fn scope<R>(ui: &mut Ui, add: impl FnOnce(&mut Ui) -> R) -> R {
.inner
}
/// Compact library cards share search, segment, chip and footer metrics.
pub(crate) fn catalog_scope<R>(ui: &mut Ui, add: impl FnOnce(&mut Ui) -> R) -> R {
ui.scope_builder(egui::UiBuilder::new().ui_stack_info(egui::UiStackInfo::default().with_tag("sc_catalog")), |ui| {
ui.spacing_mut().item_spacing.y = Tokens::get().space_8;
add(ui)
})
.inner
}
pub(super) fn in_catalog(ui: &Ui) -> bool {
ui.stack().iter().any(|node| node.tags().contains("sc_catalog"))
}
/// Quiet full-width library footer with the shared information glyph.
pub(crate) fn catalog_footer(ui: &mut Ui, text: &str) {
let t = Tokens::get();
let (rect, _) = ui.allocate_exact_size(vec2(ui.available_width(), t.control_height), egui::Sense::hover());
t.secondary_hline(ui.painter(), rect.x_range(), rect.top(), t.dialog_rule);
let icon = egui::Rect::from_center_size(egui::pos2(rect.left() + t.space_6, rect.center().y), vec2(t.space_12, t.space_12));
ui.painter().circle_stroke(icon.center(), t.space_4, t.control_border_stroke(t.form_dim));
ui.painter().text(icon.center(), egui::Align2::CENTER_CENTER, "i", crate::fonts::semibold(t.font_badge), t.form_dim);
paint_text(
ui,
egui::Rect::from_min_max(egui::pos2(icon.right() + t.space_6, rect.top()), rect.max),
text,
egui::FontId::proportional(t.font_small),
t.form_dim,
false,
);
}
/// Read the enclosing row accessibility label. Tokens: `none`.
pub(crate) fn label(ui: &Ui) -> &str {
ui.stack().iter().find_map(|node| node.tags().get_downcast::<String>(LABEL)).map(String::as_str).unwrap_or("")
@@ -474,10 +505,12 @@ pub(crate) fn text(ui: &mut Ui, text: &str, style: Text<'_>) -> Response {
let fixed = matches!(style, Text::Cell | Text::NameCell(_) | Text::MonoCell | Text::Value(_, _));
let ink = match style {
Text::Hint(_) | Text::Note(_) | Text::MonoNote(_) => t.form_dim,
Text::Inline if in_catalog(ui) => t.form_dim,
Text::Report(_, true) | Text::Value(_, true) | Text::Error(_) => t.form_error,
_ => t.form_ink,
};
let font = match style {
Text::Inline if in_catalog(ui) => crate::fonts::semibold(t.font_small),
Text::NameCell(true) => crate::fonts::semibold(t.font_label),
Text::NameCell(false) => crate::fonts::medium(t.font_label),
Text::Heading(_) => crate::fonts::semibold(t.font_button),
+3
View File
@@ -45,6 +45,8 @@ pub(crate) use actions::*;
pub use actions::{Button, button};
pub(crate) use assistant::*;
pub(crate) use assistant_entry::*;
#[cfg(test)]
pub(crate) use checks::tests::{raster as raster_ui, textures_update as update_test_textures};
pub(crate) use checks::*;
pub(crate) use choice::*;
pub(crate) use color::*;
@@ -76,6 +78,7 @@ pub(crate) use reports::*;
pub(crate) use search::{CommandSearch, SearchBadge, SearchFieldGeometry};
pub(crate) use shortcuts::*;
pub use sphere::{FinishKind, Sphere, sphere_thumbnail};
pub(crate) use sphere::{SphereTile, sphere_grid};
pub(crate) use stages::{StageAction, StageBar};
pub(crate) use status::*;
pub(crate) use table::*;
+53 -6
View File
@@ -30,6 +30,18 @@ fn header_impl(
collapsed: Option<&mut bool>,
closeable: bool,
on_close: impl FnOnce(),
) {
header_actions(ui, icon, title, collapsed, closeable, on_close, None);
}
fn header_actions(
ui: &mut Ui,
icon: (&str, Option<egui::Color32>),
title: &str,
collapsed: Option<&mut bool>,
closeable: bool,
on_close: impl FnOnce(),
actions: Option<&mut dyn FnMut(&mut Ui)>,
) {
let t = Tokens::get();
let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), header_height()), egui::Sense::hover());
@@ -38,7 +50,9 @@ fn header_impl(
egui::pos2(rect.left() + t.space_12 + t.form_icon_size / 2.0, rect.center().y),
vec2(t.form_icon_size, t.form_icon_size),
);
if let Some(ink) = icon.1 {
if icon.0.is_empty() {
ui.painter().circle_filled(icon_rect.center(), t.space_3, crate::theme::TabAccent::current(ui.ctx()).ink);
} else if let Some(ink) = icon.1 {
crate::icons::paint_ink(ui.painter(), icon_rect, icon.0, ink);
} else {
crate::icons::paint_icon(ui.painter(), icon_rect, icon.0, 1.0);
@@ -54,7 +68,15 @@ fn header_impl(
on_close();
}
}
let right = if let Some(collapsed) = collapsed {
let right = if let Some(actions) = actions {
let action_rect = egui::Rect::from_center_size(
egui::pos2(rect.right() - t.space_8 - t.control_height, rect.center().y),
vec2(t.control_height * 2.0, t.control_height),
);
let mut action_ui = ui.new_child(egui::UiBuilder::new().max_rect(action_rect));
actions(&mut action_ui);
action_rect.left() - t.space_8
} else if let Some(collapsed) = collapsed {
let fold = egui::Rect::from_min_size(egui::pos2(close_rect.left() - t.form_close_size - t.space_4, close_rect.top()), close_rect.size());
let response = super::disclosure_button_at(ui, fold, !*collapsed, crate::i18n::tr_label(if *collapsed { "Expand" } else { "Collapse" }));
scenario::publish_handle("dialog:collapse", response.rect.center());
@@ -69,7 +91,7 @@ fn header_impl(
};
let left = (icon_rect.right() + t.space_8).min(right);
let title_rect = egui::Rect::from_min_max(egui::pos2(left, rect.top()), egui::pos2(right.max(left), rect.bottom()));
paint_text(ui, title_rect, title, crate::fonts::semibold(t.font_heading), t.form_ink, false);
paint_text(ui, title_rect, title, crate::fonts::semibold(if icon.0.is_empty() { t.font_label } else { t.font_heading }), t.form_ink, false);
let title_response = ui.interact(title_rect, ui.make_persistent_id("title_text"), egui::Sense::hover());
title_response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), title));
scenario::publish_rect("dialog:header", rect);
@@ -219,6 +241,8 @@ pub(crate) struct WorkspaceOptions<'a> {
pub fill_height: bool,
/// Use the minimum dock width without overwriting its remembered width.
pub compact: bool,
pub enabled: bool,
pub header_actions: Option<&'a mut dyn FnMut(&mut Ui)>,
}
pub(crate) struct FeatureOptions<'a> {
@@ -245,6 +269,21 @@ pub(crate) enum Part {
}
impl<'a> Panel<'a> {
/// Shared vertical dock policy: reserve room for a second card, then place it
/// below the measured first card with the standard container gap.
pub(crate) fn stack_first_bounds(mut bounds: egui::Rect) -> egui::Rect {
bounds.max.y = bounds.top()
+ bounds
.height()
.min(Tokens::get().form_header_height + Tokens::get().control_height * 10.0 + Tokens::get().space_8 * 2.0)
.min((bounds.height() * 0.5).floor());
bounds
}
pub(crate) fn stack_next_bounds(mut bounds: egui::Rect, previous: egui::Rect) -> egui::Rect {
bounds.min.y = (previous.bottom() + Tokens::get().space_8).min(bounds.bottom());
bounds
}
/// Pinned inline actions inside an existing feature/card surface. This is not
/// a second window or painted card: the parent owns the chrome. Tokens:
/// control_height, space_24/8; bounded row count preserves finite geometry.
@@ -290,11 +329,12 @@ impl<'a> Panel<'a> {
/// side request, which the caller dispatches through its command. Neither gesture edits the document.
pub(crate) fn workspace<R>(
ui: &mut Ui,
options: WorkspaceOptions<'_>,
mut options: WorkspaceOptions<'_>,
side: &mut String,
width: &mut f32,
add: impl FnOnce(&mut Ui) -> R,
) -> Option<egui::InnerResponse<(R, Option<&'static str>)>> {
let actions = options.header_actions.take();
Self::workspace_with_header(
ui,
options,
@@ -302,7 +342,7 @@ impl<'a> Panel<'a> {
width,
false,
|ui, options| {
header_impl(ui, (options.icon, None), options.title, None, false, || {});
header_actions(ui, (options.icon, None), options.title, None, false, || {}, actions);
},
add,
)
@@ -353,6 +393,9 @@ impl<'a> Panel<'a> {
let (body, _) = ui.allocate_exact_size(size, egui::Sense::hover());
let mut child = ui.new_child(egui::UiBuilder::new().max_rect(body).id_salt("workspace_body"));
let ui = &mut child;
if !options.enabled {
ui.disable();
}
ui.set_clip_rect(ui.clip_rect().intersect(body));
ui.set_width(size.x);
ui.set_max_height(size.y);
@@ -390,7 +433,11 @@ impl<'a> Panel<'a> {
ui.ctx().request_repaint();
}
egui::Frame::NONE
.inner_margin(if tree { egui::Margin::symmetric(0, t.space_4 as i8) } else { egui::Margin::same(t.space_12 as i8) })
.inner_margin(if tree {
egui::Margin::symmetric(0, t.space_4 as i8)
} else {
egui::Margin::same(if options.icon.is_empty() { t.space_10 } else { t.space_12 } as i8)
})
.show(ui, |ui| {
ui.spacing_mut().item_spacing.y = t.form_gap_y;
if tree {
+117 -5
View File
@@ -82,16 +82,26 @@ fn shade(key: Key, t: &Tokens) -> Mesh {
let z = (1.0 - r * r).max(0.0).sqrt();
let light = (-0.4 * x - 0.5 * y + 0.76 * z).max(0.0);
let specular = (-0.25 * x - 0.35 * y + 0.902 * z).max(0.0);
let (diffuse, shine) = match key.kind {
let (diffuse, mut shine) = match key.kind {
FinishKind::Matte => (0.3 + 0.7 * light, 0.04 * specular.powi(8)),
FinishKind::Satin => (0.25 + 0.75 * light, 0.25 * specular.powi(16)),
FinishKind::Gloss => (0.2 + 0.8 * light, 0.85 * specular.powi(64)),
FinishKind::Metal => (0.15 + 0.65 * light, 0.8 * specular.powi(24)),
FinishKind::Metal => (0.45 + 0.5 * light, 0.65 * specular.powi(16)),
FinishKind::Glass => (0.5 + 0.5 * light, (0.85 * specular.powi(64) + 0.4 * (1.0 - z).powi(3)).min(1.0)),
};
let shaded = key.color.lerp_to_gamma(t.tab_on_fill_dark, 1.0 - diffuse);
let highlight = if key.kind == FinishKind::Metal { key.color.lerp_to_gamma(t.on_accent, 0.65) } else { t.on_accent };
let color = shaded.lerp_to_gamma(highlight, shine).gamma_multiply(f32::from(key.opacity) / 255.0);
let mut shaded = key.color.lerp_to_gamma(t.tab_on_fill_dark, 1.0 - diffuse);
if key.kind == FinishKind::Metal {
// Original studio sample: broad radial illumination, a curved horizon,
// a lower reflector and an oval softbox. All are bounded analytic fields.
let gradient = ((x + 0.28).hypot(y + 0.44) / 1.64).clamp(0.0, 1.0);
shaded = if gradient < 0.42 {
key.color.lerp_to_gamma(t.on_accent, 0.4 * (1.0 - gradient / 0.42))
} else {
key.color.lerp_to_gamma(t.tab_on_fill_dark, 0.66 * (gradient - 0.42) / 0.58)
};
shine = 0.0;
}
let color = shaded.lerp_to_gamma(t.on_accent, shine).gamma_multiply(f32::from(key.opacity) / 255.0);
mesh.colored_vertex(pos2(radius + x * radius, radius + y * radius), color);
if ring < RINGS && sector < SECTORS {
let a = ring * (SECTORS + 1) + sector;
@@ -126,6 +136,32 @@ pub(super) fn paint_sphere(ui: &Ui, rect: Rect, sphere: Sphere) {
vertex.pos = rect.min + vertex.pos.to_vec2() * scale;
}
ui.painter().add(egui::Shape::mesh(mesh));
if sphere.kind == FinishKind::Metal {
let radius = rect.width() / 2.0;
let at = |x: f32, y: f32| rect.center() + vec2(x, y) * radius;
let opacity = f32::from(key.opacity) / 255.0;
// Vector reflections stay smooth at small sizes without increasing cached mesh topology.
ui.painter().add(egui::epaint::QuadraticBezierShape::from_points_stroke(
[at(-0.965, 0.207), at(0.0, -0.138), at(0.965, 0.207)],
false,
Color32::TRANSPARENT,
egui::Stroke::new(radius * 0.069, t.tab_on_fill_dark.gamma_multiply(0.22 * opacity)),
));
let ellipse = |center: egui::Pos2, radii: egui::Vec2, angle: f32, alpha: f32| {
let (sin, cos) = angle.sin_cos();
let points = (0..48)
.map(|index| {
let a = std::f32::consts::TAU * index as f32 / 48.0;
let x = radii.x * a.cos();
let y = radii.y * a.sin();
center + vec2(cos * x - sin * y, sin * x + cos * y)
})
.collect();
ui.painter().add(egui::Shape::convex_polygon(points, t.on_accent.gamma_multiply(alpha * opacity), egui::Stroke::NONE));
};
ellipse(at(0.0, 0.48), vec2(0.83, 0.21) * radius, 0.0, 0.16);
ellipse(at(-0.345, -0.483), vec2(0.38, 0.21) * radius, -32.0_f32.to_radians(), 0.55);
}
}
/// Clamps size to 1–96 logical points. Cache: 64 FIFO entries per egui context.
@@ -139,6 +175,82 @@ pub fn sphere_thumbnail(ui: &mut Ui, id: &str, sphere: Sphere, size: f32) -> Res
response
}
/// A catalog sample: 48 pt sphere in a 56 pt cell, two-line caption and optional
/// usage badge. The surrounding chrome follows the active workspace accent.
pub(crate) struct SphereTile<'a> {
pub id: &'a str,
pub name: &'a str,
pub sphere: Sphere,
pub selected: bool,
pub users: usize,
pub tip: &'a str,
}
impl SphereTile<'_> {
pub(crate) fn show(&self, ui: &mut Ui) -> Response {
let t = Tokens::get();
let accent = crate::theme::TabAccent::current(ui.ctx());
let side = t.control_height * 2.0;
let height = side + t.space_3 + t.font_small * 2.5 + t.space_4;
let (rect, _) = ui.allocate_exact_size(vec2(ui.available_width(), height), Sense::hover());
let response = ui.interact(rect, ui.make_persistent_id(self.id), Sense::click());
let cell = Rect::from_min_size(pos2(rect.center().x - side / 2.0, rect.top() + t.space_4), vec2(side, side));
ui.painter().rect_filled(cell, t.radius_xl, t.control_fill);
ui.painter().rect_stroke(cell, t.radius_xl, t.control_border_stroke(t.dialog_rule), egui::StrokeKind::Inside);
if self.selected || response.hovered() || response.has_focus() {
ui.painter().rect_stroke(cell.expand(t.space_2), t.radius_xl, egui::Stroke::new(t.space_2, accent.ink), egui::StrokeKind::Outside);
}
paint_sphere(ui, cell.shrink(t.space_4), self.sphere);
if self.users > 0 {
let text = if self.users > 99 { "99+".into() } else { self.users.to_string() };
let galley = ui.painter().layout_no_wrap(text, crate::fonts::semibold(t.font_badge), t.on_accent);
let width = (galley.size().x + t.space_8).max(t.space_16);
let badge = Rect::from_min_size(pos2(cell.right() + t.space_2 - width, cell.top() - t.space_2), vec2(width, t.space_16));
ui.painter().rect_filled(badge, t.radius_lg, accent.ink);
ui.painter().galley(badge.center() - galley.size() / 2.0, galley, t.on_accent);
}
let label = Rect::from_min_max(pos2(rect.left(), cell.bottom() + t.space_3), rect.max);
let font = if self.selected { crate::fonts::semibold(t.font_small) } else { egui::FontId::proportional(t.font_small) };
let mut job = egui::text::LayoutJob::simple(self.name.to_owned(), font, t.form_ink, label.width());
job.halign = egui::Align::Center;
job.wrap.max_rows = 2;
job.wrap.break_anywhere = false;
let galley = ui.painter().layout_job(job);
ui.painter().with_clip_rect(ui.clip_rect().intersect(label)).galley(
pos2(label.center().x - galley.rect.center().x, label.top() - galley.rect.top()),
galley,
t.form_ink,
);
response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), self.selected, self.name));
scenario::publish_target(self.id, rect);
let mut tip = egui::Tooltip::for_enabled(&response);
tip.popup = tip.popup.frame(super::Container::new(ui.ctx(), super::Surface::Toast).tooltip_frame(ui.ctx()));
tip.show(|ui| {
ui.label(self.tip);
});
response
}
}
/// Fixed-column catalog composition. Tile geometry and gaps stay with the kit.
pub(crate) fn sphere_grid(ui: &mut Ui, tiles: &[SphereTile<'_>]) -> Option<usize> {
let t = Tokens::get();
let mut clicked = None;
ui.spacing_mut().item_spacing = vec2(t.space_2, t.space_8);
for (row, chunk) in tiles.chunks(3).enumerate() {
ui.columns(3, |columns| {
for (column, tile) in chunk.iter().enumerate() {
if let Some(ui) = columns.get_mut(column)
&& tile.show(ui).clicked()
{
clicked = Some(row * 3 + column);
}
}
});
}
clicked
}
#[cfg(test)]
#[path = "sphere_tests.rs"]
mod tests;
+48
View File
@@ -1,5 +1,53 @@
use super::*;
#[test]
fn tiles_keep_three_columns_cell_sphere_badge_and_selection_in_both_themes() {
for dark in [false, true] {
crate::theme::set_dark(dark);
let ctx = crate::fonts::test_context();
let t = Tokens::get();
let output = crate::test_support::frame(
&ctx,
egui::RawInput { screen_rect: Some(Rect::from_min_size(egui::Pos2::ZERO, vec2(320.0, 400.0))), ..Default::default() },
|ui| {
ui.set_width(240.0);
super::super::scope(ui, |ui| {
let tiles = ["a", "b", "c"].map(|id| SphereTile {
id,
name: "Satin",
sphere: Sphere { color: t.render_accent, kind: FinishKind::Satin, opacity: None },
selected: id == "b",
users: usize::from(id == "a"),
tip: "Hover details",
});
assert!(sphere_grid(ui, &tiles).is_none());
});
},
);
assert!(
!output.shapes.iter().any(|shape| matches!(&shape.shape,egui::Shape::Text(text) if text.galley.job.text.contains("Hover details"))),
"hover cards must stay closed without a pointer"
);
let a = crate::scenario::rect_of("a").unwrap();
let b = crate::scenario::rect_of("b").unwrap();
let c = crate::scenario::rect_of("c").unwrap();
assert_eq!(a.top(), b.top());
assert_eq!(b.top(), c.top());
assert!(a.right() < b.left() && b.right() < c.left());
fn meshes(shape: &egui::Shape) -> usize {
match shape {
egui::Shape::Mesh(_) => 1,
egui::Shape::Vec(shapes) => shapes.iter().map(meshes).sum(),
_ => 0,
}
}
assert_eq!(output.shapes.iter().map(|shape| meshes(&shape.shape)).sum::<usize>(), 3);
let accent = crate::theme::TabAccent::current(&ctx);
assert!(output.shapes.iter().any(|shape| matches!(&shape.shape,egui::Shape::Rect(r) if r.stroke.color==accent.ink && r.rect.width()==60.0)));
assert!(output.shapes.iter().any(|shape| matches!(&shape.shape,egui::Shape::Rect(r) if r.rect.size()==vec2(56.0,56.0))));
}
}
#[test]
fn cache_bounds_a_thousand_distinct_inputs_and_evicts_oldest() {
let t = Tokens::light();
@@ -3,12 +3,13 @@
{"call":"ui.resize","params":{"width":1440,"height":1000}},
{"call":"engine.execute","params":{"command":"solid.box","params":{"length":20,"width":15,"height":10}}},
{"call":"ui.workspace","params":{"workspace":"render"}},
{"expect":{"shown_handles":["render:stage:look","render:stage:light","render:stage:frame","render:stage:output","render:stage:render.start","render:stage:render.cancel","ribbon:search","render:shots:hide","render:inspector:grip","render:browser:grip"],"hidden_handles":["tab:RENDER","tab:RENDER APPEARANCE","ribbon:section:RENDER:IMAGE"],"errors":0}},
{"expect":{"shown_handles":["render:stage:look","render:stage:light","render:stage:frame","render:stage:output","render:stage:render.start","render:stage:render.cancel","ribbon:search","render:shots:hide","render:inspector:grip","render:browser:grip","render:appearances:grip","render:library-search","render:library-grid","render:library-list"],"hidden_handles":["tab:RENDER","tab:RENDER APPEARANCE","ribbon:section:RENDER:IMAGE"],"errors":0}},
{"click":{"handle":"render:stage:look"}},
{"click":{"handle":"render:stage:light"}},
{"click":{"handle":"render:stage:frame"}},
{"click":{"handle":"render:stage:output"}},
{"expect":{"disjoint":["render:browser:header","render:tree:environment"]}},
{"expect":{"disjoint":["render:browser:header","render:appearances:header"]}},
{"expect":{"disjoint":["render:inspector:header","render:page:output"]}},
{"click":{"handle":"render:shots:hide"}},
{"expect":{"shown_handles":["render:shots:show"],"hidden_handles":["render:shots:hide"]}},
+25 -8
View File
@@ -33,14 +33,31 @@ light coordinate frame remains disabled with its reason in this checkout. Frame
uses the existing explicit camera command for projection; Output shows the current
size/format and directs edits to the Output Inspector. No completion ticks are inferred.
The Browser and Inspector float in both shell layouts, share top and bottom edges,
and clear the bar and Shots strip by 8 pt. Their default outer widths are 266 pt and 305 pt, with the shared resize bounds.
The 48 pt Shots strip has an 8 pt gap from the docks. The 110 pt compass uses the
free canvas beside the Inspector and the navigation bar keeps its shared navigation handler. Narrow
rows scroll horizontally; docks shrink together or disappear if no usable space
remains. The Shots strip's independent `view.shots_strip` preference is unchanged.
The current model/library Browser can reveal model bodies for Look; scene-specific
Lights, Shots and Output expansion awaits the scene Browser change.
The Browser and Inspector float in both shell layouts and share a top edge, 8 pt
below the bar. Their default outer widths are 266 pt and 305 pt, with shared resize
bounds. The Browser keeps the upper left card (up to ten compact scene rows); its
stage panel fills the remaining height below it, ending 8 pt above the 48 pt Shots
strip. Both cards share width and side preferences. Narrow windows shorten the
Browser to reserve library space, then omit cards that cannot fit safely.
Look hosts Appearances: search with the actual catalog count, In Design / Library /
Recent / favorites scopes, horizontally scrolling category chips and a three-column
sphere grid or list. Resources used in the design or matching a selected look's
finish family or category appear first. Clicking a look applies through
`appearance.assign` to selected bodies, faces or components; with no target it
only inspects. Favorites and recent history live in user preferences. Explicit
catalog navigation from the Inspector retains the read-only resource browser.
Light hosts the existing native studios and HDR environments in the same tile grid.
A click runs `render.preset.apply` or `render.library.environment.apply`, preserving
those commands' validation and undo behavior. Studios require an explicitly selected
GPU path setup; environments require CPU or GPU ray tracing. Frame and Output show
faded Frame presets / Size presets placeholders with their Shot editor / Output
editor reasons. Stage navigation itself never applies a resource.
The 110 pt compass uses the free canvas beside the Inspector; the navigation bar
keeps its shared handler. The Shots strip's independent `view.shots_strip`
preference is unchanged.
`view.render_focus {on: true}` hides the Browser, Inspector and Shots strip and
releases their canvas reservations. Tab toggles focus while Render is active and
+11 -2
View File
@@ -52,8 +52,10 @@ rules. Its compass is 110 pt; the 48 pt Shots strip clears the docks by 8 pt.
Panel/Window header and padded body, with no second top inset below the ribbon.
Persistent workspace cards omit the close action. `Panel::workspace_with_header` lets tree cards
compose the shared `tree_header` (title, compact lens and quiet search action). Its tree policy
shares the full dock height and lets rows own their 8 pt side insets; header navigation
retains a separate title grip. `Panel::bottom_strip`
caps the card at ten 28 pt rows and lets rows own their 8 pt side insets; header navigation
retains a separate title grip. Optional header actions share the same title band.
`stack_first_bounds` reserves a bounded Browser above its companion;
`stack_next_bounds` places that companion with the shared gap. `Panel::bottom_strip`
uses `Container::bottom_strip_rect`, the same placement as Design History.
`Container::navigation_card` supplies the shared Navigation surface for anchored HUDs.
Register measured card rectangles and reserved edges with `shell::register_panel` so
@@ -156,6 +158,7 @@ table. Panel/Window/Confirm compositions also have dedicated geometry and intera
| `tool_choices`, `ToolChoice`, `toggle_icon` | Wrapped command modes or independent icon toggles | sketch mode/icon tokens, `accent` |
| `list_picker` | Selectable row with caller identity and native checked state | `control_height`, form selection tokens |
| `popup_list`, `PopupOption` | Focus-neutral suggestions; owner retains keyboard routing | `space_2`, `form_label_width`, `control_height`, form tokens |
| sphere: `sphere_thumbnail`, `SphereTile`, `sphere_grid` | Deterministic lit material samples; matte/satin/gloss/metal/glass finishes. Catalog tiles centre a 48 pt sphere in a 56 pt rounded cell with a two-line name, active-tab selection ring, user-count badge and shared Container tooltip. The grid owns three columns and token gaps. | `control_height`, `radius_xl`, `space_2/3/4/8/16`, `font_small/badge`, `control_fill`, `dialog_rule`, active-tab accent, `on_accent` |
| `color_swatch`, `swatch_grid`, `color_thumbnail` | 30 pt draggable samples, 6 pt grid step gap, selected outer ring and checker pattern under transparent colours; caller payloads retained; local-library thumbnails use 16 pt | `control_height/radius`, `border`, `form_primary`, `control_fill`, `space_2/6/8` |
| `assistant_entry`, `AssistantEntryState` | Application-bar chat icon with quiet, ready, busy, auth, stopped and approval count marks; caller owns state and target | `app_bar`, `agent_ok/busy`, `warning/error`, `font_badge` |
| actions: `button`, `Button` | Secondary action: `Normal`, `Small`, or `Enabled(bool)` | native sizing, form font/control tokens |
@@ -711,3 +714,9 @@ with Body active, and an empty chain with Face active in both themes.
For CPU-rendered review images, run
`SOLIDCRAFT_MATERIAL_WIDGET_EVIDENCE=/tmp/material-widgets cargo test -p solidcraft-ui-egui ui_kit::gallery::material_widgets_board_in_both_themes`.
`catalog_scope` supplies compact catalog metrics to the shared search field, segments,
icon segments and category chips. `catalog_footer` draws the quiet information hint.
Catalog title marks use the active workspace accent; tile captions, usage badges and
selection outlines share the sphere widgets. Feature code supplies data and commands,
while the kit owns every dimension, colour and inset.