Skip to content
Swift

Move the code into Sources, Tests, Scripts and Docs.

Andy Gao05ab3a080065
diff --git a/DESIGN-SYSTEM.md b/Docs/DESIGN-SYSTEM.md
similarity index 97%
rename from DESIGN-SYSTEM.md
rename to Docs/DESIGN-SYSTEM.md
index 44edd8c..cae36fb 100644
--- a/DESIGN-SYSTEM.md
+++ b/Docs/DESIGN-SYSTEM.md
@@ -181,7 +181,7 @@ When a system control can't meet the rules in §4 (blue, translucent), draw a sm
## 9. Imagery and 3D renders
- **Source:** Apple's AirPods Pro 3 AR asset, `Assets/airpods-pro.usdz`. The source URL is in `Assets/README.md` and its hash in `Assets/CaseLid/lid.json`. Apple owns the model. Keep the USDZ bytes unchanged, and only bundle renders (PNG).
-- **Rendering:** `render-closed-case.py`, run with Blender in the background (never a live Blender session). Cycles, AgX "Medium High Contrast", a dark studio (near-black world, soft key and fill, thin strip lights left, right, top and front, and a rim) so the gloss reads as crisp highlight bands, transparent film, and a measured silhouette in a JSON sidecar. The earbuds are seated with the transform from `seat-earbuds.py` so they clear the closed lid. Output goes to `work/case-renders`; copy it into `Assets/` as described in `Assets/README.md`.
+- **Rendering:** `Scripts/render-closed-case.py`, run with Blender in the background (never a live Blender session). Cycles, AgX "Medium High Contrast", a dark studio (near-black world, soft key and fill, thin strip lights left, right, top and front, and a rim) so the gloss reads as crisp highlight bands, transparent film, and a measured silhouette in a JSON sidecar. The earbuds are seated with the transform from `Scripts/seat-earbuds.py` so they clear the closed lid. Output goes to `work/case-renders`; copy it into `Assets/` as described in `Assets/README.md`.
- **Bundled set (one front camera, 12° above, shared by every frame):**
- `CaseLid/lid-00.png`…`lid-11.png`: the lid easing from open (115°) to closed. The light comes on in the last two frames.
- `CaseFront.png`: the closed case turned a quarter clockwise, upright, lid seam on the right, light facing you.
diff --git a/render-closed-case.py b/Scripts/render-closed-case.py
similarity index 99%
rename from render-closed-case.py
rename to Scripts/render-closed-case.py
index 4ccebe0..46d56c2 100644
--- a/render-closed-case.py
+++ b/Scripts/render-closed-case.py
@@ -14,7 +14,7 @@ above the front so every output can crossfade:
review/ each still over a light and a dark stage, lid frame strip
/Applications/Blender.app/Contents/MacOS/Blender --background --factory-startup \
- --threads 8 --python render-closed-case.py
+ --threads 8 --python Scripts/render-closed-case.py
Optional, after a "--": --only open,closed,pointer,lid,spin,review --preview
"""
import bpy
@@ -35,7 +35,7 @@ only = set(args[args.index('--only') + 1].split(',')) if '--only' in args else \
preview = '--preview' in args
# Renders land in work/ (ignored); the app bundles the copies in Assets/ (see Assets/README.md).
-root = Path(__file__).resolve().parent
+root = Path(__file__).resolve().parent.parent
out = root / 'work' / 'case-renders' / ('preview' if preview else '')
(out / 'lid').mkdir(parents=True, exist_ok=True)
(out / 'spin').mkdir(parents=True, exist_ok=True)
diff --git a/seat-earbuds.py b/Scripts/seat-earbuds.py
similarity index 98%
rename from seat-earbuds.py
rename to Scripts/seat-earbuds.py
index 149da1a..3580b47 100644
--- a/seat-earbuds.py
+++ b/Scripts/seat-earbuds.py
@@ -18,7 +18,7 @@ is the X-mirror of the left transform. The result is written to seat.json and
is embedded as a constant in render-closed-case.py.
/Applications/Blender.app/Contents/MacOS/Blender --background --factory-startup \
- --threads 8 --python seat-earbuds.py
+ --threads 8 --python Scripts/seat-earbuds.py
"""
import bpy
import json
@@ -27,7 +27,7 @@ from pathlib import Path
from mathutils import Matrix, Vector
from mathutils.bvhtree import BVHTree
-root = Path(__file__).resolve().parent
+root = Path(__file__).resolve().parent.parent
here = root / 'work' / 'case-renders'
here.mkdir(parents=True, exist_ok=True)
model = root / 'Assets' / 'airpods-pro.usdz'
diff --git a/AirPointer.swift b/Sources/AirPointer/App/AirPointer.swift
similarity index 100%
rename from AirPointer.swift
rename to Sources/AirPointer/App/AirPointer.swift
diff --git a/AppHome.swift b/Sources/AirPointer/App/AppHome.swift
similarity index 100%
rename from AppHome.swift
rename to Sources/AirPointer/App/AppHome.swift
diff --git a/PointerShortcut.swift b/Sources/AirPointer/App/PointerShortcut.swift
similarity index 100%
rename from PointerShortcut.swift
rename to Sources/AirPointer/App/PointerShortcut.swift
diff --git a/Checks.swift b/Sources/AirPointer/Checks/Checks.swift
similarity index 100%
rename from Checks.swift
rename to Sources/AirPointer/Checks/Checks.swift
diff --git a/HomeChecks.swift b/Sources/AirPointer/Checks/HomeChecks.swift
similarity index 100%
rename from HomeChecks.swift
rename to Sources/AirPointer/Checks/HomeChecks.swift
diff --git a/AccessibilityGuide.swift b/Sources/AirPointer/Interface/AccessibilityGuide.swift
similarity index 100%
rename from AccessibilityGuide.swift
rename to Sources/AirPointer/Interface/AccessibilityGuide.swift
diff --git a/AirPointerHome.swift b/Sources/AirPointer/Interface/AirPointerHome.swift
similarity index 100%
rename from AirPointerHome.swift
rename to Sources/AirPointer/Interface/AirPointerHome.swift
diff --git a/CaseLessons.swift b/Sources/AirPointer/Interface/CaseLessons.swift
similarity index 100%
rename from CaseLessons.swift
rename to Sources/AirPointer/Interface/CaseLessons.swift
diff --git a/NotchFlow.swift b/Sources/AirPointer/Interface/NotchFlow.swift
similarity index 100%
rename from NotchFlow.swift
rename to Sources/AirPointer/Interface/NotchFlow.swift
diff --git a/RemoteKit.swift b/Sources/AirPointer/Interface/RemoteKit.swift
similarity index 100%
rename from RemoteKit.swift
rename to Sources/AirPointer/Interface/RemoteKit.swift
diff --git a/SetupAssistant.swift b/Sources/AirPointer/Interface/SetupAssistant.swift
similarity index 100%
rename from SetupAssistant.swift
rename to Sources/AirPointer/Interface/SetupAssistant.swift
diff --git a/StatusBarUI.swift b/Sources/AirPointer/Interface/StatusBarUI.swift
similarity index 100%
rename from StatusBarUI.swift
rename to Sources/AirPointer/Interface/StatusBarUI.swift
diff --git a/TapTest.swift b/Sources/AirPointer/Interface/TapTest.swift
similarity index 100%
rename from TapTest.swift
rename to Sources/AirPointer/Interface/TapTest.swift
diff --git a/AudioOutputGuard.swift b/Sources/AirPointer/Session/AudioOutputGuard.swift
similarity index 100%
rename from AudioOutputGuard.swift
rename to Sources/AirPointer/Session/AudioOutputGuard.swift
diff --git a/ClosedCaseAirPods.swift b/Sources/AirPointer/Session/ClosedCaseAirPods.swift
similarity index 100%
rename from ClosedCaseAirPods.swift
rename to Sources/AirPointer/Session/ClosedCaseAirPods.swift
diff --git a/ClosedCaseSession.swift b/Sources/AirPointer/Session/ClosedCaseSession.swift
similarity index 100%
rename from ClosedCaseSession.swift
rename to Sources/AirPointer/Session/ClosedCaseSession.swift
diff --git a/ClosedCaseTap.swift b/Sources/AirPointer/Session/ClosedCaseTap.swift
similarity index 99%
rename from ClosedCaseTap.swift
rename to Sources/AirPointer/Session/ClosedCaseTap.swift
index f8286ea..b67dd59 100644
--- a/ClosedCaseTap.swift
+++ b/Sources/AirPointer/Session/ClosedCaseTap.swift
@@ -8,7 +8,7 @@ import Foundation
// turned 28°/s at most, and just before tap-like jolts from moving it 41°/s or more, so turning asks for a firmer, more exact spike.
// A firm, exact spike with little turning counts even if the hand wasn't quite still. For a second after a tap the hand
// hasn't settled, so a spike there only has to come without much rotation.
-// The thresholds come from closed-lid taps held in the hand, closed-lid handling and pointing (ClosedCase/TapFixtures.csv)
+// The thresholds come from closed-lid taps held in the hand, closed-lid handling and pointing (Tests/TapFixtures.csv)
// and from runs of the tap test.
struct ClosedCaseTapDetector {
// tap: click where the pointer was before `since` (sensor seconds), and keep it there through the wobble.
diff --git a/CursorSize.swift b/Sources/AirPointer/Session/CursorSize.swift
similarity index 100%
rename from CursorSize.swift
rename to Sources/AirPointer/Session/CursorSize.swift
diff --git a/MotionLearning.swift b/Sources/AirPointer/Session/MotionLearning.swift
similarity index 100%
rename from MotionLearning.swift
rename to Sources/AirPointer/Session/MotionLearning.swift
diff --git a/ClosedCase/Orientation.js b/Sources/AirPointer/Session/Orientation.js
similarity index 100%
rename from ClosedCase/Orientation.js
rename to Sources/AirPointer/Session/Orientation.js
diff --git a/ClosedCase/CaseSustainedRenewal.m b/Sources/ClosedCaseMotion/CaseSustainedRenewal.m
similarity index 100%
rename from ClosedCase/CaseSustainedRenewal.m
rename to Sources/ClosedCaseMotion/CaseSustainedRenewal.m
diff --git a/ClosedCaseRestore.swift b/Sources/ClosedCaseRestore/ClosedCaseRestore.swift
similarity index 100%
rename from ClosedCaseRestore.swift
rename to Sources/ClosedCaseRestore/ClosedCaseRestore.swift
diff --git a/ClosedCase/TapFixtures.csv b/Tests/TapFixtures.csv
similarity index 100%
rename from ClosedCase/TapFixtures.csv
rename to Tests/TapFixtures.csv
diff --git a/build.sh b/build.sh
index bbd6c2f..cf1fd57 100755
--- a/build.sh
+++ b/build.sh
@@ -9,9 +9,9 @@ for frame in Assets/CaseLid/lid-*.png; do cp "$frame" "AirPointer.app/Contents/R
cp Assets/TapClick/click.wav AirPointer.app/Contents/Resources/TapClick.wav
cp Assets/NotchShimmer.wav AirPointer.app/Contents/Resources/NotchShimmer.wav
cp Assets/TapClick/LICENSE-cuelume.txt AirPointer.app/Contents/Resources/LICENSE-cuelume.txt
-clang -fobjc-arc -Wall -Wextra -Werror -framework Foundation -framework CoreBluetooth -framework IOBluetooth ClosedCase/CaseSustainedRenewal.m -o AirPointer.app/Contents/Resources/ClosedCaseMotion.bin
-xcrun swiftc -swift-version 5 -O ClosedCaseRestore.swift -o AirPointer.app/Contents/Resources/ClosedCaseRestore.bin -framework Foundation -framework CoreBluetooth -framework IOBluetooth
-cp ClosedCase/Orientation.js AirPointer.app/Contents/Resources/ClosedCaseOrientation.js
+clang -fobjc-arc -Wall -Wextra -Werror -framework Foundation -framework CoreBluetooth -framework IOBluetooth Sources/ClosedCaseMotion/CaseSustainedRenewal.m -o AirPointer.app/Contents/Resources/ClosedCaseMotion.bin
+xcrun swiftc -swift-version 5 -O Sources/ClosedCaseRestore/ClosedCaseRestore.swift -o AirPointer.app/Contents/Resources/ClosedCaseRestore.bin -framework Foundation -framework CoreBluetooth -framework IOBluetooth
+cp Sources/AirPointer/Session/Orientation.js AirPointer.app/Contents/Resources/ClosedCaseOrientation.js
# The app finds the paired AirPods itself; no address is built in.
cat > AirPointer.app/Contents/Info.plist <<'PLIST'
<?xml version="1.0" encoding="UTF-8"?>
@@ -29,7 +29,7 @@ cat > AirPointer.app/Contents/Info.plist <<'PLIST'
<key>NSBluetoothAlwaysUsageDescription</key><string>AirPointer connects to your paired AirPods to keep motion available with the case closed.</string>
</dict></plist>
PLIST
-xcrun swiftc -swift-version 5 "$airpointer_build_mode" AirPointer.swift ClosedCaseSession.swift ClosedCaseTap.swift TapTest.swift ClosedCaseAirPods.swift AudioOutputGuard.swift AppHome.swift AirPointerHome.swift RemoteKit.swift SetupAssistant.swift AccessibilityGuide.swift PointerShortcut.swift CursorSize.swift StatusBarUI.swift NotchFlow.swift HomeChecks.swift MotionLearning.swift CaseLessons.swift Checks.swift -o AirPointer.app/Contents/MacOS/.AirPointer-next -framework AppKit -framework JavaScriptCore -framework QuartzCore -framework ApplicationServices -framework Carbon -framework AVFoundation -framework CoreAudio -framework CoreBluetooth
+xcrun swiftc -swift-version 5 "$airpointer_build_mode" Sources/AirPointer/**/*.swift -o AirPointer.app/Contents/MacOS/.AirPointer-next -framework AppKit -framework JavaScriptCore -framework QuartzCore -framework ApplicationServices -framework Carbon -framework AVFoundation -framework CoreAudio -framework CoreBluetooth
mv -f AirPointer.app/Contents/MacOS/.AirPointer-next AirPointer.app/Contents/MacOS/AirPointer
if [[ "$airpointer_signing_identity" != "-" ]]; then
codesign --force --sign "$airpointer_signing_identity" --timestamp=none --identifier local.airpointer.closed-case-motion AirPointer.app/Contents/Resources/ClosedCaseMotion.bin
@@ -38,4 +38,4 @@ fi
codesign --force --sign "$airpointer_signing_identity" --timestamp=none AirPointer.app
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -f "$PWD/AirPointer.app"
AirPointer.app/Contents/MacOS/AirPointer --self-test
-AirPointer.app/Contents/MacOS/AirPointer --check-closed-case-tap ClosedCase/TapFixtures.csv
+AirPointer.app/Contents/MacOS/AirPointer --check-closed-case-tap Tests/TapFixtures.csv