Skip to content

armgit / SOMA

Public Imported from GitHub
0

Desktop app for designing parametric 3D models in CadQuery together with the coding agent of your choice

App: Icon „Dialog“ für Fenster, Taskleiste und Kopfzeile (E44)

Kai-Jungsthoefel87cfc0590ec2
diff --git a/app/resources/icon.ico b/app/resources/icon.ico
new file mode 100644
index 0000000..34e48e8
Binary files /dev/null and b/app/resources/icon.ico differ
diff --git a/app/resources/icon.png b/app/resources/icon.png
new file mode 100644
index 0000000..91654db
Binary files /dev/null and b/app/resources/icon.png differ
diff --git a/app/resources/icon.svg b/app/resources/icon.svg
new file mode 100644
index 0000000..4aaa5d5
--- /dev/null
+++ b/app/resources/icon.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 64 64"><rect x="0.5" y="0.5" width="63" height="63" rx="14" fill="#1b1e23" stroke="#2d323a"/><g transform="translate(32 32) scale(0.78) translate(-32 -32)"><polygon points="33.5,7 54.5,19 33.5,31 12.5,19" fill="#f29a38"/><path d="M33.5 7 L54.5 19 L54.5 43 L33.5 55 L22 48.4 L8 57 L12.5 37 L12.5 19 Z M12.5 19 L33.5 31 L54.5 19 M33.5 31 L33.5 55" fill="none" stroke="#f29a38" stroke-width="4.2" stroke-linecap="round" stroke-linejoin="round"/></g></svg>
diff --git a/app/scripts/make-icon.py b/app/scripts/make-icon.py
new file mode 100644
index 0000000..dbd0b58
--- /dev/null
+++ b/app/scripts/make-icon.py
@@ -0,0 +1,72 @@
+"""Erzeugt das App-Icon von SOMA (E44): resources/icon.svg (Vorlage), icon.png (256 px) und icon.ico (16 bis 256 px).
+
+Das Zeichen ist der Würfel als Sprechblase mit orangem Deckel auf einer Graphit-Fläche. Kleine Größen bekommen einen
+dickeren Strich und ein größeres Zeichen, sonst verschwimmt es bei 16 px. Gerastert wird mit Edge ohne Fenster
+(SVG wird in jeder Größe einzeln gezeichnet, nicht herunterskaliert), die ICO baut Pillow.
+
+Aufruf (in app/): python scripts/make-icon.py Edge-Pfad notfalls über die Umgebungsvariable EDGE.
+"""
+import os
+import pathlib
+import subprocess
+import tempfile
+
+from PIL import Image
+
+RES = pathlib.Path(__file__).resolve().parent.parent / "resources"
+EDGE = os.environ.get("EDGE", r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe")
+SIZES = [256, 128, 64, 48, 40, 32, 24, 20, 16]
+
+ORANGE, TILE, BORDER = "#f29a38", "#1b1e23", "#2d323a"
+# Würfel als Sprechblase im 64er-Raster; die Spitze links unten ersetzt die Ecke des Würfels
+OUTLINE = "M33.5 7 L54.5 19 L54.5 43 L33.5 55 L22 48.4 L8 57 L12.5 37 L12.5 19 Z M12.5 19 L33.5 31 L54.5 19 M33.5 31 L33.5 55"
+LID = "33.5,7 54.5,19 33.5,31 12.5,19"
+
+
+def params(size):
+ """Zeichengröße und Strichstärke je Pixelgröße."""
+ if size <= 32:
+ return 0.86, 5.6
+ if size <= 48:
+ return 0.82, 4.8
+ return 0.78, 4.2
+
+
+def svg(size):
+ scale, sw = params(size)
+ return (f'<svg xmlns="http://www.w3.org/2000/svg" width="{size}" height="{size}" viewBox="0 0 64 64">'
+ f'<rect x="0.5" y="0.5" width="63" height="63" rx="14" fill="{TILE}" stroke="{BORDER}"/>'
+ f'<g transform="translate(32 32) scale({scale}) translate(-32 -32)">'
+ f'<polygon points="{LID}" fill="{ORANGE}"/>'
+ f'<path d="{OUTLINE}" fill="none" stroke="{ORANGE}" stroke-width="{sw}" stroke-linecap="round" stroke-linejoin="round"/>'
+ f'</g></svg>')
+
+
+def main():
+ RES.mkdir(exist_ok=True)
+ (RES / "icon.svg").write_text(svg(256) + "\n", encoding="utf-8", newline="\n")
+
+ # Alle Größen nebeneinander auf transparentem Grund, dann einzeln ausschneiden
+ gap, x, cells = 16, 0, []
+ for s in SIZES:
+ cells.append((s, x))
+ x += s + gap
+ body = "".join(f'<div style="position:absolute;left:{x}px;top:0">{svg(s)}</div>' for s, x in cells)
+ html = f'<!doctype html><html><head><meta charset="utf-8"><style>html,body{{margin:0;background:transparent}}svg{{display:block}}</style></head><body>{body}</body></html>'
+ with tempfile.TemporaryDirectory() as tmp:
+ page, shot = pathlib.Path(tmp) / "icons.html", pathlib.Path(tmp) / "icons.png"
+ page.write_text(html, encoding="utf-8")
+ subprocess.run([EDGE, "--headless=new", "--disable-gpu", "--hide-scrollbars", "--force-device-scale-factor=1",
+ "--default-background-color=00000000", f"--window-size={x},{max(SIZES)}",
+ f"--screenshot={shot}", page.as_uri()], check=True, capture_output=True)
+ sheet = Image.open(shot).convert("RGBA")
+ images = [sheet.crop((x, 0, x + s, s)) for s, x in cells]
+ # Ohne Alphakanal wäre der Grund nicht durchsichtig (dann stimmt die Rasterung nicht)
+ assert images[0].getpixel((0, 0))[3] == 0, "Hintergrund ist nicht transparent"
+ images[0].save(RES / "icon.png")
+ images[0].save(RES / "icon.ico", sizes=[(s, s) for s in SIZES], append_images=images[1:])
+ print("geschrieben:", ", ".join(f"icon.{e}" for e in ("svg", "png", "ico")), "in", RES)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/app/src/main/main.ts b/app/src/main/main.ts
index eab0b4f..602e7a9 100644
--- a/app/src/main/main.ts
+++ b/app/src/main/main.ts
@@ -6,7 +6,7 @@ import { choose, setTestAnswers } from './dialogs';
import { backupText, importInputs, listFiles, resolveInside, saveFeedbackImage, writeProjectText } from './files';
import { ProjectController } from './projects';
import { terminalEnv } from './terminals';
-import { editBackupsDir, thumbnailsDir } from './paths';
+import { appIcon, editBackupsDir, thumbnailsDir } from './paths';
import { createProject, getLastProject, isProjectId } from './workspace';
// App-Daten (Arbeitsordner, Caches) gehören auf die lokale Platte. Das Roaming-Profil (%APPDATA%) kann in Firmennetzen
@@ -135,7 +135,7 @@ const testWindowMode = process.env.SOMA_HIDDEN;
function createWindow(): void {
win = new BrowserWindow({
- width: 1600, height: 950, title: 'SOMA', backgroundColor: '#121417', show: testWindowMode !== '1' && testWindowMode !== 'offscreen',
+ width: 1600, height: 950, title: 'SOMA', icon: appIcon(), backgroundColor: '#121417', show: testWindowMode !== '1' && testWindowMode !== 'offscreen',
webPreferences: {
preload: path.join(__dirname, '..', 'preload', 'preload.js'),
contextIsolation: true, nodeIntegration: false, sandbox: true,
diff --git a/app/src/main/paths.ts b/app/src/main/paths.ts
index 8e57019..01f5c6c 100644
--- a/app/src/main/paths.ts
+++ b/app/src/main/paths.ts
@@ -23,6 +23,9 @@ export const thumbnailsDir = () => path.join(userDataDir(), 'thumbnails');
/** Vorlage fuer neue Projekte (liegt neben dem Programm, spaeter im Installationspaket). */
export const templateDir = () => path.join(app.getAppPath(), 'resources', 'template');
+/** App-Icon (E44) für Fenster und Taskleiste. Windows nimmt die ICO mit allen Größen, andere Systeme das PNG. */
+export const appIcon = () => path.join(app.getAppPath(), 'resources', process.platform === 'win32' ? 'icon.ico' : 'icon.png');
+
/**
* Python der Basisumgebung. Reihenfolge: SOMA_PYTHON, Entwicklungs-Umgebung aus Phase 0, sonst `python` im PATH.
* Die mitgelieferte Basisumgebung ersetzt das spaeter (Auslieferung ist noch offen).
diff --git a/app/src/renderer/icons.ts b/app/src/renderer/icons.ts
index 931692d..d049761 100644
--- a/app/src/renderer/icons.ts
+++ b/app/src/renderer/icons.ts
@@ -2,6 +2,8 @@
// innerHTML ist hier unbedenklich, weil nie Text aus dem Projekt hineinkommt.
const PATHS: Record<string, string> = {
cube: '<path d="M12 2.5 20.5 7.2v9.6L12 21.5l-8.5-4.7V7.2z"/><path d="M3.5 7.2 12 12l8.5-4.8M12 12v9.5"/>',
+ // Marke von SOMA (E44): der Würfel als Sprechblase mit gefülltem Deckel
+ logo: '<path d="M12 2.6 19.9 7.1 12 11.6 4.1 7.1z" fill="currentColor"/><path d="M12 2.6 19.9 7.1v9L12 20.6l-4.3-2.45-5.3 3.2 1.7-7.5V7.1z"/><path d="M4.1 7.1 12 11.6l7.9-4.5M12 11.6v9"/>',
down: '<path d="m6 9 6 6 6-6"/>', up: '<path d="m6 15 6-6 6 6"/>', right: '<path d="m9 6 6 6-6 6"/>',
refresh: '<path d="M20 12a8 8 0 1 1-2.3-5.7L20 8.5"/><path d="M20 3.5v5h-5"/>',
export: '<path d="M12 15V4M7 9l5-5 5 5"/><path d="M5 14v5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5"/>',
diff --git a/app/src/renderer/index.html b/app/src/renderer/index.html
index 329707f..30e6acf 100644
--- a/app/src/renderer/index.html
+++ b/app/src/renderer/index.html
@@ -10,7 +10,7 @@
<body>
<div id="app">
<header id="topbar" class="top">
- <button id="btn-home" class="logo" title="Startseite" aria-label="Startseite"><i data-icon="cube" data-size="22"></i></button>
+ <button id="btn-home" class="logo" title="Startseite" aria-label="Startseite"><i data-icon="logo" data-size="22" data-stroke="1.6"></i></button>
<button id="btn-doc" class="docname" title="Neu, Öffnen, Zuletzt geöffnet, Speichern unter" aria-haspopup="menu" aria-expanded="false"><b id="doc-name">SOMA</b><i data-icon="down" data-size="14" data-stroke="2"></i></button>
<span id="save-badge" class="savestate"></span>
<button id="problems" class="warnbadge" hidden aria-haspopup="dialog" aria-expanded="false"></button>
@@ -283,7 +283,7 @@
</div>
<div id="start" class="start" hidden>
- <header class="top"><span class="logo"><i data-icon="cube" data-size="22"></i></span><b class="brand">SOMA</b><span class="grow"></span>
+ <header class="top"><span class="logo"><i data-icon="logo" data-size="22" data-stroke="1.6"></i></span><b class="brand">SOMA</b><span class="grow"></span>
<button id="btn-start-close" class="btn">Zurück zum Modell</button></header>
<div class="start-body">
<div class="start-grid">
diff --git a/app/test/unit.mjs b/app/test/unit.mjs
index 5c813e6..675920c 100644
--- a/app/test/unit.mjs
+++ b/app/test/unit.mjs
@@ -91,6 +91,11 @@ try {
check('Pfad außerhalb des Projekts: abgelehnt', !w.ok && !fs.existsSync(path.join(tmp, 'draussen.py')), w.error?.slice(0, 60));
const b1 = backupText(bdir, 'parts/deckel.py', 'eins'), b2 = backupText(bdir, 'parts/deckel.py', 'zwei');
check('Sicherungen überschreiben einander nicht', b1 !== b2 && fs.readFileSync(b1, 'utf8') === 'eins' && fs.readFileSync(b2, 'utf8') === 'zwei', path.basename(b2));
+ // App-Icon (E44): ICO mit allen Größen für Fenster und Taskleiste (Breite 0 steht für 256), PNG für andere Systeme
+ const ico = fs.readFileSync(path.join(APP, 'resources', 'icon.ico'));
+ const icoSizes = Array.from({ length: ico.readUInt16LE(4) }, (_, i) => ico[6 + 16 * i] || 256);
+ check('App-Icon: icon.ico mit 16 bis 256 px, icon.png vorhanden', [16, 24, 32, 48, 256].every((s) => icoSizes.includes(s))
+ && fs.existsSync(path.join(APP, 'resources', 'icon.png')), icoSizes.join(','));
} catch (e) {
console.log('ABBRUCH:', e.message);
t.fail();