SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
macOS DMG: blueprint window with larger icons and a drag arrow (#5831)
Nathan Danec5e63b7871ba
diff --git a/ATTRIBUTION.md b/ATTRIBUTION.mdindex bc0b3616c1..36d7df0905 100644--- a/ATTRIBUTION.md+++ b/ATTRIBUTION.md@@ -174,6 +174,10 @@ Editable drawing code, native projects and shipped exports are collected under `| assets/platforms/linux/ai.storyteller.solidcraft.desktop | PhotoCraft / SolidCraft contributors | PhotoCraft packaging templates (https://github.com/storytold/photocraft), adapted for SolidCraft | Apache-2.0 || assets/platforms/linux/ai.storyteller.solidcraft.metainfo.xml.in | PhotoCraft / SolidCraft contributors | PhotoCraft packaging templates (https://github.com/storytold/photocraft), adapted for SolidCraft | Apache-2.0 || assets/platforms/linux/ai.storyteller.solidcraft.mime.xml | PhotoCraft / SolidCraft contributors | PhotoCraft packaging templates (https://github.com/storytold/photocraft), adapted for SolidCraft | Apache-2.0 |+| assets/platforms/macos/dmg/background.tiff | SolidCraft contributors | original disk image window background (blueprint sheet: grid, double border, circles, centre lines, leader arrow, title block) drawn by assets/platforms/macos/dmg/make_background.py in IBM Plex Sans/Mono; 1x and 2x representations | MIT OR Apache-2.0 |+| assets/platforms/macos/dmg/make_background.py | SolidCraft contributors | authoring script that draws the disk image background (Pillow); not part of any build | MIT OR Apache-2.0 |+| assets/platforms/macos/dmg/layout.json | SolidCraft contributors | disk image window size, icon size and icon positions shared by the background script and settings.py | MIT OR Apache-2.0 |+| assets/platforms/macos/dmg/settings.py | SolidCraft contributors | dmgbuild settings (MIT, https://github.com/dmgbuild/dmgbuild) for the SolidCraft disk image; original settings, no dmgbuild code copied | MIT OR Apache-2.0 || assets/platforms/macos/Info.plist.in | PhotoCraft / SolidCraft contributors | PhotoCraft packaging templates (https://github.com/storytold/photocraft), adapted for SolidCraft | Apache-2.0 || assets/platforms/macos/README.txt | PhotoCraft / SolidCraft contributors | PhotoCraft packaging templates (https://github.com/storytold/photocraft), adapted for SolidCraft | Apache-2.0 || assets/platforms/windows/solidcraft.en-us.wxl | PhotoCraft / SolidCraft contributors | PhotoCraft packaging templates (https://github.com/storytold/photocraft), adapted for SolidCraft | Apache-2.0 |diff --git a/assets/README.md b/assets/README.mdindex 372f3500d5..604e41392a 100644--- a/assets/README.md+++ b/assets/README.md@@ -25,6 +25,7 @@ assets/fonts/{liberation-sans,biz-udp-gothic}/ # unmodified fonts and OFL licenceslocales/{en,de,ja,ko}.json # shared offline catalogsplatforms/{macos,linux,windows}/ # bundle, freedesktop and WiX templates+ platforms/macos/dmg/ # disk image window: layout, dmgbuild settings, background artarchive/icons/macos-v1/source/icon.vectorcraft # earlier editable work, retained# redundant historical exports are retireddiff --git a/assets/platforms/macos/dmg/background.tiff b/assets/platforms/macos/dmg/background.tiffnew file mode 100644index 0000000000..792de1a5a3Binary files /dev/null and b/assets/platforms/macos/dmg/background.tiff differdiff --git a/assets/platforms/macos/dmg/layout.json b/assets/platforms/macos/dmg/layout.jsonnew file mode 100644index 0000000000..918f65a8c6--- /dev/null+++ b/assets/platforms/macos/dmg/layout.json@@ -0,0 +1,8 @@+{+ "window": [540, 360],+ "title_bar": 32,+ "icon_size": 148,+ "text_size": 12,+ "app": [132, 176],+ "applications": [408, 176]+}diff --git a/assets/platforms/macos/dmg/make_background.py b/assets/platforms/macos/dmg/make_background.pynew file mode 100644index 0000000000..c6d0a3c6f7--- /dev/null+++ b/assets/platforms/macos/dmg/make_background.py@@ -0,0 +1,179 @@+#!/usr/bin/env python3+"""Draw the SolidCraft disk image window background (background.tiff).++A blueprint sheet: deep blue with a drafting grid, a double border with ticks, a circle round each+icon, dash-dot centre lines, a leader arrow from the app to Applications and a small title block.+Every line stops short of text. The window geometry comes from layout.json, shared with+settings.py, so the art and the icons agree.++Authoring tool only (assets/AGENTS.md): run it after editing, commit the TIFF. Packaging never+runs it. Needs Python 3.11+, Pillow and macOS `tiffutil`:++ python3 -m venv target/dmg-art && target/dmg-art/bin/pip install pillow+ target/dmg-art/bin/python assets/platforms/macos/dmg/make_background.py [--preview DIR]++All coordinates are points; the TIFF holds a 1x and a 144 dpi 2x representation.+"""+import argparse+import json+import subprocess+import tempfile+from pathlib import Path++from PIL import Image, ImageDraw, ImageFont++HERE = Path(__file__).resolve().parent+FONTS = HERE.parents[2] / "fonts"+LAYOUT = json.loads((HERE / "layout.json").read_text())+W, H = LAYOUT["window"]+ICON = LAYOUT["icon_size"]+AX, CY = LAYOUT["app"]+BX, _ = LAYOUT["applications"]+SS = 6 # drawing scale: 3x the 2x output, reduced afterwards++PAPER_TOP, PAPER_BOTTOM = (28, 84, 158), (18, 58, 118)+LINE = (226, 238, 252)+PALE = (190, 215, 245)+# Finder draws the icon names itself, black in Light and white in Dark appearance, and the art+# cannot change that: each name sits on a mid-tone plate that both colours read on.+PLATE = (92, 132, 196)+PLATE_W, PLATE_H, PLATE_GAP = 116, 22, 8+++def px(v):+ return int(round(v * SS))+++def sans(size, weight):+ # IBMPlexSans-Variable axes: wght, wdth+ f = ImageFont.truetype(str(FONTS / "ibm-plex-sans/IBMPlexSans-Variable.ttf"), px(size))+ f.set_variation_by_axes([weight, 100])+ return f+++def mono(size):+ return ImageFont.truetype(str(FONTS / "ibm-plex-mono/IBMPlexMono-Regular.ttf"), px(size))+++def text(d, xy, s, f, fill, anchor="la", tracking=0.0):+ """Draw text with letter spacing (points); anchor is the usual Pillow one for the whole run."""+ x, y = xy+ if tracking == 0:+ d.text((px(x), px(y)), s, font=f, fill=fill, anchor=anchor)+ return+ widths = [f.getlength(c) / SS for c in s]+ total = sum(widths) + tracking * (len(s) - 1)+ if anchor[0] == "m":+ x -= total / 2+ elif anchor[0] == "r":+ x -= total+ for c, w in zip(s, widths):+ d.text((px(x), px(y)), c, font=f, fill=fill, anchor="l" + anchor[1])+ x += w + tracking+++def dashdot(d, p0, p1, fill, width=1.0, pattern=(14, 3, 2, 3)):+ """A centre line: long dash, gap, short dash, gap. Horizontal or vertical."""+ (x0, y0), (x1, y1) = p0, p1+ horiz = y0 == y1+ a, b = (x0, x1) if horiz else (y0, y1)+ pos, k = a, 0+ while pos < b:+ seg = min(pattern[k % 4], b - pos)+ if k % 2 == 0:+ q, r = ((pos, y0), (pos + seg, y0)) if horiz else ((x0, pos), (x0, pos + seg))+ d.line([(px(q[0]), px(q[1])), (px(r[0]), px(r[1]))], fill=fill, width=px(width))+ pos += seg+ k += 1+++def draw_sheet():+ img = Image.new("RGB", (px(W), px(H)))+ d = ImageDraw.Draw(img)+ for y in range(px(H)):+ t = y / px(H)+ d.line([(0, y), (px(W), y)], fill=tuple(round(a + (b - a) * t) for a, b in zip(PAPER_TOP, PAPER_BOTTOM)))++ # Grid on its own layer so a soft radial mask can fade it towards the edges.+ grid = Image.new("RGBA", img.size, (0, 0, 0, 0))+ g = ImageDraw.Draw(grid)+ for i in range(0, W + 1, 12):+ g.line([(px(i), 0), (px(i), px(H))], fill=(*PALE, 95 if i % 60 == 0 else 40), width=px(0.6))+ for j in range(0, H + 1, 12):+ g.line([(0, px(j)), (px(W), px(j))], fill=(*PALE, 95 if j % 60 == 0 else 40), width=px(0.6))+ mask = Image.radial_gradient("L").resize(img.size).point(lambda v: max(0, 255 - int(v * 0.7)))+ grid.putalpha(Image.composite(grid.getchannel("A"), Image.new("L", img.size, 0), mask))+ img = Image.alpha_composite(img.convert("RGBA"), grid)+ d = ImageDraw.Draw(img)++ # Double border with a tick every 60 pt.+ d.rectangle([px(10), px(10), px(W - 10), px(H - 10)], outline=(*LINE, 255), width=px(1.8))+ d.rectangle([px(15), px(15), px(W - 15), px(H - 15)], outline=(*LINE, 110), width=px(0.6))+ for t in range(60, W, 60):+ d.line([(px(t), px(10)), (px(t), px(15))], fill=(*LINE, 255), width=px(0.8))+ d.line([(px(t), px(H - 15)), (px(t), px(H - 10))], fill=(*LINE, 255), width=px(0.8))++ # Title, top left. The left icon's centre line sits to its right and starts below it.+ text(d, (30, 24), "SolidCraft", sans(20, 600), (*LINE, 255))+ text(d, (31, 49), "PARAMETRIC 3D CAD", mono(7), (*PALE, 255), tracking=0.9)++ # A circle round each icon, with centre lines that stop short of circles, plates and text.+ r = ICON / 2 + 6+ for cx in (AX, BX):+ d.ellipse([px(cx - r), px(CY - r), px(cx + r), px(CY + r)], outline=(*LINE, 170), width=px(1.1))+ cl = (*LINE, 120)+ dashdot(d, (30, CY), (AX - r - 10, CY), cl)+ dashdot(d, (BX + r + 10, CY), (W - 30, CY), cl)+ for cx in (AX, BX):+ dashdot(d, (cx, 66), (cx, CY - r - 6), cl)+ dashdot(d, (cx, CY + r + 34), (cx, H - 42), cl)++ # Leader from the app to Applications: origin dot, line, arrowhead, a label above.+ x0, x1, y = AX + r + 8, BX - r - 8, CY + 7+ d.line([(px(x0 + 4), px(y)), (px(x1 - 10), px(y))], fill=(*LINE, 255), width=px(1.8))+ d.ellipse([px(x0 - 3), px(y - 3), px(x0 + 3), px(y + 3)], fill=(*LINE, 255))+ d.polygon([(px(x1), px(y)), (px(x1 - 11), px(y - 4.4)), (px(x1 - 11), px(y + 4.4))], fill=(*LINE, 255))+ text(d, ((x0 + x1) / 2, CY - 6), "DRAG TO INSTALL", mono(8.5), (*LINE, 255), "ms", tracking=1.4)++ # Title block, bottom right: two cells.+ bx1, by1 = W - 16, H - 16+ d.rectangle([px(bx1 - 196), px(by1 - 18), px(bx1), px(by1)], outline=(*LINE, 255), width=px(1))+ d.line([(px(bx1 - 98), px(by1 - 18)), (px(bx1 - 98), px(by1))], fill=(*LINE, 255), width=px(1))+ text(d, (bx1 - 147, by1 - 8.5), "SHEET 1/1", mono(7), (*LINE, 255), "mm", tracking=1)+ text(d, (bx1 - 49, by1 - 8.5), "SCALE 1:1", mono(7), (*LINE, 255), "mm", tracking=1)++ # Name plates where Finder draws the icon names.+ py = CY + ICON / 2 + PLATE_GAP+ for cx in (AX, BX):+ d.rounded_rectangle(+ [px(cx - PLATE_W / 2), px(py), px(cx + PLATE_W / 2), px(py + PLATE_H)], radius=px(6), fill=(*PLATE, 255)+ )++ return img.convert("RGB")+++def main():+ ap = argparse.ArgumentParser()+ ap.add_argument("--preview", help="also write the 1x and 2x PNGs to this directory")+ ap.add_argument("--out", default=str(HERE / "background.tiff"))+ args = ap.parse_args()++ big = draw_sheet()+ with tempfile.TemporaryDirectory() as tmp:+ one, two = Path(tmp, "bg.png"), Path(tmp, "[email protected]")+ big.resize((W, H), Image.LANCZOS).save(one, dpi=(72, 72))+ big.resize((W * 2, H * 2), Image.LANCZOS).save(two, dpi=(144, 144))+ # A multi-representation TIFF: Finder picks the 2x one on Retina screens.+ raw = Path(tmp, "bg.tiff")+ subprocess.run(["tiffutil", "-cat", str(one), str(two), "-out", str(raw)], check=True)+ subprocess.run(["tiffutil", "-lzw", str(raw), "-out", args.out], check=True)+ if args.preview:+ out = Path(args.preview)+ out.mkdir(parents=True, exist_ok=True)+ for p in (one, two):+ (out / p.name).write_bytes(p.read_bytes())+ print("wrote", args.out)+++if __name__ == "__main__":+ main()diff --git a/assets/platforms/macos/dmg/settings.py b/assets/platforms/macos/dmg/settings.pynew file mode 100644index 0000000000..d987533910--- /dev/null+++ b/assets/platforms/macos/dmg/settings.py@@ -0,0 +1,41 @@+"""dmgbuild settings for the SolidCraft disk image (packaging/macos/package.sh).++Passed with -D here=<this folder> -D app=<SolidCraft.app> -D readme=<README.txt>+-D icns=<icon.icns>. dmgbuild writes the Finder layout (window, background, icon positions) straight into the image, so the build+needs no Finder session and no AppleScript.+"""+import json+import os++here = defines["here"] # noqa: F821 (this folder; settings files have no __file__)+layout = json.load(open(os.path.join(here, "layout.json")))+width, height = layout["window"]++format = "UDZO"+filesystem = "HFS+"+# `dmgbuild -D` values arrive in `defines`.+files = [defines["app"], defines["readme"]] # noqa: F821+symlinks = {"Applications": "/Applications"}+# The read-me stays on the disk for people who look for it, out of the window's calm layout.+hide = ["README.txt"]+icon = defines["icns"] # noqa: F821++background = os.path.join(here, "background.tiff")+show_status_bar = False+show_tab_view = False+show_toolbar = False+show_pathbar = False+show_sidebar = False+default_view = "icon-view"+arrange_by = None+# The rectangle is the whole window: the title bar (32 pt on macOS 27) sits above the content area,+# which must be exactly the size of the background.+window_rect = ((260, 260), (width, height + layout["title_bar"]))+icon_size = layout["icon_size"]+text_size = layout["text_size"]+label_pos = "bottom"+icon_locations = {+ os.path.basename(defines["app"]): tuple(layout["app"]), # noqa: F821+ "Applications": tuple(layout["applications"]),+ "README.txt": (width // 2, height + 200),+}diff --git a/docs/releasing.md b/docs/releasing.mdindex cf5494cfb9..4df1da1c4d 100644--- a/docs/releasing.md+++ b/docs/releasing.md@@ -109,6 +109,31 @@ new commits were added. An existing tag or published release is never overwritteversion after publication. Do not push the version tag yourself: publishing the draft createsit at the draft's target commit.+## macOS disk image++`packaging/macos/package.sh` builds the `.dmg` with [dmgbuild](https://github.com/dmgbuild/dmgbuild)+(MIT; hash-pinned in `packaging/macos/dmg-requirements.txt`, installed into a throwaway venv under+`target/`). It writes the Finder layout, the background and the icon positions straight into the+image, so the build needs no Finder session or AppleScript, which are unreliable on CI runners.++The look lives in `assets/platforms/macos/dmg/`: `layout.json` (window size, icon size and+positions, shared by both files below), `settings.py` (the dmgbuild settings) and `background.tiff`+(a blueprint sheet, 540×360 pt, with a 1x and a 2x representation so Retina screens get the sharp one). Change the art with+`make_background.py` (needs Pillow; its docstring has the commands), view the result by mounting the+image, and commit the TIFF with the script. Rules the design follows:++- The title bar adds to the window rectangle (`title_bar` in `layout.json`, 32 pt on macOS 27); the+ content area must equal the background's size. Older macOS versions have a thinner title bar and+ were not checked.+- Finder draws the icon names itself, black in Light and white in Dark appearance, and art cannot+ change that. Each name therefore sits on a mid-tone plate that both colours read on. Keep the+ plates under the icons if you move them.+- `README.txt` stays on the disk but is hidden (`SetFile -a V`), so the window stays calm.++`package.sh` mounts the finished image and checks the layout files, the volume icon, the bundle and+its signature. `hdiutil` prints deprecation warnings on macOS 27 (dmgbuild still uses it); if a+later macOS removes it, dmgbuild needs a release that uses `diskutil image`.+## Notes for the next releaseItems to carry into the next release's notes (step 3 below), then remove from here:diff --git a/packaging/macos/dmg-requirements.txt b/packaging/macos/dmg-requirements.txtnew file mode 100644index 0000000000..81298a23b1--- /dev/null+++ b/packaging/macos/dmg-requirements.txt@@ -0,0 +1,10 @@+# Tools that lay out the disk image window (assets/platforms/macos/dmg/settings.py), all MIT.+# dmgbuild writes the Finder layout straight into the image, so no Finder session is needed.+# Installed by package.sh with --require-hashes; regenerate the hashes with `pip hash` on the+# downloaded wheels when bumping a version.+dmgbuild==1.6.7 \+ --hash=sha256:37ee5771c377beb3203d9164aae8046ffed8531c06edf9227f5788b3c599b1bf+ds_store==1.3.3 \+ --hash=sha256:b92a371efbf1b4ccce2a04d1ed13fceacc4736c81ba09cf5aefb74c088160a35+mac_alias==2.2.3 \+ --hash=sha256:7362b521d2132ef92f606a37abfed5fcd849ceb2f28b6f9743e014b02af92f0ddiff --git a/packaging/macos/package.sh b/packaging/macos/package.shindex de66ee44d3..32f53bab2a 100755--- a/packaging/macos/package.sh+++ b/packaging/macos/package.sh@@ -2,7 +2,8 @@# Build and package SolidCraft for macOS:## $DIST/solidcraft-<version>-macos-<arch>.dmg SolidCraft.app (with solidcraft-cli inside) on a-# drag-to-Applications DMG+# drag-to-Applications DMG with a drawn window+# (assets/platforms/macos/dmg)# $DIST/solidcraft-cli-<version>-macos-<arch>.zip the headless CLI (and its solvecraft-cli# compatibility alias) with the licence files#@@ -193,23 +194,26 @@ fi# ---- DMG ---------------------------------------------------------------------------------------echo "==> building $DMG"-STAGE="$WORK/dmg"-mkdir -p "$STAGE"-ditto "$APP" "$STAGE/SolidCraft.app"-ln -s /Applications "$STAGE/Applications"-cp "$ROOT/assets/platforms/macos/README.txt" "$STAGE/README.txt"-rm -f "$DMG" "$WORK/raw.dmg"-# makehybrid + convert builds the image without attaching a device, unlike `create -srcfolder`,-# which is flaky on CI runners ("Resource busy").-hdiutil makehybrid -hfs -hfs-volume-name "SolidCraft" -hfs-openfolder "$STAGE" -o "$WORK/raw.dmg" "$STAGE"-hdiutil convert "$WORK/raw.dmg" -format UDZO -imagekey zlib-level=9 -o "$DMG"-rm -f "$WORK/raw.dmg"+DMG_ART="$ROOT/assets/platforms/macos/dmg"+# dmgbuild (hash-pinned, packaging/macos/dmg-requirements.txt) writes the window layout, the+# background and the icon positions into the image without a Finder session.+VENV="$WORK/dmg-venv"+python3 -m venv "$VENV"+"$VENV/bin/pip" install --quiet --disable-pip-version-check --require-hashes -r "$ROOT/packaging/macos/dmg-requirements.txt"+rm -f "$DMG"+"$VENV/bin/dmgbuild" -s "$DMG_ART/settings.py" \+ -D "here=$DMG_ART" -D "app=$APP" -D "readme=$ROOT/assets/platforms/macos/README.txt" \+ -D "icns=$ROOT/assets/icons/app/macos/exports/icon.icns" \+ SolidCraft "$DMG"# Check the image as a user gets it: mount it and look inside.MNT="$(mktemp -d)"hdiutil attach -readonly -nobrowse -mountpoint "$MNT" "$DMG"ls -la "$MNT" "$MNT/SolidCraft.app/Contents" "$MNT/SolidCraft.app/Contents/MacOS" "$MNT/SolidCraft.app/Contents/Resources"test -L "$MNT/Applications" && test "$(readlink "$MNT/Applications")" = /Applications+# The window's look: Finder layout, background art and the volume icon.+test -s "$MNT/.DS_Store" && test -s "$MNT/.VolumeIcon.icns"+test -s "$MNT/.background.tiff"plutil -lint "$MNT/SolidCraft.app/Contents/Info.plist"# Check the names Finder/LaunchServices actually use, and the bundle identity.for key in CFBundleName CFBundleDisplayName CFBundleExecutable CFBundleIconFile CFBundleIconName; do