diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index 9daf749c4..d13f541a0 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -336,6 +336,7 @@ Editable drawing code, native projects and shipped exports are collected under ` | assets/icons/ui/design/svg/flat/send.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 | | assets/icons/ui/design/svg/flat/stop.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 | | assets/icons/ui/design/svg/flat/shield.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 | +| assets/icons/ui/design/svg/model/status_recovery.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 | | assets/icons/ui/design/svg/model/placeholder.svg | SolidCraft contributors | two-tone modelling icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 | | assets/icons/ui/design/svg/model/plane.svg | SolidCraft contributors | two-tone modelling icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 | | assets/icons/ui/design/svg/model/plane_angle.svg | SolidCraft contributors | two-tone modelling icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 | diff --git a/ROADMAP.md b/ROADMAP.md index dfa81b55c..e2dcd216a 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -70,6 +70,11 @@ pointer movement orbits without a mouse button, and vertical scrolling zooms. Ot retain their saved two-finger scroll preference; camera motion is available through `view.navigate` and modifier-aware `ui.move` automation. +UI redesign (#2016): the File/start view (#2027) uses shared light/dark navigation, +action tiles, recent rows and sample cards, with recovery review and Save As/Export +entry points. Document loading, sample caches and recovery safety retain their +existing command paths. + M11 precursor: File → Export Current View as DXF exports shown placed bodies and sketches from the current camera as a 2D millimetre drawing, with hidden edges omitted or dashed. Vector occlusion splits partly hidden edges and includes curved silhouettes. Repeated part meshes and triangle diff --git a/assets/icons/ui/design/requested_icons.txt b/assets/icons/ui/design/requested_icons.txt index 2751731a2..0270b9912 100644 --- a/assets/icons/ui/design/requested_icons.txt +++ b/assets/icons/ui/design/requested_icons.txt @@ -239,6 +239,7 @@ split_face false spun false star false status_error false +status_recovery false style false suppress false surface_blend false diff --git a/assets/icons/ui/design/svg/model/status_recovery.svg b/assets/icons/ui/design/svg/model/status_recovery.svg new file mode 100644 index 000000000..ce92e4b7a --- /dev/null +++ b/assets/icons/ui/design/svg/model/status_recovery.svg @@ -0,0 +1,7 @@ + + Recover unsaved design + + + + + diff --git a/assets/locales/cs.json b/assets/locales/cs.json index ba1e2a85b..75fa9d728 100644 --- a/assets/locales/cs.json +++ b/assets/locales/cs.json @@ -857,19 +857,57 @@ "help.mit": "Licence MIT", "help.notice": "NOTICE", "help.third_party": "Licence třetích stran", + "home.back": "Zpět na {name}", + "home.crashes": "Hlášení o pádech", + "home.design_workspace": "Návrh", "home.documentation": "Dokumentace", + "home.export": "Exportovat", + "home.export_hint": "Vyberte formát pro aktuální návrh.", + "home.export_json_hint": "Upravitelný návrh a historie příkazů", + "home.export_mesh_hint": "Síť pro tisk nebo sdílení", + "home.export_step_hint": "Přesná geometrie tělesa", + "home.import": "Importovat…", + "home.import_hint": "STEP, IGES nebo síť do nového návrhu", "home.in_this_browser": "v tomto prohlížeči", "home.missing": "chybí", + "home.month_01": "led", + "home.month_02": "úno", + "home.month_03": "bře", + "home.month_04": "dub", + "home.month_05": "kvě", + "home.month_06": "čer", + "home.month_07": "čvc", + "home.month_08": "srp", + "home.month_09": "zář", + "home.month_10": "říj", + "home.month_11": "lis", + "home.month_12": "pro", + "home.new_inches": "Nový návrh v palcích", + "home.new_inches_hint": "Palce · otevře se v pracovním prostoru Návrh", + "home.new_mm": "Nový návrh", + "home.new_mm_hint": "Milimetry · otevře se v pracovním prostoru Návrh", "home.open": "Otevřít…", - "home.opened_days_ago": "Otevřeno před {count} dny", - "home.opened_hours_ago": "Otevřeno před {count} h", - "home.opened_just_now": "Otevřeno právě teď", - "home.opened_minutes_ago": "Otevřeno před {count} min", + "home.open_hint": "Návrh ve formátu .solidcraft ({shortcut})", + "home.open_now": "Otevřít nyní", + "home.opened_days_ago": "Před {count} dny", + "home.opened_hours_ago": "Před {count} h", + "home.opened_just_now": "Právě teď", + "home.opened_minutes_ago": "Před {count} min", "home.opening": "otevírání…", + "home.properties": "Vlastnosti návrhu", "home.recent": "Nedávné", + "home.recent_empty": "Zde se zobrazí návrhy, které otevřete nebo uložíte.", + "home.recovery_count": "Návrhy k obnovení: {count}", + "home.recovery_empty": "Žádné návrhy k obnovení.", + "home.recovery_hint": "SolidCraft se zavřel před uložením těchto návrhů.", "home.report_issue": "Nahlásit problém", "home.samples": "Ukázky", + "home.settings": "Nastavení", + "home.short_date": "{day}. {month}", + "home.shortcuts": "Klávesové zkratky", + "home.start_hint": "Vytvořte návrh, otevřete nedávný soubor nebo prozkoumejte ukázku.", "home.whats_new": "Co je nového", + "home.yesterday": "Včera", "install.button_tip": "Nainstalovat SolidCraft jako aplikaci: otevře se ve vlastním okně a funguje i offline", "install.dock_1": "Zvolte Soubor › Přidat do Docku.", "install.dock_2": "Klikněte na Přidat.", diff --git a/assets/locales/da.json b/assets/locales/da.json index f2cc366bf..d3ed74c7d 100644 --- a/assets/locales/da.json +++ b/assets/locales/da.json @@ -857,19 +857,57 @@ "help.mit": "MIT-licens", "help.notice": "NOTICE", "help.third_party": "Tredjepartslicenser", + "home.back": "Tilbage til {name}", + "home.crashes": "Nedbrudsrapporter", + "home.design_workspace": "Design", "home.documentation": "Dokumentation", + "home.export": "Eksportér", + "home.export_hint": "Vælg et format til det aktuelle design.", + "home.export_json_hint": "Redigerbart design og kommandohistorik", + "home.export_mesh_hint": "Mesh til udskrivning eller deling", + "home.export_step_hint": "Præcis geometri for massive legemer", + "home.import": "Importér…", + "home.import_hint": "STEP, IGES eller mesh til et nyt design", "home.in_this_browser": "i denne webbrowser", "home.missing": "mangler", + "home.month_01": "jan.", + "home.month_02": "feb.", + "home.month_03": "mar.", + "home.month_04": "apr.", + "home.month_05": "maj", + "home.month_06": "jun.", + "home.month_07": "jul.", + "home.month_08": "aug.", + "home.month_09": "sep.", + "home.month_10": "okt.", + "home.month_11": "nov.", + "home.month_12": "dec.", + "home.new_inches": "Nyt design i tommer", + "home.new_inches_hint": "Tommer · åbner i Design", + "home.new_mm": "Nyt design", + "home.new_mm_hint": "Millimeter · åbner i Design", "home.open": "Åbn…", - "home.opened_days_ago": "Åbnet for {count} dage siden", - "home.opened_hours_ago": "Åbnet for {count} t siden", - "home.opened_just_now": "Netop åbnet", - "home.opened_minutes_ago": "Åbnet for {count} min siden", + "home.open_hint": "Et .solidcraft-design ({shortcut})", + "home.open_now": "Åbn nu", + "home.opened_days_ago": "For {count} dage siden", + "home.opened_hours_ago": "For {count} t siden", + "home.opened_just_now": "Lige nu", + "home.opened_minutes_ago": "For {count} min siden", "home.opening": "åbner…", + "home.properties": "Designegenskaber", "home.recent": "Seneste", + "home.recent_empty": "Design, du åbner eller gemmer, vises her.", + "home.recovery_count": "Design til gendannelse: {count}", + "home.recovery_empty": "Ingen design kan gendannes.", + "home.recovery_hint": "SolidCraft lukkede, før disse design blev gemt.", "home.report_issue": "Rapportér et problem", "home.samples": "Eksempler", + "home.settings": "Indstillinger", + "home.short_date": "{day}. {month}", + "home.shortcuts": "Tastaturgenveje", + "home.start_hint": "Opret et design, åbn en nylig fil, eller udforsk et eksempel.", "home.whats_new": "Nyheder", + "home.yesterday": "I går", "install.button_tip": "Installér SolidCraft som en app: Den åbner i sit eget vindue og virker offline", "install.dock_1": "Vælg Arkiv › Føj til Dock.", "install.dock_2": "Klik på Tilføj.", diff --git a/assets/locales/de.json b/assets/locales/de.json index ab618e41e..f50159cfa 100644 --- a/assets/locales/de.json +++ b/assets/locales/de.json @@ -859,19 +859,57 @@ "help.mit": "MIT-Lizenz", "help.notice": "NOTICE", "help.third_party": "Drittanbieterlizenzen", + "home.back": "Zurück zu {name}", + "home.crashes": "Absturzberichte", + "home.design_workspace": "Entwurf", "home.documentation": "Dokumentation", + "home.export": "Exportieren", + "home.export_hint": "Wählen Sie ein Format für den aktuellen Entwurf.", + "home.export_json_hint": "Bearbeitbarer Entwurf und Befehlsverlauf", + "home.export_mesh_hint": "Netz zum Drucken oder Teilen", + "home.export_step_hint": "Präzise Volumengeometrie", + "home.import": "Importieren…", + "home.import_hint": "STEP, IGES oder Netz in einen neuen Entwurf", "home.in_this_browser": "in diesem Browser", "home.missing": "fehlt", + "home.month_01": "Jan.", + "home.month_02": "Feb.", + "home.month_03": "März", + "home.month_04": "Apr.", + "home.month_05": "Mai", + "home.month_06": "Juni", + "home.month_07": "Juli", + "home.month_08": "Aug.", + "home.month_09": "Sept.", + "home.month_10": "Okt.", + "home.month_11": "Nov.", + "home.month_12": "Dez.", + "home.new_inches": "Neuer Entwurf in Zoll", + "home.new_inches_hint": "Zoll · öffnet sich im Arbeitsbereich Entwurf", + "home.new_mm": "Neuer Entwurf", + "home.new_mm_hint": "Millimeter · öffnet sich im Arbeitsbereich Entwurf", "home.open": "Öffnen…", - "home.opened_days_ago": "Vor {count} Tag(en) geöffnet", - "home.opened_hours_ago": "Vor {count} Std. geöffnet", - "home.opened_just_now": "Gerade eben geöffnet", - "home.opened_minutes_ago": "Vor {count} Min. geöffnet", + "home.open_hint": "Ein .solidcraft-Entwurf ({shortcut})", + "home.open_now": "Jetzt öffnen", + "home.opened_days_ago": "Vor {count} Tagen", + "home.opened_hours_ago": "Vor {count} Std.", + "home.opened_just_now": "Gerade eben", + "home.opened_minutes_ago": "Vor {count} Min.", "home.opening": "wird geöffnet…", + "home.properties": "Entwurfseigenschaften", "home.recent": "Zuletzt verwendet", + "home.recent_empty": "Entwürfe, die Sie öffnen oder speichern, erscheinen hier.", + "home.recovery_count": "Wiederherstellbare Entwürfe: {count}", + "home.recovery_empty": "Keine wiederherstellbaren Entwürfe.", + "home.recovery_hint": "SolidCraft wurde geschlossen, bevor diese Entwürfe gespeichert wurden.", "home.report_issue": "Problem melden", "home.samples": "Beispiele", + "home.settings": "Einstellungen", + "home.short_date": "{day}. {month}", + "home.shortcuts": "Tastenkombinationen", + "home.start_hint": "Erstellen Sie einen Entwurf, öffnen Sie eine zuletzt verwendete Datei oder erkunden Sie ein Beispiel.", "home.whats_new": "Neuigkeiten", + "home.yesterday": "Gestern", "install.button_tip": "SolidCraft als App installieren: eigenes Fenster, funktioniert auch offline", "install.dock_1": "Wählen Sie Ablage › Zum Dock hinzufügen.", "install.dock_2": "Klicken Sie auf „Hinzufügen“.", diff --git a/assets/locales/en.json b/assets/locales/en.json index db6a1d2fe..0d4b657b3 100644 --- a/assets/locales/en.json +++ b/assets/locales/en.json @@ -889,19 +889,57 @@ "help.solid.revolve": "Spins a sketch profile around an axis to make a round solid. Use it for shafts, knobs, bowls and any part that is round about a centre line.", "help.solid.shell": "Hollows out a solid, leaving walls of the thickness you set, and can open the faces you pick. Use it for boxes, covers and other thin-walled parts.", "help.third_party": "Third-party licences", + "home.back": "Back to {name}", + "home.crashes": "Crash reports", + "home.design_workspace": "Design", "home.documentation": "Documentation", + "home.export": "Export", + "home.export_hint": "Choose a format for the current design.", + "home.export_json_hint": "Editable design and command history", + "home.export_mesh_hint": "Mesh for printing or sharing", + "home.export_step_hint": "Precise solid geometry", + "home.import": "Import…", + "home.import_hint": "STEP, IGES or mesh into a new design", "home.in_this_browser": "in this browser", "home.missing": "missing", + "home.month_01": "Jan", + "home.month_02": "Feb", + "home.month_03": "Mar", + "home.month_04": "Apr", + "home.month_05": "May", + "home.month_06": "Jun", + "home.month_07": "Jul", + "home.month_08": "Aug", + "home.month_09": "Sep", + "home.month_10": "Oct", + "home.month_11": "Nov", + "home.month_12": "Dec", + "home.new_inches": "New design, inches", + "home.new_inches_hint": "Inches · opens in Design", + "home.new_mm": "New design", + "home.new_mm_hint": "Millimetres · opens in Design", "home.open": "Open…", - "home.opened_days_ago": "Opened {count} days ago", - "home.opened_hours_ago": "Opened {count} h ago", - "home.opened_just_now": "Opened just now", - "home.opened_minutes_ago": "Opened {count} min ago", + "home.open_hint": "A .solidcraft design ({shortcut})", + "home.open_now": "Open now", + "home.opened_days_ago": "{count} days ago", + "home.opened_hours_ago": "{count} h ago", + "home.opened_just_now": "Just now", + "home.opened_minutes_ago": "{count} min ago", "home.opening": "opening…", + "home.properties": "Design properties", "home.recent": "Recent", + "home.recent_empty": "Designs you open or save appear here.", + "home.recovery_count": "Recoverable designs: {count}", + "home.recovery_empty": "No recoverable designs.", + "home.recovery_hint": "SolidCraft closed before these designs were saved.", "home.report_issue": "Report an Issue", "home.samples": "Samples", + "home.settings": "Settings", + "home.short_date": "{day} {month}", + "home.shortcuts": "Keyboard shortcuts", + "home.start_hint": "Create a design, open a recent file, or explore a sample.", "home.whats_new": "What's new", + "home.yesterday": "Yesterday", "install.button_tip": "Install SolidCraft as an app: it opens in its own window and works offline", "install.dock_1": "Choose File › Add to Dock.", "install.dock_2": "Click Add.", diff --git a/assets/locales/es.json b/assets/locales/es.json index 71fabc566..4f13918d4 100644 --- a/assets/locales/es.json +++ b/assets/locales/es.json @@ -857,19 +857,57 @@ "help.mit": "Licencia MIT", "help.notice": "NOTICE", "help.third_party": "Licencias de terceros", + "home.back": "Volver a {name}", + "home.crashes": "Informes de fallos", + "home.design_workspace": "Diseño", "home.documentation": "Documentación", + "home.export": "Exportar", + "home.export_hint": "Elige un formato para el diseño actual.", + "home.export_json_hint": "Diseño editable e historial de comandos", + "home.export_mesh_hint": "Malla para imprimir o compartir", + "home.export_step_hint": "Geometría sólida precisa", + "home.import": "Importar…", + "home.import_hint": "STEP, IGES o malla en un nuevo diseño", "home.in_this_browser": "en este navegador", "home.missing": "no disponible", + "home.month_01": "ene", + "home.month_02": "feb", + "home.month_03": "mar", + "home.month_04": "abr", + "home.month_05": "may", + "home.month_06": "jun", + "home.month_07": "jul", + "home.month_08": "ago", + "home.month_09": "sept", + "home.month_10": "oct", + "home.month_11": "nov", + "home.month_12": "dic", + "home.new_inches": "Nuevo diseño en pulgadas", + "home.new_inches_hint": "Pulgadas · se abre en Diseño", + "home.new_mm": "Nuevo diseño", + "home.new_mm_hint": "Milímetros · se abre en Diseño", "home.open": "Abrir…", - "home.opened_days_ago": "Abierto hace {count} días", - "home.opened_hours_ago": "Abierto hace {count} h", - "home.opened_just_now": "Acaba de abrirse", - "home.opened_minutes_ago": "Abierto hace {count} min", + "home.open_hint": "Un diseño .solidcraft ({shortcut})", + "home.open_now": "Abrir ahora", + "home.opened_days_ago": "Hace {count} días", + "home.opened_hours_ago": "Hace {count} h", + "home.opened_just_now": "Ahora mismo", + "home.opened_minutes_ago": "Hace {count} min", "home.opening": "abriendo…", + "home.properties": "Propiedades del diseño", "home.recent": "Recientes", + "home.recent_empty": "Los diseños que abras o guardes aparecerán aquí.", + "home.recovery_count": "Diseños recuperables: {count}", + "home.recovery_empty": "No hay diseños recuperables.", + "home.recovery_hint": "SolidCraft se cerró antes de guardar estos diseños.", "home.report_issue": "Notificar un problema", "home.samples": "Ejemplos", + "home.settings": "Configuración", + "home.short_date": "{day} {month}", + "home.shortcuts": "Atajos de teclado", + "home.start_hint": "Crea un diseño, abre un archivo reciente o explora un ejemplo.", "home.whats_new": "Novedades", + "home.yesterday": "Ayer", "install.button_tip": "Instalar SolidCraft como aplicación: se abre en una ventana propia y funciona sin conexión", "install.dock_1": "Elige Archivo › Añadir al Dock.", "install.dock_2": "Haz clic en Añadir.", diff --git a/assets/locales/fr.json b/assets/locales/fr.json index 07731cea4..2e31781e8 100644 --- a/assets/locales/fr.json +++ b/assets/locales/fr.json @@ -863,19 +863,57 @@ "help.solid.revolve": "Fait tourner le profil d'une esquisse autour d'un axe pour obtenir un solide de révolution. À utiliser pour les arbres, boutons, bols et toute pièce ronde autour d'une ligne centrale.", "help.solid.shell": "Évide un solide en laissant des parois de l'épaisseur indiquée, et peut ouvrir les faces choisies. À utiliser pour les boîtes, couvercles et autres pièces à parois minces.", "help.third_party": "Licences tierces", + "home.back": "Revenir à {name}", + "home.crashes": "Rapports de plantage", + "home.design_workspace": "Conception", "home.documentation": "Documentation", + "home.export": "Exporter", + "home.export_hint": "Choisissez un format pour la conception actuelle.", + "home.export_json_hint": "Conception modifiable et historique des commandes", + "home.export_mesh_hint": "Maillage pour l’impression ou le partage", + "home.export_step_hint": "Géométrie solide précise", + "home.import": "Importer…", + "home.import_hint": "STEP, IGES ou maillage dans une nouvelle conception", "home.in_this_browser": "dans ce navigateur", "home.missing": "introuvable", + "home.month_01": "janv.", + "home.month_02": "févr.", + "home.month_03": "mars", + "home.month_04": "avr.", + "home.month_05": "mai", + "home.month_06": "juin", + "home.month_07": "juil.", + "home.month_08": "août", + "home.month_09": "sept.", + "home.month_10": "oct.", + "home.month_11": "nov.", + "home.month_12": "déc.", + "home.new_inches": "Nouvelle conception en pouces", + "home.new_inches_hint": "Pouces · ouvre l’espace Conception", + "home.new_mm": "Nouvelle conception", + "home.new_mm_hint": "Millimètres · ouvre l’espace Conception", "home.open": "Ouvrir…", - "home.opened_days_ago": "Ouvert il y a {count} j", - "home.opened_hours_ago": "Ouvert il y a {count} h", - "home.opened_just_now": "Ouvert à l'instant", - "home.opened_minutes_ago": "Ouvert il y a {count} min", + "home.open_hint": "Une conception .solidcraft ({shortcut})", + "home.open_now": "Ouvrir maintenant", + "home.opened_days_ago": "Il y a {count} j", + "home.opened_hours_ago": "Il y a {count} h", + "home.opened_just_now": "À l’instant", + "home.opened_minutes_ago": "Il y a {count} min", "home.opening": "ouverture…", + "home.properties": "Propriétés de la conception", "home.recent": "Récents", + "home.recent_empty": "Les conceptions que vous ouvrez ou enregistrez apparaissent ici.", + "home.recovery_count": "Conceptions récupérables : {count}", + "home.recovery_empty": "Aucune conception récupérable.", + "home.recovery_hint": "SolidCraft s’est fermé avant l’enregistrement de ces conceptions.", "home.report_issue": "Signaler un problème", "home.samples": "Exemples", + "home.settings": "Paramètres", + "home.short_date": "{day} {month}", + "home.shortcuts": "Raccourcis clavier", + "home.start_hint": "Créez une conception, ouvrez un fichier récent ou explorez un exemple.", "home.whats_new": "Nouveautés", + "home.yesterday": "Hier", "install.button_tip": "Installer SolidCraft comme une app : il s'ouvre dans sa propre fenêtre et fonctionne hors ligne", "install.dock_1": "Choisissez Fichier › Ajouter au Dock.", "install.dock_2": "Cliquez sur Ajouter.", diff --git a/assets/locales/gl.json b/assets/locales/gl.json index e5b818c14..4e92acf02 100644 --- a/assets/locales/gl.json +++ b/assets/locales/gl.json @@ -857,19 +857,57 @@ "help.mit": "Licenza MIT", "help.notice": "NOTICE", "help.third_party": "Licenzas de terceiros", + "home.back": "Volver a {name}", + "home.crashes": "Informes de fallos", + "home.design_workspace": "Deseño", "home.documentation": "Documentación", + "home.export": "Exportar", + "home.export_hint": "Escolle un formato para o deseño actual.", + "home.export_json_hint": "Deseño editable e historial de comandos", + "home.export_mesh_hint": "Malla para imprimir ou compartir", + "home.export_step_hint": "Xeometría sólida precisa", + "home.import": "Importar…", + "home.import_hint": "STEP, IGES ou malla nun novo deseño", "home.in_this_browser": "neste navegador", "home.missing": "non atopado", + "home.month_01": "xan.", + "home.month_02": "feb.", + "home.month_03": "mar.", + "home.month_04": "abr.", + "home.month_05": "maio", + "home.month_06": "xuño", + "home.month_07": "xul.", + "home.month_08": "ago.", + "home.month_09": "set.", + "home.month_10": "out.", + "home.month_11": "nov.", + "home.month_12": "dec.", + "home.new_inches": "Novo deseño en polgadas", + "home.new_inches_hint": "Polgadas · ábrese en Deseño", + "home.new_mm": "Novo deseño", + "home.new_mm_hint": "Milímetros · ábrese en Deseño", "home.open": "Abrir…", - "home.opened_days_ago": "Aberto hai {count} días", - "home.opened_hours_ago": "Aberto hai {count} h", - "home.opened_just_now": "Aberto agora mesmo", - "home.opened_minutes_ago": "Aberto hai {count} min", + "home.open_hint": "Un deseño .solidcraft ({shortcut})", + "home.open_now": "Abrir agora", + "home.opened_days_ago": "Hai {count} días", + "home.opened_hours_ago": "Hai {count} h", + "home.opened_just_now": "Agora mesmo", + "home.opened_minutes_ago": "Hai {count} min", "home.opening": "abrindo…", + "home.properties": "Propiedades do deseño", "home.recent": "Recentes", + "home.recent_empty": "Os deseños que abras ou gardes aparecerán aquí.", + "home.recovery_count": "Deseños recuperables: {count}", + "home.recovery_empty": "Non hai deseños recuperables.", + "home.recovery_hint": "SolidCraft pechouse antes de gardar estes deseños.", "home.report_issue": "Informar dunha incidencia", "home.samples": "Exemplos", + "home.settings": "Configuración", + "home.short_date": "{day} {month}", + "home.shortcuts": "Atallos de teclado", + "home.start_hint": "Crea un deseño, abre un ficheiro recente ou explora un exemplo.", "home.whats_new": "Novidades", + "home.yesterday": "Onte", "install.button_tip": "Instala SolidCraft como aplicación: ábrese na súa propia xanela e funciona sen conexión", "install.dock_1": "Escolle Ficheiro › Engadir ao Dock.", "install.dock_2": "Fai clic en Engadir.", diff --git a/assets/locales/hu.json b/assets/locales/hu.json index f96d615b5..e9f8f9b7a 100644 --- a/assets/locales/hu.json +++ b/assets/locales/hu.json @@ -856,19 +856,57 @@ "help.mit": "MIT licenc", "help.notice": "NOTICE", "help.third_party": "Harmadik felek licencei", + "home.back": "Vissza ide: {name}", + "home.crashes": "Összeomlási jelentések", + "home.design_workspace": "Tervezés", "home.documentation": "Dokumentáció", + "home.export": "Exportálás", + "home.export_hint": "Válasszon formátumot az aktuális tervhez.", + "home.export_json_hint": "Szerkeszthető terv és parancselőzmények", + "home.export_mesh_hint": "Háló nyomtatáshoz vagy megosztáshoz", + "home.export_step_hint": "Pontos testgeometria", + "home.import": "Importálás…", + "home.import_hint": "STEP, IGES vagy háló importálása új tervbe", "home.in_this_browser": "ebben a böngészőben", "home.missing": "hiányzik", + "home.month_01": "jan.", + "home.month_02": "febr.", + "home.month_03": "márc.", + "home.month_04": "ápr.", + "home.month_05": "máj.", + "home.month_06": "jún.", + "home.month_07": "júl.", + "home.month_08": "aug.", + "home.month_09": "szept.", + "home.month_10": "okt.", + "home.month_11": "nov.", + "home.month_12": "dec.", + "home.new_inches": "Új terv hüvelykben", + "home.new_inches_hint": "Hüvelyk · a Tervezés munkaterületen nyílik meg", + "home.new_mm": "Új terv", + "home.new_mm_hint": "Milliméter · a Tervezés munkaterületen nyílik meg", "home.open": "Megnyitás…", - "home.opened_days_ago": "Megnyitva {count} napja", - "home.opened_hours_ago": "Megnyitva {count} órája", - "home.opened_just_now": "Épp most megnyitva", - "home.opened_minutes_ago": "Megnyitva {count} perce", + "home.open_hint": "Egy .solidcraft terv ({shortcut})", + "home.open_now": "Jelenleg megnyitva", + "home.opened_days_ago": "{count} napja", + "home.opened_hours_ago": "{count} órája", + "home.opened_just_now": "Épp most", + "home.opened_minutes_ago": "{count} perce", "home.opening": "megnyitás…", + "home.properties": "Terv tulajdonságai", "home.recent": "Legutóbbi", + "home.recent_empty": "A megnyitott vagy mentett tervek itt jelennek meg.", + "home.recovery_count": "Helyreállítható tervek: {count}", + "home.recovery_empty": "Nincs helyreállítható terv.", + "home.recovery_hint": "A SolidCraft a tervek mentése előtt bezárult.", "home.report_issue": "Hiba jelentése", "home.samples": "Minták", + "home.settings": "Beállítások", + "home.short_date": "{month} {day}.", + "home.shortcuts": "Billentyűparancsok", + "home.start_hint": "Hozzon létre egy tervet, nyisson meg egy legutóbbi fájlt, vagy fedezzen fel egy mintát.", "home.whats_new": "Újdonságok", + "home.yesterday": "Tegnap", "install.button_tip": "A SolidCraft telepítése alkalmazásként: saját ablakban nyílik meg, és offline is működik", "install.dock_1": "Válassza a Fájl › Hozzáadás a Dockhoz lehetőséget.", "install.dock_2": "Kattintson a Hozzáadás gombra.", diff --git a/assets/locales/id.json b/assets/locales/id.json index 3847d7a1a..437b79126 100644 --- a/assets/locales/id.json +++ b/assets/locales/id.json @@ -856,19 +856,57 @@ "help.mit": "Lisensi MIT", "help.notice": "NOTICE", "help.third_party": "Lisensi pihak ketiga", + "home.back": "Kembali ke {name}", + "home.crashes": "Laporan kerusakan", + "home.design_workspace": "Desain", "home.documentation": "Dokumentasi", + "home.export": "Ekspor", + "home.export_hint": "Pilih format untuk desain saat ini.", + "home.export_json_hint": "Desain yang dapat diedit dan riwayat perintah", + "home.export_mesh_hint": "Mesh untuk pencetakan atau berbagi", + "home.export_step_hint": "Geometri benda padat yang presisi", + "home.import": "Impor…", + "home.import_hint": "STEP, IGES, atau mesh ke dalam desain baru", "home.in_this_browser": "di peramban ini", "home.missing": "hilang", + "home.month_01": "Jan", + "home.month_02": "Feb", + "home.month_03": "Mar", + "home.month_04": "Apr", + "home.month_05": "Mei", + "home.month_06": "Jun", + "home.month_07": "Jul", + "home.month_08": "Agu", + "home.month_09": "Sep", + "home.month_10": "Okt", + "home.month_11": "Nov", + "home.month_12": "Des", + "home.new_inches": "Desain baru dalam inci", + "home.new_inches_hint": "Inci · terbuka di Desain", + "home.new_mm": "Desain baru", + "home.new_mm_hint": "Milimeter · terbuka di Desain", "home.open": "Buka…", - "home.opened_days_ago": "Dibuka {count} hari lalu", - "home.opened_hours_ago": "Dibuka {count} jam lalu", - "home.opened_just_now": "Baru saja dibuka", - "home.opened_minutes_ago": "Dibuka {count} mnt lalu", + "home.open_hint": "Desain .solidcraft ({shortcut})", + "home.open_now": "Sedang terbuka", + "home.opened_days_ago": "{count} hari lalu", + "home.opened_hours_ago": "{count} jam lalu", + "home.opened_just_now": "Baru saja", + "home.opened_minutes_ago": "{count} mnt lalu", "home.opening": "membuka…", + "home.properties": "Properti desain", "home.recent": "Terbaru", + "home.recent_empty": "Desain yang Anda buka atau simpan akan muncul di sini.", + "home.recovery_count": "Desain yang dapat dipulihkan: {count}", + "home.recovery_empty": "Tidak ada desain yang dapat dipulihkan.", + "home.recovery_hint": "SolidCraft ditutup sebelum desain ini disimpan.", "home.report_issue": "Laporkan Masalah", "home.samples": "Contoh", + "home.settings": "Pengaturan", + "home.short_date": "{day} {month}", + "home.shortcuts": "Pintasan papan ketik", + "home.start_hint": "Buat desain, buka berkas terbaru, atau jelajahi contoh.", "home.whats_new": "Yang baru", + "home.yesterday": "Kemarin", "install.button_tip": "Pasang SolidCraft sebagai aplikasi: terbuka di jendelanya sendiri dan berfungsi offline", "install.dock_1": "Pilih File › Add to Dock.", "install.dock_2": "Klik Add.", diff --git a/assets/locales/it.json b/assets/locales/it.json index 6a772ff66..af11a6787 100644 --- a/assets/locales/it.json +++ b/assets/locales/it.json @@ -860,19 +860,57 @@ "help.mit": "Licenza MIT", "help.notice": "NOTICE", "help.third_party": "Licenze di terze parti", + "home.back": "Torna a {name}", + "home.crashes": "Rapporti di arresto anomalo", + "home.design_workspace": "Progettazione", "home.documentation": "Documentazione", + "home.export": "Esporta", + "home.export_hint": "Scegli un formato per il progetto attuale.", + "home.export_json_hint": "Progetto modificabile e cronologia dei comandi", + "home.export_mesh_hint": "Mesh per la stampa o la condivisione", + "home.export_step_hint": "Geometria solida precisa", + "home.import": "Importa…", + "home.import_hint": "STEP, IGES o mesh in un nuovo progetto", "home.in_this_browser": "in questo browser", "home.missing": "non presente", + "home.month_01": "gen", + "home.month_02": "feb", + "home.month_03": "mar", + "home.month_04": "apr", + "home.month_05": "mag", + "home.month_06": "giu", + "home.month_07": "lug", + "home.month_08": "ago", + "home.month_09": "set", + "home.month_10": "ott", + "home.month_11": "nov", + "home.month_12": "dic", + "home.new_inches": "Nuovo progetto in pollici", + "home.new_inches_hint": "Pollici · si apre in Progettazione", + "home.new_mm": "Nuovo progetto", + "home.new_mm_hint": "Millimetri · si apre in Progettazione", "home.open": "Apri…", - "home.opened_days_ago": "Aperto {count} giorni fa", - "home.opened_hours_ago": "Aperto {count} h fa", - "home.opened_just_now": "Appena aperto", - "home.opened_minutes_ago": "Aperto {count} min fa", + "home.open_hint": "Un progetto .solidcraft ({shortcut})", + "home.open_now": "Apri ora", + "home.opened_days_ago": "{count} giorni fa", + "home.opened_hours_ago": "{count} h fa", + "home.opened_just_now": "Adesso", + "home.opened_minutes_ago": "{count} min fa", "home.opening": "apertura…", + "home.properties": "Proprietà del progetto", "home.recent": "Recenti", + "home.recent_empty": "I progetti che apri o salvi vengono visualizzati qui.", + "home.recovery_count": "Progetti recuperabili: {count}", + "home.recovery_empty": "Nessun progetto recuperabile.", + "home.recovery_hint": "SolidCraft si è chiuso prima del salvataggio di questi progetti.", "home.report_issue": "Segnala un problema", "home.samples": "Esempi", + "home.settings": "Impostazioni", + "home.short_date": "{day} {month}", + "home.shortcuts": "Scorciatoie da tastiera", + "home.start_hint": "Crea un progetto, apri un file recente o esplora un esempio.", "home.whats_new": "Novità", + "home.yesterday": "Ieri", "install.button_tip": "Installa SolidCraft come applicazione: si apre in una finestra dedicata e funziona offline", "install.dock_1": "Scegli File › Aggiungi al Dock.", "install.dock_2": "Fai clic su Aggiungi.", diff --git a/assets/locales/ja.json b/assets/locales/ja.json index 697c15101..402bde41f 100644 --- a/assets/locales/ja.json +++ b/assets/locales/ja.json @@ -889,19 +889,57 @@ "help.solid.revolve": "スケッチの輪郭を軸のまわりに回転させ、丸い立体を作ります。軸、つまみ、ボウルなど、中心線まわりに丸い部品に使います。", "help.solid.shell": "立体の中をくり抜き、指定した厚さの壁を残します。選んだ面を開口にすることもできます。箱、カバーなどの薄肉の部品に使います。", "help.third_party": "サードパーティライセンス", + "home.back": "{name} に戻る", + "home.crashes": "クラッシュレポート", + "home.design_workspace": "デザイン", "home.documentation": "ドキュメント", + "home.export": "エクスポート", + "home.export_hint": "現在のデザインの出力形式を選択してください。", + "home.export_json_hint": "編集可能なデザインとコマンド履歴", + "home.export_mesh_hint": "印刷や共有用のメッシュ", + "home.export_step_hint": "精密なソリッド形状", + "home.import": "インポート…", + "home.import_hint": "STEP、IGES、またはメッシュを新しいデザインに読み込みます", "home.in_this_browser": "このブラウザ内", "home.missing": "見つかりません", + "home.month_01": "1月", + "home.month_02": "2月", + "home.month_03": "3月", + "home.month_04": "4月", + "home.month_05": "5月", + "home.month_06": "6月", + "home.month_07": "7月", + "home.month_08": "8月", + "home.month_09": "9月", + "home.month_10": "10月", + "home.month_11": "11月", + "home.month_12": "12月", + "home.new_inches": "新しいデザイン(インチ)", + "home.new_inches_hint": "インチ · デザインで開きます", + "home.new_mm": "新しいデザイン", + "home.new_mm_hint": "ミリメートル · デザインで開きます", "home.open": "開く…", - "home.opened_days_ago": "{count} 日前に開きました", - "home.opened_hours_ago": "{count} 時間前に開きました", - "home.opened_just_now": "たった今開きました", - "home.opened_minutes_ago": "{count} 分前に開きました", + "home.open_hint": ".solidcraft 形式のデザイン ({shortcut})", + "home.open_now": "今すぐ開く", + "home.opened_days_ago": "{count} 日前", + "home.opened_hours_ago": "{count} 時間前", + "home.opened_just_now": "たった今", + "home.opened_minutes_ago": "{count} 分前", "home.opening": "開いています…", + "home.properties": "デザインのプロパティ", "home.recent": "最近使用した項目", + "home.recent_empty": "開いたり保存したデザインがここに表示されます。", + "home.recovery_count": "復元可能なデザイン: {count} 件", + "home.recovery_empty": "復元可能なデザインはありません。", + "home.recovery_hint": "これらのデザインが保存される前に SolidCraft が終了しました。", "home.report_issue": "問題を報告", "home.samples": "サンプル", + "home.settings": "設定", + "home.short_date": "{month}{day}日", + "home.shortcuts": "キーボードショートカット", + "home.start_hint": "デザインを作成するか、最近使ったファイルを開くか、サンプルをご覧ください。", "home.whats_new": "新機能", + "home.yesterday": "昨日", "install.button_tip": "SolidCraft をアプリとしてインストールします。専用のウィンドウで開き、オフラインでも使えます", "install.dock_1": "「ファイル」›「Dockに追加」を選びます。", "install.dock_2": "「追加」をクリックします。", diff --git a/assets/locales/ko.json b/assets/locales/ko.json index dcd938260..f76a724ae 100644 --- a/assets/locales/ko.json +++ b/assets/locales/ko.json @@ -859,19 +859,57 @@ "help.mit": "MIT 라이선스", "help.notice": "NOTICE", "help.third_party": "타사 라이선스", + "home.back": "{name}(으)로 돌아가기", + "home.crashes": "충돌 보고서", + "home.design_workspace": "설계", "home.documentation": "문서", + "home.export": "내보내기", + "home.export_hint": "현재 설계의 형식을 선택하세요.", + "home.export_json_hint": "편집 가능한 설계 및 명령 기록", + "home.export_mesh_hint": "인쇄 또는 공유용 메시", + "home.export_step_hint": "정밀한 솔리드 형상", + "home.import": "가져오기…", + "home.import_hint": "STEP, IGES 또는 메시를 새 설계로 가져오기", "home.in_this_browser": "이 브라우저에 저장됨", "home.missing": "찾을 수 없음", + "home.month_01": "1월", + "home.month_02": "2월", + "home.month_03": "3월", + "home.month_04": "4월", + "home.month_05": "5월", + "home.month_06": "6월", + "home.month_07": "7월", + "home.month_08": "8월", + "home.month_09": "9월", + "home.month_10": "10월", + "home.month_11": "11월", + "home.month_12": "12월", + "home.new_inches": "새 설계(인치)", + "home.new_inches_hint": "인치 · 설계 작업 공간에서 열기", + "home.new_mm": "새 설계", + "home.new_mm_hint": "밀리미터 · 설계 작업 공간에서 열기", "home.open": "열기…", - "home.opened_days_ago": "{count}일 전에 열림", - "home.opened_hours_ago": "{count}시간 전에 열림", - "home.opened_just_now": "방금 열림", - "home.opened_minutes_ago": "{count}분 전에 열림", + "home.open_hint": ".solidcraft 설계 ({shortcut})", + "home.open_now": "지금 열기", + "home.opened_days_ago": "{count}일 전", + "home.opened_hours_ago": "{count}시간 전", + "home.opened_just_now": "방금", + "home.opened_minutes_ago": "{count}분 전", "home.opening": "여는 중…", + "home.properties": "설계 속성", "home.recent": "최근 항목", + "home.recent_empty": "열거나 저장한 설계가 여기에 표시됩니다.", + "home.recovery_count": "복구 가능한 설계: {count}개", + "home.recovery_empty": "복구 가능한 설계가 없습니다.", + "home.recovery_hint": "이 설계가 저장되기 전에 SolidCraft가 종료되었습니다.", "home.report_issue": "문제 신고", "home.samples": "샘플", + "home.settings": "설정", + "home.short_date": "{month} {day}일", + "home.shortcuts": "키보드 단축키", + "home.start_hint": "설계를 만들거나, 최근 파일을 열거나, 예제를 살펴보세요.", "home.whats_new": "새로운 기능", + "home.yesterday": "어제", "install.button_tip": "SolidCraft를 앱으로 설치합니다. 별도 창에서 열리며 오프라인에서도 작동합니다", "install.dock_1": "파일 › Dock에 추가를 선택합니다.", "install.dock_2": "추가를 클릭합니다.", diff --git a/assets/locales/ms.json b/assets/locales/ms.json index e1d38cf7a..bb435a891 100644 --- a/assets/locales/ms.json +++ b/assets/locales/ms.json @@ -857,19 +857,57 @@ "help.mit": "Lesen MIT", "help.notice": "NOTIS", "help.third_party": "Lesen pihak ketiga", + "home.back": "Kembali ke {name}", + "home.crashes": "Laporan ranap", + "home.design_workspace": "Reka Bentuk", "home.documentation": "Dokumentasi", + "home.export": "Eksport", + "home.export_hint": "Pilih format untuk reka bentuk semasa.", + "home.export_json_hint": "Reka bentuk boleh sunting dan sejarah perintah", + "home.export_mesh_hint": "Jejaring untuk pencetakan atau perkongsian", + "home.export_step_hint": "Geometri pepejal yang tepat", + "home.import": "Import…", + "home.import_hint": "STEP, IGES atau jejaring ke dalam reka bentuk baharu", "home.in_this_browser": "dalam pelayar ini", "home.missing": "tiada", + "home.month_01": "Jan", + "home.month_02": "Feb", + "home.month_03": "Mac", + "home.month_04": "Apr", + "home.month_05": "Mei", + "home.month_06": "Jun", + "home.month_07": "Jul", + "home.month_08": "Ogo", + "home.month_09": "Sep", + "home.month_10": "Okt", + "home.month_11": "Nov", + "home.month_12": "Dis", + "home.new_inches": "Reka bentuk baharu dalam inci", + "home.new_inches_hint": "Inci · dibuka dalam Reka Bentuk", + "home.new_mm": "Reka bentuk baharu", + "home.new_mm_hint": "Milimeter · dibuka dalam Reka Bentuk", "home.open": "Buka…", - "home.opened_days_ago": "Dibuka {count} hari lalu", - "home.opened_hours_ago": "Dibuka {count} jam lalu", - "home.opened_just_now": "Baru dibuka", - "home.opened_minutes_ago": "Dibuka {count} minit lalu", + "home.open_hint": "Reka bentuk .solidcraft ({shortcut})", + "home.open_now": "Buka sekarang", + "home.opened_days_ago": "{count} hari lalu", + "home.opened_hours_ago": "{count} jam lalu", + "home.opened_just_now": "Baru sahaja", + "home.opened_minutes_ago": "{count} minit lalu", "home.opening": "membuka…", + "home.properties": "Sifat reka bentuk", "home.recent": "Terkini", + "home.recent_empty": "Reka bentuk yang anda buka atau simpan dipaparkan di sini.", + "home.recovery_count": "Reka bentuk boleh dipulihkan: {count}", + "home.recovery_empty": "Tiada reka bentuk yang boleh dipulihkan.", + "home.recovery_hint": "SolidCraft ditutup sebelum reka bentuk ini disimpan.", "home.report_issue": "Laporkan Isu", "home.samples": "Contoh", + "home.settings": "Tetapan", + "home.short_date": "{day} {month}", + "home.shortcuts": "Pintasan papan kekunci", + "home.start_hint": "Cipta reka bentuk, buka fail terkini atau terokai contoh.", "home.whats_new": "Apa yang baharu", + "home.yesterday": "Semalam", "install.button_tip": "Pasang SolidCraft: tetingkap sendiri dan boleh guna di luar talian", "install.dock_1": "Pilih File › Add to Dock.", "install.dock_2": "Klik Add.", diff --git a/assets/locales/nl.json b/assets/locales/nl.json index ab69c00db..5bf0d835c 100644 --- a/assets/locales/nl.json +++ b/assets/locales/nl.json @@ -856,19 +856,57 @@ "help.mit": "MIT-licentie", "help.notice": "NOTICE", "help.third_party": "Licenties van derden", + "home.back": "Terug naar {name}", + "home.crashes": "Crashrapporten", + "home.design_workspace": "Ontwerp", "home.documentation": "Documentatie", + "home.export": "Exporteren", + "home.export_hint": "Kies een indeling voor het huidige ontwerp.", + "home.export_json_hint": "Bewerkbaar ontwerp en opdrachtgeschiedenis", + "home.export_mesh_hint": "Mesh om af te drukken of te delen", + "home.export_step_hint": "Nauwkeurige volumegeometrie", + "home.import": "Importeren…", + "home.import_hint": "STEP, IGES of een mesh in een nieuw ontwerp", "home.in_this_browser": "in deze browser", "home.missing": "ontbreekt", + "home.month_01": "jan.", + "home.month_02": "feb.", + "home.month_03": "mrt.", + "home.month_04": "apr.", + "home.month_05": "mei", + "home.month_06": "jun.", + "home.month_07": "jul.", + "home.month_08": "aug.", + "home.month_09": "sep.", + "home.month_10": "okt.", + "home.month_11": "nov.", + "home.month_12": "dec.", + "home.new_inches": "Nieuw ontwerp in inches", + "home.new_inches_hint": "Inches · opent in Ontwerp", + "home.new_mm": "Nieuw ontwerp", + "home.new_mm_hint": "Millimeters · opent in Ontwerp", "home.open": "Openen…", - "home.opened_days_ago": "{count} dagen geleden geopend", - "home.opened_hours_ago": "{count} u geleden geopend", - "home.opened_just_now": "Zojuist geopend", - "home.opened_minutes_ago": "{count} min geleden geopend", + "home.open_hint": "Een .solidcraft-ontwerp ({shortcut})", + "home.open_now": "Momenteel geopend", + "home.opened_days_ago": "{count} dagen geleden", + "home.opened_hours_ago": "{count} u geleden", + "home.opened_just_now": "Zojuist", + "home.opened_minutes_ago": "{count} min geleden", "home.opening": "openen…", + "home.properties": "Ontwerpeigenschappen", "home.recent": "Recent", + "home.recent_empty": "Ontwerpen die u opent of opslaat, verschijnen hier.", + "home.recovery_count": "Herstelbare ontwerpen: {count}", + "home.recovery_empty": "Geen herstelbare ontwerpen.", + "home.recovery_hint": "SolidCraft is gesloten voordat deze ontwerpen werden opgeslagen.", "home.report_issue": "Probleem melden", "home.samples": "Voorbeelden", + "home.settings": "Instellingen", + "home.short_date": "{day} {month}", + "home.shortcuts": "Sneltoetsen", + "home.start_hint": "Maak een ontwerp, open een recent bestand of bekijk een voorbeeld.", "home.whats_new": "Wat is er nieuw", + "home.yesterday": "Gisteren", "install.button_tip": "Installeer SolidCraft als app: deze opent in een eigen venster en werkt offline", "install.dock_1": "Kies Bestand › Toevoegen aan Dock.", "install.dock_2": "Klik op Voeg toe.", diff --git a/assets/locales/pl.json b/assets/locales/pl.json index d0577f54a..2ecdac077 100644 --- a/assets/locales/pl.json +++ b/assets/locales/pl.json @@ -857,19 +857,57 @@ "help.mit": "Licencja MIT", "help.notice": "NOTICE", "help.third_party": "Licencje stron trzecich", + "home.back": "Wróć do {name}", + "home.crashes": "Raporty awarii", + "home.design_workspace": "Projektowanie", "home.documentation": "Dokumentacja", + "home.export": "Eksportuj", + "home.export_hint": "Wybierz format dla bieżącego projektu.", + "home.export_json_hint": "Edytowalny projekt i historia poleceń", + "home.export_mesh_hint": "Siatka do druku lub udostępniania", + "home.export_step_hint": "Precyzyjna geometria bryłowa", + "home.import": "Importuj…", + "home.import_hint": "STEP, IGES lub siatka do nowego projektu", "home.in_this_browser": "w tej przeglądarce", "home.missing": "brak", + "home.month_01": "sty", + "home.month_02": "lut", + "home.month_03": "mar", + "home.month_04": "kwi", + "home.month_05": "maj", + "home.month_06": "cze", + "home.month_07": "lip", + "home.month_08": "sie", + "home.month_09": "wrz", + "home.month_10": "paź", + "home.month_11": "lis", + "home.month_12": "gru", + "home.new_inches": "Nowy projekt w calach", + "home.new_inches_hint": "Cale · otwiera w obszarze Projektowanie", + "home.new_mm": "Nowy projekt", + "home.new_mm_hint": "Milimetry · otwiera w obszarze Projektowanie", "home.open": "Otwórz…", - "home.opened_days_ago": "Otwarto {count} dni temu", - "home.opened_hours_ago": "Otwarto {count} godz. temu", - "home.opened_just_now": "Otwarto przed chwilą", - "home.opened_minutes_ago": "Otwarto {count} min temu", + "home.open_hint": "Projekt .solidcraft ({shortcut})", + "home.open_now": "Otwórz teraz", + "home.opened_days_ago": "{count} dni temu", + "home.opened_hours_ago": "{count} godz. temu", + "home.opened_just_now": "Przed chwilą", + "home.opened_minutes_ago": "{count} min temu", "home.opening": "otwieranie…", + "home.properties": "Właściwości projektu", "home.recent": "Ostatnie", + "home.recent_empty": "Tutaj pojawią się projekty, które otworzysz lub zapiszesz.", + "home.recovery_count": "Projekty do odzyskania: {count}", + "home.recovery_empty": "Brak projektów do odzyskania.", + "home.recovery_hint": "SolidCraft zamknął się przed zapisaniem tych projektów.", "home.report_issue": "Zgłoś problem", "home.samples": "Przykłady", + "home.settings": "Ustawienia", + "home.short_date": "{day} {month}", + "home.shortcuts": "Skróty klawiszowe", + "home.start_hint": "Utwórz projekt, otwórz ostatni plik lub obejrzyj przykład.", "home.whats_new": "Co nowego", + "home.yesterday": "Wczoraj", "install.button_tip": "Zainstaluj SolidCraft jako aplikację: otwiera się we własnym oknie i działa offline", "install.dock_1": "Wybierz Plik › Dodaj do Docka.", "install.dock_2": "Kliknij Dodaj.", diff --git a/assets/locales/pt-BR.json b/assets/locales/pt-BR.json index 9416e1eca..dcf6daa73 100644 --- a/assets/locales/pt-BR.json +++ b/assets/locales/pt-BR.json @@ -857,19 +857,57 @@ "help.mit": "Licença MIT", "help.notice": "NOTICE", "help.third_party": "Licenças de terceiros", + "home.back": "Voltar para {name}", + "home.crashes": "Relatórios de falhas", + "home.design_workspace": "Projeto", "home.documentation": "Documentação", + "home.export": "Exportar", + "home.export_hint": "Escolha um formato para o projeto atual.", + "home.export_json_hint": "Projeto editável e histórico de comandos", + "home.export_mesh_hint": "Malha para impressão ou compartilhamento", + "home.export_step_hint": "Geometria sólida precisa", + "home.import": "Importar…", + "home.import_hint": "STEP, IGES ou malha em um novo projeto", "home.in_this_browser": "neste navegador", "home.missing": "ausente", + "home.month_01": "jan.", + "home.month_02": "fev.", + "home.month_03": "mar.", + "home.month_04": "abr.", + "home.month_05": "mai.", + "home.month_06": "jun.", + "home.month_07": "jul.", + "home.month_08": "ago.", + "home.month_09": "set.", + "home.month_10": "out.", + "home.month_11": "nov.", + "home.month_12": "dez.", + "home.new_inches": "Novo projeto em polegadas", + "home.new_inches_hint": "Polegadas · abre em Projeto", + "home.new_mm": "Novo projeto", + "home.new_mm_hint": "Milímetros · abre em Projeto", "home.open": "Abrir…", - "home.opened_days_ago": "Aberto há {count} dias", - "home.opened_hours_ago": "Aberto há {count} h", - "home.opened_just_now": "Aberto agora mesmo", - "home.opened_minutes_ago": "Aberto há {count} min", + "home.open_hint": "Um projeto .solidcraft ({shortcut})", + "home.open_now": "Abrir agora", + "home.opened_days_ago": "Há {count} dias", + "home.opened_hours_ago": "Há {count} h", + "home.opened_just_now": "Agora mesmo", + "home.opened_minutes_ago": "Há {count} min", "home.opening": "abrindo…", + "home.properties": "Propriedades do projeto", "home.recent": "Recentes", + "home.recent_empty": "Os projetos que você abrir ou salvar aparecerão aqui.", + "home.recovery_count": "Projetos recuperáveis: {count}", + "home.recovery_empty": "Nenhum projeto recuperável.", + "home.recovery_hint": "O SolidCraft foi fechado antes que estes projetos fossem salvos.", "home.report_issue": "Relatar um problema", "home.samples": "Exemplos", + "home.settings": "Configurações", + "home.short_date": "{day} {month}", + "home.shortcuts": "Atalhos de teclado", + "home.start_hint": "Crie um projeto, abra um arquivo recente ou explore um exemplo.", "home.whats_new": "Novidades", + "home.yesterday": "Ontem", "install.button_tip": "Instale o SolidCraft como aplicativo: ele abre em sua própria janela e funciona offline", "install.dock_1": "Escolha Arquivo › Adicionar ao Dock.", "install.dock_2": "Clique em Adicionar.", diff --git a/assets/locales/ro.json b/assets/locales/ro.json index 05fb3a9cc..fc5d334a4 100644 --- a/assets/locales/ro.json +++ b/assets/locales/ro.json @@ -856,19 +856,57 @@ "help.mit": "Licența MIT", "help.notice": "NOTICE", "help.third_party": "Licențe terțe", + "home.back": "Înapoi la {name}", + "home.crashes": "Rapoarte de blocare", + "home.design_workspace": "Proiectare", "home.documentation": "Documentație", + "home.export": "Exportă", + "home.export_hint": "Alege un format pentru proiectul curent.", + "home.export_json_hint": "Proiect editabil și istoricul comenzilor", + "home.export_mesh_hint": "Plasă pentru imprimare sau partajare", + "home.export_step_hint": "Geometrie solidă precisă", + "home.import": "Importă…", + "home.import_hint": "STEP, IGES sau plasă într-un proiect nou", "home.in_this_browser": "în acest browser", "home.missing": "lipsă", + "home.month_01": "ian.", + "home.month_02": "feb.", + "home.month_03": "mar.", + "home.month_04": "apr.", + "home.month_05": "mai", + "home.month_06": "iun.", + "home.month_07": "iul.", + "home.month_08": "aug.", + "home.month_09": "sept.", + "home.month_10": "oct.", + "home.month_11": "nov.", + "home.month_12": "dec.", + "home.new_inches": "Proiect nou în inci", + "home.new_inches_hint": "Inci · se deschide în Proiectare", + "home.new_mm": "Proiect nou", + "home.new_mm_hint": "Milimetri · se deschide în Proiectare", "home.open": "Deschide…", - "home.opened_days_ago": "Deschis acum {count} zile", - "home.opened_hours_ago": "Deschis acum {count} h", - "home.opened_just_now": "Deschis chiar acum", - "home.opened_minutes_ago": "Deschis acum {count} min", + "home.open_hint": "Un proiect .solidcraft ({shortcut})", + "home.open_now": "Deschis acum", + "home.opened_days_ago": "Acum {count} zile", + "home.opened_hours_ago": "Acum {count} h", + "home.opened_just_now": "Chiar acum", + "home.opened_minutes_ago": "Acum {count} min", "home.opening": "se deschide…", + "home.properties": "Proprietățile proiectului", "home.recent": "Recente", + "home.recent_empty": "Proiectele pe care le deschizi sau le salvezi apar aici.", + "home.recovery_count": "Proiecte recuperabile: {count}", + "home.recovery_empty": "Nu există proiecte recuperabile.", + "home.recovery_hint": "SolidCraft s-a închis înainte ca aceste proiecte să fie salvate.", "home.report_issue": "Raportează o problemă", "home.samples": "Exemple", + "home.settings": "Setări", + "home.short_date": "{day} {month}", + "home.shortcuts": "Scurtături de la tastatură", + "home.start_hint": "Creează un proiect, deschide un fișier recent sau explorează un exemplu.", "home.whats_new": "Noutăți", + "home.yesterday": "Ieri", "install.button_tip": "Instalați SolidCraft ca aplicație: se deschide în propria fereastră și funcționează offline", "install.dock_1": "Alegeți Fișier › Adaugă în Dock.", "install.dock_2": "Faceți clic pe Adaugă.", diff --git a/assets/locales/ru.json b/assets/locales/ru.json index 6ce9b280f..4bcc1221e 100644 --- a/assets/locales/ru.json +++ b/assets/locales/ru.json @@ -856,19 +856,57 @@ "help.mit": "Лицензия MIT", "help.notice": "NOTICE", "help.third_party": "Лицензии сторонних компонентов", + "home.back": "Назад к {name}", + "home.crashes": "Отчёты о сбоях", + "home.design_workspace": "Проектирование", "home.documentation": "Документация", + "home.export": "Экспорт", + "home.export_hint": "Выберите формат для текущего проекта.", + "home.export_json_hint": "Редактируемый проект и история команд", + "home.export_mesh_hint": "Сетка для печати или обмена", + "home.export_step_hint": "Точная твердотельная геометрия", + "home.import": "Импорт…", + "home.import_hint": "STEP, IGES или сетка в новый проект", "home.in_this_browser": "в этом браузере", "home.missing": "отсутствует", + "home.month_01": "янв.", + "home.month_02": "февр.", + "home.month_03": "мар.", + "home.month_04": "апр.", + "home.month_05": "мая", + "home.month_06": "июн.", + "home.month_07": "июл.", + "home.month_08": "авг.", + "home.month_09": "сент.", + "home.month_10": "окт.", + "home.month_11": "нояб.", + "home.month_12": "дек.", + "home.new_inches": "Новый проект в дюймах", + "home.new_inches_hint": "Дюймы · откроется в рабочей области «Проектирование»", + "home.new_mm": "Новый проект", + "home.new_mm_hint": "Миллиметры · откроется в рабочей области «Проектирование»", "home.open": "Открыть…", - "home.opened_days_ago": "Открыт {count} дн. назад", - "home.opened_hours_ago": "Открыт {count} ч назад", - "home.opened_just_now": "Открыт только что", - "home.opened_minutes_ago": "Открыт {count} мин назад", + "home.open_hint": "Проект .solidcraft ({shortcut})", + "home.open_now": "Открыть сейчас", + "home.opened_days_ago": "{count} дн. назад", + "home.opened_hours_ago": "{count} ч назад", + "home.opened_just_now": "Только что", + "home.opened_minutes_ago": "{count} мин назад", "home.opening": "открывается…", + "home.properties": "Свойства проекта", "home.recent": "Недавние", + "home.recent_empty": "Здесь появятся проекты, которые вы откроете или сохраните.", + "home.recovery_count": "Проектов для восстановления: {count}", + "home.recovery_empty": "Нет проектов для восстановления.", + "home.recovery_hint": "SolidCraft закрылся до сохранения этих проектов.", "home.report_issue": "Сообщить о проблеме", "home.samples": "Примеры", + "home.settings": "Настройки", + "home.short_date": "{day} {month}", + "home.shortcuts": "Сочетания клавиш", + "home.start_hint": "Создайте проект, откройте недавний файл или изучите пример.", "home.whats_new": "Что нового", + "home.yesterday": "Вчера", "install.button_tip": "Установить SolidCraft как приложение: отдельное окно и работа без сети", "install.dock_1": "Выберите «Файл» › «Добавить в Dock».", "install.dock_2": "Нажмите «Добавить».", diff --git a/assets/locales/sv.json b/assets/locales/sv.json index 2cc4f221c..3862e553c 100644 --- a/assets/locales/sv.json +++ b/assets/locales/sv.json @@ -856,19 +856,57 @@ "help.mit": "MIT-licens", "help.notice": "NOTICE", "help.third_party": "Licenser från tredje part", + "home.back": "Tillbaka till {name}", + "home.crashes": "Kraschrapporter", + "home.design_workspace": "Konstruktion", "home.documentation": "Dokumentation", + "home.export": "Exportera", + "home.export_hint": "Välj ett format för den aktuella konstruktionen.", + "home.export_json_hint": "Redigerbar konstruktion och kommandohistorik", + "home.export_mesh_hint": "Mesh för utskrift eller delning", + "home.export_step_hint": "Exakt solidgeometri", + "home.import": "Importera…", + "home.import_hint": "STEP, IGES eller mesh till en ny konstruktion", "home.in_this_browser": "i den här webbläsaren", "home.missing": "saknas", + "home.month_01": "jan.", + "home.month_02": "feb.", + "home.month_03": "mars", + "home.month_04": "apr.", + "home.month_05": "maj", + "home.month_06": "juni", + "home.month_07": "juli", + "home.month_08": "aug.", + "home.month_09": "sep.", + "home.month_10": "okt.", + "home.month_11": "nov.", + "home.month_12": "dec.", + "home.new_inches": "Ny konstruktion i tum", + "home.new_inches_hint": "Tum · öppnas i Konstruktion", + "home.new_mm": "Ny konstruktion", + "home.new_mm_hint": "Millimeter · öppnas i Konstruktion", "home.open": "Öppna…", - "home.opened_days_ago": "Öppnades för {count} dagar sedan", - "home.opened_hours_ago": "Öppnades för {count} h sedan", - "home.opened_just_now": "Öppnades nyss", - "home.opened_minutes_ago": "Öppnades för {count} min sedan", + "home.open_hint": "En .solidcraft-konstruktion ({shortcut})", + "home.open_now": "Öppen nu", + "home.opened_days_ago": "För {count} dagar sedan", + "home.opened_hours_ago": "För {count} h sedan", + "home.opened_just_now": "Nyss", + "home.opened_minutes_ago": "För {count} min sedan", "home.opening": "öppnar…", + "home.properties": "Konstruktionsegenskaper", "home.recent": "Senaste", + "home.recent_empty": "Konstruktioner som du öppnar eller sparar visas här.", + "home.recovery_count": "Återställningsbara konstruktioner: {count}", + "home.recovery_empty": "Inga återställningsbara konstruktioner.", + "home.recovery_hint": "SolidCraft stängdes innan dessa konstruktioner sparades.", "home.report_issue": "Rapportera ett problem", "home.samples": "Exempel", + "home.settings": "Inställningar", + "home.short_date": "{day} {month}", + "home.shortcuts": "Kortkommandon", + "home.start_hint": "Skapa en konstruktion, öppna en nyligen använd fil eller utforska ett exempel.", "home.whats_new": "Nyheter", + "home.yesterday": "I går", "install.button_tip": "Installera SolidCraft som en app: den öppnas i ett eget fönster och fungerar offline", "install.dock_1": "Välj Arkiv › Lägg till i Dock.", "install.dock_2": "Klicka på Lägg till.", diff --git a/assets/locales/tr.json b/assets/locales/tr.json index da0faf0e3..77535d88b 100644 --- a/assets/locales/tr.json +++ b/assets/locales/tr.json @@ -856,19 +856,57 @@ "help.mit": "MIT lisansı", "help.notice": "NOTICE", "help.third_party": "Üçüncü taraf lisansları", + "home.back": "{name} tasarımına dön", + "home.crashes": "Çökme raporları", + "home.design_workspace": "Tasarım", "home.documentation": "Belgeler", + "home.export": "Dışa aktar", + "home.export_hint": "Geçerli tasarım için bir biçim seçin.", + "home.export_json_hint": "Düzenlenebilir tasarım ve komut geçmişi", + "home.export_mesh_hint": "Yazdırma veya paylaşma için ağ", + "home.export_step_hint": "Hassas katı geometrisi", + "home.import": "İçe aktar…", + "home.import_hint": "STEP, IGES veya ağı yeni bir tasarıma aktar", "home.in_this_browser": "bu tarayıcıda", "home.missing": "eksik", + "home.month_01": "Oca", + "home.month_02": "Şub", + "home.month_03": "Mar", + "home.month_04": "Nis", + "home.month_05": "May", + "home.month_06": "Haz", + "home.month_07": "Tem", + "home.month_08": "Ağu", + "home.month_09": "Eyl", + "home.month_10": "Eki", + "home.month_11": "Kas", + "home.month_12": "Ara", + "home.new_inches": "Yeni tasarım, inç", + "home.new_inches_hint": "İnç · Tasarım alanında açılır", + "home.new_mm": "Yeni tasarım", + "home.new_mm_hint": "Milimetre · Tasarım alanında açılır", "home.open": "Aç…", - "home.opened_days_ago": "{count} gün önce açıldı", - "home.opened_hours_ago": "{count} sa. önce açıldı", - "home.opened_just_now": "Az önce açıldı", - "home.opened_minutes_ago": "{count} dk. önce açıldı", + "home.open_hint": "Bir .solidcraft tasarımı ({shortcut})", + "home.open_now": "Şimdi aç", + "home.opened_days_ago": "{count} gün önce", + "home.opened_hours_ago": "{count} sa. önce", + "home.opened_just_now": "Az önce", + "home.opened_minutes_ago": "{count} dk. önce", "home.opening": "açılıyor…", + "home.properties": "Tasarım özellikleri", "home.recent": "Son kullanılanlar", + "home.recent_empty": "Açtığınız veya kaydettiğiniz tasarımlar burada görünür.", + "home.recovery_count": "Kurtarılabilir tasarımlar: {count}", + "home.recovery_empty": "Kurtarılabilir tasarım yok.", + "home.recovery_hint": "Bu tasarımlar kaydedilmeden SolidCraft kapandı.", "home.report_issue": "Sorun bildir", "home.samples": "Örnekler", + "home.settings": "Ayarlar", + "home.short_date": "{day} {month}", + "home.shortcuts": "Klavye kısayolları", + "home.start_hint": "Bir tasarım oluşturun, son kullanılan bir dosyayı açın veya bir örneği inceleyin.", "home.whats_new": "Yenilikler", + "home.yesterday": "Dün", "install.button_tip": "SolidCraft'ı uygulama olarak yükleyin: kendi penceresinde açılır ve çevrimdışı da çalışır", "install.dock_1": "Dosya › Dock'a Ekle'yi seçin.", "install.dock_2": "“Ekle” düğmesine tıklayın.", diff --git a/assets/locales/uk.json b/assets/locales/uk.json index c65514fe2..fcca06e27 100644 --- a/assets/locales/uk.json +++ b/assets/locales/uk.json @@ -857,19 +857,57 @@ "help.mit": "Ліцензія MIT", "help.notice": "NOTICE", "help.third_party": "Ліцензії сторонніх компонентів", + "home.back": "Назад до {name}", + "home.crashes": "Звіти про збої", + "home.design_workspace": "Проєктування", "home.documentation": "Документація", + "home.export": "Експортувати", + "home.export_hint": "Виберіть формат для поточного проєкту.", + "home.export_json_hint": "Редагований проєкт та історія команд", + "home.export_mesh_hint": "Сітка для друку або поширення", + "home.export_step_hint": "Точна твердотільна геометрія", + "home.import": "Імпортувати…", + "home.import_hint": "STEP, IGES або сітку в новий проєкт", "home.in_this_browser": "у цьому браузері", "home.missing": "відсутній", + "home.month_01": "січ.", + "home.month_02": "лют.", + "home.month_03": "бер.", + "home.month_04": "квіт.", + "home.month_05": "трав.", + "home.month_06": "черв.", + "home.month_07": "лип.", + "home.month_08": "серп.", + "home.month_09": "вер.", + "home.month_10": "жовт.", + "home.month_11": "лист.", + "home.month_12": "груд.", + "home.new_inches": "Новий проєкт у дюймах", + "home.new_inches_hint": "Дюйми · відкриється в робочому просторі «Проєктування»", + "home.new_mm": "Новий проєкт", + "home.new_mm_hint": "Міліметри · відкриється в робочому просторі «Проєктування»", "home.open": "Відкрити…", - "home.opened_days_ago": "Відкрито {count} дн. тому", - "home.opened_hours_ago": "Відкрито {count} год тому", - "home.opened_just_now": "Щойно відкрито", - "home.opened_minutes_ago": "Відкрито {count} хв тому", + "home.open_hint": "Проєкт .solidcraft ({shortcut})", + "home.open_now": "Відкрити зараз", + "home.opened_days_ago": "{count} дн. тому", + "home.opened_hours_ago": "{count} год тому", + "home.opened_just_now": "Щойно", + "home.opened_minutes_ago": "{count} хв тому", "home.opening": "відкриття…", + "home.properties": "Властивості проєкту", "home.recent": "Недавні", + "home.recent_empty": "Тут з’являться проєкти, які ви відкриєте або збережете.", + "home.recovery_count": "Проєктів для відновлення: {count}", + "home.recovery_empty": "Немає проєктів для відновлення.", + "home.recovery_hint": "SolidCraft закрився до збереження цих проєктів.", "home.report_issue": "Повідомити про проблему", "home.samples": "Зразки", + "home.settings": "Налаштування", + "home.short_date": "{day} {month}", + "home.shortcuts": "Сполучення клавіш", + "home.start_hint": "Створіть проєкт, відкрийте нещодавній файл або перегляньте приклад.", "home.whats_new": "Що нового", + "home.yesterday": "Учора", "install.button_tip": "Встановити SolidCraft як застосунок: він відкривається в окремому вікні й працює без мережі", "install.dock_1": "Виберіть «Файл» › «Додати в Dock».", "install.dock_2": "Натисніть «Додати».", diff --git a/assets/locales/vi.json b/assets/locales/vi.json index 892776813..bed170788 100644 --- a/assets/locales/vi.json +++ b/assets/locales/vi.json @@ -857,19 +857,57 @@ "help.mit": "Giấy phép MIT", "help.notice": "NOTICE", "help.third_party": "Giấy phép của bên thứ ba", + "home.back": "Quay lại {name}", + "home.crashes": "Báo cáo sự cố", + "home.design_workspace": "Thiết kế", "home.documentation": "Tài liệu hướng dẫn", + "home.export": "Xuất", + "home.export_hint": "Chọn định dạng cho thiết kế hiện tại.", + "home.export_json_hint": "Thiết kế có thể chỉnh sửa và lịch sử lệnh", + "home.export_mesh_hint": "Lưới để in hoặc chia sẻ", + "home.export_step_hint": "Hình học khối chính xác", + "home.import": "Nhập…", + "home.import_hint": "Nhập STEP, IGES hoặc lưới vào thiết kế mới", "home.in_this_browser": "trong trình duyệt này", "home.missing": "thiếu", + "home.month_01": "thg 1", + "home.month_02": "thg 2", + "home.month_03": "thg 3", + "home.month_04": "thg 4", + "home.month_05": "thg 5", + "home.month_06": "thg 6", + "home.month_07": "thg 7", + "home.month_08": "thg 8", + "home.month_09": "thg 9", + "home.month_10": "thg 10", + "home.month_11": "thg 11", + "home.month_12": "thg 12", + "home.new_inches": "Thiết kế mới theo inch", + "home.new_inches_hint": "Inch · mở trong Thiết kế", + "home.new_mm": "Thiết kế mới", + "home.new_mm_hint": "Milimét · mở trong Thiết kế", "home.open": "Mở…", - "home.opened_days_ago": "Đã mở {count} ngày trước", - "home.opened_hours_ago": "Đã mở {count} giờ trước", - "home.opened_just_now": "Vừa mới mở", - "home.opened_minutes_ago": "Đã mở {count} phút trước", + "home.open_hint": "Một thiết kế .solidcraft ({shortcut})", + "home.open_now": "Mở ngay", + "home.opened_days_ago": "{count} ngày trước", + "home.opened_hours_ago": "{count} giờ trước", + "home.opened_just_now": "Vừa xong", + "home.opened_minutes_ago": "{count} phút trước", "home.opening": "đang mở…", + "home.properties": "Thuộc tính thiết kế", "home.recent": "Gần đây", + "home.recent_empty": "Các thiết kế bạn mở hoặc lưu sẽ xuất hiện ở đây.", + "home.recovery_count": "Thiết kế có thể khôi phục: {count}", + "home.recovery_empty": "Không có thiết kế nào có thể khôi phục.", + "home.recovery_hint": "SolidCraft đã đóng trước khi các thiết kế này được lưu.", "home.report_issue": "Báo cáo sự cố", "home.samples": "Mẫu thiết kế", + "home.settings": "Cài đặt", + "home.short_date": "{day} {month}", + "home.shortcuts": "Phím tắt", + "home.start_hint": "Tạo thiết kế, mở tệp gần đây hoặc khám phá mẫu.", "home.whats_new": "Có gì mới", + "home.yesterday": "Hôm qua", "install.button_tip": "Cài đặt SolidCraft dưới dạng ứng dụng: mở trong cửa sổ riêng và hoạt động ngoại tuyến", "install.dock_1": "Chọn Tệp › Thêm vào Dock.", "install.dock_2": "Nhấp vào Thêm.", diff --git a/assets/locales/zh-TW.json b/assets/locales/zh-TW.json index 8f253abcb..4f03674cb 100644 --- a/assets/locales/zh-TW.json +++ b/assets/locales/zh-TW.json @@ -856,19 +856,57 @@ "help.mit": "MIT 授權", "help.notice": "NOTICE", "help.third_party": "第三方授權", + "home.back": "返回 {name}", + "home.crashes": "當機報告", + "home.design_workspace": "設計", "home.documentation": "文件", + "home.export": "匯出", + "home.export_hint": "選擇目前設計的格式。", + "home.export_json_hint": "可編輯的設計與命令歷程", + "home.export_mesh_hint": "用於列印或分享的網格", + "home.export_step_hint": "精確的實體幾何", + "home.import": "匯入…", + "home.import_hint": "將 STEP、IGES 或網格匯入新設計", "home.in_this_browser": "在此瀏覽器中", "home.missing": "找不到檔案", + "home.month_01": "1月", + "home.month_02": "2月", + "home.month_03": "3月", + "home.month_04": "4月", + "home.month_05": "5月", + "home.month_06": "6月", + "home.month_07": "7月", + "home.month_08": "8月", + "home.month_09": "9月", + "home.month_10": "10月", + "home.month_11": "11月", + "home.month_12": "12月", + "home.new_inches": "新增設計(英吋)", + "home.new_inches_hint": "英吋 · 在設計工作區中開啟", + "home.new_mm": "新增設計", + "home.new_mm_hint": "公釐 · 在設計工作區中開啟", "home.open": "開啟…", - "home.opened_days_ago": "{count} 天前開啟", - "home.opened_hours_ago": "{count} 小時前開啟", - "home.opened_just_now": "剛剛開啟", - "home.opened_minutes_ago": "{count} 分鐘前開啟", + "home.open_hint": ".solidcraft 設計檔案 ({shortcut})", + "home.open_now": "目前開啟中", + "home.opened_days_ago": "{count} 天前", + "home.opened_hours_ago": "{count} 小時前", + "home.opened_just_now": "剛剛", + "home.opened_minutes_ago": "{count} 分鐘前", "home.opening": "正在開啟…", + "home.properties": "設計屬性", "home.recent": "最近使用", + "home.recent_empty": "您開啟或儲存的設計會顯示於此。", + "home.recovery_count": "可復原的設計:{count} 個", + "home.recovery_empty": "沒有可復原的設計。", + "home.recovery_hint": "SolidCraft 在這些設計儲存前已關閉。", "home.report_issue": "回報問題", "home.samples": "範例", + "home.settings": "設定", + "home.short_date": "{month}{day}日", + "home.shortcuts": "鍵盤快速鍵", + "home.start_hint": "建立設計、開啟最近使用的檔案,或瀏覽範例。", "home.whats_new": "新功能", + "home.yesterday": "昨天", "install.button_tip": "將 SolidCraft 安裝為應用程式:在獨立視窗中開啟,離線也能使用", "install.dock_1": "選擇「檔案」›「加入 Dock」。", "install.dock_2": "按一下「加入」。", diff --git a/assets/locales/zh.json b/assets/locales/zh.json index 08c5b5c72..d93043135 100644 --- a/assets/locales/zh.json +++ b/assets/locales/zh.json @@ -889,19 +889,57 @@ "help.solid.revolve": "将草图轮廓绕一条轴旋转,生成圆形的实体。用于轴、旋钮、碗等围绕中心线呈圆形的零件。", "help.solid.shell": "将实体掏空,留下指定厚度的壁,还可以打开所选的面。用于盒子、盖子等薄壁零件。", "help.third_party": "第三方许可证", + "home.back": "返回 {name}", + "home.crashes": "崩溃报告", + "home.design_workspace": "设计", "home.documentation": "文档", + "home.export": "导出", + "home.export_hint": "为当前设计选择一种格式。", + "home.export_json_hint": "可编辑的设计和命令历史记录", + "home.export_mesh_hint": "用于打印或共享的网格", + "home.export_step_hint": "精确的实体几何", + "home.import": "导入…", + "home.import_hint": "将 STEP、IGES 或网格导入新设计", "home.in_this_browser": "在此浏览器中", "home.missing": "文件不存在", + "home.month_01": "1月", + "home.month_02": "2月", + "home.month_03": "3月", + "home.month_04": "4月", + "home.month_05": "5月", + "home.month_06": "6月", + "home.month_07": "7月", + "home.month_08": "8月", + "home.month_09": "9月", + "home.month_10": "10月", + "home.month_11": "11月", + "home.month_12": "12月", + "home.new_inches": "新建设计(英寸)", + "home.new_inches_hint": "英寸 · 在设计工作区中打开", + "home.new_mm": "新建设计", + "home.new_mm_hint": "毫米 · 在设计工作区中打开", "home.open": "打开…", - "home.opened_days_ago": "{count} 天前打开", - "home.opened_hours_ago": "{count} 小时前打开", - "home.opened_just_now": "刚刚打开", - "home.opened_minutes_ago": "{count} 分钟前打开", + "home.open_hint": ".solidcraft 设计文件 ({shortcut})", + "home.open_now": "立即打开", + "home.opened_days_ago": "{count} 天前", + "home.opened_hours_ago": "{count} 小时前", + "home.opened_just_now": "刚刚", + "home.opened_minutes_ago": "{count} 分钟前", "home.opening": "正在打开…", + "home.properties": "设计属性", "home.recent": "最近使用", + "home.recent_empty": "您打开或保存的设计将显示在这里。", + "home.recovery_count": "可恢复的设计: {count} 个", + "home.recovery_empty": "没有可恢复的设计。", + "home.recovery_hint": "SolidCraft 在这些设计保存前已关闭。", "home.report_issue": "报告问题", "home.samples": "示例", + "home.settings": "设置", + "home.short_date": "{month}{day}日", + "home.shortcuts": "键盘快捷键", + "home.start_hint": "创建设计、打开最近的文件或浏览示例。", "home.whats_new": "新功能", + "home.yesterday": "昨天", "install.button_tip": "将 SolidCraft 安装为应用:在独立窗口中打开,离线也能使用", "install.dock_1": "选择“文件”›“添加到程序坞”。", "install.dock_2": "点按“添加”。", diff --git a/assets/styles/ui/palettes.rs b/assets/styles/ui/palettes.rs index 939e7cd7b..33f4e3d80 100644 --- a/assets/styles/ui/palettes.rs +++ b/assets/styles/ui/palettes.rs @@ -8,6 +8,35 @@ const fn icon_primary(rgb: [u8; 3]) -> Color32 { impl Tokens { pub const fn light() -> Tokens { Tokens { + file_dim: Color32::from_rgb(58, 70, 86), + file_recovery_well: Color32::from_rgb(247, 226, 184), + file_action_height: 32.0, + file_back_height: 40.0, + file_recovery_icon: 32.0, + file_grid_gap: 14.0, + file_background: Color32::from_rgb(247, 249, 251), + file_surface: Color32::WHITE, + file_border: Color32::from_rgb(224, 229, 236), + file_image_tint: Color32::WHITE, + file_rail: Color32::from_rgb(35, 110, 173), + file_rail_ink: Color32::WHITE, + file_rail_hover: Color32::from_rgb(43, 118, 180), + file_primary: Color32::from_rgb(227, 240, 251), + file_primary_ink: Color32::from_rgb(26, 80, 127), + file_primary_border: Color32::from_rgb(50, 139, 211), + file_recovery: Color32::from_rgb(255, 246, 229), + file_recovery_ink: Color32::from_rgb(122, 74, 5), + file_recovery_border: Color32::from_rgb(240, 210, 154), + file_nav_width: 248.0, + file_nav_height: 38.0, + file_tile_height: 84.0, + file_tile_icon: 44.0, + file_recent_height: 52.0, + file_sample_image_height: 84.0, + file_content_inset_x: 40.0, + file_content_inset_y: 32.0, + file_section_gap: 28.0, + font_start_title: 28.0, space_2: 2.0, space_3: 3.0, space_4: 4.0, @@ -236,6 +265,19 @@ impl Tokens { t.sketch_mode_tint = 0.12; t.sketch_footer_icon_size = 15.0; t.font_section_tracking = 0.04; + t.file_dim = Color32::from_rgb(180, 187, 200); + t.file_recovery_well = Color32::from_rgb(92, 68, 32); + t.file_background = Color32::from_rgb(31, 35, 43); + t.file_surface = Color32::from_rgb(39, 43, 52); + t.file_border = Color32::from_rgb(63, 69, 82); + t.file_rail = Color32::from_rgb(30, 80, 128); + t.file_rail_hover = Color32::from_rgb(46, 99, 149); + t.file_primary = Color32::from_rgb(27, 48, 72); + t.file_primary_ink = Color32::from_rgb(156, 199, 245); + t.file_primary_border = Color32::from_rgb(58, 136, 238); + t.file_recovery = Color32::from_rgb(67, 51, 28); + t.file_recovery_ink = Color32::from_rgb(245, 204, 137); + t.file_recovery_border = Color32::from_rgb(115, 88, 43); t.app_bar = Color32::from_rgb(28, 31, 38); t.toolbar = Color32::from_rgb(39, 43, 52); t.panel = Color32::from_rgb(39, 43, 52); diff --git a/crates/ui-egui/src/colour_tokens_tests.rs b/crates/ui-egui/src/colour_tokens_tests.rs index 700cd7371..a8a297c3b 100644 --- a/crates/ui-egui/src/colour_tokens_tests.rs +++ b/crates/ui-egui/src/colour_tokens_tests.rs @@ -75,7 +75,6 @@ const ALLOWED_LITERALS: &[(&str, usize, &str)] = &[ ("dialogs_motion.rs", 1, "a white outline"), ("gizmo.rs", 2, "the gizmo's neutral grey ball"), ("icons.rs", 1, "the white tint that carries an icon image's opacity"), - ("home.rs", 2, "thumbnail tints"), ("ref_images.rs", 1, "a reference image's opacity tint"), ("theme_files.rs", 1, "a colour read from a theme file, which sets tokens"), ("titlebar.rs", 2, "the window close button's red hover (the system's convention) and white ink"), diff --git a/crates/ui-egui/src/colour_vision_tests.rs b/crates/ui-egui/src/colour_vision_tests.rs index e2b1e3b9a..821a4081f 100644 --- a/crates/ui-egui/src/colour_vision_tests.rs +++ b/crates/ui-egui/src/colour_vision_tests.rs @@ -379,6 +379,35 @@ const SHADED: [&str; 2] = ["analysis.draft", "analysis.access"]; /// Tokens no colour vision mode needs to keep apart, and why. A new token fails /// `every_token_is_measured_or_carries_no_meaning` until it is in a group above or here. const NO_MEANING: &[(&str, &str)] = &[ + ("file_dim", "File view secondary text, WCAG guarded in theme tests"), + ("file_recovery_well", "decorative recovery icon ground"), + ("file_action_height", "layout dimension"), + ("file_back_height", "layout dimension"), + ("file_recovery_icon", "layout dimension"), + ("file_grid_gap", "layout dimension"), + ("file_nav_width", "layout dimension"), + ("file_nav_height", "layout dimension"), + ("file_tile_height", "layout dimension"), + ("file_tile_icon", "layout dimension"), + ("file_recent_height", "layout dimension"), + ("file_sample_image_height", "layout dimension"), + ("file_content_inset_x", "layout dimension"), + ("file_content_inset_y", "layout dimension"), + ("file_section_gap", "layout dimension"), + ("font_start_title", "layout dimension"), + ("file_background", "File view chrome; paired text contrast is guarded in theme tests"), + ("file_surface", "File view chrome; paired text contrast is guarded in theme tests"), + ("file_image_tint", "neutral image multiplication; model pixels retain their original colours"), + ("file_border", "File view chrome; paired text contrast is guarded in theme tests"), + ("file_rail", "File view chrome; paired text contrast is guarded in theme tests"), + ("file_rail_ink", "File view chrome; paired text contrast is guarded in theme tests"), + ("file_rail_hover", "File view chrome; paired text contrast is guarded in theme tests"), + ("file_primary", "File view chrome; paired text contrast is guarded in theme tests"), + ("file_primary_ink", "File view chrome; paired text contrast is guarded in theme tests"), + ("file_primary_border", "File view chrome; paired text contrast is guarded in theme tests"), + ("file_recovery", "File view chrome; paired text contrast is guarded in theme tests"), + ("file_recovery_ink", "File view chrome; paired text contrast is guarded in theme tests"), + ("file_recovery_border", "File view chrome; paired text contrast is guarded in theme tests"), ("space_2", "layout dimension"), ("space_3", "layout dimension"), ("space_4", "layout dimension"), diff --git a/crates/ui-egui/src/documents.rs b/crates/ui-egui/src/documents.rs index 31b004942..da23a8f92 100644 --- a/crates/ui-egui/src/documents.rs +++ b/crates/ui-egui/src/documents.rs @@ -225,8 +225,8 @@ pub fn new_design(app: &mut SolveApp) { } } -/// The tab strip's +: always a new tab, except over the blank design the start page covers -/// (a launch), which New takes as [`new_design`] does. +/// Create a new tab directly; the File view chooses units before using [`new_design`]. +/// An untouched blank launch design is reused. pub fn new_tab(app: &mut SolveApp) { if app.file_picker_busy() { return; @@ -590,7 +590,7 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) { d.remove::<(usize, egui::Pos2)>(menu_id); } }); - // New design: a new tab showing the start page. + // Choose a new design, open or sample from the File view before creating a tab. let pr = Rect::from_center_size(pos2(x + 14.0, r.center().y), vec2(22.0, 22.0)); let presp = ui.interact(pr, ui.id().with("doc_new"), Sense::click()); if presp.hovered() { @@ -604,8 +604,9 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) { ); // A file loading into the window keeps the tabs as they are (dragging still moves it). let idle = !app.file_load.busy(); - if presp.on_hover_text("New Design (Ctrl+N)").clicked() && idle { - new_tab(app); + crate::scenario::publish_handle("tab:new", pr.center()); + if presp.on_hover_text(app.tr("ui.start_page")).clicked() && idle { + app.home.show(app.session.revision); } match (shut, pick) { _ if !idle => {} @@ -917,10 +918,9 @@ mod tests { assert!(active_is_blank(&a) && a.home.open); } - /// The tab strip's + opens a tab every time, an empty design's included; over the start - /// page's blank design (a launch) it uses that design. + /// Direct tab creation remains available, including reuse of an untouched launch design. #[test] - fn plus_opens_a_tab_every_time() { + fn direct_new_tab_reuses_the_launch_design_then_opens_a_tab_every_time() { let mut a = app(); a.home.open = true; new_tab(&mut a); diff --git a/crates/ui-egui/src/font_literals_tests.rs b/crates/ui-egui/src/font_literals_tests.rs index ca6b3ea09..ce3514632 100644 --- a/crates/ui-egui/src/font_literals_tests.rs +++ b/crates/ui-egui/src/font_literals_tests.rs @@ -8,7 +8,6 @@ use syn::{Expr, Item, Lit}; /// These `.size()` calls size spinner geometry, not text. No text sizes are exempt. const ALLOWED_LITERALS: &[(&str, usize, &str)] = &[ ("dialogs.rs", 2, "preview spinners: graphic diameter, not typography"), - ("home.rs", 1, "thumbnail loading spinner: graphic diameter, not typography"), ("viewport.rs", 1, "viewport status spinner: graphic diameter, not typography"), ]; diff --git a/crates/ui-egui/src/home.rs b/crates/ui-egui/src/home.rs index 16b33b246..11077ce96 100644 --- a/crates/ui-egui/src/home.rs +++ b/crates/ui-egui/src/home.rs @@ -2,16 +2,15 @@ //! picture of the design rendered from it. Shown on launch without a file and from the house //! button or the first document tab; selecting a design returns to its view. -use crate::fonts::RichTextExt as _; -use crate::ui_kit::{Container, Surface}; use std::collections::HashMap; -use egui::{Color32, CornerRadius, RichText, Sense, Stroke, vec2}; +use egui::vec2; use solidcraft_engine::Session; use solidcraft_engine::render::{Camera, StandardView}; use crate::SolveApp; use crate::theme::Tokens; +use crate::ui_kit::{self, FileView, RecoveryMessage}; /// Recent designs kept. pub const MAX_RECENT: usize = 12; @@ -31,6 +30,7 @@ type Made = (String, Option, Option); #[derive(Default)] pub struct HomeState { + section: Section, pub open: bool, /// Recent design paths, newest first (kept in the preferences). pub recent: Vec, @@ -81,6 +81,7 @@ impl HomeState { pub fn show(&mut self, _rev: u64) { self.open = true; + self.section = Section::Start; // Returning from another document cancels an earlier, unfinished sample selection. self.wanted = None; } @@ -502,13 +503,82 @@ fn ask_present(h: &mut HomeState, ctx: &egui::Context, recent: &[String]) { } } -/// The page itself (in place of the toolbar, browser and viewport). +#[derive(Clone, Copy, Default, PartialEq)] +enum Section { + #[default] + Start, + Recovery, + Export, +} + +enum FileAction { + Back, + Section(Section), + New(&'static str), + Open, + Import, + Save, + SaveAs, + Export(&'static str), + Mesh, + ViewDxf, + Properties, + Settings, + Shortcuts, + Crashes, + About, + Recovery(solidcraft_engine::recovery::Entry, bool), +} + +/// File view replaces the workspace while keeping the open design and its history intact. pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) { poll(app, ui.ctx()); + let file_menu_open = ui.ctx().data(|data| data.get_temp::(egui::Id::new("sc_file_menu"))).unwrap_or(false); + let interactive = !app.file_picker_busy() && !app.file_load.busy() && !file_menu_open; + // Help windows draw before Home; remember their prior visibility so one Escape closes only the window. + let had_help_window = ui.ctx().memory(|memory| { + ["sc_about", "sc_crash_reports"] + .iter() + .any(|id| memory.areas().visible_last_frame(&egui::LayerId::new(egui::Order::Middle, egui::Id::new(id)))) + }); + + if interactive + && !had_help_window + && !app.prefs_window.open + && !app.help.about + && !app.crashes.open + && !app.help.menu + && !egui::Popup::is_any_open(ui.ctx()) + && app.issue_report.draft.is_none() + && ui.input_mut(|input| input.consume_key(egui::Modifiers::NONE, egui::Key::Escape)) + { + app.home.open = false; + return; + } + if interactive + && !had_help_window + && !app.prefs_window.open + && !app.help.about + && !app.crashes.open + && !egui::Popup::is_any_open(ui.ctx()) + && app.issue_report.draft.is_none() + && !crate::documents::active_is_blank(app) + { + let save_as = egui::Modifiers { command: true, shift: true, ..Default::default() }; + let action = if ui.input_mut(|input| input.consume_key(save_as, egui::Key::S)) { + Some(FileAction::SaveAs) + } else if ui.input_mut(|input| input.consume_key(egui::Modifiers::COMMAND, egui::Key::S)) { + Some(FileAction::Save) + } else { + None + }; + if let Some(action) = action { + dispatch(app, ui.ctx(), action); + return; + } + } let t = Tokens::get(); let samples = solidcraft_engine::sample::samples(); - // Embedded previews are available on the first frame, including on the web. No model - // scripts, filesystem reads or GPU readbacks are needed to show the sample cards. for i in 0..samples.len() { let key = format!("sample:{i}"); if !app.home.thumbs.contains_key(&key) { @@ -525,242 +595,441 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) { } let recent = app.home.recent.clone(); ask_present(&mut app.home, ui.ctx(), &recent); - for p in &recent { - if app.home.present.get(p).copied().unwrap_or(true) { - want(&mut app.home, p); + for path in &recent { + if app.home.present.get(path).copied().unwrap_or(true) { + want(&mut app.home, path); } } - let mut action: Option> = None; - let page = Container::new(ui.ctx(), Surface::Viewport).central(); - page.frame(Container::new(ui.ctx(), Surface::Viewport).edge_frame(t.panel).inner_margin(egui::Margin::symmetric(36, 24))).show(ui, |ui| { - egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| { - ui.horizontal(|ui| { - ui.label(RichText::new("SolidCraft").size(crate::theme::Tokens::get().font_display).semibold().color(t.text)); - ui.add_space(t.space_12); - ui.label(RichText::new(crate::i18n::tr_label("Start")).size(crate::theme::Tokens::get().font_intro).color(t.text_dim)); - }); - ui.add_space(t.space_16); - ui.horizontal(|ui| { - let big = |ui: &mut egui::Ui, icon: &str, label: &str, primary: bool| -> bool { - // The label sets the width: a translation longer than the English one widens - // the button instead of running past its edge. - let ink_text = if primary { t.on_accent } else { t.text }; - let galley = ui.painter().layout_no_wrap( - label.to_owned(), - egui::FontId::proportional(crate::theme::Tokens::get().font_subtitle), - ink_text, - ); - let width = (56.0 + galley.size().x + 20.0).max(170.0); - let (r, resp) = ui.allocate_exact_size(vec2(width, 64.0), Sense::click()); - let fill = if primary { - t.accent - } else if resp.hovered() { - t.hover - } else { - t.field - }; - ui.painter().rect(r, t.radius_md, fill, Stroke::new(1.0, if primary { t.accent } else { t.border }), egui::StrokeKind::Inside); - let ink = if primary { t.on_accent } else { t.icon }; - crate::icons::paint_icon( - ui.painter(), - egui::Rect::from_center_size(r.left_center() + vec2(30.0, 0.0), vec2(30.0, 30.0)), - icon, - f32::from(ink.a()) / 255.0, - ); - ui.painter().galley(r.left_center() + vec2(56.0, -galley.size().y / 2.0), galley, ink_text); - resp.clicked() - }; - if big(ui, "new", app.tr("ui.new_design"), true) { - action = Some(Box::new(|app: &mut SolveApp| crate::documents::new_design(app))); - } - ui.add_space(t.space_10); - if big(ui, "open", app.tr("home.open"), false) { - action = Some(Box::new(|app: &mut SolveApp| { - app.pick_open(|app, path| { - if let Some(path) = path { - app.home.open = false; - app.open_path_async(&path); + let mut action = None; + FileView::page(ui, |ui| { + ui.add_enabled_ui(interactive, |ui| { + let full = ui.available_rect_before_wrap(); + crate::scenario::publish_rect("home:page", full); + let narrow = full.width() < t.file_nav_width + FileView::tile_min_width() + t.file_content_inset_x * 2.0; + if narrow { + FileView::navigation(ui, |ui| { + ui_kit::dropdown_menu(ui, "home_navigation", app.tr("ui.start_page"), |ui| { + ui.set_min_width(t.file_nav_width); + FileView::navigation(ui, |ui| { + navigation(app, ui, &mut action); + if action.is_some() { + ui.close(); } }); - })); - } - }); - ui.add_space(t.space_24); - ui.horizontal_wrapped(|ui| { - ui.hyperlink_to(app.tr("home.documentation"), crate::help::DOCS_URL); - ui.hyperlink_to(app.tr("home.report_issue"), "https://github.com/tangency-labs/solidcraft/issues/new"); - ui.hyperlink_to(app.tr("home.whats_new"), "https://github.com/bherbruck/solidcraft/releases/latest"); - if ui.link(app.tr("ui.keyboard_shortcuts")).clicked() { - app.keymap.open = true; - app.keymap.read_only = true; - } - if ui.link(app.tr("ui.preferences")).clicked() { - crate::prefs::open_at(app, 0); - } - }); - ui.add_space(t.space_16); - section(ui, app.tr("home.recent")); - if recent.is_empty() { - ui.label(RichText::new(crate::i18n::tr_label("Designs you open or save appear here.")).color(t.text_dim)); + }); + }); + content(app, ui, &mut action, true); } else { - grid(ui, recent.len(), |ui, i| { - let Some(p) = recent.get(i) else { return }; - let path = std::path::Path::new(p); - let name = path.file_stem().map(|x| x.to_string_lossy().to_string()).unwrap_or_else(|| p.clone()); - let missing = !available(app, p); - let mut sub = if missing { - app.tr("home.missing").to_string() - } else if p.starts_with("/disk/") { - // The web build remembers files it saved on the computer. - crate::i18n::tr_label("On your computer").to_string() - } else if p.starts_with("/opfs/") { - // The web build keeps designs in the browser's own storage. + let rail = egui::Rect::from_min_size(full.min, vec2(t.file_nav_width, full.height())); + FileView::rail(ui, rail, |ui| { + egui::ScrollArea::vertical().id_salt("home_navigation").auto_shrink([false, false]).show(ui, |ui| { + navigation(app, ui, &mut action); + }); + }); + let body = egui::Rect::from_min_max(egui::pos2(rail.right(), full.top()), full.max); + ui.scope_builder(egui::UiBuilder::new().max_rect(body), |ui| content(app, ui, &mut action, false)); + } + }); + }); + if let Some(action) = action { + dispatch(app, ui.ctx(), action); + } +} + +fn navigation(app: &SolveApp, ui: &mut egui::Ui, action: &mut Option) { + let busy = app.file_picker_busy(); + let design = !crate::documents::active_is_blank(app); + let response = FileView::back_to(ui, "home:back", app.tr("home.back"), &app.session.doc.name, "Esc"); + publish("home:back", &response); + if response.clicked() { + *action = Some(FileAction::Back); + } + let primary = if cfg!(target_os = "macos") { "⌘" } else { "Ctrl+" }; + let shift = if cfg!(target_os = "macos") { "⇧" } else { "Shift+" }; + let recover = if app.recoverable.is_empty() { + app.tr_label("Recover").to_string() + } else { + format!("{} ({})", app.tr_label("Recover"), app.recoverable.len()) + }; + let nav = [ + ("home:start", app.tr_label("Start"), String::new(), Some(Section::Start), true, FileAction::Section(Section::Start)), + ("home:new", app.tr_label("New"), format!("{primary}N"), None, true, FileAction::New("preferred")), + ("home:open", app.tr("ui.open"), format!("{primary}O"), None, true, FileAction::Open), + ("home:recover", recover.as_str(), String::new(), Some(Section::Recovery), true, FileAction::Section(Section::Recovery)), + ("home:save", app.tr("ui.save"), format!("{primary}S"), None, design, FileAction::Save), + ("home:save_as", app.tr("ui.save_as"), format!("{primary}{shift}S"), None, design, FileAction::SaveAs), + ("home:export", app.tr("home.export"), String::new(), Some(Section::Export), design, FileAction::Section(Section::Export)), + ("home:properties", app.tr("home.properties"), String::new(), None, design, FileAction::Properties), + ("home:settings", app.tr("home.settings"), format!("{primary},"), None, true, FileAction::Settings), + ("home:shortcuts", app.tr("home.shortcuts"), String::new(), None, true, FileAction::Shortcuts), + ("home:crashes", app.tr("home.crashes"), String::new(), None, true, FileAction::Crashes), + ("home:about", app.tr_label("About SolidCraft"), String::new(), None, true, FileAction::About), + ]; + for (index, (id, label, key, section, enabled, picked)) in nav.into_iter().enumerate() { + if index == 4 || index == 8 { + FileView::separator(ui); + } + let response = FileView::nav_row(ui, id, label, &key, section == Some(app.home.section), enabled && !busy); + publish(id, &response); + if response.clicked() { + *action = Some(picked); + } + } +} + +fn publish(id: &str, response: &egui::Response) { + crate::scenario::publish_handle(id, response.rect.center()); + crate::scenario::publish_rect(id, response.rect); +} + +fn content(app: &mut SolveApp, ui: &mut egui::Ui, action: &mut Option, narrow: bool) { + let t = Tokens::get(); + FileView::content(ui, narrow, |ui| { + egui::ScrollArea::vertical().id_salt("home_content").auto_shrink([false, false]).show(ui, |ui| { + ui.spacing_mut().item_spacing.y = 0.0; + let (title, hint) = match app.home.section { + Section::Start => (app.tr_label("Start"), app.tr("home.start_hint")), + Section::Recovery => (app.tr_label("Recover"), app.tr("home.recovery_hint")), + Section::Export => (app.tr("home.export"), app.tr("home.export_hint")), + }; + FileView::title(ui, title); + ui.add_space(t.space_6); + FileView::subtitle(ui, hint); + ui.add_space(t.file_section_gap); + if let Some((message, _, true)) = &app.status { + ui_kit::text(ui, message, ui_kit::Text::Error("home_status")); + } + match app.home.section { + Section::Start => start_content(app, ui, action), + Section::Recovery => recovery_content(app, ui, action), + Section::Export => export_content(app, ui, action), + } + }); + }); +} + +fn start_content(app: &mut SolveApp, ui: &mut egui::Ui, action: &mut Option) { + let t = Tokens::get(); + if let Some(entry) = app.recoverable.first().cloned() { + let title = crate::i18n::format("home.recovery_count", &[("count", &app.recoverable.len().to_string())]); + let filename = entry + .path + .as_deref() + .and_then(|path| std::path::Path::new(path).file_name()) + .map(|name| name.to_string_lossy().into_owned()) + .unwrap_or_else(|| entry.name.clone()); + let metadata = format!(" · {}", crate::recovery_ui::ago(entry.saved_at)); + let (recover, discard) = FileView::recovery_banner( + ui, + "home:recovery", + RecoveryMessage { title: &title, before_filename: " · ", filename: &filename, after_filename: &metadata }, + app.tr_label("Recover"), + (app.recoverable.len() == 1).then(|| app.tr_label("Discard")), + ); + publish("home:recovery:recover", &recover); + if recover.clicked() { + *action = + Some(if app.recoverable.len() == 1 { FileAction::Recovery(entry.clone(), true) } else { FileAction::Section(Section::Recovery) }); + } + if let Some(discard) = discard { + publish("home:recovery:discard", &discard); + if discard.clicked() { + *action = Some(FileAction::Recovery(entry, false)); + } + } + ui.add_space(t.file_section_gap); + } + let shortcut = if cfg!(target_os = "macos") { "⌘O" } else { "Ctrl+O" }; + let open_hint = crate::i18n::format("home.open_hint", &[("shortcut", shortcut)]); + let tiles = [ + ("home:new_mm", "new", app.tr("home.new_mm"), app.tr("home.new_mm_hint"), true), + ("home:new_inches", "new", app.tr("home.new_inches"), app.tr("home.new_inches_hint"), false), + ("home:open_tile", "open", app.tr("home.open"), open_hint.as_str(), false), + ("home:import", "import", app.tr("home.import"), app.tr("home.import_hint"), false), + ]; + FileView::section(ui, app.tr_label("New"), t.space_12, |ui| { + FileView::grid(ui, "home_new", FileView::tile_min_width(), tiles.len(), |ui, index, width| { + let Some((id, icon, title, hint, primary)) = tiles.get(index) else { return }; + let response = FileView::action_tile(ui, id, width, icon, title, hint, *primary); + publish(id, &response); + if response.clicked() { + *action = Some(match index { + 0 => FileAction::New("mm"), + 1 => FileAction::New("in"), + 2 => FileAction::Open, + _ => FileAction::Import, + }); + } + }); + }); + ui.add_space(t.file_section_gap); + FileView::section(ui, app.tr("home.recent"), t.space_10, |ui| { + if app.home.recent.is_empty() { + FileView::detail(ui, app.tr("home.recent_empty")); + } + if !app.home.recent.is_empty() { + FileView::recent_list(ui, |ui| { + for (index, path) in app.home.recent.clone().iter().enumerate() { + let name = std::path::Path::new(path).file_stem().map(|name| name.to_string_lossy()).unwrap_or_else(|| path.as_str().into()); + let missing = !available(app, path); + let when = if app.session.path.as_ref() == Some(path) { app.tr("home.open_now").to_string() } else { recent_time(app, path) }; + let shown_path = if missing { + format!("{} · {}", app.tr("home.missing"), friendly_path(path)) + } else if path.starts_with("/disk/") { + app.tr_label("On your computer").to_string() + } else if path.starts_with("/opfs/") { app.tr("home.in_this_browser").to_string() } else { - p.clone() + friendly_path(path) }; - if let Some(time) = app.home.opened_at.get(p) { - let now = web_time::SystemTime::now().duration_since(web_time::UNIX_EPOCH).map(|d| d.as_secs()).unwrap_or(*time); - let seconds = now.saturating_sub(*time); - let opened = if seconds < 60 { - app.tr("home.opened_just_now").to_string() - } else if seconds < 3600 { - crate::i18n::format("home.opened_minutes_ago", &[("count", &(seconds / 60).to_string())]) - } else if seconds < 86400 { - crate::i18n::format("home.opened_hours_ago", &[("count", &(seconds / 3600).to_string())]) - } else { - crate::i18n::format("home.opened_days_ago", &[("count", &(seconds / 86400).to_string())]) - }; - sub.push('\n'); - sub.push_str(&opened); - } - let response = card(ui, Pic::Ready(app.home.thumbs.get(p.as_str()).and_then(Option::as_ref)), &name, &sub, missing) - .on_hover_text(p.as_str()); - crate::scenario::publish_handle(&format!("home:recent:{i}"), response.rect.center()); - crate::ui_kit::Menu::context(&response, |ui| { - if crate::context_menu::button(ui, crate::i18n::tr_label("Remove from list"), "delete").clicked() { - app.home.recent.retain(|x| x != p); - app.home.opened_at.remove(p); + let response = FileView::recent_row( + ui, + &format!("home:recent:{index}"), + ui_kit::RecentRow { + title: &name, + path: &shown_path, + when: &when, + workspace: app.tr("home.design_workspace"), + thumbnail: texture(app.home.thumbs.get(path).and_then(Option::as_ref)), + }, + ); + publish(&format!("home:recent:{index}"), &response); + response.clone().on_hover_text(path); + ui_kit::Menu::context(&response, |ui| { + if crate::context_menu::button(ui, app.tr_label("Remove from list"), "delete").clicked() { + app.home.recent.retain(|x| x != path); + app.home.opened_at.remove(path); ui.close(); } - if !cfg!(target_arch = "wasm32") - && crate::context_menu::button(ui, crate::i18n::tr_label("Show in folder"), "folder").clicked() - { + if !cfg!(target_arch = "wasm32") && crate::context_menu::button(ui, app.tr_label("Show in folder"), "folder").clicked() { if let Some(show) = &app.services.show_in_folder { - show(p); + show(path); } ui.close(); } }); if response.clicked() { - let p = p.clone(); - action = Some(Box::new(move |app: &mut SolveApp| open_recent(app, &p))); + open_recent(app, path); } - }); - } - ui.add_space(t.space_24); - section(ui, app.tr("home.samples")); - grid(ui, samples.len(), |ui, i| { - let Some(s) = samples.get(i) else { return }; - let key = format!("sample:{i}"); - let busy = app.home.wanted == Some(i); - // The engine's sample table holds English text; the opened design keeps it as its name. - let about = app.tr_label(s.about); - let sub = if busy { app.tr("home.opening") } else { about }; - let tex = match app.home.thumbs.get(&key) { - Some(t) => Pic::Ready(t.as_ref()), - None => Pic::Icon("box"), - }; - if card(ui, tex, app.tr_label(s.name), sub, false).on_hover_text(about).clicked() { - action = Some(Box::new(move |app: &mut SolveApp| open_sample(app, i))); } }); - }); + } }); - if let Some(f) = action { - f(app); - } -} - -fn section(ui: &mut egui::Ui, title: &str) { - let t = Tokens::get(); - ui.label(RichText::new(title).size(crate::theme::Tokens::get().font_subtitle).semibold().color(t.text)); - ui.add_space(t.space_8); -} - -/// Cards in rows that fill the width. -fn grid(ui: &mut egui::Ui, n: usize, mut each: impl FnMut(&mut egui::Ui, usize)) { - let t = Tokens::get(); - let w = THUMB[0] as f32 + 16.0; - let per_row = ((ui.available_width() + t.space_14) / (w + t.space_14)).floor().max(1.0) as usize; - for row in 0..n.div_ceil(per_row) { - ui.horizontal(|ui| { - ui.spacing_mut().item_spacing.x = t.space_14; - for i in row * per_row..((row + 1) * per_row).min(n) { - each(ui, i); - } - }); - ui.add_space(t.space_14); - } -} - -/// A card's picture: rendered (`None` while it renders), or an icon until it is asked for. -enum Pic<'a> { - Ready(Option<&'a egui::TextureHandle>), - Icon(&'static str), -} - -/// A design card: its picture (a spinner while it renders), name and a line under it. -fn card(ui: &mut egui::Ui, pic: Pic, name: &str, sub: &str, dim: bool) -> egui::Response { - let t = Tokens::get(); - let size = vec2(THUMB[0] as f32 + 16.0, THUMB[1] as f32 + 80.0); - let (r, resp) = ui.allocate_exact_size(size, Sense::click()); - let hover = resp.hovered(); - ui.painter().rect( - r, - t.radius_md, - if hover { t.hover } else { t.field }, - Stroke::new(1.0, if hover { t.accent } else { t.border }), - egui::StrokeKind::Inside, - ); - let img = egui::Rect::from_min_size(r.min + vec2(8.0, 8.0), vec2(THUMB[0] as f32, THUMB[1] as f32)); - match pic { - Pic::Icon(icon) => { - ui.painter().rect_filled(img, CornerRadius::same(t.radius_sm), t.panel_header); - crate::icons::paint_icon(ui.painter(), egui::Rect::from_center_size(img.center(), vec2(56.0, 56.0)), icon, f32::from(t.icon.a()) / 255.0); - } - Pic::Ready(Some(tx)) => { - let tint = if dim { Color32::from_white_alpha(90) } else { Color32::WHITE }; - ui.painter().image(tx.id(), img, egui::Rect::from_min_max(egui::pos2(0.0, 0.0), egui::pos2(1.0, 1.0)), tint); - } - Pic::Ready(None) => { - ui.painter().rect_filled(img, CornerRadius::same(t.radius_sm), t.panel_header); - if !dim { - egui::Spinner::new().size(18.0).paint_at(ui, egui::Rect::from_center_size(img.center(), vec2(18.0, 18.0))); + ui.add_space(t.file_section_gap); + FileView::section(ui, app.tr("home.samples"), t.space_10, |ui| { + let samples: Vec<_> = solidcraft_engine::sample::samples() + .iter() + .enumerate() + .map(|(index, sample)| { + let hint = if app.home.wanted == Some(index) { app.tr("home.opening") } else { app.tr_label(sample.about) }; + ui_kit::SampleCard { + title: app.tr_label(sample.name), + description: hint, + icon: "box", + thumbnail: texture(app.home.thumbs.get(&format!("sample:{index}")).and_then(Option::as_ref)), + } + }) + .collect(); + for (index, response) in FileView::sample_grid(ui, "home:sample", &samples).into_iter().enumerate() { + publish(&format!("home:sample:{index}"), &response); + if response.clicked() { + open_sample(app, index); } } + }); +} + +fn texture(texture: Option<&egui::TextureHandle>) -> Option<(egui::TextureId, egui::Vec2)> { + texture.map(|texture| (texture.id(), texture.size_vec2())) +} + +/// Abbreviate only an actual home-directory ancestor; the source path is kept for actions. +fn friendly_path(path: &str) -> String { + let home = std::env::var_os("HOME").or_else(|| std::env::var_os("USERPROFILE")); + abbreviated_path(path, home.as_deref().map(std::path::Path::new)) +} + +fn abbreviated_path(path: &str, home: Option<&std::path::Path>) -> String { + if let Some(relative) = home.filter(|home| !home.as_os_str().is_empty()).and_then(|home| std::path::Path::new(path).strip_prefix(home).ok()) { + if relative.as_os_str().is_empty() { "~".into() } else { format!("~/{}", relative.to_string_lossy()) } + } else { + path.to_owned() } - let ty = img.bottom() + 8.0; - let clip = egui::Rect::from_min_max(egui::pos2(r.left() + 8.0, ty), egui::pos2(r.right() - 8.0, r.bottom())); - let p = ui.painter().with_clip_rect(clip); - p.text( - egui::pos2(r.left() + 10.0, ty), - egui::Align2::LEFT_TOP, - name, - egui::FontId::proportional(t.font_heading), - if dim { t.text_dim } else { t.text }, - ); - p.text(egui::pos2(r.left() + 10.0, ty + 20.0), egui::Align2::LEFT_TOP, sub, egui::FontId::proportional(t.font_caption), t.text_dim); - if hover { - ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); +} + +fn recent_time(app: &SolveApp, path: &str) -> String { + let Some(time) = app.home.opened_at.get(path) else { return String::new() }; + let now = web_time::SystemTime::now().duration_since(web_time::UNIX_EPOCH).map(|d| d.as_secs()).unwrap_or(*time); + recent_time_at(app, *time, now) +} + +fn recent_time_at(app: &SolveApp, time: u64, now: u64) -> String { + let seconds = now.saturating_sub(time); + if seconds < 60 { + return app.tr("home.opened_just_now").to_string(); + } + let (key, count) = if seconds < 3600 { + ("home.opened_minutes_ago", seconds / 60) + } else if seconds < 86400 { + ("home.opened_hours_ago", seconds / 3600) + } else if seconds < 172800 { + return app.tr("home.yesterday").to_string(); + } else { + let date = solidcraft_engine::crash::utc(time); + let date = date.split_once('T').map_or(date.as_str(), |(date, _)| date); + let mut parts = date.rsplitn(3, '-'); + let day = parts.next().unwrap_or("").trim_start_matches('0'); + let month = parts.next().unwrap_or(""); + return crate::i18n::format("home.short_date", &[("day", day), ("month", app.tr(&format!("home.month_{month}")))]); + }; + crate::i18n::format(key, &[("count", &count.to_string())]) +} + +fn recovery_content(app: &SolveApp, ui: &mut egui::Ui, action: &mut Option) { + if app.recoverable.is_empty() { + ui_kit::text(ui, app.tr("home.recovery_empty"), ui_kit::Text::Inline); + } + for (index, entry) in app.recoverable.iter().take(20).enumerate() { + let detail = crate::i18n::format( + "recovery.detail", + &[ + ("file", entry.path.as_deref().unwrap_or(app.tr("recovery.never_saved"))), + ("features", &entry.features.to_string()), + ("when", &crate::recovery_ui::ago(entry.saved_at)), + ], + ); + let (recover, discard) = + FileView::recovery_review(ui, &format!("home:recovery:{index}"), &entry.name, &detail, app.tr_label("Recover"), app.tr_label("Discard")); + for (id, response, recover) in [("recover", Some(recover), true), ("discard", discard, false)] { + let Some(response) = response else { continue }; + publish(&format!("home:recovery:{index}:{id}"), &response); + if response.clicked() { + *action = Some(FileAction::Recovery(entry.clone(), recover)); + } + } + ui.add_space(Tokens::get().space_12); + } +} + +fn export_content(app: &SolveApp, ui: &mut egui::Ui, action: &mut Option) { + let formats = [ + ("step", "STEP", Some("home.export_step_hint")), + ("mesh", "Mesh", Some("home.export_mesh_hint")), + ("view_dxf", "DXF", None), + ("obj", "OBJ", None), + ("urdf", "URDF", None), + ("json", "JSON", Some("home.export_json_hint")), + ]; + FileView::grid(ui, "home_exports", FileView::tile_min_width(), formats.len(), |ui, index, width| { + let Some((id, format, hint)) = formats.get(index) else { return }; + let label = if *id == "view_dxf" { + app.tr_label("Export Current View as DXF…").to_string() + } else { + format!("{} {}…", app.tr("home.export"), app.tr_label(format)) + }; + let subtitle = hint.map(|key| app.tr(key)).unwrap_or(format); + let response = FileView::action_tile(ui, &format!("home:export:{id}"), width, "export", &label, subtitle, false); + publish(&format!("home:export:{id}"), &response); + if response.clicked() { + *action = Some(match *id { + "step" => FileAction::Export("step"), + "mesh" => FileAction::Mesh, + "view_dxf" => FileAction::ViewDxf, + "obj" => FileAction::Export("obj"), + "urdf" => FileAction::Export("urdf"), + _ => FileAction::Export("json"), + }); + } + }); +} + +fn dispatch(app: &mut SolveApp, ctx: &egui::Context, action: FileAction) { + match action { + FileAction::Back => app.home.open = false, + FileAction::Section(section) => { + app.home.section = section; + if section == Section::Recovery && app.recoverable.is_empty() { + let dir = app.autosave.as_ref().map(|autosave| autosave.dir.clone()).or_else(solidcraft_engine::recovery::default_dir); + if let Some(dir) = dir { + app.recoverable = solidcraft_engine::recovery::orphans(&dir); + } + } + } + FileAction::New(units) => { + crate::documents::new_design(app); + if units != "preferred" && !app.home.open && crate::documents::active_is_blank(app) { + crate::prefs::apply_new_design_units(app, units); + } + } + FileAction::Open => app.pick_open(|app, path| { + if let Some(path) = path { + app.open_path_async(&path); + } + }), + FileAction::Import => app.pick_open_for(&["step", "stp", "iges", "igs", "stl", "obj", "3mf", "gltf", "glb"], |app, path| { + if let Some(path) = path { + app.open_path_async(&path); + } + }), + FileAction::Save => { + app.home.open = false; + crate::toolbar::save(app); + } + FileAction::SaveAs => { + app.home.open = false; + crate::toolbar::save_as(app); + } + FileAction::Export(ext) => { + app.home.open = false; + crate::toolbar::export(app, ext); + } + FileAction::Mesh => { + app.home.open = false; + app.start("file.save_mesh"); + } + FileAction::ViewDxf => { + app.home.open = false; + app.start("file.export_view_dxf"); + } + FileAction::Properties => { + app.home.open = false; + app.start("document.metadata"); + } + FileAction::Settings => crate::prefs::open_at(app, 0), + FileAction::Shortcuts => { + app.keymap.open = true; + app.keymap.read_only = true; + } + FileAction::Crashes => crate::help::run(app, ctx, "crashes"), + FileAction::About => crate::help::run(app, ctx, "about"), + FileAction::Recovery(entry, recover) => crate::recovery_ui::apply(app, entry, recover), } - resp } #[cfg(test)] mod tests { use super::*; + #[test] + fn recent_paths_only_abbreviate_complete_home_ancestors() { + let home = Some(std::path::Path::new("/Users/sample")); + assert_eq!(abbreviated_path("/Users/sample/Designs/plate.solidcraft", home), "~/Designs/plate.solidcraft"); + assert_eq!(abbreviated_path("/Users/sample", home), "~"); + assert_eq!(abbreviated_path("/Users/sample-other/plate.solidcraft", home), "/Users/sample-other/plate.solidcraft"); + assert_eq!(abbreviated_path("/disk/design.solidcraft", None), "/disk/design.solidcraft"); + } + + #[test] + fn recent_times_use_compact_labels_and_calendar_dates() { + let app = crate::test_support::sample_app(); + let now = 1_792_569_600; // 2026-10-21T08:00:00Z. + assert_eq!(recent_time_at(&app, now + 60, now), "Just now"); + assert_eq!(recent_time_at(&app, now - 120, now), "2 min ago"); + assert_eq!(recent_time_at(&app, now - 7200, now), "2 h ago"); + assert_eq!(recent_time_at(&app, now - 86400, now), "Yesterday"); + assert_eq!(recent_time_at(&app, now - 172800, now), "19 Oct"); + } + #[test] fn shipped_sample_pictures_are_bounded_and_match_the_current_scripts() { use sha2::{Digest, Sha256}; @@ -790,7 +1059,9 @@ mod tests { assert!(available(&h.app, "/disk/other/Bracket.solidcraft")); h.app.home.present.insert("/disk/other/Bracket.solidcraft".into(), false); assert!(!available(&h.app, "/disk/other/Bracket.solidcraft")); - open_recent(&mut h.app, "/disk/known/Bracket.solidcraft"); + h.app.home.add_recent("/disk/known/Bracket.solidcraft"); + h.app.home.show(h.app.session.revision); + click_file(&mut h, "home:recent:0"); assert_eq!(*asked.borrow(), ["/disk/known/Bracket.solidcraft"]); open_recent(&mut h.app, "/disk/other/Bracket.solidcraft"); assert_eq!(asked.borrow().len(), 1, "a file the host doesn't remember is not asked for"); @@ -1035,4 +1306,179 @@ mod tests { h.frames(2); assert!(shown(&h) && h.app.prefs_window.section == crate::prefs::PAGE_SHORTCUTS && h.app.home.open); } + + fn click_file(h: &mut crate::scenario::Harness, id: &str) { + h.frames(3); + h.step(&serde_json::json!({"click": {"handle": id}})).unwrap(); + h.frames(3); + } + + #[test] + fn file_view_new_tiles_choose_units_without_changing_preferences_or_other_tabs() { + for (id, units) in [("home:new_mm", "mm"), ("home:new_inches", "in")] { + let mut h = crate::scenario::Harness::new(); + h.app.run("solid.box", serde_json::json!({"length":10,"width":12,"height":14})).unwrap(); + let original = h.app.session.doc.to_json(); + h.app.preferences.default_units = "ft".into(); + h.app.home.show(0); + click_file(&mut h, id); + assert!(!h.app.home.open); + assert_eq!(h.app.session.doc.units, units); + assert_eq!(h.app.preferences.default_units, "ft"); + assert_eq!(h.app.docs.count(), 2); + assert!(!h.app.session.is_dirty(), "a new empty design is initially clean"); + crate::documents::switch(&mut h.app, 0); + assert_eq!(h.app.session.doc.to_json(), original, "the previously open design is untouched"); + } + } + + #[test] + fn file_view_open_and_import_cancel_preserve_the_current_design_and_history() { + for id in ["home:open_tile", "home:import"] { + let mut h = crate::scenario::Harness::new(); + h.app.run("solid.box", serde_json::json!({"length":10,"width":12,"height":14})).unwrap(); + let original = h.app.session.doc.to_json(); + let undo = h.app.session.undo.len(); + h.app.home.show(0); + click_file(&mut h, id); + assert!(h.app.home.open, "cancel keeps the File view open"); + assert_eq!(h.app.session.doc.to_json(), original); + assert_eq!(h.app.session.undo.len(), undo); + assert_eq!(h.app.docs.count(), 1); + } + } + + #[test] + fn file_view_save_as_and_export_act_only_after_an_explicit_file_action() { + let mut h = crate::scenario::Harness::new(); + h.app.run("solid.box", serde_json::json!({"length":10,"width":12,"height":14})).unwrap(); + h.app.home.show(0); + h.frames(3); + assert!(h.app.session.path.is_none()); + click_file(&mut h, "home:save_as"); + h.settle(); + assert!(!h.app.home.open); + assert!(h.app.session.path.as_ref().is_some_and(|path| std::path::Path::new(path).is_file())); + assert!(!h.app.session.is_dirty()); + let original = h.app.session.doc.to_json(); + h.app.home.show(0); + click_file(&mut h, "home:export"); + assert!(h.app.home.open && h.app.home.section == Section::Export); + click_file(&mut h, "home:export:json"); + h.settle(); + assert!(!h.app.home.open); + assert!(h.dir.join(format!("{}.json", h.app.session.doc.name)).is_file()); + assert_eq!(h.app.session.doc.to_json(), original, "export leaves the design unchanged"); + } + + #[test] + fn file_view_recovery_reuses_dirty_design_protection_and_keeps_the_entry() { + let mut h = crate::scenario::Harness::new(); + h.app.run("solid.box", serde_json::json!({"length":10,"width":12,"height":14})).unwrap(); + let original = h.app.session.doc.to_json(); + h.app.recoverable = + vec![solidcraft_engine::recovery::Entry { id: "file-test".into(), name: "Bracket".into(), path: None, saved_at: 0, features: 3 }]; + h.app.home.show(0); + h.frames(3); + assert!(crate::scenario::handle_at("home:recovery:recover").is_some()); + click_file(&mut h, "home:recovery:recover"); + assert_eq!(h.app.session.doc.to_json(), original); + assert_eq!(h.app.recoverable.len(), 1); + click_file(&mut h, "home:recover"); + click_file(&mut h, "home:recovery:0:recover"); + assert_eq!(h.app.session.doc.to_json(), original); + assert_eq!(h.app.recoverable.len(), 1); + assert!(h.app.status.as_ref().is_some_and(|(message, _, error)| *error && message.contains("save or discard"))); + assert!(crate::scenario::rect_of("dialog:report:home_status").is_some(), "the refusal is visible on File"); + } + + #[test] + fn file_view_escape_returns_to_design_but_does_not_close_file_behind_preferences() { + let mut h = crate::scenario::Harness::new(); + h.app.home.show(0); + click_file(&mut h, "home:settings"); + h.step(&serde_json::json!({"key":"Escape"})).unwrap(); + assert!(h.app.home.open); + h.frames(2); + click_file(&mut h, "home:about"); + h.step(&serde_json::json!({"key":"Escape"})).unwrap(); + assert!(h.app.home.open, "Escape must close About without closing File behind it"); + h.frames(3); + h.step(&serde_json::json!({"key":"Escape"})).unwrap(); + assert!(!h.app.home.open); + } + + #[test] + fn file_view_narrow_navigation_and_content_stay_inside_the_window() { + for dark in [false, true] { + let mut h = crate::scenario::Harness::new(); + h.call("ui.resize", serde_json::json!({"width":420,"height":800})); + h.app.ui.dark = dark; + h.app.home.show(0); + h.frames(4); + let page = crate::scenario::rect_of("home:page").unwrap(); + let tile = crate::scenario::rect_of("home:new_mm").unwrap(); + assert!(page.contains_rect(tile), "{dark}: the new tile escapes the narrow page"); + h.step(&serde_json::json!({"widget":"Start page"})).unwrap(); + h.frames(2); + assert!(crate::scenario::handle_at("home:settings").is_some(), "all File actions remain available through the narrow menu"); + } + } + + #[test] + fn file_view_desktop_cards_align_in_rows_and_remain_visible() { + let mut h = crate::scenario::Harness::new(); + h.call("ui.resize", serde_json::json!({"width":1400,"height":900})); + h.app.home.show(0); + h.frames(5); + let page = crate::scenario::rect_of("home:page").unwrap(); + let first = crate::scenario::rect_of("home:new_mm").unwrap(); + for id in ["home:new_mm", "home:new_inches", "home:open_tile", "home:import"] { + let rect = crate::scenario::rect_of(id).unwrap(); + assert!((rect.top() - first.top()).abs() < 0.5, "{id}: action tiles must share a row"); + assert!(page.contains_rect(rect), "{id}: card is off screen"); + } + let first = crate::scenario::rect_of("home:sample:0").unwrap(); + for i in 0..6 { + let rect = crate::scenario::rect_of(&format!("home:sample:{i}")).unwrap(); + assert!((rect.top() - first.top()).abs() < 0.5, "sample {i}: thumbnails must share a row"); + assert!(page.contains_rect(rect), "sample {i}: card is off screen"); + } + } + + #[test] + fn file_view_save_as_shortcut_uses_the_picker_without_overwriting_the_source() { + let mut h = crate::scenario::Harness::new(); + h.app.run("solid.box", serde_json::json!({"length":10,"width":12,"height":14})).unwrap(); + let source = h.dir.join("source.solidcraft"); + h.app.run("file.save_as", serde_json::json!({"path":source})).unwrap(); + let bytes = std::fs::read(&source).unwrap(); + h.app.session.doc = std::sync::Arc::new({ + let mut doc = (*h.app.session.doc).clone(); + doc.name = "Copy".into(); + doc + }); + h.app.home.show(0); + h.frames(3); + h.step(&serde_json::json!({"key":"S","cmd":true,"shift":true})).unwrap(); + h.frames(3); + h.settle(); + assert!(!h.app.home.open); + assert_eq!(h.app.session.path.as_deref(), h.dir.join("Copy.solidcraft").to_str()); + assert_eq!(std::fs::read(source).unwrap(), bytes); + } + + #[test] + fn document_plus_opens_file_before_creating_a_design() { + let mut h = crate::scenario::Harness::new(); + h.app.run("solid.box", serde_json::json!({"length":10,"width":12,"height":14})).unwrap(); + let original = h.app.session.doc.to_json(); + click_file(&mut h, "tab:new"); + assert!(h.app.home.open); + assert_eq!(h.app.docs.count(), 1); + assert_eq!(h.app.session.doc.to_json(), original); + click_file(&mut h, "home:new_inches"); + assert_eq!(h.app.docs.count(), 2); + assert_eq!(h.app.session.doc.units, "in"); + } } diff --git a/crates/ui-egui/src/i18n_ui_tests.rs b/crates/ui-egui/src/i18n_ui_tests.rs index 1de00d22d..fe4343ff0 100644 --- a/crates/ui-egui/src/i18n_ui_tests.rs +++ b/crates/ui-egui/src/i18n_ui_tests.rs @@ -103,7 +103,7 @@ fn window_chrome_renders_in_the_active_language() { } } -/// The start page's two big buttons had a fixed width, so a translation longer than the English +/// File-view action tiles must keep translated labels inside their bounds. A translation longer than the English /// label ran past the edge ("Nouvelle conception"). Every registered language's label must stay /// inside its button. #[test] @@ -127,12 +127,12 @@ fn home_page_buttons_fit_their_translated_labels() { let (mut rects, mut texts) = (Vec::new(), Vec::new()); out.shapes.iter().for_each(|shape| collect(&shape.shape, &mut rects, &mut texts)); let locale = crate::i18n::Locale::for_language(catalog.id); - for id in ["ui.new_design", "home.open"] { + for id in ["home.new_mm", "home.new_inches", "home.open", "home.import"] { let label = locale.text(id); let (_, text) = texts.iter().find(|(t, _)| t == label).unwrap_or_else(|| panic!("{}: {label:?} is not painted", catalog.id)); let button = rects .iter() - .filter(|r| (r.height() - 64.0).abs() < 1.0 && r.contains(text.left_center())) + .filter(|r| (r.height() - crate::theme::Tokens::get().file_tile_height).abs() < 1.0 && r.contains(text.left_center())) .min_by(|a, b| a.area().total_cmp(&b.area())) .unwrap_or_else(|| panic!("{}: no button around {label:?}", catalog.id)); assert!(text.right() <= button.right(), "{}: {label:?} ends at {} past its button's edge {}", catalog.id, text.right(), button.right()); @@ -155,37 +155,15 @@ fn home_page_renders_in_the_active_language() { let cases = [ ( "it", - [ - "Nuovo progetto", - "Apri…", - "Documentazione", - "Segnala un problema", - "Novità", - "Scorciatoie da tastiera", - "Preferenze", - "Recenti", - "Esempi", - "Piastra di esempio", - ], - "non presente\nAperto 2 h fa", + ["Nuovo progetto", "Apri…", "Scorciatoie da tastiera", "Impostazioni", "Recenti", "Esempi", "Piastra di esempio"], + "non presente\n2 h fa", ), ( "ja", - [ - "新規デザイン", - "開く…", - "ドキュメント", - "問題を報告", - "新機能", - "キーボードショートカット", - "環境設定", - "最近使用した項目", - "サンプル", - "サンプル プレート", - ], - "見つかりません\n2 時間前に開きました", + ["新しいデザイン", "開く…", "キーボードショートカット", "設定", "最近使用した項目", "サンプル", "サンプル プレート"], + "見つかりません\n2 時間前", ), - ("zh", ["新建设计", "打开…", "文档", "报告问题", "新功能", "键盘快捷键", "首选项", "最近使用", "示例", "示例板"], "文件不存在\n2 小时前打开"), + ("zh", ["新建设计", "打开…", "键盘快捷键", "设置", "最近使用", "示例", "示例板"], "文件不存在\n2 小时前"), ]; for (lang, words, missing_recent) in cases { let mut h = Harness::new(); @@ -203,9 +181,12 @@ fn home_page_renders_in_the_active_language() { let out = crate::test_support::frame(&h.ctx, egui::RawInput { screen_rect: Some(screen), ..Default::default() }, |ui| h.app.ui(ui)); let mut texts = Vec::new(); out.shapes.iter().for_each(|shape| painted(&shape.shape, &mut texts)); - for word in words.into_iter().chain([missing_recent]) { + for word in words { assert!(texts.iter().any(|t| t == word), "{lang}: {word:?} must be painted, got {texts:?}"); } + let (missing, opened) = missing_recent.split_once('\n').unwrap(); + assert!(texts.iter().any(|text| text.starts_with(&format!("{missing} · "))), "{lang}: missing-file status must remain visible"); + assert!(texts.iter().any(|text| text == opened), "{lang}: the recent timestamp must remain visible"); for english in ["New Design", "Open…", "Documentation", "Report an Issue", "What's new", "Recent", "Samples", "Sample Plate"] { assert!(!texts.iter().any(|t| t == english), "{lang}: {english:?} is still painted in English"); } diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rs index c42c96c76..b801fed03 100644 --- a/crates/ui-egui/src/icons.rs +++ b/crates/ui-egui/src/icons.rs @@ -39,29 +39,41 @@ pub fn paint_icon(p: &Painter, r: Rect, name: &str, opacity: f32) { /// Draw the icon `name` for a surface that is always dark (the application bar), whatever the /// theme: `dark: Some(true)`. `None` follows the theme. pub fn paint_on(p: &Painter, r: Rect, name: &str, dark: Option, opacity: f32) { - paint_with_ink(p, r, name, dark, opacity, None, false); + paint_with_ink(p, r, name, dark, opacity, None, Mirror::None); } /// Monochrome flat controls on the application bar use its text token exactly. pub(crate) fn paint_app_bar(p: &Painter, r: Rect, name: &str, opacity: f32) { - paint_with_ink(p, r, name, Some(true), opacity, Some(crate::theme::Tokens::get().app_bar_text), false); + paint_with_ink(p, r, name, Some(true), opacity, Some(crate::theme::Tokens::get().app_bar_text), Mirror::None); } /// Paint a single-colour icon in `ink`. pub(crate) fn paint_ink(p: &Painter, r: Rect, name: &str, ink: Color32) { - paint_with_ink(p, r, name, Some(true), 1.0, Some(ink), false); + paint_with_ink(p, r, name, Some(true), 1.0, Some(ink), Mirror::None); } /// Paint a single-colour icon in `ink`, mirrored top to bottom (a chevron pointing up). pub(crate) fn paint_ink_flipped(p: &Painter, r: Rect, name: &str, ink: Color32) { - paint_with_ink(p, r, name, Some(true), 1.0, Some(ink), true); + paint_with_ink(p, r, name, Some(true), 1.0, Some(ink), Mirror::Vertical); } -fn paint_with_ink(p: &Painter, r: Rect, name: &str, dark: Option, opacity: f32, ink: Option, flip_y: bool) { +/// Paint a single-colour icon mirrored left to right, reusing the original master. +pub(crate) fn paint_ink_mirrored(p: &Painter, r: Rect, name: &str, ink: Color32) { + paint_with_ink(p, r, name, Some(true), 1.0, Some(ink), Mirror::Horizontal); +} + +#[derive(Clone, Copy)] +enum Mirror { + None, + Vertical, + Horizontal, +} + +fn paint_with_ink(p: &Painter, r: Rect, name: &str, dark: Option, opacity: f32, ink: Option, mirror: Mirror) { let ctx = p.ctx(); let resolved = icon_svg::resolve(name); let look = Look { dark: dark.unwrap_or_else(|| ctx.global_style().visuals.dark_mode), accent: resolved.accent, vision: crate::theme::vision() }; - paint_resolved(p, r, resolved, look, opacity, ink.map_or(Finish::Artwork, Finish::Ink), flip_y); + paint_resolved(p, r, resolved, look, opacity, ink.map_or(Finish::Artwork, Finish::Ink), mirror); } /// Draw with a named palette ramp, preserving outlines, passive faces and transparency. @@ -74,7 +86,7 @@ pub fn paint_accented(p: &Painter, r: Rect, name: &str, accent: Option<&str>, op None => None, }; let look = Look { dark: p.ctx().global_style().visuals.dark_mode, accent, vision: crate::theme::vision() }; - paint_resolved(p, r, resolved, look, opacity, Finish::Artwork, false); + paint_resolved(p, r, resolved, look, opacity, Finish::Artwork, Mirror::None); } /// Shared destructive-action artwork: red shaded faces, normal outlines and cutouts. @@ -83,10 +95,10 @@ pub fn paint_accented(p: &Painter, r: Rect, name: &str, accent: Option<&str>, op pub(crate) fn paint_danger(p: &Painter, r: Rect, name: &str, opacity: f32) { let resolved = icon_svg::resolve(name); let look = Look { dark: p.ctx().global_style().visuals.dark_mode, accent: icon_svg::accent_index("constraint"), vision: crate::theme::vision() }; - paint_resolved(p, r, resolved, look, opacity, Finish::Danger, false); + paint_resolved(p, r, resolved, look, opacity, Finish::Danger, Mirror::None); } -fn paint_resolved(p: &Painter, r: Rect, resolved: icon_svg::Resolved, look: Look, opacity: f32, finish: Finish, flip_y: bool) { +fn paint_resolved(p: &Painter, r: Rect, resolved: icon_svg::Resolved, look: Look, opacity: f32, finish: Finish, mirror: Mirror) { let ctx = p.ctx(); let ppp = ctx.pixels_per_point().max(0.5); let side = r.width().min(r.height()); @@ -111,7 +123,11 @@ fn paint_resolved(p: &Painter, r: Rect, resolved: icon_svg::Resolved, look: Look let size = px as f32 / ppp; let min = pos2(((r.center().x - size / 2.0) * ppp).round() / ppp, ((r.center().y - size / 2.0) * ppp).round() / ppp); let tint = Color32::from_white_alpha((opacity.clamp(0.0, 1.0) * 255.0).round() as u8); - let uv = if flip_y { Rect::from_min_max(pos2(0.0, 1.0), pos2(1.0, 0.0)) } else { Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)) }; + let uv = match mirror { + Mirror::None => Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)), + Mirror::Vertical => Rect::from_min_max(pos2(0.0, 1.0), pos2(1.0, 0.0)), + Mirror::Horizontal => Rect::from_min_max(pos2(1.0, 0.0), pos2(0.0, 1.0)), + }; p.image(tex.id(), Rect::from_min_size(min, egui::vec2(size, size)), uv, tint); } diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs index be1f976bf..a71a1fc1c 100644 --- a/crates/ui-egui/src/prefs.rs +++ b/crates/ui-egui/src/prefs.rs @@ -848,9 +848,14 @@ pub fn apply(app: &mut SolveApp, ctx: &egui::Context) { /// Callers: a launch with no file, New on a design that is already empty, `file.new`, and the /// blank design left when the last tab closes. A design that already has features is unchanged. pub fn apply_new_design(app: &mut SolveApp) { - if app.session.doc.features.is_empty() && app.session.doc.units != app.preferences.default_units { + apply_new_design_units(app, &app.preferences.default_units.clone()); +} + +/// Explicit units for a new-design tile; the user's default preference stays unchanged. +pub(crate) fn apply_new_design_units(app: &mut SolveApp, units: &str) { + if app.session.doc.features.is_empty() && app.session.doc.units != units { let saved = !app.session.is_dirty(); - if app.session.execute("document.units", &json!({ "units": app.preferences.default_units })).is_ok() { + if app.session.execute("document.units", &json!({ "units": units })).is_ok() { app.session.undo.pop(); if saved { app.session.mark_saved(); diff --git a/crates/ui-egui/src/recovery_ui.rs b/crates/ui-egui/src/recovery_ui.rs index ce835e8e5..2886bfe64 100644 --- a/crates/ui-egui/src/recovery_ui.rs +++ b/crates/ui-egui/src/recovery_ui.rs @@ -111,7 +111,7 @@ pub fn close(app: &mut SolveApp) { } } -fn ago(secs: u64) -> String { +pub(crate) fn ago(secs: u64) -> String { let now = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs()).unwrap_or(secs); let d = now.saturating_sub(secs); match d { @@ -123,10 +123,10 @@ fn ago(secs: u64) -> String { } pub fn show(app: &mut SolveApp, ctx: &egui::Context) { - if app.recoverable.is_empty() { + // File view presents the same entries inline, without a second window covering them. + if app.home.open || app.recoverable.is_empty() { return; } - let dir = app.autosave.as_ref().map(|a| a.dir.clone()).or_else(recovery::default_dir); let mut act: Option<(Entry, bool)> = None; let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_recover_prompt"), "restore", crate::i18n::tr_label("Recover unsaved design?")) .actions("", crate::i18n::tr_label("Later"), None) @@ -153,28 +153,33 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) { } }); let later = closed || action != ui_kit::Action::None; - let dir_s = dir.map(|d| d.to_string_lossy().to_string()); - if let Some((e, recover)) = act { - app.recoverable.retain(|x| x.id != e.id); - if recover { - if app.session.is_dirty() { - app.set_status("save or discard the open design's changes before recovering another", true); - app.recoverable.insert(0, e); - return; - } - // Rebuilt off the window thread like any other file; once it is in, it is - // autosaved under this app's entry before the old entry goes. - let kind = crate::file_load::Kind::Recover { id: e.id.clone(), dir: dir_s }; - let _ = crate::file_load::begin_request(app, crate::file_load::Request::new(&e.name, kind)); - } else { - let _ = app.run("doc.recovery_discard", json!({"id": e.id, "dir": dir_s})); - } + if let Some((entry, recover)) = act { + apply(app, entry, recover); } if later { app.recoverable.clear(); } } +/// Shared recovery action for the launch prompt and File view; dirty work is never replaced. +pub(crate) fn apply(app: &mut SolveApp, entry: Entry, recover: bool) { + let dir_s = app.autosave.as_ref().map(|a| a.dir.clone()).or_else(recovery::default_dir).map(|d| d.to_string_lossy().to_string()); + app.recoverable.retain(|x| x.id != entry.id); + if recover { + if app.session.is_dirty() { + app.set_status("save or discard the open design's changes before recovering another", true); + app.recoverable.insert(0, entry); + return; + } + // Rebuilt off the window thread like any other file; once it is in, it is + // autosaved under this app's entry before the old entry goes. + let kind = crate::file_load::Kind::Recover { id: entry.id.clone(), dir: dir_s }; + let _ = crate::file_load::begin_request(app, crate::file_load::Request::new(&entry.name, kind)); + } else { + let _ = app.run("doc.recovery_discard", json!({"id": entry.id, "dir": dir_s})); + } +} + #[cfg(test)] mod tests { use super::*; @@ -453,6 +458,26 @@ mod tests { Entry { id: id.into(), path: None, name: name.into(), saved_at: 0, features: 3 } } + #[test] + fn file_view_recovery_is_inline_and_the_design_workspace_keeps_the_prompt() { + let mut h = crate::scenario::Harness::new(); + h.app.home.open = true; + h.app.recoverable = vec![entry("a", "Bracket"), entry("b", "Housing")]; + h.frames(4); + assert!(crate::scenario::handle_at("home:recovery:recover").is_some()); + assert!(h.widget("Later").is_none(), "the recovery window must not cover File view"); + assert_eq!(h.app.recoverable.len(), 2); + h.step(&json!({"click": {"handle": "home:recover"}})).unwrap(); + h.frames(2); + assert!(crate::scenario::handle_at("home:recovery:0:recover").is_some()); + assert!(crate::scenario::handle_at("home:recovery:1:discard").is_some()); + assert!(h.widget("Later").is_none()); + h.app.home.open = false; + h.frames(4); + assert!(h.widget("Later").is_some()); + assert_eq!(h.app.recoverable.len(), 2); + } + #[test] fn recovered_sessions_are_a_card_with_one_row_each_and_later_keeps_them_for_next_launch() { let mut h = crate::scenario::Harness::new(); diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rs index 1edd0455b..125392f04 100644 --- a/crates/ui-egui/src/theme.rs +++ b/crates/ui-egui/src/theme.rs @@ -225,6 +225,37 @@ pub struct IconColors { #[derive(Clone, Copy, Debug, PartialEq)] pub struct Tokens { + /// File/start presentation, with explicit foreground/background pairs. + pub file_dim: Color32, + pub file_recovery_well: Color32, + pub file_action_height: f32, + pub file_back_height: f32, + pub file_recovery_icon: f32, + pub file_grid_gap: f32, + pub file_background: Color32, + pub file_surface: Color32, + pub file_border: Color32, + /// Neutral multiplication tint for File-view model thumbnails. + pub file_image_tint: Color32, + pub file_rail: Color32, + pub file_rail_ink: Color32, + pub file_rail_hover: Color32, + pub file_primary: Color32, + pub file_primary_ink: Color32, + pub file_primary_border: Color32, + pub file_recovery: Color32, + pub file_recovery_ink: Color32, + pub file_recovery_border: Color32, + pub file_nav_width: f32, + pub file_nav_height: f32, + pub file_tile_height: f32, + pub file_tile_icon: f32, + pub file_recent_height: f32, + pub file_sample_image_height: f32, + pub file_content_inset_x: f32, + pub file_content_inset_y: f32, + pub file_section_gap: f32, + pub font_start_title: f32, // Shared dimensions in logical pixels; identical in both themes. pub space_2: f32, pub space_3: f32, @@ -591,6 +622,28 @@ pub fn apply(ctx: &egui::Context) { #[cfg(test)] mod tests { + #[test] + fn file_view_foreground_pairs_hold_small_text_contrast_without_changing_accent() { + for dark in [false, true] { + for vision in super::ColorVision::ALL { + let t = super::Tokens::themed(dark, vision); + for (ink, surface) in [ + (t.file_rail_ink, t.file_rail), + (t.file_rail_ink, t.file_rail_hover), + (t.file_primary_ink, t.file_primary), + (t.file_primary_ink, t.file_background), + (t.file_recovery_ink, t.file_recovery), + (t.form_ink, t.file_surface), + (t.file_dim, t.file_surface), + (t.file_dim, t.file_background), + (t.file_dim, t.file_primary), + ] { + assert!(super::contrast_ratio(ink, surface) >= 4.5, "dark={dark}: {ink:?} on {surface:?}"); + } + } + } + } + #[test] fn tab_accents_map_explicit_tokens_without_changing_model() { for dark in [false, true] { diff --git a/crates/ui-egui/src/theme_files.rs b/crates/ui-egui/src/theme_files.rs index 912ba3e48..3388a43e0 100644 --- a/crates/ui-egui/src/theme_files.rs +++ b/crates/ui-egui/src/theme_files.rs @@ -107,6 +107,9 @@ macro_rules! theme_keys { let Tokens { $($one: _,)* $($many: _,)* hover_face_lift: _, analysis: _, icons: _, + file_action_height: _, file_back_height: _, file_recovery_icon: _, file_grid_gap: _, + file_nav_width: _, file_nav_height: _, file_tile_height: _, file_tile_icon: _, file_recent_height: _, + file_sample_image_height: _, file_content_inset_x: _, file_content_inset_y: _, file_section_gap: _, font_start_title: _, space_2: _, space_3: _, space_4: _, space_6: _, space_8: _, space_10: _, space_12: _, space_14: _, space_16: _, space_24: _, radius_sm: _, radius_md: _, radius_lg: _, radius_xl: _, font_badge: _, font_micro: _, font_panel: _, font_small: _, @@ -124,6 +127,8 @@ macro_rules! theme_keys { theme_keys! { one: [ + file_dim, file_recovery_well, file_background, file_surface, file_border, file_image_tint, file_rail, file_rail_ink, file_rail_hover, + file_primary, file_primary_ink, file_primary_border, file_recovery, file_recovery_ink, file_recovery_border, app_bar, toolbar, panel, panel_header, border, text, text_dim, accent, accent_soft, sketch_accent, error, warning, icon, timeline, hover, sel_face, sel_edge, sel_edge_rim, hover_edge, hover_edge_halo, sel_profile, sel_profile_edge, hover_profile, hover_profile_edge, sel_vertex, origin_plane, origin_plane_edge, origin_plane_hover, diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index e9f0ec749..0ddbca259 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -630,8 +630,8 @@ fn file_menu(app: &mut SolveApp, ctx: &egui::Context) { } } -/// Whether the open design is on screen. Home hides it, so commands that act on it (save, -/// undo, insert, export, tool shortcuts) are off there. +/// Whether the design is on screen: viewport/menu editing stays disabled behind File. +/// File owns its explicit Save/Save As/export actions and returns to the design before dispatch. pub fn design_shown(app: &SolveApp) -> bool { !app.home.open } @@ -648,7 +648,7 @@ pub fn save(app: &mut SolveApp) { } } -fn save_as(app: &mut SolveApp) { +pub(crate) fn save_as(app: &mut SolveApp) { save_as_with_extension(app, solidcraft_engine::io::DESIGN_EXT); } @@ -679,7 +679,7 @@ fn download_design(app: &mut SolveApp) { } } -fn export(app: &mut SolveApp, ext: &str) { +pub(crate) fn export(app: &mut SolveApp, ext: &str) { export_as(app, ext, None); } @@ -2334,8 +2334,8 @@ mod home_tests { use super::*; /// Home hides the design: its Undo and Redo buttons, the File menu's Insert, Save - /// and Export, and the design's keyboard shortcuts leave it alone. They work again once - /// the design is back. + /// and Export, and CAD keyboard shortcuts leave it alone. File-view Save shortcuts + /// have their own regression coverage; viewport actions work again after returning. #[test] fn design_actions_are_off_on_home() { // A design with history both ways, a selection and unsaved changes, behind Home. @@ -2378,7 +2378,7 @@ mod home_tests { for icon in ["undo", "redo"] { actions.push((format!("{icon} button"), Box::new(move |h| click(h, &format!("appbar:{icon}"))))); } - for (key, cmd) in [("S", true), ("Z", true), ("Y", true), ("Delete", false), ("V", false), ("E", false), ("S", false)] { + for (key, cmd) in [("Z", true), ("Y", true), ("Delete", false), ("V", false), ("E", false), ("S", false)] { let name = if cmd { format!("Ctrl+{key}") } else { key.to_string() }; actions.push((name, Box::new(move |h| drop(h.call("ui.key", json!({"key": key, "cmd": cmd})))))); } @@ -2389,7 +2389,10 @@ mod home_tests { Box::new(move |h| { h.ctx.data_mut(|d| d.insert_temp(egui::Id::new("sc_file_menu"), false)); click(h, "appbar:folder"); - let _ = h.step(&json!({"widget": item})); + // A same-named File navigation action is now present: target the menu row explicitly. + if let Some(at) = crate::scenario::handle_at(&format!("menu:{item}")) { + h.call("ui.click", json!({"x":at.x,"y":at.y})); + } }), )); } diff --git a/crates/ui-egui/src/ui_kit/actions.rs b/crates/ui-egui/src/ui_kit/actions.rs index c9bcb6027..01c91e31e 100644 --- a/crates/ui-egui/src/ui_kit/actions.rs +++ b/crates/ui-egui/src/ui_kit/actions.rs @@ -249,23 +249,33 @@ pub(crate) fn button_pair(ui: &mut egui::Ui, key: &str, states: [bool; 2], butto (clicked.first().copied().unwrap_or(false), clicked.get(1).copied().unwrap_or(false)) } -/// Secondary button variants preserve native sizing and enabled-button translation. +/// Shared button variants preserve native sizing and enabled-button translation. +#[derive(Clone, Copy)] pub enum Button { Normal, + Primary, Small, Enabled(bool), } +fn button_widget(label: egui::WidgetText, options: Button) -> egui::Button<'static> { + let t = Tokens::get(); + match options { + Button::Small => egui::Button::new(label).small(), + Button::Primary => { + let ink = if crate::theme::contrast_ratio(t.on_accent, t.form_primary) >= 4.5 { t.on_accent } else { t.tab_on_fill_dark }; + egui::Button::new(label.color(ink)).fill(t.form_primary) + } + _ => egui::Button::new(label), + } +} + pub fn button(ui: &mut Ui, label: impl Into, options: Button) -> Response { let label = label.into(); let key = label.text().to_owned(); - let draw = |ui: &mut Ui, label| match options { - Button::Small => ui.small_button(label), - _ => ui.button(label), - }; let response = match options { - Button::Enabled(enabled) => ui.add_enabled_ui(enabled, |ui| draw(ui, crate::i18n::tr_label(&key).into())).inner, - _ => draw(ui, label), + Button::Enabled(enabled) => ui.add_enabled_ui(enabled, |ui| ui.add(button_widget(crate::i18n::tr_label(&key).into(), options))).inner, + _ => ui.add(button_widget(label, options)), }; pointer_on_hover(ui, &response); let key = if matches!(options, Button::Enabled(_)) { crate::i18n::tr_label(&key) } else { &key }; @@ -273,12 +283,34 @@ pub fn button(ui: &mut Ui, label: impl Into, options: Button) response } -/// Accent action outside the footer. Tokens: `accent, on_accent; scope tokens`. +/// The same button at an existing rectangle, with stable identity and centred native text. +/// Tokens: shared button colours; caller supplies its token-sized rectangle and optional typography. +pub(crate) fn button_at(ui: &mut Ui, id: &str, rect: egui::Rect, label: impl Into, options: Button) -> Response { + let label = label.into(); + let key = label.text().to_owned(); + let response = ui + .scope_builder( + egui::UiBuilder::new().id_salt(id).max_rect(rect).layout(egui::Layout::centered_and_justified(egui::Direction::LeftToRight)), + |ui| { + super::scope(ui, |ui| { + let draw = |ui: &mut Ui, label| ui.add_sized(rect.size(), button_widget(label, options)); + match options { + Button::Enabled(enabled) => ui.add_enabled_ui(enabled, |ui| draw(ui, crate::i18n::tr_label(&key).into())).inner, + _ => draw(ui, label), + } + }) + }, + ) + .inner; + pointer_on_hover(ui, &response); + publish_button(ui, &response, &key); + response +} + +/// Accent action outside the footer, using the same shared button component. #[cfg(any(not(target_arch = "wasm32"), test))] pub(crate) fn primary_button(ui: &mut Ui, label: &str) -> Response { - let t = Tokens::get(); - let response = ui.add(egui::Button::new(RichText::new(crate::i18n::tr_label(label)).color(t.on_accent)).fill(t.form_primary)); - pointer_on_hover(ui, &response); + let response = button(ui, crate::i18n::tr_label(label), Button::Primary); scenario::publish_target(&format!("dialog:button:{label}"), response.rect); response } diff --git a/crates/ui-egui/src/ui_kit/actions_tests.rs b/crates/ui-egui/src/ui_kit/actions_tests.rs index fe5f3f4f0..1f8a93322 100644 --- a/crates/ui-egui/src/ui_kit/actions_tests.rs +++ b/crates/ui-egui/src/ui_kit/actions_tests.rs @@ -72,3 +72,67 @@ fn enabled_buttons_show_the_pointing_hand_and_disabled_ones_do_not() { assert_eq!(frame_cursor(&ctx, cancel, &mut draw), egui::CursorIcon::PointingHand, "Cancel is always enabled"); } } + +#[test] +fn positioned_shared_buttons_center_text_and_respect_disabled_clicks_in_both_themes() { + use crate::theme::Tokens; + use egui::{Pos2, RawInput, Rect, RichText, Shape, vec2}; + let previous = crate::theme::is_dark(); + for dark in [false, true] { + crate::theme::set_dark(dark); + for enabled in [false, true] { + let ctx = crate::fonts::test_context(); + crate::theme::apply(&ctx); + let rects = + [Rect::from_min_size(egui::pos2(20.0, 30.0), vec2(108.0, 32.0)), Rect::from_min_size(egui::pos2(140.0, 30.0), vec2(108.0, 32.0))]; + let mut clicks = [0_usize; 2]; + let mut draw = |events| { + ctx.run_ui( + RawInput { screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(320.0, 200.0))), events, focused: true, ..Default::default() }, + |ui| { + ui.add_enabled_ui(enabled, |ui| { + for (index, (label, variant)) in [("Recover", Button::Primary), ("Discard", Button::Normal)].into_iter().enumerate() { + let response = button_at( + ui, + label, + rects[index], + RichText::new(label).font(crate::fonts::semibold(Tokens::get().font_button)), + variant, + ); + assert_eq!(response.rect, rects[index]); + assert_eq!(response.enabled(), enabled); + if response.clicked() { + clicks[index] += 1; + } + } + }); + }, + ) + }; + let output = draw(vec![]); + for (index, label) in ["Recover", "Discard"].into_iter().enumerate() { + let text = output + .shapes + .iter() + .find_map(|shape| match &shape.shape { + Shape::Text(text) if text.galley.job.text == label => Some(text), + _ => None, + }) + .expect("native button label is painted"); + if enabled && index == 0 { + let ink = text.galley.job.sections.first().expect("primary text format").format.color; + assert!(crate::theme::contrast_ratio(ink, Tokens::get().form_primary) >= 4.5, "primary label remains legible in both themes"); + } + let center = text.pos + text.galley.size() / 2.0; + assert!((center.x - rects[index].center().x).abs() <= 1.0, "{label} horizontal center: {center:?}"); + assert!((center.y - rects[index].center().y).abs() <= 1.0, "{label} vertical center: {center:?}"); + } + for rect in rects { + draw(pointer(rect.center(), true)); + draw(pointer(rect.center(), false)); + } + assert_eq!(clicks, if enabled { [1, 1] } else { [0, 0] }); + } + } + crate::theme::set_dark(previous); +} diff --git a/crates/ui-egui/src/ui_kit/file_view.rs b/crates/ui-egui/src/ui_kit/file_view.rs new file mode 100644 index 000000000..fe7226006 --- /dev/null +++ b/crates/ui-egui/src/ui_kit/file_view.rs @@ -0,0 +1,535 @@ +//! File/start presentation; callers retain commands, caches and recovery ownership. +use super::{metrics::dimension, text::paint_text}; +use crate::theme::Tokens; +use egui::{Align2, FontId, InnerResponse, Rect, Response, Sense, Stroke, TextureId, Ui, Vec2, pos2, vec2}; + +pub(crate) struct RecoveryMessage<'a> { + pub title: &'a str, + pub before_filename: &'a str, + pub filename: &'a str, + pub after_filename: &'a str, +} + +pub(crate) struct RecentRow<'a> { + pub title: &'a str, + pub path: &'a str, + pub when: &'a str, + pub workspace: &'a str, + pub thumbnail: Option<(TextureId, Vec2)>, +} + +#[derive(Clone, Copy)] +pub(crate) struct SampleCard<'a> { + pub title: &'a str, + pub description: &'a str, + pub icon: &'a str, + pub thumbnail: Option<(TextureId, Vec2)>, +} + +/// Shared start-page surfaces. Every allocation is bounded by the caller's width. +pub(crate) struct FileView; + +impl FileView { + pub(crate) fn page(ui: &mut Ui, add: impl FnOnce(&mut Ui) -> R) -> InnerResponse { + super::Container::new(ui.ctx(), super::Surface::Viewport) + .central() + .frame(super::Container::new(ui.ctx(), super::Surface::Viewport).edge_frame(Tokens::get().file_background)) + .show(ui, add) + } + + pub(crate) fn content(ui: &mut Ui, narrow: bool, add: impl FnOnce(&mut Ui) -> R) -> InnerResponse { + let t = Tokens::get(); + let inset = if narrow { t.space_16 } else { t.file_content_inset_x }; + egui::Frame::NONE.inner_margin(egui::Margin::symmetric(inset as i8, t.file_content_inset_y as i8)).show(ui, add) + } + + pub(crate) fn subtitle(ui: &mut Ui, text: &str) { + let t = Tokens::get(); + let galley = ui.painter().layout(text.to_owned(), FontId::proportional(t.font_heading), t.file_dim, dimension(ui.available_width())); + let (rect, _) = ui.allocate_exact_size(galley.size(), Sense::hover()); + ui.painter().galley(rect.min, galley, t.file_dim); + } + + pub(crate) fn detail(ui: &mut Ui, text: &str) { + let t = Tokens::get(); + let galley = ui.painter().layout(text.to_owned(), FontId::proportional(t.font_label), t.file_dim, dimension(ui.available_width())); + let (rect, _) = ui.allocate_exact_size(galley.size(), Sense::hover()); + ui.painter().galley(rect.min, galley, t.file_dim); + } + + pub(crate) fn section(ui: &mut Ui, title: &str, gap: f32, add: impl FnOnce(&mut Ui) -> R) -> InnerResponse { + ui.scope(|ui| { + ui.spacing_mut().item_spacing.y = 0.0; + Self::section_title(ui, title); + ui.add_space(dimension(gap)); + add(ui) + }) + } + + pub(crate) fn grid(ui: &mut Ui, id: &str, min_width: f32, count: usize, mut cell: impl FnMut(&mut Ui, usize, f32)) { + let t = Tokens::get(); + let gap = t.file_grid_gap; + let (columns, width) = grid_geometry(ui.available_width(), min_width, count); + ui.push_id(id, |ui| { + ui.spacing_mut().item_spacing.y = 0.0; + for row in (0..count).step_by(columns) { + if row > 0 { + ui.add_space(gap); + } + ui.horizontal_top(|ui| { + ui.spacing_mut().item_spacing.x = gap; + for index in row..(row + columns).min(count) { + ui.scope_builder( + egui::UiBuilder::new() + .max_rect(Rect::from_min_size(ui.next_widget_position(), vec2(width, 0.0))) + .layout(egui::Layout::top_down(egui::Align::Min)), + |ui| { + ui.set_width(width); + cell(ui, index, width); + }, + ); + } + }); + } + }); + } + + pub(crate) fn recent_list(ui: &mut Ui, add: impl FnOnce(&mut Ui) -> R) -> InnerResponse { + let t = Tokens::get(); + egui::Frame::NONE.fill(t.file_surface).stroke(Stroke::new(1.0, t.file_border)).corner_radius(t.radius_xl).show(ui, |ui| { + ui.spacing_mut().item_spacing.y = 0.0; + let key = ui.id().with("file_recent_index"); + ui.ctx().data_mut(|data| data.insert_temp(key, 0_usize)); + let result = add(ui); + ui.ctx().data_mut(|data| data.remove::(key)); + result + }) + } + + pub(crate) fn title(ui: &mut Ui, title: &str) { + let t = Tokens::get(); + let galley = ui.painter().layout_no_wrap(title.to_owned(), crate::fonts::semibold(t.font_start_title), t.form_ink); + let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), galley.size().y), Sense::hover()); + ui.painter().with_clip_rect(ui.clip_rect().intersect(rect)).galley(rect.min, galley, t.form_ink); + } + + pub(crate) fn section_title(ui: &mut Ui, title: &str) { + let t = Tokens::get(); + let galley = ui.painter().layout_no_wrap(title.to_owned(), crate::fonts::semibold(t.font_intro), t.form_ink); + let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), galley.size().y), Sense::hover()); + ui.painter().with_clip_rect(ui.clip_rect().intersect(rect)).galley(rect.min, galley, t.form_ink); + } + + pub(crate) fn tile_min_width() -> f32 { + Tokens::get().form_card_width - Tokens::get().space_24 + } + pub(crate) fn sample_min_width() -> f32 { + Tokens::get().file_nav_width - Tokens::get().file_tile_height + } + + pub(crate) fn rail(ui: &mut Ui, rect: Rect, add: impl FnOnce(&mut Ui) -> R) -> InnerResponse { + ui.scope_builder(egui::UiBuilder::new().max_rect(rect).layout(egui::Layout::top_down(egui::Align::Min)), |ui| { + ui.set_clip_rect(ui.clip_rect().intersect(rect)); + ui.painter().rect_filled(rect, 0, Tokens::get().file_rail); + Self::navigation(ui, add).inner + }) + } + + pub(crate) fn navigation(ui: &mut Ui, add: impl FnOnce(&mut Ui) -> R) -> InnerResponse { + let t = Tokens::get(); + egui::Frame::NONE.fill(t.file_rail).inner_margin(egui::Margin::symmetric(t.space_10 as i8, t.space_14 as i8)).show(ui, |ui| { + ui.spacing_mut().item_spacing.y = t.space_2; + add(ui) + }) + } + + pub(crate) fn nav_row(ui: &mut Ui, id: &str, label: &str, shortcut: &str, selected: bool, enabled: bool) -> Response { + let t = Tokens::get(); + ui.add_enabled_ui(enabled, |ui| { + let (rect, response) = allocate(ui, id, ui.available_width(), t.file_nav_height, label); + if selected || response.hovered() || response.has_focus() { + ui.painter().rect_filled(rect, t.radius_lg, t.file_rail_hover); + } + let inner = rect.shrink2(vec2(t.space_12, 0.0)); + let key_width = + ui.painter().layout_no_wrap(shortcut.to_owned(), FontId::monospace(t.font_small), t.file_rail_ink).size().x.min(inner.width()); + let label_rect = Rect::from_min_max(inner.min, pos2((inner.right() - key_width - t.space_8).max(inner.left()), inner.bottom())); + let ink = if ui.is_enabled() { t.file_rail_ink } else { t.file_rail_ink.gamma_multiply(0.5) }; + paint_text( + ui, + label_rect, + label, + if selected { crate::fonts::semibold(t.font_heading) } else { FontId::proportional(t.font_heading) }, + ink, + false, + ); + paint_text( + ui, + Rect::from_min_max(pos2(inner.right() - key_width, inner.top()), inner.max), + shortcut, + FontId::monospace(t.font_small), + ink, + false, + ); + response + }) + .inner + } + + pub(crate) fn back_to(ui: &mut Ui, id: &str, template: &str, document: &str, shortcut: &str) -> Response { + let t = Tokens::get(); + let (rect, response) = allocate(ui, id, ui.available_width(), t.file_back_height, &template.replace("{name}", document)); + if response.hovered() || response.has_focus() { + ui.painter().rect_filled(rect, t.radius_lg, t.file_rail_hover); + } + let inner = rect.shrink2(vec2(t.space_12, 0.0)); + let icon = Rect::from_center_size(pos2(inner.left() + t.form_icon_size / 2.0, inner.center().y), Vec2::splat(t.form_icon_size)); + crate::icons::paint_ink_mirrored(ui.painter(), icon, "chevron_right", t.file_rail_ink); + let key = ui.painter().layout_no_wrap(shortcut.to_owned(), FontId::monospace(t.font_small), t.file_rail_ink); + let key_rect = Rect::from_center_size( + pos2(inner.right() - (key.size().x + t.space_10) / 2.0, inner.center().y), + key.size() + vec2(t.space_10, t.space_4), + ); + ui.painter().rect_stroke(key_rect, t.radius_sm, Stroke::new(1.0, t.file_rail_ink.gamma_multiply(0.5)), egui::StrokeKind::Inside); + paint_text(ui, key_rect.shrink2(vec2(t.space_4, 0.0)), shortcut, FontId::monospace(t.font_small), t.file_rail_ink, false); + let (before, after) = template.split_once("{name}").unwrap_or((template, "")); + let mut job = egui::text::LayoutJob::default(); + for (text, font) in [ + (before, FontId::proportional(t.font_button)), + (document, crate::fonts::semibold(t.font_button)), + (after, FontId::proportional(t.font_button)), + ] { + job.append(text, 0.0, egui::TextFormat::simple(font, t.file_rail_ink)); + } + let text_rect = Rect::from_min_max( + pos2(icon.right() + t.space_10, inner.top()), + pos2((key_rect.left() - t.space_8).max(icon.right() + t.space_10), inner.bottom()), + ); + job.wrap.max_width = text_rect.width(); + job.wrap.max_rows = 1; + let galley = ui.fonts_mut(|fonts| fonts.layout_job(job)); + ui.painter().with_clip_rect(ui.clip_rect().intersect(text_rect)).galley( + pos2(text_rect.left(), text_rect.center().y - galley.size().y / 2.0), + galley, + t.file_rail_ink, + ); + ui.add_space(t.space_10); + response + } + + pub(crate) fn separator(ui: &mut Ui) { + let t = Tokens::get(); + ui.add_space(t.space_10); + let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), 1.0), Sense::hover()); + ui.painter().hline( + (rect.left() + t.space_12)..=(rect.right() - t.space_12).max(rect.left() + t.space_12), + rect.center().y, + Stroke::new(1.0, t.file_rail_ink.gamma_multiply(0.25)), + ); + ui.add_space(t.space_10); + } + + pub(crate) fn action_tile(ui: &mut Ui, id: &str, width: f32, icon: &str, label: &str, subtitle: &str, primary: bool) -> Response { + let t = Tokens::get(); + let (rect, response) = allocate(ui, id, width, t.file_tile_height, label); + card(ui, rect, &response, primary); + let inner = rect.shrink(t.space_16); + let icon_size = t.file_tile_icon.min(inner.height()).min(inner.width()); + let icon_rect = Rect::from_center_size(pos2(inner.left() + icon_size / 2.0, inner.center().y), Vec2::splat(icon_size)); + crate::icons::paint_accented(ui.painter(), icon_rect, icon, None, if ui.is_enabled() { 1.0 } else { 0.45 }); + let text_rect = Rect::from_min_max(pos2((icon_rect.right() + t.space_14).min(inner.right()), inner.top()), inner.max); + let ink = if primary { t.file_primary_ink } else { t.form_ink }; + let mut title_job = egui::text::LayoutJob::simple(label.to_owned(), crate::fonts::semibold(t.font_heading), ink, text_rect.width()); + title_job.wrap.max_rows = 1; + let title = ui.fonts_mut(|fonts| fonts.layout_job(title_job)); + let mut caption_job = egui::text::LayoutJob::simple(subtitle.to_owned(), FontId::proportional(t.font_label), t.file_dim, text_rect.width()); + caption_job.wrap.max_rows = 2; + let caption = ui.fonts_mut(|fonts| fonts.layout_job(caption_job)); + let group_height = title.size().y + t.space_2 + caption.size().y; + let top = text_rect.center().y - group_height / 2.0; + let painter = ui.painter().with_clip_rect(ui.clip_rect().intersect(text_rect)); + painter.galley(pos2(text_rect.left(), top), title.clone(), ink); + painter.galley(pos2(text_rect.left(), top + title.size().y + t.space_2), caption, t.file_dim); + response.on_hover_text(format!("{label}\n{subtitle}")) + } + + pub(crate) fn recent_row(ui: &mut Ui, id: &str, row: RecentRow<'_>) -> Response { + let t = Tokens::get(); + let (rect, response) = allocate(ui, id, ui.available_width(), t.file_recent_height, row.title); + if response.hovered() || response.has_focus() { + ui.painter().rect_filled(rect, t.radius_lg, t.hover); + } + let list = ui.stack().iter().find_map(|node| { + let key = node.id.with("file_recent_index"); + ui.ctx().data(|data| data.get_temp::(key)).map(|index| (key, index)) + }); + if let Some((key, index)) = list { + if index > 0 { + ui.painter().hline(rect.x_range(), rect.top(), Stroke::new(1.0, t.file_border)); + } + ui.ctx().data_mut(|data| data.insert_temp(key, index.saturating_add(1))); + } + let inner = rect.shrink2(vec2(t.space_14, t.space_8)); + let preview = Rect::from_min_size(inner.min, vec2(t.space_24 * 2.0, inner.height()).min(inner.size())); + thumbnail(ui, preview, row.thumbnail); + if row.thumbnail.is_none() { + crate::icons::paint_accented( + ui.painter(), + Rect::from_center_size(preview.center(), Vec2::splat(t.space_24.min(preview.height()))), + "box", + None, + 1.0, + ); + } + let left = (preview.right() + t.space_14).min(inner.right()); + let content = Rect::from_min_max(pos2(left, inner.top()), inner.max); + // At narrow widths the same row keeps title and path, leaving optional metadata out. + if content.width() < t.form_card_width * 2.0 { + let half = content.center().y; + paint_text( + ui, + Rect::from_min_max(content.min, pos2(content.right(), half)), + row.title, + crate::fonts::medium(t.font_button), + t.form_ink, + false, + ); + paint_text(ui, Rect::from_min_max(pos2(left, half), content.max), row.path, FontId::monospace(t.font_body), t.file_dim, false); + } else { + let when_width = t.space_24 * 5.0; + let workspace_width = t.form_label_width * 2.0; + let remaining = (content.width() - when_width - workspace_width - t.space_14 * 3.0).max(0.0); + let title_width = remaining * 0.4; + let path_left = left + title_width + t.space_14; + let when_left = content.right() - workspace_width - t.space_14 - when_width; + let workspace_left = content.right() - workspace_width; + paint_text( + ui, + Rect::from_min_max(content.min, pos2(left + title_width, content.bottom())), + row.title, + crate::fonts::medium(t.font_button), + t.form_ink, + false, + ); + paint_text( + ui, + Rect::from_min_max(pos2(path_left, content.top()), pos2((when_left - t.space_14).max(path_left), content.bottom())), + row.path, + FontId::monospace(t.font_body), + t.file_dim, + false, + ); + paint_text( + ui, + Rect::from_min_max(pos2(when_left, content.top()), pos2(when_left + when_width, content.bottom())), + row.when, + FontId::proportional(t.font_label), + t.file_dim, + false, + ); + ui.painter().circle_filled(pos2(workspace_left + t.space_4, content.center().y), t.space_4, t.file_rail); + paint_text( + ui, + Rect::from_min_max(pos2(workspace_left + t.space_8 + t.space_6, content.top()), content.max), + row.workspace, + FontId::proportional(t.font_label), + t.file_dim, + false, + ); + } + response.on_hover_text(row.path) + } + + pub(crate) fn sample_grid(ui: &mut Ui, id: &str, samples: &[SampleCard<'_>]) -> Vec { + let (columns, width) = grid_geometry(ui.available_width(), Self::sample_min_width(), samples.len()); + let heights: Vec = + samples.chunks(columns).map(|row| row.iter().map(|sample| sample_height(ui, width, sample)).fold(0.0, f32::max)).collect(); + let mut responses = Vec::with_capacity(samples.len()); + Self::grid(ui, id, Self::sample_min_width(), samples.len(), |ui, index, width| { + if let Some(sample) = samples.get(index) { + let height = heights.get(index / columns).copied().unwrap_or(0.0); + responses.push(sample_card_with_height(ui, &format!("{id}:{index}"), width, sample, height)); + } + }); + responses + } + + pub(crate) fn recovery_banner( + ui: &mut Ui, + id: &str, + message: RecoveryMessage<'_>, + recover: &str, + discard: Option<&str>, + ) -> (Response, Option) { + recovery_panel(ui, id, message, recover, discard, true) + } + + pub(crate) fn recovery_review(ui: &mut Ui, id: &str, title: &str, detail: &str, recover: &str, discard: &str) -> (Response, Option) { + let separated = format!("\n{}", detail.trim_start()); + recovery_panel( + ui, + id, + RecoveryMessage { title, before_filename: &separated, filename: "", after_filename: "" }, + recover, + Some(discard), + false, + ) + } +} + +fn allocate(ui: &mut Ui, id: &str, width: f32, height: f32, label: &str) -> (Rect, Response) { + let (rect, _) = ui.allocate_exact_size(vec2(dimension(width).min(dimension(ui.available_width())), height), Sense::hover()); + let response = ui.interact(rect, ui.make_persistent_id(id), Sense::click()); + response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label)); + if response.clicked() { + response.request_focus(); + } + if response.enabled() && response.hovered() { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + (rect, response) +} + +fn card(ui: &Ui, rect: Rect, response: &Response, primary: bool) { + let t = Tokens::get(); + let fill = if primary { + t.file_primary + } else if response.hovered() || response.has_focus() { + t.hover + } else { + t.file_surface + }; + let border = if primary || response.has_focus() { t.file_primary_border } else { t.file_border }; + ui.painter().rect(rect, t.radius_xl, fill, Stroke::new(if primary { 1.5 } else { 1.0 }, border), egui::StrokeKind::Inside); +} + +fn thumbnail(ui: &Ui, rect: Rect, texture: Option<(TextureId, Vec2)>) { + let t = Tokens::get(); + ui.painter().rect(rect, t.radius_md, t.file_surface, Stroke::new(1.0, t.file_border), egui::StrokeKind::Inside); + if let Some((texture, size)) = texture.filter(|(_, size)| size.is_finite() && size.x > 0.0 && size.y > 0.0) { + let scale = (rect.width() / size.x).min(rect.height() / size.y); + let target = Align2::CENTER_CENTER.align_size_within_rect(size * scale, rect); + ui.painter().image(texture, target, Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)), t.file_image_tint); + } +} + +fn recovery_panel( + ui: &mut Ui, + id: &str, + message: RecoveryMessage<'_>, + recover: &str, + discard: Option<&str>, + banner: bool, +) -> (Response, Option) { + let t = Tokens::get(); + let fill = if banner { t.file_recovery } else { t.file_surface }; + let border = if banner { t.file_recovery_border } else { t.file_border }; + egui::Frame::NONE + .fill(fill) + .stroke(Stroke::new(1.0, border)) + .corner_radius(t.radius_xl) + .inner_margin(egui::Margin::symmetric(t.space_16 as i8, t.space_12 as i8)) + .show(ui, |ui| { + let width = dimension(ui.available_width()); + let button_width = |text: &str| { + ui.painter().layout_no_wrap(text.to_owned(), crate::fonts::semibold(t.font_heading), t.form_ink).size().x + t.space_14 * 2.0 + }; + let recover_width = button_width(recover); + let discard_width = discard.map_or(0.0, button_width); + let actions_width = recover_width + if discard.is_some() { t.space_8 + discard_width } else { 0.0 }; + let icon_width = if banner { t.file_recovery_icon + t.space_14 } else { 0.0 }; + let wrapped = width < icon_width + t.form_card_width + actions_width + t.space_14; + let text_width = (width - icon_width - if wrapped { 0.0 } else { actions_width + t.space_14 }).max(0.0); + let mut job = egui::text::LayoutJob::default(); + for (text, font) in [ + (message.title, crate::fonts::semibold(t.font_button)), + (message.before_filename, FontId::proportional(t.font_button)), + (message.filename, FontId::monospace(t.font_button)), + (message.after_filename, FontId::proportional(t.font_button)), + ] { + job.append(text, 0.0, egui::TextFormat::simple(font, t.form_ink)); + } + job.wrap.max_width = text_width; + let galley = ui.fonts_mut(|fonts| fonts.layout_job(job)); + let top_height = + galley.size().y.max(if banner { t.file_recovery_icon } else { 0.0 }).max(if wrapped { 0.0 } else { t.file_action_height }); + let height = top_height + if wrapped { t.space_12 + t.file_action_height } else { 0.0 }; + let (rect, _) = ui.allocate_exact_size(vec2(width, height), Sense::hover()); + if banner { + let well = + Rect::from_min_size(pos2(rect.left(), rect.top() + (top_height - t.file_recovery_icon) / 2.0), Vec2::splat(t.file_recovery_icon)); + ui.painter().rect_filled(well, t.radius_lg, t.file_recovery_well); + crate::icons::paint_accented(ui.painter(), well.shrink(t.space_6), "status_recovery", Some("construction"), 1.0); + } + let text_at = pos2(rect.left() + icon_width, rect.top() + (top_height - galley.size().y) / 2.0); + ui.painter().with_clip_rect(ui.clip_rect().intersect(rect)).galley(text_at, galley, t.form_ink); + let action_top = if wrapped { rect.bottom() - t.file_action_height } else { rect.top() + (top_height - t.file_action_height) / 2.0 }; + let action_left = if wrapped { rect.left() } else { rect.right() - actions_width }; + let scale = if wrapped { (width / actions_width).min(1.0) } else { 1.0 }; + let recover_rect = Rect::from_min_size(pos2(action_left, action_top), vec2(recover_width * scale, t.file_action_height)); + let discard_rect = + Rect::from_min_size(pos2(recover_rect.right() + t.space_8 * scale, action_top), vec2(discard_width * scale, t.file_action_height)); + let a = super::actions::button_at( + ui, + &format!("{id}:recover"), + recover_rect, + egui::RichText::new(recover).font(crate::fonts::semibold(t.font_heading)), + super::actions::Button::Primary, + ); + let b = discard.map(|label| { + super::actions::button_at( + ui, + &format!("{id}:discard"), + discard_rect, + egui::RichText::new(label).font(FontId::proportional(t.font_heading)), + super::actions::Button::Normal, + ) + }); + (a, b) + }) + .inner +} + +fn grid_geometry(available: f32, min_width: f32, count: usize) -> (usize, f32) { + let gap = Tokens::get().file_grid_gap; + let available = dimension(available); + let columns = (((available + gap) / (dimension(min_width).max(1.0) + gap)).floor() as usize).max(1).min(count.max(1)); + let width = ((available - gap * columns.saturating_sub(1) as f32) / columns as f32).max(0.0); + (columns, width) +} + +fn sample_height(ui: &Ui, width: f32, sample: &SampleCard<'_>) -> f32 { + let t = Tokens::get(); + let inner_width = (dimension(width) - t.space_10 * 2.0).max(0.0); + let title = ui.painter().layout(sample.title.to_owned(), crate::fonts::semibold(t.font_button), t.form_ink, inner_width); + let description = ui.painter().layout(sample.description.to_owned(), FontId::proportional(t.font_body), t.file_dim, inner_width); + t.file_sample_image_height + t.space_10 * 2.0 + t.space_8 * 2.0 + title.size().y + description.size().y +} + +fn sample_card_with_height(ui: &mut Ui, id: &str, width: f32, sample: &SampleCard<'_>, min_height: f32) -> Response { + let t = Tokens::get(); + let inner_width = (dimension(width).min(dimension(ui.available_width())) - t.space_10 * 2.0).max(0.0); + let title = ui.painter().layout(sample.title.to_owned(), crate::fonts::semibold(t.font_button), t.form_ink, inner_width); + let description = ui.painter().layout(sample.description.to_owned(), FontId::proportional(t.font_body), t.file_dim, inner_width); + let height = sample_height(ui, width, sample).max(min_height); + let (rect, response) = allocate(ui, id, width, height, sample.title); + card(ui, rect, &response, false); + let inner = rect.shrink(t.space_10); + let image = Rect::from_min_size(inner.min, vec2(inner.width(), t.file_sample_image_height)); + thumbnail(ui, image, sample.thumbnail); + if sample.thumbnail.is_none() { + crate::icons::paint_accented( + ui.painter(), + Rect::from_center_size(image.center(), Vec2::splat(t.file_tile_icon.min(image.width()))), + sample.icon, + None, + 1.0, + ); + } + let painter = ui.painter().with_clip_rect(ui.clip_rect().intersect(inner)); + let title_top = image.bottom() + t.space_8; + let description_top = title_top + title.size().y + t.space_8; + painter.galley(pos2(inner.left(), title_top), title, t.form_ink); + painter.galley(pos2(inner.left(), description_top), description, t.file_dim); + response.on_hover_text(sample.description) +} diff --git a/crates/ui-egui/src/ui_kit/gallery.rs b/crates/ui-egui/src/ui_kit/gallery.rs index 787f036c9..03e4db861 100644 --- a/crates/ui-egui/src/ui_kit/gallery.rs +++ b/crates/ui-egui/src/ui_kit/gallery.rs @@ -170,6 +170,75 @@ const ELEMENTS: &[Element] = &[ element!("history_seam_drag", |ui, _| history_seam_example(ui, HistoryHandleState::Drag)), element!("history_icons", |ui, _| history_example(ui, false)), element!("history_names", |ui, _| history_example(ui, true)), + element!("file_navigation", |ui, _| { + FileView::navigation(ui, |ui| { + FileView::back_to(ui, "gallery:file:back", "Back to {name}", "Sample Plate", "Esc"); + FileView::nav_row(ui, "gallery:file:start", "Start", "", true, true); + FileView::nav_row(ui, "gallery:file:open", "Open", "Ctrl+O", false, true); + FileView::separator(ui); + FileView::nav_row(ui, "gallery:file:save", "Save", "Ctrl+S", false, false); + }); + }), + element!("file_action", |ui, _| { + FileView::action_tile(ui, "gallery:file:new", ui.available_width(), "new", "New design", "Millimetres · opens in Design", true); + }), + element!("file_recovery_banner", |ui, _| { + FileView::recovery_banner( + ui, + "gallery:recovery", + super::file_view::RecoveryMessage { + title: "1 design was recovered", + before_filename: " after SolidCraft closed unexpectedly: ", + filename: "enclosure-lid.solidcraft", + after_filename: ", 2 minutes ago.", + }, + "Recover", + Some("Discard"), + ); + }), + element!("file_recovery_review", |ui, _| { + FileView::recovery_review(ui, "gallery:recovery-review", "Sample Plate", " · 14 features · 2 minutes ago", "Recover", "Discard"); + }), + element!("file_recent_list", |ui, _| { + FileView::recent_list(ui, |ui| { + for id in ["first", "second"] { + FileView::recent_row( + ui, + id, + RecentRow { + title: "Sample Plate", + path: "Designs/sample-plate.solidcraft", + when: "Open now", + workspace: "Design", + thumbnail: None, + }, + ); + } + }); + }), + element!("file_recent", |ui, _| { + FileView::recent_row( + ui, + "gallery:file:recent", + RecentRow { title: "Sample Plate", path: "Designs/sample-plate.solidcraft", when: "Open now", workspace: "Design", thumbnail: None }, + ); + }), + element!("file_sample", |ui, _| { + FileView::sample_grid( + ui, + "gallery:file:sample", + &[SampleCard { title: "Sample Plate", description: "Parametric plate with holes and a bored boss", icon: "new", thumbnail: None }], + ); + }), + element!("file_recovery", |ui, _| { + FileView::recovery_banner( + ui, + "gallery:recovery-summary", + super::file_view::RecoveryMessage { title: "2 designs have unsaved changes", before_filename: "", filename: "", after_filename: "" }, + "Review", + None, + ); + }), element!("command_search", |ui, _| { let mut query = "fillet".to_owned(); CommandSearch::field( @@ -769,6 +838,11 @@ const ELEMENTS: &[Element] = &[ button(ui, "Add", Button::Normal); }); }), + element!("button_at", |ui, _| { + let t = Tokens::get(); + let (rect, _) = ui.allocate_exact_size(vec2(t.space_24 * 5.0, t.file_action_height), egui::Sense::hover()); + button_at(ui, "gallery:button_at", rect, "Recover", Button::Primary); + }), element!("small_button", "dialog:row:Gallery", Some("dialog:button:Gallery:×"), |ui, _| { row(ui, "Gallery", |ui| { button(ui, "×", Button::Small); @@ -1690,3 +1764,67 @@ fn command_search_ribbon_transition_clips_content_in_both_themes() { } crate::theme::set_dark(previous); } + +/// Opt-in CPU capture of the actual File view, with public temporary fixtures only. +#[test] +#[ignore = "set SOLIDCRAFT_FILE_EVIDENCE to an output directory and run explicitly"] +fn file_view_application_evidence_in_both_themes_and_widths() { + use super::checks::tests::{raster, textures_update}; + use std::collections::HashMap; + let output_dir = std::path::PathBuf::from(std::env::var("SOLIDCRAFT_FILE_EVIDENCE").expect("set SOLIDCRAFT_FILE_EVIDENCE")); + std::fs::create_dir_all(&output_dir).unwrap(); + let fixture_dir = std::env::temp_dir().join(format!("solidcraft-file-evidence-{}", std::process::id())); + std::fs::create_dir_all(&fixture_dir).unwrap(); + let path = fixture_dir.join("sample-plate.solidcraft"); + let fixture = path.to_string_lossy().to_string(); + let mut sample = crate::test_support::sample_app(); + sample.session.execute("file.save_as", &serde_json::json!({"path":fixture})).unwrap(); + let previous = crate::theme::is_dark(); + for dark in [false, true] { + for (name, size) in [("desktop", vec2(1440.0, 1000.0)), ("narrow", vec2(420.0, 1000.0))] { + let ctx = crate::fonts::test_context(); + let mut app = crate::test_support::sample_app(); + app.home.show(0); + app.home.add_recent(&fixture); + app.session.path = Some(fixture.clone()); + let preview = image::load_from_memory(include_bytes!("../../../../assets/samples/exports/0.png")).unwrap().to_rgba8(); + let preview = egui::ColorImage::from_rgba_unmultiplied([preview.width() as usize, preview.height() as usize], preview.as_raw()); + crate::home::install(&mut app.home, &ctx, &fixture, Some(preview)); + app.preferences.theme = if dark { "dark" } else { "light" }.into(); + app.ui.dark = dark; + app.recoverable.push(solidcraft_engine::recovery::Entry { + id: "public-evidence".into(), + path: Some("enclosure-lid.solidcraft".into()), + name: "Enclosure lid".into(), + saved_at: web_time::SystemTime::now().duration_since(web_time::UNIX_EPOCH).unwrap().as_secs().saturating_sub(120), + features: 14, + }); + crate::theme::set_dark(dark); + crate::theme::apply(&ctx); + let bounds = egui::Rect::from_min_size(egui::Pos2::ZERO, size); + let mut textures = HashMap::new(); + for frame in 0..6 { + let mut input = + egui::RawInput { screen_rect: Some(bounds), time: Some(f64::from(frame) / 60.0), focused: true, ..Default::default() }; + app.raw_input_hook(&mut input); + let mut output = ctx.run_ui(input, |ui| { + app.logic(ui.ctx()); + app.ui(ui); + }); + textures_update(&mut textures, &output.textures_delta); + if frame == 5 { + assert!(app.home.open); + let page = scenario::rect_of("home:page").expect("actual File view allocation"); + assert!(bounds.contains_rect(page)); + raster(&ctx, output.shapes.clone(), output.pixels_per_point, bounds, &textures) + .save(output_dir.join(format!("file-{name}-{}.png", if dark { "dark" } else { "light" }))) + .unwrap(); + } + output.textures_delta.clear(); + } + } + } + crate::theme::set_dark(previous); + std::fs::remove_file(path).unwrap(); + std::fs::remove_dir(fixture_dir).unwrap(); +} diff --git a/crates/ui-egui/src/ui_kit/metrics_tests.rs b/crates/ui-egui/src/ui_kit/metrics_tests.rs index 62f696d19..963642f9e 100644 --- a/crates/ui-egui/src/ui_kit/metrics_tests.rs +++ b/crates/ui-egui/src/ui_kit/metrics_tests.rs @@ -21,3 +21,106 @@ fn non_finite_and_tiny_row_widths_are_sanitized() { assert!(scenario::rect_of("dialog:row:Tiny").unwrap().is_finite()); } } + +#[test] +fn file_tiles_are_fixed_height_bounded_and_disabled_actions_stay_inert() { + let ctx = crate::fonts::test_context(); + for width in [80.0, 264.0, 680.0] { + frame(&ctx, vec![], |ui| { + ui.set_width(width); + let tile = FileView::action_tile(ui, "file:new", width, "new", "New design", "Millimetres", true); + assert_eq!(tile.rect.height(), crate::theme::Tokens::get().file_tile_height); + assert!(tile.rect.width() <= width); + let row = FileView::nav_row(ui, "file:save", "Save", "Ctrl+S", false, false); + assert!(!row.enabled()); + assert!(!row.clicked()); + assert_eq!(row.rect.height(), crate::theme::Tokens::get().file_nav_height); + }); + } +} + +#[test] +fn file_grid_has_only_between_row_gaps_and_recovery_actions_fit_narrow_widths() { + let ctx = crate::fonts::test_context(); + frame(&ctx, vec![], |ui| { + ui.set_width(280.0); + let mut rects = Vec::new(); + ui.spacing_mut().item_spacing.y = 0.0; + let before = ui.cursor().top(); + FileView::grid(ui, "grid", 240.0, 2, |ui, _, width| { + rects.push(FileView::action_tile(ui, "tile", width, "new", "New", "Millimetres", true).rect); + }); + assert!((rects[1].top() - rects[0].bottom() - crate::theme::Tokens::get().file_grid_gap).abs() < 0.1); + assert!( + (ui.cursor().top() - before - 2.0 * crate::theme::Tokens::get().file_tile_height - crate::theme::Tokens::get().file_grid_gap).abs() < 0.1 + ); + let (recover, discard) = FileView::recovery_banner( + ui, + "recovery", + crate::ui_kit::file_view::RecoveryMessage { + title: "Recovered", + before_filename: " ", + filename: "enclosure.solidcraft", + after_filename: " · just now", + }, + "Recover", + Some("Discard"), + ); + let discard = discard.expect("single-entry banner has discard"); + assert!(!recover.rect.intersects(discard.rect)); + assert!(recover.rect.is_positive() && discard.rect.is_positive()); + assert!(recover.rect.left() >= ui.min_rect().left()); + assert!(discard.rect.right() <= ui.max_rect().right()); + }); +} + +#[test] +fn file_grid_cells_use_vertical_layout_even_inside_a_horizontal_parent() { + let ctx = crate::fonts::test_context(); + frame(&ctx, vec![], |ui| { + ui.set_width(680.0); + let mut rects = Vec::new(); + FileView::grid(ui, "aligned", 240.0, 2, |ui, index, width| { + rects.push(FileView::action_tile(ui, &format!("tile-{index}"), width, "new", "New", "Millimetres", true).rect); + }); + assert!((rects[0].top() - rects[1].top()).abs() < 0.1); + let (_, discard) = FileView::recovery_banner( + ui, + "summary", + crate::ui_kit::file_view::RecoveryMessage { title: "2 designs recovered", before_filename: "", filename: "", after_filename: "" }, + "Review", + None, + ); + assert!(discard.is_none(), "a summary cannot discard an arbitrary design"); + }); +} + +#[test] +fn sample_grid_stretches_each_row_without_clipping_long_descriptions() { + let ctx = crate::fonts::test_context(); + let mut cards = Vec::new(); + let output = ctx.run_ui( + egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(680.0, 600.0))), ..Default::default() }, + |ui| { + ui.set_width(680.0); + cards = FileView::sample_grid(ui, "samples", &[ + SampleCard { title: "Plate", description: "Short description", icon: "new", thumbnail: None }, + SampleCard { title: "Enclosure", description: "Long descriptive sample text that wraps across several lines while preserving every word through the final marker.", icon: "new", thumbnail: None }, + ]); + }, + ); + assert_eq!(cards.len(), 2); + assert!((cards[0].rect.top() - cards[1].rect.top()).abs() < 0.1); + assert!((cards[0].rect.bottom() - cards[1].rect.bottom()).abs() < 0.1); + let long = output + .shapes + .iter() + .find_map(|shape| match &shape.shape { + egui::Shape::Text(text) if text.galley.job.text.contains("final marker") => Some((shape.clip_rect, text)), + _ => None, + }) + .expect("the entire description is painted"); + let text_rect = egui::Rect::from_min_size(long.1.pos, long.1.galley.size()); + assert!(cards[1].rect.contains_rect(text_rect)); + assert!(long.0.contains_rect(text_rect), "the complete description must fit its clip"); +} diff --git a/crates/ui-egui/src/ui_kit/mod.rs b/crates/ui-egui/src/ui_kit/mod.rs index a4f40fb3a..c1e5eaddd 100644 --- a/crates/ui-egui/src/ui_kit/mod.rs +++ b/crates/ui-egui/src/ui_kit/mod.rs @@ -11,6 +11,7 @@ mod confirm; pub mod container; mod disclosure; mod fields; +mod file_view; mod history; mod layout; mod menu; @@ -35,6 +36,7 @@ pub use container::{Container, DockEdges, Edge, Surface}; pub(crate) use disclosure::*; pub use fields::cell_editor; pub(crate) use fields::*; +pub(crate) use file_view::{FileView, RecentRow, RecoveryMessage, SampleCard}; pub(crate) use history::*; pub(crate) use layout::*; pub(crate) use menu::{Menu, MenuItem, rename_menu, workspace_menu}; diff --git a/crates/ui-egui/tests/icon_audit.rs b/crates/ui-egui/tests/icon_audit.rs index f931c1db0..3e61864b3 100644 --- a/crates/ui-egui/tests/icon_audit.rs +++ b/crates/ui-egui/tests/icon_audit.rs @@ -370,6 +370,13 @@ fn requested_menu_icons_have_artwork_and_match_manifest() { let path = geometry.dir.join("audit.solidcraft"); geometry.app.run("file.save", json!({"path":path})).unwrap(); geometry.app.home.recent = vec![path.to_string_lossy().into_owned()]; + geometry.app.recoverable.push(solidcraft_engine::recovery::Entry { + id: "icon-audit".into(), + path: Some("audit.solidcraft".into()), + name: "Audit design".into(), + saved_at: 0, + features: 1, + }); geometry.app.home.open = true; geometry.frames(3); context_rows(&mut geometry, "home:recent:", &mut requested); diff --git a/docs/manage-ui-kit-audit.md b/docs/manage-ui-kit-audit.md index b13b4ac56..4f4c0a79b 100644 --- a/docs/manage-ui-kit-audit.md +++ b/docs/manage-ui-kit-audit.md @@ -14,7 +14,7 @@ These specialised contents remain in their owners: | Surface / source | Content ownership | | --- | --- | -| Start page: `home.rs` | Shared Home components with cached thumbnails and page navigation | +| Start page: `home.rs` | File-page composition, asynchronous thumbnail caches and links; navigation, action tiles, recent rows, samples and recovery surfaces use `ui_kit::FileView` | | Assistant transcript/composer containers, gallery and docking: `agent_chat/panel.rs` | Conversation/media layout, rich selectable content, drag/docking behavior; matching controls use the kit | | Native file/program pickers: `file_picker.rs`, host services | Host-native sheets have no egui control surface; load/progress cards use the kit | | Command-result ranking/list/pins: `shortcut_box.rs` | Search layout and ranking; popup shell and matching controls use the kit | diff --git a/docs/ui-kit.md b/docs/ui-kit.md index 340cfc1ac..84d39bf87 100644 --- a/docs/ui-kit.md +++ b/docs/ui-kit.md @@ -413,3 +413,49 @@ border strip without changing logical panel allocations. The application bar has an independent surface role. The saved `Prefs::layout` is changed through `view.layout`; `ui.set` may still make a transient automation override. +## File/start presentation + +`FileView` owns File surfaces and controls. It accepts translated strings, existing +icon ids and cached thumbnail textures; callers retain commands, document state, +persistence, thumbnail jobs and recovery decisions. + +- `page`, `content` and `rail` own the page background, responsive insets and + full-height rail fill/clip. `navigation` also supports the narrow navigation menu. + Callers supply layout rectangles, scrolling and entry order. +- `nav_row` accepts a stable id, label, shortcut, selection and enabled state. + `back_to` accepts a translated `{name}` template, paints the document name + semibold and reuses the mirrored chevron and outlined keycap. `separator` + supplies grouped rules. Disabled rows cannot activate. +- `title`, `subtitle`, `detail` and `section` own typography. `section` accepts a + token-based heading/body gap: `space_12` for New, `space_10` for Recent/Samples. + Callers retain semantic section order and the larger `file_section_gap`. +- `grid` provides responsive columns with 14 pt gutters and no trailing row gap. + `action_tile` supplies an 84 pt card with 44 pt original artwork and vertically + centered label/subtitle. `tile_min_width` informs responsive columns. +- `recent_list` owns the rounded border and zero row gap. `recent_row` accepts a + `RecentRow`, paints internal separators, medium names and workspace dots, and + retains title/path at narrow widths. Callers handle unavailable-file actions. +- `sample_grid(ui, id, &[SampleCard])` measures each row's tallest content and + stretches cards to equal bottoms without clipping descriptions. Responses stay + in sample order, with stable `{id}:{index}` ids. Artwork inputs remain unchanged. +- `recovery_banner` accepts `RecoveryMessage` segments for a bold title, normal + message, monospace filename and normal suffix. Actions align right or wrap below + at narrow widths. Discard is optional for summaries; the return value is + `(recover_response, optional_discard_response)`. `recovery_review` uses the same + geometry with per-design Discard. Callers provide truthful metadata. + +The exported `file_*` colour tokens provide readable light/dark foreground and +background pairs, including File-specific secondary text. Thumbnails retain the +neutral `file_image_tint`; icon and text colours do not change their pixels. +Spacing, dimensions, fonts and radii come from `theme::Tokens`. + +Gallery and geometry tests cover these components. To capture the actual File +view using public temporary fixtures, set `SOLIDCRAFT_FILE_EVIDENCE` to an output +directory and run `file_view_application_evidence_in_both_themes_and_widths` with +`--ignored`. It produces desktop and 420 pt narrow PNGs in both themes. + +`button_at(ui, id, rect, label, Button::Primary/Normal)` places the same shared +native button used by `button` inside a bounded, centred layout. It preserves +stable identity, enabled state and exact caller-owned geometry. Recovery actions +use this component rather than custom button painters. The recovery well renders +the existing restore artwork through its construction accent ramp.