* Navigation bar: slot model and one-row renderer (#6585) * Navigation bar: customisation section in Preferences (#6585) * Navigation bar: icons for visual styles, selection modes and display (#6585) * Navigation bar: redraw the Bodies, Parts and Components selection icons (#6585) * Navigation bar: refine the Ground shadow, Ambient occlusion, Parts and Components icons (#6585) * Navigation bar: solid cube and a longer arc for the Ground shadow icon (#6585) * Navigation bar: the owner accepts the new icons as final (#6585)
@@ -429,6 +429,20 @@ Original SolidCraft drawings, Open for owner review; no runtime assignments.
|
||||
| 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/frame_member.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/model/render_environment.svg | SolidCraft contributors | original Studio icon master (64 grid): dome with a grey cube inside | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/flat/style_shaded.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/flat/style_wireframe.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/flat/style_hidden_edges.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/flat/style_translucent.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/flat/select_faces_edges.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/flat/select_bodies.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/flat/select_features.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/flat/select_parts.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/flat/select_components.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/flat/select_sketch.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/flat/display.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/flat/grid.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/flat/ground_shadow.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/flat/ambient_occlusion.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 |
|
||||
|
||||
@@ -27,6 +27,9 @@ error = { master = "status_error", accent = "surface" }
|
||||
warning = { master = "status_warning", accent = "mesh" }
|
||||
ground = "c_fix"
|
||||
|
||||
# Visual style: Shaded with edges is the generic style icon.
|
||||
style_shaded_edges = "style"
|
||||
|
||||
# Same finished drawing, different semantic operation. Colours live only in palette.toml.
|
||||
sketch_break = { master = "break", accent = "sketch" }
|
||||
sketch_cancel = { master = "close", accent = "sketch" }
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
accessibility false
|
||||
activate false
|
||||
agent_chat false
|
||||
align false
|
||||
ambient_occlusion false
|
||||
appearance false
|
||||
arc3 false
|
||||
arc_center false
|
||||
@@ -83,6 +85,8 @@ decal false
|
||||
delete false
|
||||
delete_face false
|
||||
dimension false
|
||||
display false
|
||||
dots false
|
||||
draft false
|
||||
draft_analysis false
|
||||
drive false
|
||||
@@ -110,7 +114,9 @@ folder false
|
||||
frame_member false
|
||||
gear false
|
||||
graph false
|
||||
grid false
|
||||
ground false
|
||||
ground_shadow false
|
||||
help false
|
||||
hem false
|
||||
hole false
|
||||
@@ -210,6 +216,11 @@ section false
|
||||
select false
|
||||
send false
|
||||
settings false
|
||||
settings_keyboard false
|
||||
settings_monitor false
|
||||
settings_mouse false
|
||||
settings_palette false
|
||||
settings_plug false
|
||||
sheet_rules false
|
||||
shell false
|
||||
shield false
|
||||
@@ -247,6 +258,11 @@ star false
|
||||
status_error false
|
||||
status_recovery false
|
||||
style false
|
||||
style_hidden_edges false
|
||||
style_shaded false
|
||||
style_shaded_edges false
|
||||
style_translucent false
|
||||
style_wireframe false
|
||||
suppress false
|
||||
surface false
|
||||
surface_blend false
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"agent_chat": "4a9ae0e7e2c360b4858b3175674c93d096705c92318fecd481e849f3ae650bf4",
|
||||
"agent_link": "2f20d89a0e3e9b28744910dddf7f282a1099ccd91aa160c9841c5b1d9ea9ed0f",
|
||||
"align": "05615db7dd9e4be56ae898e59a68c548b8a8447794442a9a394940651204bc4f",
|
||||
"ambient_occlusion": "973f8ef2326aeaf0face576e5a2c79c7ef3d13638b2c51a5aad199e4ef7edb02",
|
||||
"appearance": "b3162edd92291a5ef402e8499cd52be05beb2fa7eda641163c3f6e98325de2bf",
|
||||
"arc3": "fdca3d501fd557ac989376a12e9c4fa8231fde2b455c20724d1079a466153e9c",
|
||||
"arc_center": "3a5fdeb1d64fc6741f944c4435870b05fccab62293e270da692c6681155cbc51",
|
||||
@@ -88,6 +89,7 @@
|
||||
"dimension": "a926b7c64bc8ca99d8d6dcbb81b95235bd3fc34fbed049aca8b01b4d1147c15d",
|
||||
"disclosure_closed": "49a350c6f2efae78de0be96c524ebee1fd1291ea449a84224b88d37164a4e807",
|
||||
"disclosure_open": "d13ce3f97e3e362a9904fa2bf3412f3f00e4136bc23538b92d41483961d280de",
|
||||
"display": "58b45e5e2230eaf2c80f74b3be2e02a23714c90d6fb03b59ed093a1949993163",
|
||||
"dots": "600f7ff209d93145fc938bc4f6a1e34473e6b9ee22a5b4718f133bc7da5ee58d",
|
||||
"draft": "9c0fc361cacd0ad95ccd54794f4825dfc9901a83a3de752a588faec365d0ee09",
|
||||
"draft_analysis": "eb39c0f90e9cf226da6307365a76015e900dd692dc3f0fdc8f02fe717226261f",
|
||||
@@ -117,7 +119,9 @@
|
||||
"folder": "c19f5230df45a1bda1e92e89de38bba21c91e6eca0517eb15847a7712012d1e5",
|
||||
"gear": "25a1ca48a587850da1104a46005a330873ed196246e3d04e12cf61f26ad2b0d5",
|
||||
"graph": "7156caedd2dbfa2ae53da18b7a2204b8db66c45126859d36caf049a3fd4335a4",
|
||||
"grid": "084b5040d57e9d5183b3db1fad0d17a13ab5bae64676eef703cc06622f9c7438",
|
||||
"ground": "23e2471a9d6872e83028e0e219e330cef1930a4d89456a0fefa1bda8a7e3eb81",
|
||||
"ground_shadow": "a96809ed87f5047c2d7f1274908ed7b65b180613322ac9c10eb0f9d6296c1b66",
|
||||
"help": "8ce4060577483dbdb510be147d2827de50ac20029354008fca55abc0c7edf05d",
|
||||
"hem": "f9b1aafbedcf3dc90c26be308814638e0095fbe31b0647092507343fa60af011",
|
||||
"hole": "f82d47751f826e08682db847a270897474661bfe9f35b6d3678f49a203172563",
|
||||
@@ -263,6 +267,12 @@
|
||||
"screw": "5e30570785360d6a591ea22862a82f1cf62228385c1e96382536db8a453ac791",
|
||||
"section": "cdd13f99f15f6d59bfa21c747810608d6afd00cb8207faf0337928c8521e7eae",
|
||||
"select": "fdf6431270006ca7409c60c37cfed59572de04229f104ec723e6010ffa2b7163",
|
||||
"select_bodies": "8e6e61e083e6097535da3b98d41b607b40fc81b72bbd8c7fb903618c5b35c568",
|
||||
"select_components": "3e6cc847b334e92ce7ec5e5f35dfa929572e0974239790d76563ca4e20b26789",
|
||||
"select_faces_edges": "7b99b5370b1647bf8cea57df7a1053caab641c2f4a94c4d797b9679e6f38d6f1",
|
||||
"select_features": "b050bc19ce86d135cbe50998be681555110e92e179c4c7b101170c6b62c19943",
|
||||
"select_parts": "569adc5595a64187411d8ffeea69eab3b76ddfa33aeead6fd728efdd993bcccc",
|
||||
"select_sketch": "b0605b34a14d4173f7ed80d877109ec0b891a1b395bcab5743a603ed2eae240a",
|
||||
"send": "f83b6cdab792f9567a81d46d7828ed20795513c57a2c7d00fbbe6bd14d2f5848",
|
||||
"settings": "9193dd3a1007c43660d0d47b6499cb2571338b67949e1a99df112057b9bf2b8a",
|
||||
"settings_keyboard": "4968c70788094365af9c6e2b1c15b2aac45cf21212a14b8a256daf1ffe17f41a",
|
||||
@@ -309,6 +319,11 @@
|
||||
"stitch": "6c3205d64007b771ed78d6f8055867578439fb25d591563b32dbd3343c98732d",
|
||||
"stop": "36967eb4d423370d0d6c679b0a71f8d09f4fb2c73eed3e8cc50c604c44b0c32b",
|
||||
"style": "6c2b04234b82ea4858c80190cc7208c60f549358253005afc35ab4e29506b578",
|
||||
"style_hidden_edges": "a707dfc0bdcabe9144865f569abfcb478e493143cbd4331efc1404cf3082f6d2",
|
||||
"style_shaded": "6e5f8f9a9030ab3717f8b2192bbfd3f6b515ad398acf6cb41bc24f1298bc73b4",
|
||||
"style_shaded_edges": "6c2b04234b82ea4858c80190cc7208c60f549358253005afc35ab4e29506b578",
|
||||
"style_translucent": "c46b0cd485cfb9023514908357048b5cba9017a0c4976239da1e98f50e4ab5f9",
|
||||
"style_wireframe": "af7e575d378b5b6850bee9d3ca384efab95c8d4c876c5e3524f3ea771c4380a3",
|
||||
"suppress": "c54fbc01c12c0175d78cd63f692e8aaf73fc2cac79752b2a3ad821ac32734343",
|
||||
"surface": "ba0e839ce0ee03e7ff95a2389a5ecb20bd80c713064d9b1bd5f461f4a80d1921",
|
||||
"surface_blend": "0642f3b4af7d22f379a3c74f54c7b1c9eef0bdda19372ce4df73c0e56bdd7bbc",
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<title>Ambient occlusion</title>
|
||||
<g opacity="0.22"><path d="M13 51L51 51A38 38 0 0 0 13 13Z" fill="currentColor" stroke="currentColor" stroke-width="0" stroke-linejoin="round" stroke-linecap="round"/></g>
|
||||
<g opacity="0.38"><path d="M13 51L40 51A27 27 0 0 0 13 24Z" fill="currentColor" stroke="currentColor" stroke-width="0" stroke-linejoin="round" stroke-linecap="round"/></g>
|
||||
<g opacity="0.62"><path d="M13 51L29 51A16 16 0 0 0 13 35Z" fill="currentColor" stroke="currentColor" stroke-width="0" stroke-linejoin="round" stroke-linecap="round"/></g>
|
||||
<path d="M13 10L13 51L54 51" fill="none" stroke="currentColor" stroke-width="5.6" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 758 B |
@@ -0,0 +1,8 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<title>Display</title>
|
||||
<path d="M10 22L54 22M10 42L54 42" fill="none" stroke="currentColor" stroke-width="5.6" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<circle cx="24" cy="22" r="10.5" fill="#ffffff"/>
|
||||
<circle cx="42" cy="42" r="10.5" fill="#ffffff"/>
|
||||
<circle cx="24" cy="22" r="6.4" fill="currentColor"/>
|
||||
<circle cx="42" cy="42" r="6.4" fill="currentColor"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 448 B |
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<title>Grid</title>
|
||||
<path d="M12 12L52 12L52 52L12 52Z" fill="none" stroke="currentColor" stroke-width="5.6" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M25.3 12L25.3 52M38.7 12L38.7 52M12 25.3L52 25.3M12 38.7L52 38.7" fill="none" stroke="currentColor" stroke-width="4" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 407 B |
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<title>Ground shadow</title>
|
||||
<path d="M32 4.8 L48.1 13.9 L48.1 32.1 L32 41.2 L15.9 32.1 L15.9 13.9Z" fill="currentColor" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M9.34 31.35A25 11 0 1 0 54.66 31.35" fill="none" stroke="currentColor" stroke-width="5.2" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 433 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<title>Bodies</title>
|
||||
<path d="M32 6 L55 19 L55 45 L32 58 L9 45 L9 19Z" fill="currentColor" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 254 B |
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<title>Components</title>
|
||||
<path d="M22.91 5.75 L41.09 16.25 L22.91 26.75 L4.72 16.25ZM4.72 16.25 L22.91 26.75 L22.91 47.75 L4.72 37.25ZM41.09 16.25 L59.28 26.75 L41.09 37.25 L22.91 26.75ZM22.91 26.75 L41.09 37.25 L41.09 58.25 L22.91 47.75ZM59.28 26.75 L41.09 37.25 L41.09 58.25 L59.28 47.75Z" fill="currentColor" stroke="currentColor" stroke-width="4.2" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M37.46 18.35L22.91 26.75L22.91 43.55" fill="none" stroke="#ffffff" stroke-width="3.6" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 621 B |
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<title>Faces and edges</title>
|
||||
<path d="M32 6 L55 19 L32 32 L9 19Z" fill="currentColor" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M32 6 L55 19 L55 45 L32 58 L9 45 L9 19Z" fill="none" stroke="currentColor" stroke-width="4.6" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M32 32L9 19M32 32L55 19M32 32L32 58" fill="none" stroke="currentColor" stroke-width="3.6" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 554 B |
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<title>Features</title>
|
||||
<path d="M32 6 L55 19 L55 45 L32 58 L9 45 L9 19Z" fill="none" stroke="currentColor" stroke-width="4.6" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M9 19L32 32M32 32L55 19M32 32L32 58" fill="none" stroke="currentColor" stroke-width="3.6" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M42 19C42 22.2 37.52 24.8 32 24.8C26.48 24.8 22 22.2 22 19C22 15.8 26.48 13.2 32 13.2C37.52 13.2 42 15.8 42 19Z" fill="currentColor" stroke="currentColor" stroke-width="0.6" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 632 B |
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<title>Parts</title>
|
||||
<path d="M22.91 5.75 L41.09 16.25 L22.91 26.75 L4.72 16.25ZM4.72 16.25 L22.91 26.75 L22.91 47.75 L4.72 37.25Z" fill="none" stroke="currentColor" stroke-width="4.2" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M41.09 16.25 L59.28 26.75 L41.09 37.25 L22.91 26.75ZM22.91 26.75 L41.09 37.25 L41.09 58.25 L22.91 47.75ZM59.28 26.75 L41.09 37.25 L41.09 58.25 L59.28 47.75Z" fill="currentColor" stroke="currentColor" stroke-width="4.2" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 585 B |
@@ -0,0 +1,10 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<title>Sketch features</title>
|
||||
<path d="M10 46C18 14 46 14 54 46" fill="none" stroke="currentColor" stroke-width="5" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<circle cx="10" cy="46" r="8.6" fill="#ffffff"/>
|
||||
<circle cx="54" cy="46" r="8.6" fill="#ffffff"/>
|
||||
<circle cx="32" cy="22.5" r="8.6" fill="#ffffff"/>
|
||||
<circle cx="10" cy="46" r="5.8" fill="currentColor"/>
|
||||
<circle cx="54" cy="46" r="5.8" fill="currentColor"/>
|
||||
<circle cx="32" cy="22.5" r="5.8" fill="currentColor"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 563 B |
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<title>Shaded with hidden edges</title>
|
||||
<path d="M32 6 L55 19 L55 45 L32 58 L9 45 L9 19Z" fill="currentColor" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M32 32L15.44 22.64M32 32L48.56 22.64M32 32L32 50.72" fill="none" stroke="#ffffff" stroke-width="3.6" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M32 32L32 13.28M32 32L48.56 41.36M32 32L15.44 41.36" fill="none" stroke="#ffffff" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round" stroke-dasharray="4.5 4"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 619 B |
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<title>Shaded</title>
|
||||
<g opacity="0.5"><path d="M32 6 L55 19 L32 32 L9 19Z" fill="currentColor" stroke="currentColor" stroke-width="0.8" stroke-linejoin="round" stroke-linecap="round"/></g>
|
||||
<g opacity="0.8"><path d="M9 19 L32 32 L32 58 L9 45Z" fill="currentColor" stroke="currentColor" stroke-width="0.8" stroke-linejoin="round" stroke-linecap="round"/></g>
|
||||
<path d="M32 32 L55 19 L55 45 L32 58Z" fill="currentColor" stroke="currentColor" stroke-width="0.8" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 583 B |
@@ -0,0 +1,10 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<title>Translucent</title>
|
||||
<defs>
|
||||
<clipPath id="tr-clip"><path d="M32 8.6 L52.7 20.3 L52.7 43.7 L32 55.4 L11.3 43.7 L11.3 20.3Z"/></clipPath>
|
||||
</defs>
|
||||
<g clip-path="url(#tr-clip)"><path d="M-71 72L9 -8M-60.5 72L19.5 -8M-50 72L30 -8M-39.5 72L40.5 -8M-29 72L51 -8M-18.5 72L61.5 -8M-8 72L72 -8M2.5 72L82.5 -8M13 72L93 -8M23.5 72L103.5 -8M34 72L114 -8M44.5 72L124.5 -8M55 72L135 -8" fill="none" stroke="currentColor" stroke-width="2.8" stroke-linejoin="round" stroke-linecap="round"/></g>
|
||||
<path d="M32 6 L55 19 L55 45 L32 58 L9 45 L9 19Z" fill="none" stroke="currentColor" stroke-width="5.2" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M32 32L11.76 20.56M32 32L52.24 20.56M32 32L32 54.88" fill="none" stroke="#ffffff" stroke-width="6.4" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M32 32L11.3 20.3M32 32L52.7 20.3M32 32L32 55.4" fill="none" stroke="currentColor" stroke-width="3.6" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<title>Wireframe</title>
|
||||
<path d="M32 6 L55 19 L55 45 L32 58 L9 45 L9 19Z" fill="none" stroke="currentColor" stroke-width="5.2" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
<path d="M32 32L32 6M32 32L55 19M32 32L55 45M32 32L32 58M32 32L9 45M32 32L9 19" fill="none" stroke="currentColor" stroke-width="3.6" stroke-linejoin="round" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 433 B |
@@ -0,0 +1,562 @@
|
||||
{
|
||||
"en": {
|
||||
"navbar.custom.title": "Navigation bar",
|
||||
"navbar.custom.preview_as": "Preview as",
|
||||
"navbar.custom.design": "Design",
|
||||
"navbar.custom.render": "Render",
|
||||
"navbar.custom.hidden_render": "Hidden in Render",
|
||||
"navbar.custom.hidden_design": "Hidden in Design",
|
||||
"navbar.custom.select": "No slot selected. Select a slot on the bar to move it, remove it or change how it looks.",
|
||||
"navbar.custom.left": "Move left",
|
||||
"navbar.custom.right": "Move right",
|
||||
"navbar.custom.remove": "Remove",
|
||||
"navbar.custom.shows": "Shows",
|
||||
"navbar.custom.icon_value": "Icon and value",
|
||||
"navbar.custom.icon_only": "Icon only",
|
||||
"navbar.custom.available": "{available} · drag onto the bar, or press Add",
|
||||
"navbar.custom.add_slot": "Add {slot}",
|
||||
"navbar.custom.position": "Position",
|
||||
"navbar.custom.size": "Size",
|
||||
"navbar.custom.compact": "Compact",
|
||||
"navbar.custom.regular": "Regular",
|
||||
"navbar.custom.buttons": "Buttons",
|
||||
"navbar.custom.icons": "Icons",
|
||||
"navbar.custom.labels": "Icons and labels",
|
||||
"navbar.custom.idle": "When idle",
|
||||
"navbar.custom.always": "Always visible",
|
||||
"navbar.custom.fade": "Fade",
|
||||
"navbar.custom.hide_idle": "Hide until hovered",
|
||||
"navbar.custom.show": "Show navigation bar",
|
||||
"navbar.custom.reset_default": "Reset to default",
|
||||
"navbar.custom.count": "{count} of 16 slots",
|
||||
"navbar.custom.customise": "Customise navigation bar…",
|
||||
"navbar.custom.hide": "Hide navigation bar",
|
||||
"navbar.custom.reset": "Reset navigation bar",
|
||||
"navbar.custom.remove_bar": "Remove from bar",
|
||||
"navbar.custom.full": "Remove a slot to add another.",
|
||||
"navbar.custom.separators_full": "The bar already has four separators.",
|
||||
"navbar.custom.duplicate": "This slot is already on the bar.",
|
||||
"navbar.custom.stale": "The bar changed. Select the slot again.",
|
||||
"navbar.custom.unknown": "This slot is not available.",
|
||||
"navbar.custom.intro": "Choose the controls on the bar at the bottom of the 3D view, and in what order. Drag a slot to move it, or drag it off the bar to remove it.",
|
||||
"navbar.custom.position_left": "Left",
|
||||
"navbar.custom.position_centre": "Centre",
|
||||
"navbar.custom.position_right": "Right",
|
||||
"navbar.value_tip": "{name} · {value}",
|
||||
"navbar.translucent": "Translucent",
|
||||
"navbar.later": "Later",
|
||||
"navbar.graphics": "Graphics",
|
||||
"navbar.preset": "Preset",
|
||||
"navbar.show": "Show",
|
||||
"navbar.projection_heading": "Projection",
|
||||
"navbar.orthographic": "Orthographic",
|
||||
"navbar.perspective": "Perspective",
|
||||
"navbar.assistant": "Assistant",
|
||||
"navbar.agent_cursor": "Show agent cursor",
|
||||
"navbar.agent_chat": "Assistant chat panel",
|
||||
"navbar.description.orbit": "Turns the view around the model.",
|
||||
"navbar.description.pan": "Slides the view sideways, up or down.",
|
||||
"navbar.description.zoom": "Moves the view closer to or further from the model.",
|
||||
"navbar.description.spin": "Keeps the view turning until you click or press a key.",
|
||||
"navbar.description.fit": "Frames the selection, or the whole model if nothing is selected.",
|
||||
"navbar.description.look_at": "Turns the view to face the selected face, plane or open sketch.",
|
||||
"navbar.description.home": "Returns to the isometric view of the whole model.",
|
||||
"navbar.description.visual_style": "Switches how the model is drawn: shaded, wireframe or with hidden edges.",
|
||||
"navbar.description.display": "Holds the view settings: graphics preset, grid, ground shadow, ambient occlusion and projection.",
|
||||
"navbar.description.grid": "Shows or hides the ground grid.",
|
||||
"navbar.description.ground_shadow": "Shows or hides the shadow under the model.",
|
||||
"navbar.description.ambient_occlusion": "Darkens creases and corners to add depth.",
|
||||
"navbar.description.projection": "Switches between orthographic and perspective views.",
|
||||
"navbar.description.separator": "A thin line that groups neighbouring slots."
|
||||
},
|
||||
"ja": {
|
||||
"navbar.custom.title": "ナビゲーションバー",
|
||||
"navbar.custom.preview_as": "プレビュー",
|
||||
"navbar.custom.design": "デザイン",
|
||||
"navbar.custom.render": "レンダー",
|
||||
"navbar.custom.hidden_render": "レンダーでは非表示",
|
||||
"navbar.custom.hidden_design": "デザインでは非表示",
|
||||
"navbar.custom.select": "スロットが選択されていません。バーのスロットを選択して移動、削除、表示の変更ができます。",
|
||||
"navbar.custom.left": "左へ移動",
|
||||
"navbar.custom.right": "右へ移動",
|
||||
"navbar.custom.remove": "削除",
|
||||
"navbar.custom.shows": "表示内容",
|
||||
"navbar.custom.icon_value": "アイコンと値",
|
||||
"navbar.custom.icon_only": "アイコンのみ",
|
||||
"navbar.custom.available": "{available} · バーへドラッグ、または「追加」",
|
||||
"navbar.custom.add_slot": "{slot} を追加",
|
||||
"navbar.custom.position": "位置",
|
||||
"navbar.custom.size": "サイズ",
|
||||
"navbar.custom.compact": "コンパクト",
|
||||
"navbar.custom.regular": "標準",
|
||||
"navbar.custom.buttons": "ボタン",
|
||||
"navbar.custom.icons": "アイコン",
|
||||
"navbar.custom.labels": "アイコンとラベル",
|
||||
"navbar.custom.idle": "操作していないとき",
|
||||
"navbar.custom.always": "常に表示",
|
||||
"navbar.custom.fade": "薄く表示",
|
||||
"navbar.custom.hide_idle": "ホバー時のみ表示",
|
||||
"navbar.custom.show": "ナビゲーションバーを表示",
|
||||
"navbar.custom.reset_default": "既定値に戻す",
|
||||
"navbar.custom.count": "16 個中 {count} 個のスロット",
|
||||
"navbar.custom.customise": "ナビゲーションバーをカスタマイズ…",
|
||||
"navbar.custom.hide": "ナビゲーションバーを非表示",
|
||||
"navbar.custom.reset": "ナビゲーションバーをリセット",
|
||||
"navbar.custom.remove_bar": "バーから削除",
|
||||
"navbar.custom.full": "別のスロットを追加するには、スロットを削除してください。",
|
||||
"navbar.custom.separators_full": "区切りは既に4個あります。",
|
||||
"navbar.custom.duplicate": "このスロットは既にバーにあります。",
|
||||
"navbar.custom.stale": "バーが変更されました。スロットを再選択してください。",
|
||||
"navbar.custom.unknown": "このスロットは使用できません。",
|
||||
"navbar.custom.intro": "3Dビューの下部に表示する操作と順序を選びます。スロットをドラッグして移動し、バーの外へドラッグして削除します。",
|
||||
"navbar.custom.position_left": "左",
|
||||
"navbar.custom.position_centre": "中央",
|
||||
"navbar.custom.position_right": "右",
|
||||
"navbar.value_tip": "{name} · {value}",
|
||||
"navbar.translucent": "半透明",
|
||||
"navbar.later": "後日対応",
|
||||
"navbar.graphics": "グラフィックス",
|
||||
"navbar.preset": "プリセット",
|
||||
"navbar.show": "表示",
|
||||
"navbar.projection_heading": "投影",
|
||||
"navbar.orthographic": "平行投影",
|
||||
"navbar.perspective": "透視投影",
|
||||
"navbar.assistant": "アシスタント",
|
||||
"navbar.agent_cursor": "エージェントカーソルを表示",
|
||||
"navbar.agent_chat": "アシスタントチャットパネル",
|
||||
"navbar.description.orbit": "モデルの周りに視点を回転します。",
|
||||
"navbar.description.pan": "視点を左右上下に移動します。",
|
||||
"navbar.description.zoom": "モデルに視点を近づけたり遠ざけたりします。",
|
||||
"navbar.description.spin": "クリックまたはキー入力まで視点を回転し続けます。",
|
||||
"navbar.description.fit": "選択対象、未選択ならモデル全体が収まるように表示します。",
|
||||
"navbar.description.look_at": "選択した面、平面、編集中のスケッチに正対します。",
|
||||
"navbar.description.home": "モデル全体の等角投影ビューに戻します。",
|
||||
"navbar.description.visual_style": "シェーディング、ワイヤーフレーム、隠線表示などの描画方法を切り替えます。",
|
||||
"navbar.description.display": "描画プリセット、グリッド、地面の影、アンビエントオクルージョン、投影を設定します。",
|
||||
"navbar.description.grid": "地面のグリッドを表示または非表示にします。",
|
||||
"navbar.description.ground_shadow": "モデルの下の影を表示または非表示にします。",
|
||||
"navbar.description.ambient_occlusion": "くぼみや隅を暗くして奥行きを表現します。",
|
||||
"navbar.description.projection": "平行投影と透視投影を切り替えます。",
|
||||
"navbar.description.separator": "隣接するスロットをまとめる細い区切り線です。"
|
||||
},
|
||||
"zh": {
|
||||
"navbar.custom.title": "导航栏",
|
||||
"navbar.custom.preview_as": "预览为",
|
||||
"navbar.custom.design": "设计",
|
||||
"navbar.custom.render": "渲染",
|
||||
"navbar.custom.hidden_render": "在渲染中隐藏",
|
||||
"navbar.custom.hidden_design": "在设计中隐藏",
|
||||
"navbar.custom.select": "未选择槽位。选择栏上的槽位即可移动、移除或更改其外观。",
|
||||
"navbar.custom.left": "左移",
|
||||
"navbar.custom.right": "右移",
|
||||
"navbar.custom.remove": "移除",
|
||||
"navbar.custom.shows": "显示内容",
|
||||
"navbar.custom.icon_value": "图标和值",
|
||||
"navbar.custom.icon_only": "仅图标",
|
||||
"navbar.custom.available": "{available} · 拖到栏上,或点击添加",
|
||||
"navbar.custom.add_slot": "添加{slot}",
|
||||
"navbar.custom.position": "位置",
|
||||
"navbar.custom.size": "大小",
|
||||
"navbar.custom.compact": "紧凑",
|
||||
"navbar.custom.regular": "常规",
|
||||
"navbar.custom.buttons": "按钮",
|
||||
"navbar.custom.icons": "图标",
|
||||
"navbar.custom.labels": "图标和标签",
|
||||
"navbar.custom.idle": "空闲时",
|
||||
"navbar.custom.always": "始终显示",
|
||||
"navbar.custom.fade": "淡化",
|
||||
"navbar.custom.hide_idle": "悬停时显示",
|
||||
"navbar.custom.show": "显示导航栏",
|
||||
"navbar.custom.reset_default": "恢复默认",
|
||||
"navbar.custom.count": "{count} / 16 个槽位",
|
||||
"navbar.custom.customise": "自定义导航栏…",
|
||||
"navbar.custom.hide": "隐藏导航栏",
|
||||
"navbar.custom.reset": "重置导航栏",
|
||||
"navbar.custom.remove_bar": "从栏中移除",
|
||||
"navbar.custom.full": "请先移除一个槽位以添加其他槽位。",
|
||||
"navbar.custom.separators_full": "导航栏已有4个分隔线。",
|
||||
"navbar.custom.duplicate": "此槽位已在栏上。",
|
||||
"navbar.custom.stale": "导航栏已更改。请重新选择槽位。",
|
||||
"navbar.custom.unknown": "此槽位不可用。",
|
||||
"navbar.custom.intro": "选择3D视图底部导航栏中的控件及其顺序。拖动槽位可移动,拖出栏外可移除。",
|
||||
"navbar.custom.position_left": "左",
|
||||
"navbar.custom.position_centre": "居中",
|
||||
"navbar.custom.position_right": "右",
|
||||
"navbar.value_tip": "{name} · {value}",
|
||||
"navbar.translucent": "半透明",
|
||||
"navbar.later": "稍后提供",
|
||||
"navbar.graphics": "图形",
|
||||
"navbar.preset": "预设",
|
||||
"navbar.show": "显示",
|
||||
"navbar.projection_heading": "投影",
|
||||
"navbar.orthographic": "正交",
|
||||
"navbar.perspective": "透视",
|
||||
"navbar.assistant": "助手",
|
||||
"navbar.agent_cursor": "显示智能体光标",
|
||||
"navbar.agent_chat": "助手聊天面板",
|
||||
"navbar.description.orbit": "围绕模型旋转视图。",
|
||||
"navbar.description.pan": "向左右或上下平移视图。",
|
||||
"navbar.description.zoom": "将视图拉近或远离模型。",
|
||||
"navbar.description.spin": "持续旋转视图,直到点击或按键停止。",
|
||||
"navbar.description.fit": "完整显示所选对象;未选择时显示整个模型。",
|
||||
"navbar.description.look_at": "使视图正对所选面、平面或打开的草图。",
|
||||
"navbar.description.home": "返回显示整个模型的等轴测视图。",
|
||||
"navbar.description.visual_style": "切换着色、线框或带隐藏边线等模型绘制方式。",
|
||||
"navbar.description.display": "设置图形预设、网格、地面阴影、环境光遮蔽和投影。",
|
||||
"navbar.description.grid": "显示或隐藏地面网格。",
|
||||
"navbar.description.ground_shadow": "显示或隐藏模型下方的阴影。",
|
||||
"navbar.description.ambient_occlusion": "加深凹槽和角落的阴影,增加深度感。",
|
||||
"navbar.description.projection": "切换正交视图和透视视图。",
|
||||
"navbar.description.separator": "用于分组相邻槽位的细分隔线。"
|
||||
},
|
||||
"ar": {
|
||||
"navbar.custom.title": "شريط التنقل",
|
||||
"navbar.custom.preview_as": "معاينة كـ",
|
||||
"navbar.custom.design": "التصميم",
|
||||
"navbar.custom.render": "التصيير",
|
||||
"navbar.custom.hidden_render": "مخفي في التصيير",
|
||||
"navbar.custom.hidden_design": "مخفي في التصميم",
|
||||
"navbar.custom.select": "لم يتم تحديد أي خانة. حدّد خانة على الشريط لنقلها أو إزالتها أو تغيير مظهرها.",
|
||||
"navbar.custom.left": "نقل إلى اليسار",
|
||||
"navbar.custom.right": "نقل إلى اليمين",
|
||||
"navbar.custom.remove": "إزالة",
|
||||
"navbar.custom.shows": "يعرض",
|
||||
"navbar.custom.icon_value": "الأيقونة والقيمة",
|
||||
"navbar.custom.icon_only": "الأيقونة فقط",
|
||||
"navbar.custom.available": "{available} · اسحبها إلى الشريط، أو اضغط إضافة",
|
||||
"navbar.custom.add_slot": "إضافة {slot}",
|
||||
"navbar.custom.position": "الموضع",
|
||||
"navbar.custom.size": "الحجم",
|
||||
"navbar.custom.compact": "مضغوط",
|
||||
"navbar.custom.regular": "عادي",
|
||||
"navbar.custom.buttons": "الأزرار",
|
||||
"navbar.custom.icons": "الأيقونات",
|
||||
"navbar.custom.labels": "الأيقونات والتسميات",
|
||||
"navbar.custom.idle": "عند الخمول",
|
||||
"navbar.custom.always": "ظاهر دائماً",
|
||||
"navbar.custom.fade": "تلاشٍ",
|
||||
"navbar.custom.hide_idle": "إخفاء حتى التمرير",
|
||||
"navbar.custom.show": "إظهار شريط التنقل",
|
||||
"navbar.custom.reset_default": "إعادة الضبط إلى الافتراضي",
|
||||
"navbar.custom.count": "{count} من 16 خانة",
|
||||
"navbar.custom.customise": "تخصيص شريط التنقل…",
|
||||
"navbar.custom.hide": "إخفاء شريط التنقل",
|
||||
"navbar.custom.reset": "إعادة ضبط شريط التنقل",
|
||||
"navbar.custom.remove_bar": "إزالة من الشريط",
|
||||
"navbar.custom.full": "أزل خانة لإضافة أخرى.",
|
||||
"navbar.custom.separators_full": "يحتوي الشريط بالفعل على أربعة فواصل.",
|
||||
"navbar.custom.duplicate": "هذه الخانة موجودة بالفعل على الشريط.",
|
||||
"navbar.custom.stale": "تغيّر الشريط. حدّد الخانة مرة أخرى.",
|
||||
"navbar.custom.unknown": "هذه الخانة غير متاحة.",
|
||||
"navbar.custom.intro": "اختر عناصر التحكم على الشريط أسفل العرض ثلاثي الأبعاد وترتيبها. اسحب خانة لنقلها، أو اسحبها خارج الشريط لإزالتها.",
|
||||
"navbar.custom.position_left": "يسار",
|
||||
"navbar.custom.position_centre": "وسط",
|
||||
"navbar.custom.position_right": "يمين",
|
||||
"navbar.value_tip": "{name} · {value}",
|
||||
"navbar.translucent": "شفاف",
|
||||
"navbar.later": "لاحقاً",
|
||||
"navbar.graphics": "الرسوميات",
|
||||
"navbar.preset": "الإعداد المسبق",
|
||||
"navbar.show": "إظهار",
|
||||
"navbar.projection_heading": "الإسقاط",
|
||||
"navbar.orthographic": "إسقاط متعامد",
|
||||
"navbar.perspective": "منظور",
|
||||
"navbar.assistant": "المساعد",
|
||||
"navbar.agent_cursor": "إظهار مؤشر الوكيل",
|
||||
"navbar.agent_chat": "لوحة دردشة المساعد",
|
||||
"navbar.description.orbit": "يدير العرض حول النموذج.",
|
||||
"navbar.description.pan": "يزيح العرض جانبياً أو لأعلى أو لأسفل.",
|
||||
"navbar.description.zoom": "يقرّب العرض من النموذج أو يبعده عنه.",
|
||||
"navbar.description.spin": "يُبقي العرض يدور حتى تنقر أو تضغط مفتاحاً.",
|
||||
"navbar.description.fit": "يضبط العرض على التحديد، أو على النموذج كله إن لم يكن هناك تحديد.",
|
||||
"navbar.description.look_at": "يوجّه العرض نحو الوجه أو المستوى المحدد أو الرسم المفتوح.",
|
||||
"navbar.description.home": "يعود إلى المنظور الأيزومتري للنموذج كله.",
|
||||
"navbar.description.visual_style": "يبدّل طريقة رسم النموذج: مظلل أو إطار سلكي أو مع الحواف المخفية.",
|
||||
"navbar.description.display": "يضم إعدادات العرض: الإعداد المسبق للرسوميات والشبكة وظل الأرض والإظلال المحيطي والإسقاط.",
|
||||
"navbar.description.grid": "يُظهر شبكة الأرضية أو يُخفيها.",
|
||||
"navbar.description.ground_shadow": "يُظهر الظل تحت النموذج أو يُخفيه.",
|
||||
"navbar.description.ambient_occlusion": "يُعتّم الطيات والزوايا لإضافة عمق.",
|
||||
"navbar.description.projection": "يبدّل بين العرض المتعامد والمنظوري.",
|
||||
"navbar.description.separator": "خط رفيع يجمع الخانات المتجاورة."
|
||||
},
|
||||
"de": {
|
||||
"navbar.custom.title": "Navigationsleiste",
|
||||
"navbar.custom.preview_as": "Vorschau als",
|
||||
"navbar.custom.design": "Entwurf",
|
||||
"navbar.custom.render": "Rendern",
|
||||
"navbar.custom.hidden_render": "Im Rendern ausgeblendet",
|
||||
"navbar.custom.hidden_design": "Im Entwurf ausgeblendet",
|
||||
"navbar.custom.select": "Kein Feld ausgewählt. Wählen Sie ein Feld in der Leiste, um es zu verschieben, zu entfernen oder sein Aussehen zu ändern.",
|
||||
"navbar.custom.left": "Nach links",
|
||||
"navbar.custom.right": "Nach rechts",
|
||||
"navbar.custom.remove": "Entfernen",
|
||||
"navbar.custom.shows": "Zeigt",
|
||||
"navbar.custom.icon_value": "Symbol und Wert",
|
||||
"navbar.custom.icon_only": "Nur Symbol",
|
||||
"navbar.custom.available": "{available} · auf die Leiste ziehen oder auf Hinzufügen klicken",
|
||||
"navbar.custom.add_slot": "{slot} hinzufügen",
|
||||
"navbar.custom.position": "Position",
|
||||
"navbar.custom.size": "Größe",
|
||||
"navbar.custom.compact": "Kompakt",
|
||||
"navbar.custom.regular": "Normal",
|
||||
"navbar.custom.buttons": "Schaltflächen",
|
||||
"navbar.custom.icons": "Symbole",
|
||||
"navbar.custom.labels": "Symbole und Beschriftungen",
|
||||
"navbar.custom.idle": "Bei Inaktivität",
|
||||
"navbar.custom.always": "Immer sichtbar",
|
||||
"navbar.custom.fade": "Abblenden",
|
||||
"navbar.custom.hide_idle": "Ausblenden, bis die Maus darüber ist",
|
||||
"navbar.custom.show": "Navigationsleiste anzeigen",
|
||||
"navbar.custom.reset_default": "Auf Standard zurücksetzen",
|
||||
"navbar.custom.count": "{count} von 16 Feldern",
|
||||
"navbar.custom.customise": "Navigationsleiste anpassen…",
|
||||
"navbar.custom.hide": "Navigationsleiste ausblenden",
|
||||
"navbar.custom.reset": "Navigationsleiste zurücksetzen",
|
||||
"navbar.custom.remove_bar": "Aus der Leiste entfernen",
|
||||
"navbar.custom.full": "Entfernen Sie ein Feld, um ein weiteres hinzuzufügen.",
|
||||
"navbar.custom.separators_full": "Die Leiste hat bereits vier Trennlinien.",
|
||||
"navbar.custom.duplicate": "Dieses Feld ist bereits in der Leiste.",
|
||||
"navbar.custom.stale": "Die Leiste hat sich geändert. Wählen Sie das Feld erneut aus.",
|
||||
"navbar.custom.unknown": "Dieses Feld ist nicht verfügbar.",
|
||||
"navbar.custom.intro": "Wählen Sie die Bedienelemente der Leiste am unteren Rand der 3D-Ansicht und ihre Reihenfolge. Ziehen Sie ein Feld, um es zu verschieben, oder aus der Leiste heraus, um es zu entfernen.",
|
||||
"navbar.custom.position_left": "Links",
|
||||
"navbar.custom.position_centre": "Mitte",
|
||||
"navbar.custom.position_right": "Rechts",
|
||||
"navbar.value_tip": "{name} · {value}",
|
||||
"navbar.translucent": "Durchscheinend",
|
||||
"navbar.later": "Später",
|
||||
"navbar.graphics": "Grafik",
|
||||
"navbar.preset": "Voreinstellung",
|
||||
"navbar.show": "Einblenden",
|
||||
"navbar.projection_heading": "Projektion",
|
||||
"navbar.orthographic": "Orthografisch",
|
||||
"navbar.perspective": "Perspektivisch",
|
||||
"navbar.assistant": "Assistent",
|
||||
"navbar.agent_cursor": "Agentencursor zeigen",
|
||||
"navbar.agent_chat": "Chat-Bereich des Assistenten",
|
||||
"navbar.description.orbit": "Dreht die Ansicht um das Modell.",
|
||||
"navbar.description.pan": "Verschiebt die Ansicht seitwärts, nach oben oder unten.",
|
||||
"navbar.description.zoom": "Bringt die Ansicht näher an das Modell heran oder weiter davon weg.",
|
||||
"navbar.description.spin": "Dreht die Ansicht weiter, bis Sie klicken oder eine Taste drücken.",
|
||||
"navbar.description.fit": "Zeigt die Auswahl formatfüllend, oder das ganze Modell, wenn nichts ausgewählt ist.",
|
||||
"navbar.description.look_at": "Dreht die Ansicht zur gewählten Fläche, Ebene oder offenen Skizze.",
|
||||
"navbar.description.home": "Kehrt zur isometrischen Ansicht des ganzen Modells zurück.",
|
||||
"navbar.description.visual_style": "Schaltet um, wie das Modell gezeichnet wird: schattiert, Drahtmodell oder mit verdeckten Kanten.",
|
||||
"navbar.description.display": "Enthält die Ansichtseinstellungen: Grafikvoreinstellung, Raster, Bodenschatten, Umgebungsverdeckung und Projektion.",
|
||||
"navbar.description.grid": "Zeigt oder verbirgt das Bodenraster.",
|
||||
"navbar.description.ground_shadow": "Zeigt oder verbirgt den Schatten unter dem Modell.",
|
||||
"navbar.description.ambient_occlusion": "Dunkelt Falten und Ecken ab und erzeugt Tiefe.",
|
||||
"navbar.description.projection": "Schaltet zwischen orthografischer und perspektivischer Ansicht um.",
|
||||
"navbar.description.separator": "Eine dünne Linie, die benachbarte Felder gruppiert."
|
||||
},
|
||||
"he": {
|
||||
"navbar.custom.title": "סרגל ניווט",
|
||||
"navbar.custom.preview_as": "תצוגה מקדימה כ",
|
||||
"navbar.custom.design": "תכן",
|
||||
"navbar.custom.render": "הדמיה",
|
||||
"navbar.custom.hidden_render": "מוסתר בהדמיה",
|
||||
"navbar.custom.hidden_design": "מוסתר בתכן",
|
||||
"navbar.custom.select": "לא נבחרה משבצת. בחרו משבצת בסרגל כדי להזיז אותה, להסיר אותה או לשנות את המראה שלה.",
|
||||
"navbar.custom.left": "הזזה שמאלה",
|
||||
"navbar.custom.right": "הזזה ימינה",
|
||||
"navbar.custom.remove": "הסרה",
|
||||
"navbar.custom.shows": "מציג",
|
||||
"navbar.custom.icon_value": "סמל וערך",
|
||||
"navbar.custom.icon_only": "סמל בלבד",
|
||||
"navbar.custom.available": "{available} · גררו אל הסרגל או לחצו על הוספה",
|
||||
"navbar.custom.add_slot": "הוספת {slot}",
|
||||
"navbar.custom.position": "מיקום",
|
||||
"navbar.custom.size": "גודל",
|
||||
"navbar.custom.compact": "דחוס",
|
||||
"navbar.custom.regular": "רגיל",
|
||||
"navbar.custom.buttons": "לחצנים",
|
||||
"navbar.custom.icons": "סמלים",
|
||||
"navbar.custom.labels": "סמלים ותוויות",
|
||||
"navbar.custom.idle": "כשאין פעילות",
|
||||
"navbar.custom.always": "תמיד מוצג",
|
||||
"navbar.custom.fade": "דהייה",
|
||||
"navbar.custom.hide_idle": "הסתרה עד מעבר עכבר",
|
||||
"navbar.custom.show": "הצגת סרגל הניווט",
|
||||
"navbar.custom.reset_default": "איפוס לברירת מחדל",
|
||||
"navbar.custom.count": "{count} מתוך 16 משבצות",
|
||||
"navbar.custom.customise": "התאמת סרגל הניווט…",
|
||||
"navbar.custom.hide": "הסתרת סרגל הניווט",
|
||||
"navbar.custom.reset": "איפוס סרגל הניווט",
|
||||
"navbar.custom.remove_bar": "הסרה מהסרגל",
|
||||
"navbar.custom.full": "הסירו משבצת כדי להוסיף אחרת.",
|
||||
"navbar.custom.separators_full": "בסרגל כבר יש ארבעה מפרידים.",
|
||||
"navbar.custom.duplicate": "המשבצת הזו כבר בסרגל.",
|
||||
"navbar.custom.stale": "הסרגל השתנה. בחרו שוב את המשבצת.",
|
||||
"navbar.custom.unknown": "המשבצת הזו אינה זמינה.",
|
||||
"navbar.custom.intro": "בחרו את הפקדים בסרגל שבתחתית התצוגה התלת־ממדית ואת סדרם. גררו משבצת כדי להזיז אותה, או גררו אותה מחוץ לסרגל כדי להסיר אותה.",
|
||||
"navbar.custom.position_left": "שמאל",
|
||||
"navbar.custom.position_centre": "מרכז",
|
||||
"navbar.custom.position_right": "ימין",
|
||||
"navbar.value_tip": "{name} · {value}",
|
||||
"navbar.translucent": "שקוף למחצה",
|
||||
"navbar.later": "בהמשך",
|
||||
"navbar.graphics": "גרפיקה",
|
||||
"navbar.preset": "הגדרה מוכנה",
|
||||
"navbar.show": "הצגה",
|
||||
"navbar.projection_heading": "הטלה",
|
||||
"navbar.orthographic": "אורתוגרפי",
|
||||
"navbar.perspective": "פרספקטיבה",
|
||||
"navbar.assistant": "עוזר",
|
||||
"navbar.agent_cursor": "הצגת סמן הסוכן",
|
||||
"navbar.agent_chat": "חלונית שיחת העוזר",
|
||||
"navbar.description.orbit": "מסובב את התצוגה סביב המודל.",
|
||||
"navbar.description.pan": "מזיז את התצוגה הצדה, למעלה או למטה.",
|
||||
"navbar.description.zoom": "מקרב את התצוגה אל המודל או מרחיק אותה ממנו.",
|
||||
"navbar.description.spin": "ממשיך לסובב את התצוגה עד ללחיצה או הקשה על מקש.",
|
||||
"navbar.description.fit": "ממסגר את הבחירה, או את כל המודל אם דבר לא נבחר.",
|
||||
"navbar.description.look_at": "מסובב את התצוגה אל הפאה, המישור או הסקיצה הפתוחה שנבחרו.",
|
||||
"navbar.description.home": "חוזר לתצוגה האיזומטרית של כל המודל.",
|
||||
"navbar.description.visual_style": "מחליף את אופן הציור של המודל: מוצלל, מסגרת תיל או עם קצוות נסתרים.",
|
||||
"navbar.description.display": "מכיל את הגדרות התצוגה: הגדרת גרפיקה מוכנה, רשת, צל על הקרקע, הצללה סביבתית והטלה.",
|
||||
"navbar.description.grid": "מציג או מסתיר את רשת הקרקע.",
|
||||
"navbar.description.ground_shadow": "מציג או מסתיר את הצל שמתחת למודל.",
|
||||
"navbar.description.ambient_occlusion": "מכהה קפלים ופינות כדי להוסיף עומק.",
|
||||
"navbar.description.projection": "מחליף בין תצוגה אורתוגרפית לפרספקטיבה.",
|
||||
"navbar.description.separator": "קו דק שמקבץ משבצות שכנות."
|
||||
},
|
||||
"ko": {
|
||||
"navbar.custom.title": "탐색 막대",
|
||||
"navbar.custom.preview_as": "미리 보기 모드",
|
||||
"navbar.custom.design": "설계",
|
||||
"navbar.custom.render": "렌더",
|
||||
"navbar.custom.hidden_render": "렌더에서 숨김",
|
||||
"navbar.custom.hidden_design": "설계에서 숨김",
|
||||
"navbar.custom.select": "선택한 칸이 없습니다. 막대에서 칸을 선택하면 이동하거나 제거하거나 모양을 바꿀 수 있습니다.",
|
||||
"navbar.custom.left": "왼쪽으로 이동",
|
||||
"navbar.custom.right": "오른쪽으로 이동",
|
||||
"navbar.custom.remove": "제거",
|
||||
"navbar.custom.shows": "표시 내용",
|
||||
"navbar.custom.icon_value": "아이콘과 값",
|
||||
"navbar.custom.icon_only": "아이콘만",
|
||||
"navbar.custom.available": "{available} · 막대로 끌어 놓거나 추가를 누르세요",
|
||||
"navbar.custom.add_slot": "{slot} 추가",
|
||||
"navbar.custom.position": "위치",
|
||||
"navbar.custom.size": "크기",
|
||||
"navbar.custom.compact": "컴팩트",
|
||||
"navbar.custom.regular": "보통",
|
||||
"navbar.custom.buttons": "버튼",
|
||||
"navbar.custom.icons": "아이콘",
|
||||
"navbar.custom.labels": "아이콘과 레이블",
|
||||
"navbar.custom.idle": "사용하지 않을 때",
|
||||
"navbar.custom.always": "항상 표시",
|
||||
"navbar.custom.fade": "흐리게",
|
||||
"navbar.custom.hide_idle": "가리킬 때까지 숨김",
|
||||
"navbar.custom.show": "탐색 막대 표시",
|
||||
"navbar.custom.reset_default": "기본값으로 재설정",
|
||||
"navbar.custom.count": "{count}/16칸",
|
||||
"navbar.custom.customise": "탐색 막대 사용자 지정…",
|
||||
"navbar.custom.hide": "탐색 막대 숨기기",
|
||||
"navbar.custom.reset": "탐색 막대 재설정",
|
||||
"navbar.custom.remove_bar": "막대에서 제거",
|
||||
"navbar.custom.full": "다른 칸을 추가하려면 칸을 하나 제거하세요.",
|
||||
"navbar.custom.separators_full": "막대에 구분선이 이미 네 개 있습니다.",
|
||||
"navbar.custom.duplicate": "이 칸은 이미 막대에 있습니다.",
|
||||
"navbar.custom.stale": "막대가 바뀌었습니다. 칸을 다시 선택하세요.",
|
||||
"navbar.custom.unknown": "이 칸은 사용할 수 없습니다.",
|
||||
"navbar.custom.intro": "3D 보기 아래쪽 막대에 둘 컨트롤과 순서를 고르세요. 칸을 끌어 옮기거나, 막대 밖으로 끌어 제거할 수 있습니다.",
|
||||
"navbar.custom.position_left": "왼쪽",
|
||||
"navbar.custom.position_centre": "가운데",
|
||||
"navbar.custom.position_right": "오른쪽",
|
||||
"navbar.value_tip": "{name} · {value}",
|
||||
"navbar.translucent": "반투명",
|
||||
"navbar.later": "나중에",
|
||||
"navbar.graphics": "그래픽",
|
||||
"navbar.preset": "프리셋",
|
||||
"navbar.show": "표시",
|
||||
"navbar.projection_heading": "투영",
|
||||
"navbar.orthographic": "직교 투영",
|
||||
"navbar.perspective": "원근 투영",
|
||||
"navbar.assistant": "어시스턴트",
|
||||
"navbar.agent_cursor": "에이전트 커서 표시",
|
||||
"navbar.agent_chat": "어시스턴트 채팅 패널",
|
||||
"navbar.description.orbit": "모델을 중심으로 보기를 회전합니다.",
|
||||
"navbar.description.pan": "보기를 옆으로, 위나 아래로 이동합니다.",
|
||||
"navbar.description.zoom": "보기를 모델에 더 가까이 또는 더 멀리 옮깁니다.",
|
||||
"navbar.description.spin": "클릭하거나 키를 누를 때까지 보기를 계속 회전합니다.",
|
||||
"navbar.description.fit": "선택 항목을, 선택이 없으면 모델 전체를 화면에 맞춥니다.",
|
||||
"navbar.description.look_at": "선택한 면, 평면 또는 열린 스케치를 정면으로 바라보게 보기를 돌립니다.",
|
||||
"navbar.description.home": "모델 전체의 등각 보기로 돌아갑니다.",
|
||||
"navbar.description.visual_style": "모델을 그리는 방식을 바꿉니다: 음영, 와이어프레임 또는 숨은 모서리 포함.",
|
||||
"navbar.description.display": "보기 설정을 담고 있습니다: 그래픽 프리셋, 격자, 바닥 그림자, 앰비언트 오클루전, 투영.",
|
||||
"navbar.description.grid": "바닥 격자를 표시하거나 숨깁니다.",
|
||||
"navbar.description.ground_shadow": "모델 아래 그림자를 표시하거나 숨깁니다.",
|
||||
"navbar.description.ambient_occlusion": "주름과 모서리를 어둡게 하여 깊이를 더합니다.",
|
||||
"navbar.description.projection": "직교 투영과 원근 투영을 전환합니다.",
|
||||
"navbar.description.separator": "이웃한 칸을 묶는 가는 선입니다."
|
||||
},
|
||||
"vi": {
|
||||
"navbar.custom.title": "Thanh điều hướng",
|
||||
"navbar.custom.preview_as": "Xem trước ở chế độ",
|
||||
"navbar.custom.design": "Thiết kế",
|
||||
"navbar.custom.render": "Kết xuất",
|
||||
"navbar.custom.hidden_render": "Ẩn trong Kết xuất",
|
||||
"navbar.custom.hidden_design": "Ẩn trong Thiết kế",
|
||||
"navbar.custom.select": "Chưa chọn ô nào. Hãy chọn một ô trên thanh để di chuyển, xóa hoặc đổi cách hiển thị.",
|
||||
"navbar.custom.left": "Chuyển sang trái",
|
||||
"navbar.custom.right": "Chuyển sang phải",
|
||||
"navbar.custom.remove": "Xóa",
|
||||
"navbar.custom.shows": "Hiển thị",
|
||||
"navbar.custom.icon_value": "Biểu tượng và giá trị",
|
||||
"navbar.custom.icon_only": "Chỉ biểu tượng",
|
||||
"navbar.custom.available": "{available} · kéo vào thanh hoặc nhấn Thêm",
|
||||
"navbar.custom.add_slot": "Thêm {slot}",
|
||||
"navbar.custom.position": "Vị trí",
|
||||
"navbar.custom.size": "Kích thước",
|
||||
"navbar.custom.compact": "Gọn",
|
||||
"navbar.custom.regular": "Thường",
|
||||
"navbar.custom.buttons": "Nút",
|
||||
"navbar.custom.icons": "Biểu tượng",
|
||||
"navbar.custom.labels": "Biểu tượng và nhãn",
|
||||
"navbar.custom.idle": "Khi không dùng",
|
||||
"navbar.custom.always": "Luôn hiện",
|
||||
"navbar.custom.fade": "Mờ dần",
|
||||
"navbar.custom.hide_idle": "Ẩn cho đến khi rê chuột",
|
||||
"navbar.custom.show": "Hiện thanh điều hướng",
|
||||
"navbar.custom.reset_default": "Đặt lại mặc định",
|
||||
"navbar.custom.count": "{count}/16 ô",
|
||||
"navbar.custom.customise": "Tùy chỉnh thanh điều hướng…",
|
||||
"navbar.custom.hide": "Ẩn thanh điều hướng",
|
||||
"navbar.custom.reset": "Đặt lại thanh điều hướng",
|
||||
"navbar.custom.remove_bar": "Xóa khỏi thanh",
|
||||
"navbar.custom.full": "Hãy xóa một ô để thêm ô khác.",
|
||||
"navbar.custom.separators_full": "Thanh đã có bốn dải phân cách.",
|
||||
"navbar.custom.duplicate": "Ô này đã có trên thanh.",
|
||||
"navbar.custom.stale": "Thanh đã thay đổi. Hãy chọn lại ô.",
|
||||
"navbar.custom.unknown": "Ô này không khả dụng.",
|
||||
"navbar.custom.intro": "Chọn các điều khiển trên thanh ở cuối khung nhìn 3D và thứ tự của chúng. Kéo một ô để di chuyển, hoặc kéo ra khỏi thanh để xóa.",
|
||||
"navbar.custom.position_left": "Trái",
|
||||
"navbar.custom.position_centre": "Giữa",
|
||||
"navbar.custom.position_right": "Phải",
|
||||
"navbar.value_tip": "{name} · {value}",
|
||||
"navbar.translucent": "Bán trong suốt",
|
||||
"navbar.later": "Sau",
|
||||
"navbar.graphics": "Đồ họa",
|
||||
"navbar.preset": "Mẫu thiết lập sẵn",
|
||||
"navbar.show": "Hiển thị",
|
||||
"navbar.projection_heading": "Phép chiếu",
|
||||
"navbar.orthographic": "Trực giao",
|
||||
"navbar.perspective": "Phối cảnh",
|
||||
"navbar.assistant": "Trợ lý",
|
||||
"navbar.agent_cursor": "Hiện con trỏ tác tử",
|
||||
"navbar.agent_chat": "Bảng trò chuyện của trợ lý",
|
||||
"navbar.description.orbit": "Xoay góc nhìn quanh mô hình.",
|
||||
"navbar.description.pan": "Trượt góc nhìn sang ngang, lên hoặc xuống.",
|
||||
"navbar.description.zoom": "Đưa góc nhìn lại gần hoặc ra xa mô hình.",
|
||||
"navbar.description.spin": "Giữ cho góc nhìn tiếp tục xoay cho đến khi bạn nhấp chuột hoặc nhấn phím.",
|
||||
"navbar.description.fit": "Đưa vùng chọn vào khung nhìn, hoặc toàn bộ mô hình nếu chưa chọn gì.",
|
||||
"navbar.description.look_at": "Xoay góc nhìn về phía mặt, mặt phẳng hoặc bản phác đang mở đã chọn.",
|
||||
"navbar.description.home": "Quay về góc nhìn đẳng cự của toàn bộ mô hình.",
|
||||
"navbar.description.visual_style": "Đổi cách vẽ mô hình: tô bóng, khung dây hoặc có cạnh ẩn.",
|
||||
"navbar.description.display": "Chứa các cài đặt hiển thị: mẫu đồ họa, lưới, bóng đổ mặt sàn, đổ bóng che khuất môi trường và phép chiếu.",
|
||||
"navbar.description.grid": "Hiện hoặc ẩn lưới mặt sàn.",
|
||||
"navbar.description.ground_shadow": "Hiện hoặc ẩn bóng bên dưới mô hình.",
|
||||
"navbar.description.ambient_occlusion": "Làm tối các nếp gấp và góc để tạo chiều sâu.",
|
||||
"navbar.description.projection": "Chuyển giữa chế độ trực giao và phối cảnh.",
|
||||
"navbar.description.separator": "Một đường mảnh nhóm các ô liền kề."
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
{
|
||||
"en": {
|
||||
"navbar.ambient_occlusion": "Ambient occlusion",
|
||||
"navbar.display": "Display",
|
||||
"navbar.fit": "Fit",
|
||||
"navbar.grid": "Grid",
|
||||
"navbar.ground_shadow": "Ground shadow",
|
||||
"navbar.home": "Home",
|
||||
"navbar.look_at": "Look at",
|
||||
"navbar.more": "More",
|
||||
"navbar.orbit": "Orbit",
|
||||
"navbar.pan": "Pan",
|
||||
"navbar.projection": "Projection",
|
||||
"navbar.separator": "Separator",
|
||||
"navbar.spin": "Spin",
|
||||
"navbar.style.shaded": "Shaded",
|
||||
"navbar.style.shaded_with_edges": "Shaded with edges",
|
||||
"navbar.style.shaded_with_hidden_edges": "Shaded with hidden edges",
|
||||
"navbar.style.wireframe": "Wireframe",
|
||||
"navbar.visual_style": "Visual style",
|
||||
"navbar.zoom": "Zoom"
|
||||
},
|
||||
"ja": {
|
||||
"navbar.ambient_occlusion": "アンビエントオクルージョン",
|
||||
"navbar.display": "表示",
|
||||
"navbar.fit": "フィット",
|
||||
"navbar.grid": "グリッド",
|
||||
"navbar.ground_shadow": "地面の影",
|
||||
"navbar.home": "ホームビュー",
|
||||
"navbar.look_at": "正面から見る",
|
||||
"navbar.more": "その他",
|
||||
"navbar.orbit": "オービット",
|
||||
"navbar.pan": "パン",
|
||||
"navbar.projection": "透視投影",
|
||||
"navbar.separator": "区切り",
|
||||
"navbar.spin": "連続オービット",
|
||||
"navbar.style.shaded": "シェーディング",
|
||||
"navbar.style.shaded_with_edges": "エッジ付きシェーディング",
|
||||
"navbar.style.shaded_with_hidden_edges": "隠線付きシェーディング",
|
||||
"navbar.style.wireframe": "ワイヤーフレーム",
|
||||
"navbar.visual_style": "表示スタイル",
|
||||
"navbar.zoom": "ズーム"
|
||||
},
|
||||
"zh": {
|
||||
"navbar.ambient_occlusion": "环境光遮蔽",
|
||||
"navbar.display": "显示",
|
||||
"navbar.fit": "适合视图",
|
||||
"navbar.grid": "网格",
|
||||
"navbar.ground_shadow": "地面阴影",
|
||||
"navbar.home": "主视图",
|
||||
"navbar.look_at": "正视",
|
||||
"navbar.more": "更多",
|
||||
"navbar.orbit": "环绕",
|
||||
"navbar.pan": "平移",
|
||||
"navbar.projection": "透视投影",
|
||||
"navbar.separator": "分隔线",
|
||||
"navbar.spin": "连续环绕",
|
||||
"navbar.style.shaded": "着色",
|
||||
"navbar.style.shaded_with_edges": "带边线着色",
|
||||
"navbar.style.shaded_with_hidden_edges": "带隐藏边线着色",
|
||||
"navbar.style.wireframe": "线框",
|
||||
"navbar.visual_style": "视觉样式",
|
||||
"navbar.zoom": "缩放"
|
||||
},
|
||||
"ar": {
|
||||
"navbar.ambient_occlusion": "الإظلال المحيطي",
|
||||
"navbar.display": "العرض",
|
||||
"navbar.fit": "ملاءمة",
|
||||
"navbar.grid": "الشبكة",
|
||||
"navbar.ground_shadow": "ظل الأرض",
|
||||
"navbar.home": "الرئيسية",
|
||||
"navbar.look_at": "النظر إلى",
|
||||
"navbar.more": "المزيد",
|
||||
"navbar.orbit": "تدوير العرض",
|
||||
"navbar.pan": "إزاحة العرض",
|
||||
"navbar.projection": "الإسقاط",
|
||||
"navbar.separator": "فاصل",
|
||||
"navbar.spin": "دوران مستمر",
|
||||
"navbar.style.shaded": "مظلل",
|
||||
"navbar.style.shaded_with_edges": "مظلل مع الحواف",
|
||||
"navbar.style.shaded_with_hidden_edges": "مظلل مع الحواف المخفية",
|
||||
"navbar.style.wireframe": "إطار سلكي",
|
||||
"navbar.visual_style": "نمط العرض",
|
||||
"navbar.zoom": "تكبير"
|
||||
},
|
||||
"de": {
|
||||
"navbar.ambient_occlusion": "Umgebungsverdeckung",
|
||||
"navbar.display": "Anzeige",
|
||||
"navbar.fit": "Einpassen",
|
||||
"navbar.grid": "Raster",
|
||||
"navbar.ground_shadow": "Bodenschatten",
|
||||
"navbar.home": "Start",
|
||||
"navbar.look_at": "Ansehen",
|
||||
"navbar.more": "Mehr",
|
||||
"navbar.orbit": "Drehen",
|
||||
"navbar.pan": "Verschieben",
|
||||
"navbar.projection": "Projektion",
|
||||
"navbar.separator": "Trennlinie",
|
||||
"navbar.spin": "Dauerdrehung",
|
||||
"navbar.style.shaded": "Schattiert",
|
||||
"navbar.style.shaded_with_edges": "Schattiert mit Kanten",
|
||||
"navbar.style.shaded_with_hidden_edges": "Schattiert mit verdeckten Kanten",
|
||||
"navbar.style.wireframe": "Drahtmodell",
|
||||
"navbar.visual_style": "Darstellung",
|
||||
"navbar.zoom": "Zoomen"
|
||||
},
|
||||
"he": {
|
||||
"navbar.ambient_occlusion": "הצללה סביבתית (AO)",
|
||||
"navbar.display": "תצוגה",
|
||||
"navbar.fit": "התאמה לחלון",
|
||||
"navbar.grid": "רשת",
|
||||
"navbar.ground_shadow": "צל על הקרקע",
|
||||
"navbar.home": "בית",
|
||||
"navbar.look_at": "מבט אל",
|
||||
"navbar.more": "עוד",
|
||||
"navbar.orbit": "סיבוב מבט",
|
||||
"navbar.pan": "הזזת מבט",
|
||||
"navbar.projection": "הטלה",
|
||||
"navbar.separator": "מפריד",
|
||||
"navbar.spin": "סיבוב רציף",
|
||||
"navbar.style.shaded": "מוצלל",
|
||||
"navbar.style.shaded_with_edges": "מוצלל עם קצוות",
|
||||
"navbar.style.shaded_with_hidden_edges": "מוצלל עם קצוות נסתרים",
|
||||
"navbar.style.wireframe": "מסגרת תיל",
|
||||
"navbar.visual_style": "סגנון תצוגה",
|
||||
"navbar.zoom": "זום"
|
||||
},
|
||||
"ko": {
|
||||
"navbar.ambient_occlusion": "앰비언트 오클루전",
|
||||
"navbar.display": "표시",
|
||||
"navbar.fit": "맞춤",
|
||||
"navbar.grid": "격자",
|
||||
"navbar.ground_shadow": "바닥 그림자",
|
||||
"navbar.home": "홈",
|
||||
"navbar.look_at": "바라보기",
|
||||
"navbar.more": "더 보기",
|
||||
"navbar.orbit": "회전",
|
||||
"navbar.pan": "이동",
|
||||
"navbar.projection": "투영",
|
||||
"navbar.separator": "구분선",
|
||||
"navbar.spin": "연속 회전",
|
||||
"navbar.style.shaded": "음영 처리",
|
||||
"navbar.style.shaded_with_edges": "모서리 포함 음영",
|
||||
"navbar.style.shaded_with_hidden_edges": "숨은 모서리 포함 음영",
|
||||
"navbar.style.wireframe": "와이어프레임",
|
||||
"navbar.visual_style": "시각 스타일",
|
||||
"navbar.zoom": "확대/축소"
|
||||
},
|
||||
"vi": {
|
||||
"navbar.ambient_occlusion": "Đổ bóng che khuất môi trường (AO)",
|
||||
"navbar.display": "Hiển thị",
|
||||
"navbar.fit": "Vừa khung nhìn",
|
||||
"navbar.grid": "Lưới tọa độ",
|
||||
"navbar.ground_shadow": "Bóng đổ mặt sàn",
|
||||
"navbar.home": "Góc nhìn chuẩn",
|
||||
"navbar.look_at": "Nhìn vào",
|
||||
"navbar.more": "Thêm",
|
||||
"navbar.orbit": "Xoay góc nhìn",
|
||||
"navbar.pan": "Trượt góc nhìn",
|
||||
"navbar.projection": "Phép chiếu",
|
||||
"navbar.separator": "Dải phân cách",
|
||||
"navbar.spin": "Xoay liên tục",
|
||||
"navbar.style.shaded": "Tô bóng",
|
||||
"navbar.style.shaded_with_edges": "Tô bóng có cạnh",
|
||||
"navbar.style.shaded_with_hidden_edges": "Tô bóng có cạnh ẩn",
|
||||
"navbar.style.wireframe": "Khung dây",
|
||||
"navbar.visual_style": "Kiểu hiển thị trực quan",
|
||||
"navbar.zoom": "Thu phóng"
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,15 @@ const fn icon_primary(rgb: [u8; 3]) -> Color32 {
|
||||
impl Tokens {
|
||||
pub const fn light() -> Tokens {
|
||||
Tokens {
|
||||
nav_hover: Color32::from_rgb(233, 237, 242),
|
||||
nav_press: Color32::from_rgb(220, 226, 234),
|
||||
nav_dim: Color32::from_rgb(136, 149, 167),
|
||||
nav_viewport: Color32::from_rgb(238, 241, 245),
|
||||
nav_tip: Color32::from_rgb(27, 36, 48),
|
||||
nav_tip_ink: Color32::from_rgb(255, 255, 255),
|
||||
nav_tip_key_border: Color32::from_rgba_unmultiplied_const(128, 140, 160, 153),
|
||||
nav_field: Color32::from_rgb(255, 255, 255),
|
||||
|
||||
borders: crate::theme::Borders::LEGACY,
|
||||
icon_palette: None,
|
||||
file_dim: Color32::from_rgb(58, 70, 86),
|
||||
@@ -314,6 +323,14 @@ impl Tokens {
|
||||
t.render_ink = Color32::from_rgb(224, 116, 174);
|
||||
t.render_soft = Color32::from_rgb(64, 35, 54);
|
||||
t.tab_on_fill_dark = Color32::BLACK;
|
||||
t.nav_hover = Color32::from_rgb(58, 65, 80);
|
||||
t.nav_press = Color32::from_rgb(70, 78, 96);
|
||||
t.nav_dim = Color32::from_rgb(124, 135, 154);
|
||||
t.nav_viewport = Color32::from_rgb(38, 43, 53);
|
||||
t.nav_tip = Color32::from_rgb(238, 241, 245);
|
||||
t.nav_tip_ink = Color32::from_rgb(27, 36, 48);
|
||||
t.nav_tip_key_border = Color32::from_rgba_unmultiplied_const(128, 140, 160, 153);
|
||||
t.nav_field = Color32::from_rgb(47, 52, 62);
|
||||
t.dialog_body = Color32::from_rgb(39, 43, 52);
|
||||
t.dialog_footer = Color32::from_rgb(47, 52, 62);
|
||||
t.dialog_rule = Color32::from_rgb(53, 59, 71);
|
||||
|
||||
@@ -101,6 +101,14 @@
|
||||
"mesh_fill": "#ffffff",
|
||||
"mesh_ink": "#ffffff",
|
||||
"mesh_soft": "#000000",
|
||||
"nav_dim": "#ffffff",
|
||||
"nav_field": "#000000",
|
||||
"nav_hover": "#000000",
|
||||
"nav_press": "#ffffff",
|
||||
"nav_tip": "#ffffff",
|
||||
"nav_tip_ink": "#000000",
|
||||
"nav_tip_key_border": "#000000",
|
||||
"nav_viewport": "#000000",
|
||||
"on_accent": "#000000",
|
||||
"origin_plane": "#000000",
|
||||
"origin_plane_edge": "#ffffff",
|
||||
|
||||
@@ -101,6 +101,14 @@
|
||||
"mesh_fill": "#000000",
|
||||
"mesh_ink": "#000000",
|
||||
"mesh_soft": "#ffffff",
|
||||
"nav_dim": "#000000",
|
||||
"nav_field": "#ffffff",
|
||||
"nav_hover": "#ffffff",
|
||||
"nav_press": "#000000",
|
||||
"nav_tip": "#000000",
|
||||
"nav_tip_ink": "#ffffff",
|
||||
"nav_tip_key_border": "#ffffff",
|
||||
"nav_viewport": "#ffffff",
|
||||
"on_accent": "#ffffff",
|
||||
"origin_plane": "#ffffff",
|
||||
"origin_plane_edge": "#000000",
|
||||
|
||||
@@ -101,6 +101,14 @@
|
||||
"mesh_fill": "#55ff55",
|
||||
"mesh_ink": "#55ff55",
|
||||
"mesh_soft": "#000000",
|
||||
"nav_dim": "#55ffff",
|
||||
"nav_field": "#000000",
|
||||
"nav_hover": "#aa00aa",
|
||||
"nav_press": "#ff55ff",
|
||||
"nav_tip": "#ffffff",
|
||||
"nav_tip_ink": "#000000",
|
||||
"nav_tip_key_border": "#55ffff",
|
||||
"nav_viewport": "#000000",
|
||||
"on_accent": "#000000",
|
||||
"origin_plane": "#55ffff20",
|
||||
"origin_plane_edge": "#55ffff80",
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
| `assets/locales/pending/navbar-customisation.json` | SolidCraft contributors | Original navigation bar editor translations | MIT OR Apache-2.0 |
|
||||
@@ -0,0 +1 @@
|
||||
| `assets/locales/pending/navbar-slots.json` | SolidCraft contributors | Original navigation slot translations | MIT OR Apache-2.0 |
|
||||
@@ -280,6 +280,7 @@ fn groups(t: &Tokens) -> Vec<Group> {
|
||||
group("card text", &[("form_ink", t.form_ink), ("form_error", t.form_error)], &[("dialog_body", t.dialog_body)]),
|
||||
group("card hints", &[("form_dim", t.form_dim)], &[("dialog_body", t.dialog_body)]),
|
||||
group("card primary", &[("form_primary", t.form_primary)], &[("dialog_body", t.dialog_body)]),
|
||||
group("navigation status", &[("form_primary", t.form_primary), ("warning", t.warning)], &[("dialog_body", t.dialog_body)]),
|
||||
// Validation is identified by its words as well as colour. Measure both the
|
||||
// ink and badge surfaces against the corresponding failure states.
|
||||
group(
|
||||
@@ -377,6 +378,14 @@ 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)] = &[
|
||||
("nav_hover", "neutral hover surface; placement and pointer feedback identify the control"),
|
||||
("nav_press", "neutral pressed/open surface; interaction and menu presence identify the state"),
|
||||
("nav_dim", "neutral secondary ink; the Later label identifies the unavailable option"),
|
||||
("nav_field", "neutral control surface, not a semantic category"),
|
||||
("nav_tip", "neutral tooltip surface, not a semantic category"),
|
||||
("nav_tip_ink", "neutral tooltip text; words identify the control and value"),
|
||||
("nav_tip_key_border", "neutral keycap outline; its key label carries the meaning"),
|
||||
("nav_viewport", "neutral preview-stage background, not model or status colour"),
|
||||
("borders.primary", "structural chrome: hierarchy uses width, pattern and placement, not hue"),
|
||||
("borders.secondary", "structural chrome: hierarchy uses width, pattern and placement, not hue"),
|
||||
("borders.secondary_dotted", "structural chrome: hierarchy uses width, pattern and placement, not hue"),
|
||||
|
||||
@@ -1322,3 +1322,23 @@ fn perforate_edit_restores_dimensions_pattern_and_target() {
|
||||
assert_eq!(params[key], value, "{key} is restored");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn flat_pattern_navigation_slots_hide_orbit_controls_and_keep_fit_home() {
|
||||
let ctx = crate::fonts::test_context();
|
||||
let mut app = flat_app("fusion", crate::shell::LayoutMode::Floating);
|
||||
app.preferences.navigation_bar = serde_json::from_value(json!({
|
||||
"slots":["orbit","spin","look_at","projection","visual_style","pan","zoom","fit","home","display"]
|
||||
}))
|
||||
.unwrap();
|
||||
let mut time = 0.0;
|
||||
crate::scenario::clear_handles();
|
||||
frame(&mut app, &ctx, &mut time, egui::Modifiers::NONE, vec![]);
|
||||
assert_eq!(crate::navigation_bar::canvas_caps(&app), crate::navigation::NavCaps { orbit: false, pick: false });
|
||||
for slot in ["orbit", "spin", "look_at", "projection", "visual_style"] {
|
||||
assert!(crate::scenario::handle_at(&format!("nav:slot:{slot}")).is_none(), "{slot}");
|
||||
}
|
||||
for slot in ["pan", "zoom", "fit", "home", "display"] {
|
||||
assert!(crate::scenario::handle_at(&format!("nav:slot:{slot}")).is_some(), "{slot}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,6 +184,8 @@ mod file_load_ui_tests;
|
||||
mod fillet_spline_handle_tests;
|
||||
pub mod mouse_gesture;
|
||||
pub(crate) mod navigation;
|
||||
pub mod navigation_bar;
|
||||
mod navigation_bar_view;
|
||||
pub use navigation::WebWheelGestures;
|
||||
pub mod network_prompt;
|
||||
pub mod open_elsewhere;
|
||||
@@ -1853,7 +1855,7 @@ impl SolveApp {
|
||||
}
|
||||
|
||||
fn resolve_fit(&mut self, ctx: &egui::Context) {
|
||||
viewport::refresh_layout(self, ctx.pixels_per_point());
|
||||
viewport::refresh_layout(self, ctx);
|
||||
if self.viewport.layout.is_some()
|
||||
&& let Some((cam, bounds, animate)) = self.pending_fit.take()
|
||||
{
|
||||
@@ -2299,7 +2301,7 @@ impl SolveApp {
|
||||
.into_iter()
|
||||
.filter(|r| r.is_positive())
|
||||
.collect();
|
||||
viewport::refresh_layout(self, ui.ctx().pixels_per_point());
|
||||
viewport::refresh_layout(self, ui.ctx());
|
||||
} else {
|
||||
preview::update(self, ui.ctx());
|
||||
self.show_workspace(ui);
|
||||
|
||||
@@ -0,0 +1,345 @@
|
||||
//! Stored navigation slots and their catalogue. Painting lives in `navigation_bar_view`.
|
||||
use crate::{SolveApp, navigation::NavCaps};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
|
||||
pub const MAX_SLOTS: usize = 16;
|
||||
pub const MAX_SEPARATORS: usize = 4;
|
||||
|
||||
// Reserved for the selection-mode slot in #6326; no runtime consumer yet.
|
||||
#[cfg(test)]
|
||||
pub(crate) const SELECTION_MODE_ICONS: &[(&str, &str)] = &[
|
||||
("faces_edges", "select_faces_edges"),
|
||||
("bodies", "select_bodies"),
|
||||
("features", "select_features"),
|
||||
("parts", "select_parts"),
|
||||
("components", "select_components"),
|
||||
("sketch", "select_sketch"),
|
||||
];
|
||||
|
||||
pub(crate) fn visual_style_icon(style: u8) -> &'static str {
|
||||
match style {
|
||||
1 => "style_shaded",
|
||||
2 => "style_wireframe",
|
||||
3 => "style_hidden_edges",
|
||||
_ => "style_shaded_edges",
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum Kind {
|
||||
Action,
|
||||
Tool,
|
||||
Toggle,
|
||||
Menu,
|
||||
Separator,
|
||||
}
|
||||
|
||||
pub(crate) struct Slot {
|
||||
pub id: &'static str,
|
||||
pub kind: Kind,
|
||||
pub icon: &'static str,
|
||||
pub label: &'static str,
|
||||
pub description: &'static str,
|
||||
pub command: Option<&'static str>,
|
||||
}
|
||||
|
||||
macro_rules! slot {
|
||||
($id:literal, $kind:ident, $icon:literal, $command:expr) => {
|
||||
Slot {
|
||||
id: $id,
|
||||
kind: Kind::$kind,
|
||||
icon: $icon,
|
||||
label: concat!("navbar.", $id),
|
||||
description: concat!("navbar.description.", $id),
|
||||
command: $command,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) const CATALOGUE: &[Slot] = &[
|
||||
slot!("orbit", Tool, "orbit", Some("view.tool")),
|
||||
slot!("pan", Tool, "pan", Some("view.tool")),
|
||||
slot!("zoom", Tool, "zoom", Some("view.tool")),
|
||||
slot!("spin", Toggle, "spin", Some("view.spin")),
|
||||
slot!("fit", Action, "fit", Some("view.fit")),
|
||||
slot!("look_at", Action, "lookat", Some("view.normal_to")),
|
||||
slot!("home", Action, "home", Some("view.home")),
|
||||
slot!("visual_style", Menu, "style_shaded_edges", Some("view.visual_style")),
|
||||
slot!("projection", Toggle, "perspective", None),
|
||||
slot!("display", Menu, "display", None),
|
||||
slot!("grid", Toggle, "grid", Some("view.grid")),
|
||||
slot!("ground_shadow", Toggle, "ground_shadow", Some("view.ground_shadow")),
|
||||
slot!("ambient_occlusion", Toggle, "ambient_occlusion", Some("view.ambient_occlusion")),
|
||||
slot!("separator", Separator, "", None),
|
||||
];
|
||||
|
||||
pub(crate) fn find(id: &str) -> Option<&'static Slot> {
|
||||
CATALOGUE.iter().find(|slot| slot.id == id)
|
||||
}
|
||||
|
||||
impl Slot {
|
||||
pub(crate) fn current_icon(&self, visual_style: u8) -> &'static str {
|
||||
if self.id == "visual_style" { visual_style_icon(visual_style) } else { self.icon }
|
||||
}
|
||||
|
||||
pub(crate) fn available(&self, caps: NavCaps) -> bool {
|
||||
if !caps.orbit {
|
||||
return !matches!(self.id, "orbit" | "spin" | "look_at" | "projection" | "visual_style");
|
||||
}
|
||||
if !caps.pick && matches!(self.id, "look_at" | "visual_style") {
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn canvas_caps(app: &SolveApp) -> NavCaps {
|
||||
if crate::dialogs_sheet::flat_active(app) || crate::render_workspace::result_active(app) {
|
||||
NavCaps { orbit: false, pick: false }
|
||||
} else if crate::render_workspace::active(app) {
|
||||
NavCaps::RENDER
|
||||
} else {
|
||||
NavCaps::MODEL
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum Position {
|
||||
#[default]
|
||||
#[serde(alias = "bottom")]
|
||||
Centre,
|
||||
#[serde(alias = "bottom_left")]
|
||||
Left,
|
||||
#[serde(alias = "bottom_right")]
|
||||
Right,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum Size {
|
||||
Compact,
|
||||
#[default]
|
||||
Regular,
|
||||
}
|
||||
|
||||
impl Size {
|
||||
// Logical points: egui's UI zoom applies the preference's scale to these dimensions.
|
||||
pub(crate) fn points(self) -> f32 {
|
||||
crate::ui_kit::NavigationMetrics::for_size(self).button
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum Labels {
|
||||
#[default]
|
||||
Icons,
|
||||
Labels,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum Idle {
|
||||
Always,
|
||||
#[default]
|
||||
Fade,
|
||||
Hide,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum MenuDisplay {
|
||||
IconAndValue,
|
||||
#[default]
|
||||
IconOnly,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
|
||||
pub struct SlotOptions {
|
||||
pub shows: MenuDisplay,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
|
||||
pub struct NavigationBar {
|
||||
pub slots: Vec<String>,
|
||||
pub slot_options: std::collections::BTreeMap<String, SlotOptions>,
|
||||
pub position: Position,
|
||||
pub size: Size,
|
||||
pub labels: Labels,
|
||||
pub idle: Idle,
|
||||
}
|
||||
|
||||
impl Default for NavigationBar {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
slots: ["orbit", "pan", "zoom", "separator", "fit", "look_at", "home", "separator", "visual_style", "display"]
|
||||
.into_iter()
|
||||
.map(str::to_owned)
|
||||
.collect(),
|
||||
slot_options: Default::default(),
|
||||
position: Position::default(),
|
||||
size: Size::default(),
|
||||
labels: Labels::default(),
|
||||
idle: Idle::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for NavigationBar {
|
||||
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
|
||||
let value = Value::deserialize(deserializer)?;
|
||||
let mut bar = Self::default();
|
||||
if let Some(ids) = value.get("slots").and_then(Value::as_array) {
|
||||
let mut seen = std::collections::BTreeSet::new();
|
||||
let mut separators = 0;
|
||||
bar.slots = ids
|
||||
.iter()
|
||||
.filter_map(Value::as_str)
|
||||
.filter(|id| {
|
||||
if *id == "separator" {
|
||||
if separators == MAX_SEPARATORS {
|
||||
return false;
|
||||
}
|
||||
separators += 1;
|
||||
true
|
||||
} else {
|
||||
seen.insert(*id)
|
||||
}
|
||||
})
|
||||
.take(MAX_SLOTS)
|
||||
.map(str::to_owned)
|
||||
.collect();
|
||||
}
|
||||
if let Some(options) = value.get("slot_options").and_then(Value::as_object) {
|
||||
for (id, option) in options.iter().take(MAX_SLOTS) {
|
||||
if id.len() <= 128 && find(id).is_some_and(|slot| slot.kind == Kind::Menu) {
|
||||
let shows = option.get("shows").cloned().and_then(|v| serde_json::from_value(v).ok()).unwrap_or_default();
|
||||
bar.slot_options.insert(id.clone(), SlotOptions { shows });
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(v) = value.get("position") {
|
||||
bar.position = serde_json::from_value(v.clone()).unwrap_or_default();
|
||||
}
|
||||
if let Some(v) = value.get("size") {
|
||||
bar.size = serde_json::from_value(v.clone()).unwrap_or_default();
|
||||
}
|
||||
if let Some(v) = value.get("labels") {
|
||||
bar.labels = serde_json::from_value(v.clone()).unwrap_or_default();
|
||||
}
|
||||
if let Some(v) = value.get("idle") {
|
||||
bar.idle = serde_json::from_value(v.clone()).unwrap_or_default();
|
||||
}
|
||||
Ok(bar)
|
||||
}
|
||||
}
|
||||
|
||||
/// Interactive callers get errors for malformed values; saved files recover field by field.
|
||||
pub(crate) fn validate(value: &Value) -> Result<(), String> {
|
||||
let object = value.as_object().ok_or("`navigation_bar` must be an object")?;
|
||||
for (key, value) in object {
|
||||
let valid = match key.as_str() {
|
||||
"slots" => value.as_array().is_some_and(|ids| ids.iter().all(Value::is_string)),
|
||||
"slot_options" => value.as_object().is_some_and(|options| {
|
||||
options.len() <= MAX_SLOTS
|
||||
&& options.iter().all(|(id, option)| {
|
||||
id.len() <= 128
|
||||
&& option.as_object().is_some_and(|fields| {
|
||||
fields.iter().all(|(key, v)| key == "shows" && serde_json::from_value::<MenuDisplay>(v.clone()).is_ok())
|
||||
})
|
||||
})
|
||||
}),
|
||||
"position" => serde_json::from_value::<Position>(value.clone()).is_ok(),
|
||||
"size" => serde_json::from_value::<Size>(value.clone()).is_ok(),
|
||||
"labels" => serde_json::from_value::<Labels>(value.clone()).is_ok(),
|
||||
"idle" => serde_json::from_value::<Idle>(value.clone()).is_ok(),
|
||||
_ => return Err(format!("unknown navigation_bar field `{key}`")),
|
||||
};
|
||||
if !valid {
|
||||
return Err(format!("invalid navigation_bar `{key}`"));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl NavigationBar {
|
||||
pub(crate) fn menu_display(&self, id: &str) -> MenuDisplay {
|
||||
if id == "display" {
|
||||
return MenuDisplay::IconOnly;
|
||||
}
|
||||
self.slot_options
|
||||
.get(id)
|
||||
.map(|option| option.shows)
|
||||
.unwrap_or_else(|| if matches!(id, "selection_mode" | "render_mode") { MenuDisplay::IconAndValue } else { MenuDisplay::IconOnly })
|
||||
}
|
||||
|
||||
/// Apply a drag only to the list it began on, including repeated separator occurrences.
|
||||
pub(crate) fn drop_slot(
|
||||
&mut self,
|
||||
original: &[String],
|
||||
from: Option<usize>,
|
||||
id: &str,
|
||||
gap: Option<usize>,
|
||||
) -> Result<Option<usize>, &'static str> {
|
||||
if original != self.slots.as_slice() || from.is_some_and(|index| self.slots.get(index).is_none_or(|slot| slot != id)) {
|
||||
return Err("navbar.custom.stale");
|
||||
}
|
||||
match (from, gap) {
|
||||
(Some(from), Some(gap)) => self.move_to(from, gap).map(Some),
|
||||
(Some(from), None) => self.remove(from).map(|()| None),
|
||||
(None, Some(gap)) => self.insert(gap, id).map(|()| Some(gap)),
|
||||
(None, None) => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn can_insert(&self, id: &str) -> Result<(), &'static str> {
|
||||
if find(id).is_none() {
|
||||
return Err("navbar.custom.unknown");
|
||||
}
|
||||
if self.slots.len() >= MAX_SLOTS {
|
||||
return Err("navbar.custom.full");
|
||||
}
|
||||
if id == "separator" {
|
||||
if self.slots.iter().filter(|s| s.as_str() == id).count() >= MAX_SEPARATORS {
|
||||
return Err("navbar.custom.separators_full");
|
||||
}
|
||||
} else if self.slots.iter().any(|s| s == id) {
|
||||
return Err("navbar.custom.duplicate");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn insert(&mut self, index: usize, id: &str) -> Result<(), &'static str> {
|
||||
self.can_insert(id)?;
|
||||
if index > self.slots.len() {
|
||||
return Err("navbar.custom.stale");
|
||||
}
|
||||
self.slots.insert(index, id.to_owned());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn remove(&mut self, index: usize) -> Result<(), &'static str> {
|
||||
if self.slots.get(index).is_none() {
|
||||
return Err("navbar.custom.stale");
|
||||
}
|
||||
self.slots.remove(index);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Destination is a gap in the original list, including the gap after its last slot.
|
||||
pub(crate) fn move_to(&mut self, from: usize, gap: usize) -> Result<usize, &'static str> {
|
||||
if self.slots.get(from).is_none() || gap > self.slots.len() {
|
||||
return Err("navbar.custom.stale");
|
||||
}
|
||||
let to = if gap > from { gap - 1 } else { gap };
|
||||
let id = self.slots.remove(from);
|
||||
self.slots.insert(to, id);
|
||||
Ok(to)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "navigation_bar_tests.rs"]
|
||||
mod tests;
|
||||
@@ -0,0 +1,558 @@
|
||||
use super::*;
|
||||
use crate::navigation_bar_view::measure;
|
||||
use egui::{Rect, pos2, vec2};
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn selection_mode_icons_resolve_to_real_masters() {
|
||||
assert_eq!(SELECTION_MODE_ICONS.len(), 6);
|
||||
for (mode, icon) in SELECTION_MODE_ICONS {
|
||||
let resolved = crate::icon_svg::resolve(icon);
|
||||
assert!(!resolved.placeholder, "{mode}: {icon}");
|
||||
assert_eq!(resolved.master, *icon);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn slot_icons_follow_current_style_and_display_toggle_meanings() {
|
||||
let slot = find("visual_style").unwrap();
|
||||
for (style, icon) in [(0, "style_shaded_edges"), (1, "style_shaded"), (2, "style_wireframe"), (3, "style_hidden_edges")] {
|
||||
assert_eq!(slot.current_icon(style), icon);
|
||||
let resolved = crate::icon_svg::resolve(icon);
|
||||
assert!(!resolved.placeholder, "{style}: {icon}");
|
||||
assert_eq!(resolved.master, if style == 0 { "style" } else { icon });
|
||||
}
|
||||
assert_eq!(slot.current_icon(u8::MAX), "style_shaded_edges");
|
||||
assert!(!crate::icon_svg::resolve("style_translucent").placeholder);
|
||||
for id in ["display", "grid", "ground_shadow", "ambient_occlusion"] {
|
||||
assert_eq!(find(id).unwrap().current_icon(2), id);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn slot_catalogue_uses_registered_commands_and_existing_icons() {
|
||||
let mut ids = std::collections::BTreeSet::new();
|
||||
for slot in CATALOGUE {
|
||||
assert!(ids.insert(slot.id), "duplicate catalogue id {}", slot.id);
|
||||
match slot.command {
|
||||
Some(command) => assert!(solidcraft_engine::find_command(command).is_some(), "{}", slot.id),
|
||||
None => assert!(["projection", "display", "separator"].contains(&slot.id)),
|
||||
}
|
||||
if slot.kind != Kind::Separator {
|
||||
assert!(!crate::icon_svg::resolve(slot.icon).placeholder, "{}: {}", slot.id, slot.icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn catalogue_slot_descriptions_explain_slots_without_settings_jargon() {
|
||||
for slot in CATALOGUE {
|
||||
for language in ["en", "ja", "zh"] {
|
||||
let description = crate::i18n::Locale::for_language(language).text(slot.description);
|
||||
assert!(!description.trim().is_empty() && description != slot.description, "{language}: {} needs a description", slot.id);
|
||||
assert!(description.ends_with(['.', '。']), "{language}: {} must be a sentence", slot.id);
|
||||
let lower = description.to_lowercase();
|
||||
assert!(!lower.contains("icon only") && !lower.contains("icon and value"), "{language}: {} describes settings controls", slot.id);
|
||||
// The owner's exact Grid/Shadow copy uses "Shows" as a visibility verb,
|
||||
// rather than naming the inspector's Shows setting.
|
||||
let words = if language == "en" && matches!(slot.id, "grid" | "ground_shadow") {
|
||||
description.strip_prefix("Shows or hides ").expect("the specified visibility description")
|
||||
} else {
|
||||
description
|
||||
};
|
||||
assert!(
|
||||
!words.split(|c: char| !c.is_alphabetic()).any(|word| word.eq_ignore_ascii_case("shows")),
|
||||
"{language}: {} names the Shows setting",
|
||||
slot.id
|
||||
);
|
||||
}
|
||||
}
|
||||
assert!(find("future_slot").is_none(), "unknown slots have no catalogue description");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_slots_and_canvas_availability_preserve_navigation() {
|
||||
let bar = NavigationBar::default();
|
||||
assert_eq!(bar.slots, ["orbit", "pan", "zoom", "separator", "fit", "look_at", "home", "separator", "visual_style", "display"]);
|
||||
let flat = NavCaps { orbit: false, pick: false };
|
||||
for caps in [NavCaps::MODEL, NavCaps::RENDER, flat] {
|
||||
let shown: Vec<_> = CATALOGUE.iter().filter(|slot| slot.available(caps)).map(|slot| slot.id).collect();
|
||||
for id in ["orbit", "spin", "look_at", "projection", "visual_style"] {
|
||||
assert_eq!(shown.contains(&id), caps.orbit && (caps.pick || !matches!(id, "look_at" | "visual_style")), "{caps:?}: {id}");
|
||||
}
|
||||
for id in ["pan", "zoom", "fit", "home", "display", "grid", "ground_shadow", "ambient_occlusion"] {
|
||||
assert!(shown.contains(&id), "{caps:?}: {id}");
|
||||
}
|
||||
}
|
||||
let mut app = crate::SolveApp::new(Default::default(), Default::default());
|
||||
app.run("sketch.create", json!({"plane":"XY"})).unwrap();
|
||||
assert!(find("visual_style").unwrap().available(canvas_caps(&app)), "the previous bar kept style available in a sketch");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn measured_bar_drops_labels_then_overflows_in_order_without_compass_overlap() {
|
||||
let prefs = NavigationBar { labels: Labels::Labels, ..Default::default() };
|
||||
for width in [5.0, 39.0, 46.0, 90.0, 160.0, 250.0, 310.0, 700.0, 1400.0] {
|
||||
for height in [30.0, 80.0, 130.0, 240.0, 720.0] {
|
||||
let canvas = Rect::from_min_size(pos2(20.0, 30.0), vec2(width, height));
|
||||
let bar = measure(canvas, &prefs, NavCaps::MODEL, |_| 50.0);
|
||||
let layout = crate::viewport_layout::Layout::with_content(
|
||||
canvas,
|
||||
canvas,
|
||||
&[],
|
||||
1.0,
|
||||
crate::prefs::NavigatorStyle::Cube,
|
||||
egui::Vec2::ZERO,
|
||||
bar.rect,
|
||||
);
|
||||
assert!(!layout.axis_view.intersect(bar.rect).is_positive());
|
||||
if !bar.rect.is_positive() {
|
||||
continue;
|
||||
}
|
||||
assert!(canvas.contains_rect(bar.rect));
|
||||
assert_eq!(bar.rect.height(), crate::ui_kit::NavigationMetrics::for_size(prefs.size).height());
|
||||
let mut previous = bar.rect.left();
|
||||
for (_, rect) in &bar.slots {
|
||||
assert!(bar.rect.contains_rect(*rect));
|
||||
assert!(rect.left() >= previous);
|
||||
previous = rect.right();
|
||||
}
|
||||
if bar.more.is_positive() {
|
||||
assert!(!bar.labels);
|
||||
assert!(bar.rect.contains_rect(bar.more));
|
||||
assert!(bar.more.left() >= previous);
|
||||
}
|
||||
let order: Vec<_> = bar.slots.iter().map(|(slot, _)| slot.id).chain(bar.overflow.iter().map(|slot| slot.id)).collect();
|
||||
assert_eq!(order, prefs.slots);
|
||||
}
|
||||
}
|
||||
let wide = Rect::from_min_size(pos2(0.0, 0.0), vec2(1400.0, 720.0));
|
||||
assert!(measure(wide, &prefs, NavCaps::MODEL, |_| 50.0).labels);
|
||||
let middle = Rect::from_min_size(pos2(0.0, 0.0), vec2(380.0, 720.0));
|
||||
let bar = measure(middle, &prefs, NavCaps::MODEL, |_| 50.0);
|
||||
assert!(!bar.labels && bar.overflow.is_empty(), "text disappears before slots fold");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn measured_bar_honours_size_position_and_ignores_unknown_slots() {
|
||||
let canvas = Rect::from_min_size(pos2(20.0, 30.0), vec2(700.0, 500.0));
|
||||
for size in [Size::Compact, Size::Regular] {
|
||||
for position in [Position::Centre, Position::Left, Position::Right] {
|
||||
let prefs: NavigationBar = serde_json::from_value(json!({"slots":["future", "pan", "fit"], "size":size, "position":position})).unwrap();
|
||||
let bar = measure(canvas, &prefs, NavCaps::MODEL, |_| 0.0);
|
||||
assert_eq!(bar.slots.iter().map(|(slot, _)| slot.id).collect::<Vec<_>>(), ["pan", "fit"]);
|
||||
assert!(bar.slots.iter().all(|(_, rect)| rect.height() == size.points()));
|
||||
match position {
|
||||
Position::Centre => assert_eq!(bar.rect.center().x, canvas.center().x),
|
||||
Position::Left => assert_eq!(bar.rect.left(), canvas.left() + crate::ui_kit::NAV_EDGE),
|
||||
Position::Right => assert_eq!(bar.rect.right(), canvas.right() - crate::ui_kit::NAV_EDGE),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_slot_visuals_never_use_focus_as_a_fill() {
|
||||
use crate::ui_kit::{NavigationFill, navigation_visual};
|
||||
for kind in [Kind::Action, Kind::Tool, Kind::Toggle, Kind::Menu] {
|
||||
for keyboard_focus in [false, true] {
|
||||
assert_eq!(
|
||||
navigation_visual(kind, false, false, false, keyboard_focus),
|
||||
(NavigationFill::None, keyboard_focus),
|
||||
"{kind:?}: idle or released"
|
||||
);
|
||||
for (hovered, pressed) in [(true, false), (false, true), (true, true)] {
|
||||
assert_eq!(
|
||||
navigation_visual(kind, false, hovered, pressed, keyboard_focus),
|
||||
(if pressed { NavigationFill::Press } else { NavigationFill::Hover }, keyboard_focus),
|
||||
"{kind:?}: hover or press"
|
||||
);
|
||||
}
|
||||
let active_fill = match kind {
|
||||
Kind::Action => NavigationFill::None,
|
||||
Kind::Menu => NavigationFill::Press,
|
||||
_ => NavigationFill::Active,
|
||||
};
|
||||
assert_eq!(
|
||||
navigation_visual(kind, true, false, false, keyboard_focus),
|
||||
(active_fill, keyboard_focus),
|
||||
"{kind:?}: active tool/toggle or open menu"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_slot_pointer_clicks_release_focus_and_leave_no_fill() {
|
||||
use crate::theme::Tokens;
|
||||
use crate::ui_kit::{NavigationButton, navigation_button};
|
||||
use egui::{Color32, Event, RawInput, Shape};
|
||||
|
||||
fn fill(output: &egui::FullOutput, bounds: Rect) -> Option<Color32> {
|
||||
let mut fill = None;
|
||||
for shape in &output.shapes {
|
||||
crate::test_support::each_shape(&shape.shape, &mut |shape| {
|
||||
if let Shape::Rect(rect) = shape
|
||||
&& rect.rect == bounds
|
||||
&& rect.fill != Color32::TRANSPARENT
|
||||
{
|
||||
fill = Some(rect.fill);
|
||||
}
|
||||
});
|
||||
}
|
||||
fill
|
||||
}
|
||||
|
||||
for kind in [Kind::Action, Kind::Tool, Kind::Toggle] {
|
||||
let ctx = crate::fonts::test_context();
|
||||
let bounds = Rect::from_min_size(pos2(20.0, 30.0), vec2(26.0, 26.0));
|
||||
let draw = |events, selected| {
|
||||
let mut focused = false;
|
||||
let mut clicked = false;
|
||||
let output = crate::test_support::frame(
|
||||
&ctx,
|
||||
RawInput {
|
||||
screen_rect: Some(Rect::from_min_size(egui::Pos2::ZERO, vec2(320.0, 400.0))),
|
||||
events,
|
||||
focused: true,
|
||||
..Default::default()
|
||||
},
|
||||
|ui| {
|
||||
let response = navigation_button(
|
||||
ui,
|
||||
bounds,
|
||||
NavigationButton { id: "regression", label: "Fit", icon: "fit", selected, kind, labels: false, menu: false },
|
||||
);
|
||||
focused = response.has_focus();
|
||||
clicked = response.clicked();
|
||||
},
|
||||
);
|
||||
(output, focused, clicked)
|
||||
};
|
||||
draw(vec![], false);
|
||||
draw(vec![Event::PointerMoved(bounds.center())], false);
|
||||
let pressed = draw(crate::test_support::pointer(bounds.center(), true), false);
|
||||
assert_eq!(fill(&pressed.0, bounds), Some(Tokens::get().nav_press), "{kind:?}: pressed");
|
||||
let released = draw(crate::test_support::pointer(bounds.center(), false), false);
|
||||
assert!(released.2, "{kind:?}: real pointer activation");
|
||||
assert!(!released.1, "{kind:?}: pointer activation must surrender focus");
|
||||
let away = draw(vec![Event::PointerMoved(pos2(200.0, 200.0))], false);
|
||||
assert_eq!(fill(&away.0, bounds), None, "{kind:?}: no lingering fill");
|
||||
if kind != Kind::Action {
|
||||
let active = draw(vec![], true);
|
||||
assert_eq!(fill(&active.0, bounds), Some(Tokens::get().selected_bg));
|
||||
draw(crate::test_support::pointer(bounds.center(), true), true);
|
||||
let released = draw(crate::test_support::pointer(bounds.center(), false), true);
|
||||
assert!(released.2 && !released.1);
|
||||
let off = draw(vec![Event::PointerMoved(pos2(200.0, 200.0))], false);
|
||||
assert_eq!(fill(&off.0, bounds), None, "{kind:?}: tool/toggle released");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_list_operations_check_indices_caps_duplicates_and_separators() {
|
||||
let mut bar = NavigationBar { slots: Vec::new(), ..Default::default() };
|
||||
assert!(bar.insert(1, "pan").is_err());
|
||||
assert!(bar.insert(0, "unknown").is_err());
|
||||
bar.insert(0, "pan").unwrap();
|
||||
bar.insert(0, "fit").unwrap();
|
||||
bar.insert(2, "home").unwrap();
|
||||
assert_eq!(bar.slots, ["fit", "pan", "home"]);
|
||||
assert!(bar.insert(0, "pan").is_err());
|
||||
assert_eq!(bar.move_to(0, 3).unwrap(), 2);
|
||||
assert_eq!(bar.slots, ["pan", "home", "fit"]);
|
||||
assert_eq!(bar.move_to(2, 0).unwrap(), 0);
|
||||
assert_eq!(bar.move_to(0, 1).unwrap(), 0);
|
||||
let before = bar.clone();
|
||||
for (from, gap) in [(usize::MAX, 0), (0, usize::MAX), (3, 0)] {
|
||||
assert!(bar.move_to(from, gap).is_err());
|
||||
assert_eq!(bar, before);
|
||||
}
|
||||
assert!(bar.remove(usize::MAX).is_err());
|
||||
bar.remove(1).unwrap();
|
||||
assert_eq!(bar.slots, ["fit", "home"]);
|
||||
for _ in 0..MAX_SEPARATORS {
|
||||
bar.insert(0, "separator").unwrap();
|
||||
}
|
||||
assert!(bar.insert(0, "separator").is_err());
|
||||
for slot in CATALOGUE {
|
||||
if bar.slots.len() == MAX_SLOTS {
|
||||
break;
|
||||
}
|
||||
if slot.id != "separator" && !bar.slots.iter().any(|id| id == slot.id) {
|
||||
bar.insert(bar.slots.len(), slot.id).unwrap();
|
||||
}
|
||||
}
|
||||
assert_eq!(bar.slots.len(), MAX_SLOTS);
|
||||
assert_eq!(bar.can_insert("pan"), Err("navbar.custom.full"));
|
||||
assert!(bar.insert(0, "pan").is_err());
|
||||
while !bar.slots.is_empty() {
|
||||
bar.remove(0).unwrap();
|
||||
}
|
||||
assert!(bar.remove(0).is_err());
|
||||
assert!(bar.move_to(0, 0).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_menu_options_round_trip_and_old_lists_load() {
|
||||
let old: NavigationBar = serde_json::from_value(json!({"slots":["visual_style","display","future"]})).unwrap();
|
||||
assert_eq!(old.slots, ["visual_style", "display", "future"]);
|
||||
assert_eq!(old.menu_display("visual_style"), MenuDisplay::IconOnly);
|
||||
assert_eq!(old.menu_display("selection_mode"), MenuDisplay::IconAndValue);
|
||||
assert_eq!(old.menu_display("render_mode"), MenuDisplay::IconAndValue);
|
||||
let value = json!({"slots":["visual_style","display"], "slot_options":{"visual_style":{"shows":"icon_and_value"}}});
|
||||
validate(&value).unwrap();
|
||||
let bar: NavigationBar = serde_json::from_value(value).unwrap();
|
||||
assert_eq!(bar.menu_display("visual_style"), MenuDisplay::IconAndValue);
|
||||
assert_eq!(serde_json::from_value::<NavigationBar>(serde_json::to_value(&bar).unwrap()).unwrap(), bar);
|
||||
for bad in [json!(null), json!([]), json!(true), json!({"shows":"future"}), json!({"shows":[]} )] {
|
||||
let bar: NavigationBar = serde_json::from_value(json!({"slot_options":{"visual_style":bad}})).unwrap();
|
||||
assert_eq!(bar.menu_display("visual_style"), MenuDisplay::IconOnly);
|
||||
}
|
||||
assert!(validate(&json!({"slot_options":[]})).is_err());
|
||||
assert!(validate(&json!({"slot_options":{"visual_style":{"shows":"future"}}})).is_err());
|
||||
assert!(validate(&json!({"slot_options":{"visual_style":{"hostile":1}}})).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_drop_index_handles_edges_empty_and_hostile_coordinates() {
|
||||
use crate::ui_kit::drop_index;
|
||||
for (x, gap) in [(-100.0, 0), (9.0, 0), (10.0, 1), (29.0, 1), (30.0, 2), (100.0, 2), (f32::NAN, 2), (f32::INFINITY, 2)] {
|
||||
assert_eq!(drop_index(x, [10.0, 30.0]), gap);
|
||||
}
|
||||
assert_eq!(drop_index(0.0, []), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_menu_value_width_is_independent_of_global_button_labels() {
|
||||
let mut bar = NavigationBar { slots: vec!["visual_style".into(), "display".into()], ..Default::default() };
|
||||
let content = Rect::from_min_size(egui::Pos2::ZERO, vec2(800.0, 200.0));
|
||||
let before = measure(content, &bar, NavCaps::MODEL, |_| 100.0);
|
||||
bar.slot_options.insert("visual_style".into(), SlotOptions { shows: MenuDisplay::IconAndValue });
|
||||
let value = measure(content, &bar, NavCaps::MODEL, |_| 100.0);
|
||||
assert_eq!(value.slots[0].1.width(), before.slots[0].1.width() + 100.0 + crate::ui_kit::NAV_MENU_GAP);
|
||||
assert_eq!(value.slots[1].1.width(), before.slots[1].1.width());
|
||||
bar.labels = Labels::Labels;
|
||||
let labels = measure(content, &bar, NavCaps::MODEL, |_| 100.0);
|
||||
assert_eq!(labels.slots.iter().map(|(_, rect)| *rect).collect::<Vec<_>>(), value.slots.iter().map(|(_, rect)| *rect).collect::<Vec<_>>());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_preview_and_viewport_share_the_row_painter() {
|
||||
let ctx = crate::fonts::test_context();
|
||||
let app = crate::SolveApp::new(Default::default(), Default::default());
|
||||
let content = Rect::from_min_size(egui::Pos2::ZERO, vec2(800.0, 200.0));
|
||||
let bar = measure(content, &app.preferences.navigation_bar, NavCaps::MODEL, |_| 0.0);
|
||||
let paint = |editing| {
|
||||
crate::test_support::frame(&ctx, egui::RawInput::default(), |ui| {
|
||||
crate::navigation_bar_view::paint_row(&app, ui, &bar, "", editing);
|
||||
})
|
||||
};
|
||||
let live = paint(None);
|
||||
let preview = paint(Some((None, NavCaps::MODEL, false)));
|
||||
assert_eq!(live.shapes.len(), preview.shapes.len());
|
||||
for (live, preview) in live.shapes.iter().zip(&preview.shapes) {
|
||||
assert_eq!(live.clip_rect, preview.clip_rect);
|
||||
if let (egui::Shape::Rect(live), egui::Shape::Rect(preview)) = (&live.shape, &preview.shape)
|
||||
&& live.fill != preview.fill
|
||||
{
|
||||
assert_eq!(live.fill, crate::theme::Tokens::get().dialog_body.gamma_multiply(0.97));
|
||||
assert_eq!(preview.fill, crate::theme::Tokens::get().dialog_body);
|
||||
let mut opaque = live.clone();
|
||||
opaque.fill = preview.fill;
|
||||
assert_eq!(&opaque, preview, "only the board's opaque editing surface differs");
|
||||
} else if let (egui::Shape::Mesh(live), egui::Shape::Mesh(preview)) = (&live.shape, &preview.shape)
|
||||
&& live != preview
|
||||
{
|
||||
let first = live.vertices.first().unwrap().pos;
|
||||
assert!(bar.slots.iter().any(|(slot, rect)| slot.kind == Kind::Menu && rect.contains(first)));
|
||||
let delta = preview.vertices.first().unwrap().pos - first;
|
||||
assert_eq!(delta.y, 0.0);
|
||||
assert_eq!(delta.x.abs(), crate::ui_kit::NAV_BORDER, "editing menus include their CSS transparent border");
|
||||
let mut shifted = live.as_ref().clone();
|
||||
for vertex in &mut shifted.vertices {
|
||||
vertex.pos += delta;
|
||||
}
|
||||
assert_eq!(&shifted, preview.as_ref(), "menu padding changes no artwork, colour, UVs or other geometry");
|
||||
} else {
|
||||
assert_eq!(live, preview, "slot painting is identical in both callers");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_profile_export_import_preserves_menu_options_and_legacy_profiles() {
|
||||
let mut source = crate::SolveApp::new(Default::default(), Default::default());
|
||||
source.preferences.navigation_bar.slots = vec!["visual_style".into()];
|
||||
source.preferences.navigation_bar.slot_options.insert("visual_style".into(), SlotOptions { shows: MenuDisplay::IconAndValue });
|
||||
let profile = crate::toolbar_custom::export(&source);
|
||||
let mut dest = crate::SolveApp::new(Default::default(), Default::default());
|
||||
crate::toolbar_custom::import(&mut dest, &profile).unwrap();
|
||||
assert_eq!(source.preferences.navigation_bar, dest.preferences.navigation_bar);
|
||||
let before = dest.preferences.navigation_bar.clone();
|
||||
crate::toolbar_custom::import(&mut dest, &json!({"format":"solidcraft-shortcuts/1"})).unwrap();
|
||||
assert_eq!(before, dest.preferences.navigation_bar);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_drop_adds_moves_removes_and_rejects_stale_sources() {
|
||||
let mut bar = NavigationBar { slots: vec!["separator".into(), "pan".into(), "separator".into()], ..Default::default() };
|
||||
let original = bar.slots.clone();
|
||||
assert_eq!(bar.drop_slot(&original, Some(2), "separator", Some(0)).unwrap(), Some(0));
|
||||
assert_eq!(bar.slots, ["separator", "separator", "pan"]);
|
||||
let before = bar.clone();
|
||||
assert!(bar.drop_slot(&original, Some(1), "pan", None).is_err());
|
||||
assert_eq!(bar, before);
|
||||
assert!(bar.drop_slot(&bar.slots.clone(), Some(0), "pan", None).is_err());
|
||||
let original = bar.slots.clone();
|
||||
assert_eq!(bar.drop_slot(&original, None, "fit", Some(3)).unwrap(), Some(3));
|
||||
let original = bar.slots.clone();
|
||||
assert_eq!(bar.drop_slot(&original, Some(3), "fit", None).unwrap(), None);
|
||||
assert_eq!(bar, before);
|
||||
assert_eq!(bar.drop_slot(&bar.slots.clone(), None, "fit", None).unwrap(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_context_menus_customise_hide_reset_and_remove() {
|
||||
for action in ["customise", "hide", "reset", "remove"] {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.app.preferences.navigation_bar.slots = vec!["pan".into(), "fit".into()];
|
||||
h.frames(4);
|
||||
if action == "remove" {
|
||||
h.step(&json!({"click":{"handle":"nav:slot:pan"},"button":"right"})).unwrap();
|
||||
} else {
|
||||
let bar = crate::scenario::rect_of("nav:outer").unwrap();
|
||||
h.step(&json!({"click":[bar.left()+1.0,bar.top()+1.0],"button":"right"})).unwrap();
|
||||
}
|
||||
h.frames(3);
|
||||
for entry in ["customise", "hide", "reset", "remove"] {
|
||||
assert_eq!(
|
||||
crate::scenario::handle_at(&format!("nav:context:{entry}")).is_some(),
|
||||
if action == "remove" { entry == "remove" } else { entry != "remove" },
|
||||
"{entry} follows the board's bar/slot split"
|
||||
);
|
||||
}
|
||||
crate::test_support::click(&mut h, &format!("nav:context:{action}"));
|
||||
match action {
|
||||
"customise" => {
|
||||
assert!(h.app.prefs_window.open);
|
||||
assert_eq!(h.app.prefs_window.section, crate::prefs::PAGE_INTERFACE);
|
||||
assert!(crate::scenario::rect_of("prefs:navbar:preview").is_some());
|
||||
}
|
||||
"hide" => assert!(!h.app.ui.show_navigation_bar),
|
||||
"reset" => assert_eq!(h.app.preferences.navigation_bar, NavigationBar::default()),
|
||||
_ => assert_eq!(h.app.preferences.navigation_bar.slots, ["fit"]),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_board_metrics_and_state_colors_are_shared_in_both_themes() {
|
||||
use crate::ui_kit::*;
|
||||
assert_eq!(Size::default(), Size::Regular);
|
||||
for (size, button, icon, height, radius, button_radius) in [(Size::Regular, 32.0, 18.0, 40.0, 10, 7), (Size::Compact, 26.0, 16.0, 34.0, 9, 6)] {
|
||||
let metrics = NavigationMetrics::for_size(size);
|
||||
assert_eq!(
|
||||
(metrics.button, metrics.icon, metrics.height(), metrics.radius, metrics.button_radius),
|
||||
(button, icon, height, radius, button_radius)
|
||||
);
|
||||
}
|
||||
assert_eq!((NAV_BORDER, NAV_PADDING, NAV_GAP, NAV_BOTTOM, NAV_EDGE), (1.0, 3.0, 2.0, 7.0, 12.0));
|
||||
assert_eq!((NAV_SEPARATOR, NAV_SEPARATOR_HEIGHT, NAV_MENU_LEFT, NAV_MENU_RIGHT, NAV_MENU_GAP, NAV_CHEVRON), (9.0, 18.0, 7.0, 6.0, 5.0, 12.0));
|
||||
assert_eq!((NAV_STAGE_HEIGHT, NAV_STAGE_INSET, NAV_TILE_HEIGHT, NAV_TILE_ADD), (58.0, 12.0, 32.0, 22.0));
|
||||
assert_eq!(
|
||||
(NAV_MARKER_HEIGHT, NAV_GHOST_OPACITY, NAV_TILE_DRAG_OPACITY, NAV_IDLE_OPACITY, NAV_FADE_SECONDS, NAV_TOOLTIP_DELAY),
|
||||
(24.0, 0.7, 0.55, 0.45, 0.12, 0.8)
|
||||
);
|
||||
for tokens in [crate::theme::Tokens::light(), crate::theme::Tokens::dark()] {
|
||||
let _theme = crate::theme::scoped_tokens(tokens);
|
||||
assert_eq!(navigation_fill(&tokens, NavigationFill::None), None);
|
||||
assert_eq!(navigation_fill(&tokens, NavigationFill::Hover), Some(tokens.nav_hover));
|
||||
assert_eq!(navigation_fill(&tokens, NavigationFill::Press), Some(tokens.nav_press));
|
||||
assert_eq!(navigation_fill(&tokens, NavigationFill::Active), Some(tokens.selected_bg));
|
||||
let frame = navigation_popup_frame();
|
||||
assert_eq!(frame.fill, tokens.dialog_body);
|
||||
assert_eq!(frame.stroke, egui::Stroke::new(NAV_BORDER, tokens.dialog_border));
|
||||
assert_eq!(frame.corner_radius, egui::CornerRadius::same(10));
|
||||
assert_eq!(frame.inner_margin, egui::Margin::same(5));
|
||||
assert_eq!(frame.shadow, Container::menu_frame().shadow, "navigation inherits the shared popup elevation");
|
||||
}
|
||||
assert_eq!((NAV_POPUP_WIDTH, NAV_CONTEXT_WIDTH, NAV_MORE_WIDTH, NAV_POPUP_GAP), (244.0, 232.0, 200.0, 6.0));
|
||||
for (idle, opacity) in [(Idle::Always, 1.0), (Idle::Fade, 0.45), (Idle::Hide, 0.0)] {
|
||||
assert_eq!(navigation_opacity(idle, false), opacity);
|
||||
assert_eq!(navigation_opacity(idle, true), 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_board_popup_width_includes_its_border_and_padding() {
|
||||
use crate::ui_kit::*;
|
||||
let ctx = crate::fonts::test_context();
|
||||
for tokens in [crate::theme::Tokens::light(), crate::theme::Tokens::dark()] {
|
||||
let _theme = crate::theme::scoped_tokens(tokens);
|
||||
for width in [NAV_POPUP_WIDTH, NAV_CONTEXT_WIDTH, NAV_MORE_WIDTH] {
|
||||
let mut outer = Rect::NOTHING;
|
||||
let mut row = Rect::NOTHING;
|
||||
crate::test_support::frame(&ctx, egui::RawInput::default(), |ui| {
|
||||
outer = ui
|
||||
.scope(|ui| {
|
||||
navigation_menu(ui, width, |ui| {
|
||||
row = NavigationMenuRow::new("fit", "Fit", "fit").show(ui).rect;
|
||||
})
|
||||
})
|
||||
.response
|
||||
.rect;
|
||||
});
|
||||
assert_eq!(outer.width(), width);
|
||||
assert_eq!(row.height(), NAV_MENU_ROW);
|
||||
assert_eq!(row.left() - outer.left(), f32::from(NAV_POPUP_PADDING) + NAV_BORDER);
|
||||
assert_eq!(outer.right() - row.right(), f32::from(NAV_POPUP_PADDING) + NAV_BORDER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_board_position_aliases_migrate_and_editor_alignment_follows_position() {
|
||||
use crate::navigation_bar_view::editor_layout;
|
||||
use crate::ui_kit::*;
|
||||
let stage = Rect::from_min_size(pos2(100.0, 200.0), vec2(640.0, NAV_STAGE_HEIGHT));
|
||||
for (legacy, current, position) in
|
||||
[("bottom", "centre", Position::Centre), ("bottom_left", "left", Position::Left), ("bottom_right", "right", Position::Right)]
|
||||
{
|
||||
let bar: NavigationBar = serde_json::from_value(json!({"position":legacy,"slots":["orbit","pan","fit","look_at","visual_style"]})).unwrap();
|
||||
assert_eq!(bar.position, position);
|
||||
assert_eq!(serde_json::to_value(&bar).unwrap()["position"], current);
|
||||
for size in [Size::Compact, Size::Regular] {
|
||||
let bar = NavigationBar { size, ..bar.clone() };
|
||||
let preview = editor_layout(stage, &bar, |_| 0.0);
|
||||
let live = measure(stage, &bar, NavCaps::MODEL, |_| 0.0);
|
||||
assert_eq!(preview.rect.center().y, stage.center().y);
|
||||
assert_eq!(preview.rect.height(), NavigationMetrics::for_size(size).height());
|
||||
match position {
|
||||
Position::Centre => assert_eq!(preview.rect.center().x, stage.center().x),
|
||||
Position::Left => assert_eq!(preview.rect.left(), stage.left() + NAV_BORDER + NAV_STAGE_INSET),
|
||||
Position::Right => assert_eq!(preview.rect.right(), stage.right() - NAV_BORDER - NAV_STAGE_INSET),
|
||||
}
|
||||
assert_eq!(preview.slots.iter().map(|(slot, _)| slot.id).collect::<Vec<_>>(), bar.slots);
|
||||
for ((slot, rect), (live_slot, live_rect)) in preview.slots.iter().zip(&live.slots) {
|
||||
assert_eq!(slot.id, live_slot.id);
|
||||
assert_eq!(rect.width(), live_rect.width() + if slot.kind == Kind::Menu { 2.0 * NAV_BORDER } else { 0.0 });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_board_drops_menu_value_text_before_folding_slots() {
|
||||
let mut bar = NavigationBar { slots: vec!["pan".into(), "visual_style".into(), "display".into()], ..Default::default() };
|
||||
bar.slot_options.insert("visual_style".into(), SlotOptions { shows: MenuDisplay::IconAndValue });
|
||||
let wide = measure(Rect::from_min_size(egui::Pos2::ZERO, vec2(700.0, 200.0)), &bar, NavCaps::MODEL, |_| 120.0);
|
||||
assert!(wide.values && wide.overflow.is_empty());
|
||||
let narrow = measure(Rect::from_min_size(egui::Pos2::ZERO, vec2(220.0, 200.0)), &bar, NavCaps::MODEL, |_| 120.0);
|
||||
assert!(!narrow.values && narrow.overflow.is_empty());
|
||||
let folded = measure(Rect::from_min_size(egui::Pos2::ZERO, vec2(100.0, 200.0)), &bar, NavCaps::MODEL, |_| 120.0);
|
||||
assert!(!folded.values && !folded.overflow.is_empty());
|
||||
assert_eq!(folded.more.size(), vec2(32.0, 32.0));
|
||||
}
|
||||
@@ -0,0 +1,560 @@
|
||||
//! Measured single-row navigation bar. Commands own all view changes.
|
||||
use crate::navigation::NavCaps;
|
||||
use crate::navigation_bar::{self, Idle, Kind, Labels, MenuDisplay, NavigationBar, Position, Slot};
|
||||
use crate::theme::Tokens;
|
||||
use crate::ui_kit::{self, Container, Surface};
|
||||
use crate::{SolveApp, viewport::NavMode};
|
||||
use egui::{Align2, Rect, pos2, vec2};
|
||||
use serde_json::json;
|
||||
|
||||
pub(crate) struct BarLayout {
|
||||
pub rect: Rect,
|
||||
pub slots: Vec<(&'static Slot, Rect)>,
|
||||
pub overflow: Vec<&'static Slot>,
|
||||
pub more: Rect,
|
||||
pub labels: bool,
|
||||
pub values: bool,
|
||||
}
|
||||
|
||||
/// Drop menu values, then labels, before moving a suffix into More. All rectangles use logical UI points.
|
||||
pub(crate) fn measure(content: Rect, prefs: &NavigationBar, caps: NavCaps, label_width: impl Fn(&Slot) -> f32) -> BarLayout {
|
||||
measure_row(content, prefs, caps, label_width, false)
|
||||
}
|
||||
|
||||
fn measure_row(content: Rect, prefs: &NavigationBar, caps: NavCaps, label_width: impl Fn(&Slot) -> f32, editing: bool) -> BarLayout {
|
||||
use ui_kit::*;
|
||||
let metrics = NavigationMetrics::for_size(prefs.size);
|
||||
let button = prefs.size.points();
|
||||
let inset = NAV_BORDER + NAV_PADDING;
|
||||
let mut result = BarLayout { rect: Rect::NOTHING, slots: Vec::new(), overflow: Vec::new(), more: Rect::NOTHING, labels: false, values: true };
|
||||
let height = metrics.height();
|
||||
let available = content.width() - 2.0 * NAV_EDGE;
|
||||
if !content.is_finite() || available < button + 2.0 * inset || content.height() < height + NAV_BOTTOM {
|
||||
return result;
|
||||
}
|
||||
let slots: Vec<_> =
|
||||
prefs.slots.iter().take(navigation_bar::MAX_SLOTS).filter_map(|id| navigation_bar::find(id)).filter(|slot| slot.available(caps)).collect();
|
||||
if slots.is_empty() {
|
||||
return result;
|
||||
}
|
||||
let width = |slot: &Slot, labels, values| {
|
||||
if slot.kind == Kind::Separator {
|
||||
NAV_SEPARATOR
|
||||
} else if slot.kind == Kind::Menu {
|
||||
metrics.icon
|
||||
+ if editing { 2.0 * NAV_BORDER } else { 0.0 }
|
||||
+ NAV_MENU_LEFT
|
||||
+ NAV_MENU_RIGHT
|
||||
+ NAV_CHEVRON
|
||||
+ NAV_MENU_GAP
|
||||
+ if values && slot.id == "visual_style" && prefs.menu_display(slot.id) == MenuDisplay::IconAndValue {
|
||||
label_width(slot).max(0.0) + NAV_MENU_GAP
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
} else if labels {
|
||||
(metrics.icon + NAV_LABEL_GAP + label_width(slot).max(0.0) + 2.0 * NAV_LABEL_PADDING).max(metrics.button)
|
||||
} else {
|
||||
metrics.button
|
||||
}
|
||||
};
|
||||
let total = |labels, values| {
|
||||
slots.iter().map(|slot| width(slot, labels, values)).sum::<f32>() + NAV_GAP * slots.len().saturating_sub(1) as f32 + 2.0 * inset
|
||||
};
|
||||
result.labels = prefs.labels == Labels::Labels;
|
||||
if total(result.labels, true) > available {
|
||||
result.values = false;
|
||||
}
|
||||
if total(result.labels, result.values) > available {
|
||||
result.labels = false;
|
||||
}
|
||||
let mut visible = slots.len();
|
||||
let mut row_width = total(result.labels, result.values);
|
||||
if row_width > available {
|
||||
visible = 0;
|
||||
row_width = metrics.button + 2.0 * inset;
|
||||
for slot in &slots {
|
||||
let next = row_width + width(slot, false, false) + NAV_GAP;
|
||||
if next > available {
|
||||
break;
|
||||
}
|
||||
row_width = next;
|
||||
visible += 1;
|
||||
}
|
||||
result.overflow.extend(slots.iter().skip(visible).copied());
|
||||
}
|
||||
let left = match prefs.position {
|
||||
Position::Centre => content.center().x - row_width / 2.0,
|
||||
Position::Left => content.left() + NAV_EDGE,
|
||||
Position::Right => content.right() - NAV_EDGE - row_width,
|
||||
};
|
||||
result.rect = Rect::from_min_size(pos2(left, content.bottom() - height - NAV_BOTTOM), vec2(row_width, height));
|
||||
let mut x = left + inset;
|
||||
for slot in slots.iter().take(visible) {
|
||||
let w = width(slot, result.labels, result.values);
|
||||
result.slots.push((*slot, Rect::from_min_size(pos2(x, result.rect.top() + inset), vec2(w, metrics.button))));
|
||||
x += w + NAV_GAP;
|
||||
}
|
||||
if !result.overflow.is_empty() {
|
||||
result.more = Rect::from_min_size(pos2(x, result.rect.top() + inset), vec2(metrics.button, metrics.button));
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
/// Editing retains every stored catalogue slot, including those hidden by the preview canvas.
|
||||
pub(crate) fn editor_layout(stage: Rect, prefs: &NavigationBar, label_width: impl Fn(&Slot) -> f32) -> BarLayout {
|
||||
let virtual_canvas = Rect::from_min_size(stage.min, vec2(8192.0, ui_kit::NAV_STAGE_HEIGHT));
|
||||
let mut bar = measure_row(virtual_canvas, prefs, NavCaps::MODEL, label_width, true);
|
||||
if !bar.rect.is_positive() {
|
||||
let metrics = ui_kit::NavigationMetrics::for_size(prefs.size);
|
||||
bar.rect = Rect::from_min_size(stage.min, vec2(metrics.button + 2.0 * (ui_kit::NAV_PADDING + ui_kit::NAV_BORDER), metrics.height()));
|
||||
}
|
||||
let x = match prefs.position {
|
||||
Position::Left => stage.left() + ui_kit::NAV_BORDER + ui_kit::NAV_STAGE_INSET,
|
||||
Position::Centre => stage.center().x - bar.rect.width() / 2.0,
|
||||
Position::Right => stage.right() - ui_kit::NAV_BORDER - ui_kit::NAV_STAGE_INSET - bar.rect.width(),
|
||||
};
|
||||
let delta = pos2(x, stage.center().y - bar.rect.height() / 2.0) - bar.rect.min;
|
||||
bar.rect = bar.rect.translate(delta);
|
||||
for (_, rect) in &mut bar.slots {
|
||||
*rect = rect.translate(delta);
|
||||
}
|
||||
if bar.more.is_positive() {
|
||||
bar.more = bar.more.translate(delta);
|
||||
}
|
||||
bar
|
||||
}
|
||||
|
||||
pub(crate) fn measured(app: &SolveApp, ctx: &egui::Context, content: Rect) -> BarLayout {
|
||||
let t = Tokens::get();
|
||||
measure(content, &app.preferences.navigation_bar, navigation_bar::canvas_caps(app), |slot| {
|
||||
ctx.fonts_mut(|fonts| fonts.layout_no_wrap(slot_text(app, slot).to_owned(), crate::fonts::medium(ui_kit::NAV_TEXT), t.form_ink).size().x)
|
||||
})
|
||||
}
|
||||
|
||||
fn selected(app: &SolveApp, id: &str) -> bool {
|
||||
match id {
|
||||
"orbit" => app.viewport.nav == Some(NavMode::Orbit),
|
||||
"pan" => app.viewport.nav == Some(NavMode::Pan),
|
||||
"zoom" => app.viewport.nav == Some(NavMode::Zoom),
|
||||
"spin" => app.viewport.spin,
|
||||
"projection" => app.perspective_view(),
|
||||
"grid" => app.ui.show_grid,
|
||||
"ground_shadow" => app.ui.ground_shadow,
|
||||
"ambient_occlusion" => app.preferences.ambient_occlusion,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// A sketch is always drawn orthographic, so the projection controls stay inert until it ends (#2144).
|
||||
fn projection_locked(app: &SolveApp) -> bool {
|
||||
app.session.active_sketch.is_some()
|
||||
}
|
||||
|
||||
/// #6143 will replace this single compatibility path with a registered command.
|
||||
fn toggle_projection(app: &mut SolveApp) {
|
||||
if !projection_locked(app) {
|
||||
app.ui.perspective = !app.ui.perspective;
|
||||
}
|
||||
}
|
||||
|
||||
fn activate(app: &mut SolveApp, slot: &Slot) {
|
||||
match slot.id {
|
||||
"look_at" => crate::viewport::look_at_selection(app),
|
||||
"projection" => toggle_projection(app),
|
||||
_ => {
|
||||
if let Some(command) = slot.command {
|
||||
let params = match slot.kind {
|
||||
Kind::Tool => json!({"tool": if selected(app, slot.id) { "none" } else { slot.id }}),
|
||||
_ if slot.id == "ambient_occlusion" => json!({"enabled": !app.preferences.ambient_occlusion}),
|
||||
_ => json!({}),
|
||||
};
|
||||
let _ = app.run(command, params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn tooltip(app: &SolveApp, response: egui::Response, slot: &Slot, hidden: Option<&str>, top: f32) -> egui::Response {
|
||||
let label = if let Some(hidden) = hidden {
|
||||
app.tr(hidden).to_owned()
|
||||
} else if slot.id == "visual_style" {
|
||||
crate::i18n::format("navbar.value_tip", &[("name", app.tr(slot.label)), ("value", current_style(app))])
|
||||
} else if slot.id == "projection" && projection_locked(app) {
|
||||
app.tr("nav.perspective.sketch").to_owned()
|
||||
} else {
|
||||
app.tr(slot.label).to_owned()
|
||||
};
|
||||
let key = slot.command.and_then(|id| crate::keymap::display_for(app, id));
|
||||
ui_kit::navigation_tooltip(&response, top, &label, key.as_deref());
|
||||
response
|
||||
}
|
||||
|
||||
pub(crate) fn show(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
if !app.ui.show_navigation_bar {
|
||||
return;
|
||||
}
|
||||
let Some(layout) = app.viewport.layout.as_ref().filter(|l| l.navigation.is_positive()) else { return };
|
||||
let bar = measured(app, ui.ctx(), layout.content);
|
||||
if !bar.rect.is_positive() {
|
||||
return;
|
||||
}
|
||||
crate::scenario::publish_rect("nav:outer", bar.rect);
|
||||
let menu_id = ui.id().with("navigation_bar_menu");
|
||||
let mut open = ui.data(|d| d.get_temp::<String>(menu_id)).unwrap_or_default();
|
||||
let active = ui.rect_contains_pointer(bar.rect)
|
||||
|| ui.rect_contains_pointer(crate::viewport::axis_rect(app, rect))
|
||||
|| app.viewport.axis_drag.is_some()
|
||||
|| app.viewport.primary_nav.is_some()
|
||||
|| app.viewport.orbit_from.is_some()
|
||||
|| (app.viewport.mouse.is_some() && ui.input(|i| i.pointer.middle_down()))
|
||||
|| app.viewport.modifier_nav.is_some()
|
||||
|| app.viewport.spin
|
||||
|| !open.is_empty();
|
||||
let opacity = ui_kit::navigation_opacity(app.preferences.navigation_bar.idle, active);
|
||||
let background = ui.interact(bar.rect, ui.id().with("navigation_bar_context"), egui::Sense::click());
|
||||
let opacity = if app.preferences.navigation_bar.idle == Idle::Hide {
|
||||
ui.ctx().animate_value_with_time(menu_id.with("opacity"), opacity, if active { ui_kit::NAV_FADE_SECONDS } else { 0.0 })
|
||||
} else {
|
||||
opacity
|
||||
};
|
||||
let mut anchor = bar.more;
|
||||
ui.scope(|ui| {
|
||||
ui.set_opacity(opacity);
|
||||
for (index, slot, response) in paint_row(app, ui, &bar, &open, None) {
|
||||
let bounds = response.rect;
|
||||
crate::scenario::publish_target(&format!("nav:slot:{}", slot.id), bounds);
|
||||
context_menu(app, &response, Some(index));
|
||||
if response.clicked() && slot.kind != Kind::Separator {
|
||||
if slot.kind == Kind::Menu {
|
||||
open = if open == slot.id { String::new() } else { slot.id.to_owned() };
|
||||
} else {
|
||||
activate(app, slot);
|
||||
}
|
||||
}
|
||||
if slot.id == "display" {
|
||||
crate::scenario::publish_handle("nav:view", bounds.center());
|
||||
}
|
||||
if open == slot.id {
|
||||
anchor = bounds;
|
||||
}
|
||||
}
|
||||
if bar.more.is_positive() {
|
||||
let response = ui_kit::navigation_button(
|
||||
ui,
|
||||
bar.more,
|
||||
ui_kit::NavigationButton {
|
||||
id: "more",
|
||||
kind: Kind::Menu,
|
||||
icon: "dots",
|
||||
label: app.tr("navbar.more"),
|
||||
selected: open == "more" || bar.overflow.iter().any(|slot| slot.id == open),
|
||||
labels: false,
|
||||
menu: false,
|
||||
},
|
||||
);
|
||||
ui_kit::navigation_tooltip(&response, bar.rect.top(), app.tr("navbar.more"), None);
|
||||
crate::scenario::publish_target("nav:more", response.rect);
|
||||
context_menu(app, &response, None);
|
||||
if response.clicked() {
|
||||
open = if open == "more" { String::new() } else { "more".to_owned() };
|
||||
}
|
||||
}
|
||||
});
|
||||
context_menu(app, &background, None);
|
||||
if !open.is_empty() && anchor.is_positive() {
|
||||
let child_popup_open = egui::Popup::is_any_open(ui.ctx());
|
||||
let ctx = ui.ctx().clone();
|
||||
let menu = Container::new(&ctx, Surface::Popup)
|
||||
.area(menu_id.with("popup"))
|
||||
.order(egui::Order::Foreground)
|
||||
.pivot(Align2::RIGHT_BOTTOM)
|
||||
.fixed_pos(anchor.right_top() - vec2(0.0, ui_kit::NAV_POPUP_GAP))
|
||||
.show(&ctx, |ui| {
|
||||
ui_kit::navigation_menu(ui, if open == "more" { ui_kit::NAV_MORE_WIDTH } else { ui_kit::NAV_POPUP_WIDTH }, |ui| {
|
||||
match open.as_str() {
|
||||
"visual_style" => {
|
||||
if style_menu(app, ui) {
|
||||
open.clear();
|
||||
}
|
||||
}
|
||||
"display" => display_menu(app, ui),
|
||||
"more" => overflow_menu(app, ui, &bar.overflow, &mut open),
|
||||
_ => open.clear(),
|
||||
}
|
||||
});
|
||||
});
|
||||
let outside = !child_popup_open
|
||||
&& ui.input(|i| {
|
||||
i.pointer.any_pressed() && i.pointer.interact_pos().is_some_and(|p| !menu.response.rect.contains(p) && !bar.rect.contains(p))
|
||||
});
|
||||
if outside || ui.input(|i| i.key_pressed(egui::Key::Escape)) {
|
||||
open.clear();
|
||||
}
|
||||
}
|
||||
ui.data_mut(|d| d.insert_temp(menu_id, open));
|
||||
}
|
||||
|
||||
pub(crate) fn current_style(app: &SolveApp) -> &str {
|
||||
app.tr(match app.ui.visual_style {
|
||||
1 => "navbar.style.shaded",
|
||||
2 => "navbar.style.wireframe",
|
||||
3 => "navbar.style.shaded_with_hidden_edges",
|
||||
_ => "navbar.style.shaded_with_edges",
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn slot_text<'a>(app: &'a SolveApp, slot: &Slot) -> &'a str {
|
||||
if slot.id == "visual_style" && app.preferences.navigation_bar.menu_display(slot.id) == MenuDisplay::IconAndValue {
|
||||
current_style(app)
|
||||
} else {
|
||||
app.tr(slot.label)
|
||||
}
|
||||
}
|
||||
|
||||
/// Both viewport and Preferences call this painter. Editing changes interaction and outlines only.
|
||||
pub(crate) fn paint_row(
|
||||
app: &SolveApp,
|
||||
ui: &mut egui::Ui,
|
||||
bar: &BarLayout,
|
||||
open: &str,
|
||||
editing: Option<(Option<usize>, NavCaps, bool)>,
|
||||
) -> Vec<(usize, &'static Slot, egui::Response)> {
|
||||
ui_kit::navigation_surface(ui, bar.rect, app.preferences.navigation_bar.size, editing.is_some());
|
||||
let mut responses = Vec::new();
|
||||
let mut cursor = 0;
|
||||
for (slot, bounds) in &bar.slots {
|
||||
let Some((index, _)) = app.preferences.navigation_bar.slots.iter().enumerate().skip(cursor).find(|(_, id)| id.as_str() == slot.id) else {
|
||||
continue;
|
||||
};
|
||||
cursor = index + 1;
|
||||
let response = ui
|
||||
.push_id(index, |ui| {
|
||||
let hidden = editing.is_some_and(|(_, caps, _)| !slot.available(caps));
|
||||
ui.scope(|ui| {
|
||||
if hidden {
|
||||
ui.set_opacity(ui_kit::NAV_HIDDEN_OPACITY);
|
||||
} else if editing.is_none() && slot.id == "projection" && projection_locked(app) {
|
||||
ui.set_opacity(ui.visuals().disabled_alpha);
|
||||
}
|
||||
if slot.kind == Kind::Separator {
|
||||
ui_kit::navigation_separator(ui, *bounds);
|
||||
ui.interact(
|
||||
*bounds,
|
||||
ui.id().with("separator"),
|
||||
if editing.is_some() { egui::Sense::click_and_drag() } else { egui::Sense::click() },
|
||||
)
|
||||
} else {
|
||||
let button = ui_kit::NavigationButton {
|
||||
id: slot.id,
|
||||
kind: slot.kind,
|
||||
icon: slot.current_icon(app.ui.visual_style),
|
||||
label: slot_text(app, slot),
|
||||
selected: if editing.is_some() { false } else { selected(app, slot.id) || open == slot.id },
|
||||
labels: if slot.kind == Kind::Menu {
|
||||
bar.values
|
||||
&& slot.id == "visual_style"
|
||||
&& app.preferences.navigation_bar.menu_display(slot.id) == MenuDisplay::IconAndValue
|
||||
} else {
|
||||
bar.labels
|
||||
},
|
||||
menu: slot.kind == Kind::Menu,
|
||||
};
|
||||
if editing.is_some() {
|
||||
ui_kit::navigation_button_editable(ui, *bounds, button, true)
|
||||
} else {
|
||||
ui_kit::navigation_button(ui, *bounds, button)
|
||||
}
|
||||
}
|
||||
})
|
||||
.inner
|
||||
})
|
||||
.inner;
|
||||
let mut hidden = None;
|
||||
if let Some((selected, caps, render)) = editing {
|
||||
response
|
||||
.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), selected == Some(index), app.tr(slot.label)));
|
||||
ui_kit::navigation_edit_outline(ui, *bounds, !slot.available(caps), selected == Some(index));
|
||||
if !slot.available(caps) {
|
||||
hidden = Some(if render { "navbar.custom.hidden_render" } else { "navbar.custom.hidden_design" });
|
||||
}
|
||||
} else {
|
||||
response.widget_info(|| {
|
||||
egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), selected(app, slot.id) || open == slot.id, app.tr(slot.label))
|
||||
});
|
||||
}
|
||||
responses.push((index, *slot, tooltip(app, response, slot, hidden, bar.rect.top())));
|
||||
}
|
||||
responses
|
||||
}
|
||||
|
||||
pub(crate) fn context_menu(app: &mut SolveApp, response: &egui::Response, index: Option<usize>) {
|
||||
ui_kit::navigation_context(response, |ui| {
|
||||
for id in if index.is_none() { &["customise", "hide", "reset"][..] } else { &[][..] } {
|
||||
let key = format!("navbar.custom.{id}");
|
||||
let item = ui_kit::NavigationMenuRow::new(id, app.tr(&key), "").show(ui);
|
||||
crate::scenario::publish_target(&format!("nav:context:{id}"), item.rect);
|
||||
if item.clicked() {
|
||||
match *id {
|
||||
"customise" => {
|
||||
let _ = crate::prefs::control(app, &json!({"open":"Interface/Navigation bar"}));
|
||||
}
|
||||
"hide" => {
|
||||
let _ = app.run("view.navigation_bar", json!({"visible":false}));
|
||||
}
|
||||
_ => {
|
||||
app.preferences.navigation_bar = NavigationBar::default();
|
||||
let _ = app.run("view.navigation_bar", json!({"visible":true}));
|
||||
}
|
||||
}
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
if let Some(index) = index {
|
||||
let item = ui_kit::NavigationMenuRow::new("remove", app.tr("navbar.custom.remove_bar"), "").show(ui);
|
||||
crate::scenario::publish_target("nav:context:remove", item.rect);
|
||||
if item.clicked() {
|
||||
let _ = app.preferences.navigation_bar.remove(index);
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn style_menu(app: &mut SolveApp, ui: &mut egui::Ui) -> bool {
|
||||
let mut chosen = false;
|
||||
for (index, style) in ["shaded_with_edges", "shaded", "wireframe", "shaded_with_hidden_edges"].into_iter().enumerate() {
|
||||
let label = format!("navbar.style.{style}");
|
||||
let mut item = ui_kit::NavigationMenuRow::new(style, app.tr(&label), navigation_bar::visual_style_icon(index as u8));
|
||||
item.selected = app.ui.visual_style == index as u8;
|
||||
let response = item.show(ui);
|
||||
crate::scenario::publish_target(&format!("nav:style:{style}"), response.rect);
|
||||
if response.clicked() {
|
||||
let _ = app.run("view.visual_style", json!({"style":style}));
|
||||
chosen = true;
|
||||
}
|
||||
}
|
||||
ui_kit::navigation_menu_separator(ui);
|
||||
let mut later = ui_kit::NavigationMenuRow::new("translucent", app.tr("navbar.translucent"), "style_translucent");
|
||||
later.enabled = false;
|
||||
later.detail = Some(app.tr("navbar.later"));
|
||||
later.show(ui);
|
||||
chosen
|
||||
}
|
||||
|
||||
fn overflow_menu(app: &mut SolveApp, ui: &mut egui::Ui, slots: &[&Slot], open: &mut String) {
|
||||
for slot in slots {
|
||||
if slot.kind == Kind::Separator {
|
||||
let start = ui.next_widget_position();
|
||||
ui_kit::navigation_menu_separator(ui);
|
||||
let bounds = Rect::from_min_max(start, pos2(start.x + ui.available_width(), ui.next_widget_position().y));
|
||||
crate::scenario::publish_target(&format!("nav:slot:{}", slot.id), bounds);
|
||||
continue;
|
||||
}
|
||||
let mut item = ui_kit::NavigationMenuRow::new(slot.id, app.tr(slot.label), slot.current_icon(app.ui.visual_style));
|
||||
if matches!(slot.kind, Kind::Tool | Kind::Toggle) {
|
||||
item.selected = selected(app, slot.id);
|
||||
}
|
||||
let response = item.show(ui);
|
||||
let index = app.preferences.navigation_bar.slots.iter().position(|id| id == slot.id);
|
||||
context_menu(app, &response, index);
|
||||
crate::scenario::publish_target(&format!("nav:slot:{}", slot.id), response.rect);
|
||||
if slot.id == "display" {
|
||||
crate::scenario::publish_handle("nav:view", response.rect.center());
|
||||
}
|
||||
if tooltip(app, response.clone(), slot, None, response.rect.top()).clicked() {
|
||||
if slot.kind == Kind::Menu {
|
||||
*open = slot.id.to_owned();
|
||||
} else {
|
||||
activate(app, slot);
|
||||
open.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn display_menu(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
use ui_kit::{NavigationMenuRow, navigation_menu_heading as heading, navigation_menu_separator as separator};
|
||||
heading(ui, app.tr("navbar.graphics"));
|
||||
let current = crate::prefs::graphics_preset(&app.preferences);
|
||||
let detail = format!("ui.graphics_{current}");
|
||||
let mut preset = NavigationMenuRow::new("preset", app.tr("navbar.preset"), "");
|
||||
preset.detail = Some(app.tr(&detail));
|
||||
preset.submenu = true;
|
||||
let response = preset.show(ui);
|
||||
crate::scenario::publish_target("view:graphics_preset", response.rect);
|
||||
Container::new(ui.ctx(), Surface::Popup).menu(&response).frame(ui_kit::navigation_popup_frame()).show(|ui| {
|
||||
ui.set_width(ui_kit::NAV_POPUP_WIDTH - 2.0 * (f32::from(ui_kit::NAV_POPUP_PADDING) + ui_kit::NAV_BORDER));
|
||||
ui.spacing_mut().item_spacing.y = 0.0;
|
||||
for (id, label) in [("performance", "ui.graphics_performance"), ("quality", "ui.graphics_quality")] {
|
||||
let mut item = NavigationMenuRow::new(id, app.tr(label), "");
|
||||
item.selected = current == id;
|
||||
let response = item.show(ui);
|
||||
crate::scenario::publish_target(&format!("view:graphics_preset:{id}"), response.rect);
|
||||
if response.clicked() {
|
||||
let _ = app.run("view.graphics_preset", json!({"preset":id}));
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
separator(ui);
|
||||
heading(ui, app.tr("navbar.show"));
|
||||
for id in ["grid", "ground_shadow", "ambient_occlusion"] {
|
||||
let Some(slot) = navigation_bar::find(id) else { continue };
|
||||
let mut item = NavigationMenuRow::new(slot.id, app.tr(slot.label), slot.current_icon(app.ui.visual_style));
|
||||
item.selected = selected(app, slot.id);
|
||||
let response = item.show(ui);
|
||||
crate::scenario::publish_target(&format!("view:{id}"), response.rect);
|
||||
if response.clicked() {
|
||||
activate(app, slot);
|
||||
}
|
||||
}
|
||||
separator(ui);
|
||||
heading(ui, app.tr("navbar.projection_heading"));
|
||||
for (perspective, key) in [(false, "navbar.orthographic"), (true, "navbar.perspective")] {
|
||||
let mut item = NavigationMenuRow::new(key, app.tr(key), "perspective");
|
||||
item.selected = app.ui.perspective == perspective;
|
||||
item.enabled = !projection_locked(app);
|
||||
let response = item.show(ui);
|
||||
let response = if projection_locked(app) { response.on_hover_text(app.tr("nav.perspective.sketch")) } else { response };
|
||||
crate::scenario::publish_target(if perspective { "view:projection" } else { "view:orthographic" }, response.rect);
|
||||
if response.clicked() && app.ui.perspective != perspective {
|
||||
toggle_projection(app);
|
||||
}
|
||||
}
|
||||
separator(ui);
|
||||
for (id, label, on) in [
|
||||
("auto_ortho_faces", "Perspective while orbiting, ortho on faces", app.ui.auto_ortho_faces),
|
||||
("tool_cursor", "Show tool at cursor", app.ui.tool_cursor),
|
||||
] {
|
||||
let mut row = NavigationMenuRow::new(id, crate::i18n::tr_label(label), "select");
|
||||
row.selected = on;
|
||||
let response = row.show(ui);
|
||||
crate::scenario::publish_target(&format!("view:{id}"), response.rect);
|
||||
if response.clicked() {
|
||||
match id {
|
||||
"auto_ortho_faces" => app.ui.auto_ortho_faces = !on,
|
||||
_ => app.ui.tool_cursor = !on,
|
||||
}
|
||||
}
|
||||
}
|
||||
separator(ui);
|
||||
heading(ui, app.tr("navbar.assistant"));
|
||||
let mut cursor = NavigationMenuRow::new("agent_cursor", app.tr("navbar.agent_cursor"), "select");
|
||||
cursor.selected = app.ui.agent_cursor.show;
|
||||
let response = cursor.show(ui);
|
||||
crate::scenario::publish_target("view:agent_cursor", response.rect);
|
||||
if response.clicked() {
|
||||
app.ui.agent_cursor.show = !app.ui.agent_cursor.show;
|
||||
}
|
||||
if crate::agent_chat::shown(app) {
|
||||
let mut chat = NavigationMenuRow::new("agent_chat", app.tr("navbar.agent_chat"), "agent_chat");
|
||||
chat.selected = app.agent_chat.open;
|
||||
let response = chat.show(ui);
|
||||
crate::scenario::publish_target("view:agent_chat", response.rect);
|
||||
if response.clicked() {
|
||||
app.agent_chat.open = !app.agent_chat.open;
|
||||
app.preferences.agent_chat_minimized &= !app.agent_chat.open;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ mod design;
|
||||
mod general;
|
||||
mod graphics;
|
||||
mod interface;
|
||||
mod navbar;
|
||||
mod navigation;
|
||||
mod sketch;
|
||||
|
||||
@@ -816,6 +817,9 @@ preference_settings! {
|
||||
language: String = "en".into(), 0;
|
||||
/// Shared workspace composition; system windows and popups retain their purpose.
|
||||
layout: crate::shell::LayoutMode = Default::default(), PAGE_INTERFACE;
|
||||
/// Ordered view controls and their appearance.
|
||||
#[serde(default)]
|
||||
navigation_bar: crate::navigation_bar::NavigationBar = Default::default(), PAGE_INTERFACE;
|
||||
/// Show command names beneath ribbon icons, independently of workspace layout.
|
||||
ribbon_labels: bool = true, PAGE_INTERFACE;
|
||||
/// Where a dialog's OK and Cancel sit: under its inputs (the default) or in its title row (#6708).
|
||||
@@ -1035,6 +1039,8 @@ impl MiddleDoubleClick {
|
||||
/// The preferences window.
|
||||
#[derive(Default)]
|
||||
pub struct PrefsWindow {
|
||||
navbar: navbar::State,
|
||||
navbar_scroll: bool,
|
||||
pub open: bool,
|
||||
/// The page shown (index into [`PAGES`]).
|
||||
pub section: usize,
|
||||
@@ -1144,6 +1150,7 @@ struct Snapshot {
|
||||
layout: crate::shell::LayoutMode,
|
||||
grid: bool,
|
||||
navigation_bar: bool,
|
||||
tool_cursor: bool,
|
||||
shadow: bool,
|
||||
perspective: bool,
|
||||
style: u8,
|
||||
@@ -1162,6 +1169,7 @@ impl Snapshot {
|
||||
layout: app.ui.layout,
|
||||
grid: app.ui.show_grid,
|
||||
navigation_bar: app.ui.show_navigation_bar,
|
||||
tool_cursor: app.ui.tool_cursor,
|
||||
shadow: app.ui.ground_shadow,
|
||||
perspective: app.ui.perspective,
|
||||
style: app.ui.visual_style,
|
||||
@@ -1186,6 +1194,7 @@ impl Snapshot {
|
||||
app.ui.layout = self.layout;
|
||||
app.ui.show_grid = self.grid;
|
||||
app.ui.show_navigation_bar = self.navigation_bar;
|
||||
app.ui.tool_cursor = self.tool_cursor;
|
||||
app.ui.ground_shadow = self.shadow;
|
||||
app.ui.perspective = self.perspective;
|
||||
app.ui.visual_style = self.style;
|
||||
@@ -1332,8 +1341,13 @@ fn follow_row(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
let (mut choose, mut stop) = (false, false);
|
||||
// The setting's name is longer than the label column: it leads the row's own line.
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
// On a narrow page the buttons drop to a second line rather than widening the page.
|
||||
let narrow = ui.available_width() < Tokens::get().form_card_width;
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui_kit::text(ui, app.tr("prefs.theme_follow"), ui_kit::Text::Inline);
|
||||
if narrow {
|
||||
ui.end_row();
|
||||
}
|
||||
let choose_button = ui_kit::button(ui, app.tr_label("Choose…"), ui_kit::Button::Small);
|
||||
crate::scenario::publish_target("prefs:theme_follow", choose_button.rect);
|
||||
choose = choose_button.clicked();
|
||||
@@ -1416,7 +1430,8 @@ fn defaults(app: &mut SolveApp, page: usize) {
|
||||
app.ui.show_navigation_bar = true;
|
||||
}
|
||||
PAGE_AI => app.ui.agent_cursor = Default::default(),
|
||||
PAGE_NAVIGATION | PAGE_DESIGN => {}
|
||||
PAGE_NAVIGATION => app.ui.tool_cursor = false,
|
||||
PAGE_DESIGN => {}
|
||||
PAGE_SHORTCUTS => crate::keymap::reset(app, None),
|
||||
PAGE_GRAPHICS => {
|
||||
app.ui.visual_style = 0;
|
||||
@@ -1775,7 +1790,12 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
|
||||
let window = ui_kit::Window::new(egui::Id::new("sc_prefs"), "settings", app.tr("ui.preferences"))
|
||||
.cards(10.0 / 3.0)
|
||||
.page_rows(24.0)
|
||||
.page_padding(egui::vec2(Tokens::get().space_16 + Tokens::get().space_4, Tokens::get().space_16))
|
||||
.page_padding(egui::Margin {
|
||||
left: (Tokens::get().space_16 + Tokens::get().space_4) as i8,
|
||||
right: (Tokens::get().space_16 + Tokens::get().space_4) as i8,
|
||||
top: Tokens::get().space_6 as i8,
|
||||
bottom: (Tokens::get().space_16 + Tokens::get().space_4) as i8,
|
||||
})
|
||||
.fields()
|
||||
.actions("OK", "Cancel", Some("Apply"));
|
||||
let window = if capturing { window.keep_open_on_escape() } else { window };
|
||||
@@ -1910,6 +1930,7 @@ fn draw_page(app: &mut SolveApp, ui: &mut egui::Ui, index: usize, t: &Tokens) {
|
||||
fn page_index(name: &str) -> Option<usize> {
|
||||
match name.to_ascii_lowercase().as_str() {
|
||||
"selection" | "sketch & selection" | "sketch and selection" => Some(PAGE_SKETCH),
|
||||
"interface/navigation bar" => Some(PAGE_INTERFACE),
|
||||
"assistant" => Some(PAGE_AI),
|
||||
"shortcuts" => Some(PAGE_SHORTCUTS),
|
||||
_ => PAGES.iter().position(|x| x.eq_ignore_ascii_case(name)),
|
||||
@@ -2440,6 +2461,7 @@ fn button_job_picker(
|
||||
/// text) adds a theme and turns it on, `theme_remove` (an id) removes an imported one and
|
||||
/// `theme_export: true` returns the theme on now as `theme_file`, `theme_follow` (a path, or
|
||||
/// `""` to stop) follows a theme file on the desktop (#7573); any other keys set preferences.
|
||||
/// `open: "Interface/Navigation bar"` opens Interface and scrolls to its bar editor.
|
||||
/// Returns them all, the open page, the offer, the theme ids and the followed file
|
||||
/// (`theme_followed`, `theme_follow_error`).
|
||||
pub fn control(app: &mut SolveApp, p: &serde_json::Value) -> Result<serde_json::Value, String> {
|
||||
@@ -2448,6 +2470,7 @@ pub fn control(app: &mut SolveApp, p: &serde_json::Value) -> Result<serde_json::
|
||||
let name = page.as_str().unwrap_or("General");
|
||||
let i = page_index(name).ok_or_else(|| format!("no page `{name}` ({})", PAGES.join(", ")))?;
|
||||
open_at(app, i);
|
||||
app.prefs_window.navbar_scroll = name.eq_ignore_ascii_case("Interface/Navigation bar");
|
||||
if app.prefs_window.snapshot.is_none() {
|
||||
app.prefs_window.snapshot = Some(Snapshot::take(app));
|
||||
}
|
||||
@@ -2698,6 +2721,9 @@ pub fn set(app: &mut SolveApp, p: &serde_json::Value) -> Result<serde_json::Valu
|
||||
{
|
||||
return Err("`viewport_theme` must be theme, light or dark".into());
|
||||
}
|
||||
if let Some(value) = p.get("navigation_bar") {
|
||||
crate::navigation_bar::validate(value)?;
|
||||
}
|
||||
let new: Prefs = migrate(serde_json::from_value(cur).map_err(|e| e.to_string())?);
|
||||
if !UNITS.contains(&new.default_units.as_str()) {
|
||||
return Err(format!("units must be one of {}", UNITS.join(", ")));
|
||||
@@ -2795,6 +2821,391 @@ pub(crate) fn reveal_preference(h: &mut crate::scenario::Harness, handle: &str)
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn navigation_bar_preferences_round_trip_and_recover_hostile_fields() {
|
||||
use crate::navigation_bar::{Idle, Labels, NavigationBar, Position, Size};
|
||||
use serde_json::json;
|
||||
assert_eq!(super::lenient(&json!({})).navigation_bar, NavigationBar::default());
|
||||
let p = super::lenient(&json!({"navigation_bar": {
|
||||
"slots":["pan", "future_slot", "pan", "separator", "separator", "separator", "separator", "separator", 7, "fit"],
|
||||
"position":"bottom_left", "size":"regular", "labels":"labels", "idle":"hide"
|
||||
}}));
|
||||
assert_eq!(p.navigation_bar.slots, ["pan", "future_slot", "separator", "separator", "separator", "separator", "fit"]);
|
||||
assert_eq!(
|
||||
(p.navigation_bar.position, p.navigation_bar.size, p.navigation_bar.labels, p.navigation_bar.idle),
|
||||
(Position::Left, Size::Regular, Labels::Labels, Idle::Hide)
|
||||
);
|
||||
let saved = serde_json::to_value(&p).unwrap();
|
||||
assert_eq!(serde_json::from_value::<super::Prefs>(saved).unwrap(), p);
|
||||
for field in ["position", "size", "labels", "idle"] {
|
||||
let mut value = serde_json::to_value(&p).unwrap();
|
||||
value["navigation_bar"][field] = json!({"wrong":"type"});
|
||||
let mut expected = p.clone();
|
||||
match field {
|
||||
"position" => expected.navigation_bar.position = Position::default(),
|
||||
"size" => expected.navigation_bar.size = Size::default(),
|
||||
"labels" => expected.navigation_bar.labels = Labels::default(),
|
||||
_ => expected.navigation_bar.idle = Idle::default(),
|
||||
}
|
||||
assert_eq!(super::lenient(&value), expected, "{field}");
|
||||
value["navigation_bar"][field] = json!("unknown");
|
||||
assert_eq!(super::lenient(&value), expected, "{field}");
|
||||
}
|
||||
for value in [json!(null), json!(7), json!([]), json!({"slots":false})] {
|
||||
assert_eq!(super::lenient(&json!({"navigation_bar":value})).navigation_bar, NavigationBar::default());
|
||||
}
|
||||
let ids: Vec<_> = (0..100).map(|i| format!("future_{i}")).collect();
|
||||
let limited = super::lenient(&json!({"navigation_bar":{"slots":ids}}));
|
||||
assert_eq!(limited.navigation_bar.slots.len(), crate::navigation_bar::MAX_SLOTS);
|
||||
assert_eq!(limited.navigation_bar.slots.last().map(String::as_str), Some("future_15"));
|
||||
let ids: Vec<_> = ["pan".to_owned(), "pan".to_owned()].into_iter().chain((0..20).map(|i| format!("future_{i}"))).collect();
|
||||
let limited = super::lenient(&json!({"navigation_bar":{"slots":ids}}));
|
||||
assert_eq!(limited.navigation_bar.slots.len(), crate::navigation_bar::MAX_SLOTS);
|
||||
assert_eq!(limited.navigation_bar.slots.last().map(String::as_str), Some("future_14"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_bar_control_reads_writes_validates_and_restores() {
|
||||
use crate::navigation_bar::NavigationBar;
|
||||
use serde_json::json;
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
let initial = h.call("ui.prefs", json!({}));
|
||||
assert_eq!(initial["result"]["navigation_bar"], serde_json::to_value(NavigationBar::default()).unwrap());
|
||||
let edit = json!({"navigation_bar":{"slots":["zoom", "future", "zoom", "display"], "position":"bottom_right", "size":"regular", "labels":"labels", "idle":"always"}});
|
||||
h.call("ui.prefs", json!({"open":"Interface"}));
|
||||
let reply = h.call("ui.prefs", edit);
|
||||
assert_eq!(reply["ok"], true, "{reply}");
|
||||
assert_eq!(reply["result"]["navigation_bar"]["slots"], json!(["zoom", "future", "display"]));
|
||||
let before = h.app.preferences.clone();
|
||||
for bad in [
|
||||
json!(null),
|
||||
json!({"slots":"fit"}),
|
||||
json!({"slots":[7]}),
|
||||
json!({"position":"top"}),
|
||||
json!({"size":true}),
|
||||
json!({"labels":"text"}),
|
||||
json!({"idle":10}),
|
||||
json!({"unknown":true}),
|
||||
] {
|
||||
assert!(super::control(&mut h.app, &json!({"navigation_bar":bad,"zoom_reverse":true})).is_err());
|
||||
assert_eq!(h.app.preferences, before, "failed updates are atomic");
|
||||
}
|
||||
let mut restored = crate::SolveApp::new(Default::default(), Default::default());
|
||||
restored.load_prefs(&h.app.prefs());
|
||||
assert_eq!(restored.preferences.navigation_bar, before.navigation_bar);
|
||||
h.call("ui.prefs", json!({"button":"cancel"}));
|
||||
assert_eq!(h.app.preferences.navigation_bar, NavigationBar::default());
|
||||
h.call("ui.prefs", json!({"open":"Interface","navigation_bar":{"slots":[]}}));
|
||||
assert!(h.app.preferences.navigation_bar.slots.is_empty());
|
||||
h.call("ui.prefs", json!({"button":"defaults"}));
|
||||
assert_eq!(h.app.preferences.navigation_bar, NavigationBar::default());
|
||||
}
|
||||
|
||||
fn navbar_click(h: &mut crate::scenario::Harness, handle: &str) {
|
||||
h.call("ui.prefs", json!({"open":"Interface/Navigation bar"}));
|
||||
h.frames(20);
|
||||
scroll_to_and_click(h, handle);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_bar_editor_buttons_and_appearance_update_preferences() {
|
||||
use crate::navigation_bar::{Idle, Labels, MenuDisplay, Position, Size};
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.call("ui.resize", json!({"width":1600,"height":1100}));
|
||||
h.call("ui.prefs", json!({"open":"Interface/Navigation bar", "navigation_bar":{"slots":["pan","fit","visual_style","display"]}}));
|
||||
navbar_click(&mut h, "prefs:navbar:add:spin");
|
||||
assert_eq!(h.app.preferences.navigation_bar.slots, ["pan", "fit", "visual_style", "display", "spin"]);
|
||||
navbar_click(&mut h, "prefs:navbar:slot:pan");
|
||||
navbar_click(&mut h, "prefs:navbar:right");
|
||||
assert_eq!(h.app.preferences.navigation_bar.slots, ["fit", "pan", "visual_style", "display", "spin"]);
|
||||
navbar_click(&mut h, "prefs:navbar:remove");
|
||||
assert_eq!(h.app.preferences.navigation_bar.slots, ["fit", "visual_style", "display", "spin"]);
|
||||
navbar_click(&mut h, "prefs:navbar:slot:visual_style");
|
||||
navbar_click(&mut h, "prefs:navbar:shows:0");
|
||||
assert_eq!(h.app.preferences.navigation_bar.menu_display("visual_style"), MenuDisplay::IconAndValue);
|
||||
navbar_click(&mut h, "prefs:navbar:position:0");
|
||||
assert_eq!(h.app.preferences.navigation_bar.position, Position::Left);
|
||||
navbar_click(&mut h, "prefs:navbar:position:2");
|
||||
assert_eq!(h.app.preferences.navigation_bar.position, Position::Right);
|
||||
navbar_click(&mut h, "prefs:navbar:size:0");
|
||||
assert_eq!(h.app.preferences.navigation_bar.size, Size::Compact);
|
||||
navbar_click(&mut h, "prefs:navbar:size:1");
|
||||
assert_eq!(h.app.preferences.navigation_bar.size, Size::Regular);
|
||||
navbar_click(&mut h, "prefs:navbar:buttons:1");
|
||||
assert_eq!(h.app.preferences.navigation_bar.labels, Labels::Labels);
|
||||
navbar_click(&mut h, "prefs:navbar:idle:0");
|
||||
assert_eq!(h.app.preferences.navigation_bar.idle, Idle::Always);
|
||||
navbar_click(&mut h, "prefs:navbar:idle:2");
|
||||
assert_eq!(h.app.preferences.navigation_bar.idle, Idle::Hide);
|
||||
let before = h.app.preferences.navigation_bar.clone();
|
||||
navbar_click(&mut h, "prefs:navbar:preview_as:1");
|
||||
assert_eq!(h.app.preferences.navigation_bar, before, "canvas preview is transient");
|
||||
navbar_click(&mut h, "prefs:navbar:show");
|
||||
assert!(!h.app.ui.show_navigation_bar);
|
||||
navbar_click(&mut h, "prefs:navbar:show");
|
||||
assert!(h.app.ui.show_navigation_bar);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_bar_appearance_segments_stay_inside_the_page_at_narrow_widths() {
|
||||
for width in [1600, 880, 640, 600, 480] {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.call("ui.resize", json!({"width":width,"height":1100}));
|
||||
h.call("ui.prefs", json!({"open":"Interface/Navigation bar", "navigation_bar":{"slots":["fit","visual_style","display","spin"]}}));
|
||||
h.frames(20);
|
||||
for (key, label, labels) in [
|
||||
("position", "Position", &["Left", "Centre", "Right"][..]),
|
||||
("size", "Size", &["Compact", "Regular"][..]),
|
||||
("buttons", "Buttons", &["Icons", "Icons and labels"][..]),
|
||||
("idle", "When idle", &["Always visible", "Fade", "Hide until hovered"][..]),
|
||||
] {
|
||||
let body = crate::scenario::rect_of("prefs:page_body").unwrap();
|
||||
let row = crate::scenario::rect_of(&format!("prefs:navbar:{key}")).unwrap();
|
||||
assert!(row.left() >= body.left() && row.right() <= body.right() + 0.5, "{key} at {width}: {row:?} outside {body:?}");
|
||||
assert_eq!(row.height(), crate::ui_kit::row_height(), "standard control height");
|
||||
let dropdown = crate::scenario::rect_of(&format!("dialog:segments:{label}")).is_none();
|
||||
if !dropdown {
|
||||
let t = crate::theme::Tokens::get();
|
||||
let natural: f32 = labels
|
||||
.iter()
|
||||
.map(|option| {
|
||||
h.ctx
|
||||
.fonts_mut(|fonts| fonts.layout_no_wrap((*option).to_owned(), crate::fonts::semibold(t.font_label), t.form_ink))
|
||||
.size()
|
||||
.x
|
||||
.ceil()
|
||||
+ t.space_16
|
||||
})
|
||||
.sum();
|
||||
let control = crate::scenario::rect_of(&format!("dialog:control:{label}")).unwrap();
|
||||
assert!((row.width() - natural.min(control.width())).abs() < 0.5, "{key} hugs its content at {width}");
|
||||
}
|
||||
if dropdown {
|
||||
// Standard Segments fall back to the kit dropdown when their labels cannot fit.
|
||||
navbar_click(&mut h, &format!("prefs:navbar:{key}"));
|
||||
h.frames(2);
|
||||
}
|
||||
for (index, option) in labels.iter().enumerate() {
|
||||
let cell = crate::scenario::rect_of(&format!("prefs:navbar:{key}:{index}")).unwrap();
|
||||
let at = crate::scenario::handle_at(&format!("prefs:navbar:{key}:{index}")).unwrap();
|
||||
assert!(cell.contains(at), "the scenario target is the actual choice");
|
||||
let mut text_found = false;
|
||||
for shape in &h.shapes {
|
||||
crate::test_support::each_shape(&shape.shape, &mut |shape| {
|
||||
if let egui::Shape::Text(text) = shape
|
||||
&& text.galley.job.text == *option
|
||||
{
|
||||
let bounds = text.galley.rect.translate(text.pos.to_vec2());
|
||||
if cell.contains(bounds.center()) {
|
||||
assert!(
|
||||
!text.galley.elided && cell.contains_rect(bounds),
|
||||
"{key}:{index} text clips at {width}: {bounds:?} in {cell:?}"
|
||||
);
|
||||
text_found = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
assert!(text_found, "{key}:{index} has painted, readable text at {width}");
|
||||
}
|
||||
if dropdown {
|
||||
h.step(&json!({"click":{"handle":format!("prefs:navbar:{key}:{}", labels.len() - 1)}})).unwrap();
|
||||
h.frames(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_bar_inspector_header_reserves_one_line_for_actions() {
|
||||
let t = crate::theme::Tokens::light();
|
||||
for width in [0.0, 80.0, 200.0, 520.0, 640.0, 760.0, 880.0] {
|
||||
for remove_width in [75.0, 160.0] {
|
||||
let bounds = egui::Rect::from_min_size(egui::pos2(10.0, 20.0), egui::vec2(width, t.control_height));
|
||||
let (name, buttons, compact) = super::navbar::inspector_header_layout(bounds, remove_width, &t);
|
||||
assert!(bounds.contains_rect(name));
|
||||
for rect in buttons {
|
||||
assert!(bounds.contains_rect(rect), "{width}: {rect:?} outside {bounds:?}");
|
||||
assert_eq!(rect.top(), bounds.top());
|
||||
assert_eq!(rect.bottom(), bounds.bottom());
|
||||
assert!(name.right() <= rect.left());
|
||||
}
|
||||
assert!((buttons.last().unwrap().right() - bounds.right()).abs() < 0.01);
|
||||
for pair in buttons.windows(2) {
|
||||
assert!(pair[0].right() <= pair[1].left());
|
||||
}
|
||||
if width >= 760.0 {
|
||||
assert!(!compact, "wide rows keep Remove's label");
|
||||
} else if width <= 80.0 {
|
||||
assert!(compact, "narrow rows keep Remove as an icon");
|
||||
}
|
||||
if !compact {
|
||||
assert_eq!(buttons[0].width(), t.control_height, "Move left is always icon-only");
|
||||
assert_eq!(buttons[1].width(), t.control_height, "Move right is always icon-only");
|
||||
assert_eq!(buttons[2].width(), remove_width);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_bar_inspector_and_status_keep_full_width_for_every_selection() {
|
||||
for width in [480, 600, 880, 1030, 1200, 1600] {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.call("ui.resize", json!({"width":width,"height":1100}));
|
||||
h.call(
|
||||
"ui.prefs",
|
||||
json!({"open":"Interface/Navigation bar", "navigation_bar":{"slots":["pan","fit","visual_style","display","separator"]}}),
|
||||
);
|
||||
h.frames(20);
|
||||
for slot in [None, Some("pan"), Some("fit"), Some("visual_style"), Some("display"), Some("separator")] {
|
||||
if let Some(slot) = slot {
|
||||
navbar_click(&mut h, &format!("prefs:navbar:slot:{slot}"));
|
||||
h.frames(3);
|
||||
}
|
||||
let body = crate::scenario::rect_of("prefs:page_body").unwrap();
|
||||
let card = crate::scenario::rect_of("prefs:navbar:inspector").unwrap();
|
||||
assert!(
|
||||
(card.left() - body.left()).abs() < 0.5 && (card.right() - body.right()).abs() < 0.5,
|
||||
"{slot:?} at {width}: {card:?} vs {body:?}"
|
||||
);
|
||||
let status = crate::scenario::rect_of("prefs:navbar:status").unwrap();
|
||||
let reset = crate::scenario::rect_of("prefs:navbar:reset").unwrap();
|
||||
let show = crate::scenario::rect_of("prefs:navbar:show").unwrap();
|
||||
assert_eq!(status.right(), body.right());
|
||||
assert!(status.contains_rect(reset) && status.contains_rect(show));
|
||||
assert!(show.right() <= reset.left());
|
||||
assert_eq!(reset.center().y, show.center().y);
|
||||
if slot.is_some() {
|
||||
let header = crate::scenario::rect_of("prefs:navbar:inspector:header").unwrap();
|
||||
let name = crate::scenario::rect_of("prefs:navbar:inspector:name").unwrap();
|
||||
let actions: Vec<_> =
|
||||
["left", "right", "remove"].iter().map(|key| crate::scenario::rect_of(&format!("prefs:navbar:{key}")).unwrap()).collect();
|
||||
for rect in &actions {
|
||||
assert!(header.contains_rect(*rect), "{slot:?} at {width}: {rect:?} outside {header:?}");
|
||||
assert_eq!(rect.center().y, header.center().y);
|
||||
assert!(name.right() <= rect.left());
|
||||
}
|
||||
assert_eq!(actions[0].width(), header.height(), "Move left stays icon-only");
|
||||
assert_eq!(actions[1].width(), header.height(), "Move right stays icon-only");
|
||||
assert_eq!(actions.last().unwrap().right(), header.right());
|
||||
}
|
||||
for (_, at) in crate::scenario::handles("prefs:navbar:add:") {
|
||||
assert!(at.x >= body.left() && at.x <= body.right(), "tray actions stay in their tiles");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn interface_sections_share_the_page_content_width_before_and_after_navigation() {
|
||||
for width in [600, 880, 1030, 1200, 1496, 1600] {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.call("ui.resize", json!({"width":width,"height":1100}));
|
||||
h.call("ui.prefs", json!({"open":"Interface"}));
|
||||
h.frames(20);
|
||||
for _ in 0..2 {
|
||||
let body = crate::scenario::rect_of("prefs:page_body").unwrap();
|
||||
let window = crate::scenario::rect_of("prefs:window").unwrap();
|
||||
let t = crate::theme::Tokens::get();
|
||||
let inset = t.space_16 + t.space_4 + crate::ui_kit::navigation_popup_frame().stroke.width;
|
||||
assert!((body.right() - (window.right() - inset)).abs() < 0.5, "{width}: page {body:?} leaves unused window content {window:?}");
|
||||
for key in ["theme", "layout", "navigation_bar", "scale", "colour_vision"] {
|
||||
let section = crate::scenario::rect_of(&format!("prefs:section:{key}")).unwrap();
|
||||
assert!(
|
||||
(section.left() - body.left()).abs() < 0.5 && (section.right() - body.right()).abs() < 0.5,
|
||||
"{key} at {width}: {section:?} vs {body:?}"
|
||||
);
|
||||
}
|
||||
for key in ["prefs:navbar:stage", "dialog:divider:scale_font", "dialog:row:Font"] {
|
||||
let row = crate::scenario::rect_of(key).unwrap();
|
||||
assert!((row.right() - body.right()).abs() < 0.5, "{key} at {width}: {row:?} vs {body:?}");
|
||||
}
|
||||
h.call("ui.scroll", json!({"x":body.center().x,"y":body.center().y,"delta":-600}));
|
||||
h.frames(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_bar_preview_stage_follows_position_live() {
|
||||
use crate::navigation_bar::Position;
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.call("ui.resize", json!({"width":1600,"height":1100}));
|
||||
h.call("ui.prefs", json!({"open":"Interface/Navigation bar","navigation_bar":{"slots":["pan","fit","display"]}}));
|
||||
for (index, position) in [(0, Position::Left), (1, Position::Centre), (2, Position::Right)] {
|
||||
navbar_click(&mut h, &format!("prefs:navbar:position:{index}"));
|
||||
h.frames(3);
|
||||
let stage = crate::scenario::rect_of("prefs:navbar:stage").unwrap();
|
||||
let bar = crate::scenario::rect_of("prefs:navbar:bar").unwrap();
|
||||
assert_eq!(h.app.preferences.navigation_bar.position, position);
|
||||
assert_eq!(stage.height(), crate::ui_kit::NAV_STAGE_HEIGHT);
|
||||
assert_eq!(bar.center().y, stage.center().y);
|
||||
match position {
|
||||
Position::Left => assert_eq!(bar.left(), stage.left() + crate::ui_kit::NAV_BORDER + crate::ui_kit::NAV_STAGE_INSET),
|
||||
Position::Centre => assert_eq!(bar.center().x, stage.center().x),
|
||||
Position::Right => assert_eq!(bar.right(), stage.right() - crate::ui_kit::NAV_BORDER - crate::ui_kit::NAV_STAGE_INSET),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_bar_editor_drag_adds_reorders_and_removes() {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.call("ui.resize", json!({"width":1600,"height":1100}));
|
||||
h.call("ui.prefs", json!({"open":"Interface/Navigation bar", "navigation_bar":{"slots":["pan","fit","display"]}}));
|
||||
h.frames(20);
|
||||
let preview = crate::scenario::rect_of("prefs:navbar:preview").unwrap();
|
||||
h.step(&json!({"drag":[{"handle":"prefs:navbar:tile:spin"}, [preview.right()-8.0,preview.center().y]],"steps":12})).unwrap();
|
||||
h.frames(4);
|
||||
assert_eq!(h.app.preferences.navigation_bar.slots, ["pan", "fit", "display", "spin"]);
|
||||
let pan = crate::scenario::rect_of("prefs:navbar:slot:pan").unwrap();
|
||||
h.step(&json!({"drag":[{"handle":"prefs:navbar:slot:spin"}, [pan.left()+1.0,pan.center().y]],"steps":12})).unwrap();
|
||||
h.frames(4);
|
||||
assert_eq!(h.app.preferences.navigation_bar.slots, ["spin", "pan", "fit", "display"]);
|
||||
let preview = crate::scenario::rect_of("prefs:navbar:preview").unwrap();
|
||||
h.step(&json!({"drag":[{"handle":"prefs:navbar:slot:spin"}, [preview.center().x,preview.bottom()+80.0]],"steps":12})).unwrap();
|
||||
h.frames(4);
|
||||
assert_eq!(h.app.preferences.navigation_bar.slots, ["pan", "fit", "display"]);
|
||||
// Empty stage space is off the bar too; it must remove rather than append a moved slot.
|
||||
h.step(&json!({"drag":[{"handle":"prefs:navbar:slot:pan"}, [preview.right()-4.0,preview.center().y]],"steps":12})).unwrap();
|
||||
h.frames(4);
|
||||
assert_eq!(h.app.preferences.navigation_bar.slots, ["fit", "display"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_bar_menu_options_cancel_defaults_and_section_reset() {
|
||||
use crate::navigation_bar::NavigationBar;
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
let before = h.app.preferences.navigation_bar.clone();
|
||||
let options = json!({"slots":["visual_style","pan"],"slot_options":{"visual_style":{"shows":"icon_and_value"}},"size":"regular"});
|
||||
h.call("ui.prefs", json!({"open":"Interface/Navigation bar","navigation_bar":options}));
|
||||
h.app.run("view.navigation_bar", json!({"visible":false})).unwrap();
|
||||
h.call("ui.prefs", json!({"button":"cancel"}));
|
||||
assert_eq!(h.app.preferences.navigation_bar, before);
|
||||
assert!(h.app.ui.show_navigation_bar);
|
||||
h.call("ui.prefs", json!({"open":"Interface/Navigation bar","navigation_bar":options}));
|
||||
h.call("ui.prefs", json!({"button":"defaults"}));
|
||||
assert_eq!(h.app.preferences.navigation_bar, NavigationBar::default());
|
||||
h.call("ui.prefs", json!({"navigation_bar":options}));
|
||||
navbar_click(&mut h, "prefs:navbar:reset");
|
||||
assert_eq!(h.app.preferences.navigation_bar, NavigationBar::default());
|
||||
navbar_click(&mut h, "dialog:section:Navigation bar");
|
||||
assert!(crate::scenario::handle_at("prefs:navbar:slot:pan").is_none(), "the section collapsed");
|
||||
h.call("ui.prefs", json!({"open":"Interface/Navigation bar"}));
|
||||
h.frames(20);
|
||||
let preview = crate::scenario::rect_of("prefs:navbar:preview").unwrap();
|
||||
let body = crate::scenario::rect_of("prefs:page_body").unwrap();
|
||||
assert!(body.contains(preview.center()), "the route reopens and scrolls to the section");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_ghost_position_defaults_round_trips_and_reads_tolerantly() {
|
||||
use super::SpaceMouseGhost::{LeftViewport as Current, LeftWindow as Left, RightViewport as Right};
|
||||
@@ -2987,15 +3398,14 @@ mod tests {
|
||||
assert!(top.is_some_and(|layer| layer.id == egui::Id::new("sc_space_mouse_calibration")), "top is {top:?}");
|
||||
}
|
||||
|
||||
/// Scrolls the open page until the handle is well inside the page body (not at its clipped edge), then clicks it (the harness has
|
||||
/// no scroll step, so the wheel is sent the way a mouse would).
|
||||
/// Scrolls vertically to the handle, then clicks after the wheel animation settles.
|
||||
/// Edge-aligned controls are valid targets; scrolling cannot move them inward horizontally.
|
||||
fn scroll_to_and_click(h: &mut crate::scenario::Harness, handle: &str) {
|
||||
for step in 0..60 {
|
||||
for _ in 0..60 {
|
||||
let body = crate::scenario::rect_of("prefs:page_body").expect("the page body");
|
||||
// Well inside the body while the page can still scroll, at its edge when it cannot.
|
||||
let margin = if step < 30 { 40.0 } else { 0.0 };
|
||||
if let Some(at) = crate::scenario::handle_at(handle)
|
||||
&& body.shrink(margin).contains(egui::pos2(at.x, at.y))
|
||||
let target = crate::scenario::handle_at(handle);
|
||||
if let Some(at) = target
|
||||
&& body.contains(at)
|
||||
{
|
||||
// The wheel scrolls smoothly: let it come to rest, then click where the handle is now.
|
||||
h.frames(20);
|
||||
@@ -3009,7 +3419,7 @@ mod tests {
|
||||
h.app.synthetic.push(egui::Event::PointerMoved(body.center()));
|
||||
h.app.synthetic.push(egui::Event::MouseWheel {
|
||||
unit: egui::MouseWheelUnit::Point,
|
||||
delta: egui::vec2(0.0, -60.0),
|
||||
delta: egui::vec2(0.0, if target.is_some_and(|at| at.y < body.top()) { 60.0 } else { -60.0 }),
|
||||
modifiers: egui::Modifiers::NONE,
|
||||
phase: egui::TouchPhase::Move,
|
||||
});
|
||||
@@ -5266,17 +5676,6 @@ mod ui_scale_regression_tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// Both display-setting surfaces dispatch the same programmatic command.
|
||||
pub(crate) fn ambient_occlusion_checkbox(app: &mut SolveApp, ui: &mut egui::Ui, label: &str) {
|
||||
let mut enabled = app.preferences.ambient_occlusion;
|
||||
let response = ui_kit::checkbox(ui, crate::i18n::tr_label(label), &mut enabled)
|
||||
.on_hover_text(crate::i18n::tr_label("Soft shading where opaque surfaces meet. Requires the GPU viewport."));
|
||||
crate::scenario::publish_handle("view:ambient_occlusion", response.rect.center());
|
||||
if response.changed() {
|
||||
let _ = app.run("view.ambient_occlusion", json!({"enabled": enabled}));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod ambient_occlusion_tests {
|
||||
use super::*;
|
||||
@@ -5317,7 +5716,7 @@ mod ambient_occlusion_tests {
|
||||
}
|
||||
|
||||
/// Manual edits are preserved and shown as Custom rather than claiming to match a preset.
|
||||
fn graphics_preset(prefs: &Prefs) -> &'static str {
|
||||
pub(crate) fn graphics_preset(prefs: &Prefs) -> &'static str {
|
||||
match (prefs.ambient_occlusion, prefs.display_quality.as_str(), prefs.supersampling, prefs.supersampling_adaptive) {
|
||||
(false, "normal", 1.0, _) => "performance",
|
||||
(true, "fine", 2.0, true) => "quality",
|
||||
@@ -5325,22 +5724,6 @@ fn graphics_preset(prefs: &Prefs) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn graphics_preset_selector(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
let current = graphics_preset(&app.preferences);
|
||||
let label = format!("ui.graphics_{current}");
|
||||
let response = ui_kit::dropdown_menu(ui, "graphics_preset", app.tr(&label), |ui| {
|
||||
for (preset, label) in [("performance", "ui.graphics_performance"), ("quality", "ui.graphics_quality")] {
|
||||
let item = ui_kit::list_picker(ui, preset, app.tr(label), current == preset);
|
||||
crate::scenario::publish_handle(&format!("view:graphics_preset:{preset}"), item.rect.center());
|
||||
if item.clicked() {
|
||||
let _ = app.run("view.graphics_preset", json!({"preset":preset}));
|
||||
}
|
||||
}
|
||||
})
|
||||
.on_hover_text(app.tr("ui.graphics_preset_help"));
|
||||
crate::scenario::publish_handle("view:graphics_preset", response.rect.center());
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod graphics_preset_tests {
|
||||
use super::*;
|
||||
|
||||
@@ -183,6 +183,7 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
);
|
||||
});
|
||||
origin_plane_names(app, ui);
|
||||
super::navbar::show(app, ui);
|
||||
ui_kit::settings_section(ui, "scale", app.tr("prefs.scale_text"), |ui| {
|
||||
ui_kit::settings_pair(
|
||||
ui,
|
||||
|
||||
@@ -0,0 +1,406 @@
|
||||
//! Navigation bar editor. The shared viewport painter owns the preview's appearance.
|
||||
use crate::navigation::NavCaps;
|
||||
use crate::navigation_bar::{self, Idle, Kind, Labels, MenuDisplay, NavigationBar, Position, Size, SlotOptions};
|
||||
use crate::navigation_bar_view;
|
||||
use crate::{SolveApp, scenario, theme::Tokens, ui_kit};
|
||||
use egui::{Rect, Sense, vec2};
|
||||
use serde_json::json;
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct State {
|
||||
selected: Option<usize>,
|
||||
render: bool,
|
||||
notice: Option<&'static str>,
|
||||
slots: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct Source {
|
||||
slot: String,
|
||||
index: Option<usize>,
|
||||
slots: Vec<String>,
|
||||
}
|
||||
type Drag = ui_kit::ReorderPayload<Source>;
|
||||
|
||||
pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
// The bar editor is drawn by hand, not through the kit rows the search hides, so while a
|
||||
// search runs it stays out unless the section's own title or a setting's label matches.
|
||||
if crate::prefs_search::querying(ui) {
|
||||
let labels: Vec<String> = ["title", "preview_as", "position", "size", "buttons", "idle", "show", "reset_default"]
|
||||
.iter()
|
||||
.map(|key| app.tr(&format!("navbar.custom.{key}")).to_owned())
|
||||
.collect();
|
||||
let texts: Vec<&str> = labels.iter().map(String::as_str).collect();
|
||||
if !crate::prefs_search::texts_hit(ui, &texts) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
let scroll = app.prefs_window.navbar_scroll;
|
||||
let mut state = std::mem::take(&mut app.prefs_window.navbar);
|
||||
if state.slots != app.preferences.navigation_bar.slots {
|
||||
state.selected = None;
|
||||
}
|
||||
let section = ui.scope(|ui| {
|
||||
if scroll {
|
||||
let id = ui.make_persistent_id("navigation_bar");
|
||||
ui.ctx().data_mut(|data| data.insert_persisted(id, true));
|
||||
}
|
||||
ui_kit::settings_section(ui, "navigation_bar", crate::i18n::tr("navbar.custom.title"), |ui| {
|
||||
let width = ui.available_width();
|
||||
ui_kit::text(ui, app.tr("navbar.custom.intro"), ui_kit::Text::Hint("navbar_intro"));
|
||||
segments(ui, "preview_as", &mut usize::from(state.render), &["navbar.custom.design", "navbar.custom.render"], |i| state.render = i == 1);
|
||||
preview(app, ui, &mut state, width);
|
||||
let card = ui_kit::settings_card(ui, |ui| inspector(app, ui, &mut state));
|
||||
scenario::publish_rect("prefs:navbar:inspector", card.response.rect);
|
||||
available(app, ui, &mut state);
|
||||
ui_kit::divider(ui, "navbar_appearance");
|
||||
appearance(app, ui);
|
||||
ui_kit::settings_inline_note(
|
||||
ui,
|
||||
&crate::i18n::format("navbar.custom.count", &[("count", &app.preferences.navigation_bar.slots.len().to_string())]),
|
||||
);
|
||||
if let Some(message) =
|
||||
state.notice.or_else(|| (app.preferences.navigation_bar.slots.len() >= navigation_bar::MAX_SLOTS).then_some("navbar.custom.full"))
|
||||
{
|
||||
ui.label(egui::RichText::new(app.tr(message)).color(Tokens::get().warning));
|
||||
}
|
||||
footer(app, ui, &mut state);
|
||||
});
|
||||
if let Some(rect) = scenario::rect_of(&format!("dialog:section:{}", app.tr("navbar.custom.title"))) {
|
||||
scenario::publish_rect("prefs:section:navigation_bar", rect);
|
||||
}
|
||||
});
|
||||
if scroll {
|
||||
ui.scroll_to_rect(Rect::from_min_size(section.response.rect.min, vec2(1.0, 1.0)), Some(egui::Align::Min));
|
||||
app.prefs_window.navbar_scroll = false;
|
||||
}
|
||||
state.slots = app.preferences.navigation_bar.slots.clone();
|
||||
app.prefs_window.navbar = state;
|
||||
}
|
||||
|
||||
fn segments(ui: &mut egui::Ui, key: &str, selected: &mut usize, options: &[&str], mut change: impl FnMut(usize)) {
|
||||
let label_key = format!("navbar.custom.{key}");
|
||||
let label = crate::i18n::tr(&label_key);
|
||||
let labels: Vec<_> = options.iter().map(|key| crate::i18n::tr(key)).collect();
|
||||
ui_kit::row(ui, label, |ui| {
|
||||
if ui_kit::segmented(ui, selected, &labels, ui_kit::Segments { intrinsic: true, ..Default::default() }) {
|
||||
change(*selected);
|
||||
}
|
||||
if let Some(rect) = scenario::rect_of(&format!("dialog:segments:{label}")) {
|
||||
scenario::publish_target(&format!("prefs:navbar:{key}"), rect);
|
||||
} else if let Some(rect) = scenario::rect_of(&format!("dialog:widget:{label}")) {
|
||||
scenario::publish_target(&format!("prefs:navbar:{key}"), rect);
|
||||
}
|
||||
for (index, option) in labels.iter().enumerate() {
|
||||
if let Some(rect) = scenario::rect_of(&format!("dialog:{label}:{option}")) {
|
||||
scenario::publish_target(&format!("prefs:navbar:{key}:{index}"), rect);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn footer(app: &mut SolveApp, ui: &mut egui::Ui, state: &mut State) {
|
||||
let t = Tokens::get();
|
||||
let label = app.tr("navbar.custom.reset_default");
|
||||
let width = ui_kit::ContentWidth::button(ui, label).max(t.control_height);
|
||||
let (rect, _) = ui.allocate_exact_size(vec2(ui.available_width(), t.control_height), Sense::hover());
|
||||
let reset = Rect::from_min_max(egui::pos2((rect.right() - width).max(rect.left()), rect.top()), rect.max);
|
||||
let check = Rect::from_min_max(rect.min, egui::pos2((reset.left() - t.space_8).max(rect.left()), rect.bottom()));
|
||||
ui.scope_builder(egui::UiBuilder::new().max_rect(check).layout(egui::Layout::left_to_right(egui::Align::Center)), |ui| {
|
||||
let mut visible = app.ui.show_navigation_bar;
|
||||
let response = ui_kit::checkbox(ui, app.tr("navbar.custom.show"), &mut visible);
|
||||
scenario::publish_target("prefs:navbar:show", response.rect);
|
||||
if response.changed() {
|
||||
let _ = app.run("view.navigation_bar", json!({"visible":visible}));
|
||||
}
|
||||
});
|
||||
let response = ui_kit::button_at(ui, "navbar_reset", reset, label, ui_kit::Button::Normal);
|
||||
scenario::publish_target("prefs:navbar:reset", response.rect);
|
||||
scenario::publish_rect("prefs:navbar:status", rect);
|
||||
if response.clicked() {
|
||||
app.preferences.navigation_bar = NavigationBar::default();
|
||||
let _ = app.run("view.navigation_bar", json!({"visible":true}));
|
||||
state.selected = None;
|
||||
state.notice = None;
|
||||
}
|
||||
}
|
||||
|
||||
fn preview(app: &mut SolveApp, ui: &mut egui::Ui, state: &mut State, width: f32) {
|
||||
let t = Tokens::get();
|
||||
let stage = ui_kit::navigation_stage(ui, width);
|
||||
scenario::publish_target("prefs:navbar:stage", stage);
|
||||
scenario::publish_target("prefs:navbar:preview", stage);
|
||||
let bar = navigation_bar_view::editor_layout(stage, &app.preferences.navigation_bar, |slot| {
|
||||
ui.painter().layout_no_wrap(navigation_bar_view::slot_text(app, slot).to_owned(), crate::fonts::medium(ui_kit::NAV_TEXT), t.form_ink).size().x
|
||||
});
|
||||
scenario::publish_rect("prefs:navbar:bar", bar.rect);
|
||||
let mut cells = Vec::new();
|
||||
let caps = if state.render { NavCaps::RENDER } else { NavCaps::MODEL };
|
||||
{
|
||||
let mut preview_ui = ui.new_child(egui::UiBuilder::new().id_salt("navigation_stage_content").max_rect(stage));
|
||||
let ui = &mut preview_ui;
|
||||
ui.set_clip_rect(ui.clip_rect().intersect(stage.shrink(ui_kit::NAV_BORDER)));
|
||||
for (index, slot, response) in navigation_bar_view::paint_row(app, ui, &bar, "", Some((state.selected, caps, state.render))) {
|
||||
cells.push((index, response.rect));
|
||||
scenario::publish_target(&format!("prefs:navbar:slot:{}", slot.id), response.rect);
|
||||
scenario::publish_target(&format!("prefs:navbar:slot:{index}"), response.rect);
|
||||
if response.clicked() {
|
||||
state.selected = Some(index);
|
||||
}
|
||||
if response.drag_started() {
|
||||
response.dnd_set_drag_payload(Drag {
|
||||
id: Source { slot: slot.id.to_owned(), index: Some(index), slots: app.preferences.navigation_bar.slots.clone() },
|
||||
from_menu: false,
|
||||
});
|
||||
}
|
||||
ui_kit::navigation_context(&response, |ui| {
|
||||
for (key, enabled) in [("left", index > 0), ("right", index + 1 < app.preferences.navigation_bar.slots.len()), ("remove", true)] {
|
||||
let label = format!("navbar.custom.{key}");
|
||||
let mut item = ui_kit::NavigationMenuRow::new(key, app.tr(&label), "");
|
||||
item.enabled = enabled;
|
||||
if item.show(ui).clicked() {
|
||||
edit(app, state, index, key);
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
let target = if egui::DragAndDrop::payload::<Drag>(ui.ctx()).is_some_and(|payload| payload.id.index.is_some()) {
|
||||
bar.rect.intersect(stage)
|
||||
} else {
|
||||
stage
|
||||
};
|
||||
drop_on_preview(app, ui, state, target.intersect(ui.clip_rect()), &cells);
|
||||
}
|
||||
|
||||
fn drop_on_preview(app: &mut SolveApp, ui: &mut egui::Ui, state: &mut State, target: Rect, cells: &[(usize, Rect)]) {
|
||||
let Some(payload) = egui::DragAndDrop::payload::<Drag>(ui.ctx()) else { return };
|
||||
let Some(pointer) = ui.input(|i| i.pointer.interact_pos()) else { return };
|
||||
let over = target.contains(pointer) && ui.rect_contains_pointer(target);
|
||||
let gap = ui_kit::drop_index(pointer.x, cells.iter().map(|(_, rect)| rect.center().x));
|
||||
let index = cells.get(gap).map(|(index, _)| *index).unwrap_or(app.preferences.navigation_bar.slots.len());
|
||||
if over {
|
||||
let x = cells
|
||||
.get(gap)
|
||||
.map(|(_, rect)| rect.left() - ui_kit::NAV_GAP / 2.0)
|
||||
.or_else(|| cells.last().map(|(_, rect)| rect.right() + ui_kit::NAV_GAP / 2.0))
|
||||
.unwrap_or(target.left() + Tokens::get().space_4);
|
||||
let marker = ui_kit::insertion_marker_with_ink(
|
||||
ui.painter(),
|
||||
x,
|
||||
target.center().y - ui_kit::NAV_MARKER_HEIGHT / 2.0,
|
||||
target.center().y + ui_kit::NAV_MARKER_HEIGHT / 2.0,
|
||||
Tokens::get().form_primary,
|
||||
);
|
||||
scenario::publish_target("prefs:navbar:marker", marker);
|
||||
}
|
||||
if !ui.input(|i| i.pointer.any_released()) {
|
||||
if let Some(slot) = navigation_bar::find(&payload.id.slot) {
|
||||
ui_kit::navigation_drag_ghost(
|
||||
ui,
|
||||
pointer,
|
||||
ui_kit::NavigationButton {
|
||||
id: slot.id,
|
||||
label: app.tr(slot.label),
|
||||
icon: slot.current_icon(app.ui.visual_style),
|
||||
selected: false,
|
||||
kind: slot.kind,
|
||||
labels: false,
|
||||
menu: slot.kind == Kind::Menu,
|
||||
},
|
||||
app.preferences.navigation_bar.size,
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
egui::DragAndDrop::clear_payload(ui.ctx());
|
||||
let result = app.preferences.navigation_bar.drop_slot(&payload.id.slots, payload.id.index, &payload.id.slot, over.then_some(index));
|
||||
match result {
|
||||
Ok(selected) if !payload.from_menu || over => state.selected = selected,
|
||||
_ => {}
|
||||
}
|
||||
state.notice = result.err();
|
||||
}
|
||||
|
||||
fn edit(app: &mut SolveApp, state: &mut State, index: usize, action: &str) {
|
||||
let bar = &mut app.preferences.navigation_bar;
|
||||
let result = match action {
|
||||
"left" if index > 0 => bar.move_to(index, index - 1).map(|to| state.selected = Some(to)),
|
||||
"right" => bar.move_to(index, index.saturating_add(2)).map(|to| state.selected = Some(to)),
|
||||
"remove" => bar.remove(index).map(|()| state.selected = None),
|
||||
_ => Ok(()),
|
||||
};
|
||||
state.notice = result.err();
|
||||
}
|
||||
|
||||
fn inspector(app: &mut SolveApp, ui: &mut egui::Ui, state: &mut State) {
|
||||
let Some((index, slot)) = state
|
||||
.selected
|
||||
.and_then(|index| app.preferences.navigation_bar.slots.get(index).and_then(|id| navigation_bar::find(id)).map(|slot| (index, slot)))
|
||||
else {
|
||||
ui_kit::text(ui, app.tr("navbar.custom.select"), ui_kit::Text::Hint("navbar_select"));
|
||||
return;
|
||||
};
|
||||
inspector_header(app, ui, state, index, slot);
|
||||
ui_kit::text(ui, app.tr(slot.description), ui_kit::Text::Hint("navbar_description"));
|
||||
if slot.id == "visual_style" {
|
||||
let mut selected = usize::from(app.preferences.navigation_bar.menu_display(slot.id) == MenuDisplay::IconOnly);
|
||||
segments(ui, "shows", &mut selected, &["navbar.custom.icon_value", "navbar.custom.icon_only"], |index| {
|
||||
app.preferences
|
||||
.navigation_bar
|
||||
.slot_options
|
||||
.insert(slot.id.to_owned(), SlotOptions { shows: if index == 0 { MenuDisplay::IconAndValue } else { MenuDisplay::IconOnly } });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Keep the arrow actions fixed; truncate the name before collapsing Remove to its icon.
|
||||
pub(super) fn inspector_header_layout(bounds: Rect, remove_width: f32, t: &Tokens) -> (Rect, [Rect; 3], bool) {
|
||||
let gap = t.space_4.min(bounds.width().max(0.0) / 2.0);
|
||||
let minimum_name = t.form_icon_size + t.space_8 + t.space_24;
|
||||
let widths = [t.control_height, t.control_height, remove_width];
|
||||
let compact = bounds.width() < widths.iter().sum::<f32>() + gap * 3.0 + minimum_name;
|
||||
let widths = if compact { [t.control_height.min(((bounds.width() - gap * 2.0) / 3.0).max(0.0)); 3] } else { widths };
|
||||
let total = widths.iter().sum::<f32>() + gap * 2.0;
|
||||
let start = (bounds.right() - total).max(bounds.left());
|
||||
let name = Rect::from_min_max(bounds.min, egui::pos2((start - gap).max(bounds.left()), bounds.bottom()));
|
||||
let mut x = start;
|
||||
let buttons = widths.map(|width| {
|
||||
let rect = Rect::from_min_size(egui::pos2(x, bounds.top()), vec2(width, bounds.height()));
|
||||
x += width + gap;
|
||||
rect
|
||||
});
|
||||
(name, buttons, compact)
|
||||
}
|
||||
|
||||
fn inspector_header(app: &mut SolveApp, ui: &mut egui::Ui, state: &mut State, index: usize, slot: &navigation_bar::Slot) {
|
||||
let t = Tokens::get();
|
||||
let remove = app.tr_label(app.tr("navbar.custom.remove"));
|
||||
let remove_width = ui.painter().layout_no_wrap(remove.to_owned(), egui::FontId::proportional(t.font_label), t.form_ink).size().x.ceil()
|
||||
+ t.space_10 * 2.0
|
||||
+ t.space_14
|
||||
+ t.space_6;
|
||||
let (bounds, _) = ui.allocate_exact_size(vec2(ui.available_width(), t.control_height), Sense::hover());
|
||||
let (name, buttons, compact) = inspector_header_layout(bounds, remove_width, &t);
|
||||
ui.scope_builder(egui::UiBuilder::new().max_rect(name).layout(egui::Layout::left_to_right(egui::Align::Center)), |ui| {
|
||||
if !slot.icon.is_empty() && name.width() >= t.form_icon_size {
|
||||
let (icon, _) = ui.allocate_exact_size(vec2(t.form_icon_size, t.form_icon_size), Sense::hover());
|
||||
crate::icons::paint_ink(ui.painter(), icon, slot.current_icon(app.ui.visual_style), t.form_dim);
|
||||
}
|
||||
ui_kit::text(ui, app.tr(slot.label), ui_kit::Text::NameCell(true));
|
||||
});
|
||||
scenario::publish_rect("prefs:navbar:inspector:name", name);
|
||||
scenario::publish_rect("prefs:navbar:inspector:header", bounds);
|
||||
let mut actions_ui = ui.new_child(egui::UiBuilder::new().id_salt("slot_actions").max_rect(bounds));
|
||||
for ((key, icon, enabled), rect) in [
|
||||
("left", "chevron_right", index > 0),
|
||||
("right", "chevron_right", index + 1 < app.preferences.navigation_bar.slots.len()),
|
||||
("remove", "close", true),
|
||||
]
|
||||
.into_iter()
|
||||
.zip(buttons)
|
||||
{
|
||||
let label_key = format!("navbar.custom.{key}");
|
||||
let label = app.tr_label(app.tr(&label_key));
|
||||
let response = actions_ui
|
||||
.scope_builder(egui::UiBuilder::new().id_salt(key).max_rect(rect), |ui| {
|
||||
ui.add_enabled_ui(enabled, |ui| {
|
||||
if key == "left" {
|
||||
ui_kit::mirrored_icon_button_at(ui, rect, icon, label)
|
||||
} else if key == "right" || compact {
|
||||
ui_kit::icon_button_at(ui, rect, icon, label)
|
||||
} else {
|
||||
ui_kit::icon_label_button(ui, label, icon, true, false)
|
||||
}
|
||||
})
|
||||
.inner
|
||||
})
|
||||
.inner
|
||||
.on_hover_text(label);
|
||||
response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, enabled && ui.is_enabled(), label));
|
||||
scenario::publish_target(&format!("prefs:navbar:{key}"), response.rect);
|
||||
if response.clicked() {
|
||||
edit(app, state, index, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn available(app: &mut SolveApp, ui: &mut egui::Ui, state: &mut State) {
|
||||
ui.scope(|ui| {
|
||||
ui.spacing_mut().item_spacing.y = Tokens::get().space_6;
|
||||
let caption = crate::i18n::format("navbar.custom.available", &[("available", app.tr("ui.workspace_available"))]);
|
||||
ui_kit::text(ui, &caption, ui_kit::Text::Hint("navbar_available"));
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.spacing_mut().item_spacing = vec2(Tokens::get().space_8, Tokens::get().space_8);
|
||||
for slot in navigation_bar::CATALOGUE {
|
||||
if slot.kind != Kind::Separator && app.preferences.navigation_bar.slots.iter().any(|id| id == slot.id) {
|
||||
continue;
|
||||
}
|
||||
let dragging = egui::DragAndDrop::payload::<Drag>(ui.ctx()).is_some_and(|payload| payload.from_menu && payload.id.slot == slot.id);
|
||||
let (tile, add) = ui_kit::navigation_tile(ui, slot.id, app.tr(slot.label), slot.current_icon(app.ui.visual_style), dragging);
|
||||
scenario::publish_target(&format!("prefs:navbar:tile:{}", slot.id), tile.rect);
|
||||
scenario::publish_target(&format!("prefs:navbar:add:{}", slot.id), add.rect);
|
||||
if tile.drag_started() {
|
||||
tile.dnd_set_drag_payload(Drag {
|
||||
id: Source { slot: slot.id.to_owned(), index: None, slots: app.preferences.navigation_bar.slots.clone() },
|
||||
from_menu: true,
|
||||
});
|
||||
}
|
||||
if add.clicked() {
|
||||
let index = app.preferences.navigation_bar.slots.len();
|
||||
state.notice = app.preferences.navigation_bar.insert(index, slot.id).err();
|
||||
if state.notice.is_none() {
|
||||
state.selected = Some(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn appearance(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
let bar = &mut app.preferences.navigation_bar;
|
||||
ui_kit::settings_form(ui, Tokens::get().form_label_width, |ui| {
|
||||
segments(
|
||||
ui,
|
||||
"position",
|
||||
&mut match bar.position {
|
||||
Position::Left => 0,
|
||||
Position::Centre => 1,
|
||||
Position::Right => 2,
|
||||
},
|
||||
&["navbar.custom.position_left", "navbar.custom.position_centre", "navbar.custom.position_right"],
|
||||
|i| {
|
||||
bar.position = match i {
|
||||
0 => Position::Left,
|
||||
2 => Position::Right,
|
||||
_ => Position::Centre,
|
||||
}
|
||||
},
|
||||
);
|
||||
segments(ui, "size", &mut usize::from(bar.size == Size::Regular), &["navbar.custom.compact", "navbar.custom.regular"], |i| {
|
||||
bar.size = if i == 1 { Size::Regular } else { Size::Compact }
|
||||
});
|
||||
segments(ui, "buttons", &mut usize::from(bar.labels == Labels::Labels), &["navbar.custom.icons", "navbar.custom.labels"], |i| {
|
||||
bar.labels = if i == 1 { Labels::Labels } else { Labels::Icons }
|
||||
});
|
||||
segments(
|
||||
ui,
|
||||
"idle",
|
||||
&mut match bar.idle {
|
||||
Idle::Always => 0,
|
||||
Idle::Fade => 1,
|
||||
Idle::Hide => 2,
|
||||
},
|
||||
&["navbar.custom.always", "navbar.custom.fade", "navbar.custom.hide_idle"],
|
||||
|i| {
|
||||
bar.idle = match i {
|
||||
0 => Idle::Always,
|
||||
2 => Idle::Hide,
|
||||
_ => Idle::Fade,
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -131,6 +131,8 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
setting::direct_interaction(app, ui);
|
||||
});
|
||||
});
|
||||
let cursor = ui_kit::checkbox(ui, crate::i18n::tr_label("Show tool at cursor"), &mut app.ui.tool_cursor);
|
||||
crate::scenario::publish_target("view:tool_cursor", cursor.rect);
|
||||
ui_kit::divider(ui, "navigation_view_controls");
|
||||
ui_kit::settings_form(ui, 150.0, |ui| {
|
||||
ui_kit::row(ui, app.tr_label("View navigator"), |ui| {
|
||||
|
||||
@@ -159,7 +159,7 @@ pub(crate) fn overlays(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
if !free.is_positive() {
|
||||
return;
|
||||
}
|
||||
crate::viewport::nav_bar(app, ui, viewport);
|
||||
crate::navigation_bar_view::show(app, ui, viewport);
|
||||
shots_pill(app, ui, free);
|
||||
}
|
||||
|
||||
|
||||
@@ -1321,7 +1321,7 @@ fn show_result(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
}
|
||||
let response = ui.allocate_rect(rect, Sense::click_and_drag());
|
||||
app.viewport.rect = Some(rect);
|
||||
crate::viewport::refresh_layout(app, ui.ctx().pixels_per_point());
|
||||
crate::viewport::refresh_layout(app, ui.ctx());
|
||||
let size = [info.width, info.height];
|
||||
let scale = app.render_workspace.view.result_scale;
|
||||
if scale != ResultScale::Free {
|
||||
@@ -1370,6 +1370,7 @@ fn show_result(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
);
|
||||
painter.rect_filled(badge, t.control_radius, t.panel);
|
||||
painter.galley(badge.min + egui::vec2(t.space_8, t.space_8 * 0.5), label, t.text);
|
||||
crate::navigation_bar_view::show(app, ui, rect);
|
||||
}
|
||||
|
||||
impl State {
|
||||
@@ -1643,7 +1644,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
}
|
||||
let rect = ui.max_rect();
|
||||
app.viewport.rect = Some(rect);
|
||||
crate::viewport::refresh_layout(app, ui.ctx().pixels_per_point());
|
||||
crate::viewport::refresh_layout(app, ui.ctx());
|
||||
let response = ui.interact(rect, ui.id().with("render_preview"), Sense::click_and_drag());
|
||||
let input = crate::navigation::handle(app, ui, rect, &response, crate::navigation::NavCaps::RENDER);
|
||||
let navigating = input.scroll != 0.0
|
||||
@@ -1763,6 +1764,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
preview_error(app, ui, rect, &error);
|
||||
}
|
||||
crate::viewport::axis_view(app, ui, rect);
|
||||
crate::navigation_bar_view::show(app, ui, rect);
|
||||
}
|
||||
|
||||
pub(crate) fn interactive_command_info(app: &SolveApp, command: &solidcraft_engine::CommandSpec) -> solidcraft_engine::CommandInfo {
|
||||
|
||||
@@ -3415,3 +3415,40 @@ fn render_workspace_component_filter_keeps_nested_repeated_occurrences_distinct(
|
||||
assert_eq!(candidate(&h.app, &[hit]).unwrap().1, Sel::Occurrence { path });
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_bar_render_canvases_filter_slots_and_keep_product_fit() {
|
||||
let mut h = Harness::new();
|
||||
h.app.run("solid.box", json!({"length":10,"width":20,"height":5})).unwrap();
|
||||
enter(&mut h.app, true).unwrap();
|
||||
h.app.preferences.look_at_anim = false;
|
||||
h.settle();
|
||||
assert_eq!(crate::navigation_bar::canvas_caps(&h.app), crate::navigation::NavCaps::RENDER);
|
||||
// The product preview picks (#6426), so the slots that need a pick are on the bar there too.
|
||||
for slot in ["orbit", "pan", "zoom", "fit", "look_at", "home", "visual_style", "display"] {
|
||||
assert!(crate::scenario::handle_at(&format!("nav:slot:{slot}")).is_some(), "{slot}");
|
||||
}
|
||||
h.app.cam.pan(100.0, 50.0, 600.0);
|
||||
let panned = h.app.cam;
|
||||
h.step(&json!({"click":{"handle":"nav:slot:fit"}})).unwrap();
|
||||
assert_ne!(h.app.cam.target, panned.target, "Fit recentres the product");
|
||||
assert_product_fits_canvas(&h.app);
|
||||
let mut iso = h.app.cam;
|
||||
iso.set_view(solidcraft_engine::render::StandardView::Iso);
|
||||
h.app.cam.orbit(0.4, 0.2);
|
||||
h.step(&json!({"click":{"handle":"nav:slot:home"}})).unwrap();
|
||||
assert_eq!((h.app.cam.yaw, h.app.cam.pitch), (iso.yaw, iso.pitch), "Home returns to the isometric view");
|
||||
assert_product_fits_canvas(&h.app);
|
||||
|
||||
let job = completed_preview(&mut h, [20, 40, 60]);
|
||||
h.app.render_workspace.view.job = Some(job);
|
||||
h.app.render_workspace.view.result = true;
|
||||
h.settle();
|
||||
assert_eq!(crate::navigation_bar::canvas_caps(&h.app), crate::navigation::NavCaps { orbit: false, pick: false });
|
||||
for slot in ["orbit", "look_at", "visual_style"] {
|
||||
assert!(crate::scenario::handle_at(&format!("nav:slot:{slot}")).is_none(), "{slot}");
|
||||
}
|
||||
for slot in ["pan", "zoom", "fit", "home", "display"] {
|
||||
assert!(crate::scenario::handle_at(&format!("nav:slot:{slot}")).is_some(), "{slot}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -510,6 +510,16 @@ pub struct IconColors {
|
||||
/// other one's colours (#4146): a new colour drawn in the view goes in both.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Tokens {
|
||||
/// Navigation chrome from the approved Navbar boards.
|
||||
pub nav_hover: Color32,
|
||||
pub nav_press: Color32,
|
||||
pub nav_dim: Color32,
|
||||
pub nav_viewport: Color32,
|
||||
pub nav_tip: Color32,
|
||||
pub nav_tip_ink: Color32,
|
||||
pub nav_tip_key_border: Color32,
|
||||
pub nav_field: Color32,
|
||||
|
||||
/// Optional structural/control strokes. None retains each surface’s legacy styling.
|
||||
pub borders: Borders,
|
||||
/// File/start presentation, with explicit foreground/background pairs.
|
||||
|
||||
@@ -298,6 +298,7 @@ macro_rules! theme_keys {
|
||||
|
||||
theme_keys! {
|
||||
one: [
|
||||
nav_hover, nav_press, nav_dim, nav_viewport, nav_tip, nav_tip_ink, nav_tip_key_border, nav_field,
|
||||
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,
|
||||
@@ -821,6 +822,33 @@ impl Follow {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn navigation_board_colours_are_themeable_and_roundtrip_on_both_bases() {
|
||||
for (base, tokens, colours) in [
|
||||
("light", Tokens::light(), ["#e9edf2", "#dce2ea", "#8895a7", "#eef1f5", "#1b2430", "#ffffff", "#ffffff"]),
|
||||
("dark", Tokens::dark(), ["#3a4150", "#464e60", "#7c879a", "#262b35", "#eef1f5", "#1b2430", "#2f343e"]),
|
||||
] {
|
||||
for (actual, hex) in
|
||||
[tokens.nav_hover, tokens.nav_press, tokens.nav_dim, tokens.nav_viewport, tokens.nav_tip, tokens.nav_tip_ink, tokens.nav_field]
|
||||
.into_iter()
|
||||
.zip(colours)
|
||||
{
|
||||
assert_eq!(actual, parse_color(hex).unwrap(), "{base}: {hex}");
|
||||
}
|
||||
let old = from_value(&json!({"format":FORMAT,"name":"Old","base":base})).unwrap();
|
||||
assert_eq!(resolve(&old), tokens, "old themes retain the base's new navigation roles");
|
||||
assert_eq!(resolve(&from_value(&export("Board", old.base, &tokens)).unwrap()), tokens);
|
||||
let custom = from_value(&json!({"format":FORMAT,"name":"Custom","base":base,
|
||||
"colors":{"nav_press":"#123456","nav_tip":"#abcdef","nav_tip_key_border":"#01020380"}}))
|
||||
.unwrap();
|
||||
let custom_tokens = resolve(&custom);
|
||||
assert_eq!(custom_tokens.nav_press, parse_color("#123456").unwrap());
|
||||
assert_eq!(custom_tokens.nav_tip, parse_color("#abcdef").unwrap());
|
||||
assert_eq!(custom_tokens.nav_tip_key_border, parse_color("#01020380").unwrap());
|
||||
assert_eq!(resolve(&from_value(&export("Custom", custom.base, &custom_tokens)).unwrap()), custom_tokens);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn border_roles_roundtrip_on_either_base_and_preserve_legacy_defaults() {
|
||||
use crate::theme::{BorderRole, Borders};
|
||||
|
||||
@@ -85,24 +85,44 @@ mod tests {
|
||||
solidcraft_engine::find_command(id).unwrap().icon
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_preference_restores_tool_badge_on_cancel_and_defaults() {
|
||||
let mut h = Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.call("ui.prefs", json!({"open":"Navigation"}));
|
||||
h.frames(4);
|
||||
crate::prefs::reveal_preference(&mut h, "view:tool_cursor");
|
||||
h.step(&json!({"click":{"handle":"view:tool_cursor"}})).unwrap();
|
||||
assert!(h.app.ui.tool_cursor);
|
||||
h.call("ui.prefs", json!({"button":"cancel"}));
|
||||
assert!(!h.app.ui.tool_cursor);
|
||||
h.app.ui.tool_cursor = true;
|
||||
h.call("ui.prefs", json!({"open":"Navigation"}));
|
||||
h.call("ui.prefs", json!({"button":"defaults"}));
|
||||
assert!(!h.app.ui.tool_cursor);
|
||||
h.call("ui.prefs", json!({"button":"cancel"}));
|
||||
assert!(h.app.ui.tool_cursor, "Cancel also restores the value from before Defaults");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn badge_shows_the_running_tool_beside_the_pointer() {
|
||||
let mut h = Harness::new();
|
||||
h.settle();
|
||||
// Off by default: a running tool shows no badge until View settings turn it on.
|
||||
// Off by default: a running tool shows no badge until Navigation preferences turn it on.
|
||||
assert!(!h.app.ui.tool_cursor, "the badge is on by default");
|
||||
h.step(&json!({"start": "sketch.create"})).unwrap();
|
||||
let (_, badge) = hover_middle(&mut h);
|
||||
assert!(badge.is_none(), "off by default, yet a badge is drawn at {badge:?}");
|
||||
h.step(&json!({"key": "Escape"})).unwrap();
|
||||
h.settle();
|
||||
// Turned on with the checkbox in the navigation bar's View settings.
|
||||
h.step(&json!({"click": {"handle": "nav:view"}})).unwrap();
|
||||
h.frames(2);
|
||||
// The board's Display menu omits this preference; Navigation keeps its checkbox.
|
||||
h.call("ui.prefs", json!({"open":"Navigation"}));
|
||||
h.frames(4);
|
||||
crate::prefs::reveal_preference(&mut h, "view:tool_cursor");
|
||||
h.step(&json!({"click": {"handle": "view:tool_cursor"}})).unwrap();
|
||||
h.step(&json!({"click": {"handle": "nav:view"}})).unwrap();
|
||||
h.call("ui.prefs", json!({"button":"ok"}));
|
||||
h.frames(2);
|
||||
assert!(h.app.ui.tool_cursor, "the View settings checkbox did not turn the badge on");
|
||||
assert!(h.app.ui.tool_cursor, "the Navigation preferences checkbox did not turn the badge on");
|
||||
let (_, badge) = hover_middle(&mut h);
|
||||
assert!(badge.is_none(), "no tool runs, yet a badge is drawn at {badge:?}");
|
||||
|
||||
@@ -123,7 +143,7 @@ mod tests {
|
||||
// The coordinate readout starts READOUT below and right of the pointer: no overlap.
|
||||
assert!(badge.bottom() < at.y + READOUT, "the badge {badge:?} covers the readout under {at:?}");
|
||||
|
||||
// Turned off in View settings.
|
||||
// Turned off in Navigation preferences.
|
||||
h.app.ui.tool_cursor = false;
|
||||
let (_, badge) = hover_middle(&mut h);
|
||||
assert!(badge.is_none(), "turned off, yet a badge is drawn at {badge:?}");
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use crate::fonts::RichTextExt as _;
|
||||
use crate::icons::glyphs::pin_icon;
|
||||
use crate::ui_kit::{Container, Edge, Surface};
|
||||
use crate::ui_kit::{self, Container, Edge, Surface};
|
||||
use egui::{Align2, Color32, FontId, Rect, Sense, Stroke, pos2, vec2};
|
||||
use serde_json::json;
|
||||
|
||||
@@ -1423,8 +1423,7 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
if let Some(d) = resp.dnd_hover_payload::<ToolbarDrag>()
|
||||
&& d.id != c.id
|
||||
{
|
||||
painter
|
||||
.line_segment([pos2(br.left() - 1.0, br.top() + 2.0), pos2(br.left() - 1.0, br.bottom() - 2.0)], Stroke::new(2.0, t.accent));
|
||||
ui_kit::insertion_marker(&painter, br.left() - 1.0, br.top() + 2.0, br.bottom() - 2.0);
|
||||
}
|
||||
if let Some(d) = resp.dnd_release_payload::<ToolbarDrag>()
|
||||
&& d.id != c.id
|
||||
@@ -1604,7 +1603,7 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
})
|
||||
});
|
||||
if !over_button && ui.rect_contains_pointer(panel_rect) && egui::DragAndDrop::payload::<ToolbarDrag>(ui.ctx()).is_some() {
|
||||
painter.line_segment([pos2(px + width - 4.0, top + 4.0), pos2(px + width - 4.0, top + 38.0)], Stroke::new(2.0, t.accent));
|
||||
ui_kit::insertion_marker(&painter, px + width - 4.0, top + 4.0, top + 38.0);
|
||||
if ui.input(|input| input.pointer.any_released())
|
||||
&& let Some(d) = egui::DragAndDrop::take_payload::<ToolbarDrag>(ui.ctx())
|
||||
{
|
||||
@@ -2062,12 +2061,7 @@ fn sketch_menu_rows(
|
||||
}
|
||||
}
|
||||
|
||||
/// A command being dragged: a toolbar button, or a row of a panel drop-down (`from_menu`).
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
struct ToolbarDrag {
|
||||
id: &'static str,
|
||||
from_menu: bool,
|
||||
}
|
||||
type ToolbarDrag = ui_kit::ReorderPayload<&'static str>;
|
||||
|
||||
/// The dragged command's icon under the pointer, crossed out when releasing removes it.
|
||||
fn drag_ghost(app: &SolveApp, ctx: &egui::Context, id: &str, at: egui::Pos2, removing: bool) {
|
||||
|
||||
@@ -348,9 +348,9 @@ pub fn run(app: &mut SolveApp, action: &str, p: &Value) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Shortcut keys, S box favourites and the toolbar as one file (Keyboard Shortcuts › Export).
|
||||
/// Shortcut keys, S box favourites, toolbar and navigation bar as one file (Keyboard Shortcuts › Export).
|
||||
pub fn export(app: &SolveApp) -> Value {
|
||||
json!({ "format": "solidcraft-shortcuts/1", "shortcuts": app.keymap.prefs(), "favourites": app.sbox.pinned, "toolbar": app.toolbar_custom.prefs() })
|
||||
json!({ "format": "solidcraft-shortcuts/1", "shortcuts": app.keymap.prefs(), "favourites": app.sbox.pinned, "toolbar": app.toolbar_custom.prefs(), "navigation_bar": app.preferences.navigation_bar })
|
||||
}
|
||||
|
||||
/// The largest shortcuts file Import… reads (hostile input; an export is a few tens of KiB).
|
||||
@@ -361,6 +361,16 @@ pub fn import(app: &mut SolveApp, v: &Value) -> Result<(), String> {
|
||||
if !matches!(v.get("format").and_then(Value::as_str), Some("solidcraft-shortcuts/1" | "solvecraft-shortcuts/1")) {
|
||||
return Err("not a SolidCraft shortcuts file".into());
|
||||
}
|
||||
let navigation_bar = v
|
||||
.get("navigation_bar")
|
||||
.map(|value| {
|
||||
crate::navigation_bar::validate(value)?;
|
||||
serde_json::from_value::<crate::navigation_bar::NavigationBar>(value.clone()).map_err(|e| e.to_string())
|
||||
})
|
||||
.transpose()?;
|
||||
if let Some(bar) = navigation_bar {
|
||||
app.preferences.navigation_bar = bar;
|
||||
}
|
||||
if let Some(s) = v.get("shortcuts") {
|
||||
app.keymap.load(s);
|
||||
}
|
||||
|
||||
@@ -31,14 +31,27 @@ pub(crate) fn icon_button_at(ui: &mut Ui, rect: egui::Rect, icon: &str, label: &
|
||||
|
||||
/// Quiet secondary action: a small, muted glyph with the normal full-size hit target.
|
||||
pub(crate) fn quiet_icon_button_at(ui: &mut Ui, rect: egui::Rect, icon: &str, label: &str) -> Response {
|
||||
icon_button_presentation(ui, rect, icon, label, None, true)
|
||||
icon_button_presentation(ui, rect, icon, label, None, true, false)
|
||||
}
|
||||
|
||||
/// Directional counterpart of an existing master, with the same hit target and accessibility.
|
||||
pub(crate) fn mirrored_icon_button_at(ui: &mut Ui, rect: egui::Rect, icon: &str, label: &str) -> Response {
|
||||
icon_button_presentation(ui, rect, icon, label, None, false, true)
|
||||
}
|
||||
|
||||
pub(super) fn icon_button_colored(ui: &mut Ui, rect: egui::Rect, icon: &str, label: &str, ink: Option<egui::Color32>) -> Response {
|
||||
icon_button_presentation(ui, rect, icon, label, ink, false)
|
||||
icon_button_presentation(ui, rect, icon, label, ink, false, false)
|
||||
}
|
||||
|
||||
fn icon_button_presentation(ui: &mut Ui, rect: egui::Rect, icon: &str, label: &str, ink: Option<egui::Color32>, quiet: bool) -> Response {
|
||||
fn icon_button_presentation(
|
||||
ui: &mut Ui,
|
||||
rect: egui::Rect,
|
||||
icon: &str,
|
||||
label: &str,
|
||||
ink: Option<egui::Color32>,
|
||||
quiet: bool,
|
||||
mirrored: bool,
|
||||
) -> Response {
|
||||
let t = Tokens::get();
|
||||
let response = ui.interact(rect, ui.make_persistent_id(("icon_button", icon, label)), egui::Sense::click());
|
||||
if response.clicked() {
|
||||
@@ -47,7 +60,8 @@ fn icon_button_presentation(ui: &mut Ui, rect: egui::Rect, icon: &str, label: &s
|
||||
if response.hovered() {
|
||||
ui.painter().rect_filled(rect, t.control_radius, t.hover);
|
||||
}
|
||||
crate::icons::paint_ink(
|
||||
let paint = if mirrored { crate::icons::paint_ink_mirrored } else { crate::icons::paint_ink };
|
||||
paint(
|
||||
ui.painter(),
|
||||
if quiet { egui::Rect::from_center_size(rect.center(), vec2(t.space_12, t.space_12)) } else { rect.shrink(t.form_icon_inset) },
|
||||
icon,
|
||||
|
||||
@@ -35,24 +35,6 @@ pub(crate) fn segmented(ui: &mut Ui, selected: &mut usize, options: &[&str], con
|
||||
let Segments { targets, icons, workspace_accent, dense, states, compact, primary, intrinsic, proportional } = config;
|
||||
let accent = crate::theme::TabAccent::current(ui.ctx());
|
||||
let t = Tokens::get();
|
||||
let segment_width = dimension(ui.available_width()) / options.len().max(1) as f32;
|
||||
let widest = options
|
||||
.iter()
|
||||
.map(|option| {
|
||||
ui.painter().layout_no_wrap(crate::i18n::tr_label(option).to_string(), crate::fonts::semibold(t.font_label), t.form_ink).size().x
|
||||
})
|
||||
.fold(0.0, f32::max);
|
||||
// Judged on the whole row, which is what a scrollbar narrows, not on one segment.
|
||||
if !intrinsic
|
||||
&& !proportional
|
||||
&& !compact
|
||||
&& !super::fits_steadily(ui, label(ui), (widest + 2.0 * t.space_8) * options.len() as f32, segment_width * options.len() as f32)
|
||||
{
|
||||
let before = *selected;
|
||||
let id = format!("segments_fallback_{}", label(ui));
|
||||
dropdown(ui, &id, selected, options);
|
||||
return *selected != before;
|
||||
}
|
||||
let natural: Vec<_> = options
|
||||
.iter()
|
||||
.enumerate()
|
||||
@@ -63,6 +45,21 @@ pub(crate) fn segmented(ui: &mut Ui, selected: &mut usize, options: &[&str], con
|
||||
})
|
||||
.collect();
|
||||
let total = natural.iter().sum::<f32>();
|
||||
let segment_width = dimension(ui.available_width()) / options.len().max(1) as f32;
|
||||
let widest = options
|
||||
.iter()
|
||||
.map(|option| {
|
||||
ui.painter().layout_no_wrap(crate::i18n::tr_label(option).to_string(), crate::fonts::semibold(t.font_label), t.form_ink).size().x
|
||||
})
|
||||
.fold(0.0, f32::max);
|
||||
// Judged on the whole row, which is what a scrollbar narrows, not on one segment.
|
||||
let need = if intrinsic { total } else { (widest + 2.0 * t.space_8) * options.len() as f32 };
|
||||
if !proportional && !compact && !super::fits_steadily(ui, label(ui), need, segment_width * options.len() as f32) {
|
||||
let before = *selected;
|
||||
let id = format!("segments_fallback_{}", label(ui));
|
||||
dropdown(ui, &id, selected, options);
|
||||
return *selected != before;
|
||||
}
|
||||
let desired = if intrinsic { total.min(dimension(ui.available_width())) } else { dimension(ui.available_width()) };
|
||||
let (rect, _) = ui.allocate_exact_size(vec2(desired, if dense { t.control_height - t.space_2 } else { row_height() }), egui::Sense::hover());
|
||||
ui.painter().rect_filled(rect, t.control_radius, t.control_fill);
|
||||
@@ -133,7 +130,7 @@ pub(crate) fn segmented(ui: &mut Ui, selected: &mut usize, options: &[&str], con
|
||||
);
|
||||
t.button_bevel_with_radius(ui, &response, on, rounding);
|
||||
response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), on, *option));
|
||||
scenario::publish_handle(&format!("dialog:{}:{option}", label(ui)), segment.center());
|
||||
scenario::publish_target(&format!("dialog:{}:{option}", label(ui)), segment);
|
||||
if let Some(target) = targets.get(index) {
|
||||
let visible = segment.intersect(ui.clip_rect());
|
||||
if visible.is_positive() {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//! Reordering chrome shared by the ribbon and editable navigation bar.
|
||||
use crate::theme::Tokens;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub(crate) struct ReorderPayload<T> {
|
||||
pub id: T,
|
||||
pub from_menu: bool,
|
||||
}
|
||||
|
||||
pub(crate) fn insertion_marker(painter: &egui::Painter, x: f32, top: f32, bottom: f32) -> egui::Rect {
|
||||
insertion_marker_with_ink(painter, x, top, bottom, Tokens::get().accent)
|
||||
}
|
||||
|
||||
pub(crate) fn insertion_marker_with_ink(painter: &egui::Painter, x: f32, top: f32, bottom: f32, ink: egui::Color32) -> egui::Rect {
|
||||
let rect = egui::Rect::from_min_max(egui::pos2(x - 1.0, top), egui::pos2(x + 1.0, bottom));
|
||||
painter.rect_filled(rect, 1, ink);
|
||||
rect
|
||||
}
|
||||
|
||||
/// A gap before the first centre to the right of the pointer; hostile coordinates append.
|
||||
pub(crate) fn drop_index(x: f32, centres: impl IntoIterator<Item = f32>) -> usize {
|
||||
let mut count = 0;
|
||||
for centre in centres {
|
||||
if x.is_finite() && centre.is_finite() && x < centre {
|
||||
return count;
|
||||
}
|
||||
count += 1;
|
||||
}
|
||||
count
|
||||
}
|
||||
@@ -271,7 +271,7 @@ pub(crate) fn dropdown(ui: &mut Ui, id: &str, selected: &mut usize, options: &[&
|
||||
dropdown_menu(ui, id, text, |ui| {
|
||||
for (index, option) in options.iter().enumerate() {
|
||||
let response = ui.selectable_value(selected, index, crate::i18n::tr_label(option));
|
||||
scenario::publish_handle(&format!("dialog:{row}:{option}"), response.rect.center());
|
||||
scenario::publish_target(&format!("dialog:{row}:{option}"), response.rect);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -27,6 +27,32 @@ macro_rules! element {
|
||||
};
|
||||
}
|
||||
|
||||
fn navigation_sample(ui: &mut Ui, size: crate::navigation_bar::Size) {
|
||||
let metrics = NavigationMetrics::for_size(size);
|
||||
let inset = NAV_PADDING + NAV_BORDER;
|
||||
let menu_width = metrics.icon + NAV_MENU_LEFT + NAV_MENU_RIGHT + NAV_MENU_GAP + NAV_CHEVRON;
|
||||
let (rect, _) =
|
||||
ui.allocate_exact_size(vec2(2.0 * metrics.button + menu_width + 2.0 * NAV_GAP + 2.0 * inset, metrics.height()), egui::Sense::hover());
|
||||
navigation_surface(ui, rect, size, true);
|
||||
let mut x = rect.left() + inset;
|
||||
for (id, icon, kind, selected, width) in [
|
||||
("pan", "pan", crate::navigation_bar::Kind::Tool, true, metrics.button),
|
||||
("fit", "fit", crate::navigation_bar::Kind::Action, false, metrics.button),
|
||||
("visual_style", "style_shaded_edges", crate::navigation_bar::Kind::Menu, false, menu_width),
|
||||
] {
|
||||
let bounds = egui::Rect::from_min_size(egui::pos2(x, rect.top() + inset), vec2(width, metrics.button));
|
||||
navigation_button(
|
||||
ui,
|
||||
bounds,
|
||||
NavigationButton { id, icon, label: id, kind, selected, labels: false, menu: kind == crate::navigation_bar::Kind::Menu },
|
||||
);
|
||||
if id == "fit" {
|
||||
navigation_edit_outline(ui, bounds, true, false);
|
||||
}
|
||||
x += width + NAV_GAP;
|
||||
}
|
||||
}
|
||||
|
||||
// One entry per element/variant: names, rendering and geometry expectations stay together.
|
||||
const ELEMENTS: &[Element] = &[
|
||||
element!("sphere_thumbnail", |ui, _| {
|
||||
@@ -59,6 +85,39 @@ const ELEMENTS: &[Element] = &[
|
||||
element!("look_chain_empty", |ui, _| {
|
||||
look_chain(ui, "gallery:empty-chain", ["Face", "Body", "Component", "Material"], [None; 4], LookStep::Face);
|
||||
}),
|
||||
element!("navigation_regular", |ui, _| navigation_sample(ui, crate::navigation_bar::Size::Regular)),
|
||||
element!("navigation_compact", |ui, _| navigation_sample(ui, crate::navigation_bar::Size::Compact)),
|
||||
element!("navigation_popup", |ui, _| {
|
||||
navigation_menu(ui, NAV_POPUP_WIDTH, |ui| {
|
||||
navigation_menu_heading(ui, "Visual style");
|
||||
let mut row = NavigationMenuRow::new("shaded", "Shaded", "style_shaded");
|
||||
row.selected = true;
|
||||
row.show(ui);
|
||||
navigation_menu_separator(ui);
|
||||
NavigationMenuRow::new("fit", "Fit", "fit").show(ui);
|
||||
let mut later = NavigationMenuRow::new("translucent", "Translucent", "style_translucent");
|
||||
later.enabled = false;
|
||||
later.detail = Some("Later");
|
||||
later.show(ui);
|
||||
});
|
||||
}),
|
||||
element!("navigation_settings", |ui, state| {
|
||||
settings_section(ui, "gallery_navigation", "Navigation bar", |ui| {
|
||||
text(ui, "Choose the controls on the bar at the bottom of the 3D view.", Text::Hint("gallery_navigation"));
|
||||
let width = ui.available_width();
|
||||
navigation_stage(ui, width);
|
||||
settings_card(ui, |ui| {
|
||||
text(ui, "Fit", Text::NameCell(true));
|
||||
text(ui, "Action · Runs once and never stays lit.", Text::Hint("gallery_navigation_action"));
|
||||
});
|
||||
navigation_tile(ui, "grid", "Grid", "style", false);
|
||||
row(ui, "Position", |ui| {
|
||||
segmented(ui, &mut state.selected, &["Left", "Centre", "Right"], Default::default());
|
||||
});
|
||||
checkbox(ui, "Show navigation bar", &mut state.checked);
|
||||
button(ui, "Reset to default", Button::Normal);
|
||||
});
|
||||
}),
|
||||
element!("settings_form", |ui, state| {
|
||||
settings_form(ui, Tokens::get().form_label_width, |ui| {
|
||||
row(ui, "Sample", |ui| {
|
||||
@@ -1036,6 +1095,10 @@ const ELEMENTS: &[Element] = &[
|
||||
let (rect, _) = ui.allocate_exact_size(vec2(row_height(), row_height()), egui::Sense::hover());
|
||||
icon_button_at(ui, rect, "close", "Close");
|
||||
}),
|
||||
element!("mirrored_icon_button_at", |ui, _| {
|
||||
let (rect, _) = ui.allocate_exact_size(vec2(row_height(), row_height()), egui::Sense::hover());
|
||||
mirrored_icon_button_at(ui, rect, "chevron_right", "Move left");
|
||||
}),
|
||||
element!("quiet_icon_button_at", |ui, _| {
|
||||
let (rect, _) = ui.allocate_exact_size(vec2(row_height(), row_height()), egui::Sense::hover());
|
||||
quiet_icon_button_at(ui, rect, "plus", "Add shortcut");
|
||||
@@ -1116,7 +1179,10 @@ const ELEMENTS: &[Element] = &[
|
||||
fn example(ui: &mut Ui, element: &Element) -> (&'static str, Option<&'static str>) {
|
||||
let mut sample = Sample { value: "12 mm".into(), second: "25 mm".into(), selected: 0, checked: true };
|
||||
let rect = ui.scope(|ui| (element.draw)(ui, &mut sample)).response.rect;
|
||||
if matches!(element.name, "menu" | "menu_submenu" | "rename_menu" | "workspace_menu" | "command_search" | "history_icons" | "history_names") {
|
||||
if matches!(
|
||||
element.name,
|
||||
"menu" | "menu_submenu" | "rename_menu" | "workspace_menu" | "command_search" | "history_icons" | "history_names" | "navigation_popup"
|
||||
) {
|
||||
// A popup's elevation is painted outside its layout rectangle. Reserve those
|
||||
// actual shadow bounds as part of the gallery sample, keeping the paint guard strict.
|
||||
ui.expand_to_include_rect(rect + Menu::frame().shadow.margin());
|
||||
|
||||
@@ -10,6 +10,7 @@ mod color;
|
||||
mod confirm;
|
||||
pub mod container;
|
||||
mod disclosure;
|
||||
mod drag;
|
||||
mod fields;
|
||||
mod file_view;
|
||||
mod history;
|
||||
@@ -17,6 +18,9 @@ mod layout;
|
||||
mod look_chain;
|
||||
mod menu;
|
||||
mod metrics;
|
||||
mod navigation;
|
||||
mod navigation_menu;
|
||||
mod navigation_settings;
|
||||
pub(crate) mod panel;
|
||||
mod preferences;
|
||||
mod preferences_assistant;
|
||||
@@ -44,6 +48,7 @@ pub(crate) use color::*;
|
||||
pub(crate) use confirm::{Confirm, Tone};
|
||||
pub use container::{Container, DockEdges, Edge, Surface};
|
||||
pub(crate) use disclosure::*;
|
||||
pub(crate) use drag::*;
|
||||
pub use fields::cell_editor;
|
||||
pub(crate) use fields::*;
|
||||
pub(crate) use file_view::{FileView, RecentRow, RecoveryMessage, SampleCard};
|
||||
@@ -52,6 +57,9 @@ pub(crate) use layout::*;
|
||||
pub use look_chain::{LookStep, look_chain};
|
||||
pub(crate) use menu::{Menu, MenuItem, rename_menu, workspace_menu};
|
||||
pub(crate) use metrics::{ContentWidth, header_height, row_height, table_row_height};
|
||||
pub(crate) use navigation::*;
|
||||
pub(crate) use navigation_menu::*;
|
||||
pub(crate) use navigation_settings::*;
|
||||
pub(crate) use panel::{ComputeStatus, FeatureOptions, Panel, Part, WindowPage, WorkspaceOptions, panel_header_hover};
|
||||
pub use panel::{DialogButtons, Window};
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
//! Navigation chrome and measurements shared by the viewport and Preferences editor.
|
||||
use crate::{
|
||||
icons,
|
||||
navigation_bar::{Idle, Kind, Size},
|
||||
theme::Tokens,
|
||||
};
|
||||
use egui::{Rect, Response, Sense, Ui, pos2, vec2};
|
||||
|
||||
pub(crate) const NAV_BORDER: f32 = 1.0;
|
||||
pub(crate) const NAV_PADDING: f32 = 3.0;
|
||||
pub(crate) const NAV_GAP: f32 = 2.0;
|
||||
pub(crate) const NAV_BOTTOM: f32 = 7.0;
|
||||
pub(crate) const NAV_EDGE: f32 = 12.0;
|
||||
pub(crate) const NAV_SEPARATOR: f32 = 9.0;
|
||||
pub(crate) const NAV_SEPARATOR_HEIGHT: f32 = 18.0;
|
||||
pub(crate) const NAV_MENU_LEFT: f32 = 7.0;
|
||||
pub(crate) const NAV_MENU_RIGHT: f32 = 6.0;
|
||||
pub(crate) const NAV_MENU_GAP: f32 = 5.0;
|
||||
pub(crate) const NAV_CHEVRON: f32 = 12.0;
|
||||
pub(crate) const NAV_TEXT: f32 = 12.5;
|
||||
pub(crate) const NAV_LABEL_GAP: f32 = 6.0;
|
||||
pub(crate) const NAV_LABEL_PADDING: f32 = 7.0;
|
||||
pub(crate) const NAV_POPUP_WIDTH: f32 = 244.0;
|
||||
pub(crate) const NAV_CONTEXT_WIDTH: f32 = 232.0;
|
||||
pub(crate) const NAV_MORE_WIDTH: f32 = 200.0;
|
||||
pub(crate) const NAV_POPUP_GAP: f32 = 6.0;
|
||||
pub(crate) const NAV_POPUP_PADDING: i8 = 5;
|
||||
pub(crate) const NAV_MENU_ROW: f32 = 30.0;
|
||||
pub(crate) const NAV_MENU_RADIUS: u8 = 6;
|
||||
pub(crate) const NAV_MENU_HEADING: f32 = 22.0;
|
||||
pub(crate) const NAV_HEADING_TEXT: f32 = 11.0;
|
||||
pub(crate) const NAV_HEADING_TRACKING: f32 = 0.07;
|
||||
pub(crate) const NAV_MENU_ICON: f32 = 17.0;
|
||||
pub(crate) const NAV_MENU_INSET: f32 = 8.0;
|
||||
pub(crate) const NAV_ROW_GAP: f32 = 9.0;
|
||||
pub(crate) const NAV_FOCUS_WIDTH: f32 = 2.0;
|
||||
pub(crate) const NAV_FOCUS_OFFSET: f32 = 1.0;
|
||||
pub(crate) const NAV_IDLE_OPACITY: f32 = 0.45;
|
||||
pub(crate) const NAV_HIDDEN_OPACITY: f32 = 0.4;
|
||||
pub(crate) const NAV_FADE_SECONDS: f32 = 0.12;
|
||||
pub(crate) const NAV_TOOLTIP_DELAY: f64 = 0.8;
|
||||
pub(crate) const NAV_TOOLTIP_KEY_LINE_HEIGHT: f32 = 15.0;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub(crate) struct NavigationMetrics {
|
||||
pub button: f32,
|
||||
pub icon: f32,
|
||||
pub radius: u8,
|
||||
pub button_radius: u8,
|
||||
}
|
||||
impl NavigationMetrics {
|
||||
pub(crate) fn for_size(size: Size) -> Self {
|
||||
match size {
|
||||
Size::Regular => Self { button: 32.0, icon: 18.0, radius: 10, button_radius: 7 },
|
||||
Size::Compact => Self { button: 26.0, icon: 16.0, radius: 9, button_radius: 6 },
|
||||
}
|
||||
}
|
||||
pub(crate) fn height(self) -> f32 {
|
||||
self.button + 2.0 * (NAV_BORDER + NAV_PADDING)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct NavigationButton<'a> {
|
||||
pub id: &'a str,
|
||||
pub label: &'a str,
|
||||
pub icon: &'a str,
|
||||
pub selected: bool,
|
||||
pub kind: Kind,
|
||||
pub labels: bool,
|
||||
pub menu: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum NavigationFill {
|
||||
None,
|
||||
Hover,
|
||||
Press,
|
||||
Active,
|
||||
}
|
||||
|
||||
/// Actions never latch, and keyboard focus has its own outline rather than a fill.
|
||||
pub(crate) fn navigation_visual(kind: Kind, active: bool, hovered: bool, pressed: bool, keyboard_focus: bool) -> (NavigationFill, bool) {
|
||||
let fill = if pressed || (active && kind == Kind::Menu) {
|
||||
NavigationFill::Press
|
||||
} else if active && matches!(kind, Kind::Tool | Kind::Toggle) {
|
||||
NavigationFill::Active
|
||||
} else if hovered {
|
||||
NavigationFill::Hover
|
||||
} else {
|
||||
NavigationFill::None
|
||||
};
|
||||
(fill, keyboard_focus)
|
||||
}
|
||||
|
||||
pub(crate) fn navigation_fill(t: &Tokens, fill: NavigationFill) -> Option<egui::Color32> {
|
||||
match fill {
|
||||
NavigationFill::None => None,
|
||||
NavigationFill::Hover => Some(t.nav_hover),
|
||||
NavigationFill::Press => Some(t.nav_press),
|
||||
NavigationFill::Active => Some(t.selected_bg),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn navigation_opacity(idle: Idle, active: bool) -> f32 {
|
||||
match idle {
|
||||
_ if active => 1.0,
|
||||
Idle::Always => 1.0,
|
||||
Idle::Fade => NAV_IDLE_OPACITY,
|
||||
Idle::Hide => 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn navigation_button(ui: &mut Ui, rect: Rect, button: NavigationButton<'_>) -> Response {
|
||||
navigation_button_editable(ui, rect, button, false)
|
||||
}
|
||||
|
||||
pub(crate) fn navigation_button_editable(ui: &mut Ui, rect: Rect, button: NavigationButton<'_>, editing: bool) -> Response {
|
||||
let t = Tokens::get();
|
||||
let metrics =
|
||||
NavigationMetrics::for_size(if rect.height() < NavigationMetrics::for_size(Size::Regular).button { Size::Compact } else { Size::Regular });
|
||||
let response = ui.interact(rect, ui.make_persistent_id(("nav_slot", button.id)), if editing { Sense::click_and_drag() } else { Sense::click() });
|
||||
let pressed = response.is_pointer_button_down_on();
|
||||
if pressed || response.clicked_by(egui::PointerButton::Primary) {
|
||||
response.surrender_focus();
|
||||
}
|
||||
let (fill, focus) = navigation_visual(button.kind, button.selected, response.hovered(), pressed, response.has_focus());
|
||||
if let Some(fill) = navigation_fill(&t, fill) {
|
||||
ui.painter().rect_filled(rect, metrics.button_radius, fill);
|
||||
}
|
||||
if focus {
|
||||
ui.painter().rect_stroke(
|
||||
rect.expand(NAV_FOCUS_OFFSET + NAV_FOCUS_WIDTH),
|
||||
metrics.button_radius.saturating_add((NAV_FOCUS_OFFSET + NAV_FOCUS_WIDTH) as u8),
|
||||
egui::Stroke::new(NAV_FOCUS_WIDTH, t.form_primary),
|
||||
egui::StrokeKind::Inside,
|
||||
);
|
||||
}
|
||||
let ink = if fill == NavigationFill::Active { t.form_primary } else { t.form_ink };
|
||||
let text = button.labels.then(|| ui.painter().layout_no_wrap(button.label.to_owned(), crate::fonts::medium(NAV_TEXT), ink));
|
||||
let mut x = if button.menu {
|
||||
rect.left() + NAV_MENU_LEFT + if editing { NAV_BORDER } else { 0.0 }
|
||||
} else {
|
||||
rect.center().x - (metrics.icon + text.as_ref().map_or(0.0, |g| NAV_LABEL_GAP + g.size().x)) / 2.0
|
||||
};
|
||||
icons::paint_ink(
|
||||
ui.painter(),
|
||||
Rect::from_center_size(pos2(x + metrics.icon / 2.0, rect.center().y), vec2(metrics.icon, metrics.icon)),
|
||||
button.icon,
|
||||
ink,
|
||||
);
|
||||
x += metrics.icon;
|
||||
if let Some(text) = text {
|
||||
x += if button.menu { NAV_MENU_GAP } else { NAV_LABEL_GAP };
|
||||
ui.painter().galley(pos2(x, rect.center().y - text.size().y / 2.0), text, ink);
|
||||
}
|
||||
if button.menu {
|
||||
let chevron = Rect::from_center_size(
|
||||
pos2(rect.right() - NAV_MENU_RIGHT - if editing { NAV_BORDER } else { 0.0 } - NAV_CHEVRON / 2.0, rect.center().y),
|
||||
vec2(NAV_CHEVRON, NAV_CHEVRON),
|
||||
);
|
||||
icons::paint_ink_flipped(ui.painter(), chevron, "chevron", t.form_dim);
|
||||
}
|
||||
if response.hovered() {
|
||||
ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
|
||||
}
|
||||
response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), button.selected, button.label));
|
||||
response
|
||||
}
|
||||
|
||||
pub(crate) fn navigation_separator(ui: &Ui, rect: Rect) {
|
||||
let t = Tokens::get();
|
||||
ui.painter().vline(
|
||||
rect.center().x,
|
||||
rect.center().y - NAV_SEPARATOR_HEIGHT / 2.0..=rect.center().y + NAV_SEPARATOR_HEIGHT / 2.0,
|
||||
egui::Stroke::new(NAV_BORDER, t.control_border),
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn navigation_edit_outline(ui: &Ui, rect: Rect, hidden: bool, selected: bool) {
|
||||
let t = Tokens::get();
|
||||
let metrics =
|
||||
NavigationMetrics::for_size(if rect.height() < NavigationMetrics::for_size(Size::Regular).button { Size::Compact } else { Size::Regular });
|
||||
let mut painter = ui.painter().clone();
|
||||
if hidden {
|
||||
painter.multiply_opacity(NAV_HIDDEN_OPACITY);
|
||||
let mut points = Vec::new();
|
||||
egui::epaint::tessellator::path::rounded_rectangle(
|
||||
&mut points,
|
||||
rect.shrink(NAV_BORDER / 2.0),
|
||||
egui::epaint::CornerRadiusF32::same(f32::from(metrics.button_radius) - NAV_BORDER / 2.0),
|
||||
);
|
||||
if let Some(first) = points.first().copied() {
|
||||
points.push(first);
|
||||
}
|
||||
painter.extend(egui::Shape::dashed_line(&points, egui::Stroke::new(NAV_BORDER, t.control_border), t.space_4, t.space_3));
|
||||
}
|
||||
if selected {
|
||||
painter.rect_stroke(
|
||||
rect.expand(NAV_FOCUS_WIDTH),
|
||||
metrics.button_radius.saturating_add(NAV_FOCUS_WIDTH as u8),
|
||||
egui::Stroke::new(NAV_FOCUS_WIDTH, t.form_primary),
|
||||
egui::StrokeKind::Inside,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn navigation_surface(ui: &Ui, rect: Rect, size: Size, editing: bool) {
|
||||
let t = Tokens::get();
|
||||
let frame = super::Container::new(ui.ctx(), super::Surface::Navigation)
|
||||
.frame(ui.ctx(), t.dialog_body, crate::frame::Side::Left)
|
||||
.fill(if editing { t.dialog_body } else { t.dialog_body.gamma_multiply(0.97) })
|
||||
.stroke(egui::Stroke::new(NAV_BORDER, t.dialog_border))
|
||||
.corner_radius(NavigationMetrics::for_size(size).radius);
|
||||
super::Container::paint_frame(ui.painter(), frame, rect.shrink(NAV_BORDER));
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
//! Popup and tooltip skin from the approved navigation boards.
|
||||
use super::{Container, Surface, navigation::*};
|
||||
use crate::{icons, theme::Tokens};
|
||||
use egui::{Align2, FontId, Rect, Response, Sense, Ui, pos2, vec2};
|
||||
|
||||
pub(crate) fn navigation_popup_frame() -> egui::Frame {
|
||||
Container::menu_frame().inner_margin(egui::Margin::same(NAV_POPUP_PADDING))
|
||||
}
|
||||
|
||||
pub(crate) fn navigation_menu<R>(ui: &mut Ui, width: f32, add: impl FnOnce(&mut Ui) -> R) -> R {
|
||||
Container::new(ui.ctx(), Surface::Popup)
|
||||
.show_frame(ui, navigation_popup_frame(), ui.max_rect(), |ui| {
|
||||
ui.set_width((width - 2.0 * (f32::from(NAV_POPUP_PADDING) + NAV_BORDER)).max(0.0));
|
||||
ui.spacing_mut().item_spacing.y = 0.0;
|
||||
ui.with_layout(egui::Layout::top_down(egui::Align::Min), add).inner
|
||||
})
|
||||
.inner
|
||||
}
|
||||
|
||||
pub(crate) fn navigation_context<R>(response: &Response, add: impl FnOnce(&mut Ui) -> R) {
|
||||
Container::new(&response.ctx, Surface::Popup).context_menu(response).frame(navigation_popup_frame()).show(|ui| {
|
||||
ui.set_width(NAV_CONTEXT_WIDTH - 2.0 * (f32::from(NAV_POPUP_PADDING) + NAV_BORDER));
|
||||
ui.spacing_mut().item_spacing.y = 0.0;
|
||||
add(ui)
|
||||
});
|
||||
}
|
||||
|
||||
pub(crate) struct NavigationMenuRow<'a> {
|
||||
pub id: &'a str,
|
||||
pub label: &'a str,
|
||||
pub icon: &'a str,
|
||||
pub selected: bool,
|
||||
pub enabled: bool,
|
||||
pub detail: Option<&'a str>,
|
||||
pub submenu: bool,
|
||||
}
|
||||
impl<'a> NavigationMenuRow<'a> {
|
||||
pub(crate) fn new(id: &'a str, label: &'a str, icon: &'a str) -> Self {
|
||||
Self { id, label, icon, selected: false, enabled: true, detail: None, submenu: false }
|
||||
}
|
||||
pub(crate) fn show(self, ui: &mut Ui) -> Response {
|
||||
let t = Tokens::get();
|
||||
let (rect, _) = ui.allocate_exact_size(vec2(ui.available_width().max(0.0), NAV_MENU_ROW), Sense::hover());
|
||||
let response = ui.interact(rect, ui.id().with(self.id), if self.enabled { Sense::click() } else { Sense::hover() });
|
||||
let ink = if self.selected { t.form_primary } else { t.form_ink };
|
||||
let bg = if self.selected {
|
||||
Some(t.selected_bg)
|
||||
} else if response.hovered() && self.enabled {
|
||||
Some(t.nav_hover)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
if let Some(bg) = bg {
|
||||
ui.painter().rect_filled(rect, NAV_MENU_RADIUS, bg);
|
||||
}
|
||||
if !self.icon.is_empty() {
|
||||
let icon =
|
||||
Rect::from_center_size(pos2(rect.left() + NAV_MENU_INSET + NAV_MENU_ICON / 2.0, rect.center().y), vec2(NAV_MENU_ICON, NAV_MENU_ICON));
|
||||
icons::paint_ink(ui.painter(), icon, self.icon, if self.selected { ink } else { t.form_dim });
|
||||
}
|
||||
let font = if self.selected { crate::fonts::semibold(NAV_TEXT) } else { FontId::proportional(NAV_TEXT) };
|
||||
ui.painter().text(
|
||||
pos2(rect.left() + NAV_MENU_INSET + NAV_MENU_ICON + NAV_ROW_GAP, rect.center().y),
|
||||
Align2::LEFT_CENTER,
|
||||
self.label,
|
||||
font,
|
||||
ink,
|
||||
);
|
||||
if let Some(detail) = self.detail {
|
||||
ui.painter().text(
|
||||
pos2(rect.right() - NAV_MENU_INSET - if self.submenu { NAV_CHEVRON + t.space_4 } else { 0.0 }, rect.center().y),
|
||||
Align2::RIGHT_CENTER,
|
||||
detail,
|
||||
FontId::proportional(if self.enabled { t.font_body } else { t.font_small }),
|
||||
if self.enabled { t.form_dim } else { t.nav_dim },
|
||||
);
|
||||
}
|
||||
let tail = Rect::from_center_size(pos2(rect.right() - NAV_MENU_INSET - t.space_14 / 2.0, rect.center().y), vec2(t.space_14, t.space_14));
|
||||
if self.selected {
|
||||
super::checks::paint_check_glyph(ui.painter(), tail, false, t.form_primary);
|
||||
} else if self.submenu {
|
||||
let arrow =
|
||||
Rect::from_center_size(pos2(rect.right() - NAV_MENU_INSET - NAV_CHEVRON / 2.0, rect.center().y), vec2(NAV_CHEVRON, NAV_CHEVRON));
|
||||
icons::paint_ink(ui.painter(), arrow, "chevron", t.form_dim);
|
||||
}
|
||||
response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, self.enabled && ui.is_enabled(), self.selected, self.label));
|
||||
response
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn navigation_menu_heading(ui: &mut Ui, title: &str) {
|
||||
let t = Tokens::get();
|
||||
let (rect, _) = ui.allocate_exact_size(vec2(ui.available_width().max(0.0), NAV_MENU_HEADING), Sense::hover());
|
||||
let mut format = egui::TextFormat::simple(crate::fonts::semibold(NAV_HEADING_TEXT), t.form_dim);
|
||||
format.extra_letter_spacing = NAV_HEADING_TEXT * NAV_HEADING_TRACKING;
|
||||
let galley = ui.painter().layout_job(egui::text::LayoutJob::single_section(title.to_uppercase(), format));
|
||||
ui.painter().galley(rect.min + vec2(t.space_8, t.space_6), galley, t.form_dim);
|
||||
}
|
||||
|
||||
pub(crate) fn navigation_menu_separator(ui: &mut Ui) {
|
||||
let t = Tokens::get();
|
||||
let (rect, _) = ui.allocate_exact_size(vec2(ui.available_width().max(0.0), NAV_BORDER + 2.0 * t.space_4), Sense::hover());
|
||||
ui.painter().hline(rect.shrink2(vec2(t.space_2, 0.0)).x_range(), rect.center().y, egui::Stroke::new(NAV_BORDER, t.dialog_rule));
|
||||
}
|
||||
|
||||
pub(crate) fn navigation_tooltip(response: &Response, top: f32, label: &str, shortcut: Option<&str>) {
|
||||
let ctx = &response.ctx;
|
||||
let id = response.id.with("nav_tooltip_delay");
|
||||
if !response.hovered() {
|
||||
ctx.data_mut(|data| data.remove::<f64>(id));
|
||||
return;
|
||||
}
|
||||
let now = ctx.input(|i| i.time);
|
||||
let began = ctx.data_mut(|data| *data.get_temp_mut_or_insert_with(id, || now));
|
||||
if now - began < NAV_TOOLTIP_DELAY {
|
||||
ctx.request_repaint_after(std::time::Duration::from_secs_f64((NAV_TOOLTIP_DELAY - (now - began)).clamp(0.0, NAV_TOOLTIP_DELAY)));
|
||||
return;
|
||||
}
|
||||
let t = Tokens::get();
|
||||
let frame =
|
||||
egui::Frame::NONE.fill(t.nav_tip).corner_radius(t.control_radius).inner_margin(egui::Margin::symmetric(t.space_8 as i8, NAV_POPUP_PADDING));
|
||||
Container::new(ctx, Surface::Popup)
|
||||
.area(response.id.with("nav_tooltip"))
|
||||
.order(egui::Order::Tooltip)
|
||||
.interactable(false)
|
||||
.pivot(Align2::CENTER_BOTTOM)
|
||||
.fixed_pos(pos2(response.rect.center().x, top - NAV_POPUP_GAP))
|
||||
.show(ctx, |ui| {
|
||||
Container::new(ctx, Surface::Popup).show_frame(ui, frame, ui.max_rect(), |ui| {
|
||||
ui.spacing_mut().item_spacing.x = t.space_8;
|
||||
ui.spacing_mut().interact_size.y = 0.0;
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(egui::RichText::new(label).font(crate::fonts::medium(t.font_body)).color(t.nav_tip_ink));
|
||||
if let Some(key) = shortcut {
|
||||
egui::Frame::NONE
|
||||
.stroke(egui::Stroke::new(NAV_BORDER, t.nav_tip_key_border))
|
||||
.corner_radius(t.radius_sm)
|
||||
.inner_margin(egui::Margin::symmetric(NAV_POPUP_PADDING, 0))
|
||||
.show(ui, |ui| {
|
||||
ui.label(
|
||||
egui::RichText::new(key)
|
||||
.monospace()
|
||||
.size(t.font_small)
|
||||
.line_height(Some(NAV_TOOLTIP_KEY_LINE_HEIGHT))
|
||||
.color(t.nav_tip_ink),
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
//! Preference compositions for the approved Navigation bar board.
|
||||
use super::{Container, Surface, navigation::*};
|
||||
use crate::{icons, theme::Tokens};
|
||||
use egui::{FontId, Rect, Response, Sense, Ui, pos2, vec2};
|
||||
|
||||
pub(crate) const NAV_STAGE_HEIGHT: f32 = 58.0;
|
||||
pub(crate) const NAV_STAGE_INSET: f32 = 12.0;
|
||||
pub(crate) const NAV_STAGE_RADIUS: u8 = 8;
|
||||
pub(crate) const NAV_TILE_HEIGHT: f32 = 30.0 + 2.0 * NAV_BORDER;
|
||||
pub(crate) const NAV_TILE_ICON: f32 = 16.0;
|
||||
pub(crate) const NAV_TILE_ADD: f32 = 22.0;
|
||||
pub(crate) const NAV_MARKER_HEIGHT: f32 = 24.0;
|
||||
pub(crate) const NAV_GHOST_OPACITY: f32 = 0.7;
|
||||
pub(crate) const NAV_TILE_DRAG_OPACITY: f32 = 0.55;
|
||||
const NAV_TILE_INSET: f32 = 9.0;
|
||||
const NAV_TILE_GAP: f32 = 7.0;
|
||||
const NAV_TILE_RADIUS: u8 = 7;
|
||||
|
||||
pub(crate) fn navigation_stage(ui: &mut Ui, width: f32) -> Rect {
|
||||
let t = Tokens::get();
|
||||
let (rect, _) = ui.allocate_exact_size(vec2(width.max(0.0), NAV_STAGE_HEIGHT), Sense::hover());
|
||||
let frame = Container::new(ui.ctx(), Surface::Canvas)
|
||||
.frame(ui.ctx(), t.nav_viewport, crate::frame::Side::Left)
|
||||
.stroke(egui::Stroke::new(NAV_BORDER, t.dialog_border))
|
||||
.corner_radius(NAV_STAGE_RADIUS);
|
||||
Container::paint_frame(ui.painter(), frame, rect.shrink(NAV_BORDER));
|
||||
rect
|
||||
}
|
||||
|
||||
pub(crate) fn navigation_tile(ui: &mut Ui, id: &str, label: &str, icon: &str, dragging: bool) -> (Response, Response) {
|
||||
let t = Tokens::get();
|
||||
let text = ui.painter().layout_no_wrap(label.to_owned(), FontId::proportional(NAV_TEXT), t.form_ink);
|
||||
let width = (2.0 * NAV_BORDER + NAV_TILE_INSET + NAV_TILE_ICON + NAV_TILE_GAP + text.size().x + NAV_TILE_GAP + NAV_TILE_ADD + t.space_4)
|
||||
.min(ui.max_rect().width().max(0.0));
|
||||
let (rect, _) = ui.allocate_exact_size(vec2(width, NAV_TILE_HEIGHT), Sense::hover());
|
||||
let response = ui.interact(rect, ui.id().with((id, "tile")), Sense::click_and_drag());
|
||||
let add_rect =
|
||||
Rect::from_center_size(pos2(rect.right() - NAV_BORDER - t.space_4 - NAV_TILE_ADD / 2.0, rect.center().y), vec2(NAV_TILE_ADD, NAV_TILE_ADD));
|
||||
let add = ui.interact(add_rect, ui.id().with((id, "add")), Sense::click());
|
||||
let mut painter = ui.painter().clone();
|
||||
if dragging {
|
||||
painter.multiply_opacity(NAV_TILE_DRAG_OPACITY);
|
||||
}
|
||||
painter.rect(
|
||||
rect,
|
||||
NAV_TILE_RADIUS,
|
||||
if response.hovered() { t.nav_hover } else { t.nav_field },
|
||||
egui::Stroke::new(NAV_BORDER, t.control_border),
|
||||
egui::StrokeKind::Inside,
|
||||
);
|
||||
let icon_rect = Rect::from_center_size(
|
||||
pos2(rect.left() + NAV_BORDER + NAV_TILE_INSET + NAV_TILE_ICON / 2.0, rect.center().y),
|
||||
vec2(NAV_TILE_ICON, NAV_TILE_ICON),
|
||||
);
|
||||
if icon.is_empty() {
|
||||
painter.vline(icon_rect.center().x, icon_rect.y_range(), egui::Stroke::new(NAV_BORDER, t.form_dim));
|
||||
} else {
|
||||
icons::paint_ink(&painter, icon_rect, icon, t.form_dim);
|
||||
}
|
||||
painter
|
||||
.with_clip_rect(rect.intersect(ui.clip_rect()).intersect(Rect::from_min_max(rect.min, pos2(add_rect.left() - NAV_TILE_GAP, rect.bottom()))))
|
||||
.galley(pos2(icon_rect.right() + NAV_TILE_GAP, rect.center().y - text.size().y / 2.0), text, t.form_ink);
|
||||
if add.hovered() {
|
||||
painter.rect_filled(add_rect, t.control_radius.saturating_sub(NAV_BORDER as u8), t.nav_hover);
|
||||
}
|
||||
icons::paint_ink(&painter, Rect::from_center_size(add_rect.center(), vec2(t.space_14, t.space_14)), "plus", t.form_primary);
|
||||
response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label));
|
||||
add.widget_info(|| {
|
||||
egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), crate::i18n::format("navbar.custom.add_slot", &[("slot", label)]))
|
||||
});
|
||||
(response, add)
|
||||
}
|
||||
|
||||
pub(crate) fn navigation_drag_ghost(ui: &Ui, at: egui::Pos2, button: NavigationButton<'_>, size: crate::navigation_bar::Size) {
|
||||
let ctx = ui.ctx();
|
||||
let t = Tokens::get();
|
||||
let metrics = NavigationMetrics::for_size(size);
|
||||
let width =
|
||||
if button.menu { metrics.icon + NAV_MENU_LEFT + NAV_MENU_RIGHT + NAV_MENU_GAP + NAV_CHEVRON + 2.0 * NAV_BORDER } else { metrics.button };
|
||||
Container::new(ctx, Surface::Navigation)
|
||||
.area(ui.id().with("navigation_drag_ghost"))
|
||||
.order(egui::Order::Tooltip)
|
||||
.interactable(false)
|
||||
.fixed_pos(at + vec2(t.space_14, t.space_16))
|
||||
.show(ctx, |ui| {
|
||||
ui.set_opacity(NAV_GHOST_OPACITY);
|
||||
let (rect, _) = ui.allocate_exact_size(vec2(width, metrics.button), Sense::hover());
|
||||
ui.painter().rect_filled(rect, metrics.button_radius, t.nav_hover);
|
||||
super::navigation_button_editable(ui, rect, button, true);
|
||||
});
|
||||
}
|
||||
@@ -3,6 +3,9 @@ use super::{actions::icon_button_at, metrics::*, text::paint_text};
|
||||
use crate::{scenario, theme::Tokens};
|
||||
use egui::{Ui, vec2};
|
||||
|
||||
const WINDOW_PAGES_NARROW_WIDTH: f32 = 150.0;
|
||||
const WINDOW_PAGES_NARROW_AT: f32 = 700.0;
|
||||
|
||||
/// Shared active-tab hover tint for the browser and collapsible panel chrome.
|
||||
pub(crate) fn panel_header_hover(painter: &egui::Painter, rect: egui::Rect) {
|
||||
let t = Tokens::get();
|
||||
@@ -11,16 +14,23 @@ pub(crate) fn panel_header_hover(painter: &egui::Painter, rect: egui::Rect) {
|
||||
|
||||
/// Feature title/icon/close band. Tokens: `form_header_height, form_icon_size, form_close_size, form_inset, font_label, text, dialog_rule, space_8/10; icon_button_at tokens`.
|
||||
pub(crate) fn header(ui: &mut Ui, icon: &str, title: &str, on_close: impl FnOnce()) {
|
||||
header_impl(ui, icon, title, None, true, on_close);
|
||||
header_impl(ui, (icon, None), title, None, true, on_close);
|
||||
}
|
||||
|
||||
/// Optional fold action for managers which historically hide their inputs without losing edits.
|
||||
/// Tokens: header tokens and space_4; retains the dialog:collapse scenario handle.
|
||||
pub(crate) fn collapsible_header(ui: &mut Ui, icon: &str, title: &str, collapsed: &mut bool, on_close: impl FnOnce()) {
|
||||
header_impl(ui, icon, title, Some(collapsed), true, on_close);
|
||||
header_impl(ui, (icon, None), title, Some(collapsed), true, on_close);
|
||||
}
|
||||
|
||||
fn header_impl(ui: &mut Ui, icon: &str, title: &str, collapsed: Option<&mut bool>, closeable: bool, on_close: impl FnOnce()) {
|
||||
fn header_impl(
|
||||
ui: &mut Ui,
|
||||
icon: (&str, Option<egui::Color32>),
|
||||
title: &str,
|
||||
collapsed: Option<&mut bool>,
|
||||
closeable: bool,
|
||||
on_close: impl FnOnce(),
|
||||
) {
|
||||
let t = Tokens::get();
|
||||
let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), header_height()), egui::Sense::hover());
|
||||
// Shared card chrome: 12 pt left inset, 19 pt icon, 8 pt gap and 26 pt close target.
|
||||
@@ -28,7 +38,11 @@ fn header_impl(ui: &mut Ui, icon: &str, title: &str, collapsed: Option<&mut bool
|
||||
egui::pos2(rect.left() + t.space_12 + t.form_icon_size / 2.0, rect.center().y),
|
||||
vec2(t.form_icon_size, t.form_icon_size),
|
||||
);
|
||||
crate::icons::paint_icon(ui.painter(), icon_rect, icon, 1.0);
|
||||
if let Some(ink) = icon.1 {
|
||||
crate::icons::paint_ink(ui.painter(), icon_rect, icon.0, ink);
|
||||
} else {
|
||||
crate::icons::paint_icon(ui.painter(), icon_rect, icon.0, 1.0);
|
||||
}
|
||||
let close_rect = egui::Rect::from_center_size(
|
||||
egui::pos2((rect.right() - t.space_8 - t.form_close_size / 2.0).max(rect.left()), rect.center().y),
|
||||
vec2(t.form_close_size, t.form_close_size),
|
||||
@@ -319,7 +333,7 @@ impl<'a> Panel<'a> {
|
||||
let band = egui::Rect::from_min_size(ui.cursor().min, vec2(ui.available_width(), header_height()));
|
||||
let grip = ui.interact(band, ui.id().with("workspace_grip"), egui::Sense::drag()).on_hover_cursor(egui::CursorIcon::Grab);
|
||||
scenario::publish_target(&format!("{}:grip", options.id), grip.rect);
|
||||
header_impl(ui, options.icon, options.title, None, false, || {});
|
||||
header_impl(ui, (options.icon, None), options.title, None, false, || {});
|
||||
scenario::publish_rect(&format!("{}:header", options.id), band);
|
||||
if grip.dragged() {
|
||||
let frame_nr = ui.ctx().cumulative_frame_nr();
|
||||
@@ -687,7 +701,8 @@ pub struct Window<'a> {
|
||||
width: f32,
|
||||
body_padding: bool,
|
||||
page_rows: f32,
|
||||
page_padding: egui::Vec2,
|
||||
page_padding: egui::Margin,
|
||||
page_chrome: bool,
|
||||
left_slot: bool,
|
||||
}
|
||||
|
||||
@@ -709,7 +724,8 @@ impl<'a> Window<'a> {
|
||||
width: Tokens::get().form_card_width * 1.5,
|
||||
body_padding: true,
|
||||
page_rows: 16.0,
|
||||
page_padding: vec2(Tokens::get().space_16, Tokens::get().space_16),
|
||||
page_padding: egui::Margin::same(Tokens::get().space_16 as i8),
|
||||
page_chrome: false,
|
||||
left_slot: false,
|
||||
}
|
||||
}
|
||||
@@ -764,10 +780,9 @@ impl<'a> Window<'a> {
|
||||
}
|
||||
|
||||
/// Content inset for a page-based window, independent of its navigation rail.
|
||||
pub(crate) fn page_padding(mut self, padding: egui::Vec2) -> Self {
|
||||
if padding.is_finite() {
|
||||
self.page_padding = padding.max(egui::Vec2::ZERO);
|
||||
}
|
||||
pub(crate) fn page_padding(mut self, padding: egui::Margin) -> Self {
|
||||
self.page_padding =
|
||||
egui::Margin { left: padding.left.max(0), right: padding.right.max(0), top: padding.top.max(0), bottom: padding.bottom.max(0) };
|
||||
self
|
||||
}
|
||||
|
||||
@@ -808,7 +823,7 @@ impl<'a> Window<'a> {
|
||||
let t = Tokens::get();
|
||||
ui.spacing_mut().item_spacing.y = 0.0;
|
||||
let mut close = false;
|
||||
header_impl(ui, self.icon, self.title, None, self.closeable, || close = true);
|
||||
header_impl(ui, (self.icon, self.page_chrome.then_some(t.form_primary)), self.title, None, self.closeable, || close = true);
|
||||
egui::Frame::NONE.inner_margin(if self.body_padding { t.space_12 } else { 0.0 }).show(ui, |ui| {
|
||||
ui.spacing_mut().item_spacing.y = t.form_gap_y;
|
||||
if self.body_padding {
|
||||
@@ -879,6 +894,7 @@ impl<'a> Window<'a> {
|
||||
left: impl FnOnce(&mut Ui),
|
||||
) -> (bool, super::Action) {
|
||||
self.body_padding = false;
|
||||
self.page_chrome = true;
|
||||
let rows = self.page_rows;
|
||||
let padding = self.page_padding;
|
||||
self.show_with_left(ctx, true, |ui| page_list_sized(ui, selected, pages, state, rows, padding, header, on_select), left)
|
||||
@@ -886,7 +902,11 @@ impl<'a> Window<'a> {
|
||||
|
||||
/// The same bounded card frame, either movable or an input-blocking modal.
|
||||
pub(super) fn surface(&self, ctx: &egui::Context, modal: bool, add: impl FnOnce(&mut Ui) -> (bool, super::Action)) -> (bool, super::Action) {
|
||||
let frame = Panel::card_frame(ctx);
|
||||
let frame = if self.page_chrome {
|
||||
super::navigation_popup_frame().inner_margin(0).fill(Tokens::get().dialog_body.gamma_multiply(0.97))
|
||||
} else {
|
||||
Panel::card_frame(ctx)
|
||||
};
|
||||
let inner_width = (self.width.min(dimension(ctx.content_rect().width())) - frame.total_margin().sum().x).max(0.0);
|
||||
if modal {
|
||||
let shown = super::Container::new(ctx, super::Surface::Window)
|
||||
@@ -944,7 +964,7 @@ pub(crate) struct WindowPage<S> {
|
||||
|
||||
#[cfg(test)]
|
||||
pub(super) fn page_list<S>(ui: &mut Ui, selected: &mut usize, pages: &[WindowPage<S>], state: &mut S) {
|
||||
page_list_sized(ui, selected, pages, state, 16.0, vec2(Tokens::get().space_16, Tokens::get().space_16), None, None);
|
||||
page_list_sized(ui, selected, pages, state, 16.0, egui::Margin::same(Tokens::get().space_16 as i8), None, None);
|
||||
}
|
||||
|
||||
fn page_list_sized<S>(
|
||||
@@ -953,7 +973,7 @@ fn page_list_sized<S>(
|
||||
pages: &[WindowPage<S>],
|
||||
state: &mut S,
|
||||
rows: f32,
|
||||
padding: egui::Vec2,
|
||||
padding: egui::Margin,
|
||||
header: Option<fn(&mut Ui, &mut S)>,
|
||||
on_select: Option<fn(&mut S)>,
|
||||
) {
|
||||
@@ -964,7 +984,12 @@ fn page_list_sized<S>(
|
||||
let height = (dimension(ui.ctx().content_rect().height()) - t.form_header_height - t.form_footer_height - t.space_24 * 3.0)
|
||||
.clamp(0.0, t.control_height * rows + header_band);
|
||||
let (body, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), height), egui::Sense::hover());
|
||||
let width = (t.form_label_width * 2.0 + t.space_24 * 2.0).min(body.width());
|
||||
let width = if body.width() + 2.0 * super::NAV_BORDER < WINDOW_PAGES_NARROW_AT {
|
||||
WINDOW_PAGES_NARROW_WIDTH
|
||||
} else {
|
||||
t.form_label_width * 2.0 + t.space_24 * 2.0
|
||||
}
|
||||
.min(body.width());
|
||||
let nav = egui::Rect::from_min_size(body.min, vec2(width, body.height()));
|
||||
ui.painter().rect_filled(nav, 0.0, t.dialog_footer);
|
||||
t.secondary_vline(ui.painter(), nav.right(), nav.y_range(), t.dialog_rule);
|
||||
@@ -994,11 +1019,11 @@ fn page_list_sized<S>(
|
||||
if on || response.hovered() || response.has_focus() {
|
||||
ui.painter().rect_filled(rect, t.control_radius, if on { t.selected_bg } else { t.hover });
|
||||
}
|
||||
let ink = if on { t.selected_ink } else { t.form_ink };
|
||||
let ink = if on { t.form_primary } else { t.form_ink };
|
||||
let icon =
|
||||
egui::Rect::from_center_size(egui::pos2(rect.left() + t.space_10 + t.space_8, rect.center().y), vec2(t.space_16, t.space_16));
|
||||
crate::icons::paint_ink(ui.painter(), icon, page.icon, if on { ink } else { t.form_dim });
|
||||
let text_rect = egui::Rect::from_min_max(egui::pos2(icon.right() + t.space_8, rect.top()), rect.right_bottom());
|
||||
let text_rect = egui::Rect::from_min_max(egui::pos2(icon.right() + super::NAV_ROW_GAP, rect.top()), rect.right_bottom());
|
||||
paint_text(
|
||||
ui,
|
||||
text_rect,
|
||||
@@ -1017,11 +1042,17 @@ fn page_list_sized<S>(
|
||||
});
|
||||
});
|
||||
let content = egui::Rect::from_min_max(egui::pos2(nav.right(), body.top()), body.max);
|
||||
let content = content.shrink2(vec2(padding.x.min(content.width() / 2.0), padding.y.min(content.height() / 2.0)));
|
||||
let padding = egui::epaint::MarginF32 {
|
||||
left: padding.leftf().min(content.width() / 2.0),
|
||||
right: padding.rightf().min(content.width() / 2.0),
|
||||
top: padding.topf().min(content.height() / 2.0),
|
||||
bottom: padding.bottomf().min(content.height() / 2.0),
|
||||
};
|
||||
let content = content - padding;
|
||||
ui.scope_builder(
|
||||
egui::UiBuilder::new()
|
||||
.max_rect(content)
|
||||
.ui_stack_info(egui::UiStackInfo::default().with_tag_value(super::preferences::PAGE_SCROLL_GUTTER, padding.x)),
|
||||
.ui_stack_info(egui::UiStackInfo::default().with_tag_value(super::preferences::PAGE_SCROLL_GUTTER, padding.right)),
|
||||
|ui| {
|
||||
let clip = egui::Rect::from_min_max(content.min, egui::pos2(body.right(), content.bottom()));
|
||||
ui.set_clip_rect(ui.clip_rect().intersect(clip));
|
||||
|
||||
@@ -26,12 +26,26 @@ pub(crate) fn settings_scroll<R>(ui: &mut Ui, id: impl egui::AsIdSalt, add: impl
|
||||
scroll.floating_allocated_width = 0.0;
|
||||
scroll.bar_outer_margin = 0.0;
|
||||
}
|
||||
egui::ScrollArea::vertical().id_salt(id).max_height(height).auto_shrink([false, false]).show(ui, |ui| {
|
||||
let mut scroll = egui::ScrollArea::vertical().id_salt(id).max_height(height).auto_shrink([false, false]).show(ui, |ui| {
|
||||
if gutter > 0.0 {
|
||||
ui.set_width(width);
|
||||
// The scrollbar host extends into the gutter. Its content must neither use
|
||||
// that extension nor grow the page/window when a child requests extra width.
|
||||
let bounds = Rect::from_min_size(ui.next_widget_position(), vec2(width, ui.available_height()));
|
||||
let mut content = ui.new_child(egui::UiBuilder::new().max_rect(bounds));
|
||||
let clip = content.clip_rect();
|
||||
content.set_clip_rect(clip.intersect(Rect::from_min_max(pos2(bounds.left(), clip.top()), pos2(bounds.right(), clip.bottom()))));
|
||||
let result = add(&mut content);
|
||||
ui.allocate_exact_size(vec2(width, content.min_size().y), Sense::hover());
|
||||
result
|
||||
} else {
|
||||
add(ui)
|
||||
}
|
||||
add(ui)
|
||||
})
|
||||
});
|
||||
// Consumers publish the page's content well, not the extended scrollbar host.
|
||||
if gutter > 0.0 {
|
||||
scroll.inner_rect.max.x = scroll.inner_rect.left() + width;
|
||||
}
|
||||
scroll
|
||||
})
|
||||
.inner
|
||||
}
|
||||
@@ -90,6 +104,19 @@ pub(crate) fn settings_section<R>(ui: &mut Ui, key: &str, title: &str, mut add:
|
||||
})
|
||||
}
|
||||
|
||||
/// Full-width settings detail group. Container owns its surface; content cannot shrink the card.
|
||||
pub(crate) fn settings_card<R>(ui: &mut Ui, add: impl FnOnce(&mut Ui) -> R) -> egui::InnerResponse<R> {
|
||||
let t = Tokens::get();
|
||||
let container = super::Container::new(ui.ctx(), super::Surface::Navigation);
|
||||
let frame = container
|
||||
.frame(ui.ctx(), t.dialog_footer, crate::frame::Side::Left)
|
||||
.inner_margin(egui::Margin::symmetric(t.space_12 as i8, t.space_10 as i8));
|
||||
container.show_frame(ui, frame, ui.max_rect(), |ui| {
|
||||
ui.set_min_width(dimension(ui.available_width()));
|
||||
add(ui)
|
||||
})
|
||||
}
|
||||
|
||||
/// Only the four palette roles needed by a swatch, avoiding a copy of the full theme.
|
||||
#[derive(Clone, Copy)]
|
||||
pub(crate) struct ThemeSwatch {
|
||||
|
||||
@@ -223,28 +223,33 @@ fn navigation_bar_buttons_run_registered_commands() {
|
||||
moved_block(&mut h);
|
||||
let undo = h.app.session.undo.len();
|
||||
let mut orbit_on = false;
|
||||
for (index, id) in [
|
||||
(0, "view.tool"),
|
||||
(0, "view.tool"),
|
||||
(2, "view.tool"),
|
||||
(3, "view.tool"),
|
||||
(4, "view.fit"),
|
||||
(6, "view.home"),
|
||||
(8, "view.visual_style"),
|
||||
(1, "view.spin"),
|
||||
h.call("ui.prefs", json!({"navigation_bar":{"slots":["orbit","pan","zoom","fit","home","visual_style","spin"]}}));
|
||||
for (slot, id) in [
|
||||
("orbit", "view.tool"),
|
||||
("orbit", "view.tool"),
|
||||
("pan", "view.tool"),
|
||||
("zoom", "view.tool"),
|
||||
("fit", "view.fit"),
|
||||
("home", "view.home"),
|
||||
("spin", "view.spin"),
|
||||
] {
|
||||
let bar = crate::scenario::rect_of("nav:outer").unwrap();
|
||||
let at = bar.left_top() + egui::vec2(18.0 + index as f32 * 30.0, 15.0);
|
||||
let at = crate::scenario::handle_at(&format!("nav:slot:{slot}")).unwrap();
|
||||
let log = h.app.session.log.len();
|
||||
h.call("ui.click", json!({"x":at.x,"y":at.y}));
|
||||
let label = solidcraft_engine::find_command(id).unwrap().label;
|
||||
let echo = crate::i18n::Locale::for_language(&h.app.preferences.language).format("ui.command_done", &[("command", label)]);
|
||||
assert!(h.app.session.log.iter().skip(log).any(|line| line == &echo), "{id} was not run");
|
||||
if index == 0 {
|
||||
if slot == "orbit" {
|
||||
orbit_on = !orbit_on;
|
||||
assert_eq!(h.app.viewport.nav, if orbit_on { Some(crate::viewport::NavMode::Orbit) } else { None });
|
||||
}
|
||||
}
|
||||
let log = h.app.session.log.len();
|
||||
h.step(&json!({"click":{"handle":"nav:slot:visual_style"}})).unwrap();
|
||||
h.step(&json!({"click":{"handle":"nav:style:shaded"}})).unwrap();
|
||||
let label = solidcraft_engine::find_command("view.visual_style").unwrap().label;
|
||||
let echo = crate::i18n::Locale::for_language(&h.app.preferences.language).format("ui.command_done", &[("command", label)]);
|
||||
assert!(h.app.session.log.iter().skip(log).any(|line| line == &echo));
|
||||
assert_eq!(h.app.ui.visual_style, 1);
|
||||
assert_eq!(h.app.session.undo.len(), undo);
|
||||
}
|
||||
@@ -310,3 +315,89 @@ fn navigation_bar_display_menu_runs_grid_and_shadow_commands() {
|
||||
assert!(h.app.session.log.iter().skip(log).any(|line| line == &echo), "{id} was not run");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_bar_toggle_slots_apply_commands_and_projection_compatibility() {
|
||||
let mut h = Harness::new();
|
||||
moved_block(&mut h);
|
||||
h.call("ui.prefs", json!({"navigation_bar":{"slots":["grid","ground_shadow","ambient_occlusion","projection"]}}));
|
||||
let design = h.app.session.doc.to_json();
|
||||
let undo = h.app.session.undo.len();
|
||||
for slot in ["grid", "ground_shadow", "ambient_occlusion", "projection"] {
|
||||
let value = |app: &crate::SolveApp| match slot {
|
||||
"grid" => app.ui.show_grid,
|
||||
"ground_shadow" => app.ui.ground_shadow,
|
||||
"ambient_occlusion" => app.preferences.ambient_occlusion,
|
||||
_ => app.ui.perspective,
|
||||
};
|
||||
let before = value(&h.app);
|
||||
let log = h.app.session.log.len();
|
||||
h.step(&json!({"click":{"handle":format!("nav:slot:{slot}")}})).unwrap();
|
||||
assert_eq!(value(&h.app), !before, "{slot}");
|
||||
if slot != "projection" {
|
||||
let command = solidcraft_engine::find_command(&format!("view.{slot}")).unwrap();
|
||||
let echo = crate::i18n::Locale::for_language(&h.app.preferences.language).format("ui.command_done", &[("command", command.label)]);
|
||||
assert!(h.app.session.log.iter().skip(log).any(|line| line == &echo), "{slot}");
|
||||
}
|
||||
}
|
||||
assert!(h.app.dialog.is_none() && h.app.tool.is_none());
|
||||
assert_eq!(h.app.session.doc.to_json(), design);
|
||||
assert_eq!(h.app.session.undo.len(), undo);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_bar_tool_radio_group_and_overflow_execute_in_list_order() {
|
||||
use crate::viewport::NavMode;
|
||||
let mut h = Harness::new();
|
||||
moved_block(&mut h);
|
||||
h.call("ui.prefs", json!({"navigation_bar":{"slots":["zoom","fit","pan","separator","orbit"]}}));
|
||||
for (slot, mode) in [("pan", Some(NavMode::Pan)), ("zoom", Some(NavMode::Zoom)), ("orbit", Some(NavMode::Orbit)), ("orbit", None)] {
|
||||
h.step(&json!({"click":{"handle":format!("nav:slot:{slot}")}})).unwrap();
|
||||
assert_eq!(h.app.viewport.nav, mode);
|
||||
}
|
||||
h.call("ui.prefs", json!({"navigation_bar":{"slots":["pan","fit","home","visual_style","display","grid","ground_shadow","ambient_occlusion","projection","spin","orbit","zoom"]}}));
|
||||
h.app.ui.show_browser = false;
|
||||
h.app.ui.show_timeline = false;
|
||||
h.call("ui.resize", json!({"width":300,"height":600}));
|
||||
h.settle();
|
||||
let bar = crate::scenario::rect_of("nav:outer").unwrap();
|
||||
assert_eq!(bar, h.app.viewport.layout.as_ref().unwrap().navigation);
|
||||
let metrics = crate::ui_kit::NavigationMetrics::for_size(crate::navigation_bar::Size::Regular);
|
||||
assert_eq!(h.app.preferences.navigation_bar.size, crate::navigation_bar::Size::Regular);
|
||||
assert_eq!(bar.height(), metrics.height());
|
||||
let more = crate::scenario::rect_of("nav:more").unwrap();
|
||||
assert_eq!(more.size(), egui::vec2(metrics.button, metrics.button));
|
||||
let visible: Vec<_> = crate::scenario::handles("nav:slot:").into_iter().map(|(id, _)| id).collect();
|
||||
assert!(!visible.is_empty() && visible.len() < h.app.preferences.navigation_bar.slots.len());
|
||||
assert_eq!(visible, h.app.preferences.navigation_bar.slots.iter().take(visible.len()).map(|id| format!("nav:slot:{id}")).collect::<Vec<_>>());
|
||||
for handle in &visible {
|
||||
let slot = crate::scenario::rect_of(handle).unwrap();
|
||||
assert_eq!(slot.center().y, more.center().y, "one row: {handle}");
|
||||
assert_eq!(slot.height(), metrics.button);
|
||||
}
|
||||
assert!(!visible.iter().any(|handle| handle == "nav:slot:zoom"), "the final slot folds into More");
|
||||
h.step(&json!({"click":{"handle":"nav:more"}})).unwrap();
|
||||
let all: Vec<_> = crate::scenario::handles("nav:slot:").into_iter().map(|(id, _)| id).collect();
|
||||
assert_eq!(all, h.app.preferences.navigation_bar.slots.iter().map(|id| format!("nav:slot:{id}")).collect::<Vec<_>>());
|
||||
assert!(all.len() > visible.len());
|
||||
h.step(&json!({"click":{"handle":"nav:slot:zoom"}})).unwrap();
|
||||
assert_eq!(h.app.viewport.nav, Some(NavMode::Zoom));
|
||||
assert!(crate::scenario::rect_of("nav:slot:zoom").is_none(), "choosing an action closes More");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_bar_look_at_keeps_the_active_sketch_fallback() {
|
||||
let mut h = Harness::new();
|
||||
h.app.preferences.look_at_anim = false;
|
||||
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
|
||||
h.app.cam.set_view(StandardView::Iso);
|
||||
h.settle();
|
||||
let sketch = h.app.session.active_sketch;
|
||||
let design = h.app.session.doc.to_json();
|
||||
let undo = h.app.session.undo.len();
|
||||
h.step(&json!({"click":{"handle":"nav:slot:look_at"}})).unwrap();
|
||||
assert!(h.app.cam.back().dist(Vec3::Z) < 1e-6);
|
||||
assert_eq!(h.app.session.active_sketch, sketch);
|
||||
assert_eq!(h.app.session.doc.to_json(), design);
|
||||
assert_eq!(h.app.session.undo.len(), undo);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//! The 3D viewport: navigation, GPU (or CPU fallback) rendering, picking, overlays, the axis
|
||||
//! view and the navigation bar.
|
||||
|
||||
use crate::fonts::RichTextExt as _;
|
||||
use crate::ui_kit::{Container, Surface};
|
||||
use egui::{Align2, Color32, FontId, Pos2, Rect, Sense, Shape, Stroke, pos2, vec2};
|
||||
use serde_json::json;
|
||||
@@ -3810,7 +3809,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
let t = Tokens::get();
|
||||
let rect = ui.max_rect();
|
||||
app.viewport.rect = Some(rect);
|
||||
refresh_layout(app, ui.ctx().pixels_per_point());
|
||||
refresh_layout(app, ui.ctx());
|
||||
let resp = ui.interact(rect, ui.id().with("viewport"), Sense::click_and_drag());
|
||||
let flat = crate::dialogs_sheet::flat_active(app);
|
||||
if !flat {
|
||||
@@ -4505,7 +4504,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
crate::sketch_dims::show(app, ui, &proj);
|
||||
crate::select_other::show(app, ui.ctx());
|
||||
axis_view(app, ui, rect);
|
||||
nav_bar(app, ui, rect);
|
||||
crate::navigation_bar_view::show(app, ui, rect);
|
||||
// The notices and the agent chip first, so the 3D mouse picture can keep clear of them.
|
||||
let toasts = transient_messages(app, ui, rect);
|
||||
if app.preferences.space_mouse_in_view
|
||||
@@ -5405,7 +5404,7 @@ pub(crate) fn scene_palette(dark: bool, mode: crate::theme::ColorVision) -> soli
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn refresh_layout(app: &mut SolveApp, scale: f32) {
|
||||
pub(crate) fn refresh_layout(app: &mut SolveApp, ctx: &egui::Context) {
|
||||
if let Some(rect) = app.viewport.rect {
|
||||
let docks = crate::shell::covered_rects(app);
|
||||
let mut content = crate::shell::content_rect(app, rect);
|
||||
@@ -5427,12 +5426,13 @@ pub(crate) fn refresh_layout(app: &mut SolveApp, scale: f32) {
|
||||
// OK and Cancel in the view's corner (#6709) take the top right; the axis view goes below.
|
||||
let corner = crate::view_confirm::size(app);
|
||||
let style = app.preferences.navigator_style;
|
||||
let show_bar = app.ui.show_navigation_bar;
|
||||
app.viewport.layout = Some(if crate::render_workspace::active(app) {
|
||||
crate::viewport_layout::Layout::product(rect, content, &docks, scale, style, corner, show_bar)
|
||||
let navigation = if app.ui.show_navigation_bar { crate::navigation_bar_view::measured(app, ctx, content).rect } else { Rect::NOTHING };
|
||||
crate::viewport_layout::Layout::product(rect, content, &docks, ctx.pixels_per_point(), style, corner, navigation)
|
||||
} else {
|
||||
let content = if app.ui.layout == crate::shell::LayoutMode::Docked { rect } else { content };
|
||||
crate::viewport_layout::Layout::with_content(rect, content, &docks, scale, style, corner, show_bar)
|
||||
let navigation = if app.ui.show_navigation_bar { crate::navigation_bar_view::measured(app, ctx, content).rect } else { Rect::NOTHING };
|
||||
crate::viewport_layout::Layout::with_content(rect, content, &docks, ctx.pixels_per_point(), style, corner, navigation)
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -5604,7 +5604,6 @@ pub(crate) fn nearest_quarter_turn(yaw: f64) -> f64 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Navigation bar (bottom centre).
|
||||
/// Turn the view to face the selected planar face or plane, else the active sketch; asked again
|
||||
/// while it already faces it, from the other side (#1886).
|
||||
pub fn look_at_selection(app: &mut SolveApp) {
|
||||
@@ -5615,188 +5614,6 @@ pub fn look_at_selection(app: &mut SolveApp) {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn nav_bar(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
if !app.ui.show_navigation_bar || app.viewport.layout.as_ref().is_some_and(|l| !l.navigation.is_positive()) {
|
||||
return;
|
||||
}
|
||||
let t = Tokens::get();
|
||||
let items: [(&str, &str); 10] = [
|
||||
(
|
||||
"orbit",
|
||||
if app.preferences.nav == crate::prefs::TOUCHPAD_NAV {
|
||||
crate::i18n::tr("nav.touchpad.orbit")
|
||||
} else if app.preferences.nav == crate::prefs::OPENSCAD_NAV {
|
||||
"Orbit (left drag on empty space; Shift+left drag box-selects)"
|
||||
} else if app.preferences.free_orbit {
|
||||
"Orbit (right drag)"
|
||||
} else {
|
||||
"Orbit (right drag; hold Shift to snap)"
|
||||
},
|
||||
),
|
||||
("spin", "Continuous orbit (stops at the next click or key)"),
|
||||
("pan", if app.preferences.nav == crate::prefs::TOUCHPAD_NAV { crate::i18n::tr("nav.touchpad.pan") } else { "Pan (drag; or middle drag)" }),
|
||||
("zoom", if app.preferences.nav == crate::prefs::TOUCHPAD_NAV { crate::i18n::tr("nav.touchpad.zoom") } else { "Zoom (drag; or wheel)" }),
|
||||
("fit", "Fit (F6)"),
|
||||
("lookat", "Look At the selected face or plane (or the active sketch) (Ctrl+8)"),
|
||||
("home", "Home view"),
|
||||
("perspective", "Perspective / orthographic"),
|
||||
("style", "Visual style: shaded with edges, shaded, wireframe, shaded with hidden edges"),
|
||||
("settings", "View settings: grid, ground shadow, ambient occlusion, agent cursor"),
|
||||
];
|
||||
let menu_id = ui.id().with("nav_view_menu");
|
||||
let mut menu_open = ui.data(|d| d.get_temp::<bool>(menu_id)).unwrap_or(false);
|
||||
let w = items.len() as f32 * 30.0 + 10.0;
|
||||
let bar = app.viewport.layout.as_ref().map(|l| l.navigation).unwrap_or_else(|| {
|
||||
let available = crate::shell::bottom_overlay_rect(app, rect);
|
||||
Rect::from_center_size(pos2(available.center().x, available.bottom() - 22.0), vec2(w, 30.0))
|
||||
});
|
||||
crate::scenario::publish_rect("nav:outer", bar);
|
||||
let active = ui.rect_contains_pointer(bar)
|
||||
|| ui.rect_contains_pointer(axis_rect(app, rect))
|
||||
|| app.viewport.axis_drag.is_some()
|
||||
|| app.viewport.nav.is_some()
|
||||
|| app.viewport.modifier_nav.is_some()
|
||||
|| app.viewport.spin
|
||||
|| menu_open;
|
||||
let mut painter = ui.painter_at(rect);
|
||||
painter.set_opacity(if active || app.preferences.navigator_style == crate::prefs::NavigatorStyle::Axes { 1.0 } else { 0.45 });
|
||||
let surface = Container::new(ui.ctx(), Surface::Navigation).frame(ui.ctx(), t.overlay, crate::frame::Side::Left);
|
||||
Container::paint_frame(&painter, surface, bar.shrink(surface.stroke.width));
|
||||
let columns = ((bar.width() - 10.0) / 30.0).round().clamp(1.0, 10.0) as usize;
|
||||
for (i, (icon, tip)) in items.iter().enumerate() {
|
||||
let br = Rect::from_min_size(
|
||||
pos2(bar.left() + 5.0 + (i % columns) as f32 * 30.0, bar.top() + 2.0 + (i / columns) as f32 * 30.0),
|
||||
vec2(26.0, 26.0),
|
||||
);
|
||||
let enabled = *icon != "perspective" || app.session.active_sketch.is_none();
|
||||
let mut button_ui = ui.new_child(egui::UiBuilder::new().max_rect(br));
|
||||
if !enabled {
|
||||
button_ui.disable();
|
||||
}
|
||||
let resp = button_ui.interact(br, ui.id().with(("nav", *icon)), Sense::click());
|
||||
let active = match *icon {
|
||||
"orbit" => app.viewport.nav == Some(NavMode::Orbit),
|
||||
"pan" => app.viewport.nav == Some(NavMode::Pan),
|
||||
"zoom" => app.viewport.nav == Some(NavMode::Zoom),
|
||||
"perspective" => app.perspective_view(),
|
||||
"settings" => menu_open,
|
||||
"spin" => app.viewport.spin,
|
||||
_ => false,
|
||||
};
|
||||
if active || resp.hovered() {
|
||||
painter.rect_filled(br, t.radius_sm, if active { t.accent_soft } else { t.hover });
|
||||
}
|
||||
let mut icon_painter = painter.clone();
|
||||
if !enabled {
|
||||
icon_painter.multiply_opacity(ui.visuals().disabled_alpha);
|
||||
}
|
||||
icons::paint_icon(&icon_painter, br.shrink(4.0), icon, f32::from(t.icon.a()) / 255.0);
|
||||
let resp = resp.on_hover_text(*tip);
|
||||
let resp = if !enabled { resp.on_disabled_hover_text(app.tr("nav.perspective.sketch")) } else { resp };
|
||||
if resp.clicked() {
|
||||
match *icon {
|
||||
"orbit" | "pan" | "zoom" => {
|
||||
let selected = matches!(
|
||||
(*icon, app.viewport.nav),
|
||||
("orbit", Some(NavMode::Orbit)) | ("pan", Some(NavMode::Pan)) | ("zoom", Some(NavMode::Zoom))
|
||||
);
|
||||
let _ = app.run("view.tool", json!({"tool": if selected { "none" } else { *icon }}));
|
||||
}
|
||||
"fit" => {
|
||||
let _ = app.run("view.fit", json!({}));
|
||||
}
|
||||
"spin" => {
|
||||
let _ = app.run("view.spin", json!({}));
|
||||
}
|
||||
"home" => {
|
||||
let _ = app.run("view.home", json!({}));
|
||||
}
|
||||
"lookat" => look_at_selection(app),
|
||||
"style" => {
|
||||
let style = match app.ui.visual_style {
|
||||
0 => "shaded",
|
||||
1 => "wireframe",
|
||||
2 => "shaded_with_hidden_edges",
|
||||
_ => "shaded_with_edges",
|
||||
};
|
||||
let _ = app.run("view.visual_style", json!({"style": style}));
|
||||
}
|
||||
"perspective" => app.ui.perspective = !app.ui.perspective,
|
||||
_ => menu_open = !menu_open,
|
||||
}
|
||||
}
|
||||
if *icon == "settings" {
|
||||
crate::scenario::publish_handle("nav:view", br.center());
|
||||
if menu_open {
|
||||
menu_open = view_menu(app, ui, br);
|
||||
}
|
||||
}
|
||||
}
|
||||
ui.data_mut(|d| d.insert_temp(menu_id, menu_open));
|
||||
}
|
||||
|
||||
/// The View settings above the navigation bar's last button: grid, ground shadow, the tool at
|
||||
/// the cursor and the agent cursor (#35). False once it should close (a click outside it).
|
||||
fn view_menu(app: &mut SolveApp, ui: &mut egui::Ui, button: Rect) -> bool {
|
||||
let t = crate::theme::Tokens::get();
|
||||
// A preset dropdown extends beyond this menu; let it consume its own clicks.
|
||||
let child_popup_open = egui::Popup::is_any_open(ui.ctx());
|
||||
let area = Container::new(ui.ctx(), Surface::Popup)
|
||||
.area(egui::Id::new("sc_view_menu"))
|
||||
.order(egui::Order::Foreground)
|
||||
.pivot(Align2::RIGHT_BOTTOM)
|
||||
.fixed_pos(button.right_top() - vec2(0.0, 6.0));
|
||||
let r = area.show(ui.ctx(), |ui| {
|
||||
Container::popup_frame(ui.style()).show(ui, |ui| {
|
||||
ui.set_width(220.0);
|
||||
ui.label(egui::RichText::new(crate::i18n::tr_label("VIEW")).semibold().color(crate::theme::Tokens::get().text).size(t.font_caption));
|
||||
ui.label(app.tr("ui.graphics_preset"));
|
||||
crate::prefs::graphics_preset_selector(app, ui);
|
||||
ui.separator();
|
||||
let mut grid = app.ui.show_grid;
|
||||
if crate::ui_kit::checkbox(ui, crate::i18n::tr_label("Grid"), &mut grid).changed() {
|
||||
let _ = app.run("view.grid", json!({"on": grid}));
|
||||
}
|
||||
let mut shadow = app.ui.ground_shadow;
|
||||
if crate::ui_kit::checkbox(ui, crate::i18n::tr_label("Ground shadow"), &mut shadow).changed() {
|
||||
let _ = app.run("view.ground_shadow", json!({"on": shadow}));
|
||||
}
|
||||
let auto_ortho =
|
||||
crate::ui_kit::checkbox(ui, crate::i18n::tr_label("Perspective while orbiting, ortho on faces"), &mut app.ui.auto_ortho_faces);
|
||||
crate::scenario::publish_handle("view:auto_ortho_faces", auto_ortho.rect.center());
|
||||
crate::prefs::ambient_occlusion_checkbox(app, ui, "Ambient occlusion");
|
||||
let tool = crate::ui_kit::checkbox(ui, crate::i18n::tr_label("Show tool at cursor"), &mut app.ui.tool_cursor);
|
||||
crate::scenario::publish_handle("view:tool_cursor", tool.rect.center());
|
||||
ui.separator();
|
||||
let s = &mut app.ui.agent_cursor;
|
||||
let show = crate::ui_kit::checkbox(ui, crate::i18n::tr_label("Show Agent Cursor"), &mut s.show);
|
||||
crate::scenario::publish_handle("view:agent_cursor", show.rect.center());
|
||||
ui.add_enabled_ui(s.show, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(crate::i18n::tr_label("Speed"));
|
||||
crate::agent_cursor::speed_slider(ui, &mut s.speed);
|
||||
});
|
||||
crate::ui_kit::checkbox(ui, crate::i18n::tr_label("Follow camera (Look At sketches)"), &mut s.follow_camera);
|
||||
});
|
||||
// The agent chat panel, once the chat is turned on in Preferences.
|
||||
if crate::agent_chat::shown(app) {
|
||||
ui.separator();
|
||||
let mut open = app.agent_chat.open;
|
||||
let r = crate::ui_kit::checkbox(ui, &crate::agent_chat::panel_tip(), &mut open);
|
||||
crate::scenario::publish_handle("view:agent_chat", r.rect.center());
|
||||
if r.changed() {
|
||||
app.agent_chat.open = open;
|
||||
app.preferences.agent_chat_minimized &= !open;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
let clicked_out = !child_popup_open
|
||||
&& ui.input(|i| i.pointer.any_pressed())
|
||||
&& ui.input(|i| i.pointer.interact_pos()).is_some_and(|p| !r.response.rect.contains(p) && !button.contains(p));
|
||||
!clicked_out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -10598,11 +10415,10 @@ mod grid_plane_tests {
|
||||
for perspective in [false, true] {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.call("ui.set", json!({"layout":mode,"perspective":perspective}));
|
||||
h.app.preferences.navigation_bar.slots = vec!["projection".into()];
|
||||
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
|
||||
h.settle();
|
||||
let nav = crate::scenario::rect_of("nav:outer").unwrap();
|
||||
let button = pos2(nav.left() + 5.0 + 7.0 * 30.0 + 13.0, nav.top() + 15.0);
|
||||
h.call("ui.click", json!({"x":button.x,"y":button.y}));
|
||||
crate::test_support::click(&mut h, "nav:slot:projection");
|
||||
assert_eq!(h.app.ui.perspective, perspective, "a sketch's disabled control must preserve the normal view preference");
|
||||
let rect = h.app.viewport.rect.unwrap();
|
||||
assert_eq!(projection(&h.app, rect).cam.fov, 0.0);
|
||||
@@ -10610,7 +10426,7 @@ mod grid_plane_tests {
|
||||
h.app.finish_sketch();
|
||||
h.settle();
|
||||
assert_eq!(h.app.perspective_view(), perspective, "finishing restores the original projection");
|
||||
h.call("ui.click", json!({"x":button.x,"y":button.y}));
|
||||
crate::test_support::click(&mut h, "nav:slot:projection");
|
||||
assert_eq!(h.app.perspective_view(), !perspective, "the toggle works again outside sketch editing");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,14 +50,9 @@ pub(crate) fn free_rect(view: Rect, obstacles: &[Rect]) -> Rect {
|
||||
}
|
||||
|
||||
impl Layout {
|
||||
/// The whole viewport as content, without the OK and Cancel pair.
|
||||
#[cfg(test)]
|
||||
pub fn new(viewport: Rect, docks: &[Rect], scale: f32, style: crate::prefs::NavigatorStyle, show_navigation_bar: bool) -> Self {
|
||||
Self::with_content(viewport, viewport, docks, scale, style, egui::Vec2::ZERO, show_navigation_bar)
|
||||
}
|
||||
|
||||
/// `corner` is the size of the OK and Cancel pair (#6709; zero while it is not shown): it is
|
||||
/// held in the top right corner of the content, and the axis view moves down below it.
|
||||
/// `navigation` is the measured rectangle of the navigation bar (nothing while it is hidden).
|
||||
pub fn with_content(
|
||||
viewport: Rect,
|
||||
content: Rect,
|
||||
@@ -65,9 +60,9 @@ impl Layout {
|
||||
scale: f32,
|
||||
style: crate::prefs::NavigatorStyle,
|
||||
corner: egui::Vec2,
|
||||
show_navigation_bar: bool,
|
||||
navigation: Rect,
|
||||
) -> Self {
|
||||
Self::build(viewport, content, docks, scale, style, corner, show_navigation_bar, false)
|
||||
Self::build(viewport, content, docks, scale, style, corner, navigation, false)
|
||||
}
|
||||
|
||||
/// Render fits stay between the docked panels, including beneath a short Browser card.
|
||||
@@ -78,9 +73,9 @@ impl Layout {
|
||||
scale: f32,
|
||||
style: crate::prefs::NavigatorStyle,
|
||||
corner: egui::Vec2,
|
||||
show_navigation_bar: bool,
|
||||
navigation: Rect,
|
||||
) -> Self {
|
||||
Self::build(viewport, content, docks, scale, style, corner, show_navigation_bar, true)
|
||||
Self::build(viewport, content, docks, scale, style, corner, navigation, true)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
@@ -91,7 +86,7 @@ impl Layout {
|
||||
scale: f32,
|
||||
style: crate::prefs::NavigatorStyle,
|
||||
corner: egui::Vec2,
|
||||
show_navigation_bar: bool,
|
||||
navigation: Rect,
|
||||
fit_in_content: bool,
|
||||
) -> Self {
|
||||
let scale = if scale.is_finite() && scale > 0.0 { scale } else { 1.0 };
|
||||
@@ -116,14 +111,6 @@ impl Layout {
|
||||
} else {
|
||||
Rect::NOTHING
|
||||
};
|
||||
let nav_space = content;
|
||||
let columns = ((nav_space.width() - 10.0) / 30.0).floor().clamp(1.0, 10.0);
|
||||
let nav_height = (10.0 / columns).ceil() * 30.0;
|
||||
let navigation = if show_navigation_bar && nav_space.width() >= columns * 30.0 + 10.0 && nav_space.height() >= nav_height + 7.0 {
|
||||
Rect::from_center_size(pos2(nav_space.center().x, nav_space.bottom() - nav_height * 0.5 - 7.0), vec2(columns * 30.0 + 10.0, nav_height))
|
||||
} else {
|
||||
Rect::NOTHING
|
||||
};
|
||||
// On tiny viewports keep the bottom controls usable rather than overlapping them.
|
||||
// This decision depends only on viewport size, never on an overlay.
|
||||
if axis_view.intersect(navigation).is_positive() {
|
||||
|
||||
@@ -4,12 +4,25 @@ use crate::viewport::NavMode;
|
||||
use serde_json::json;
|
||||
use solidcraft_engine::render::StandardView;
|
||||
|
||||
fn bar_rect(canvas: Rect) -> Rect {
|
||||
crate::navigation_bar_view::measure(canvas, &Default::default(), crate::navigation::NavCaps::MODEL, |_| 0.0).rect
|
||||
}
|
||||
|
||||
fn layout(viewport: Rect, docks: &[Rect], scale: f32, style: crate::prefs::NavigatorStyle, visible: bool) -> Layout {
|
||||
let navigation = if visible {
|
||||
crate::navigation_bar_view::measure(viewport, &Default::default(), crate::navigation::NavCaps::MODEL, |_| 0.0).rect
|
||||
} else {
|
||||
Rect::NOTHING
|
||||
};
|
||||
Layout::with_content(viewport, viewport, docks, scale, style, egui::Vec2::ZERO, navigation)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thin_rotated_bounds_fit_using_the_original_full_projection() {
|
||||
for (width, height, scale) in [(1400.0, 900.0, 1.0), (700.0, 450.0, 2.0), (700.0, 360.0, 2.0), (900.0, 720.0, 1.0)] {
|
||||
let vp = Rect::from_min_max(pos2(250.0, crate::toolbar::APP_BAR_HEIGHT + crate::toolbar::RIBBON_HEIGHT), pos2(width, height - 30.0));
|
||||
let dock = Rect::from_min_max(pos2(width - 205.0, vp.top()), vp.max);
|
||||
let layout = Layout::new(vp, &[dock], scale, crate::prefs::NavigatorStyle::Axes, true);
|
||||
let layout = layout(vp, &[dock], scale, crate::prefs::NavigatorStyle::Axes, true);
|
||||
assert!(layout.drawable.width() >= 80.0 && layout.drawable.height() >= 30.0, "{layout:?}");
|
||||
assert!(layout.axis_view.is_positive() && layout.navigation.is_positive(), "{layout:?}");
|
||||
assert!(!layout.drawable.intersect(dock).is_positive());
|
||||
@@ -97,12 +110,12 @@ fn measured_palette_fit_exposes_endpoints_and_layout_changes_preserve_manual_vie
|
||||
#[test]
|
||||
fn hostile_or_empty_fit_keeps_the_existing_camera_valid() {
|
||||
let cam = Camera::default();
|
||||
let layout = Layout::new(Rect::from_min_size(pos2(0.0, 0.0), vec2(800.0, 600.0)), &[], 1.0, crate::prefs::NavigatorStyle::Axes, true);
|
||||
assert!(fit_bounds(cam, &Aabb3::EMPTY, &layout, false).is_none());
|
||||
let measured = layout(Rect::from_min_size(pos2(0.0, 0.0), vec2(800.0, 600.0)), &[], 1.0, crate::prefs::NavigatorStyle::Axes, true);
|
||||
assert!(fit_bounds(cam, &Aabb3::EMPTY, &measured, false).is_none());
|
||||
let bad = Aabb3 { min: Vec3::new(f64::NAN, 0.0, 0.0), max: Vec3::new(1.0, 1.0, 1.0) };
|
||||
assert!(fit_bounds(cam, &bad, &layout, true).is_none());
|
||||
assert!(fit_bounds(cam, &bad, &measured, true).is_none());
|
||||
let mut app = crate::SolveApp::new(Default::default(), Default::default());
|
||||
let tiny = Layout::new(Rect::from_min_size(pos2(0.0, 0.0), vec2(5.0, 5.0)), &[], 1.0, crate::prefs::NavigatorStyle::Axes, true);
|
||||
let tiny = layout(Rect::from_min_size(pos2(0.0, 0.0), vec2(5.0, 5.0)), &[], 1.0, crate::prefs::NavigatorStyle::Axes, true);
|
||||
app.viewport.layout = Some(tiny);
|
||||
let bounds = Aabb3 { min: Vec3::ZERO, max: Vec3::new(20.0, 1.0, 1.0) };
|
||||
assert_eq!(app.fitted_bounds(cam, &bounds), cam);
|
||||
@@ -253,7 +266,7 @@ fn immediate_standard_view_cancels_fit_before_the_measured_frame() {
|
||||
fn navigation_anchors_ignore_positioned_resized_and_covering_dialogs() {
|
||||
for (width, height, scale) in [(1400.0, 900.0, 1.0), (700.0, 450.0, 2.0), (700.0, 360.0, 2.0)] {
|
||||
let vp = Rect::from_min_max(pos2(250.0, crate::toolbar::APP_BAR_HEIGHT + crate::toolbar::RIBBON_HEIGHT), pos2(width, height - 30.0));
|
||||
let baseline = Layout::new(vp, &[], scale, crate::prefs::NavigatorStyle::Axes, true);
|
||||
let baseline = layout(vp, &[], scale, crate::prefs::NavigatorStyle::Axes, true);
|
||||
assert!(baseline.axis_view.is_positive() && baseline.navigation.is_positive());
|
||||
assert_eq!(baseline.axis_view.right_top(), vp.right_top());
|
||||
assert_eq!(baseline.navigation.center().x, vp.center().x);
|
||||
@@ -265,7 +278,7 @@ fn navigation_anchors_ignore_positioned_resized_and_covering_dialogs() {
|
||||
vec![vp],
|
||||
];
|
||||
for docks in cases {
|
||||
let measured = Layout::new(vp, &docks, scale, crate::prefs::NavigatorStyle::Axes, true);
|
||||
let measured = layout(vp, &docks, scale, crate::prefs::NavigatorStyle::Axes, true);
|
||||
assert_eq!(measured.axis_view, baseline.axis_view, "{docks:?}");
|
||||
assert_eq!(measured.navigation, baseline.navigation, "{docks:?}");
|
||||
assert!(vp.contains_rect(measured.axis_view));
|
||||
@@ -294,7 +307,7 @@ fn opening_different_command_dialogs_keeps_published_navigation_positions() {
|
||||
assert_eq!(crate::scenario::rect_of("axis_view:outer").unwrap(), axis, "{command}");
|
||||
assert_eq!(crate::scenario::rect_of("nav:outer").unwrap(), nav, "{command}");
|
||||
assert_eq!(h.app.cam, camera);
|
||||
let pan = pos2(nav.left() + 5.0 + 2.0 * 30.0 + 13.0, nav.top() + 15.0);
|
||||
let pan = crate::scenario::handle_at("nav:slot:pan").unwrap();
|
||||
assert!(!h.app.viewport.dialog_rect.unwrap().contains(pan));
|
||||
h.app.viewport.nav = None;
|
||||
h.call("ui.click", json!({"x":pan.x,"y":pan.y}));
|
||||
@@ -319,8 +332,9 @@ fn the_corner_pair_takes_the_top_right_and_the_view_navigator_moves_below_it() {
|
||||
for (width, height) in [(1400.0, 900.0), (700.0, 450.0), (310.0, 240.0), (160.0, 160.0), (90.0, 50.0)] {
|
||||
let vp = Rect::from_min_size(pos2(20.0, 30.0), vec2(width, height));
|
||||
let content = Rect::from_min_max(pos2(vp.left() + width * 0.25, vp.top()), vp.max);
|
||||
let plain = Layout::with_content(vp, content, &[], 1.0, style, egui::Vec2::ZERO, true);
|
||||
let held = Layout::with_content(vp, content, &[], 1.0, style, corner, true);
|
||||
let bar = bar_rect(content);
|
||||
let plain = Layout::with_content(vp, content, &[], 1.0, style, egui::Vec2::ZERO, bar);
|
||||
let held = Layout::with_content(vp, content, &[], 1.0, style, corner, bar);
|
||||
assert!(!plain.confirm.is_positive(), "{plain:?}");
|
||||
assert_eq!(held.navigation, plain.navigation, "the navigation bar never moves");
|
||||
assert!(!held.axis_view.intersect(held.navigation).is_positive(), "{held:?}");
|
||||
@@ -346,7 +360,7 @@ fn the_corner_pair_takes_the_top_right_and_the_view_navigator_moves_below_it() {
|
||||
1.0,
|
||||
crate::prefs::NavigatorStyle::Axes,
|
||||
corner,
|
||||
true,
|
||||
bar_rect(Rect::from_min_size(pos2(0.0, 0.0), vec2(1400.0, 900.0))),
|
||||
);
|
||||
assert!(roomy.confirm.is_positive() && roomy.axis_view.is_positive(), "{roomy:?}");
|
||||
}
|
||||
@@ -390,8 +404,8 @@ fn tiny_viewports_never_overlap_navigation_and_axis_view() {
|
||||
for width in [39.0, 40.0, 90.0, 120.0, 160.0, 310.0] {
|
||||
for height in [30.0, 80.0, 130.0, 160.0, 240.0] {
|
||||
let vp = Rect::from_min_size(pos2(20.0, 30.0), vec2(width, height));
|
||||
let clear = Layout::new(vp, &[], 1.0, crate::prefs::NavigatorStyle::Axes, true);
|
||||
let covered = Layout::new(vp, &[vp], 1.0, crate::prefs::NavigatorStyle::Axes, true);
|
||||
let clear = layout(vp, &[], 1.0, crate::prefs::NavigatorStyle::Axes, true);
|
||||
let covered = layout(vp, &[vp], 1.0, crate::prefs::NavigatorStyle::Axes, true);
|
||||
assert_eq!(clear.axis_view, covered.axis_view);
|
||||
assert_eq!(clear.navigation, covered.navigation);
|
||||
assert!(!clear.axis_view.intersect(clear.navigation).is_positive());
|
||||
@@ -431,13 +445,12 @@ fn floating_fit_uses_the_measured_browser_and_history_cards_at_each_size() {
|
||||
}
|
||||
|
||||
fn click_nav_mode(h: &mut Harness, mode: NavMode) {
|
||||
let nav = crate::scenario::rect_of("nav:outer").unwrap();
|
||||
let column = match mode {
|
||||
NavMode::Orbit => 0,
|
||||
NavMode::Pan => 2,
|
||||
NavMode::Zoom => 3,
|
||||
let slot = match mode {
|
||||
NavMode::Orbit => "orbit",
|
||||
NavMode::Pan => "pan",
|
||||
NavMode::Zoom => "zoom",
|
||||
};
|
||||
let p = pos2(nav.left() + 5.0 + column as f32 * 30.0 + 13.0, nav.top() + 15.0);
|
||||
let p = crate::scenario::handle_at(&format!("nav:slot:{slot}")).unwrap();
|
||||
h.call("ui.click", json!({"x":p.x,"y":p.y}));
|
||||
}
|
||||
|
||||
|
||||
@@ -171,6 +171,42 @@ fn requested_menu_icons_have_artwork_and_match_manifest() {
|
||||
collect(&mut h, "initial browser and timeline", &mut requested);
|
||||
assistant(&mut h, &mut requested);
|
||||
|
||||
let navigation = h.app.preferences.navigation_bar.clone();
|
||||
h.call("ui.prefs", json!({"navigation_bar":{"slots":["orbit","pan","zoom","spin","fit","look_at","home","visual_style","projection","display","grid","ground_shadow","ambient_occlusion"]}}));
|
||||
collect(&mut h, "navigation catalogue", &mut requested);
|
||||
let size = h.ctx.content_rect().size();
|
||||
h.call("ui.resize", json!({"width":500,"height":800}));
|
||||
h.frames(3);
|
||||
click(&mut h, "nav:more");
|
||||
h.frames(3);
|
||||
collect(&mut h, "navigation overflow", &mut requested);
|
||||
escape(&mut h);
|
||||
h.call("ui.resize", json!({"width":size.x,"height":size.y}));
|
||||
h.call("ui.prefs", json!({"navigation_bar":navigation}));
|
||||
h.frames(3);
|
||||
|
||||
for (handle, surface) in [("nav:slot:visual_style", "navigation visual styles"), ("nav:view", "navigation display")] {
|
||||
click(&mut h, handle);
|
||||
h.frames(3);
|
||||
collect(&mut h, surface, &mut requested);
|
||||
click(&mut h, handle);
|
||||
}
|
||||
|
||||
h.step(&json!({"click":{"handle":"nav:slot:pan"},"button":"right"})).unwrap();
|
||||
h.frames(3);
|
||||
collect(&mut h, "navigation context menu", &mut requested);
|
||||
escape(&mut h);
|
||||
h.call("ui.prefs", json!({"open":"Interface/Navigation bar"}));
|
||||
h.frames(20);
|
||||
collect(&mut h, "navigation editor and available tiles", &mut requested);
|
||||
click(&mut h, "prefs:navbar:slot:pan");
|
||||
h.step(&json!({"click":{"handle":"prefs:navbar:slot:pan"},"button":"right"})).unwrap();
|
||||
h.frames(3);
|
||||
collect(&mut h, "navigation editor slot menu", &mut requested);
|
||||
escape(&mut h);
|
||||
h.call("ui.prefs", json!({"button":"cancel"}));
|
||||
h.frames(3);
|
||||
|
||||
ribbon(&mut h, &mut requested);
|
||||
h.app.start("inspect.colored_components");
|
||||
h.frames(2);
|
||||
|
||||
@@ -390,6 +390,10 @@ completed drawings publish atomically. The browser still exports synchronously.
|
||||
top/bottom heading are preserved. Diagonals include 45-degree edge and isometric corner views.
|
||||
- Navigation bar overhaul (#6585): the viewport's Fit, Home, camera tools, Spin, visual style, Grid, Ground
|
||||
shadow and bar visibility are registered `view.*` commands, and Fit/Home follow the active canvas.
|
||||
- Navigation bar slots (#6585): stored order and appearance, command-driven controls, canvas availability and
|
||||
single-row overflow.
|
||||
- Navigation bar customisation (#6585): approved light/dark bar and settings geometry, live position preview,
|
||||
accessible reordering and per-menu display options.
|
||||
|
||||
## Known limitations
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ windows use the shared composition, including its header and fixed outer frame.
|
||||
| Search, completions, colour and library popovers | `shortcut_box`, kit fields/choice/colour/table | Anchored popup containers; editor focus and completion semantics retained |
|
||||
| Dimension values, canvas placement values, canvas feedback and History resize seam | `dim_view`, `sketch_dims`, `canvas`, `timeline_left` | Model/control-anchored overlays; retain their coordinates rather than becoming docks |
|
||||
| Status and loading/progress messages | `viewport`, `open_meshing` | Notification surfaces independent of layout |
|
||||
| Navigation bar | `viewport` | Shared navigation surface; shell still computes its available canvas bounds |
|
||||
| Navigation bar | `navigation_bar_view` | Measured single-row Navigation surface; upward Popup menus use kit list rows; shell supplies the free canvas bounds |
|
||||
| OK and Cancel in the view's corner | `view_confirm` | Navigation surface in its own area; the viewport layout reserves its corner and the shell counts it as covered |
|
||||
| Home, model viewport, Render canvas and native Assistant window content | `home`, `lib`, `agent_chat/panel` | Central content hosts, not floating workspace panels |
|
||||
| Loading input shield | `file_load` | Explicit input shield; must remain interactive while CAD input is blocked |
|
||||
|
||||
@@ -69,7 +69,9 @@ rules. Its compass is 110 pt; the 48 pt Shots strip clears the docks by 8 pt.
|
||||
padded content and optional 48 pt footer. `show_with_left` pins a left action beside
|
||||
the right-aligned buttons. `show_pages` accepts declarative `WindowPage` entries
|
||||
(icon, i18n label key, optional group heading, stable handle, scroll policy and draw callback).
|
||||
Its 188 pt soft page list has 32 pt icon/label rows, selected tint/ink and a divider.
|
||||
Its 188 pt soft page list (150 pt below a 700 pt window width) has 32 pt icon/label rows,
|
||||
selected tint/ink and a divider. Page windows use the navigation board's border/radius
|
||||
and the shared menu shadow; other windows retain their shared card surface.
|
||||
Preferences has nine grouped pages; legacy control-channel page names remain aliases.
|
||||
`page_rows` opts into a taller body while preserving viewport bounds.
|
||||
`actions`, `anchor`/`placed`, `cards`, `fields` and `keep_open_on_escape` retain
|
||||
@@ -154,6 +156,13 @@ table. Panel/Window/Confirm compositions also have dedicated geometry and intera
|
||||
| `assistant_entry`, `AssistantEntryState` | Application-bar chat icon with quiet, ready, busy, auth, stopped and approval count marks; caller owns state and target | `app_bar`, `agent_ok/busy`, `warning/error`, `font_badge` |
|
||||
| actions: `button`, `Button` | Secondary action: `Normal`, `Small`, or `Enabled(bool)` | native sizing, form font/control tokens |
|
||||
| `primary_button` | Accent action outside a footer | `accent`, `on_accent`, form tokens |
|
||||
| navigation: `NavigationMetrics`, `navigation_surface`, `navigation_button`, `navigation_separator` | Shared live/editor navigation painter, button states, upward menu chevron and separator; approved board dimensions below | `dialog_body/border`, `form_ink/dim/primary`, `control_border`, `selected_bg`, `nav_hover/press` |
|
||||
| `ReorderPayload<T>`, `insertion_marker`, `drop_index` | Typed drag origin, insertion chrome and horizontal gap selection shared by the ribbon and navigation editor | `accent` |
|
||||
| `navigation_button_editable`, `navigation_edit_outline` | The live navigation button with drag interaction, selection outline and dashed hidden-slot chrome | Navigation control tokens, `border/accent` |
|
||||
| navigation_menu: `navigation_menu`, `NavigationMenuRow`, `navigation_context`, `navigation_tooltip` | Upward menus, checked rows, headings, separators and the delayed shortcut tooltip; context menus retain kit popup hosts and Container's shared elevation | `dialog_body/border/rule`, `form_ink/dim/primary`, `selected_bg`, `nav_hover/tip/tip_ink/tip_key_border` |
|
||||
| navigation_settings: `navigation_stage`, `navigation_tile`, `navigation_drag_ghost` | Custom preview stage, draggable slot tiles and drag feedback. Ordinary preferences reuse `settings_section`, `settings_form`, `row`, default `segmented`, `checkbox`, `button`, `divider` and text hints | `dialog_border`, `control_border`, `form_ink/dim`, `nav_field/hover/viewport` |
|
||||
| `settings_card` | Full-width settings detail group; uses Container chrome and preserves its width with empty or changing content | `dialog_footer`, `border`, `radius_md`, `space_12/10` |
|
||||
| `mirrored_icon_button_at` | Directional counterpart of an existing icon master, sharing icon-button presentation and accessible label | Shared icon-button tokens |
|
||||
| `icon_button_at` | Icon action inside a supplied rectangle | `form_icon_inset`, `text/dim`, icon palette |
|
||||
| `button_pair`, `PairButton` | Equal secondary actions, optional icons and selected state | `form_button_height`, control/selection/icon tokens |
|
||||
| `footer`, `Footer`, `Action`, `HeaderActions` | OK/Cancel with optional Apply, compute status or selected action; `HeaderActions` puts the same buttons in a header row | `form_footer/button_height`, `dialog_footer/rule`, `control_*`, `accent`, spacing |
|
||||
@@ -234,6 +243,76 @@ this whole-glyph treatment from ordinary accent selection and monochrome ink mas
|
||||
Radial icons follow the active tab (Sketch, Surface, Mesh, Form; other tabs use base blue)
|
||||
in both normal and hovered sectors; the hovered background retains its tab tint.
|
||||
|
||||
## Navigation board dimensions
|
||||
|
||||
`Navbar_Bar` / `Navbar_Settings` and their dark boards own this composition.
|
||||
`navigation_bar_view::paint_row` paints both callers; the editor supplies selection,
|
||||
canvas availability and drag interactions. Its stage publishes `prefs:navbar:stage`;
|
||||
`prefs:navbar:bar` exposes the positioned bar inside it. Existing `nav:*` and editor
|
||||
slot/tile/add/appearance targets retain their identities.
|
||||
|
||||
| Board specimen | Logical points / state | Authority |
|
||||
| --- | --- | --- |
|
||||
| Bar 1, 6 | Regular: 32 button, 18 icon, 7 button radius, 40 outer height, 10 bar radius. Compact: 26 / 16 / 6 / 34 / 9 | `NavigationMetrics::for_size`, `height` |
|
||||
| Bar 1 | Border 1, padding 3, gap 2, bottom offset 7; separator width 1 + two 4 margins, height 18 | `NAV_BORDER/PADDING/GAP/BOTTOM/SEPARATOR/SEPARATOR_HEIGHT` |
|
||||
| Bar 2 | Menu padding left 7 / right 6, gap 5, chevron 12; medium text 12.5 | `NAV_MENU_LEFT/RIGHT/GAP`, `NAV_CHEVRON/TEXT` |
|
||||
| Bar 3 | Hover / press and open / latched; focus outline 2 with offset 1 | `navigation_visual`, `navigation_fill`, `NAV_FOCUS_WIDTH/OFFSET`; `nav_hover`, `nav_press`, `selected_bg`, `form_primary` |
|
||||
| Bar 5 | Width 244, padding 5, radius 10; shared menu shadow (0,14), blur 36; row 30, radius 6, inset 8, icon 17, gap 9; heading 22, text 11, tracking .07em | `NAV_POPUP_*`, `NAV_MENU_*`, `NAV_ROW_GAP`, `NAV_HEADING_*`, `navigation_popup_frame`, `Container::menu_frame` |
|
||||
| Bar 6 | Left / Centre / Right, 12 edge inset | `Position`, `NAV_EDGE`; legacy bottom / bottom_left / bottom_right deserialize as centre / left / right |
|
||||
| Bar 7 | More button follows the selected size; popup width 200; value text drops before labels and overflow | `NavigationMetrics`, `NAV_MORE_WIDTH`, `navigation_bar_view::measure` |
|
||||
| Bar 8 | Idle fade 45%, hidden 0%, restored 100%; hide-mode fade in 120ms | `navigation_opacity`, `NAV_IDLE_OPACITY/FADE_SECONDS` |
|
||||
| Bar 9 | Tooltip delay 800ms, gap 6, padding (8,5), radius 6; 12 medium text, 11 mono key, 15 key line height | `NAV_TOOLTIP_DELAY/POPUP_GAP`, `navigation_tooltip`; `nav_tip/tip_ink/tip_key_border` |
|
||||
| Bar 10 | Render hides Look at and Visual style; flat canvases hide Orbit, Spin, Look at, Projection and Visual style, retaining Home and Display | `Slot::available`, `canvas_caps` |
|
||||
| Bar 11 | Context width 232; bar has Customise / Hide / Reset, slot has Remove | `NAV_CONTEXT_WIDTH`, `navigation_bar_view::context_menu` |
|
||||
| Settings 1, 8 | Stage height 58, radius 8, padding 12 inside its 1 border; position follows preference live | `NAV_STAGE_HEIGHT/RADIUS/INSET`, `editor_layout` |
|
||||
| Settings 1–3 | Standard settings section and full-width detail card; actions stay on one line, with name truncation before icon-only actions | `settings_section`, `settings_card`, `inspector_header_layout` |
|
||||
| Settings 4, 5 | Marker 2×24 radius 1; ghost 70%, dragged tile 55%, hidden slot 40% and dashed border | `insertion_marker_with_ink`, `NAV_MARKER_HEIGHT/GHOST_OPACITY/TILE_DRAG_OPACITY/HIDDEN_OPACITY` |
|
||||
| Settings 6 | Enabled Add buttons answer with “Remove a slot to add another.” at the 16-slot cap | Pure list operations in `navigation_bar.rs`; `warning` |
|
||||
| Settings 7 | Standard form label column, control height, segment typography and fills; kit dropdown fallback at narrow widths | `settings_form`, `row`, `segmented`, default `Segments` |
|
||||
| Settings controls | Standard checkbox, Normal buttons, icon buttons, divider and hints. Custom tile content height 30 + two 1 borders = 32 outer; Add 22 | `checkbox`, `button`, `icon_button_at`, `divider`, `Text::Hint`, `NAV_TILE_HEIGHT/ADD` |
|
||||
|
||||
The custom tiles use CSS content-box sizing. Their rendered outer height is
|
||||
32 points, including the two border pixels around their declared height of 30.
|
||||
Editor menu slots also include a transparent one-point border, unlike live menu
|
||||
buttons. Their geometry and icon padding include it while reusing the same painter.
|
||||
Ordinary choice rows use the app's standard segmented control and its narrow-width dropdown fallback.
|
||||
|
||||
Colours shared with the boards use `dialog_body` (window/popup), `dialog_footer`
|
||||
(inspector), `dialog_border`, `dialog_rule`, `control_border`, `form_ink`, `form_dim`
|
||||
and `selected_bg`. Additional `nav_*` roles above, plus `nav_field`,
|
||||
`nav_viewport` and `nav_dim`, have light/dark defaults in
|
||||
`assets/styles/ui/palettes.rs`. They are ordinary `solidcraft-theme/1` colour keys:
|
||||
import, export and palette cache identity all include them through `theme_files.rs`.
|
||||
Files omitting them retain their base palette, including older exported themes.
|
||||
Semantic selection/action ink reuses measured `form_primary`, and the slot-cap notice
|
||||
reuses measured `warning`; neither has a navigation-specific duplicate. The colour-vision
|
||||
groups measure them together against the dialog ground. Remaining navigation colours
|
||||
are neutral surfaces/ink, with explicit reasons in `NO_MEANING`. Popup elevation comes
|
||||
from `Container::menu_frame`, not a navigation-owned shadow: its (0,14) offset, 36 blur
|
||||
and app-bar colour at 18% replace the board's (0,4), 16 blur and 10%/30% shadow.
|
||||
|
||||
The default is Regular/Centre; saved Compact values stay Compact. `slots` remains
|
||||
a plain list of IDs; optional `slot_options: {"visual_style":{"shows":"icon_and_value"}}`
|
||||
stores menu presentation independently of global button labels. Missing Visual style
|
||||
options mean Icon only; Display has no current value and remains Icon only.
|
||||
|
||||
Board regression checks live in the existing test modules:
|
||||
|
||||
- `navigation_bar_tests.rs`: `navigation_board_metrics_and_state_colors_are_shared_in_both_themes`,
|
||||
`navigation_board_popup_width_includes_its_border_and_padding`,
|
||||
`navigation_board_position_aliases_migrate_and_editor_alignment_follows_position`,
|
||||
`navigation_board_drops_menu_value_text_before_folding_slots`.
|
||||
- `theme_files.rs`: `navigation_board_colours_are_themeable_and_roundtrip_on_both_bases`.
|
||||
- `prefs.rs`: `navigation_bar_preview_stage_follows_position_live`; the existing narrow-width
|
||||
regression also checks unelided text bounds at 1600, 880, 640, 600 and 480 points.
|
||||
The existing drag regression covers removal into empty stage space as well as outside the stage.
|
||||
- The existing pointer/state, shared-painter, context-menu and canvas-availability tests
|
||||
follow the board's changed states, editing borders, menu split and hidden slots.
|
||||
The tool-cursor regression uses its Navigation preference because Display no longer lists it.
|
||||
`tool_cursor.rs::navigation_preference_restores_tool_badge_on_cancel_and_defaults` covers
|
||||
the relocated setting's snapshot and page defaults.
|
||||
Runtime icon discovery visits More at narrow width, retaining Preferences page coverage.
|
||||
|
||||
## Extending and checking the kit
|
||||
|
||||
Add one implementation, document its tokens/options here, re-export it through
|
||||
@@ -589,6 +668,12 @@ callers continue to request semantic icon IDs and surface-specific monochrome in
|
||||
See [the shipped-theme colour audit](theme-colour-audit.md) for the schema,
|
||||
workspace assignments, accessibility rules and intentionally monochrome themes.
|
||||
|
||||
Preference page scrollers keep their content width separate from the scrollbar host's
|
||||
gutter extension. Child layout overflow contributes height only, so it cannot widen
|
||||
the window and leave earlier sections clipped at their previous right edge. The
|
||||
Navigation editor follows the board's composition and uses standard kit controls
|
||||
for ordinary settings, rather than a second control skin.
|
||||
|
||||
## Material previews and look chains
|
||||
|
||||
`sphere_thumbnail(ui, id, Sphere { color, kind, opacity }, size)` paints a lit
|
||||
|
||||