SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Render inspector: Appearance editor with the look chain, scope, mixed values and Advanced (#6281) (#6432)
Nathan Dane293ed5fab7b5
diff --git a/assets/locales/pending/render-appearance-editor.json b/assets/locales/pending/render-appearance-editor.jsonnew file mode 100644index 0000000000..0f11601222--- /dev/null+++ b/assets/locales/pending/render-appearance-editor.json@@ -0,0 +1,330 @@+{+ "en": {+ "render.appearance_editor.glass": "Glass and absorption",+ "render.appearance_editor.coat": "Clear coat",+ "render.appearance_editor.maps": "Maps",+ "render.appearance_editor.saved": "Saved with this shot",+ "render.appearance_editor.reflections": "Reflections",+ "render.appearance_editor.glass_enable": "Use physical glass on this body",+ "render.appearance_editor.recipe": "Recipe",+ "render.appearance_editor.boundary": "Boundary",+ "render.appearance_editor.closed": "Closed solid",+ "render.appearance_editor.thin": "Thin sheet",+ "render.appearance_editor.box": "Box",+ "render.appearance_editor.choose_image": "Choose image…",+ "render.appearance_editor.temporary": "These optics are temporary on this tab. Save them to keep them with the shot.",+ "render.appearance_editor.save": "Save these optics",+ "render.appearance_editor.remove": "Remove saved",+ "render.appearance_editor.replace": "Replace this body's saved optics",+ "render.appearance_editor.revalidate": "Revalidate this body",+ "render.appearance_editor.remove_title": "Remove saved optics?",+ "render.appearance_editor.remove_note": "Remove the saved optics from this shot. Geometry and assigned looks are kept.",+ "render.appearance_editor.gpu_reason": "Needs GPU path tracing.",+ "render.appearance_editor.cpu_reason": "Needs CPU ray tracing.",+ "render.appearance_editor.body_reason": "Optical bindings target one whole body. Pick Body to edit these controls.",+ "render.appearance_editor.save_reason": "Saving these optics needs physical glass on a current GPU body. Coat and local image maps remain temporary.",+ "render.appearance_editor.glass_note": "Closed glass uses geometric distance. It cannot share a body with clear coat or maps.",+ "render.appearance_editor.thickness_reason": "Thickness applies to thin sheets; closed glass uses geometric distance.",+ "render.appearance_editor.scatter_reason": "Interior scattering needs a closed solid boundary.",+ "render.appearance_editor.ior": "IOR",+ "render.appearance_editor.absorption": "Absorption",+ "render.appearance_editor.thickness": "Thickness",+ "render.appearance_editor.weight": "Weight",+ "render.appearance_editor.base_colour": "Base colour",+ "render.appearance_editor.normal": "Normal",+ "render.appearance_editor.origin": "Origin",+ "render.appearance_editor.u_repeat": "U repeat",+ "render.appearance_editor.v_repeat": "V repeat",+ "render.appearance_editor.normal_strength": "Normal strength",+ "render.appearance_editor.v_up": "Texture V points upward",+ "render.appearance_editor.saved_state": "These optics are saved with this shot.",+ "render.appearance_editor.reflection_sampling": "Sampling for all reflective bodies"+ },+ "de": {+ "render.appearance_editor.glass": "Glas und Absorption",+ "render.appearance_editor.coat": "Klarlack",+ "render.appearance_editor.maps": "Texturen",+ "render.appearance_editor.saved": "Mit dieser Aufnahme gespeichert",+ "render.appearance_editor.reflections": "Reflexionen",+ "render.appearance_editor.glass_enable": "Physikalisches Glas für diesen Körper verwenden",+ "render.appearance_editor.recipe": "Rezept",+ "render.appearance_editor.boundary": "Grenzfläche",+ "render.appearance_editor.closed": "Geschlossener Körper",+ "render.appearance_editor.thin": "Dünne Schicht",+ "render.appearance_editor.box": "Quader",+ "render.appearance_editor.choose_image": "Bild wählen…",+ "render.appearance_editor.temporary": "Diese Optik gilt vorübergehend in diesem Tab. Speichern Sie sie mit der Aufnahme.",+ "render.appearance_editor.save": "Diese Optik speichern",+ "render.appearance_editor.remove": "Gespeicherte entfernen",+ "render.appearance_editor.replace": "Gespeicherte Optik dieses Körpers ersetzen",+ "render.appearance_editor.revalidate": "Diesen Körper erneut prüfen",+ "render.appearance_editor.remove_title": "Gespeicherte Optik entfernen?",+ "render.appearance_editor.remove_note": "Die gespeicherte Optik wird aus dieser Aufnahme entfernt. Geometrie und zugewiesene Looks bleiben erhalten.",+ "render.appearance_editor.gpu_reason": "Benötigt GPU-Pfadverfolgung.",+ "render.appearance_editor.cpu_reason": "Benötigt CPU-Strahlverfolgung.",+ "render.appearance_editor.body_reason": "Optische Bindungen gelten für einen ganzen Körper. Wählen Sie Körper, um diese Einstellungen zu bearbeiten.",+ "render.appearance_editor.save_reason": "Zum Speichern wird physikalisches Glas auf einem aktuellen GPU-Körper benötigt. Klarlack und lokale Bildtexturen bleiben vorübergehend.",+ "render.appearance_editor.glass_note": "Geschlossenes Glas verwendet geometrische Abstände. Es kann nicht mit Klarlack oder Texturen auf demselben Körper kombiniert werden.",+ "render.appearance_editor.thickness_reason": "Dicke gilt für dünne Schichten; geschlossenes Glas verwendet geometrische Abstände.",+ "render.appearance_editor.scatter_reason": "Innere Streuung benötigt einen geschlossenen Körper.",+ "render.appearance_editor.ior": "IOR",+ "render.appearance_editor.absorption": "Absorption",+ "render.appearance_editor.thickness": "Dicke",+ "render.appearance_editor.weight": "Gewicht",+ "render.appearance_editor.base_colour": "Grundfarbe",+ "render.appearance_editor.normal": "Normale",+ "render.appearance_editor.origin": "Ursprung",+ "render.appearance_editor.u_repeat": "U-Wiederholung",+ "render.appearance_editor.v_repeat": "V-Wiederholung",+ "render.appearance_editor.normal_strength": "Normalenstärke",+ "render.appearance_editor.v_up": "Textur-V zeigt nach oben",+ "render.appearance_editor.saved_state": "Diese Optik ist mit dieser Aufnahme gespeichert.",+ "render.appearance_editor.reflection_sampling": "Abtastung für alle reflektierenden Körper"+ },+ "ja": {+ "render.appearance_editor.glass": "ガラスと吸収",+ "render.appearance_editor.coat": "クリアコート",+ "render.appearance_editor.maps": "マップ",+ "render.appearance_editor.saved": "このショットに保存",+ "render.appearance_editor.reflections": "反射",+ "render.appearance_editor.glass_enable": "このボディに物理ガラスを使用",+ "render.appearance_editor.recipe": "レシピ",+ "render.appearance_editor.boundary": "境界",+ "render.appearance_editor.closed": "閉じたソリッド",+ "render.appearance_editor.thin": "薄板",+ "render.appearance_editor.box": "ボックス",+ "render.appearance_editor.choose_image": "画像を選択…",+ "render.appearance_editor.temporary": "この光学設定はこのタブで一時的に使用されます。ショットに保持するには保存してください。",+ "render.appearance_editor.save": "この光学設定を保存",+ "render.appearance_editor.remove": "保存済みを削除",+ "render.appearance_editor.replace": "このボディの保存済み光学設定を置換",+ "render.appearance_editor.revalidate": "このボディを再検証",+ "render.appearance_editor.remove_title": "保存済み光学設定を削除しますか?",+ "render.appearance_editor.remove_note": "このショットから保存済み光学設定を削除します。形状と割り当てた外観は保持されます。",+ "render.appearance_editor.gpu_reason": "GPUパストレーシングが必要です。",+ "render.appearance_editor.cpu_reason": "CPUレイトレーシングが必要です。",+ "render.appearance_editor.body_reason": "光学設定はボディ全体に適用されます。編集するにはボディを選択してください。",+ "render.appearance_editor.save_reason": "保存には現在のGPUボディの物理ガラスが必要です。コートとローカル画像マップは一時設定のままです。",+ "render.appearance_editor.glass_note": "閉じたガラスは形状から距離を求めます。同じボディにクリアコートやマップを併用できません。",+ "render.appearance_editor.thickness_reason": "厚さは薄板に適用されます。閉じたガラスは形状から距離を求めます。",+ "render.appearance_editor.scatter_reason": "内部散乱には閉じたソリッド境界が必要です。",+ "render.appearance_editor.ior": "IOR",+ "render.appearance_editor.absorption": "吸収",+ "render.appearance_editor.thickness": "厚さ",+ "render.appearance_editor.weight": "重み",+ "render.appearance_editor.base_colour": "ベースカラー",+ "render.appearance_editor.normal": "法線",+ "render.appearance_editor.origin": "原点",+ "render.appearance_editor.u_repeat": "Uリピート",+ "render.appearance_editor.v_repeat": "Vリピート",+ "render.appearance_editor.normal_strength": "法線強度",+ "render.appearance_editor.v_up": "テクスチャのVは上向き",+ "render.appearance_editor.saved_state": "この光学設定はこのショットに保存されています。",+ "render.appearance_editor.reflection_sampling": "すべての反射ボディのサンプリング"+ },+ "zh": {+ "render.appearance_editor.glass": "玻璃与吸收",+ "render.appearance_editor.coat": "清漆涂层",+ "render.appearance_editor.maps": "贴图",+ "render.appearance_editor.saved": "随此镜头保存",+ "render.appearance_editor.reflections": "反射",+ "render.appearance_editor.glass_enable": "对此实体使用物理玻璃",+ "render.appearance_editor.recipe": "配方",+ "render.appearance_editor.boundary": "边界",+ "render.appearance_editor.closed": "封闭实体",+ "render.appearance_editor.thin": "薄片",+ "render.appearance_editor.box": "长方体",+ "render.appearance_editor.choose_image": "选择图像…",+ "render.appearance_editor.temporary": "这些光学设置仅在此标签页临时生效。保存后可随镜头保留。",+ "render.appearance_editor.save": "保存这些光学设置",+ "render.appearance_editor.remove": "移除已保存设置",+ "render.appearance_editor.replace": "替换此实体已保存的光学设置",+ "render.appearance_editor.revalidate": "重新验证此实体",+ "render.appearance_editor.remove_title": "移除已保存的光学设置?",+ "render.appearance_editor.remove_note": "从此镜头中移除已保存的光学设置。几何形状和已分配的外观保持不变。",+ "render.appearance_editor.gpu_reason": "需要 GPU 路径追踪。",+ "render.appearance_editor.cpu_reason": "需要 CPU 光线追踪。",+ "render.appearance_editor.body_reason": "光学绑定针对单个完整实体。选择实体后可编辑这些控件。",+ "render.appearance_editor.save_reason": "保存需要当前 GPU 实体上的物理玻璃。清漆和本地图像贴图仍为临时设置。",+ "render.appearance_editor.glass_note": "封闭玻璃使用几何距离。同一实体不能同时使用清漆或贴图。",+ "render.appearance_editor.thickness_reason": "厚度适用于薄片;封闭玻璃使用几何距离。",+ "render.appearance_editor.scatter_reason": "内部散射需要封闭实体边界。",+ "render.appearance_editor.ior": "IOR",+ "render.appearance_editor.absorption": "吸收",+ "render.appearance_editor.thickness": "厚度",+ "render.appearance_editor.weight": "权重",+ "render.appearance_editor.base_colour": "基础颜色",+ "render.appearance_editor.normal": "法线",+ "render.appearance_editor.origin": "原点",+ "render.appearance_editor.u_repeat": "U 重复",+ "render.appearance_editor.v_repeat": "V 重复",+ "render.appearance_editor.normal_strength": "法线强度",+ "render.appearance_editor.v_up": "纹理 V 轴朝上",+ "render.appearance_editor.saved_state": "这些光学设置已随此镜头保存。",+ "render.appearance_editor.reflection_sampling": "所有反射实体的采样"+ },+ "ko": {+ "render.appearance_editor.glass": "유리와 흡수",+ "render.appearance_editor.coat": "클리어 코트",+ "render.appearance_editor.maps": "맵",+ "render.appearance_editor.saved": "이 샷에 저장됨",+ "render.appearance_editor.reflections": "반사",+ "render.appearance_editor.glass_enable": "이 바디에 물리 유리 사용",+ "render.appearance_editor.recipe": "레시피",+ "render.appearance_editor.boundary": "경계",+ "render.appearance_editor.closed": "닫힌 솔리드",+ "render.appearance_editor.thin": "얇은 시트",+ "render.appearance_editor.box": "상자",+ "render.appearance_editor.choose_image": "이미지 선택…",+ "render.appearance_editor.temporary": "이 광학 설정은 이 탭에서 임시로 사용됩니다. 샷과 함께 유지하려면 저장하세요.",+ "render.appearance_editor.save": "이 광학 설정 저장",+ "render.appearance_editor.remove": "저장된 설정 제거",+ "render.appearance_editor.replace": "이 바디의 저장된 광학 설정 교체",+ "render.appearance_editor.revalidate": "이 바디 다시 검증",+ "render.appearance_editor.remove_title": "저장된 광학 설정을 제거할까요?",+ "render.appearance_editor.remove_note": "이 샷에서 저장된 광학 설정을 제거합니다. 형상과 지정된 외관은 유지됩니다.",+ "render.appearance_editor.gpu_reason": "GPU 경로 추적이 필요합니다.",+ "render.appearance_editor.cpu_reason": "CPU 광선 추적이 필요합니다.",+ "render.appearance_editor.body_reason": "광학 바인딩은 하나의 전체 바디를 대상으로 합니다. 편집하려면 바디를 선택하세요.",+ "render.appearance_editor.save_reason": "저장하려면 현재 GPU 바디에 물리 유리가 필요합니다. 코트와 로컬 이미지 맵은 임시로 유지됩니다.",+ "render.appearance_editor.glass_note": "닫힌 유리는 형상 거리를 사용합니다. 같은 바디에 클리어 코트나 맵을 함께 사용할 수 없습니다.",+ "render.appearance_editor.thickness_reason": "두께는 얇은 시트에 적용됩니다. 닫힌 유리는 형상 거리를 사용합니다.",+ "render.appearance_editor.scatter_reason": "내부 산란에는 닫힌 솔리드 경계가 필요합니다.",+ "render.appearance_editor.ior": "IOR",+ "render.appearance_editor.absorption": "흡수",+ "render.appearance_editor.thickness": "두께",+ "render.appearance_editor.weight": "가중치",+ "render.appearance_editor.base_colour": "기본 색상",+ "render.appearance_editor.normal": "노멀",+ "render.appearance_editor.origin": "원점",+ "render.appearance_editor.u_repeat": "U 반복",+ "render.appearance_editor.v_repeat": "V 반복",+ "render.appearance_editor.normal_strength": "노멀 강도",+ "render.appearance_editor.v_up": "텍스처 V가 위쪽을 향함",+ "render.appearance_editor.saved_state": "이 광학 설정은 이 샷과 함께 저장되어 있습니다.",+ "render.appearance_editor.reflection_sampling": "모든 반사 바디의 샘플링"+ },+ "ar": {+ "render.appearance_editor.glass": "الزجاج والامتصاص",+ "render.appearance_editor.coat": "طبقة شفافة",+ "render.appearance_editor.maps": "الخرائط",+ "render.appearance_editor.saved": "محفوظ مع هذه اللقطة",+ "render.appearance_editor.reflections": "الانعكاسات",+ "render.appearance_editor.glass_enable": "استخدم زجاجًا فيزيائيًا على هذا الجسم",+ "render.appearance_editor.recipe": "الوصفة",+ "render.appearance_editor.boundary": "الحدود",+ "render.appearance_editor.closed": "جسم مصمت مغلق",+ "render.appearance_editor.thin": "صفيحة رقيقة",+ "render.appearance_editor.box": "مربع",+ "render.appearance_editor.choose_image": "اختر صورة…",+ "render.appearance_editor.temporary": "هذه الخصائص البصرية مؤقتة في هذا التبويب. احفظها لتبقى مع اللقطة.",+ "render.appearance_editor.save": "حفظ هذه الخصائص البصرية",+ "render.appearance_editor.remove": "إزالة المحفوظ",+ "render.appearance_editor.replace": "استبدال الخصائص البصرية المحفوظة لهذا الجسم",+ "render.appearance_editor.revalidate": "إعادة التحقق من هذا الجسم",+ "render.appearance_editor.remove_title": "إزالة الخصائص البصرية المحفوظة؟",+ "render.appearance_editor.remove_note": "أزل الخصائص البصرية المحفوظة من هذه اللقطة. تبقى الهندسة والمظاهر المعيّنة.",+ "render.appearance_editor.gpu_reason": "يتطلب تتبّع المسار على بطاقة الرسومات.",+ "render.appearance_editor.cpu_reason": "يتطلب تتبّع الأشعة على المعالج.",+ "render.appearance_editor.body_reason": "الربط البصري يستهدف جسمًا كاملًا واحدًا. اختر «جسم» لتحرير هذه الضوابط.",+ "render.appearance_editor.save_reason": "يتطلب حفظ هذه الخصائص البصرية زجاجًا فيزيائيًا على جسم حالي في بطاقة الرسومات. تبقى الطبقة الشفافة وخرائط الصور المحلية مؤقتة.",+ "render.appearance_editor.glass_note": "يستخدم الزجاج المغلق المسافة الهندسية. لا يمكن أن يشارك جسمًا مع طبقة شفافة أو خرائط.",+ "render.appearance_editor.thickness_reason": "السماكة تنطبق على الصفائح الرقيقة؛ الزجاج المغلق يستخدم المسافة الهندسية.",+ "render.appearance_editor.scatter_reason": "التشتت الداخلي يتطلب حدًّا لجسم مصمت مغلق.",+ "render.appearance_editor.ior": "معامل الانكسار",+ "render.appearance_editor.absorption": "الامتصاص",+ "render.appearance_editor.thickness": "السماكة",+ "render.appearance_editor.weight": "الوزن",+ "render.appearance_editor.base_colour": "اللون الأساسي",+ "render.appearance_editor.normal": "العادي",+ "render.appearance_editor.origin": "الأصل",+ "render.appearance_editor.u_repeat": "تكرار U",+ "render.appearance_editor.v_repeat": "تكرار V",+ "render.appearance_editor.normal_strength": "قوة العادي",+ "render.appearance_editor.v_up": "محور V للنسيج يشير للأعلى",+ "render.appearance_editor.saved_state": "هذه الخصائص البصرية محفوظة مع هذه اللقطة.",+ "render.appearance_editor.reflection_sampling": "أخذ العينات لكل الأجسام العاكسة"+ },+ "he": {+ "render.appearance_editor.glass": "זכוכית וספיגה",+ "render.appearance_editor.coat": "ציפוי שקוף",+ "render.appearance_editor.maps": "מפות",+ "render.appearance_editor.saved": "נשמר עם הצילום הזה",+ "render.appearance_editor.reflections": "השתקפויות",+ "render.appearance_editor.glass_enable": "השתמש בזכוכית פיזיקלית בגוף זה",+ "render.appearance_editor.recipe": "מתכון",+ "render.appearance_editor.boundary": "גבול",+ "render.appearance_editor.closed": "גוף מלא סגור",+ "render.appearance_editor.thin": "יריעה דקה",+ "render.appearance_editor.box": "תיבה",+ "render.appearance_editor.choose_image": "בחר תמונה…",+ "render.appearance_editor.temporary": "האופטיקה הזו זמנית בלשונית זו. שמור אותה כדי לשמור אותה עם הצילום.",+ "render.appearance_editor.save": "שמור אופטיקה זו",+ "render.appearance_editor.remove": "הסר את השמורה",+ "render.appearance_editor.replace": "החלף את האופטיקה השמורה של גוף זה",+ "render.appearance_editor.revalidate": "אמת מחדש גוף זה",+ "render.appearance_editor.remove_title": "להסיר את האופטיקה השמורה?",+ "render.appearance_editor.remove_note": "הסר את האופטיקה השמורה מהצילום הזה. הגאומטריה והמראות שהוקצו נשמרים.",+ "render.appearance_editor.gpu_reason": "דורש מעקב נתיב ב-GPU.",+ "render.appearance_editor.cpu_reason": "דורש מעקב קרניים במעבד.",+ "render.appearance_editor.body_reason": "קישורים אופטיים מכוונים לגוף שלם אחד. בחר גוף כדי לערוך את הבקרות האלה.",+ "render.appearance_editor.save_reason": "שמירת האופטיקה הזו דורשת זכוכית פיזיקלית בגוף GPU עדכני. הציפוי ומפות התמונה המקומיות נשארים זמניים.",+ "render.appearance_editor.glass_note": "זכוכית סגורה משתמשת במרחק גאומטרי. אי אפשר לשלב אותה עם ציפוי שקוף או מפות באותו גוף.",+ "render.appearance_editor.thickness_reason": "עובי חל על יריעות דקות; זכוכית סגורה משתמשת במרחק גאומטרי.",+ "render.appearance_editor.scatter_reason": "פיזור פנימי דורש גבול של גוף מלא סגור.",+ "render.appearance_editor.ior": "מקדם שבירה",+ "render.appearance_editor.absorption": "ספיגה",+ "render.appearance_editor.thickness": "עובי",+ "render.appearance_editor.weight": "משקל",+ "render.appearance_editor.base_colour": "צבע בסיס",+ "render.appearance_editor.normal": "נורמל",+ "render.appearance_editor.origin": "מקור",+ "render.appearance_editor.u_repeat": "חזרת U",+ "render.appearance_editor.v_repeat": "חזרת V",+ "render.appearance_editor.normal_strength": "עוצמת נורמל",+ "render.appearance_editor.v_up": "ציר V של הטקסטורה פונה כלפי מעלה",+ "render.appearance_editor.saved_state": "האופטיקה הזו נשמרת עם הצילום הזה.",+ "render.appearance_editor.reflection_sampling": "דגימה לכל הגופים המחזירים"+ },+ "vi": {+ "render.appearance_editor.glass": "Kính và hấp thụ",+ "render.appearance_editor.coat": "Lớp phủ trong",+ "render.appearance_editor.maps": "Bản đồ",+ "render.appearance_editor.saved": "Lưu cùng cảnh chụp này",+ "render.appearance_editor.reflections": "Phản xạ",+ "render.appearance_editor.glass_enable": "Dùng kính vật lý trên thân này",+ "render.appearance_editor.recipe": "Công thức",+ "render.appearance_editor.boundary": "Biên",+ "render.appearance_editor.closed": "Khối đặc kín",+ "render.appearance_editor.thin": "Tấm mỏng",+ "render.appearance_editor.box": "Hộp",+ "render.appearance_editor.choose_image": "Chọn ảnh…",+ "render.appearance_editor.temporary": "Các thuộc tính quang học này chỉ tạm thời trên tab này. Hãy lưu để giữ cùng cảnh chụp.",+ "render.appearance_editor.save": "Lưu các thuộc tính quang học này",+ "render.appearance_editor.remove": "Gỡ bản đã lưu",+ "render.appearance_editor.replace": "Thay thuộc tính quang học đã lưu của thân này",+ "render.appearance_editor.revalidate": "Kiểm tra lại thân này",+ "render.appearance_editor.remove_title": "Gỡ thuộc tính quang học đã lưu?",+ "render.appearance_editor.remove_note": "Gỡ thuộc tính quang học đã lưu khỏi cảnh chụp này. Hình học và diện mạo đã gán được giữ lại.",+ "render.appearance_editor.gpu_reason": "Cần dò đường đi của tia bằng GPU.",+ "render.appearance_editor.cpu_reason": "Cần dò tia bằng CPU.",+ "render.appearance_editor.body_reason": "Liên kết quang học nhắm vào một thân hoàn chỉnh. Hãy chọn Thân để chỉnh các điều khiển này.",+ "render.appearance_editor.save_reason": "Lưu các thuộc tính quang học này cần kính vật lý trên một thân GPU hiện hành. Lớp phủ và bản đồ ảnh cục bộ vẫn tạm thời.",+ "render.appearance_editor.glass_note": "Kính kín dùng khoảng cách hình học. Không thể dùng chung thân với lớp phủ trong hoặc bản đồ.",+ "render.appearance_editor.thickness_reason": "Độ dày áp dụng cho tấm mỏng; kính kín dùng khoảng cách hình học.",+ "render.appearance_editor.scatter_reason": "Tán xạ bên trong cần biên là khối đặc kín.",+ "render.appearance_editor.ior": "Chiết suất",+ "render.appearance_editor.absorption": "Hấp thụ",+ "render.appearance_editor.thickness": "Độ dày",+ "render.appearance_editor.weight": "Trọng số",+ "render.appearance_editor.base_colour": "Màu cơ bản",+ "render.appearance_editor.normal": "Pháp tuyến",+ "render.appearance_editor.origin": "Gốc",+ "render.appearance_editor.u_repeat": "Lặp U",+ "render.appearance_editor.v_repeat": "Lặp V",+ "render.appearance_editor.normal_strength": "Cường độ pháp tuyến",+ "render.appearance_editor.v_up": "Trục V của kết cấu hướng lên",+ "render.appearance_editor.saved_state": "Các thuộc tính quang học này được lưu cùng cảnh chụp này.",+ "render.appearance_editor.reflection_sampling": "Lấy mẫu cho mọi thân phản chiếu"+ }+}diff --git a/assets/locales/pending/render-appearance-inspector-ui.json b/assets/locales/pending/render-appearance-inspector-ui.jsonnew file mode 100644index 0000000000..d656415b96--- /dev/null+++ b/assets/locales/pending/render-appearance-inspector-ui.json@@ -0,0 +1,272 @@+{+ "en": {+ "render.inspector_advanced": "Advanced",+ "render.inspector_all_users": "All {count} users",+ "render.inspector_applies_to": "Applies to",+ "render.inspector_both_users": "Both users",+ "render.inspector_chain": "Where this look comes from",+ "render.inspector_colour": "Colour",+ "render.inspector_edit": "Edit",+ "render.inspector_finish": "Finish",+ "render.inspector_from_material": "From Material",+ "render.inspector_gloss": "Gloss",+ "render.inspector_material": "Material",+ "render.inspector_matte": "Matte",+ "render.inspector_metal": "Metal",+ "render.inspector_opacity": "Opacity",+ "render.inspector_opaque_help": "Finish and optical fields use opaque PBR (opacity 1). Lower opacity uses scalar shading.",+ "render.inspector_pick_target": "Pick a target of this type to inspect its appearance.",+ "render.inspector_remove": "Remove override",+ "render.inspector_replace": "Replace…",+ "render.inspector_reset": "Reset",+ "render.inspector_satin": "Satin",+ "render.inspector_save_library": "Save to library…",+ "render.inspector_set_all": "Mixed appearances. Editing sets the look on all selected targets.",+ "render.inspector_soon": "Soon",+ "render.inspector_target_limit": "Select at most 10000 targets to inspect appearances.",+ "render.inspector_textures": "Textures",+ "render.inspector_this_body": "This body",+ "render.inspector_this_component": "This component",+ "render.inspector_this_face": "This face",+ "render.inspector_this_target": "This target",+ "render.inspector_used_by": "Used by {count}",+ "render.shell_tab_lighting": "LIGHTING",+ "view.render_inspector": "Render Inspector"+ },+ "de": {+ "render.inspector_advanced": "Erweitert",+ "render.inspector_all_users": "Alle {count} Nutzer",+ "render.inspector_applies_to": "Anwenden auf",+ "render.inspector_both_users": "Beide Nutzer",+ "render.inspector_chain": "Herkunft dieses Aussehens",+ "render.inspector_colour": "Farbe",+ "render.inspector_edit": "Bearbeiten",+ "render.inspector_finish": "Oberfläche",+ "render.inspector_from_material": "Vom Material",+ "render.inspector_gloss": "Glanz",+ "render.inspector_material": "Material",+ "render.inspector_matte": "Matt",+ "render.inspector_metal": "Metall",+ "render.inspector_opacity": "Deckkraft",+ "render.inspector_opaque_help": "Oberfläche und optische Felder verwenden opakes PBR (Deckkraft 1). Geringere Deckkraft verwendet skalare Schattierung.",+ "render.inspector_pick_target": "Ein Ziel dieses Typs wählen, um sein Aussehen zu prüfen.",+ "render.inspector_remove": "Überschreibung entfernen",+ "render.inspector_replace": "Ersetzen…",+ "render.inspector_reset": "Zurücksetzen",+ "render.inspector_satin": "Seidenmatt",+ "render.inspector_save_library": "In Bibliothek speichern…",+ "render.inspector_set_all": "Gemischtes Aussehen. Eine Bearbeitung weist das Aussehen allen gewählten Zielen zu.",+ "render.inspector_soon": "Demnächst",+ "render.inspector_target_limit": "Zum Prüfen des Aussehens höchstens 10000 Ziele auswählen.",+ "render.inspector_textures": "Texturen",+ "render.inspector_this_body": "Dieser Körper",+ "render.inspector_this_component": "Diese Komponente",+ "render.inspector_this_face": "Diese Fläche",+ "render.inspector_this_target": "Dieses Ziel",+ "render.inspector_used_by": "Verwendet von {count}",+ "view.render_inspector": "Render-Inspektor"+ },+ "ja": {+ "render.inspector_advanced": "詳細",+ "render.inspector_all_users": "すべての{count}箇所",+ "render.inspector_applies_to": "適用先",+ "render.inspector_both_users": "両方の使用先",+ "render.inspector_chain": "外観の継承元",+ "render.inspector_colour": "色",+ "render.inspector_edit": "編集",+ "render.inspector_finish": "仕上げ",+ "render.inspector_from_material": "材料から継承",+ "render.inspector_gloss": "光沢",+ "render.inspector_material": "材料",+ "render.inspector_matte": "つや消し",+ "render.inspector_metal": "金属",+ "render.inspector_opacity": "不透明度",+ "render.inspector_opaque_help": "仕上げと光学特性には不透明PBR(不透明度1)を使用します。不透明度を下げるとスカラーシェーディングになります。",+ "render.inspector_pick_target": "この種類の対象を選択して外観を確認します。",+ "render.inspector_remove": "上書きを削除",+ "render.inspector_replace": "置換…",+ "render.inspector_reset": "リセット",+ "render.inspector_satin": "半光沢",+ "render.inspector_save_library": "ライブラリに保存…",+ "render.inspector_set_all": "外観が混在しています。編集すると選択したすべての対象に外観を設定します。",+ "render.inspector_soon": "近日公開",+ "render.inspector_target_limit": "外観の確認対象は10000個以下にしてください。",+ "render.inspector_textures": "テクスチャ",+ "render.inspector_this_body": "このボディ",+ "render.inspector_this_component": "このコンポーネント",+ "render.inspector_this_face": "この面",+ "render.inspector_this_target": "この対象",+ "render.inspector_used_by": "使用箇所: {count}",+ "render.shell_tab_lighting": "ライティング",+ "view.render_inspector": "レンダーインスペクター"+ },+ "zh": {+ "render.inspector_advanced": "高级",+ "render.inspector_all_users": "全部 {count} 个使用者",+ "render.inspector_applies_to": "应用范围",+ "render.inspector_both_users": "两个使用对象",+ "render.inspector_chain": "此外观的来源",+ "render.inspector_colour": "颜色",+ "render.inspector_edit": "编辑",+ "render.inspector_finish": "表面处理",+ "render.inspector_from_material": "来自材质",+ "render.inspector_gloss": "光泽",+ "render.inspector_material": "材质",+ "render.inspector_matte": "哑光",+ "render.inspector_metal": "金属",+ "render.inspector_opacity": "不透明度",+ "render.inspector_opaque_help": "表面处理和光学字段使用不透明 PBR(不透明度为 1)。降低不透明度会使用标量着色。",+ "render.inspector_pick_target": "拾取此类型的目标以检查其外观。",+ "render.inspector_remove": "移除覆盖",+ "render.inspector_replace": "替换…",+ "render.inspector_reset": "重置",+ "render.inspector_satin": "缎面",+ "render.inspector_save_library": "保存到库…",+ "render.inspector_set_all": "外观混合。编辑会将外观设置到所有选定目标。",+ "render.inspector_soon": "即将推出",+ "render.inspector_target_limit": "最多选择 10000 个目标以检查外观。",+ "render.inspector_textures": "纹理",+ "render.inspector_this_body": "此实体",+ "render.inspector_this_component": "此组件",+ "render.inspector_this_face": "此面",+ "render.inspector_this_target": "此目标",+ "render.inspector_used_by": "由 {count} 个对象使用",+ "render.shell_tab_lighting": "灯光",+ "view.render_inspector": "渲染检查器"+ },+ "ko": {+ "render.inspector_advanced": "고급",+ "render.inspector_all_users": "사용 대상 {count}개 모두",+ "render.inspector_applies_to": "적용 범위",+ "render.inspector_both_users": "두 사용 대상",+ "render.inspector_chain": "외관 출처",+ "render.inspector_colour": "색상",+ "render.inspector_edit": "편집",+ "render.inspector_finish": "마감",+ "render.inspector_from_material": "재질에서 상속",+ "render.inspector_gloss": "유광",+ "render.inspector_material": "재질",+ "render.inspector_matte": "무광",+ "render.inspector_metal": "금속",+ "render.inspector_opacity": "불투명도",+ "render.inspector_opaque_help": "마감 및 광학 필드는 불투명 PBR(불투명도 1)을 사용합니다. 불투명도를 낮추면 스칼라 음영을 사용합니다.",+ "render.inspector_pick_target": "이 유형의 대상을 선택하여 외관을 확인하세요.",+ "render.inspector_remove": "재정의 제거",+ "render.inspector_replace": "바꾸기…",+ "render.inspector_reset": "초기화",+ "render.inspector_satin": "반광",+ "render.inspector_save_library": "라이브러리에 저장…",+ "render.inspector_set_all": "외관이 혼합되어 있습니다. 편집하면 선택한 모든 대상에 외관을 설정합니다.",+ "render.inspector_soon": "출시 예정",+ "render.inspector_target_limit": "외관을 확인할 대상을 10000개 이하로 선택하세요.",+ "render.inspector_textures": "텍스처",+ "render.inspector_this_body": "이 바디",+ "render.inspector_this_component": "이 구성요소",+ "render.inspector_this_face": "이 면",+ "render.inspector_this_target": "이 대상",+ "render.inspector_used_by": "사용 대상 {count}개",+ "view.render_inspector": "렌더 검사기"+ },+ "ar": {+ "render.inspector_advanced": "متقدم",+ "render.inspector_all_users": "كل المستخدمين ({count})",+ "render.inspector_applies_to": "ينطبق على",+ "render.inspector_both_users": "كلا المستخدمين",+ "render.inspector_chain": "من أين يأتي هذا المظهر",+ "render.inspector_colour": "اللون",+ "render.inspector_edit": "تحرير",+ "render.inspector_finish": "اللمسة النهائية",+ "render.inspector_from_material": "من المادة",+ "render.inspector_gloss": "لمعان",+ "render.inspector_material": "المادة",+ "render.inspector_matte": "مطفأ",+ "render.inspector_metal": "معدن",+ "render.inspector_opacity": "العتامة",+ "render.inspector_opaque_help": "تستخدم اللمسة النهائية والحقول البصرية PBR معتمًا (عتامة 1). العتامة الأقل تستخدم تظليلًا قياسيًا.",+ "render.inspector_pick_target": "اختر هدفًا من هذا النوع لفحص مظهره.",+ "render.inspector_remove": "إزالة التجاوز",+ "render.inspector_replace": "استبدال…",+ "render.inspector_reset": "إعادة تعيين",+ "render.inspector_satin": "ساتان",+ "render.inspector_save_library": "حفظ في المكتبة…",+ "render.inspector_set_all": "مظاهر مختلطة. التحرير يضبط المظهر على كل الأهداف المحددة.",+ "render.inspector_soon": "قريبًا",+ "render.inspector_target_limit": "حدّد 10000 هدف كحد أقصى لفحص المظاهر.",+ "render.inspector_textures": "الخامات",+ "render.inspector_this_body": "هذا الجسم",+ "render.inspector_this_component": "هذا المكوّن",+ "render.inspector_this_face": "هذا الوجه",+ "render.inspector_this_target": "هذا الهدف",+ "render.inspector_used_by": "مستخدَم من {count}",+ "render.shell_tab_lighting": "الإضاءة",+ "view.render_inspector": "مفتش التصيير"+ },+ "he": {+ "render.inspector_advanced": "מתקדם",+ "render.inspector_all_users": "כל {count} המשתמשים",+ "render.inspector_applies_to": "חל על",+ "render.inspector_both_users": "שני המשתמשים",+ "render.inspector_chain": "מהיכן המראה הזה מגיע",+ "render.inspector_colour": "צבע",+ "render.inspector_edit": "עריכה",+ "render.inspector_finish": "גימור",+ "render.inspector_from_material": "מחומר",+ "render.inspector_gloss": "ברק",+ "render.inspector_material": "חומר",+ "render.inspector_matte": "מט",+ "render.inspector_metal": "מתכת",+ "render.inspector_opacity": "אטימות",+ "render.inspector_opaque_help": "שדות הגימור והאופטיקה משתמשים ב-PBR אטום (אטימות 1). אטימות נמוכה יותר משתמשת בהצללה סקלרית.",+ "render.inspector_pick_target": "בחר יעד מסוג זה כדי לבדוק את המראה שלו.",+ "render.inspector_remove": "הסר עקיפה",+ "render.inspector_replace": "החלף…",+ "render.inspector_reset": "איפוס",+ "render.inspector_satin": "סאטן",+ "render.inspector_save_library": "שמור בספרייה…",+ "render.inspector_set_all": "מראות מעורבים. העריכה קובעת את המראה בכל היעדים שנבחרו.",+ "render.inspector_soon": "בקרוב",+ "render.inspector_target_limit": "בחר עד 10000 יעדים כדי לבדוק מראות.",+ "render.inspector_textures": "טקסטורות",+ "render.inspector_this_body": "גוף זה",+ "render.inspector_this_component": "רכיב זה",+ "render.inspector_this_face": "פאה זו",+ "render.inspector_this_target": "יעד זה",+ "render.inspector_used_by": "בשימוש של {count}",+ "render.shell_tab_lighting": "תאורה",+ "view.render_inspector": "מפקח רינדור"+ },+ "vi": {+ "render.inspector_advanced": "Nâng cao",+ "render.inspector_all_users": "Cả {count} người dùng",+ "render.inspector_applies_to": "Áp dụng cho",+ "render.inspector_both_users": "Cả hai người dùng",+ "render.inspector_chain": "Diện mạo này đến từ đâu",+ "render.inspector_colour": "Màu",+ "render.inspector_edit": "Sửa",+ "render.inspector_finish": "Hoàn thiện",+ "render.inspector_from_material": "Từ vật liệu",+ "render.inspector_gloss": "Bóng",+ "render.inspector_material": "Vật liệu",+ "render.inspector_matte": "Mờ",+ "render.inspector_metal": "Kim loại",+ "render.inspector_opacity": "Độ đục",+ "render.inspector_opaque_help": "Các trường hoàn thiện và quang học dùng PBR đục (độ đục 1). Độ đục thấp hơn dùng tô bóng vô hướng.",+ "render.inspector_pick_target": "Chọn một đích thuộc loại này để xem diện mạo của nó.",+ "render.inspector_remove": "Gỡ ghi đè",+ "render.inspector_replace": "Thay…",+ "render.inspector_reset": "Đặt lại",+ "render.inspector_satin": "Satin",+ "render.inspector_save_library": "Lưu vào thư viện…",+ "render.inspector_set_all": "Diện mạo hỗn hợp. Chỉnh sửa sẽ đặt diện mạo cho mọi đích đã chọn.",+ "render.inspector_soon": "Sắp có",+ "render.inspector_target_limit": "Chọn tối đa 10000 đích để xem diện mạo.",+ "render.inspector_textures": "Kết cấu",+ "render.inspector_this_body": "Thân này",+ "render.inspector_this_component": "Thành phần này",+ "render.inspector_this_face": "Mặt này",+ "render.inspector_this_target": "Đích này",+ "render.inspector_used_by": "Được {count} dùng",+ "render.shell_tab_lighting": "ÁNH SÁNG",+ "view.render_inspector": "Bảng thuộc tính kết xuất"+ }+}diff --git a/crates/engine/src/cmd/view_navigation.rs b/crates/engine/src/cmd/view_navigation.rsindex 0404ee67f4..5e23781fe2 100644--- a/crates/engine/src/cmd/view_navigation.rs+++ b/crates/engine/src/cmd/view_navigation.rs@@ -55,6 +55,9 @@ CommandSpec::new("view.render_browser", "Render Browser", crate::checked!("view..icon("list").noundo().doc_only().contract(&BROWSER_CONTRACT).output(output_schema_for::<RenderBrowserRequest>).params("open: bool; or by_look?: bool; search?: bool; query?: string (up to 1024 bytes) → validated transient Browser controls; never edits the design or opens a dialog"),+CommandSpec::new("view.render_inspector", "Render Inspector", render_inspector)+ .icon("inspect").noundo().doc_only()+ .params("visible: bool → {visible}; per-document Inspector visibility; never edits the design or opens a dialog"),CommandSpec::new("view.render_select", "Render selection", render_select).icon("select").noundo().doc_only().params("kind: nothing|environment|light|shot|output; id?: bounded nonempty string for light/shot → validated transient Browser focus; never edits the design or opens a dialog"),@@ -320,6 +323,16 @@ fn render_dock(_s: &mut Session, p: &Value) -> Result<Value> {serde_json::to_value(request).map_err(|e| bad("view.render_dock", e.to_string()))}+fn render_inspector(_s: &mut Session, p: &Value) -> Result<Value> {+ #[derive(serde::Deserialize)]+ #[serde(deny_unknown_fields)]+ struct Request {+ visible: bool,+ }+ let request: Request = serde_json::from_value(p.clone()).map_err(|e| bad("view.render_inspector", e.to_string()))?;+ Ok(json!({"visible":request.visible}))+}+fn shots_strip(_s: &mut Session, p: &Value) -> Result<Value> {#[derive(serde::Deserialize)]#[serde(deny_unknown_fields)]@@ -1162,3 +1175,19 @@ fn render_browser_controls_validate_without_document_changes_or_evaluation() {assert!(std::sync::Arc::ptr_eq(&document, &session.doc));assert_eq!(before, (session.undo.len(), session.redo.len(), session.revision, session.evaluations, session.is_dirty()));}++#[test]+fn render_inspector_visibility_is_validated_without_mutation() {+ let mut session = Session::default();+ let before = session.doc.to_json();+ let revision = session.revision;+ for visible in [false, true] {+ assert_eq!(session.execute("view.render_inspector", &json!({"visible":visible})).unwrap(), json!({"visible":visible}));+ }+ for value in [json!({}), json!({"visible":null}), json!({"visible":"false"}), json!({"visible":true,"extra":1})] {+ assert!(session.execute("view.render_inspector", &value).is_err());+ }+ assert_eq!(session.doc.to_json(), before);+ assert_eq!(session.revision, revision);+ assert!(session.undo.is_empty());+}diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rsindex ff532eaa41..395b7c7eef 100644--- a/crates/ui-egui/src/browser.rs+++ b/crates/ui-egui/src/browser.rs@@ -902,6 +902,7 @@ fn render_card(app: &mut SolveApp, ui: &mut egui::Ui, acts: &mut Actions) {bounds: crate::ui_kit::Panel::stack_first_bounds(bounds),fill_height: true,compact: crate::render_ui::compact(app, bounds.width()),+ editor: false,enabled: true,header_actions: None,},diff --git a/crates/ui-egui/src/dialogs_appearance.rs b/crates/ui-egui/src/dialogs_appearance.rsindex 4d0d2cdecc..798b2fe9ef 100644--- a/crates/ui-egui/src/dialogs_appearance.rs+++ b/crates/ui-egui/src/dialogs_appearance.rs@@ -239,7 +239,7 @@ pub fn start(app: &SolveApp, id: &str) -> Option<(Kind, Vec<SelInput>)> {}/// The command giving `targets` (bodies or faces) a look.-fn apply_params(targets: &[Sel], color: [u8; 3], opacity: f64, look: Option<&str>, pbr: Option<PbrParameters>) -> Option<Value> {+pub(crate) fn apply_params(targets: &[Sel], color: [u8; 3], opacity: f64, look: Option<&str>, pbr: Option<PbrParameters>) -> Option<Value> {let bodies: Vec<String> = targets.iter().filter_map(|x| if let Sel::Body { name } = x { Some(name.clone()) } else { None }).collect();let faces: Vec<Value> = targets.iter()@@ -304,7 +304,11 @@ pub(super) fn selected_params(k: &Ap, items: &[Sel]) -> Option<Value> {/// Removing an override restores the inherited component or material appearance.fn clear_params(k: &Ap, items: &[Sel]) -> Option<Value> {- let mut p = selected_params(k, items)?;+ Some(without_look(selected_params(k, items)?))+}++/// Shared clear form for dialogs and the selection Inspector.+pub(crate) fn without_look(mut p: Value) -> Value {if let Some(obj) = p.as_object_mut() {obj.remove("appearance");obj.remove("name");@@ -312,7 +316,7 @@ fn clear_params(k: &Ap, items: &[Sel]) -> Option<Value> {obj.remove("opacity");obj.remove("pbr");}- Some(p)+ p}/// What a swatch dropped now would land on: the face or body under the cursor in the viewport,@@ -360,6 +364,17 @@ fn in_design(app: &mut SolveApp) -> Vec<(Look, usize)> {out}+/// Replacement pickers share the dialog's design looks and admitted library recipes.+pub(crate) fn replacement_library(app: &mut SolveApp) -> Vec<Look> {+ let mut looks: Vec<_> = in_design(app).into_iter().map(|(look, _)| look).collect();+ for look in library(app).into_iter().filter(preset_available) {+ if !looks.iter().any(|saved| saved.name == look.name && saved.color == look.color && saved.opacity == look.opacity && saved.pbr == look.pbr) {+ looks.push(look);+ }+ }+ looks+}+fn c32(c: [u8; 3], opacity: f64) -> Color32 {Color32::from_rgba_unmultiplied(c[0], c[1], c[2], (opacity.clamp(0.0, 1.0) * 255.0) as u8)}diff --git a/crates/ui-egui/src/dialogs_library.rs b/crates/ui-egui/src/dialogs_library.rsindex 58df6cd669..71fcccedfa 100644--- a/crates/ui-egui/src/dialogs_library.rs+++ b/crates/ui-egui/src/dialogs_library.rs@@ -31,6 +31,19 @@ fn editor<'a>(app: &'a mut SolveApp, token: &Arc<()>) -> Option<&'a mut Ap> {Arc::ptr_eq(&k.local.token, token).then_some(k)}+/// Parameterless UI activation of the existing export command. JSON execution never picks files.+pub(crate) fn start_export(app: &mut SolveApp) {+ let origin = app.session.doc.clone();+ app.pick_save("my-library.solidcraft-library.json", &["json"], move |app, path| {+ if let Some(path) = path+ && Arc::ptr_eq(&origin, &app.session.doc)+ && let Err(error) = app.run("library.export", json!({"path":path,"overwrite":false}))+ {+ app.set_status(error, true);+ }+ });+}+fn save_library(app: &mut SolveApp, token: Arc<()>, overwrite: bool) {let origin = app.session.doc.clone();app.pick_save("my-library.solidcraft-library.json", &["json"], move |app, path| {diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rsindex c30ea04a30..b957917b7c 100644--- a/crates/ui-egui/src/i18n.rs+++ b/crates/ui-egui/src/i18n.rs@@ -700,6 +700,10 @@ mod tests {// rather than requiring its spelling to differ from English.assert!(locale.0.messages().contains_key("toolbar.render_studio"));assert_eq!(locale.label("STUDIO"), locale.text("toolbar.render_studio"));+ let english: Messages = serde_json::from_str(ENGLISH.source).unwrap();+ for id in english.keys().filter(|id| id.starts_with("render.inspector_")) {+ assert!(locale.0.messages().contains_key(id), "{language}: {id}");+ }for id in ["render.pick_label","render.pick_body",diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex c20c0ac8b2..40fd16edab 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -1061,6 +1061,9 @@ impl SolveApp {}_ => {}}+ if id == "view.render_inspector" {+ render_workspace::set_inspector_visible(self, v.get("visible").and_then(Value::as_bool).unwrap_or(true));+ }if id == "view.render_browser" {render_workspace::apply_browser_controls(self, v);}@@ -1355,6 +1358,10 @@ impl SolveApp {self.home.open = false;return;}+ if id == "library.export" {+ dialogs_library::start_export(self);+ return;+ }// A display toggle leaves the current modelling tool and camera in place.if matches!(id, "view.fit" | "view.home" | "view.spin" | "view.grid" | "view.ground_shadow" | "view.navigation_bar") {let _ = self.run(id, json!({}));diff --git a/crates/ui-egui/src/render_ui/appearance.rs b/crates/ui-egui/src/render_ui/appearance.rsnew file mode 100644index 0000000000..5c5c7a03c4--- /dev/null+++ b/crates/ui-egui/src/render_ui/appearance.rs@@ -0,0 +1,575 @@+//! Selection-following appearance editor. All mutations use the appearance registry.+use crate::{SolveApp, dialogs_appearance, ui_kit};+use serde_json::{Value, json};+use solidcraft_engine::{+ Sel,+ doc::{Document, appearance::Look, pbr_appearance::PbrParameters},+};+use std::sync::{Arc, Weak};+use ui_kit::LookStep;++#[derive(Clone, Debug, Default)]+pub(super) struct View {+ selection: Vec<Sel>,+ mode: usize,+ pick_mode: usize,+ inspected: Option<LookStep>,+ all_users: bool,+ revision: Option<u64>,+ document: Option<Weak<Document>>,+ draft: Option<Look>,+ saved: Option<Vec<Option<Look>>>,+ dirty: bool,+ replace_search: String,+ replacements: Vec<dialogs_appearance::Look>,+}++#[derive(Clone, Debug, Default)]+pub(super) struct Targets {+ items: Vec<Sel>,+ components: Vec<u64>,+}+impl Targets {+ fn params(&self, look: &Look) -> Option<Value> {+ let mut params = dialogs_appearance::apply_params(&self.items, look.color, look.opacity, Some(&look.name), look.pbr)+ .or_else(|| (!self.components.is_empty()).then(|| look_params(look)))?;+ if !self.components.is_empty() {+ // Assignment's existing target form accepts component names or string IDs.+ params["components"] = json!(self.components.iter().map(u64::to_string).collect::<Vec<_>>());+ }+ Some(params)+ }+ fn queries(&self) -> Vec<Value> {+ self.items+ .iter()+ .filter_map(|item| match item {+ Sel::Body { name } => Some(json!({"body":name})),+ Sel::Face { body, index, .. } => Some(json!({"body":body,"face":index})),+ _ => None,+ })+ .chain(self.components.iter().map(|id| json!({"component":id})))+ .collect()+ }+}++fn mode_step(mode: usize) -> LookStep {+ match mode {+ 1 => LookStep::Face,+ 2 => LookStep::Component,+ _ => LookStep::Body,+ }+}+fn step_index(step: LookStep) -> usize {+ match step {+ LookStep::Face => 0,+ LookStep::Body => 1,+ LookStep::Component => 2,+ LookStep::Material => 3,+ }+}+pub(super) fn targets(app: &SolveApp, step: LookStep) -> Targets {+ let mut targets = Targets::default();+ let state = app.session.world_state();+ for selection in &app.session.selection {+ let body = match selection {+ Sel::Body { name } | Sel::Face { body: name, .. } => state.body(name),+ _ => None,+ };+ match step {+ LookStep::Face => {+ if matches!(selection, Sel::Face { .. }) {+ targets.items.push(selection.clone());+ }+ }+ LookStep::Body => {+ if let Some(body) = body {+ targets.items.push(Sel::Body { name: body.name.clone() });+ }+ if let Sel::Occurrence { path } = selection+ && let Ok(bodies) = app.session.occurrence_bodies(path, true)+ {+ for name in bodies {+ targets.items.push(Sel::Body { name });+ if targets.items.len() > 10_000 {+ return targets;+ }+ }+ }+ }+ LookStep::Component => {+ let component = body.map(|body| app.session.doc.model_body_component(body)).or_else(|| {+ let Sel::Occurrence { path } = selection else { return None };+ app.session.occurrence_placement(path).ok().map(|placement| placement.component)+ });+ if let Some(component) = component.filter(|id| *id != 0) {+ targets.components.push(component);+ }+ }+ LookStep::Material => {}+ }+ }+ let mut unique = std::collections::BTreeSet::new();+ targets.items.retain(|item| match item {+ Sel::Body { name } => unique.insert((name.clone(), None)),+ Sel::Face { body, index, .. } => unique.insert((body.clone(), Some(*index))),+ _ => false,+ });+ targets.components.sort_unstable();+ targets.components.dedup();+ targets+}++fn decode_look(value: &Value) -> Option<Look> {+ Some(Look {+ name: value.get("name")?.as_str()?.into(),+ color: dialogs_appearance::parse_color(value.get("color")?)?,+ opacity: value.get("opacity")?.as_f64()?,+ pbr: value.get("pbr").filter(|v| !v.is_null()).and_then(|p| serde_json::from_value(p.clone()).ok()),+ })+}+pub(super) fn chains(app: &mut SolveApp, targets: &Targets) -> Result<Vec<[Option<Look>; 4]>, String> {+ targets+ .queries()+ .into_iter()+ .map(|target| {+ let reply = app.session.execute("appearance.chain", &json!({"target":target})).map_err(|e| e.to_string())?;+ let mut chain = [None, None, None, None];+ if let Some(steps) = reply.get("steps").and_then(Value::as_array) {+ for (slot, step) in chain.iter_mut().zip(steps) {+ *slot = step.get("look").and_then(decode_look);+ }+ }+ Ok(chain)+ })+ .collect()+}+fn look_params(look: &Look) -> Value {+ json!({"name":look.name,"color":look.color,"opacity":look.opacity,"pbr":look.pbr})+}+pub(super) fn users(app: &SolveApp, look: &Look) -> usize {+ assigned_looks(app).filter(|l| *l == look).count()+}+fn assigned_looks(app: &SolveApp) -> impl Iterator<Item = &Look> {+ let appearances = &app.session.doc.appearances;+ appearances.bodies.values().chain(appearances.components.values()).chain(appearances.faces.iter().map(|f| &f.look))+}+pub(super) fn assign(app: &mut SolveApp, targets: &Targets, from: &Look, to: &Look, all_users: bool) -> Result<(), String> {+ if all_users {+ app.run("appearance.replace", json!({"from":look_params(from),"to":look_params(to)}))?;+ } else if let Some(params) = targets.params(to) {+ app.run("appearance.assign", params)?;+ }+ Ok(())+}+pub(super) fn clear(app: &mut SolveApp, targets: &Targets, look: &Look) -> Result<(), String> {+ if let Some(params) = targets.params(look) {+ app.run("appearance.assign", dialogs_appearance::without_look(params))?;+ }+ Ok(())+}++// The same validated response used by the existing material/appearance editors.+pub(super) fn finish(look: &mut Look, index: usize) -> Result<(), String> {+ let (metallic, roughness) = match index {+ 0 => (0.0, 0.85),+ 1 => (0.0, 0.5),+ 2 => (0.0, 0.12),+ _ => (1.0, 0.32),+ };+ look.pbr = Some(PbrParameters::new(metallic, roughness, look.pbr.unwrap_or_default().dielectric_ior()).map_err(|e| e.to_string())?);+ look.opacity = 1.0;+ Ok(())+}+fn finish_index(look: &Look) -> usize {+ let p = look.pbr.unwrap_or_default();+ if p.metallic() >= 0.5 {+ 3+ } else if p.roughness() >= 0.7 {+ 0+ } else if p.roughness() <= 0.2 {+ 2+ } else {+ 1+ }+}+fn sphere(look: &Look) -> ui_kit::Sphere {+ super::super::library::tile_sphere(&look_params(look))+}+pub(super) fn mixed<T: PartialEq>(looks: &[Look], value: impl Fn(&Look) -> T) -> bool {+ looks.first().is_some_and(|first| looks.iter().skip(1).any(|look| value(look) != value(first)))+}+pub(super) fn inspected_look(chain: &[Option<Look>; 4], step: Option<LookStep>) -> Option<&Look> {+ chain.iter().skip(step.map_or(0, step_index)).flatten().next()+}+fn source_step(chain: &[Option<Look>; 4], inspected: Option<LookStep>) -> Option<LookStep> {+ chain+ .iter()+ .enumerate()+ .skip(inspected.map_or(0, step_index))+ .find_map(|(index, look)| look.as_ref().and_then(|_| LookStep::ALL.get(index)).copied())+}+fn ended(response: &egui::Response, ui: &egui::Ui) -> bool {+ response.drag_stopped()+ || response.lost_focus()+ || response.changed() && !response.has_focus() && !ui.input(|i| i.pointer.any_down()) && !ui.ctx().egui_wants_keyboard_input()+}++pub(super) fn scope_label(app: &SolveApp) -> &str {+ app.tr(match app.session.selection.last() {+ Some(Sel::Occurrence { .. }) => "render.pick_component",+ Some(Sel::Face { .. }) => "render.pick_face",+ _ => "render.pick_body",+ })+}++pub(super) fn reset(app: &mut SolveApp) {+ let view = &app.render_workspace.view.inspector.selection_appearance;+ if view.selection != app.session.selection || view.document.as_ref().is_none_or(|d| !Weak::ptr_eq(d, &Arc::downgrade(&app.session.doc))) {+ return;+ }+ let step = view.inspected.unwrap_or(mode_step(view.mode));+ let selected = targets(app, step);+ if let Some(saved) = view.saved.clone() {+ let single_targets = selected+ .items+ .into_iter()+ .map(|item| Targets { items: vec![item], components: vec![] })+ .chain(selected.components.into_iter().map(|id| Targets { items: vec![], components: vec![id] }));+ for (target, look) in single_targets.zip(saved) {+ let result =+ if let Some(look) = look { assign(app, &target, &look, &look, false) } else { clear(app, &target, &Look::custom([0; 3], 1.0)) };+ if let Err(error) = result {+ app.set_status(error, true);+ break;+ }+ }+ app.render_workspace.view.inspector.selection_appearance.revision = None;+ }+}++pub(super) fn remove(app: &mut SolveApp) {+ let view = &app.render_workspace.view.inspector.selection_appearance;+ let selected = targets(app, view.inspected.unwrap_or(mode_step(view.mode)));+ if let Some(look) = view.draft.clone() {+ if let Err(error) = clear(app, &selected, &look) {+ app.set_status(error, true);+ }+ app.render_workspace.view.inspector.selection_appearance.revision = None;+ }+}++pub(super) fn footer(app: &mut SolveApp, ui: &mut egui::Ui) {+ ui.horizontal(|ui| {+ let enabled = !app.session.selection.is_empty();+ if ui_kit::icon_label_action(ui, app.tr("render.inspector_save_library"), Some("plus"), enabled, false)+ .on_hover_text(app.tr_label("Export design library..."))+ .clicked()+ {+ app.start("library.export");+ }+ ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {+ if ui_kit::text_button(ui, app.tr("render.inspector_reset"), enabled).clicked() {+ reset(app);+ }+ });+ });+}++/// Returns false only when the explicit-target fallback should be shown.+pub(super) fn controls(app: &mut SolveApp, ui: &mut egui::Ui) -> bool {+ if app.session.selection.is_empty() {+ app.render_workspace.view.inspector.selection_appearance = View::default();+ return false;+ }+ if app.session.selection.len() > 10_000 {+ ui_kit::text(ui, app.tr("render.inspector_target_limit"), ui_kit::Text::Note("render.inspector_target_limit"));+ return true;+ }+ let mut view = std::mem::take(&mut app.render_workspace.view.inspector.selection_appearance);+ let pick_mode = if app.ui.pick_components { 2 } else { usize::from(!app.ui.pick_bodies) };+ if view.selection == app.session.selection && view.pick_mode != pick_mode {+ view.mode = pick_mode;+ view.inspected = None;+ view.saved = None;+ view.revision = None;+ view.all_users = false;+ }+ view.pick_mode = pick_mode;+ if view.selection != app.session.selection {+ view.selection = app.session.selection.clone();+ view.mode = if app.ui.pick_components || view.selection.iter().any(|s| matches!(s, Sel::Occurrence { .. })) {+ 2+ } else if view.selection.iter().any(|s| matches!(s, Sel::Face { .. })) {+ 1+ } else {+ 0+ };+ view.inspected = None;+ view.saved = None;+ view.revision = None;+ view.all_users = false;+ }+ let options = [app.tr("render.pick_face"), app.tr("render.pick_body"), app.tr("render.pick_component")].map(str::to_owned);+ let mut kind = match view.mode {+ 0 => 1,+ 1 => 0,+ _ => 2,+ };+ if ui_kit::segmented(+ ui,+ &mut kind,+ &options.each_ref().map(String::as_str),+ ui_kit::Segments { compact: true, dense: true, workspace_accent: true, icons: &["surface", "body", "component"], ..Default::default() },+ ) {+ view.mode = match kind {+ 0 => 1,+ 1 => 0,+ _ => 2,+ };+ view.inspected = None;+ view.saved = None;+ view.revision = None;+ view.all_users = false;+ let mode = match view.mode {+ 1 => "face",+ 2 => "component",+ _ => "body",+ };+ let _ = app.run("select.filter", json!({"mode":mode}));+ view.pick_mode = view.mode;+ }+ let selected_targets = targets(app, mode_step(view.mode));+ let t = crate::theme::Tokens::get();+ let result = ui_kit::settings_form(ui, t.form_label_width + t.space_8, |ui| draw(app, ui, &mut view, &selected_targets));+ if let Err(error) = result {+ ui_kit::text(ui, &error, ui_kit::Text::Error("render:appearance:error"));+ }+ let body = if view.inspected.unwrap_or(mode_step(view.mode)) == LookStep::Body && selected_targets.items.len() == 1 {+ match selected_targets.items.first() {+ Some(Sel::Body { name }) => Some(name.as_str()),+ _ => None,+ }+ } else {+ None+ };+ ui_kit::settings_form(ui, t.form_label_width + t.space_8, |ui| super::materials::selection_controls(app, ui, body));+ // Resource forms keep their existing explicit prepare/review/apply flow until+ // the Surfaces and references editor owns them. They never duplicate optics.+ let resource_kinds = ["surfaces", "materials", "selene_appearances", "physical_profiles"];+ if resource_kinds.iter().any(|kind| super::library::selected_kind(app, kind)) {+ let title = app.tr("render.inspector_advanced").to_owned();+ ui_kit::editor_section(ui, "render:appearance:resources", &title, true, |ui| super::library::inspect_kinds(app, ui, &resource_kinds));+ }+ app.render_workspace.view.inspector.selection_appearance = view;+ true+}+fn draw(app: &mut SolveApp, ui: &mut egui::Ui, view: &mut View, selected: &Targets) -> Result<(), String> {+ if selected.items.len().saturating_add(selected.components.len()) > 10_000 {+ return Err(app.tr("render.inspector_target_limit").into());+ }+ let chains = chains(app, selected)?;+ let Some(chain) = chains.first() else {+ ui_kit::text(ui, app.tr("render.inspector_pick_target"), ui_kit::Text::Note("render.inspector_pick_target"));+ return Ok(());+ };+ let default_color = crate::theme::Tokens::get().body;+ let default = Look::custom([default_color.r(), default_color.g(), default_color.b()], 1.0);+ let looks: Vec<_> = chains+ .iter()+ .enumerate()+ .map(|(index, chain)| {+ inspected_look(chain, view.inspected)+ .cloned()+ .or_else(|| {+ selected.items.get(index).filter(|_| !matches!(view.inspected, Some(LookStep::Component | LookStep::Material))).and_then(|item| {+ match item {+ Sel::Body { name } | Sel::Face { body: name, .. } => {+ app.session.world_state().body(name).and_then(|body| app.session.doc.model_display_look(body))+ }+ _ => None,+ }+ })+ })+ .unwrap_or_else(|| default.clone())+ })+ .collect();+ let Some(from) = looks.first() else { return Ok(()) };+ if view.saved.is_none() {+ view.saved =+ Some(chains.iter().map(|chain| chain.get(step_index(view.inspected.unwrap_or(mode_step(view.mode)))).cloned().flatten()).collect());+ }+ let is_mixed = mixed(&looks, Clone::clone);+ let distinct: std::collections::BTreeSet<_> = looks.iter().map(|look| look_params(look).to_string()).collect();+ let count =+ if !is_mixed { users(app, from) } else { assigned_looks(app).filter(|look| distinct.contains(&look_params(look).to_string())).count() };+ let active = source_step(chain, None).unwrap_or(mode_step(view.mode));+ let source_step = source_step(chain, view.inspected).unwrap_or(mode_step(view.mode));+ let replaceable = !is_mixed && count > 0 && source_step != LookStep::Material;+ if !replaceable {+ view.all_users = false;+ }+ if view.revision != Some(app.session.revision) || view.document.as_ref().is_none_or(|d| !Weak::ptr_eq(d, &Arc::downgrade(&app.session.doc))) {+ view.draft = Some(from.clone());+ view.dirty = false;+ view.revision = Some(app.session.revision);+ view.document = Some(Arc::downgrade(&app.session.doc));+ view.replacements = dialogs_appearance::replacement_library(app);+ }+ let mut draft = view.draft.clone().unwrap_or_else(|| from.clone());+ let name = if is_mixed { app.tr("render.tree_mixed").to_owned() } else { from.name.clone() };+ let source = app.tr(if source_step == LookStep::Material { "render.inspector_material" } else { "render.library_in_design" }).to_owned();+ let used = crate::i18n::format("render.inspector_used_by", &[("count", &count.to_string())]);+ let replacements = &view.replacements;+ let ids: Vec<_> = (0..replacements.len()).map(|index| index.to_string()).collect();+ let handles: Vec<_> = ids.iter().map(|id| format!("render:appearance:replace:{id}")).collect();+ let options: Vec<_> = replacements+ .iter()+ .zip(&ids)+ .zip(&handles)+ .map(|((look, id), handle)| ui_kit::SearchOption { value: id, label: &look.name, handle: Some(handle) })+ .collect();+ let mut inspected = None;+ let selected_step = view.inspected.unwrap_or(active);+ let chain_labels = [app.tr("render.pick_face"), app.tr("render.pick_body"), app.tr("render.pick_component"), app.tr("render.inspector_material")];+ let replacement = ui_kit::sphere_preview_with_source(+ ui,+ "render:appearance:preview",+ sphere(&draft),+ &name,+ &used,+ |ui| {+ let response = ui_kit::compact_dropdown_menu(ui, "render_appearance_chain", &source, |ui| {+ ui.set_min_width(crate::theme::Tokens::get().form_label_width * 3.0);+ if let Some(step) =+ ui_kit::look_chain(ui, "render:appearance:chain", chain_labels, chain.each_ref().map(|l| l.as_ref().map(sphere)), selected_step)+ {+ inspected = Some(step);+ ui.close();+ }+ });+ crate::scenario::publish_target("render:appearance:chain-menu", response.rect.intersect(ui.clip_rect()));+ response+ },+ |ui| ui_kit::searchable_icon_dropdown(ui, "spin", app.tr("render.inspector_replace"), &mut view.replace_search, &options),+ );+ if let Some(step) = inspected {+ view.inspected = Some(step);+ view.saved = None;+ view.revision = None;+ view.all_users = false;+ return Ok(());+ }+ if let Some(to) = replacement.and_then(|id| id.parse::<usize>().ok()).and_then(|index| replacements.get(index)) {+ let to = Look { name: to.name.clone(), color: to.color, opacity: to.opacity, pbr: to.pbr };+ let step = view.inspected.filter(|step| *step != LookStep::Material).unwrap_or(mode_step(view.mode));+ let replace_targets = targets(app, step);+ assign(app, &replace_targets, from, &to, view.all_users)?;+ view.revision = None;+ return Ok(());+ }+ let step = view.inspected.unwrap_or(mode_step(view.mode));+ let mut scope = usize::from(view.all_users);+ let all_label = crate::i18n::format("render.inspector_all_users", &[("count", &count.to_string())]);+ let this_label = app+ .tr(match step {+ LookStep::Face => "render.inspector_this_face",+ LookStep::Component => "render.inspector_this_component",+ _ => "render.inspector_this_body",+ })+ .to_owned();+ ui_kit::row(ui, app.tr("render.inspector_applies_to"), |ui| {+ ui.add_enabled_ui(replaceable, |ui| {+ ui_kit::segmented(+ ui,+ &mut scope,+ &[&this_label, &all_label],+ ui_kit::Segments { compact: true, small: true, workspace_accent: true, ..Default::default() },+ )+ });+ });+ view.all_users = scope == 1;+ let edit_targets = targets(app, step);+ let mut commit = false;+ let edit_title = app.tr("render.inspector_edit").to_owned();+ ui_kit::editor_section(ui, "render:appearance:edit", &edit_title, true, |ui| {+ if is_mixed {+ ui_kit::text(ui, app.tr("render.inspector_set_all"), ui_kit::Text::Note("render.inspector_set_all"));+ }+ let editable = step != LookStep::Material && (!edit_targets.items.is_empty() || !edit_targets.components.is_empty());+ ui.add_enabled_ui(editable, |ui| {+ ui_kit::row(ui, app.tr("render.inspector_colour"), |ui| {+ let response = ui_kit::color_hex_field(ui, &mut draft.color, mixed(&looks, |l| l.color).then(|| app.tr("render.tree_mixed")));+ view.dirty |= response.changed();+ commit |= ended(&response, ui);+ });+ let mut preset = finish_index(&draft);+ let states = if mixed(&looks, |l| l.pbr) { [false; 4] } else { std::array::from_fn(|i| i == preset) };+ ui_kit::row(ui, app.tr("render.inspector_finish"), |ui| {+ let labels =+ ["render.inspector_matte", "render.inspector_satin", "render.inspector_gloss", "render.inspector_metal"].map(|key| app.tr(key));+ if ui_kit::segmented(+ ui,+ &mut preset,+ &labels,+ ui_kit::Segments { states: &states, compact: true, small: true, workspace_accent: true, ..Default::default() },+ ) {+ if let Err(error) = finish(&mut draft, preset) {+ app.set_status(error, true);+ } else {+ view.dirty = true;+ commit = true;+ }+ }+ });+ let mut p = draft.pbr.unwrap_or_default();+ let mut metallic = p.metallic();+ let mut roughness = p.roughness();+ let mut ior = p.dielectric_ior();+ let mut optical_edit = false;+ for (key, value, range, mixed) in [+ ("appearance.metallic", &mut metallic, 0.0..=1.0, mixed(&looks, |l| l.pbr.unwrap_or_default().metallic())),+ ("appearance.roughness", &mut roughness, 0.045..=1.0, mixed(&looks, |l| l.pbr.unwrap_or_default().roughness())),+ ] {+ ui_kit::row(ui, app.tr(key), |ui| {+ let response = ui_kit::mixed_slider(ui, value, range, mixed.then(|| app.tr("render.tree_mixed")));+ view.dirty |= response.changed();+ optical_edit |= response.changed();+ commit |= ended(&response, ui);+ });+ }+ ui_kit::row(ui, app.tr("render.inspector_opacity"), |ui| {+ let response =+ ui_kit::mixed_slider(ui, &mut draft.opacity, 0.0..=1.0, mixed(&looks, |l| l.opacity).then(|| app.tr("render.tree_mixed")));+ view.dirty |= response.changed();+ commit |= ended(&response, ui);+ if response.changed() && draft.opacity < 1.0 {+ draft.pbr = None;+ }+ });+ ui_kit::row(ui, app.tr("render.appearance_editor.ior"), |ui| {+ let response = ui_kit::mixed_scalar_field(+ ui,+ &mut ior,+ 1.0..=3.0,+ mixed(&looks, |l| l.pbr.unwrap_or_default().dielectric_ior()).then(|| app.tr("render.tree_mixed")),+ );+ view.dirty |= response.changed();+ optical_edit |= response.changed();+ commit |= ended(&response, ui);+ });+ ui_kit::text(ui, app.tr("render.inspector_opaque_help"), ui_kit::Text::Note("render.inspector_opaque_help"));+ if optical_edit && let Ok(parameters) = PbrParameters::new(metallic, roughness, ior) {+ p = parameters;+ draft.pbr = Some(p);+ draft.opacity = 1.0;+ }+ });+ });+ commit |= view.dirty && !ui.input(|i| i.pointer.any_down()) && !ui.ctx().egui_wants_keyboard_input();+ if commit && view.dirty && (draft != *from || is_mixed) {+ assign(app, &edit_targets, from, &draft, view.all_users)?;+ view.revision = None;+ }+ view.draft = Some(draft);+ Ok(())+}diff --git a/crates/ui-egui/src/render_workspace.rs b/crates/ui-egui/src/render_workspace.rsindex a3a71d5d41..17aced7543 100644--- a/crates/ui-egui/src/render_workspace.rs+++ b/crates/ui-egui/src/render_workspace.rs@@ -151,6 +151,7 @@ impl PathHost {}/// The samples slider's top end: 2^12 = 4096 samples per pixel.+#[cfg(test)]const MAX_SAMPLES_EXPONENT: u32 = 12;/// Setup times kept per adapter, at most.@@ -593,6 +594,7 @@ pub(crate) fn select_stage(app: &mut SolveApp, key: &str) {_ => return,};app.render_workspace.view.stage = stage;+ app.render_workspace.view.inspector.hidden = false;app.render_workspace.view.inspector.page = stage.page();let sections: &[&str] = match stage {Stage::Look => &["objects"],@@ -627,6 +629,10 @@ pub(crate) fn job_ready(app: &SolveApp, id: &str) -> Result<(), String> {ribbon::action_ready(app, id)}+pub(crate) fn set_inspector_visible(app: &mut SolveApp, visible: bool) {+ app.render_workspace.view.inspector.hidden = !visible;+}+pub fn panel(app: &mut SolveApp, ui: &mut egui::Ui) {if crate::render_ui::focused(app) {return;@@ -766,18 +772,10 @@ fn method_selector(app: &mut SolveApp, ui: &mut egui::Ui) {});crate::scenario::publish_handle("render:method", response.rect.center());if image_host(app, app.render_workspace.view.method).is_err() {- if app.render_workspace.view.inspector.page == inspector::Page::All {- ui.small(app.tr("render.setup_offline_help"));- } else {- crate::ui_kit::text(ui, app.tr("render.setup_offline_help"), crate::ui_kit::Text::Note("render.setup_offline_help"));- }+ crate::ui_kit::text(ui, app.tr("render.setup_offline_help"), crate::ui_kit::Text::Note("render.setup_offline_help"));}if app.render_workspace.view.method != ImageMethod::Raster {- if app.render_workspace.view.inspector.page == inspector::Page::All {- ui.small(app.tr("render.preview_image_settings_help"));- } else {- crate::ui_kit::text(ui, app.tr("render.preview_image_settings_help"), crate::ui_kit::Text::Note("render.preview_image_settings_help"));- }+ crate::ui_kit::text(ui, app.tr("render.preview_image_settings_help"), crate::ui_kit::Text::Note("render.preview_image_settings_help"));}}@@ -830,6 +828,7 @@ fn cpu_lighting_controls(app: &mut SolveApp, ui: &mut egui::Ui) {crate::ui_kit::checkbox(ui, &shadows, &mut app.render_workspace.view.raytrace.shadows);}+#[cfg(test)]fn image_method_controls(app: &mut SolveApp, ui: &mut egui::Ui) {method_selector(app, ui);if app.render_workspace.view.method != ImageMethod::CpuRaytrace {@@ -843,6 +842,7 @@ fn image_method_controls(app: &mut SolveApp, ui: &mut egui::Ui) {cpu::controls(app, ui);}+#[cfg(test)]fn image_edit_controls(app: &mut SolveApp, ui: &mut egui::Ui) {ui.heading(app.tr("render.image_title"));let preview = app.tr("render.result_preview").to_string();diff --git a/crates/ui-egui/src/render_workspace_cpu.rs b/crates/ui-egui/src/render_workspace_cpu.rsindex 58a52730d7..37ce0cfe31 100644--- a/crates/ui-egui/src/render_workspace_cpu.rs+++ b/crates/ui-egui/src/render_workspace_cpu.rs@@ -127,7 +127,9 @@ pub(super) enum Environment {#[derive(Clone, Debug)]pub(super) struct View {+ #[cfg(test)]pub selected_body: Option<String>,+ #[cfg(test)]pub body_filter: String,pub environment: Environment,pub hdr: hdr::Input,@@ -164,7 +166,9 @@ pub(super) struct Checked {impl Default for View {fn default() -> Self {Self {+ #[cfg(test)]selected_body: None,+ #[cfg(test)]body_filter: String::new(),environment: Environment::None,hdr: hdr::Input::default(),@@ -322,6 +326,7 @@ pub(super) fn params(app: &SolveApp, params: &mut Value) -> Result<(), String> {Ok(())}+#[cfg(test)]pub(super) fn controls(app: &mut SolveApp, ui: &mut egui::Ui) {for (id, key, section) in [("render_cpu_reflections", "render.cpu_reflections", 0),@@ -338,6 +343,7 @@ pub(super) fn controls(app: &mut SolveApp, ui: &mut egui::Ui) {ui.small(app.tr("render.cpu_runtime_help"));}+#[cfg(test)]pub(super) fn reflection_controls(app: &mut SolveApp, ui: &mut egui::Ui) {ui.small(app.tr("render.cpu_reflection_help"));let entries = app.render_workspace.view.raytrace.reflections.as_ref().map(|r| r.bodies.clone()).unwrap_or_default();@@ -413,13 +419,16 @@ pub(super) fn reflection_controls(app: &mut SolveApp, ui: &mut egui::Ui) {{app.set_status(error, true);}+ reflection_sampling_controls(app, ui);+}++/// Existing global reflection budget, shared during the Sampling-editor migration.+pub(super) fn reflection_sampling_controls(app: &mut SolveApp, ui: &mut egui::Ui) {let depth = app.tr("render.cpu_reflection_depth").to_string();let samples = app.tr("render.cpu_reflection_samples").to_string();if let Some(reflections) = &mut app.render_workspace.view.raytrace.reflections {- ui.label(depth);- ui_kit::number_field(ui, &mut reflections.max_bounces, 1..=8, 1.0, "");- ui.label(samples);- ui_kit::number_field(ui, &mut reflections.samples, 1..=64, 1.0, "");+ ui_kit::row(ui, &depth, |ui| ui_kit::number_field(ui, &mut reflections.max_bounces, 1..=8, 1.0, ""));+ ui_kit::row(ui, &samples, |ui| ui_kit::number_field(ui, &mut reflections.samples, 1..=64, 1.0, ""));} else {ui.small(app.tr("render.cpu_reflection_empty"));}diff --git a/crates/ui-egui/src/render_workspace_inspector.rs b/crates/ui-egui/src/render_workspace_inspector.rsindex 12fb80a211..67d4386d00 100644--- a/crates/ui-egui/src/render_workspace_inspector.rs+++ b/crates/ui-egui/src/render_workspace_inspector.rs@@ -1,17 +1,19 @@//! Contextual native Render UI. One workspace, existing command authority and shared controls.//! Page navigation is per document; unsupported backend capabilities never emit dummy parameters.use super::{ImageMethod, cpu, library, materials, setups, studio};-use crate::{SolveApp, theme::Tokens, ui_kit};+use crate::{SolveApp, ui_kit};use serde_json::{Value, json};use solidcraft_engine::doc::Document;use std::sync::{Arc, Weak};+#[path = "render_ui/appearance.rs"]+mod selection_appearance;+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]pub(super) enum Page {#[default]Scene,Appearance,- Aging,Effects,Lighting,Environment,@@ -19,13 +21,14 @@ pub(super) enum Page {Camera,Output,Diagnostics,+ #[cfg(test)]All,}impl Page {- const ALL: [Self; 11] = [+ #[cfg(test)]+ const ALL: [Self; 10] = [Self::Scene,Self::Appearance,- Self::Aging,Self::Lighting,Self::Environment,Self::Background,@@ -39,7 +42,6 @@ impl Page {match self {Self::Scene => "render.page_scene",Self::Appearance => "render.page_appearance",- Self::Aging => "render.page_aging",Self::Effects => "render.page_effects",Self::Lighting => "render.page_lighting",Self::Environment => "render.page_environment",@@ -47,6 +49,7 @@ impl Page {Self::Camera => "render.page_camera",Self::Output => "render.page_output",Self::Diagnostics => "render.page_diagnostics",+ #[cfg(test)]Self::All => "render.page_all",}}@@ -54,7 +57,6 @@ impl Page {match self {Self::Scene => "scene",Self::Appearance => "appearance",- Self::Aging => "aging",Self::Effects => "effects",Self::Lighting => "lighting",Self::Environment => "environment",@@ -62,6 +64,7 @@ impl Page {Self::Camera => "camera",Self::Output => "output",Self::Diagnostics => "diagnostics",+ #[cfg(test)]Self::All => "all",}}@@ -69,7 +72,6 @@ impl Page {match self {Self::Scene => "render_scene",Self::Appearance => "appearance",- Self::Aging => "appearance",Self::Effects => "camera",Self::Lighting => "settings",Self::Environment => "environment_map",@@ -77,6 +79,7 @@ impl Page {Self::Camera => "camera",Self::Output => "export",Self::Diagnostics => "inspect",+ #[cfg(test)]Self::All => "list",}}@@ -84,6 +87,7 @@ impl Page {#[derive(Clone, Debug)]pub(super) struct View {pub effects: super::effects::View,+ pub hidden: bool,pub page: Page,reveal: Option<&'static str>,pending: Option<Pending>,@@ -99,6 +103,7 @@ pub(super) struct View {ground_color: [f64; 3],replace_ground: bool,appearance: Appearance,+ selection_appearance: selection_appearance::View,resolution: Resolution,}/// Editor-only coupling. The fixed rational anchor prevents repeated rounded@@ -189,6 +194,7 @@ impl Default for View {fn default() -> Self {Self {effects: Default::default(),+ hidden: false,page: Page::Scene,reveal: None,pending: None,@@ -204,6 +210,7 @@ impl Default for View {ground_color: [0.18; 3],replace_ground: false,appearance: Appearance::default(),+ selection_appearance: Default::default(),resolution: Resolution::default(),}}@@ -214,6 +221,10 @@ pub(super) fn record_check(app: &mut SolveApp, request: &Value, reply: &Value) {}pub(super) fn panel(app: &mut SolveApp, ui: &mut egui::Ui) {+ if app.render_workspace.view.inspector.hidden {+ crate::shell::register_panel(app, "render:inspector", None, None);+ return;+ }setups::refresh_dirty(app);if app.render_workspace.revision != app.session.revision && !app.render_workspace.view.dirty {setups::load(app);@@ -221,9 +232,25 @@ pub(super) fn panel(app: &mut SolveApp, ui: &mut egui::Ui) {let bounds = crate::shell::panel_bounds(app, ui.available_rect_before_wrap());let mut side = app.preferences.render_inspector_side.clone();let mut width = app.preferences.render_inspector_width;- let title = app.tr("render.studio_title").to_string();- let icon = app.render_workspace.view.inspector.page.icon();- let content = ui_kit::Panel::workspace(+ let appearance_editor = app.render_workspace.view.inspector.page == Page::Appearance;+ let selection_appearance = appearance_editor && !app.session.selection.is_empty();+ let title = if selection_appearance {+ app.session+ .selection+ .last()+ .and_then(|item| match item {+ solidcraft_engine::Sel::Body { name } | solidcraft_engine::Sel::Face { body: name, .. } => Some(name.clone()),+ solidcraft_engine::Sel::Occurrence { path } => app.session.occurrence_placement(path).ok().map(|placement| placement.name),+ _ => None,+ })+ .unwrap_or_else(|| app.tr("render.inspector").to_owned())+ } else {+ app.tr("render.studio_title").to_string()+ };+ let icon = if selection_appearance { "body" } else { app.render_workspace.view.inspector.page.icon() };+ let scope = selection_appearance::scope_label(app).to_owned();+ let header_action = std::cell::Cell::new(None);+ let content = ui_kit::Panel::workspace_with_header(ui,ui_kit::WorkspaceOptions {id: "render:inspector",@@ -232,15 +259,23 @@ pub(super) fn panel(app: &mut SolveApp, ui: &mut egui::Ui) {bounds,fill_height: true,compact: crate::render_ui::compact(app, bounds.width()),+ editor: appearance_editor,enabled: true,header_actions: None,},&mut side,&mut width,+ false,+ |ui, options| {+ if appearance_editor {+ header_action.set(ui_kit::inspector_header(ui, options.icon, options.title, &scope));+ } else {+ ui_kit::panel::header(ui, options.icon, options.title, || header_action.set(Some(ui_kit::InspectorAction::Close)));+ }+ },|ui| {- ui_kit::scope(ui, |ui| {+ if !appearance_editor {header(app, ui);- pages(app, ui);ui_kit::Panel::pinned_footer(ui, "render_job_footer", 4, |ui| {ui.separator();super::job_controls(app, ui, true);@@ -251,38 +286,47 @@ pub(super) fn panel(app: &mut SolveApp, ui: &mut egui::Ui) {}crate::scenario::publish_rect("render:job-footer", ui.min_rect());});- let page = app.render_workspace.view.inspector.page;- egui::ScrollArea::vertical().id_salt(("render_inspector", page.handle(), app.docs.active)).auto_shrink([false, false]).show(- ui,- |ui| {- ui_kit::text(ui, app.tr(page.key()), ui_kit::Text::Heading(page.key()));- match page {- Page::Scene => scene_controls(app, ui),- Page::Appearance => appearance_controls(app, ui),- Page::Aging => super::effects::aging_controls(app, ui),- Page::Effects => super::effects::presentation_controls(app, ui),- Page::Lighting => lighting_controls(app, ui),- Page::Environment => environment_controls(app, ui),- Page::Background => background_controls(app, ui),- Page::Camera => camera_controls(app, ui),- Page::Output => output_controls(app, ui),- Page::Diagnostics => diagnostics(app, ui),- Page::All => {- ui_kit::text(ui, app.tr("render.all_controls_help"), ui_kit::Text::Note("render.all_controls_help"));- camera_actions(app, ui);- let title = app.tr("render.page_camera").to_string();- ui_kit::section(ui, "render_all_camera", &title, false, |ui| camera_controls(app, ui));- let title = app.tr("render.page_aging").to_string();- ui_kit::section(ui, "render_all_aging", &title, false, |ui| super::effects::aging_controls(app, ui));- super::image_edit_controls(app, ui);- }- }- setups::refresh_dirty(app);- },- );+ }+ if appearance_editor {+ ui_kit::Panel::editor_footer(ui, "render_appearance_footer", |ui| selection_appearance::footer(app, ui));+ }+ let page = app.render_workspace.view.inspector.page;+ egui::ScrollArea::vertical().id_salt(("render_inspector", page.handle(), app.docs.active)).auto_shrink([false, false]).show(ui, |ui| {+ if !appearance_editor {+ ui_kit::text(ui, app.tr(page.key()), ui_kit::Text::Heading(page.key()));+ }+ match page {+ Page::Scene => scene_controls(app, ui),+ Page::Appearance => appearance_controls(app, ui),+ Page::Effects => super::effects::presentation_controls(app, ui),+ Page::Lighting => lighting_controls(app, ui),+ Page::Environment => environment_controls(app, ui),+ Page::Background => background_controls(app, ui),+ Page::Camera => camera_controls(app, ui),+ Page::Output => output_controls(app, ui),+ Page::Diagnostics => diagnostics(app, ui),+ #[cfg(test)]+ Page::All => {+ ui_kit::text(ui, app.tr("render.all_controls_help"), ui_kit::Text::Note("render.all_controls_help"));+ camera_actions(app, ui);+ let title = app.tr("render.page_camera").to_string();+ ui_kit::section(ui, "render_all_camera", &title, false, |ui| camera_controls(app, ui));+ let title = app.tr("render.page_aging").to_string();+ ui_kit::section(ui, "render_all_aging", &title, false, |ui| super::effects::aging_controls(app, ui));+ super::image_edit_controls(app, ui);+ }+ }+ setups::refresh_dirty(app);});},);+ match header_action.get() {+ Some(ui_kit::InspectorAction::Close) => {+ let _ = app.run("view.render_inspector", json!({"visible":false}));+ }+ Some(ui_kit::InspectorAction::Remove) => selection_appearance::remove(app),+ None => {}+ }app.preferences.render_inspector_width = width;let requested = content.as_ref()@@ -299,30 +343,6 @@ pub(super) fn panel(app: &mut SolveApp, ui: &mut egui::Ui) {}confirmation(app, ui.ctx());}-fn pages(app: &mut SolveApp, ui: &mut egui::Ui) {- let page = app.render_workspace.view.inspector.page;- let mut index = Page::ALL.iter().position(|p| *p == page).unwrap_or(0);- let options: Vec<_> =- Page::ALL.iter().map(|page| ui_kit::IconSegment { key: page.handle(), icon: page.icon(), tip: app.tr(page.key()).to_string() }).collect();- let top = ui.cursor().min;- let width = ui.available_width();- let height = ui_kit::row_height();- if ui_kit::segmented_icons(ui, &mut index, &options, &[])- && let Some(page) = Page::ALL.get(index)- {- app.render_workspace.view.inspector.page = *page;- }- for (i, page) in Page::ALL.iter().enumerate() {- crate::scenario::publish_target(- &format!("render:page:{}", page.handle()),- egui::Rect::from_min_size(- top + egui::vec2(width * i as f32 / Page::ALL.len() as f32, 0.0),- egui::vec2(width / Page::ALL.len() as f32, height),- ),- );- }- ui.add_space(Tokens::get().space_4);-}fn header(app: &mut SolveApp, ui: &mut egui::Ui) {let current = app.render_workspace.view.name.clone();let names: Vec<_> = app.session.doc.render.setups.keys().cloned().collect();@@ -358,7 +378,7 @@ fn header(app: &mut SolveApp, ui: &mut egui::Ui) {});let status = if app.render_workspace.view.dirty { app.tr("render.unsaved") } else { app.tr("render.studio_saved") };ui.add_sized([ui.available_width(), ui.text_style_height(&egui::TextStyle::Body)], egui::Label::new(status).truncate());- if app.render_workspace.view.inspector.page != Page::All {+ {let labels = [app.tr("render.result_preview").to_string(), app.tr("render.result_title").to_string()];let mut value = usize::from(app.render_workspace.view.result);if ui_kit::segmented(ui, &mut value, &labels.iter().map(String::as_str).collect::<Vec<_>>(), Default::default()) {@@ -416,6 +436,7 @@ fn perform_action(app: &mut SolveApp, action: PendingAction) -> Result<(), Strin}fn confirmation(app: &mut SolveApp, ctx: &egui::Context) {super::shots::confirmation(app, ctx);+ materials::confirmation(app, ctx);let Some(pending) = app.render_workspace.view.inspector.pending.clone() else { return };if pending.revision != app.session.revision || !Weak::ptr_eq(&pending.document, &Arc::downgrade(&app.session.doc)) {app.render_workspace.view.inspector.pending = None;@@ -602,16 +623,21 @@ fn shot_controls(app: &mut SolveApp, ui: &mut egui::Ui) {});}fn appearance_controls(app: &mut SolveApp, ui: &mut egui::Ui) {+ if selection_appearance::controls(app, ui) {+ return;+ }ui_kit::text(ui, app.tr("render.appearance_physics_separate"), ui_kit::Text::Note("render.appearance_physics_separate"));base_appearance(app, ui);+ materials::controls(app, ui);+ let title = app.tr("render.inspector_advanced").to_owned();+ reveal_section(app, ui, "render:appearance:advanced");+ ui_kit::section(ui, "render:appearance:advanced", &title, false, |ui| advanced_appearance_controls(app, ui));+}+fn advanced_appearance_controls(app: &mut SolveApp, ui: &mut egui::Ui) {browse_button(app, ui, "surfaces", "render.browse_surfaces");browse_button(app, ui, "physical_profiles", "render.browse_physical");library::inspect_kinds(app, ui, &["surfaces", "materials", "selene_appearances", "physical_profiles"]);- library::saved_surface_controls(app, ui);- materials::controls(app, ui);- if app.render_workspace.view.method == ImageMethod::CpuRaytrace {- cpu::reflection_controls(app, ui);- }+ super::effects::aging_controls(app, ui);}fn lighting_controls(app: &mut SolveApp, ui: &mut egui::Ui) {browse_button(app, ui, "rigs", "render.browse_rigs");@@ -1155,7 +1181,7 @@ fn camera_actions(app: &mut SolveApp, ui: &mut egui::Ui) {}pub(super) fn confirmation_open(app: &SolveApp) -> bool {- app.render_workspace.view.inspector.pending.is_some() || app.render_workspace.view.save_shot_name.is_some()+ app.render_workspace.view.inspector.pending.is_some() || app.render_workspace.view.save_shot_name.is_some() || materials::confirmation_open(app)}pub(super) fn reveal(app: &mut SolveApp, section: &'static str) {app.render_workspace.view.inspector.reveal = Some(section);diff --git a/crates/ui-egui/src/render_workspace_inspector_tests.rs b/crates/ui-egui/src/render_workspace_inspector_tests.rsindex 898b3560a1..b5bb60466c 100644--- a/crates/ui-egui/src/render_workspace_inspector_tests.rs+++ b/crates/ui-egui/src/render_workspace_inspector_tests.rs@@ -1,5 +1,5 @@use super::*;-use crate::scenario::Harness;+use crate::{scenario::Harness, theme::Tokens};fn fixture() -> Harness {let mut h = Harness::new();h.call("ui.resize", json!({"width":1440,"height":1000}));@@ -25,6 +25,9 @@ fn native_inspector_defaults_to_output_and_keeps_job_actions_on_screen_in_both_sh.app.render_workspace.view.inspector.page = page;h.frames(3);let inspector = crate::scenario::rect_of("render:inspector").unwrap();+ if page == Page::Appearance {+ continue;+ }let footer = crate::scenario::rect_of("render:job-footer").unwrap();assert!(inspector.contains_rect(footer), "footer outside inspector at {page:?}: {inspector:?} {footer:?}");for name in ["render:check", "render:start", "render:cancel", "render:export"] {@@ -41,20 +44,21 @@ fn native_inspector_defaults_to_output_and_keeps_job_actions_on_screen_in_both_s}}#[test]-fn icon_page_navigation_is_local_and_never_switches_executor_or_overwrites_drafts() {+fn stage_navigation_is_local_and_never_switches_executor_or_overwrites_drafts() {let mut h = fixture();let before = h.app.session.doc.to_json();h.app.render_workspace.view.samples = 37;h.app.render_workspace.view.draft.width = 777;- for page in Page::ALL {- h.step(&json!({"click":{"handle":format!("render:page:{}",page.handle())}})).unwrap();- assert_eq!(h.app.render_workspace.view.inspector.page, page);+ for stage in super::super::Stage::ALL {+ h.step(&json!({"click":{"handle":format!("render:stage:{}",stage.key())}})).unwrap();+ assert_eq!(h.app.render_workspace.view.inspector.page, stage.page());assert_eq!(h.app.render_workspace.view.method, ImageMethod::Raster);assert_eq!(h.app.render_workspace.view.samples, 37);assert_eq!(h.app.render_workspace.view.draft.width, 777);assert_eq!(h.app.session.doc.to_json(), before);}}+#[test]fn dirty_shot_switch_keep_discard_and_save_are_explicit_and_lossless() {let mut h = fixture();@@ -305,7 +309,7 @@ fn ribbon_navigation_reuses_inspector_and_preserves_exact_unsaved_intent() {("render.stage.clear", Page::Background),("render.hdr.inspect", Page::Environment),("render.settings.capture_hdr", Page::Environment),- ("render.aging.describe", Page::Aging),+ ("render.aging.describe", Page::Appearance),("render.effects.describe", Page::Effects),("render.backends", Page::Diagnostics),] {@@ -516,7 +520,7 @@ fn aging_tab_adds_reorders_disables_and_persists_layers_without_engineering_editlet before = h.app.session.doc.to_json();h.app.start("render.aging.describe");h.frames(3);- assert_eq!(h.app.render_workspace.view.inspector.page, Page::Aging);+ assert_eq!(h.app.render_workspace.view.inspector.page, Page::Appearance);assert!(!crate::icon_svg::resolve(solidcraft_engine::find_command("render.aging.describe").unwrap().icon).placeholder);for code in [1, 3] {h.step(&json!({"click":{"handle":"render:aging-add"}})).unwrap();@@ -757,3 +761,601 @@ fn browser_shot_menus_keep_target_and_draft_through_confirmation() {assert_eq!(h.app.render_workspace.view.name, "B");assert_eq!(h.app.render_workspace.view.draft.width, 456, "removing another shot preserves this draft");}++#[test]+fn appearance_inspector_targets_and_chain_follow_body_face_and_component() {+ use super::selection_appearance::{chains, inspected_look, targets};+ use solidcraft_engine::{Sel, geom::Vec3};+ let mut h = Harness::new();+ h.app.run("component.create", json!({"name":"Part"})).unwrap();+ h.app.run("solid.box", json!({"body_name":"Subject","length":20,"width":15,"height":10})).unwrap();+ h.app.run("material.assign", json!({"bodies":["Subject"],"material":"Steel"})).unwrap();+ h.app.run("appearance.assign", json!({"components":["Part"],"appearance":"ABS - Blue"})).unwrap();+ h.app.run("appearance.assign", json!({"bodies":["Subject"],"appearance":"ABS - Red"})).unwrap();+ h.app.run("appearance.assign", json!({"body":"Subject","faces":[[10,7,10]],"appearance":"Copper"})).unwrap();+ let face = h.app.run("model.faces", json!({"body":"Subject"})).unwrap()["faces"]+ .as_array()+ .unwrap()+ .iter()+ .find(|f| f["point"][2] == 10.0)+ .unwrap()["index"]+ .as_u64()+ .unwrap() as usize;+ h.app.session.selection = vec![Sel::Face { body: "Subject".into(), index: face, point: Vec3::new(10.0, 7.0, 10.0) }];+ let before = h.app.session.doc.to_json();+ for (step, present) in [+ (ui_kit::LookStep::Face, [true, true, true, true]),+ (ui_kit::LookStep::Body, [false, true, true, true]),+ (ui_kit::LookStep::Component, [false, false, true, true]),+ ] {+ let target = targets(&h.app, step);+ let chain = chains(&mut h.app, &target).unwrap();+ assert_eq!(chain[0].each_ref().map(Option::is_some), present);+ assert_eq!(inspected_look(&chain[0], Some(ui_kit::LookStep::Component)).unwrap().name, "ABS - Blue");+ assert_eq!(inspected_look(&chain[0], Some(ui_kit::LookStep::Material)).unwrap().name, "Steel");+ let mut inherited = chain[0].clone();+ inherited[1] = None;+ inherited[2] = None;+ assert_eq!(inspected_look(&inherited, Some(ui_kit::LookStep::Body)).unwrap().name, "Steel");+ }+ assert_eq!(h.app.session.doc.to_json(), before);+}++#[test]+fn appearance_inspector_all_users_replaces_exact_look_once_without_changing_mass() {+ use super::selection_appearance::{assign, chains, targets, users};+ use solidcraft_engine::Sel;+ let mut h = fixture();+ h.app.run("solid.box", json!({"body_name":"Other","length":5,"width":5,"height":5,"corner":[30,0,0]})).unwrap();+ h.app.run("material.assign", json!({"bodies":["Subject","Other"],"material":"Steel"})).unwrap();+ h.app.run("appearance.assign", json!({"bodies":["Subject","Other"],"appearance":"ABS - Red"})).unwrap();+ h.app.session.selection = vec![Sel::Body { name: "Subject".into() }];+ let target = targets(&h.app, ui_kit::LookStep::Body);+ let from = chains(&mut h.app, &target).unwrap()[0][1].clone().unwrap();+ assert_eq!(users(&h.app, &from), 2);+ let mut to = from.clone();+ to.color = [12, 34, 56];+ let mass = h.app.run("component.properties", json!({})).unwrap();+ let undo = h.app.session.undo.len();+ assign(&mut h.app, &target, &from, &to, true).unwrap();+ assert_eq!(h.app.session.undo.len(), undo + 1);+ for name in ["Subject", "Other"] {+ assert_eq!(h.app.session.doc.appearances.bodies.get(name), Some(&to));+ }+ assert_eq!(h.app.run("component.properties", json!({})).unwrap(), mass);+ h.app.run("edit.undo", json!({})).unwrap();+ assert_eq!(users(&h.app, &from), 2);+ h.app.session.selection = vec![Sel::Body { name: "Subject".into() }];+ h.frames(2);+ h.step(&json!({"click":{"handle":"render:stage:look"}})).unwrap();+ assert_eq!(h.app.render_workspace.view.inspector.page, Page::Appearance);+ let undo = h.app.session.undo.len();+ h.step(&json!({"click":{"handle":format!("dialog:{}:{}", h.app.tr("render.inspector_applies_to"), crate::i18n::format("render.inspector_all_users", &[("count", "2")]))}}))+ .unwrap();+ h.step(&json!({"click":{"handle":"render:appearance:preview:replace"}})).unwrap();+ h.step(&json!({"click":{"handle":"dialog: search"}})).unwrap();+ h.step(&json!({"text":"ABS - Blue"})).unwrap();+ let blue = crate::dialogs_appearance::replacement_library(&mut h.app).iter().position(|look| look.name == "ABS - Blue").unwrap();+ h.step(&json!({"click":{"handle":format!("render:appearance:replace:{blue}")}})).unwrap();+ assert_eq!(h.app.session.undo.len(), undo + 1);+ for name in ["Subject", "Other"] {+ assert_eq!(h.app.session.doc.appearances.bodies[name].name, "ABS - Blue");+ }+ let undo = h.app.session.undo.len();+ h.step(&json!({"click":{"handle":format!("dialog:{}:{}",h.app.tr("render.inspector_finish"),h.app.tr("render.inspector_matte"))}})).unwrap();+ assert_eq!(h.app.session.undo.len(), undo + 1, "an all-users field edit is one replacement command");+ for name in ["Subject", "Other"] {+ assert_eq!(h.app.session.doc.appearances.bodies[name].pbr.unwrap().roughness(), 0.85);+ }+ assert_eq!(h.app.run("component.properties", json!({})).unwrap(), mass);+}++#[test]+fn appearance_inspector_finish_presets_mixed_set_all_and_clear_use_existing_assignments() {+ use super::selection_appearance::{assign, chains, clear, finish, mixed, targets};+ use solidcraft_engine::{Sel, doc::appearance::Look};+ let mut h = fixture();+ h.app.run("solid.box", json!({"body_name":"Other","length":5,"width":5,"height":5,"corner":[30,0,0]})).unwrap();+ h.app.run("material.assign", json!({"bodies":["Subject","Other"],"material":"Steel"})).unwrap();+ h.app.run("appearance.assign", json!({"bodies":["Subject"],"appearance":"ABS - Red"})).unwrap();+ h.app.run("appearance.assign", json!({"bodies":["Other"],"appearance":"ABS - Blue"})).unwrap();+ h.app.session.selection = vec![Sel::Body { name: "Subject".into() }, Sel::Body { name: "Other".into() }];+ let target = targets(&h.app, ui_kit::LookStep::Body);+ let looks: Vec<_> = chains(&mut h.app, &target).unwrap().into_iter().map(|c| c[1].clone().unwrap()).collect();+ assert!(mixed(&looks, |l| l.color));+ assert!(!mixed(&looks, |l| l.opacity));+ h.frames(2);+ h.step(&json!({"click":{"handle":"render:stage:look"}})).unwrap();+ assert_eq!(h.app.render_workspace.view.inspector.page, Page::Appearance);+ assert!(h.widget(h.app.tr("render.tree_mixed")).is_some());+ appearance_inspector_capture(&mut h, "mixed");+ let mass = h.app.run("component.properties", json!({})).unwrap();+ let mut to = Look::custom([40, 50, 60], 0.5);+ for (index, metallic, roughness) in [(0, 0.0, 0.85), (1, 0.0, 0.5), (2, 0.0, 0.12), (3, 1.0, 0.32)] {+ finish(&mut to, index).unwrap();+ let pbr = to.pbr.unwrap();+ assert_eq!((pbr.metallic(), pbr.roughness(), to.opacity), (metallic, roughness, 1.0));+ }+ let undo = h.app.session.undo.len();+ assign(&mut h.app, &target, &looks[0], &to, false).unwrap();+ assert_eq!(h.app.session.undo.len(), undo + 1);+ assert_eq!(h.app.session.doc.appearances.bodies.get("Subject"), h.app.session.doc.appearances.bodies.get("Other"));+ clear(&mut h.app, &target, &to).unwrap();+ assert!(h.app.session.doc.appearances.bodies.is_empty());+ assert!(chains(&mut h.app, &target).unwrap().iter().all(|c| c[3].as_ref().is_some_and(|l| l.name == "Steel")));+ assert_eq!(h.app.run("component.properties", json!({})).unwrap(), mass);+}++#[test]+fn appearance_inspector_real_controls_switch_targets_inspect_chain_and_edit_finish() {+ use solidcraft_engine::{Sel, geom::Vec3};+ let mut h = fixture();+ h.app.run("appearance.assign", json!({"bodies":["Subject"],"appearance":"ABS - Red"})).unwrap();+ let face = h.app.run("model.faces", json!({"body":"Subject"})).unwrap()["faces"]+ .as_array()+ .unwrap()+ .iter()+ .find(|f| f["point"][2] == 10.0)+ .unwrap()["index"]+ .as_u64()+ .unwrap() as usize;+ h.app.session.selection = vec![Sel::Face { body: "Subject".into(), index: face, point: Vec3::new(10.0, 7.0, 10.0) }];+ h.frames(2);+ h.step(&json!({"click":{"handle":"render:stage:look"}})).unwrap();+ assert_eq!(h.app.render_workspace.view.inspector.page, Page::Appearance);+ let before = h.app.session.doc.to_json();+ h.step(&json!({"click":{"handle":"render:appearance:chain-menu"}})).unwrap();+ h.step(&json!({"click":{"handle":"render:appearance:chain:body"}})).unwrap();+ assert_eq!(h.app.session.doc.to_json(), before);+ appearance_inspector_capture(&mut h, "face");+ h.frames(3);+ let undo = h.app.session.undo.len();+ h.step(&json!({"click":{"handle":format!("dialog:{}:{}",h.app.tr("render.inspector_finish"),h.app.tr("render.inspector_metal"))}})).unwrap();+ assert_eq!(h.app.session.undo.len(), undo + 1);+ assert_eq!(h.app.session.doc.appearances.bodies["Subject"].pbr.unwrap().metallic(), 1.0);+ let roughness = crate::scenario::rect_of(&format!("dialog:scalar:{}", h.app.tr("appearance.roughness"))).unwrap().center();+ let drag_undo = h.app.session.undo.len();+ h.step(&json!({"drag":[[roughness.x,roughness.y],[roughness.x+20.0,roughness.y]],"steps":12})).unwrap();+ assert_eq!(h.app.session.undo.len(), drag_undo + 1, "a multi-frame field edit is one undo step");+ assert_ne!(h.app.session.doc.appearances.bodies["Subject"].pbr.unwrap().roughness(), 0.32);+ let edited_undo = h.app.session.undo.len();+ h.step(&json!({"click":{"handle":format!("dialog::{}",h.app.tr("render.pick_body"))}})).unwrap();+ assert!(h.app.ui.pick_bodies);+ assert_eq!(h.app.session.undo.len(), edited_undo);+ h.step(&json!({"click":{"handle":format!("dialog::{}",h.app.tr("render.pick_component"))}})).unwrap();+ assert!(h.app.ui.pick_components);+ assert!(h.widget(h.app.tr("render.inspector_pick_target")).is_some(), "root bodies have no component override target");+ h.step(&json!({"click":{"handle":format!("dialog::{}",h.app.tr("render.pick_face"))}})).unwrap();+ assert!(!h.app.ui.pick_components && !h.app.ui.pick_bodies);+ h.step(&json!({"click":{"handle":format!("dialog::{}",h.app.tr("render.pick_body"))}})).unwrap();+ assert_eq!(h.app.session.undo.len(), edited_undo);+ appearance_inspector_capture(&mut h, "body");+ h.app.session.selection.clear();+ h.frames(3);+ assert!(h.widget(h.app.tr("render.base_appearance")).is_some());+ appearance_inspector_capture(&mut h, "explicit-target");+}++#[test]+fn appearance_inspector_mixed_fields_are_inert_until_edited_and_accept_the_first_value() {+ use solidcraft_engine::Sel;+ let mut h = fixture();+ h.app.run("solid.box", json!({"body_name":"Other","length":5,"width":5,"height":5,"corner":[30,0,0]})).unwrap();+ for (name, opacity) in [("Subject", 0.25), ("Other", 0.75)] {+ h.app.run("appearance.assign", json!({"bodies":[name],"color":"#123456","opacity":opacity})).unwrap();+ }+ h.app.session.selection = vec![Sel::Body { name: "Subject".into() }, Sel::Body { name: "Other".into() }];+ h.frames(2);+ h.step(&json!({"click":{"handle":"render:stage:look"}})).unwrap();+ assert_eq!(h.app.render_workspace.view.inspector.page, Page::Appearance);+ let before = h.app.session.doc.to_json();+ let undo = h.app.session.undo.len();+ let field = format!("dialog:scalar:{}", h.app.tr("render.inspector_opacity"));+ h.step(&json!({"click":{"handle":field}})).unwrap();+ h.step(&json!({"key":"Tab"})).unwrap();+ assert_eq!(h.app.session.doc.to_json(), before, "leaving Mixed without editing must be inert");+ assert_eq!(h.app.session.undo.len(), undo);+ h.step(&json!({"click":{"handle":field}})).unwrap();+ h.step(&json!({"text":"NaN"})).unwrap();+ h.step(&json!({"key":"Enter"})).unwrap();+ assert_eq!(h.app.session.doc.to_json(), before, "invalid input must not set mixed targets");+ assert_eq!(h.app.session.undo.len(), undo);+ h.step(&json!({"click":{"handle":field}})).unwrap();+ h.step(&json!({"text":"0.25"})).unwrap();+ assert_eq!(h.app.session.undo.len(), undo, "typing keeps a local draft until commit");+ h.step(&json!({"key":"Enter"})).unwrap();+ assert_eq!(h.app.session.undo.len(), undo + 1);+ for name in ["Subject", "Other"] {+ assert_eq!(h.app.session.doc.appearances.bodies[name].opacity, 0.25);+ }+ h.app.run("edit.undo", json!({})).unwrap();+ assert_eq!(h.app.session.doc.to_json(), before);+}++#[test]+fn appearance_inspector_optical_colour_and_opacity_edits_commit_once_with_shared_bounds() {+ use solidcraft_engine::Sel;+ let mut h = fixture();+ h.app+ .run(+ "appearance.assign",+ json!({"bodies":["Subject"],"color":"#123456",+ "pbr":{"metallic":0.2,"roughness":0.4,"dielectric_ior":1.5}}),+ )+ .unwrap();+ h.app.session.selection = vec![Sel::Body { name: "Subject".into() }];+ h.frames(2);+ h.step(&json!({"click":{"handle":"render:stage:look"}})).unwrap();+ assert_eq!(h.app.render_workspace.view.inspector.page, Page::Appearance);+ let mass = h.app.run("component.properties", json!({})).unwrap();+ for (key, text) in [("appearance.metallic", "2"), ("appearance.roughness", "0"), ("render.inspector_opacity", "0.25")] {+ let undo = h.app.session.undo.len();+ h.step(&json!({"click":{"handle":format!("dialog:scalar:{}",h.app.tr(key))}})).unwrap();+ h.step(&json!({"text":text})).unwrap();+ assert_eq!(h.app.session.undo.len(), undo);+ h.step(&json!({"key":"Enter"})).unwrap();+ assert_eq!(h.app.session.undo.len(), undo + 1, "{key}");+ let look = &h.app.session.doc.appearances.bodies["Subject"];+ match key {+ "appearance.metallic" => assert_eq!(look.pbr.unwrap().metallic(), 1.0),+ "appearance.roughness" => assert_eq!(look.pbr.unwrap().roughness(), 0.045),+ _ => assert_eq!((look.opacity, look.pbr), (0.25, None)),+ }+ }+ let undo = h.app.session.undo.len();+ h.step(&json!({"click":{"handle":format!("dialog:scalar:{}",h.app.tr("render.appearance_editor.ior"))}})).unwrap();+ h.step(&json!({"text":"3.5"})).unwrap();+ h.step(&json!({"key":"Enter"})).unwrap();+ assert_eq!(h.app.session.undo.len(), undo + 1);+ let look = &h.app.session.doc.appearances.bodies["Subject"];+ assert_eq!((look.pbr.unwrap().dielectric_ior(), look.opacity), (3.0, 1.0));+ h.step(&json!({"click":{"handle":format!("dialog:color:{}",h.app.tr("render.inspector_colour"))}})).unwrap();+ let undo = h.app.session.undo.len();+ h.step(&json!({"click":{"handle":"color:channel:R"}})).unwrap();+ h.step(&json!({"text":"200"})).unwrap();+ assert_eq!(h.app.session.undo.len(), undo);+ h.step(&json!({"key":"Enter"})).unwrap();+ assert_eq!(h.app.session.undo.len(), undo + 1);+ assert_eq!(h.app.session.doc.appearances.bodies["Subject"].color[0], 200);+ assert_eq!(h.app.run("component.properties", json!({})).unwrap(), mass);+}++#[test]+fn appearance_inspector_hex_edits_validate_and_commit_once() {+ use solidcraft_engine::Sel;+ let mut h = fixture();+ h.app.run("appearance.assign", json!({"bodies":["Subject"],"appearance":"ABS - Red"})).unwrap();+ h.app.session.selection = vec![Sel::Body { name: "Subject".into() }];+ h.app.run("view.render_stage", json!({"stage":"look"})).unwrap();+ h.frames(3);+ let before = h.app.session.doc.to_json();+ let undo = h.app.session.undo.len();+ let hex = format!("dialog:color_hex:{}", h.app.tr("render.inspector_colour"));+ h.step(&json!({"click":{"handle":hex}})).unwrap();+ h.step(&json!({"key":"A","cmd":true,"ctrl":true})).unwrap();+ h.step(&json!({"text":"#GG0000"})).unwrap();+ h.step(&json!({"key":"Enter"})).unwrap();+ assert_eq!(h.app.session.doc.to_json(), before);+ h.step(&json!({"click":{"handle":hex}})).unwrap();+ h.step(&json!({"key":"A","cmd":true,"ctrl":true})).unwrap();+ h.step(&json!({"text":"#123456"})).unwrap();+ assert_eq!(h.app.session.undo.len(), undo);+ h.step(&json!({"key":"Enter"})).unwrap();+ assert_eq!(h.app.session.doc.appearances.bodies["Subject"].color, [0x12, 0x34, 0x56]);+ assert_eq!(h.app.session.undo.len(), undo + 1);+ h.app.run("solid.box", json!({"body_name":"Other","length":5,"width":5,"height":5,"corner":[30,0,0]})).unwrap();+ h.app.run("appearance.assign", json!({"bodies":["Other"],"color":"#ABCDEF"})).unwrap();+ h.app.session.selection.push(Sel::Body { name: "Other".into() });+ h.frames(3);+ let mixed_before = h.app.session.doc.to_json();+ h.step(&json!({"click":{"handle":hex}})).unwrap();+ h.step(&json!({"key":"Tab"})).unwrap();+ assert_eq!(h.app.session.doc.to_json(), mixed_before);+ h.step(&json!({"click":{"handle":hex}})).unwrap();+ h.step(&json!({"key":"A","cmd":true,"ctrl":true})).unwrap();+ h.step(&json!({"text":"#123456"})).unwrap();+ h.step(&json!({"key":"Enter"})).unwrap();+ assert_eq!(h.app.session.doc.appearances.bodies["Other"].color, [0x12, 0x34, 0x56]);+}++#[test]+fn appearance_inspector_component_and_face_overrides_remove_to_material_from_real_controls() {+ use solidcraft_engine::{Sel, geom::Vec3};+ let mut h = Harness::new();+ h.call("ui.resize", json!({"width":1440,"height":1000}));+ h.app.run("component.create", json!({"name":"Part"})).unwrap();+ h.app.run("solid.box", json!({"body_name":"Subject","length":20,"width":15,"height":10})).unwrap();+ h.app.run("material.assign", json!({"bodies":["Subject"],"material":"Steel"})).unwrap();+ h.app.run("appearance.assign", json!({"components":["Part"],"appearance":"ABS - Blue"})).unwrap();+ h.app.run("appearance.assign", json!({"bodies":["Subject"],"appearance":"ABS - Red"})).unwrap();+ h.app.run("appearance.assign", json!({"body":"Subject","faces":[[10,7,10]],"appearance":"Copper"})).unwrap();+ let face = h.app.run("model.faces", json!({"body":"Subject"})).unwrap()["faces"]+ .as_array()+ .unwrap()+ .iter()+ .find(|f| f["point"][2] == 10.0)+ .unwrap()["index"]+ .as_u64()+ .unwrap() as usize;+ h.app.session.selection = vec![Sel::Face { body: "Subject".into(), index: face, point: Vec3::new(10.0, 7.0, 10.0) }];+ super::super::enter(&mut h.app, true).unwrap();+ h.frames(2);+ h.step(&json!({"click":{"handle":"render:stage:look"}})).unwrap();+ assert_eq!(h.app.render_workspace.view.inspector.page, Page::Appearance);+ let mass = h.app.run("component.properties", json!({})).unwrap();+ for (step, name) in [("face", "Copper"), ("body", "ABS - Red"), ("component", "ABS - Blue"), ("material", "Steel")] {+ let before = h.app.session.doc.to_json();+ h.step(&json!({"click":{"handle":"render:appearance:chain-menu"}})).unwrap();+ h.step(&json!({"click":{"handle":format!("render:appearance:chain:{step}")}})).unwrap();+ assert!(h.widget(name).is_some(), "inspecting {step} must show {name}");+ assert_eq!(h.app.session.doc.to_json(), before);+ }+ h.step(&json!({"click":{"handle":format!("dialog::{}",h.app.tr("render.pick_component"))}})).unwrap();+ appearance_inspector_capture(&mut h, "component");+ h.frames(3);+ for step in ["component", "body", "face"] {+ h.step(&json!({"click":{"handle":format!("dialog::{}",h.app.tr(match step {+ "component" => "render.pick_component", "body" => "render.pick_body", _ => "render.pick_face",+ }))}}))+ .unwrap();+ let undo = h.app.session.undo.len();+ h.step(&json!({"widget":"…"})).unwrap();+ h.step(&json!({"widget":h.app.tr("render.inspector_remove")})).unwrap();+ assert_eq!(h.app.session.undo.len(), undo + 1, "clearing {step}: {:?}", h.app.render_workspace.view.inspector.selection_appearance);+ }+ assert!(h.app.session.doc.appearances.is_empty());+ assert!(h.widget("Steel").is_some());+ assert_eq!(h.app.run("component.properties", json!({})).unwrap(), mass);+}++// Opt-in evidence from the actual application UI, without requiring a window server.+fn appearance_inspector_capture(h: &mut Harness, name: &str) {+ let Some(dir) = std::env::var_os("SOLIDCRAFT_INSPECTOR_EVIDENCE") else { return };+ std::fs::create_dir_all(&dir).unwrap();+ for dark in [false, true] {+ h.app.preferences.theme = if dark { "dark" } else { "light" }.into();+ h.app.ui.dark = dark;+ h.app.preferences.render_inspector_width = 305.0;+ let ctx = egui::Context::default();+ crate::fonts::setup_bundled_fonts(&ctx);+ let mut textures = std::collections::HashMap::new();+ let mut last = None;+ for frame in 0..10 {+ let mut output = ctx.run_ui(+ egui::RawInput {+ screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1440.0, 900.0))),+ time: Some(frame as f64 / 10.0),+ focused: true,+ ..Default::default()+ },+ |ui| {+ h.app.logic(ui.ctx());+ h.app.ui(ui);+ },+ );+ ui_kit::update_test_textures(&mut textures, &output.textures_delta);+ output.textures_delta.clear();+ last = Some(output);+ }+ let output = last.unwrap();+ let card = crate::scenario::rect_of("render:inspector").unwrap();+ let crop = ui_kit::raster_ui(&ctx, output.shapes.clone(), output.pixels_per_point, card, &textures);+ crop.save(std::path::Path::new(&dir).join(format!("{name}-{}-305.png", if dark { "dark" } else { "light" }))).unwrap();+ let image = ui_kit::raster_ui(&ctx, output.shapes, output.pixels_per_point, ctx.content_rect(), &textures);+ image.save(std::path::Path::new(&dir).join(format!("{name}-{}.png", if dark { "dark" } else { "light" }))).unwrap();+ }+}++#[test]+fn appearance_inspector_approved_layout_is_305_wide_and_preserves_stage_bounds() {+ use solidcraft_engine::Sel;+ let mut h = fixture();+ h.app.run("solid.box", json!({"body_name":"Boss","length":10,"width":10,"height":10,"corner":[30,0,0]})).unwrap();+ h.app.run("appearance.assign", json!({"bodies":["Boss","Subject"],"appearance":"Aluminum - Anodized Blue"})).unwrap();+ h.app.run("material.assign", json!({"bodies":["Boss","Subject"],"material":"Steel"})).unwrap();+ h.app.run("select.filter", json!({"mode":"body"})).unwrap();+ h.app.session.selection = vec![Sel::Body { name: "Boss".into() }];+ h.app.preferences.render_inspector_width = 305.0;+ h.app.run("view.render_stage", json!({"stage":"look"})).unwrap();+ h.frames(3);+ let before = h.app.session.doc.to_json();+ let undo = h.app.session.undo.len();+ appearance_inspector_capture(&mut h, "approved");+ h.frames(3);+ let inspector = crate::scenario::rect_of("render:inspector").unwrap();+ let browser = crate::scenario::rect_of("browser:card").unwrap();+ let shots = crate::scenario::rect_of("render:shots_strip").unwrap();+ assert!((inspector.width() - 305.0).abs() <= 1.0, "{inspector:?}");+ assert!((inspector.top() - browser.top()).abs() <= 1.0);+ assert!(inspector.bottom() < shots.top());+ assert!(h.widget(&crate::i18n::format("render.inspector_all_users", &[("count", "2")])).is_some());+ assert!(h.widget(h.app.tr("render.inspector_save_library")).is_some());+ assert_eq!(h.app.session.doc.to_json(), before);+ assert_eq!(h.app.session.undo.len(), undo);+ h.step(&json!({"click":{"handle":"render:appearance:close"}})).unwrap();+ assert!(h.app.render_workspace.view.inspector.hidden);+ h.app.run("view.render_stage", json!({"stage":"look"})).unwrap();+ h.frames(3);+ assert!(!h.app.render_workspace.view.inspector.hidden);+ h.step(&json!({"click":{"handle":format!("dialog:{}:{}",h.app.tr("render.inspector_finish"),h.app.tr("render.inspector_matte"))}})).unwrap();+ h.step(&json!({"click":{"handle":format!("dialog:action:{}", h.app.tr("render.inspector_reset"))}})).unwrap();+ assert_eq!(h.app.session.doc.appearances.bodies.get("Boss"), h.app.session.doc.appearances.bodies.get("Subject"));+ assert!(h.app.session.doc.appearances.bodies.contains_key("Subject"));+ assert_eq!(h.app.session.undo.len(), undo + 2);+}++#[test]+fn appearance_editor_e2_sections_are_ordered_collapsed_and_expand_for_each_method() {+ use solidcraft_engine::Sel;+ let mut h = fixture();+ h.call("ui.resize", json!({"width":1440,"height":4000}));+ h.app.preferences.render_inspector_width = 308.0;+ h.app.session.selection = vec![Sel::Body { name: "Subject".into() }];+ h.app.run("view.render_stage", json!({"stage":"look"})).unwrap();+ let titles = [+ "render.inspector_edit",+ "render.appearance_editor.glass",+ "render.appearance_editor.coat",+ "render.appearance_editor.maps",+ "render.appearance_editor.saved",+ "render.appearance_editor.reflections",+ ];+ h.frames(3);+ let before = h.app.session.doc.to_json();+ let mut last = 0.0;+ for title in titles {+ let rect = crate::scenario::rect_of(&format!("dialog:section:{}", h.app.tr(title))).unwrap();+ assert!(rect.top() > last, "{title} follows the preceding design section");+ last = rect.bottom();+ }+ assert!(h.widget(h.app.tr("render.appearance_editor.glass_enable")).is_none(), "optics default to collapsed");+ assert!(h.widget(h.app.tr("render.appearance_editor.gpu_reason")).is_some());+ for title in titles.into_iter().skip(1) {+ h.step(&json!({"click":{"handle":format!("dialog:section:{}",h.app.tr(title))}})).unwrap();+ }+ for method in [ImageMethod::Raster, ImageMethod::GpuRaytrace, ImageMethod::CpuRaytrace] {+ h.app.render_workspace.view.method = method;+ h.frames(3);+ for key in [+ "render.appearance_editor.glass_enable",+ "render.appearance_editor.recipe",+ "render.appearance_editor.boundary",+ "render.appearance_editor.thickness",+ "render.appearance_editor.absorption",+ "render.material_shadow",+ "render.subsurface_enable",+ "render.material_coat_enable",+ "render.appearance_editor.weight",+ "render.material_maps_enable",+ "render.appearance_editor.base_colour",+ "render.appearance_editor.normal",+ "appearance.metallic",+ "appearance.roughness",+ "render.appearance_editor.origin",+ "render.appearance_editor.u_repeat",+ "render.appearance_editor.v_repeat",+ "render.appearance_editor.normal_strength",+ "render.appearance_editor.v_up",+ "render.material_color_replace",+ "render.appearance_editor.save",+ "render.appearance_editor.remove",+ "render.appearance_editor.replace",+ "render.appearance_editor.revalidate",+ "render.cpu_reflection_off",+ "render.cpu_reflection_mirror",+ "render.cpu_reflection_rough",+ ] {+ assert!(h.widget(h.app.tr(key)).is_some(), "expanded E2 is missing {key} for {method:?}");+ }+ let tree = h.output.accesskit_update.as_ref().unwrap();+ let glass = tree.nodes.iter().find(|(_, n)| n.label() == Some(h.app.tr("render.appearance_editor.glass_enable"))).unwrap();+ assert_eq!(glass.1.is_disabled(), method != ImageMethod::GpuRaytrace);+ assert_eq!(h.app.session.doc.to_json(), before);+ assert!(h.app.render_workspace.view.materials.bindings.is_empty(), "opening never installs temporary bindings");+ }+ for selection in+ [Sel::Face { body: "Subject".into(), index: 0, point: solidcraft_engine::geom::Vec3::ZERO }, Sel::Body { name: "Subject".into() }]+ {+ h.app.session.selection = vec![selection];+ if matches!(h.app.session.selection.first(), Some(Sel::Body { .. })) {+ h.app.ui.pick_components = true;+ }+ h.frames(3);+ assert!(h.widget(h.app.tr("render.appearance_editor.body_reason")).is_some());+ for title in titles.into_iter().skip(1) {+ assert!(crate::scenario::rect_of(&format!("dialog:section:{}", h.app.tr(title))).is_some());+ }+ }+}++#[test]+fn appearance_editor_reset_restores_each_picked_saved_look() {+ use solidcraft_engine::Sel;+ let mut h = fixture();+ h.app.run("appearance.assign", json!({"bodies":["Subject"],"appearance":"ABS - Red"})).unwrap();+ h.app.session.selection = vec![Sel::Body { name: "Subject".into() }];+ h.app.run("view.render_stage", json!({"stage":"look"})).unwrap();+ h.frames(3);+ let saved = h.app.session.doc.appearances.bodies["Subject"].clone();+ let target = selection_appearance::targets(&h.app, ui_kit::LookStep::Body);+ let changed = solidcraft_engine::doc::appearance::Look::custom([10, 20, 30], 0.3);+ selection_appearance::assign(&mut h.app, &target, &saved, &changed, false).unwrap();+ h.frames(3);+ selection_appearance::reset(&mut h.app);+ assert_eq!(h.app.session.doc.appearances.bodies["Subject"], saved);+}++#[test]+fn appearance_editor_saved_optics_removal_confirms_and_preserves_other_drafts() {+ use solidcraft_engine::Sel;+ let mut h = fixture();+ h.call("ui.resize", json!({"width":1440,"height":2200}));+ h.app.render_workspace.view.method = ImageMethod::GpuRaytrace;+ let set = setups::snapshot(&h.app).unwrap();+ let name = h.app.render_workspace.view.name.clone();+ h.app+ .run(+ "render.optics.bind",+ json!({"name":name,"set":set,"body_index":0,"body_name":"Subject",+ "optics":{"ior":1.5,"absorption_per_mm":[0.0,0.0,0.0],"boundary":"closed_mesh","thickness_mm":0.0,"shadow_transmission":false},+ "expected_revision":h.app.session.revision}),+ )+ .unwrap();+ setups::load(&mut h.app);+ h.app.session.selection = vec![Sel::Body { name: "Subject".into() }];+ h.app.run("view.render_stage", json!({"stage":"look"})).unwrap();+ h.frames(3);+ h.step(&json!({"click":{"handle":format!("dialog:section:{}",h.app.tr("render.appearance_editor.saved"))}})).unwrap();+ let before = h.app.session.doc.to_json();+ h.step(&json!({"click":{"handle":"render:optics-remove"}})).unwrap();+ assert!(materials::confirmation_open(&h.app));+ assert!(h.widget(h.app.tr("render.appearance_editor.remove_title")).is_some());+ assert_eq!(h.app.session.doc.to_json(), before);+ h.step(&json!({"click":{"handle":"dialog:cancel"}})).unwrap();+ assert!(!materials::confirmation_open(&h.app));+ assert_eq!(h.app.session.doc.to_json(), before);+ h.step(&json!({"click":{"handle":"render:optics-remove"}})).unwrap();+ h.app.run("appearance.assign", json!({"bodies":["Subject"],"appearance":"ABS - Red"})).unwrap();+ h.frames(3);+ assert!(!materials::confirmation_open(&h.app), "a changed document expires the pending confirmation");+ assert_eq!(h.app.session.doc.render.setups[&name].optics.len(), 1);+ h.app.render_workspace.view.draft.width = 777;+ h.frames(3);+ h.step(&json!({"click":{"handle":"render:optics-remove"}})).unwrap();+ h.step(&json!({"click":{"handle":"dialog:ok"}})).unwrap();+ assert!(h.app.session.doc.render.setups[&name].optics.is_empty());+ assert!(h.app.render_workspace.view.draft.optics.is_empty());+ assert_eq!(h.app.render_workspace.view.draft.width, 777);+ assert_eq!(h.app.session.doc.appearances.bodies["Subject"].name, "ABS - Red");+}++#[test]+fn appearance_editor_save_optics_keeps_other_temporary_bindings() {+ use solidcraft_engine::Sel;+ let mut h = fixture();+ h.call("ui.resize", json!({"width":1440,"height":2600}));+ h.app.run("solid.box", json!({"body_name":"Other","length":5,"width":5,"height":5,"corner":[30,0,0]})).unwrap();+ h.app.render_workspace.view.method = ImageMethod::GpuRaytrace;+ let other = materials::read_targets(&mut h.app).unwrap().into_iter().find(|t| t.name == "Other").unwrap();+ let mut binding = materials::Binding::new(other, &h.app);+ binding.coat_enabled = true;+ h.app.render_workspace.view.materials.bindings.push(binding);+ h.app.render_workspace.view.materials.enabled = true;+ h.app.session.selection = vec![Sel::Body { name: "Subject".into() }];+ h.app.run("view.render_stage", json!({"stage":"look"})).unwrap();+ h.frames(3);+ h.step(&json!({"click":{"handle":format!("dialog:section:{}",h.app.tr("render.appearance_editor.glass"))}})).unwrap();+ h.step(&json!({"widget":h.app.tr("render.material_custom")})).unwrap();+ h.step(&json!({"click":{"handle":"render:glass:starter.glass.amber-tint"}})).unwrap();+ h.step(&json!({"click":{"handle":format!("dialog:section:{}",h.app.tr("render.appearance_editor.saved"))}})).unwrap();+ let geometry = h.app.run("component.properties", json!({})).unwrap();+ let undo = h.app.session.undo.len();+ h.step(&json!({"click":{"handle":"render:optics-save"}})).unwrap();+ let view = &h.app.render_workspace.view;+ assert_eq!(h.app.session.doc.render.setups[&view.name].optics.len(), 1);+ assert_eq!(view.materials.bindings.len(), 1);+ assert_eq!(view.materials.bindings[0].target.name, "Other");+ assert!(view.materials.bindings[0].coat_enabled);+ assert_eq!(h.app.session.undo.len(), undo + 1);+ assert_eq!(h.app.run("component.properties", json!({})).unwrap(), geometry);+}diff --git a/crates/ui-egui/src/render_workspace_library.rs b/crates/ui-egui/src/render_workspace_library.rsindex cc4c5bd4e6..2af3a41836 100644--- a/crates/ui-egui/src/render_workspace_library.rs+++ b/crates/ui-egui/src/render_workspace_library.rs@@ -373,7 +373,7 @@ fn preview_parameters(entry: &Value) -> Value {}source.clone()}-fn tile_sphere(entry: &Value) -> ui_kit::Sphere {+pub(super) fn tile_sphere(entry: &Value) -> ui_kit::Sphere {let p = preview_parameters(entry);let color = crate::dialogs_appearance::parse_color(&p["color"]).map(|[r, g, b]| egui::Color32::from_rgb(r, g, b)).unwrap_or(Tokens::get().body);let scalar = |key: &str, default: f64| p["pbr"][key].as_f64().filter(|v| v.is_finite()).unwrap_or(default).clamp(0.0, 1.0);@@ -461,6 +461,7 @@ pub(super) fn card(app: &mut SolveApp, ui: &mut egui::Ui, bounds: egui::Rect) {bounds,fill_height: true,compact: crate::render_ui::compact(app, bounds.width()),+ editor: false,enabled: matches!(stage, super::Stage::Look | super::Stage::Light),header_actions: (stage == super::Stage::Look).then_some(&mut actions as &mut dyn FnMut(&mut egui::Ui)),},@@ -1037,6 +1038,7 @@ fn source_preview(app: &mut SolveApp, ui: &mut egui::Ui, view: &mut View, id: &sui.small(error);}}+#[cfg(test)]pub(super) fn controls(app: &mut SolveApp, ui: &mut egui::Ui) {stage_controls(app, ui);saved_surface_controls(app, ui);@@ -1252,19 +1254,40 @@ fn resource_controls(app: &mut SolveApp, ui: &mut egui::Ui, view: &mut View, id:}}+#[cfg(test)]pub(super) fn saved_surface_controls(app: &mut SolveApp, ui: &mut egui::Ui) {let title = app.tr("render.saved_surfaces").to_string();+ ui_kit::section(ui, "render_saved_surfaces", &title, false, |ui| saved_surface_content(app, ui, None));+}++pub(super) fn saved_surface_target_controls(+ app: &mut SolveApp,+ ui: &mut egui::Ui,+ target: Option<&solidcraft_engine::doc::render_surface::RenderBodyTarget>,+) {+ if let Some(target) = target {+ saved_surface_content(app, ui, Some(target));+ }+}++fn saved_surface_content(app: &mut SolveApp, ui: &mut egui::Ui, target: Option<&solidcraft_engine::doc::render_surface::RenderBodyTarget>) {let bindings = app.render_workspace.view.draft.surfaces.clone();- if bindings.is_empty() {+ if !bindings.iter().any(|b| target.is_none_or(|t| t == &b.target)) {return;}- ui_kit::section(ui, "render_saved_surfaces", &title, false, |ui| {+ {ui_kit::text(ui, app.tr("render.saved_surfaces_help"), ui_kit::Text::Note("render.saved_surfaces_help"));- for (index, binding) in bindings.iter().enumerate() {+ if !app.render_workspace.view.materials.bindings.is_empty() {+ ui_kit::text(ui, app.tr("render.saved_maps_runtime_conflict"), ui_kit::Text::Note("render.saved_maps_runtime_conflict"));+ }+ for (index, binding) in bindings.iter().enumerate().filter(|(_, b)| target.is_none_or(|t| t == &b.target)) {ui.label(format!("{} - {} ({}): {:?}",binding.source.id, binding.target.definition, binding.target.feature, binding.target.occurrence_path));+ if ui_kit::button(ui, app.tr("render.inspector_replace"), ui_kit::Button::Normal).clicked() {+ open_category(app, "surfaces");+ }let response = ui_kit::button(ui, app.tr("render.saved_surface_remove"), ui_kit::Button::Normal);crate::scenario::publish_handle(&format!("render:saved-surface-remove:{index}"), response.rect.center());if response.clicked() {@@ -1277,9 +1300,10 @@ pub(super) fn saved_surface_controls(app: &mut SolveApp, ui: &mut egui::Ui) {}}}- });+ }}+#[cfg(test)]pub(super) fn stage_controls(app: &mut SolveApp, ui: &mut egui::Ui) {let title = app.tr("render.passive_stage").to_string();ui_kit::section(ui, "render_passive_stage", &title, false, |ui| stage_content(app, ui));@@ -1415,6 +1439,12 @@ mod studio_browser_tests {assert_eq!(h.app.render_workspace.view.library.selected.as_deref(), Some(id.as_str()));assert_eq!(h.app.render_workspace.view.inspector.page, super::super::inspector::Page::Appearance);assert_eq!(h.app.session.doc.to_json(), before, "browsing and selection must not apply appearances");+ // The selection-following editor takes precedence; library inspection is+ // available under Advanced when no model target is selected.+ h.app.run("select.clear", json!({})).unwrap();+ h.frames(3);+ h.step(&json!({"click":{"handle":format!("dialog:section:{}", h.app.tr("render.inspector_advanced"))}})).unwrap();+ h.frames(3);h.step(&json!({"widget":h.app.tr("render.library_favorite")})).unwrap();assert!(h.app.preferences.render_library_favorites.contains(&("appearances".into(), id.clone())));h.step(&json!({"click":{"handle":"render:library-list"}})).unwrap();diff --git a/crates/ui-egui/src/render_workspace_materials.rs b/crates/ui-egui/src/render_workspace_materials.rsindex 11cf15de22..7f2fcd0849 100644--- a/crates/ui-egui/src/render_workspace_materials.rs+++ b/crates/ui-egui/src/render_workspace_materials.rs@@ -45,13 +45,6 @@ impl Boundary {Self::Closed => "closed_mesh",}}- fn label(self) -> &'static str {- match self {- Self::Thin => "render.material_thin",- Self::Box => "render.material_box",- Self::Closed => "render.material_closed",- }- }}#[derive(Clone, Debug)]@@ -176,6 +169,15 @@ pub(super) struct View {selected: Option<usize>,target_revision: Option<u64>,target_document: Option<Weak<Document>>,+ pending_remove: Option<PendingRemoval>,+}++#[derive(Clone, Debug)]+struct PendingRemoval {+ name: String,+ target: solidcraft_engine::doc::render_surface::RenderBodyTarget,+ revision: u64,+ document: Weak<Document>,}pub(super) fn read_targets(app: &mut SolveApp) -> Result<Vec<Target>, String> {@@ -310,18 +312,10 @@ pub(super) fn params(app: &SolveApp, params: &mut Value) -> Result<(), String> {}fn vector(app: &SolveApp, ui: &mut egui::Ui, key: &str, values: &mut [f64; 3], range: std::ops::RangeInclusive<f64>, suffix: &str) -> bool {- ui.label(app.tr(key));- let mut changed = false;- ui.horizontal(|ui| {- for value in values {- changed |= ui_kit::number_field(ui, value, range.clone(), 0.01, suffix).changed();- }- });- changed+ ui_kit::row(ui, app.tr(key), |ui| ui_kit::vector3_field(ui, values, range, suffix))}pub(super) fn controls(app: &mut SolveApp, ui: &mut egui::Ui) {- saved_optics_controls(app, ui);let title = app.tr("render.material_title").to_string();ui_kit::section(ui, "render_materials", &title, false, |ui| {let mut view = std::mem::take(&mut app.render_workspace.view.materials);@@ -412,25 +406,7 @@ pub(super) fn controls(app: &mut SolveApp, ui: &mut egui::Ui) {app.set_status(e, true);}}- glass_controls(app, ui, binding);- coat_controls(app, ui, binding);- map_controls(app, ui, binding);- ui_kit::checkbox(ui, app.tr("render.optics_replace"), &mut binding.replace_saved_optics);- let save = ui_kit::button(- ui,- app.tr("render.optics_save"),- ui_kit::Button::Enabled(binding.glass_enabled && binding.current(app) && !binding.maps_enabled && !binding.coat_enabled),- );- crate::scenario::publish_target("render:optics-save", save.rect);- if save.clicked() {- // The transient editor is taken out of app above. snapshot saves- // only the numerical draft; other local bindings remain visible- // and stale for explicit revalidation after this one mutation.- match save_optics(app, binding) {- Ok(()) => remove = true,- Err(error) => app.set_status(error, true),- }- }+ remove |= editor_sections(app, ui, Some(binding));remove |= ui_kit::button(ui, app.tr("render.material_remove"), ui_kit::Button::Normal).clicked();}if remove && let Some(index) = view.selected.filter(|i| *i < view.bindings.len()) {@@ -438,110 +414,115 @@ pub(super) fn controls(app: &mut SolveApp, ui: &mut egui::Ui) {view.selected = None;}ui.small(app.tr("render.material_limits"));+ view.pending_remove = app.render_workspace.view.materials.pending_remove.take().or(view.pending_remove.take());app.render_workspace.view.materials = view;});}fn glass_controls(app: &mut SolveApp, ui: &mut egui::Ui, binding: &mut Binding) {- let title = app.tr("render.material_glass").to_string();- ui_kit::section(ui, ("render_glass", binding.target.ordinal), &title, false, |ui| {- if ui_kit::checkbox(ui, app.tr("render.material_glass_enable"), &mut binding.glass_enabled).changed() && binding.glass_enabled {- binding.coat_enabled = false;- binding.maps_enabled = false;- }- ui.small(app.tr("render.material_glass_help"));- let recipes: Vec<_> = appearance_pack::STARTER_PACK.iter().filter(|p| matches!(p.recipe, Recipe::Glass(_))).collect();- ui_kit::swatch_grid(ui, &recipes, |ui, preset| {- let [r, g, b] = preset.preview_color();- let response = ui_kit::color_swatch(- ui,- egui::Id::new(("render_glass_recipe", binding.target.ordinal, preset.id)),- egui::Color32::from_rgb(r, g, b),- binding.glass.recipe == Some(preset.id),- preset.name,- preset.id,- );- crate::scenario::publish_handle(&format!("render:glass:{}", preset.id), response.rect.center());- if response.clicked() {- match Glass::recipe(preset.id) {- Ok(glass) => {- binding.glass = glass;- binding.glass_enabled = true;- binding.coat_enabled = false;- binding.maps_enabled = false;+ if ui_kit::checkbox(ui, app.tr("render.appearance_editor.glass_enable"), &mut binding.glass_enabled).changed() && binding.glass_enabled {+ binding.coat_enabled = false;+ binding.maps_enabled = false;+ }+ let recipes: Vec<_> = appearance_pack::STARTER_PACK.iter().filter(|p| matches!(p.recipe, Recipe::Glass(_))).collect();+ let name =+ binding.glass.recipe.and_then(appearance_pack::find).map_or_else(|| app.tr("render.material_custom").to_owned(), |p| p.name.to_owned());+ let recipe_label = app.tr("render.appearance_editor.recipe").to_owned();+ ui_kit::row(ui, &recipe_label, |ui| {+ ui_kit::dropdown_menu(ui, "render_glass_recipe", &name, |ui| {+ for preset in recipes {+ let response = ui_kit::list_picker(ui, preset.id, preset.name, binding.glass.recipe == Some(preset.id));+ crate::scenario::publish_target(&format!("render:glass:{}", preset.id), response.rect);+ if response.clicked() {+ match Glass::recipe(preset.id) {+ Ok(glass) => {+ binding.glass = glass;+ binding.glass_enabled = true;+ binding.coat_enabled = false;+ binding.maps_enabled = false;+ }+ Err(error) => app.set_status(error, true),}- Err(e) => app.set_status(e, true),+ ui.close();}}});- let name =- binding.glass.recipe.and_then(appearance_pack::find).map_or_else(|| app.tr("render.material_custom").to_string(), |p| p.name.to_string());- ui.label(name);- if !binding.glass_enabled {- return;- }- let glass = &mut binding.glass;- let label = app.tr(glass.boundary.label()).to_string();- let mut changed = false;- ui_kit::dropdown_menu(ui, "render_glass_boundary", &label, |ui| {- for value in [Boundary::Closed, Boundary::Thin, Boundary::Box] {- if ui_kit::list_picker(ui, value.wire(), app.tr(value.label()), glass.boundary == value).clicked() {- glass.boundary = value;- glass.shadows = value == Boundary::Thin;- changed = true;- ui.close();+ });+ let glass = &mut binding.glass;+ let mut changed = false;+ ui.add_enabled_ui(binding.glass_enabled, |ui| {+ let mut boundary = match glass.boundary {+ Boundary::Closed => 0,+ Boundary::Thin => 1,+ Boundary::Box => 2,+ };+ ui_kit::row(ui, app.tr("render.appearance_editor.boundary"), |ui| {+ let labels = ["render.appearance_editor.closed", "render.appearance_editor.thin", "render.appearance_editor.box"].map(|key| app.tr(key));+ if ui_kit::segmented(ui, &mut boundary, &labels, ui_kit::Segments { compact: true, small: true, ..Default::default() }) {+ glass.boundary = match boundary {+ 1 => Boundary::Thin,+ 2 => Boundary::Box,+ _ => Boundary::Closed,+ };+ glass.shadows = glass.boundary == Boundary::Thin;+ if glass.boundary == Boundary::Thin {+ glass.subsurface = None;}+ changed = true;}});- ui.label(app.tr("render.material_ior"));- changed |= ui_kit::number_field(ui, &mut glass.ior, 1.0..=3.0, 0.01, "").changed();- changed |= vector(app, ui, "render.material_absorption", &mut glass.absorption, 0.0..=100.0, " /mm");- if glass.boundary == Boundary::Thin {- ui.label(app.tr("render.material_thickness"));- changed |= ui_kit::number_field(ui, &mut glass.thickness, 0.0..=10000.0, 0.1, " mm").changed();- }- changed |= ui_kit::checkbox(ui, app.tr("render.material_shadow"), &mut glass.shadows).changed();- let mut scatter = glass.subsurface.is_some();- if ui_kit::checkbox(ui, app.tr("render.subsurface_enable"), &mut scatter).changed() {- glass.subsurface =- scatter.then_some(solidcraft_engine::render::transmission::subsurface::Subsurface { scattering_per_mm: 0.1, anisotropy: 0.0 });- changed = true;- }- if let Some(subsurface) = &mut glass.subsurface {- changed |= ui_kit::row(ui, app.tr("render.subsurface_rate"), |ui| {- ui_kit::number_field(ui, &mut subsurface.scattering_per_mm, 0.0..=100.0, 0.001, " /mm")+ changed |=+ ui_kit::row(ui, app.tr("render.appearance_editor.ior"), |ui| ui_kit::number_field(ui, &mut glass.ior, 1.0..=3.0, 0.01, "")).changed();+ ui.add_enabled_ui(glass.boundary == Boundary::Thin, |ui| {+ changed |= ui_kit::row(ui, app.tr("render.appearance_editor.thickness"), |ui| {+ ui_kit::number_field(ui, &mut glass.thickness, 0.001..=10000.0, 0.1, " mm")}).changed();- changed |= ui_kit::row(ui, app.tr("render.volume_anisotropy"), |ui| {- ui_kit::number_field(ui, &mut subsurface.anisotropy, -0.95..=0.95, 0.01, "")- })- .changed();- ui_kit::text(ui, app.tr("render.subsurface_help"), ui_kit::Text::Note("render.subsurface_help"));+ });+ changed |= vector(app, ui, "render.appearance_editor.absorption", &mut glass.absorption, 0.0..=100.0, " /mm");+ changed |= ui_kit::checkbox(ui, app.tr("render.material_shadow"), &mut glass.shadows).changed();+ ui.add_enabled_ui(glass.boundary != Boundary::Thin, |ui| {+ let mut scatter = glass.subsurface.is_some();+ if ui_kit::checkbox(ui, app.tr("render.subsurface_enable"), &mut scatter).changed() {+ glass.subsurface =+ scatter.then_some(solidcraft_engine::render::transmission::subsurface::Subsurface { scattering_per_mm: 0.1, anisotropy: 0.0 });+ changed = true;+ }+ if let Some(subsurface) = &mut glass.subsurface {+ changed |= ui_kit::row(ui, app.tr("render.subsurface_rate"), |ui| {+ ui_kit::number_field(ui, &mut subsurface.scattering_per_mm, 0.0..=100.0, 0.001, " /mm")+ })+ .changed();+ changed |= ui_kit::row(ui, app.tr("render.volume_anisotropy"), |ui| {+ ui_kit::number_field(ui, &mut subsurface.anisotropy, -0.95..=0.95, 0.01, "")+ })+ .changed();+ }+ });+ if glass.boundary != Boundary::Thin {+ note(app, ui, "render.appearance_editor.thickness_reason");}- if changed {- glass.recipe = None;+ if glass.boundary == Boundary::Thin {+ note(app, ui, "render.appearance_editor.scatter_reason");}- ui.small(app.tr("render.material_certification"));});+ if changed {+ glass.recipe = None;+ }+ note(app, ui, "render.appearance_editor.glass_note");+ note(app, ui, "render.material_certification");}fn coat_controls(app: &SolveApp, ui: &mut egui::Ui, binding: &mut Binding) {- let title = app.tr("render.material_coat").to_string();- ui_kit::section(ui, ("render_coat", binding.target.ordinal), &title, false, |ui| {- ui.add_enabled_ui(!binding.glass_enabled, |ui| {- ui_kit::checkbox(ui, app.tr("render.material_coat_enable"), &mut binding.coat_enabled);- if binding.coat_enabled {- for (key, value, range) in [- ("render.material_weight", &mut binding.coat.weight, 0.0..=1.0),- ("render.material_roughness", &mut binding.coat.roughness, 0.045..=1.0),- ("render.material_ior", &mut binding.coat.ior, 1.0..=3.0),- ] {- ui.label(app.tr(key));- ui_kit::number_field(ui, value, range, 0.01, "");- }- }- });- ui.small(app.tr("render.material_coat_help"));+ ui_kit::checkbox(ui, app.tr("render.material_coat_enable"), &mut binding.coat_enabled);+ ui.add_enabled_ui(binding.coat_enabled, |ui| {+ for (key, value, range) in [+ ("render.appearance_editor.weight", &mut binding.coat.weight, 0.0..=1.0),+ ("appearance.roughness", &mut binding.coat.roughness, 0.045..=1.0),+ ] {+ ui_kit::row(ui, app.tr(key), |ui| ui_kit::mixed_slider(ui, value, range, None));+ }+ ui_kit::row(ui, app.tr("render.appearance_editor.ior"), |ui| ui_kit::number_field(ui, &mut binding.coat.ior, 1.0..=3.0, 0.01, ""));});}@@ -555,10 +536,10 @@ enum MapSlot {impl MapSlot {fn key(self) -> &'static str {match self {- Self::Color => "render.material_color_map",- Self::Normal => "render.material_normal_map",- Self::Roughness => "render.material_roughness_map",- Self::Metallic => "render.material_metallic_map",+ Self::Color => "render.appearance_editor.base_colour",+ Self::Normal => "render.appearance_editor.normal",+ Self::Roughness => "appearance.roughness",+ Self::Metallic => "appearance.metallic",}}fn field(self, maps: &mut Maps) -> &mut String {@@ -655,37 +636,32 @@ pub(super) fn install_library_surface(app: &mut SolveApp, id: &str, target: Targ}fn map_controls(app: &mut SolveApp, ui: &mut egui::Ui, binding: &mut Binding) {- let title = app.tr("render.material_maps").to_string();- ui_kit::section(ui, ("render_maps", binding.target.ordinal), &title, false, |ui| {- ui.add_enabled_ui(!binding.glass_enabled, |ui| {- ui_kit::checkbox(ui, app.tr("render.material_maps_enable"), &mut binding.maps_enabled);- if !binding.maps_enabled {- return;- }- for slot in [MapSlot::Color, MapSlot::Normal, MapSlot::Roughness, MapSlot::Metallic] {- let key = slot.key();- ui.label(app.tr(key));+ ui_kit::checkbox(ui, app.tr("render.material_maps_enable"), &mut binding.maps_enabled);+ ui.add_enabled_ui(binding.maps_enabled, |ui| {+ for slot in [MapSlot::Color, MapSlot::Normal, MapSlot::Metallic, MapSlot::Roughness] {+ let label = app.tr(slot.key()).to_owned();+ ui_kit::row(ui, &label, |ui| {let path = slot.field(&mut binding.maps);- ui_kit::bounded_cell_editor(ui, ui.id().with(key), path, "", false, 4096);- let label = app.tr("render.material_browse").to_string();- if ui_kit::button(ui, label, ui_kit::Button::Enabled(binding.current(app))).clicked() {+ let label = if path.is_empty() {+ app.tr("render.appearance_editor.choose_image").to_owned()+ } else {+ std::path::Path::new(path).file_name().map(|s| s.to_string_lossy().into_owned()).unwrap_or_default()+ };+ if ui_kit::button(ui, &label, ui_kit::Button::Enabled(binding.current(app))).clicked() {choose_map(app, binding, slot);}- }- let mut absolute = binding.maps.base_color_mode == BaseColorMode::Replace;- if ui_kit::checkbox(ui, app.tr("render.material_color_replace"), &mut absolute).changed() {- binding.maps.base_color_mode = if absolute { BaseColorMode::Replace } else { BaseColorMode::Modulate };- }- ui_kit::checkbox(ui, app.tr("render.material_v_up"), &mut binding.maps.flip_v);- ui.label(app.tr("render.material_normal_strength"));- ui_kit::number_field(ui, &mut binding.maps.strength, 0.0..=1.0, 0.01, "");- vector(app, ui, "render.material_origin", &mut binding.maps.frame.origin, -1e6..=1e6, " mm");- vector(app, ui, "render.material_repeat_u", &mut binding.maps.frame.u, -1e6..=1e6, " mm");- vector(app, ui, "render.material_repeat_v", &mut binding.maps.frame.v, -1e6..=1e6, " mm");+ });+ }+ vector(app, ui, "render.appearance_editor.origin", &mut binding.maps.frame.origin, -1e6..=1e6, " mm");+ vector(app, ui, "render.appearance_editor.u_repeat", &mut binding.maps.frame.u, -1e6..=1e6, " mm");+ vector(app, ui, "render.appearance_editor.v_repeat", &mut binding.maps.frame.v, -1e6..=1e6, " mm");+ ui_kit::row(ui, app.tr("render.appearance_editor.normal_strength"), |ui| {+ ui_kit::mixed_slider(ui, &mut binding.maps.strength, 0.0..=1.0, None)});- ui.small(app.tr("render.material_maps_help"));- if binding.glass_enabled {- ui.small(app.tr("render.material_glass_exclusive"));+ ui_kit::checkbox(ui, app.tr("render.appearance_editor.v_up"), &mut binding.maps.flip_v);+ let mut absolute = binding.maps.base_color_mode == BaseColorMode::Replace;+ if ui_kit::checkbox(ui, app.tr("render.material_color_replace"), &mut absolute).changed() {+ binding.maps.base_color_mode = if absolute { BaseColorMode::Replace } else { BaseColorMode::Modulate };}});}@@ -694,7 +670,12 @@ fn save_optics(app: &mut SolveApp, binding: &Binding) -> Result<(), String> {if !binding.current(app) {return Err(app.tr("render.material_revalidate_needed").into());}- let setup = super::setups::snapshot(app)?;+ // A saved shot owns numerical intent, not the tab's local map/coat bindings.+ // Keep those bindings intact while taking the portable shot snapshot.+ let local = std::mem::take(&mut app.render_workspace.view.materials);+ let setup = super::setups::snapshot(app);+ app.render_workspace.view.materials = local;+ let setup = setup?;let value = &binding.glass;let name = app.render_workspace.view.name.clone();let optics = json!({"ior":value.ior,"absorption_per_mm":value.absorption,"boundary":value.boundary.wire(),@@ -704,30 +685,245 @@ fn save_optics(app: &mut SolveApp, binding: &Binding) -> Result<(), String> {json!({"name":name,"set":setup,"body_index":binding.target.ordinal,"body_name":binding.target.name,"optics":optics,"replace":binding.replace_saved_optics,"expected_revision":app.session.revision}),)?;+ let local = std::mem::take(&mut app.render_workspace.view.materials);super::setups::load(app);+ app.render_workspace.view.materials = local;Ok(())}-fn saved_optics_controls(app: &mut SolveApp, ui: &mut egui::Ui) {- let bindings = app.render_workspace.view.draft.optics.clone();- if bindings.is_empty() {- return;+fn note(app: &SolveApp, ui: &mut egui::Ui, key: &'static str) {+ ui_kit::text(ui, app.tr(key), ui_kit::Text::Note(key));+}++/// The same body editor is used by the selection inspector and explicit-target page.+/// An unsupported selection gets an inert draft so every design control is inspectable.+fn editor_sections(app: &mut SolveApp, ui: &mut egui::Ui, binding: Option<&mut Binding>) -> bool {+ let supported = binding.is_some();+ let mut placeholder = Binding::new(Target { stable_target: None, ordinal: 0, name: String::new() }, app);+ let binding = binding.unwrap_or(&mut placeholder);+ let reason = if !supported {+ Some(app.tr("render.appearance_editor.body_reason").to_owned())+ } else if app.render_workspace.view.method != super::ImageMethod::GpuRaytrace {+ Some(app.tr("render.appearance_editor.gpu_reason").to_owned())+ } else {+ None+ };+ let title = app.tr("render.appearance_editor.glass").to_owned();+ ui_kit::method_section(ui, "render:appearance:glass", &title, "GPU", reason.as_deref(), |ui| glass_controls(app, ui, binding));+ let opaque_reason = reason.clone().or_else(|| binding.glass_enabled.then(|| app.tr("render.material_glass_exclusive").to_owned()));+ let title = app.tr("render.appearance_editor.coat").to_owned();+ ui_kit::method_section(ui, "render:appearance:coat", &title, "GPU", opaque_reason.as_deref(), |ui| coat_controls(app, ui, binding));+ let title = app.tr("render.appearance_editor.maps").to_owned();+ ui_kit::method_section(ui, "render:appearance:maps", &title, "GPU", opaque_reason.as_deref(), |ui| map_controls(app, ui, binding));+ let title = app.tr("render.appearance_editor.saved").to_owned();+ let removed = ui_kit::editor_section(ui, "render:appearance:saved", &title, false, |ui| {+ ui.add_enabled_ui(supported, |ui| saved_controls(app, ui, binding)).inner+ })+ .unwrap_or(false);+ reflection_section(app, ui, supported.then_some(binding.target.name.as_str()));+ removed+}++/// Resolve one selected whole body against the authoritative captured scene. Never+/// broaden a face/component selection into a whole-body optics assignment.+pub(super) fn selection_controls(app: &mut SolveApp, ui: &mut egui::Ui, body: Option<&str>) {+ let mut binding = body.and_then(|name| app.render_workspace.view.materials.bindings.iter().find(|b| b.target.name == name).cloned());+ if binding.is_none()+ && let Some(name) = body+ {+ let current = app.render_workspace.view.materials.target_revision == Some(app.session.revision)+ && app.render_workspace.view.materials.target_document.as_ref().is_some_and(|d| Weak::ptr_eq(d, &Arc::downgrade(&app.session.doc)));+ if !current {+ match read_targets(app) {+ Ok(targets) => {+ let view = &mut app.render_workspace.view.materials;+ view.targets = targets;+ view.target_revision = Some(app.session.revision);+ view.target_document = Some(Arc::downgrade(&app.session.doc));+ }+ Err(error) => app.set_status(error, true),+ }+ }+ let mut targets = app.render_workspace.view.materials.targets.iter().filter(|t| t.name == name);+ if let Some(target) = targets.next()+ && targets.next().is_none()+ {+ binding = Some(Binding::new(target.clone(), app));+ }+ }+ let before = app.session.revision;+ let removed = editor_sections(app, ui, binding.as_mut());+ if let Some(binding) = binding {+ let view = &mut app.render_workspace.view.materials;+ let existing = view.bindings.iter().position(|b| b.target == binding.target);+ if removed {+ if let Some(index) = existing {+ view.bindings.remove(index);+ }+ } else if app.session.revision == before {+ // Opening the editor alone never allocates an inactive assignment.+ if binding.glass_enabled || binding.coat_enabled || binding.maps_enabled || existing.is_some() {+ if existing.is_none() {+ view.enabled = true;+ }+ if let Some(index) = existing {+ if let Some(slot) = view.bindings.get_mut(index) {+ *slot = binding;+ }+ } else if view.bindings.len() < MAX_BINDINGS {+ view.bindings.push(binding);+ } else {+ app.set_status(app.tr("render.material_limits").to_owned(), true);+ }+ }+ }}- let title = app.tr("render.optics_saved").to_string();- ui_kit::section(ui, "render_saved_optics", &title, false, |ui| {- ui_kit::text(ui, app.tr("render.optics_saved_help"), ui_kit::Text::Note("render.optics_saved_help"));- for (index, binding) in bindings.iter().enumerate() {- ui.label(format!("{} #{} · n={:.4}", binding.target.definition, binding.target.feature, binding.optics.ior));- let remove = ui_kit::button(ui, app.tr("render.optics_remove"), ui_kit::Button::Enabled(!app.render_workspace.view.dirty));+}++fn saved_controls(app: &mut SolveApp, ui: &mut egui::Ui, binding: &mut Binding) -> bool {+ let saved = app+ .render_workspace+ .view+ .draft+ .optics+ .iter()+ .enumerate()+ .find(|(_, saved)| binding.target.stable_target.as_ref() == Some(&saved.target))+ .map(|(index, saved)| (index, saved.target.clone()));+ ui_kit::banner(ui, ui_kit::AssistantTone::Working, |ui| {+ note(+ app,+ ui,+ if saved.is_some() && !binding.active() { "render.appearance_editor.saved_state" } else { "render.appearance_editor.temporary" },+ );+ });+ let can_save = binding.glass_enabled+ && binding.current(app)+ && !binding.maps_enabled+ && !binding.coat_enabled+ && app.render_workspace.view.method == super::ImageMethod::GpuRaytrace;+ let mut removed = false;+ ui.horizontal(|ui| {+ let save = ui_kit::button(ui, app.tr("render.appearance_editor.save"), ui_kit::Button::Enabled(can_save));+ crate::scenario::publish_target("render:optics-save", save.rect);+ if save.clicked() {+ match save_optics(app, binding) {+ Ok(()) => removed = true,+ Err(error) => app.set_status(error, true),+ }+ }+ let remove = ui_kit::button(ui, app.tr("render.appearance_editor.remove"), ui_kit::Button::Enabled(saved.is_some()));+ crate::scenario::publish_target("render:optics-remove", remove.rect);+ if remove.clicked()+ && let Some((index, target)) = saved+ {crate::scenario::publish_target(&format!("render:optics-remove:{index}"), remove.rect);- if remove.clicked() {- match app.run(- "render.optics.unbind",- json!({"name":app.render_workspace.view.name,"target":binding.target,"expected_revision":app.session.revision}),- ) {- Ok(_) => super::setups::load(app),- Err(error) => app.set_status(error, true),+ app.render_workspace.view.materials.pending_remove = Some(PendingRemoval {+ name: app.render_workspace.view.name.clone(),+ target,+ revision: app.session.revision,+ document: Arc::downgrade(&app.session.doc),+ });+ }+ });+ ui_kit::checkbox(ui, app.tr("render.appearance_editor.replace"), &mut binding.replace_saved_optics);+ if !can_save {+ note(app, ui, "render.appearance_editor.save_reason");+ }+ if !binding.current(app) {+ note(app, ui, "render.material_revalidate_needed");+ }+ if ui_kit::button(ui, app.tr("render.appearance_editor.revalidate"), ui_kit::Button::Normal).clicked()+ && let Err(error) = revalidate(app, binding)+ {+ app.set_status(error, true);+ }+ super::library::saved_surface_target_controls(app, ui, binding.target.stable_target.as_ref());+ removed+}++fn reflection_section(app: &mut SolveApp, ui: &mut egui::Ui, body: Option<&str>) {+ let reason = if body.is_none() {+ Some(app.tr("render.appearance_editor.body_reason").to_owned())+ } else if app.render_workspace.view.method != super::ImageMethod::CpuRaytrace {+ Some(app.tr("render.appearance_editor.cpu_reason").to_owned())+ } else {+ None+ };+ let title = app.tr("render.appearance_editor.reflections").to_owned();+ ui_kit::method_section(ui, "render:appearance:reflections", &title, "CPU", reason.as_deref(), |ui| {+ use solidcraft_engine::render::job::ReflectionMode;+ let name = body.unwrap_or_default();+ let mut mode = app+ .render_workspace+ .view+ .raytrace+ .reflections+ .as_ref()+ .and_then(|r| r.bodies.iter().find(|b| b.body == name))+ .map_or(0, |b| if b.mode == ReflectionMode::Mirror { 1 } else { 2 });+ let labels = ["render.cpu_reflection_off", "render.cpu_reflection_mirror", "render.cpu_reflection_rough"].map(|key| app.tr(key).to_owned());+ let body_label = app.tr("render.inspector_this_body").to_owned();+ ui_kit::row(ui, &body_label, |ui| {+ if ui_kit::segmented(+ ui,+ &mut mode,+ &labels.each_ref().map(String::as_str),+ ui_kit::Segments { compact: true, small: true, ..Default::default() },+ ) {+ let value = match mode {+ 1 => Some(ReflectionMode::Mirror),+ 2 => Some(ReflectionMode::RoughSpecular),+ _ => None,+ };+ if let Err(error) = super::cpu::set_reflection(app, name, value) {+ app.set_status(error, true);}}+ });+ if ui_kit::button(ui, app.tr("render.cpu_binding_confirm"), ui_kit::Button::Enabled(mode != 0)).clicked()+ && let Err(error) = super::cpu::revalidate(app, name)+ {+ app.set_status(error, true);}+ let title = app.tr("render.appearance_editor.reflection_sampling").to_owned();+ ui_kit::editor_section(ui, "render:appearance:reflection-sampling", &title, false, |ui| super::cpu::reflection_sampling_controls(app, ui));});}++pub(super) fn confirmation_open(app: &SolveApp) -> bool {+ app.render_workspace.view.materials.pending_remove.is_some()+}++pub(super) fn confirmation(app: &mut SolveApp, ctx: &egui::Context) {+ let Some(pending) = app.render_workspace.view.materials.pending_remove.clone() else { return };+ if pending.revision != app.session.revision+ || pending.name != app.render_workspace.view.name+ || !Weak::ptr_eq(&pending.document, &Arc::downgrade(&app.session.doc))+ {+ app.render_workspace.view.materials.pending_remove = None;+ app.set_status(app.tr("render.review_stale").to_owned(), true);+ return;+ }+ let title = app.tr("render.appearance_editor.remove_title").to_owned();+ let (closed, action) = ui_kit::Confirm::new(egui::Id::new("render_remove_optics"), "delete", &title)+ .tone(ui_kit::Tone::Danger)+ .actions(app.tr("render.appearance_editor.remove"), app.tr("render.keep_editing"), None)+ .selected(ui_kit::Action::Cancel)+ .show(ctx, true, |ui| {+ note(app, ui, "render.appearance_editor.remove_note");+ });+ if closed || action == ui_kit::Action::Cancel {+ app.render_workspace.view.materials.pending_remove = None;+ }+ if action == ui_kit::Action::Ok {+ app.render_workspace.view.materials.pending_remove = None;+ match app.run("render.optics.unbind", json!({"name":pending.name,"target":&pending.target,"expected_revision":pending.revision})) {+ Ok(_) => {+ // Removing one saved binding must preserve unsaved shot settings+ // and unrelated temporary overrides on this tab.+ app.render_workspace.view.draft.optics.remove(&pending.target);+ }+ Err(error) => app.set_status(error, true),+ }+ }+}diff --git a/crates/ui-egui/src/render_workspace_ribbon.rs b/crates/ui-egui/src/render_workspace_ribbon.rsindex 2dcc8c327e..c4401b414d 100644--- a/crates/ui-egui/src/render_workspace_ribbon.rs+++ b/crates/ui-egui/src/render_workspace_ribbon.rs@@ -173,6 +173,7 @@ pub(super) fn presentation(app: &SolveApp) -> solidcraft_engine::render::job::pr}fn focus(app: &mut SolveApp, page: inspector::Page, category: Option<&str>) {+ app.render_workspace.view.inspector.hidden = false;app.render_workspace.view.inspector.page = page;if let Some(category) = category {library::open_category(app, category);@@ -207,7 +208,10 @@ fn navigate(app: &mut SolveApp, id: &str) -> Result<(), String> {action_ready(app, id)?;use inspector::Page;match id {- "render.aging.describe" => focus(app, Page::Aging, None),+ "render.aging.describe" => {+ focus(app, Page::Appearance, None);+ inspector::reveal(app, "render:appearance:advanced");+ }"render.effects.describe" => focus(app, Page::Effects, None),"render.preset.resolve" | "render.preset.apply" => focus(app, Page::Scene, Some("native_scenes")),"render.settings.get" | "render.shot.duplicate" | "render.shot.rename" | "render.shot.remove" => {diff --git a/crates/ui-egui/src/render_workspace_studio.rs b/crates/ui-egui/src/render_workspace_studio.rsindex 3b602f742a..266e888cc6 100644--- a/crates/ui-egui/src/render_workspace_studio.rs+++ b/crates/ui-egui/src/render_workspace_studio.rs@@ -169,6 +169,7 @@ pub(super) fn lens_controls(app: &mut SolveApp, ui: &mut egui::Ui) {}}+#[cfg(test)]pub(super) fn controls(app: &mut SolveApp, ui: &mut egui::Ui) {finishing_controls(app, ui);lens_controls(app, ui);diff --git a/crates/ui-egui/src/render_workspace_tests.rs b/crates/ui-egui/src/render_workspace_tests.rsindex e450bd6f36..8a7fbd01cc 100644--- a/crates/ui-egui/src/render_workspace_tests.rs+++ b/crates/ui-egui/src/render_workspace_tests.rs@@ -595,8 +595,8 @@ fn clicked_render_workspace_saves_one_setup_and_restores_design_view() {let perspective = h.app.tr("render.perspective").to_string();let save = h.app.tr("render.save_setup").to_string();let back = h.app.tr("render.return_design").to_string();+ h.step(&json!({"click":{"handle":"render:stage:frame"}})).unwrap();assert!(h.widget(&heading).is_some(), "{language}");- h.step(&json!({"click":{"handle":"render:page:camera"}})).unwrap();h.step(&json!({"widget":perspective})).unwrap();assert!(!h.app.session.is_dirty(), "preview edits are staged");h.step(&json!({"widget":save})).unwrap();@@ -1751,6 +1751,7 @@ fn clicked_gpu_glass_recipe_stays_temporary_and_blocks_cpu_rendering() {h.app.session.mark_saved();enter(&mut h.app, true).unwrap();h.app.render_workspace.view.inspector.page = inspector::Page::All;+ h.app.render_workspace.view.method = ImageMethod::GpuRaytrace;h.frames(3);let doc = h.app.session.doc.clone();let title = h.app.tr("render.material_title").to_string();@@ -1762,13 +1763,15 @@ fn clicked_gpu_glass_recipe_stays_temporary_and_blocks_cpu_rendering() {h.step(&json!({"click":{"handle":"dialog:list:render:material-body-0"}})).unwrap();let add = h.app.tr("render.material_add").to_string();h.step(&json!({"widget":add})).unwrap();- let glass = h.app.tr("render.material_glass").to_string();+ let glass = h.app.tr("render.appearance_editor.glass").to_string();h.step(&json!({"click":{"handle":format!("dialog:section:{glass}")}})).unwrap();+ h.step(&json!({"widget":h.app.tr("render.material_custom")})).unwrap();h.step(&json!({"click":{"handle":"render:glass:starter.glass.amber-tint"}})).unwrap();let binding = &h.app.render_workspace.view.materials.bindings[0];assert!(binding.glass_enabled && !binding.coat_enabled && !binding.maps_enabled);assert_eq!(binding.glass.recipe, Some("starter.glass.amber-tint"));assert_eq!(binding.target.name, "Optics");+ h.app.render_workspace.view.method = ImageMethod::CpuRaytrace;assert!(image_params(&h.app).is_err(), "CPU must not silently ignore active GPU material assignments");assert!(Arc::ptr_eq(&doc, &h.app.session.doc));assert!(!h.app.session.is_dirty());@@ -2064,7 +2067,7 @@ fn clicked_setup_save_reload_and_switch_keep_gpu_numeric_intent_without_a_host()let open_section = |h: &mut Harness, handle: String| {for _ in 0..4 {let at = crate::scenario::handle_at(&handle).unwrap();- let top = crate::scenario::rect_of("render:page:all").unwrap().bottom() + Tokens::get().space_8;+ let top = crate::scenario::rect_of("render:inspector:header").unwrap().bottom() + Tokens::get().space_8;let bottom = crate::scenario::rect_of("render:job-footer").unwrap().top() - Tokens::get().space_8;if (top..=bottom).contains(&at.y) {break;@@ -2857,8 +2860,8 @@ fn render_workspace_stage_chips_dispatch_without_mutations_and_remember_each_docassert_eq!((h.app.session.revision, h.app.session.undo.len(), h.app.session.redo.len()), history);assert!(h.app.render_workspace.view.job.is_none());assert!(h.app.render_workspace.view.completed.is_none());- // Stage selection focuses pages; it does not remove the other editors.- h.step(&json!({"click":{"handle":"render:page:diagnostics"}})).unwrap();+ // Stage selection preserves access to the other command-driven editors.+ h.app.start("render.status");h.frames(2);assert_eq!(h.app.render_workspace.view.inspector.page, inspector::Page::Diagnostics);}@@ -3033,7 +3036,7 @@ fn render_workspace_focus_tab_only_toggles_render_without_text_focus() {h.step(&json!({"key":"Tab"})).unwrap();assert!(!h.app.shell.render_focus);h.frames(3);- h.step(&json!({"click":{"handle":"render:setup-name"}})).unwrap();+ h.step(&json!({"click":{"handle":"render:library-search"}})).unwrap();assert!(h.ctx.egui_wants_keyboard_input());h.step(&json!({"key":"Tab"})).unwrap();assert!(!h.app.shell.render_focus);@@ -3433,13 +3436,13 @@ fn render_workspace_hosts_float_and_shield_input_in_both_ribbon_layouts() {} else if key == "render:appearances" {"render:library-search"} else {- "render:page:output"+ "dialog:editor_footer"}).unwrap();if key == "render:browser" {assert!(header.contains_rect(control), "Scene lens belongs in the title band");} else {- assert!(control.top() >= header.bottom(), "navigation must be below the standard header: {control:?} {header:?}");+ assert!(control.top() >= header.bottom(), "editor controls must be below the standard header: {control:?} {header:?}");}}@@ -4554,3 +4557,25 @@ fn render_workspace_shots_strip_geometry_and_theme_evidence() {}crate::theme::set_dark(previous);}++#[test]+fn appearance_editor_hostile_optics_stay_finite_and_never_panic() {+ let mut h = Harness::new();+ h.app.run("solid.box", json!({"length":10,"width":10,"height":3,"body_name":"Optics"})).unwrap();+ let target = materials::read_targets(&mut h.app).unwrap().remove(0);+ h.app.render_workspace.view.method = ImageMethod::GpuRaytrace;+ h.app.render_workspace.view.materials.enabled = true;+ for value in [f64::NAN, f64::INFINITY, f64::NEG_INFINITY, -1.0, 1e300] {+ let mut binding = materials::Binding::new(target.clone(), &h.app);+ binding.glass_enabled = true;+ binding.glass.ior = value;+ h.app.render_workspace.view.materials.bindings = vec![binding];+ assert!(materials::params(&h.app, &mut json!({})).is_err(), "hostile IOR {value}");+ }+ let mut binding = materials::Binding::new(target, &h.app);+ binding.glass_enabled = true;+ binding.glass.boundary = materials::Boundary::Box;+ binding.glass.subsurface = Some(solidcraft_engine::render::transmission::subsurface::Subsurface { scattering_per_mm: 0.1, anisotropy: 0.0 });+ h.app.render_workspace.view.materials.bindings = vec![binding];+ assert!(materials::params(&h.app, &mut json!({})).is_ok(), "box boundaries are closed dielectrics too");+}diff --git a/crates/ui-egui/src/ui_kit/actions.rs b/crates/ui-egui/src/ui_kit/actions.rsindex 299bc2e0c4..ea26ac6aef 100644--- a/crates/ui-egui/src/ui_kit/actions.rs+++ b/crates/ui-egui/src/ui_kit/actions.rs@@ -78,6 +78,17 @@ fn icon_button_presentation(response.on_hover_text(crate::i18n::tr_label(label))}+/// Plain secondary text action, sharing the kit's normal hit height and typography.+pub(crate) fn text_button(ui: &mut Ui, label: &str, enabled: bool) -> Response {+ let t = Tokens::get();+ let response = ui.add_enabled(+ enabled,+ egui::Button::new(RichText::new(label).size(t.font_label).color(t.form_ink)).frame(false).min_size(vec2(0.0, t.control_height)),+ );+ scenario::publish_target(&format!("dialog:action:{label}"), response.rect);+ response+}+/// Esc cancels; unowned Enter submits only when valid. Tokens: `none`.pub(crate) fn keyboard(ctx: &egui::Context, ok_enabled: bool) -> Action {if ctx.input(|i| i.key_pressed(egui::Key::Escape)) {diff --git a/crates/ui-egui/src/ui_kit/assistant.rs b/crates/ui-egui/src/ui_kit/assistant.rsindex 40e522e99d..4e14456a7f 100644--- a/crates/ui-egui/src/ui_kit/assistant.rs+++ b/crates/ui-egui/src/ui_kit/assistant.rs@@ -27,6 +27,17 @@ impl AssistantTone {pub(crate) fn assistant_badge(ui: &mut Ui, label: &str, tone: AssistantTone) -> Response {let t = Tokens::get();let (ink, fill) = tone.colors(&t);+ badge(ui, label, ink, fill)+}++/// A compact informational chip in the active workspace colours.+pub(crate) fn workspace_chip(ui: &mut Ui, label: &str) -> Response {+ let accent = crate::theme::TabAccent::current(ui.ctx());+ badge(ui, label, accent.ink, accent.soft)+}++fn badge(ui: &mut Ui, label: &str, ink: egui::Color32, fill: egui::Color32) -> Response {+ let t = Tokens::get();let font = egui::FontId::proportional(t.font_caption);let width = ui.painter().layout_no_wrap(label.to_owned(), font.clone(), ink).size().x + t.space_12;let (rect, response) = ui.allocate_exact_size(vec2(width, t.form_close_size - t.space_4), egui::Sense::hover());diff --git a/crates/ui-egui/src/ui_kit/color.rs b/crates/ui-egui/src/ui_kit/color.rsindex 051027551e..02d28bdd9d 100644--- a/crates/ui-egui/src/ui_kit/color.rs+++ b/crates/ui-egui/src/ui_kit/color.rs@@ -46,6 +46,39 @@ pub(crate) fn color_field(ui: &mut Ui, rgb: &mut [u8; 3]) -> Response {if ui.style().explanation_tooltips { response.on_hover_text(i18n::tr("color.edit")) } else { response }}+/// A colour swatch and editable hexadecimal field; incomplete text remains local until valid.+pub(crate) fn color_hex_field(ui: &mut Ui, rgb: &mut [u8; 3], mixed: Option<&str>) -> Response {+ let id = ui.id().with(("color_hex", label(ui)));+ let current = format!("#{:02X}{:02X}{:02X}", rgb[0], rgb[1], rgb[2]);+ let is_mixed = mixed.is_some();+ let initial = || if is_mixed { String::new() } else { current.clone() };+ let (observed, was_mixed, mut hex) = ui.ctx().data(|d| d.get_temp::<([u8; 3], bool, String)>(id)).unwrap_or_else(|| (*rgb, is_mixed, initial()));+ if observed != *rgb || was_mixed != is_mixed {+ hex = initial();+ }+ let mut response = color_field(ui, rgb);+ if response.changed() {+ hex = format!("#{:02X}{:02X}{:02X}", rgb[0], rgb[1], rgb[2]);+ }+ let mut field = super::bounded_cell_editor(ui, id.with("field"), &mut hex, mixed.unwrap_or("#RRGGBB"), false, 32);+ scenario::publish_target(&format!("dialog:color_hex:{}", label(ui)), field.rect);+ let mut valid = false;+ if field.changed() {+ let text = hex.trim();+ let digits = text.strip_prefix('#').unwrap_or(text);+ if digits.len() == 6+ && let Ok(value) = u32::from_str_radix(digits, 16)+ {+ *rgb = [(value >> 16) as u8, (value >> 8) as u8, value as u8];+ valid = true;+ response.mark_changed();+ }+ }+ field.flags.set(egui::response::Flags::CHANGED, valid);+ ui.ctx().data_mut(|d| d.insert_temp(id, (*rgb, is_mixed, hex)));+ response.union(field)+}+/// Popover body, also rendered independently by the gallery. Format is global, alpha is opaque./// Tokens: form_card_width, control_*, form_*, on_accent, border, radius_xl, font_small, space_*.pub(crate) fn color_popover(ui: &mut Ui, rgb: &mut [u8; 3]) -> bool {diff --git a/crates/ui-egui/src/ui_kit/fields.rs b/crates/ui-egui/src/ui_kit/fields.rsindex 353098e4c5..44028acfef 100644--- a/crates/ui-egui/src/ui_kit/fields.rs+++ b/crates/ui-egui/src/ui_kit/fields.rs@@ -168,15 +168,38 @@ pub(crate) fn searchable_dropdown(custom: Option<&str>,pending: Option<&str>,) -> Option<String> {+ searchable_dropdown_with(ui, id, current, filter, options, SearchMenu { custom, pending, icon: None })+}++struct SearchMenu<'a> {+ custom: Option<&'a str>,+ pending: Option<&'a str>,+ icon: Option<&'static str>,+}++fn searchable_dropdown_with(+ ui: &mut Ui,+ id: &str,+ current: &str,+ filter: &mut String,+ options: &[SearchOption<'_>],+ menu: SearchMenu<'_>,+) -> Option<String> {+ let SearchMenu { custom, pending, icon } = menu;crate::prefs_search::note_current(ui, current);let mut chosen = None;let row = label(ui).to_owned();- let response = egui::ComboBox::from_id_salt(id)- .width(dimension(ui.available_width()))+ let combo = egui::ComboBox::from_id_salt(id)+ .width(if icon.is_some() { Tokens::get().control_height } else { dimension(ui.available_width()) }).height(Tokens::get().space_24 * 14.0)- .selected_text(current)- .icon(dropdown_arrow)- .close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside)+ .selected_text(if icon.is_some() { "" } else { current })+ .close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside);+ let combo = if let Some(icon) = icon {+ combo.icon(move |ui, rect, _, _| crate::icons::paint_ink(ui.painter(), rect.shrink(Tokens::get().space_2), icon, Tokens::get().form_dim))+ } else {+ combo.icon(dropdown_arrow)+ };+ let response = combo.show_ui(ui, |ui| {let search = ui.add(text_input(egui::TextEdit::singleline(filter))@@ -496,6 +519,17 @@ pub(crate) fn search_field(ui: &mut Ui, id: egui::Id, value: &mut String, hint:response}+/// Compact icon action opening the shared searchable menu.+pub(crate) fn searchable_icon_dropdown(+ ui: &mut Ui,+ icon: &'static str,+ label: &str,+ filter: &mut String,+ options: &[SearchOption<'_>],+) -> Option<String> {+ searchable_dropdown_with(ui, "icon_search_menu", label, filter, options, SearchMenu { custom: None, pending: None, icon: Some(icon) })+}+/// Behaviour of the one kit slider. Appearance is always owned by `slider`./// Values/ranges stay in caller units; formatting never rounds saved values during drawing.pub(crate) struct Slider {@@ -503,11 +537,12 @@ pub(crate) struct Slider {pub format: fn(f64) -> String,pub show_value: bool,pub integer: bool,+ pub workspace_accent: bool,}impl Default for Slider {fn default() -> Self {- Self { step: None, format: |v| format!("{v:.2}"), show_value: true, integer: false }+ Self { step: None, format: |v| format!("{v:.2}"), show_value: true, integer: false, workspace_accent: false }}}@@ -522,6 +557,7 @@ pub(crate) fn slider<T: egui::emath::Numeric>(ui: &mut Ui, value: &mut T, range:super::scope(ui, |ui| {let t = Tokens::get();ui.style_mut().drag_value_text_style = egui::TextStyle::Monospace;+ let primary = if options.workspace_accent { crate::theme::TabAccent::current(ui.ctx()).ink } else { t.form_primary };let limits = (range.start().to_f64(), range.end().to_f64());let reserved = if options.show_value {// Reserve the actual formatted editor, including suffixes and localized Instant.@@ -568,8 +604,8 @@ pub(crate) fn slider<T: egui::emath::Numeric>(ui: &mut Ui, value: &mut T, range:let fraction = if limits.1 != limits.0 { ((value.to_f64() - limits.0) / (limits.1 - limits.0)).clamp(0.0, 1.0) as f32 } else { 0.0 };let center = egui::pos2(egui::lerp(track.x_range(), fraction), track.center().y);ui.painter().rect_filled(track, t.control_radius, t.dialog_rule);- ui.painter().rect_filled(egui::Rect::from_min_max(track.min, egui::pos2(center.x, track.bottom())), t.control_radius, t.form_primary);- ui.painter().circle(center, t.space_8, t.control_fill, egui::Stroke::new(t.space_2, t.form_primary));+ ui.painter().rect_filled(egui::Rect::from_min_max(track.min, egui::pos2(center.x, track.bottom())), t.control_radius, primary);+ ui.painter().circle(center, t.space_8, t.control_fill, egui::Stroke::new(t.space_2, primary));publish(ui, &response, egui::WidgetType::Slider);response.widget_info(|| egui::WidgetInfo::slider(ui.is_enabled(), value.to_f64(), crate::i18n::tr_label(label(ui))));scenario::publish_rect(&format!("dialog:slider_track:{}", label(ui)), slider);@@ -578,14 +614,68 @@ pub(crate) fn slider<T: egui::emath::Numeric>(ui: &mut Ui, value: &mut T, range:})}+/// Shared slider with a compact mixed-aware value editor at the right.+/// The caller owns commit timing, just as for `mixed_scalar_field`.+pub(crate) fn mixed_slider(ui: &mut Ui, value: &mut f64, range: std::ops::RangeInclusive<f64>, mixed: Option<&str>) -> Response {+ let t = Tokens::get();+ ui.horizontal(|ui| {+ let width = if mixed.is_some() { t.space_24 * 2.0 } else { t.space_24 + t.space_12 };+ let track = ui+ .allocate_ui(vec2((ui.available_width() - width - t.space_8).max(0.0), row_height()), |ui| {+ slider(ui, value, range.clone(), Slider { show_value: false, workspace_accent: true, ..Default::default() })+ })+ .inner;+ let field = ui+ .allocate_ui(vec2(width, row_height()), |ui| {+ ui.visuals_mut().widgets.inactive.bg_fill = egui::Color32::TRANSPARENT;+ ui.visuals_mut().widgets.inactive.bg_stroke = egui::Stroke::NONE;+ ui.visuals_mut().widgets.inactive.weak_bg_fill = egui::Color32::TRANSPARENT;+ ui.style_mut().text_styles.insert(egui::TextStyle::Monospace, egui::FontId::monospace(t.font_label));+ scalar_field_impl(ui, value, range, mixed, true)+ })+ .inner;+ field.union(track)+ })+ .inner+}+/// Locale-aware bounded scalar field, used for dimensionless material properties.pub(crate) fn scalar_field(ui: &mut Ui, value: &mut f64, range: std::ops::RangeInclusive<f64>) -> Response {+ mixed_scalar_field(ui, value, range, None)+}++/// A bounded scalar with a translated mixed-value placeholder. Typing or dragging+/// replaces the placeholder; commit ownership remains with the caller.+pub(crate) fn mixed_scalar_field(ui: &mut Ui, value: &mut f64, range: std::ops::RangeInclusive<f64>, mixed: Option<&str>) -> Response {+ scalar_field_impl(ui, value, range, mixed, false)+}++fn scalar_field_impl(ui: &mut Ui, value: &mut f64, range: std::ops::RangeInclusive<f64>, mixed: Option<&str>, plain: bool) -> Response {ui.style_mut().drag_value_text_style = egui::TextStyle::Monospace;- let response = ui.add_sized(- vec2(dimension(ui.available_width()), row_height()),- egui::DragValue::new(value).range(range).speed(0.01).custom_parser(crate::prefs::parse_number),- );- Tokens::get().input_bevel(ui, &response);+ let before = *value;+ let parsed = std::cell::Cell::new(false);+ let field = egui::DragValue::new(value).range(range).speed(0.01).custom_parser(|text| {+ let value = crate::prefs::parse_number(text);+ parsed.set(value.is_some());+ value+ });+ let field = if plain { field.fixed_decimals(2) } else { field };+ let mut response = ui.add_sized(vec2(dimension(ui.available_width()), row_height()), |ui: &mut Ui| {+ let field = if let Some(mixed) = mixed.filter(|_| !ui.ctx().is_being_dragged(ui.next_auto_id())) {+ field.custom_formatter(move |_, _| mixed.to_owned())+ } else {+ field+ };+ ui.add(field)+ });+ // Entering the first target's existing number still sets every mixed target.+ // Merely focusing and leaving the translated placeholder is inert.+ if mixed.is_some() {+ response.flags.set(egui::response::Flags::CHANGED, *value != before || parsed.get());+ }+ if !plain {+ Tokens::get().input_bevel(ui, &response);+ }scenario::publish_target(&format!("dialog:scalar:{}", label(ui)), response.rect);response}@@ -680,6 +770,26 @@ pub(crate) fn number_field<T: egui::emath::Numeric>(response}+/// Three bounded numeric components sharing the available control-column width.+/// Each field retains the standard parser, bevel and focus behaviour. Tokens:+/// number_field typography/chrome and the enclosing row's spacing.+pub(crate) fn vector3_field(ui: &mut Ui, values: &mut [f64; 3], range: std::ops::RangeInclusive<f64>, suffix: &str) -> bool {+ let mut changed = false;+ let label = super::layout::label(ui).to_owned();+ ui.columns(3, |columns| {+ for (axis, (ui, value)) in columns.iter_mut().zip(values).enumerate() {+ let width = ui.available_width().max(0.0);+ ui.spacing_mut().text_edit_width = width;+ ui.spacing_mut().interact_size.x = width;+ ui.set_clip_rect(ui.clip_rect().intersect(ui.max_rect()));+ let response = number_field(ui, value, range.clone(), 0.01, suffix);+ scenario::publish_target(&format!("dialog:vector:{label}:{axis}"), response.rect);+ changed |= response.changed();+ }+ });+ changed+}+/// Growing plain-text message editor; its parent owns scrolling and Enter routing./// Tokens: control_fill, form_inset, font_label. Use text_area for bounded data input.#[cfg(any(not(target_arch = "wasm32"), test))]diff --git a/crates/ui-egui/src/ui_kit/gallery.rs b/crates/ui-egui/src/ui_kit/gallery.rsindex 789f3f8792..fead21e914 100644--- a/crates/ui-egui/src/ui_kit/gallery.rs+++ b/crates/ui-egui/src/ui_kit/gallery.rs@@ -131,6 +131,43 @@ const ELEMENTS: &[Element] = &[assert_eq!(tree_row(ui, ui.id().with(("tree_geometry", index)), row).rect, Some(rect));}}),+ element!("editor_section", |ui, _| {+ editor_section(ui, "edit", "Edit", true, |ui| {+ text(ui, "Colour", Text::Inline);+ });+ }),+ element!("method_section", |ui, _| {+ method_section(ui, "gpu_section", "Glass and absorption", "GPU", Some("Needs GPU path tracing"), |ui| {+ checkbox(ui, "Use physical glass", &mut false);+ });+ }),+ element!("vector3_field", |ui, _| {+ row(ui, "Origin", |ui| vector3_field(ui, &mut [0.0; 3], -1e6..=1e6, " mm"));+ }),+ element!("pending_section", |ui, _| {+ pending_section(ui, "upcoming", "Textures", "Soon");+ }),+ element!("inspector_header", |ui, _| {+ inspector_header(ui, "body", "Boss", "Body");+ }),+ element!("workspace_chip", |ui, _| {+ workspace_chip(ui, "Body");+ }),+ element!("section_heading", |ui, _| {+ section_heading(ui, "Edit");+ }),+ element!("text_button", |ui, _| {+ text_button(ui, "Reset", true);+ }),+ element!("color_hex_field", |ui, _| {+ color_hex_field(ui, &mut [52, 92, 160], None);+ }),+ element!("mixed_slider", |ui, _| {+ mixed_slider(ui, &mut 0.5, 0.0..=1.0, None);+ }),+ element!("searchable_icon_dropdown", |ui, _| {+ searchable_icon_dropdown(ui, "spin", "Replace…", &mut String::new(), &[]);+ }),element!("icon_label_action", |ui, _| {icon_label_action(ui, "Render Image", Some("play"), true, true);}),@@ -189,6 +226,35 @@ const ELEMENTS: &[Element] = &[element!("catalog_footer", |ui, _| {catalog_footer(ui, "Click to apply · drag onto the model");}),+ element!("sphere_preview", |ui, _| {+ sphere_preview(+ ui,+ "gallery:preview",+ Sphere { color: Tokens::get().render_accent, kind: FinishKind::Satin, opacity: None },+ "Satin",+ ["Library", "Used by 2"],+ |ui| searchable_icon_dropdown(ui, "spin", "Replace…", &mut String::new(), &[]),+ );+ }),+ element!("sphere_preview_with_source", |ui, _| {+ sphere_preview_with_source(+ ui,+ "gallery:preview-source",+ Sphere { color: Tokens::get().render_accent, kind: FinishKind::Satin, opacity: None },+ "Satin",+ "Used by 2",+ |ui| {+ compact_dropdown_menu(ui, "gallery:source", "In Design", |ui| {+ text(ui, "Body look", Text::Inline);+ })+ },+ |ui| text_button(ui, "Replace…", true),+ );+ }),+ element!("mixed_scalar_field", |ui, _| {+ let mut value = 0.5;+ mixed_scalar_field(ui, &mut value, 0.0..=1.0, Some("Mixed"));+ }),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 {diff --git a/crates/ui-egui/src/ui_kit/layout.rs b/crates/ui-egui/src/ui_kit/layout.rsindex 676f3e67de..ece263b3b2 100644--- a/crates/ui-egui/src/ui_kit/layout.rs+++ b/crates/ui-egui/src/ui_kit/layout.rs@@ -261,6 +261,15 @@ pub(crate) fn figure_rows(/// Memory belongs to the enclosing dialog ID; animation is avoided so each row keeps its fixed height./// Persisted disclosure with a rule and uppercase title. Tokens: `control_height, space_2, radius_sm, hover, dialog_rule, form_section_icon_size, form_gap_y, font_caption, font_section_tracking, text_dim`.+/// Static section caption for an Inspector group that stays expanded.+#[cfg(test)]+pub(crate) fn section_heading(ui: &mut Ui, title: &str) {+ let t = Tokens::get();+ let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), t.space_16), egui::Sense::hover());+ paint_text(ui, rect, &crate::i18n::tr_label(title).to_uppercase(), crate::fonts::semibold(t.font_caption), t.form_dim, true);+ scenario::publish_rect(&format!("dialog:heading:{title}"), rect);+}+pub(crate) fn section<R>(ui: &mut Ui, id: impl egui::AsIdSalt, title: &str, default_open: bool, add: impl FnOnce(&mut Ui) -> R) -> Option<R> {section_count(ui, id, title, default_open, None::<usize>, add)}@@ -274,6 +283,48 @@ pub(crate) fn section_count<R>(count: Option<impl std::fmt::Display>,add: impl FnOnce(&mut Ui) -> R,) -> Option<R> {+ section_with_badge(ui, id, title, default_open, (count.map(|count| count.to_string()), false, false), add)+}++/// Dense editor disclosure: 24 pt heading and 6 pt field gaps, with the same saved state and commands.+pub(crate) fn editor_section<R>(ui: &mut Ui, id: impl egui::AsIdSalt, title: &str, default_open: bool, add: impl FnOnce(&mut Ui) -> R) -> Option<R> {+ section_with_badge(ui, id, title, default_open, (None, false, true), add)+}++/// Compact editor disclosure with a method badge. Unsupported content stays+/// inspectable and disabled; its translated reason remains visible when folded.+/// Uses the editor section's spacing, typography and semantic theme tokens.+pub(crate) fn method_section<R>(+ ui: &mut Ui,+ id: impl egui::AsIdSalt,+ title: &str,+ method: &str,+ reason: Option<&str>,+ add: impl FnOnce(&mut Ui) -> R,+) -> Option<R> {+ let result =+ section_with_badge(ui, id, title, false, (Some(method.to_owned()), false, true), |ui| ui.add_enabled_ui(reason.is_none(), add).inner);+ if let Some(reason) = reason {+ super::text(ui, reason, super::Text::Note("method_section_reason"));+ }+ result+}++/// A collapsed upcoming group with an inert disclosure and a trailing status chip.+#[cfg(test)]+pub(crate) fn pending_section(ui: &mut Ui, id: impl egui::AsIdSalt, title: &str, badge: &str) {+ section_with_badge(ui, id, title, false, (Some(badge.to_owned()), true, true), |_| {});+}++fn section_with_badge<R>(+ ui: &mut Ui,+ id: impl egui::AsIdSalt,+ title: &str,+ default_open: bool,+ badge: (Option<String>, bool, bool),+ add: impl FnOnce(&mut Ui) -> R,+) -> Option<R> {+ let (count, pending, compact) = badge;// A search still walks the body, so a setting inside a folded section can match, without// leaving the folded heading on screen for every query.if crate::prefs_search::querying(ui) && crate::prefs_search::suppress_chrome(ui) && !crate::prefs_search::texts_hit(ui, &[title]) {@@ -283,8 +334,11 @@ pub(crate) fn section_count<R>(let t = Tokens::get();ui.add_space(t.space_2);let id = ui.make_persistent_id(id);- let mut open = searching || ui.ctx().data_mut(|data| data.get_persisted::<bool>(id)).unwrap_or(default_open);- let (rect, response) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), row_height()), egui::Sense::click());+ let mut open = !pending && (searching || ui.ctx().data_mut(|data| data.get_persisted::<bool>(id)).unwrap_or(default_open));+ let (rect, response) = ui.allocate_exact_size(+ vec2(dimension(ui.available_width()), if compact { t.control_height - t.space_4 } else { row_height() }),+ egui::Sense::click(),+ );crate::prefs_search::follow(ui, title, rect);if response.hovered() || response.has_focus() {ui.painter().rect_filled(rect.shrink2(vec2(0.0, 1.0)), t.radius_sm, t.hover);@@ -296,7 +350,7 @@ pub(crate) fn section_count<R>(super::disclosure(ui.painter(), icon_rect.center(), open, t.form_dim);let text_rect = egui::Rect::from_min_max(egui::pos2((icon_rect.right() + t.form_gap_y).min(rect.right()), rect.top()), rect.max);let caption = crate::i18n::tr_label(title).to_uppercase();- let badge_value = count.map(|count| count.to_string());+ let badge_value = count;let badge_width = badge_value.as_ref().map_or(0.0, |value| label_width(ui, value) + t.space_12);let reserved = if badge_value.is_some() { badge_width + t.space_12 } else { 0.0 };let mut format = egui::TextFormat::simple(crate::fonts::semibold(t.font_caption), t.form_dim);@@ -310,9 +364,11 @@ pub(crate) fn section_count<R>(let title_rect = egui::Rect::from_min_max(text_rect.min, egui::pos2(text_rect.left() + title_width, text_rect.bottom()));paint_text(ui, title_rect, &caption, crate::fonts::semibold(t.font_caption), t.form_dim, true);let mut rule_left = title_rect.right() + t.space_12;+ let mut rule_right = rect.right();if let Some(value) = badge_value {let width = badge_width.min((rect.right() - rule_left).max(0.0));- let badge = egui::Rect::from_min_size(egui::pos2(rule_left.min(rect.right()), rect.center().y - t.space_10), vec2(width, t.space_10 * 2.0));+ let left = if pending { rect.right() - width } else { rule_left.min(rect.right()) };+ let badge = egui::Rect::from_min_size(egui::pos2(left, rect.center().y - t.space_10), vec2(width, t.space_10 * 2.0));ui.painter().rect_filled(badge, t.radius_xl, t.dialog_footer);ui.painter().with_clip_rect(ui.clip_rect().intersect(badge)).text(badge.center(),@@ -322,21 +378,33 @@ pub(crate) fn section_count<R>(t.form_dim,);scenario::publish_rect(&format!("dialog:section:{title}:count"), badge);- rule_left = badge.right() + t.space_12;+ if pending {+ rule_right = badge.left() - t.space_12;+ } else {+ rule_left = badge.right() + t.space_12;+ }}- if rule_left < rect.right() {- t.secondary_hline(ui.painter(), rule_left..=rect.right(), rect.center().y, t.dialog_rule);+ if rule_left < rule_right {+ t.secondary_hline(ui.painter(), rule_left..=rule_right, rect.center().y, t.dialog_rule);}response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::CollapsingHeader, ui.is_enabled(), open, crate::i18n::tr_label(title)));scenario::publish_handle(&format!("dialog:section:{title}"), response.rect.center());scenario::publish_rect(&format!("dialog:section:{title}"), rect);- if response.clicked() && !searching {+ if response.clicked() && !pending && !searching {open = !open;}if !searching {ui.ctx().data_mut(|data| data.insert_persisted(id, open));}- open.then(|| ui.push_id(id, add).inner)+ open.then(|| {+ ui.push_id(id, |ui| {+ if compact {+ ui.spacing_mut().item_spacing.y = t.space_6;+ }+ add(ui)+ })+ .inner+ })}/// Shortcut matches during Preferences search. Closed until opened, and closed again when thediff --git a/crates/ui-egui/src/ui_kit/look_chain.rs b/crates/ui-egui/src/ui_kit/look_chain.rsindex b21f1c348d..f22d67944c 100644--- a/crates/ui-egui/src/ui_kit/look_chain.rs+++ b/crates/ui-egui/src/ui_kit/look_chain.rs@@ -30,9 +30,9 @@ impl LookStep {pub fn look_chain(ui: &mut Ui, id: &str, labels: [&str; 4], looks: [Option<Sphere>; 4], active: LookStep) -> Option<LookStep> {let t = Tokens::get();let width = ui.available_width().clamp(1.0, t.form_card_width * 2.0);- let side = t.space_24.min(width / 4.0);+ let side = (t.control_height + t.space_6).min(width / 4.0);let ring_width = t.space_2.min(side / 8.0);- let height = side + t.space_8 + t.font_small + t.space_4;+ let height = side + t.space_2 + t.font_small + t.space_2;let (rect, _) = ui.allocate_exact_size(vec2(width, height), Sense::hover());let mut clicked = None;for (index, ((step, label), look)) in LookStep::ALL.into_iter().zip(labels).zip(looks).enumerate() {@@ -40,10 +40,12 @@ pub fn look_chain(ui: &mut Ui, id: &str, labels: [&str; 4], looks: [Option<Spherlet cell = Rect::from_min_size(rect.min + vec2(index as f32 * cell_width, 0.0), vec2(cell_width, height));let painter = ui.painter().with_clip_rect(ui.clip_rect().intersect(cell));let center = pos2(cell.center().x, cell.top() + side / 2.0 + ring_width);- let radius = (side / 2.0 - ring_width * 2.0).max(0.0);+ let radius = (side / 2.0 - ring_width).max(0.0);if index < 3 {- ui.painter()- .line_segment([center + vec2(side / 2.0, 0.0), center + vec2(cell_width - side / 2.0, 0.0)], Stroke::new(1.0, t.control_border));+ ui.painter().line_segment(+ [center + vec2(side / 2.0 + t.space_8, 0.0), center + vec2(cell_width - side / 2.0 - t.space_8, 0.0)],+ Stroke::new(1.0, t.control_border),+ );}let key = format!("{id}:{}", step.name());let response = ui.interact(cell, ui.make_persistent_id(&key), Sense::click());@@ -72,11 +74,11 @@ pub fn look_chain(ui: &mut Ui, id: &str, labels: [&str; 4], looks: [Option<Spherif step == active {painter.circle_stroke(center, radius + ring_width, Stroke::new(ring_width, t.render_accent));}- let font = egui::FontId::proportional(t.font_small);+ let font = if step == active { crate::fonts::semibold(t.font_small) } else { egui::FontId::proportional(t.font_small) };let label_width = ui.painter().layout_no_wrap(label.to_owned(), font.clone(), t.form_ink).size().x;let label_left = (cell.center().x - label_width / 2.0).max(cell.left());- let label_rect = Rect::from_min_max(pos2(label_left, cell.top() + side + t.space_4), cell.max);- super::text::paint_text(ui, label_rect, label, font, t.form_ink, false);+ let label_rect = Rect::from_min_max(pos2(label_left, cell.top() + side + t.space_2), cell.max);+ super::text::paint_text(ui, label_rect, label, font, if step == active { t.render_accent } else { t.form_dim }, false);scenario::publish_rect(&key, cell);scenario::publish_handle(&key, cell.center());}diff --git a/crates/ui-egui/src/ui_kit/menu.rs b/crates/ui-egui/src/ui_kit/menu.rsindex c359d9fcf8..c3a24e8ff0 100644--- a/crates/ui-egui/src/ui_kit/menu.rs+++ b/crates/ui-egui/src/ui_kit/menu.rs@@ -21,6 +21,10 @@ impl Menu {)}+ pub(crate) fn text<R>(ui: &mut Ui, label: &str, add: impl FnOnce(&mut Ui) -> R) -> egui::InnerResponse<Option<R>> {+ Self::button_with(ui, |ui, _| super::text_button(ui, label, true), add)+ }+pub(crate) fn item_button<R>(ui: &mut Ui, item: &MenuItem<'_>, add: impl FnOnce(&mut Ui) -> R) -> egui::InnerResponse<Option<R>> {Self::button_with(ui, |ui, _| item.show(ui), add)}diff --git a/crates/ui-egui/src/ui_kit/mod.rs b/crates/ui-egui/src/ui_kit/mod.rsindex e6e68a2804..f930058996 100644--- a/crates/ui-egui/src/ui_kit/mod.rs+++ b/crates/ui-egui/src/ui_kit/mod.rs@@ -79,8 +79,10 @@ pub(crate) use radial::{RADIAL_RADIUS, radial_menu};pub(crate) use reports::*;pub(crate) use search::{CommandSearch, SearchBadge, SearchFieldGeometry};pub(crate) use shortcuts::*;+#[cfg(test)]+pub(crate) use sphere::sphere_preview;pub use sphere::{FinishKind, Sphere, sphere_thumbnail};-pub(crate) use sphere::{SphereTile, sphere_grid};+pub(crate) use sphere::{SphereTile, sphere_grid, sphere_preview_with_source};pub(crate) use stages::{StageAction, StageBar};pub(crate) use status::*;pub(crate) use table::*;@@ -110,3 +112,5 @@ pub(crate) fn fits_steadily(ui: &egui::Ui, key: impl std::hash::Hash + std::fmt:ui.data_mut(|data| data.insert_temp(id, fits));fits}++pub(crate) use panel::{InspectorAction, inspector_header};diff --git a/crates/ui-egui/src/ui_kit/panel.rs b/crates/ui-egui/src/ui_kit/panel.rsindex 98d078f45a..f5bb2f580b 100644--- a/crates/ui-egui/src/ui_kit/panel.rs+++ b/crates/ui-egui/src/ui_kit/panel.rs@@ -216,6 +216,57 @@ impl<'a> TopHeader<'a> {}}+/// Selection editor chrome, shared by floating Inspectors. Returns an action for registry dispatch.+#[derive(Clone, Copy)]+pub(crate) enum InspectorAction {+ Close,+ Remove,+}++pub(crate) fn inspector_header(ui: &mut Ui, icon: &str, title: &str, kind: &str) -> Option<InspectorAction> {+ let t = Tokens::get();+ let mut action = None;+ let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), header_height()), egui::Sense::hover());+ let icon_rect = egui::Rect::from_center_size(egui::pos2(rect.left() + (t.space_16 + t.space_4), rect.center().y), vec2(t.space_14, t.space_14));+ crate::icons::paint_ink(ui.painter(), icon_rect, icon, crate::theme::TabAccent::current(ui.ctx()).ink);+ let close_rect = egui::Rect::from_center_size(+ egui::pos2(rect.right() - (t.space_16 + t.space_4), rect.center().y),+ vec2(t.form_close_size, t.form_close_size),+ );+ let close = super::icon_button_at(ui, close_rect, "close", crate::i18n::tr_label("Close"));+ scenario::publish_target("render:appearance:close", close.rect);+ if close.clicked() {+ action = Some(InspectorAction::Close);+ }+ let more_rect = close_rect.translate(vec2(-t.control_height - t.space_4, 0.0));+ {+ let mut more_ui = ui.new_child(egui::UiBuilder::new().id_salt("inspector_more").max_rect(more_rect));+ let ui = &mut more_ui;+ super::Menu::text(ui, "…", |ui| {+ if super::MenuItem::new("render:appearance:remove", crate::i18n::tr("render.inspector_remove"), "").show(ui).clicked() {+ action = Some(InspectorAction::Remove);+ ui.close();+ }+ });+ }+ let badge_width = ui.painter().layout_no_wrap(kind.to_owned(), crate::fonts::semibold(t.font_small), t.form_ink).size().x + t.space_16;+ let badge = egui::Rect::from_center_size(+ egui::pos2(more_rect.left() - t.space_8 - badge_width / 2.0, rect.center().y),+ vec2(badge_width, t.space_16 + t.space_4),+ );+ {+ let mut badge_ui = ui.new_child(egui::UiBuilder::new().id_salt("inspector_kind").max_rect(badge));+ super::workspace_chip(&mut badge_ui, kind);+ }+ let name = egui::Rect::from_min_max(egui::pos2(icon_rect.right() + t.space_8, rect.top()), egui::pos2(badge.left() - t.space_8, rect.bottom()));+ paint_text(ui, name, title, crate::fonts::semibold(t.font_label), t.form_ink, false);+ ui.interact(name, ui.make_persistent_id("inspector_title"), egui::Sense::hover())+ .widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), title));+ t.secondary_hline(ui.painter(), rect.x_range(), rect.bottom(), t.dialog_rule);+ scenario::publish_rect("dialog:header", rect);+ action+}+/// A bounded docked or floating card. Uses form_card_width and the caller's tokenised frame./// Window IDs and content scopes are retained so moving a card does not reset field focus.pub(crate) struct Panel<'a> {@@ -241,6 +292,7 @@ pub(crate) struct WorkspaceOptions<'a> {pub fill_height: bool,/// Use the minimum dock width without overwriting its remembered width.pub compact: bool,+ pub editor: bool,pub enabled: bool,pub header_actions: Option<&'a mut dyn FnMut(&mut Ui)>,}@@ -298,6 +350,27 @@ impl<'a> Panel<'a> {.show(ui, add)}+ /// One-row editor footer, pinned inside the shared workspace card.+ pub(crate) fn editor_footer<R>(ui: &mut Ui, key: &'static str, add: impl FnOnce(&mut Ui) -> R) -> egui::InnerResponse<R> {+ let t = Tokens::get();+ let host = super::Container::new(ui.ctx(), super::Surface::Viewport);+ host.edge(key, super::Edge::Bottom)+ .exact_size(t.form_footer_height)+ .resizable(false)+ .frame(+ host.edge_frame(t.dialog_footer)+ .outer_margin(egui::Margin::symmetric(-(t.space_12 as i8), 0))+ .inner_margin(egui::Margin::symmetric(t.space_12 as i8, t.space_8 as i8)),+ )+ .show(ui, |ui| {+ let band = ui.max_rect().expand2(vec2(t.space_12, t.space_8));+ ui.painter().rect_filled(band, egui::CornerRadius { nw: 0, ne: 0, sw: t.radius_xl, se: t.radius_xl }, t.dialog_footer);+ t.secondary_hline(ui.painter(), band.x_range(), band.top(), t.dialog_rule);+ scenario::publish_rect("dialog:editor_footer", band);+ add(ui)+ })+ }+/// Shared strip composition reserves actions at the right and scrolls choices at the left.pub(crate) fn strip_contents(ui: &mut egui::Ui, right: impl FnOnce(&mut egui::Ui), choices: impl FnOnce(&mut egui::Ui)) {ui.spacing_mut().item_spacing.x = Tokens::get().space_8;@@ -401,7 +474,13 @@ impl<'a> Panel<'a> {let ctx = ui.ctx().clone();let mut move_side = None;let response = container.area(egui::Id::new(options.id)).fixed_pos(rect.min).movable(false).show(&ctx, |ui| {- let frame = container.frame(&ctx, t.panel, if left { crate::frame::Side::Left } else { crate::frame::Side::Right }).inner_margin(0.0);+ let frame = container+ .frame(+ &ctx,+ if options.editor { t.dialog_body } else { t.panel },+ if left { crate::frame::Side::Left } else { crate::frame::Side::Right },+ )+ .inner_margin(0.0);let content = container.show_frame(ui, frame, bounds, |ui| {let size = (rect.size() - frame.total_margin().sum()).max(egui::Vec2::ZERO);// Allocate the bounded host once; overflowing controls scroll/clip inside a child,@@ -451,6 +530,8 @@ impl<'a> Panel<'a> {egui::Frame::NONE.inner_margin(if tree {egui::Margin::symmetric(0, t.space_4 as i8)+ } else if options.editor {+ egui::Margin { left: t.space_12 as i8, right: t.space_12 as i8, top: t.space_10 as i8, bottom: 0 }} else {egui::Margin::same(if options.icon.is_empty() { t.space_10 } else { t.space_12 } as i8)})@@ -459,7 +540,12 @@ impl<'a> Panel<'a> {if tree {ui.spacing_mut().item_spacing.y = 0.0;}- super::scope(ui, add)+ super::scope(ui, |ui| {+ if options.editor {+ ui.spacing_mut().item_spacing.y = t.space_8;+ }+ add(ui)+ })}).inner});diff --git a/crates/ui-egui/src/ui_kit/reports.rs b/crates/ui-egui/src/ui_kit/reports.rsindex 7d6cf4f59b..a2410b7273 100644--- a/crates/ui-egui/src/ui_kit/reports.rs+++ b/crates/ui-egui/src/ui_kit/reports.rs@@ -30,11 +30,16 @@ pub(crate) fn report_divider(ui: &mut Ui, key: &str) {/// List border around a caller-owned virtualised viewport. Tokens: dialog_rule, control_radius, space_10.pub(crate) fn list_frame<R>(ui: &mut Ui, key: &str, add: impl FnOnce(&mut Ui) -> R) -> R {+ list_frame_filled(ui, key, egui::Color32::TRANSPARENT, 0.0, add)+}++pub(super) fn list_frame_filled<R>(ui: &mut Ui, key: &str, fill: egui::Color32, vertical: f32, add: impl FnOnce(&mut Ui) -> R) -> R {let t = Tokens::get();let response = egui::Frame::NONE+ .fill(fill).stroke(t.container_border(t.dialog_rule)).corner_radius(t.control_radius)- .inner_margin(egui::Margin::symmetric(t.space_10 as i8, 0))+ .inner_margin(egui::Margin::symmetric(t.space_10 as i8, vertical as i8)).show(ui, |ui| {// Frame already subtracts its border and padding from the content width.ui.set_min_width(ui.available_width().max(0.0));diff --git a/crates/ui-egui/src/ui_kit/slider_tests.rs b/crates/ui-egui/src/ui_kit/slider_tests.rsindex b1ad106abc..d2d8c84804 100644--- a/crates/ui-egui/src/ui_kit/slider_tests.rs+++ b/crates/ui-egui/src/ui_kit/slider_tests.rs@@ -26,6 +26,7 @@ fn every_slider_option_uses_the_same_token_thumb_in_both_themes() {format: if formatted { |v| format!("{:.0} %", v * 100.0) } else { |v| format!("{v:.2}") },show_value,integer,+ workspace_accent: false,},);});diff --git a/crates/ui-egui/src/ui_kit/sphere.rs b/crates/ui-egui/src/ui_kit/sphere.rsindex fbfe9444d1..29cfbd37af 100644--- a/crates/ui-egui/src/ui_kit/sphere.rs+++ b/crates/ui-egui/src/ui_kit/sphere.rs@@ -175,6 +175,67 @@ pub fn sphere_thumbnail(ui: &mut Ui, id: &str, sphere: Sphere, size: f32) -> Resresponse}+/// Inspector sample card. Content, chips and action reuse the kit's existing+/// controls; dimensions and the bordered card belong here rather than callers.+#[cfg(test)]+pub(crate) fn sphere_preview<R>(ui: &mut Ui, id: &str, sphere: Sphere, name: &str, chips: [&str; 2], action: impl FnOnce(&mut Ui) -> R) -> R {+ sphere_preview_with_source(ui, id, sphere, name, chips[1], |ui| super::text(ui, chips[0], super::Text::Inline), action)+}++/// Sample card with an interactive source tag (for example an inheritance menu).+/// Keeps the standard sphere, two-line caption, usage chip and trailing action.+/// Tokens and dimensions are identical to the plain sample card.+pub(crate) fn sphere_preview_with_source<R>(+ ui: &mut Ui,+ id: &str,+ sphere: Sphere,+ name: &str,+ usage: &str,+ source: impl FnOnce(&mut Ui) -> Response,+ action: impl FnOnce(&mut Ui) -> R,+) -> R {+ let t = Tokens::get();+ super::reports::list_frame_filled(ui, id, t.dialog_footer, t.space_10, |ui| {+ let row = ui.horizontal(|ui| {+ let side = t.control_height * 2.0 - t.space_8;+ sphere_thumbnail(ui, id, sphere, side);+ let text_width = (ui.available_width() - t.control_height - t.space_16).max(0.0);+ ui.allocate_ui_with_layout(vec2(text_width, side), egui::Layout::top_down(egui::Align::Min), |ui| {+ ui.spacing_mut().item_spacing.y = t.space_4;+ ui.add_sized(+ vec2(text_width, t.space_16),+ egui::Label::new(egui::RichText::new(name).font(crate::fonts::semibold(t.font_label)).color(t.form_ink))+ .truncate()+ .halign(egui::Align::Min),+ )+ .on_hover_text(name);+ let (line, _) = ui.allocate_exact_size(vec2(text_width, t.control_height), Sense::hover());+ let usage_width = (ui.painter().layout_no_wrap(usage.to_owned(), egui::FontId::proportional(t.font_caption), t.form_ink).size().x+ + t.space_12)+ .min((text_width - t.space_24 - t.space_8).max(0.0));+ let usage_rect = Rect::from_min_max(pos2(line.right() - usage_width, line.top()), line.max);+ let source_rect = Rect::from_min_max(line.min, pos2((usage_rect.left() - t.space_4).max(line.left()), line.bottom()));+ let mut source_ui = ui.new_child(+ egui::UiBuilder::new().id_salt("sample_source").max_rect(source_rect).layout(egui::Layout::left_to_right(egui::Align::Center)),+ );+ source_ui.set_clip_rect(ui.clip_rect().intersect(source_rect));+ let source = source(&mut source_ui);+ scenario::publish_rect(&format!("{id}:chip:0"), source.rect.intersect(source_rect));+ let mut usage_ui = ui.new_child(+ egui::UiBuilder::new().id_salt("sample_usage").max_rect(usage_rect).layout(egui::Layout::left_to_right(egui::Align::Center)),+ );+ usage_ui.set_clip_rect(ui.clip_rect().intersect(usage_rect));+ let response = super::workspace_chip(&mut usage_ui, usage);+ scenario::publish_rect(&format!("{id}:chip:1"), response.rect.intersect(usage_rect));+ });+ let response = ui.vertical(action);+ scenario::publish_target(&format!("{id}:replace"), response.response.rect);+ response.inner+ });+ row.inner+ })+}+/// 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> {diff --git a/crates/ui-egui/src/ui_kit/sphere_tests.rs b/crates/ui-egui/src/ui_kit/sphere_tests.rsindex 65a4033053..b1e673867e 100644--- a/crates/ui-egui/src/ui_kit/sphere_tests.rs+++ b/crates/ui-egui/src/ui_kit/sphere_tests.rs@@ -1,5 +1,66 @@use super::*;+#[test]+fn interactive_preview_keeps_source_usage_and_replace_inside_the_card() {+ for dark in [false, true] {+ crate::theme::set_dark(dark);+ for width in [280.0, 305.0, 308.0, 356.0] {+ let ctx = crate::fonts::test_context();+ crate::test_support::frame(&ctx, egui::RawInput::default(), |ui| {+ ui.set_width(width);+ super::super::scope(ui, |ui| {+ sphere_preview_with_source(+ ui,+ "preview",+ Sphere { color: Tokens::get().render_accent, kind: FinishKind::Metal, opacity: None },+ "Brushed aluminium",+ "Used by 4",+ |ui| super::super::compact_dropdown_menu(ui, "source", "In Design", |_| {}),+ |ui| super::super::searchable_icon_dropdown(ui, "spin", "Replace…", &mut String::new(), &[]),+ );+ });+ });+ let card = crate::scenario::rect_of("dialog:list:preview").unwrap();+ assert!(card.width() <= width + 1.0, "{card:?}");+ for child in ["preview", "preview:replace", "preview:chip:0", "preview:chip:1"] {+ assert!(card.contains_rect(crate::scenario::rect_of(child).unwrap()), "{child}");+ }+ }+ }+}++#[test]+fn preview_keeps_sample_chips_and_replace_inside_the_shared_card() {+ for dark in [false, true] {+ crate::theme::set_dark(dark);+ for width in [280.0, 356.0] {+ let ctx = crate::fonts::test_context();+ crate::test_support::frame(&ctx, egui::RawInput::default(), |ui| {+ ui.set_width(width);+ super::super::scope(ui, |ui| {+ sphere_preview(+ ui,+ "preview",+ Sphere { color: Tokens::get().render_accent, kind: FinishKind::Metal, opacity: None },+ "A long appearance label that must fit the card",+ ["Library", "Used by 1000"],+ |ui| super::super::searchable_icon_dropdown(ui, "spin", "Replace…", &mut String::new(), &[]),+ );+ });+ });+ let card = crate::scenario::rect_of("dialog:list:preview").unwrap();+ let sample = crate::scenario::rect_of("preview").unwrap();+ let replace = crate::scenario::rect_of("preview:replace").unwrap();+ assert!(card.width() <= width + 1.0, "{card:?}");+ assert!(card.contains_rect(sample) && card.contains_rect(replace));+ assert!(replace.left() > sample.right());+ for chip in ["preview:chip:0", "preview:chip:1"] {+ assert!(card.contains_rect(crate::scenario::rect_of(chip).unwrap()));+ }+ }+ }+}+#[test]fn tiles_keep_three_columns_cell_sphere_badge_and_selection_in_both_themes() {for dark in [false, true] {diff --git a/crates/ui-egui/tests/scenarios/render_workspace_shell.json b/crates/ui-egui/tests/scenarios/render_workspace_shell.jsonindex ac749d745a..e8097f9b56 100644--- a/crates/ui-egui/tests/scenarios/render_workspace_shell.json+++ b/crates/ui-egui/tests/scenarios/render_workspace_shell.json@@ -8,9 +8,10 @@{"click":{"handle":"render:stage:light"}},{"click":{"handle":"render:stage:frame"}},{"click":{"handle":"render:stage:output"}},+ {"click":{"handle":"render:tree: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"]}},+ {"expect":{"disjoint":["render:inspector:header","render:output-width"]}},{"click":{"handle":"render:shots:hide"}},{"expect":{"shown_handles":["render:shots:show"],"hidden_handles":["render:shots:hide"]}},{"call":"ui.workspace","params":{"workspace":"design"}},@@ -18,5 +19,6 @@{"call":"ui.workspace","params":{"workspace":"render"}},{"click":{"handle":"render:shots:show"}},{"call":"ui.set","params":{"layout":"docked"}},- {"expect":{"shown_handles":["render:shots:hide","render:stage:output","render:page:output"],"hidden_handles":["tab:RENDER"],"errors":0}}+ {"click":{"handle":"render:tree:output"}},+ {"expect":{"shown_handles":["render:shots:hide","render:stage:output","render:output-width"],"hidden_handles":["tab:RENDER"],"errors":0}}]diff --git a/docs/render-workspace.md b/docs/render-workspace.mdindex d665e4b419..8085eef4af 100644--- a/docs/render-workspace.md+++ b/docs/render-workspace.md@@ -130,38 +130,52 @@ half-edge vectors specify their geometry in millimetres; radiance is linear RGB.An environment map replaces the constant environment term. The path integrator usesthe published emitter/BSDF MIS contract.-### GPU image materials--The GPU image materials section assigns runtime optics to whole visible scene bodies.-Refresh the authoritative body list, explicitly choose a body, and add its assignment.-The captured ordinal and exact name must match; a document identity or revision change-requires explicit revalidation. A removed, renamed or reordered body cannot silently-receive another body's settings. The editor uses weak document identity references, so-stale assignments do not retain historical documents. The normal Appearance and material-library dialogs keep their existing behavior.--Glass, clear coat and planar maps have separate collapsible controls. Six original glass-recipes come directly from the starter pack: linear transmittance over the recipe's-reference distance becomes absorption per millimetre via `-ln(T) / distance`. Selecting-one never changes saved opacity or assigns a scalar appearance. The swatch shows the-recipe's transmittance, not a rendered preview. Manual IOR, RGB absorption, thin-sheet-thickness and straight-shadow transmission are available. Closed solids derive optical-distance from geometry; full topology, orientation, overlap and optical-boundary checks-run during GPU preparation. Successful Check does not certify those geometric properties.--Clear coat exposes weight, roughness and IOR over the existing opaque base. Runtime maps-accept bounded local PNG/JPEG base-color sRGB and OpenGL +Y normal images, normal strength,-and orthogonal world-space origin/U/V vectors in millimetres. Each vector spans one full-repeat. The backend's 1024×1024 per-map, 16 MiB encoded-total and 128-repeat bounds remain.-Glass cannot share one body with coat or maps. Limits are eight glass bodies, 64 coat-bodies and 16 mapped bodies, within a maximum of 64 editor assignments.--All these controls are temporary per-document-tab state, explicitly labelled in the UI.-They are not saved in the design, render setup or portable material library. Disable the-overrides before choosing a CPU method; active GPU assignments cause Check/Start to-refuse a CPU request. Both buttons submit the same freshly validated runtime parameters,-and file contents are captured by the engine at that boundary. File-picker completion-checks the original document, revision and body identity before accepting the path.+### Appearance editor and body optics++Picking a face, body or component opens Appearance. Its kind chips, look card and+Applies to scope lead to Edit: colour, finish, metallic, roughness, opacity and IOR.+The look card's source tag opens the inheritance chain. Reset restores the picked+target's values from when it was opened; Save to library uses the existing design+library export flow.++Glass and absorption (GPU), Clear coat (GPU), Maps (GPU), Saved with this shot,+and Reflections (CPU) follow in that order and start collapsed. Unsupported+methods remain visible with an explanation; opening a section never changes the+renderer. Optical bindings currently target one whole visible body, so face,+component and multiple-body picks show the same controls disabled with a reason.+The Browser command has no Wear selection kind yet, so no Open Wear link is shown.++The old Appearance page retains explicit target selection and the library/reference+and wear controls awaiting their own editors. Its body optics use the same sections+as the picked-body editor. Scene ordinal, exact name, stable target and document+identity are checked; a document revision change requires Revalidate this body.++Six original glass recipes use linear transmittance over a reference distance to+compute absorption per millimetre via -ln(T) / distance. Glass exposes boundary,+IOR, thickness, RGB absorption, straight shadow transmission and closed-solid+interior scattering. Thickness is disabled for closed glass, which uses geometric+distance. Glass cannot share a body with coat or maps. Full topology, orientation,+overlap and optical-boundary checks run during GPU preparation; Check does not+certify those properties.++Clear coat retains weight, roughness and IOR. Maps retain the bounded PNG/JPEG+picker flow for base colour, normal, metallic and roughness images, world-space+origin and U/V repeat vectors, normal strength, V orientation and base replacement.+The backend's map-size, encoded-byte, repeat and assignment limits still apply.+File-picker completion checks the original document, revision and body identity.++These local overrides are temporary on the document tab. Save these optics uses+render.optics.bind to save physical glass with the shot; replacement requires the+explicit Replace this body's saved optics checkbox. Coat and local image maps+remain temporary, and the save action explains that limit. Remove saved opens the+shared Remove saved optics? confirmation before render.optics.unbind; stale+confirmations cannot affect a changed document. Saved authored surface bindings+remain manageable in Saved with this shot. Reflections retains this body's+Off/Mirror/Rough CPU binding and explicit target confirmation.++Active GPU overrides still cause Check/Start to refuse a CPU request. Both buttons+submit the same freshly validated runtime parameters and the engine captures file+contents at that boundary.Check and Start build the same request from the current product camera, size andselected method, including when Render Result is open. Every click revalidates host@@ -398,3 +412,16 @@ as before; the focus state is available to a later Inspector change.Look expands Objects, Light expands Lights and Environment, and Frame expandsShots. Output leaves expansion unchanged. Stages preserve selection and neverlock rows or prevent manual expansion.++## Appearance editor++Look shows one Appearance editor with scope, current look, the four-step look+chain and Edit controls. There is no Inspector page strip. Applies to chooses the+selected target or every exact user of the look; mixed values remain inert until+edited. Edit contains colour/hex, finish and metallic/roughness/opacity sliders.+Advanced reuses the existing surface library, optical bindings, glass, clear coat,+texture-map, reflection and aging controls. The separate Textures disclosure is+marked Soon. The shared footer exports the design library through `library.export`+and resets the current target's override through `appearance.assign`.+`view.render_inspector {visible}` controls transient per-document visibility;+selecting a stage reopens the editor. Selection focus routing is deferred.diff --git a/docs/ui-kit.md b/docs/ui-kit.mdindex e639871938..5de5f3ce77 100644--- a/docs/ui-kit.md+++ b/docs/ui-kit.md@@ -146,7 +146,7 @@ table. Panel/Window/Confirm compositions also have dedicated geometry and intera| `searchable_dropdown`, `SearchOption` | Filtered choices, custom-value action and pending message | dropdown tokens || `selection_field`, `Selection` | Selection chip with explicit `active` and `filled` state, in three looks: the active input (where the next pick goes) has a `form_primary` border and `selected_bg` tint; a filled inactive one a quiet neutral tint, a stronger neutral border and its count in `form_ink`; an empty inactive one the plain control with a dim prompt | `selected_bg/ink`, `form_primary/ink/dim`, `control_*`, `form_inset`, `space_2/8/24` || `value_pair` | Paired captions/expressions; optional independent field names | row/field tokens, `space_8` |-| `fraction_field`, `scalar_field` | Locale-aware bounded dimensionless values; scalar fields fill their control column | form control/font tokens |+| `fraction_field`, `scalar_field`, `mixed_scalar_field` | Locale-aware bounded dimensionless values; scalar fields fill their control column; the mixed variant accepts a translated placeholder | form control/font tokens || `number_field` | Integer/decimal field with caller range, drag speed and suffix | form control/font tokens || `length_field`, `angle_field` | Length in design units, angle in degrees | form control/font tokens || `slider` + `Slider` options | One token-painted track/thumb over native slider/value interaction; optional step, caller formatting, whole-step manipulation and hidden value editor | `control_height`, `space_24/8/4/2`, form control/font tokens |@@ -160,7 +160,7 @@ table. Panel/Window/Confirm compositions also have dedicated geometry and intera| `list_picker` | Selectable row with caller identity and native checked state | `control_height`, form selection tokens || `thumbnail_choice`, `ThumbnailChoice`, `add_choice` | Shared selection-chip variant with 52 × 30 preview, selected tab accent, modified dot, progress ring and dashed add action for bottom strips; `Panel::strip_contents` reserves right actions and scrolls choices | `control_height`, spacing, radii, `TabAccent`, control/semantic 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` |+| sphere: `sphere_thumbnail`, `SphereTile`, `sphere_grid`, `sphere_preview` | 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. The Inspector preview composes a sphere, name, informational chips and replacement action in the shared list card. | `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 |@@ -724,3 +724,18 @@ icon segments and category chips. `catalog_footer` draws the quiet information hCatalog title marks use the active workspace accent; tile captions, usage badges andselection outlines share the sphere widgets. Feature code supplies data and commands,while the kit owns every dimension, colour and inset.++The Appearance Inspector uses the shared `inspector_header` (selection icon/name,+workspace chip, Menu and close action) and `Panel::editor_footer` (48 pt pinned+band). `color_hex_field` pairs the colour popover with a bounded hex editor;+`mixed_slider` pairs the standard slider with the mixed-aware scalar editor.+`editor_section` uses a 24 pt heading and 6 pt field gaps.+`workspace_chip`, `text_button`, `section_heading`, `pending_section`,+`searchable_icon_dropdown` and `Menu::text` retain+shared token paint and hit targets. All are exercised in the kit gallery.++| Shared editor component | Behaviour |+| --- | --- |+| method_section | Compact, initially collapsed editor section with a method tag; unsupported contents remain inspectable and disabled, with a translated reason visible even when collapsed. Uses editor_section typography and spacing. |+| vector3_field | Three bounded number fields divide the row's control column evenly, retaining the shared parser, focus and bevels. Used for RGB absorption and world-space origin/repeat vectors. |+| sphere_preview_with_source | Sample card with an interactive source tag, retaining the sphere, name, usage badge and trailing action. Appearance uses the tag to inspect its inheritance chain. |