A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(editor): per-platform frameless window chrome + custom Windows/Linux controls
yhhe3f42dd68cbc
diff --git a/desktop/electron/main.ts b/desktop/electron/main.tsindex 2678532bc..21e929541 100644--- a/desktop/electron/main.ts+++ b/desktop/electron/main.ts@@ -1,6 +1,6 @@// SPDX-License-Identifier: Apache-2.0// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team-import { app, BrowserWindow, shell, ipcMain, dialog, protocol } from 'electron';+import { app, BrowserWindow, Menu, shell, ipcMain, dialog, protocol } from 'electron';import { fileURLToPath } from 'node:url';import { readFile, writeFile } from 'node:fs/promises';import { existsSync } from 'node:fs';@@ -167,6 +167,11 @@ async function runScreenshot(w: BrowserWindow, out: string): Promise<void> {}function createWindow() {+ const isMac = process.platform === 'darwin';+ // The app draws its own menu + title bar, so drop the native application menu+ // (on Windows/Linux that's the extra menu row under the title bar).+ if (!isMac) Menu.setApplicationMenu(null);+win = new BrowserWindow({width: 1480,height: 920,@@ -174,9 +179,12 @@ function createWindow() {minHeight: 680,title: 'Estella Editor',backgroundColor: '#0E121B',- // Frameless-ish chrome: the app draws its own menu/title bar.- titleBarStyle: 'hiddenInset',- trafficLightPosition: { x: 14, y: 14 },+ // macOS keeps the native traffic lights (hiddenInset); Windows/Linux go fully+ // frameless — which also removes the native menu row — and get our own window+ // controls in the title bar.+ ...(isMac+ ? { titleBarStyle: 'hiddenInset' as const, trafficLightPosition: { x: 14, y: 14 } }+ : { frame: false }),icon: path.join(VITE_PUBLIC, 'icon.png'),webPreferences: {preload: path.join(__dirname, 'preload.mjs'),@@ -192,6 +200,12 @@ function createWindow() {return { action: 'deny' };});+ // Mirror maximize state to the renderer so the custom window controls show the+ // correct maximize/restore glyph.+ const emitMax = () => win?.webContents.send('window:maximized', win?.isMaximized() ?? false);+ win.on('maximize', emitMax);+ win.on('unmaximize', emitMax);+// Screenshot/visual-regression mode (ESTELLA_SHOT=out.png): open ?automation=1 so// the renderer hook is live, then drive the launcher→editor flow and capturePage.const shotOut = process.env.ESTELLA_SHOT;@@ -241,6 +255,16 @@ ipcMain.handle('app:version', () => app.getVersion());ipcMain.handle('app:platform', () => process.platform);ipcMain.on('engine:status', (_e, status: string) => console.log('[engine]', status));+// — Custom window controls (frameless Windows/Linux; macOS uses native traffic lights) —+ipcMain.handle('window:minimize', () => win?.minimize());+ipcMain.handle('window:toggleMaximize', () => {+ if (!win) return;+ if (win.isMaximized()) win.unmaximize();+ else win.maximize();+});+ipcMain.handle('window:close', () => win?.close());+ipcMain.handle('window:isMaximized', () => win?.isMaximized() ?? false);+// — Project / filesystem (RC12 §E7). The open project root lives here in main;// every fs op is sandboxed to it (projectFs.resolveInRoot), so the renderer// can only touch files inside the project it opened. —diff --git a/desktop/electron/preload.ts b/desktop/electron/preload.tsindex 51e33a7bb..4f090a289 100644--- a/desktop/electron/preload.ts+++ b/desktop/electron/preload.ts@@ -15,9 +15,25 @@ import type { PlayRealmResult } from './buildPlayRealm';const api = {getVersion: (): Promise<string> => ipcRenderer.invoke('app:version'),getPlatform: (): Promise<NodeJS.Platform> => ipcRenderer.invoke('app:platform'),+ /** Synchronous platform, so chrome (drag padding, window controls) renders right on first paint. */+ platform: process.platform,// Surfaces engine lifecycle in the main-process log (useful for headless checks).reportEngineStatus: (status: string): void => ipcRenderer.send('engine:status', status),+ // — Custom window controls (frameless Windows/Linux; macOS has native traffic lights) —+ win: {+ minimize: (): Promise<void> => ipcRenderer.invoke('window:minimize'),+ toggleMaximize: (): Promise<void> => ipcRenderer.invoke('window:toggleMaximize'),+ close: (): Promise<void> => ipcRenderer.invoke('window:close'),+ isMaximized: (): Promise<boolean> => ipcRenderer.invoke('window:isMaximized'),+ /** Subscribe to maximize/restore; returns an unsubscribe. */+ onMaximizeChange: (cb: (maximized: boolean) => void): (() => void) => {+ const h = (_e: unknown, maximized: boolean) => cb(maximized);+ ipcRenderer.on('window:maximized', h);+ return () => ipcRenderer.removeListener('window:maximized', h);+ },+ },+// — App lifecycle: the unsaved-changes quit guard. The renderer pushes its dirty// state so main can prompt (Save / Don't Save / Cancel) on window close; on Save// main asks the renderer to save, which confirms back when done. —diff --git a/desktop/src/layout/MenuBar.tsx b/desktop/src/layout/MenuBar.tsxindex 899a7e5be..d339cf4e6 100644--- a/desktop/src/layout/MenuBar.tsx+++ b/desktop/src/layout/MenuBar.tsx@@ -2,9 +2,11 @@// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team// Top menu bar — functional dropdowns wired to the real editor commands// (project open/save, history, entity ops, view toggles), in a classic menu idiom.-// The window is frameless (titleBarStyle: hiddenInset) so this strip doubles as-// the drag region; the menus + dropdowns opt out of dragging.+// The window is frameless (macOS: hiddenInset with native traffic lights;+// Windows/Linux: our own WindowControls), so this strip doubles as the drag+// region; the menus, dropdowns, and window controls opt out of dragging.import { useEffect, useRef, useState, useSyncExternalStore } from 'react';+import { WindowControls } from '@/layout/WindowControls';import { useEditorStore } from '@/store/editorStore';import { ProjectStore } from '@/project/ProjectStore';import { EditorHistory } from '@/engine/EditorHistory';@@ -209,6 +211,7 @@ export function MenuBar() {{dirty && <span className="dirty" title="Unsaved changes">●</span>}</div>) : null}+ <WindowControls /></div>);}diff --git a/desktop/src/layout/WindowControls.tsx b/desktop/src/layout/WindowControls.tsxnew file mode 100644index 000000000..44e2a10b7--- /dev/null+++ b/desktop/src/layout/WindowControls.tsx@@ -0,0 +1,42 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file WindowControls.tsx — custom minimize / maximize / close for the frameless+ * Windows & Linux window. macOS uses its native traffic lights, so this+ * renders nothing there. Sits at the right of the title bar and opts out of+ * the drag region so the buttons are clickable.+ */+import { useEffect, useState } from 'react';+import { Minus, Square, Copy, X } from 'lucide-react';++export function WindowControls() {+ const win = window.estella?.win;+ const [maximized, setMaximized] = useState(false);++ useEffect(() => {+ if (!win) return;+ void win.isMaximized().then(setMaximized);+ return win.onMaximizeChange(setMaximized);+ }, [win]);++ // macOS has native traffic lights; nothing to draw there (or without the bridge).+ if (!win || window.estella?.platform === 'darwin') return null;++ return (+ <div className="winctl">+ <button className="winctl__btn" title="Minimize" onClick={() => void win.minimize()}>+ <Minus size={15} strokeWidth={1.8} />+ </button>+ <button+ className="winctl__btn"+ title={maximized ? 'Restore' : 'Maximize'}+ onClick={() => void win.toggleMaximize()}+ >+ {maximized ? <Copy size={12} strokeWidth={1.8} /> : <Square size={12} strokeWidth={1.8} />}+ </button>+ <button className="winctl__btn winctl__btn--close" title="Close" onClick={() => void win.close()}>+ <X size={16} strokeWidth={1.8} />+ </button>+ </div>+ );+}diff --git a/desktop/src/main.tsx b/desktop/src/main.tsxindex 7224b27d3..78c7447b2 100644--- a/desktop/src/main.tsx+++ b/desktop/src/main.tsx@@ -59,6 +59,13 @@ if (new URLSearchParams(location.search).has('automation')) {};}+// Tag the OS so the title bar renders the right chrome on first paint (macOS+// reserves space for the native traffic lights; Windows/Linux draw our controls).+const plat = window.estella?.platform;+document.documentElement.classList.add(+ plat === 'darwin' ? 'platform-mac' : plat === 'win32' ? 'platform-win' : 'platform-linux',+);+createRoot(document.getElementById('root')!).render(<StrictMode><App />diff --git a/desktop/src/theme/chrome.css b/desktop/src/theme/chrome.cssindex 399a27ea1..2696e1715 100644--- a/desktop/src/theme/chrome.css+++ b/desktop/src/theme/chrome.css@@ -43,6 +43,24 @@.menubar-title .sep { opacity: 0.5; }.menubar-title .dirty { color: var(--sel); font-size: 0.7em; line-height: 1; margin-left: -2px; }+/* The 72px traffic-light gutter is macOS-only; Windows/Linux draw their own+ controls, so reclaim the left edge and let the controls reach the right corner. */+.platform-win .menubar,+.platform-linux .menubar { padding-left: 0; padding-right: 0; }++/* ── Custom window controls (frameless Windows/Linux; macOS = native traffic lights) ── */+.winctl { display: flex; align-items: stretch; height: 100%; margin-left: 6px; -webkit-app-region: no-drag; }+.winctl__btn {+ width: 46px;+ height: 100%;+ display: grid;+ place-items: center;+ color: var(--text-mute);+ transition: color var(--t-fast), background var(--t-fast);+}+.winctl__btn:hover { color: var(--text); background: var(--srf-3); }+.winctl__btn--close:hover { color: #fff; background: var(--error); }+/* ── Toolbar (modes left · play center · actions right) ── */.toolbar {height: var(--h-toolbar);