feat: multi-material overlays, presentation guides, and release prebuilds

Align control/presentation with presentation screen rect and darkness z-order; sync window titles and session window cleanup. Pack Win/Mac/Linux with npmRebuild disabled and release-native-prep for classic-level and sharp.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ivan Fontosh
2026-08-03 11:28:18 +08:00
parent 61446dacfc
commit 2979d06f1c
41 changed files with 1060 additions and 252 deletions
+129 -47
View File
@@ -1,6 +1,7 @@
import {
clampMaterialsLayout,
DEFAULT_MATERIALS_OVERLAY_LAYOUT,
defaultLegendLayoutForMaterial,
type MaterialId,
type MaterialsOverlayEvent,
type MaterialsOverlayLayout,
@@ -12,9 +13,10 @@ import {
function emptyState(): MaterialsOverlayState {
return {
revision: 1,
activeMaterialId: null,
layout: { ...DEFAULT_MATERIALS_OVERLAY_LAYOUT },
legendLayout: { ...DEFAULT_MATERIALS_OVERLAY_LAYOUT, cx: 0.82, cy: 0.5, scale: 0.85 },
activeMaterialIds: [],
layouts: {},
legendLayouts: {},
focusMaterialId: null,
zoomTool: null,
};
}
@@ -26,14 +28,12 @@ function initialLayout(rotationDeg?: number): MaterialsOverlayLayout {
});
}
function initialLegendLayout(): MaterialsOverlayLayout {
return clampMaterialsLayout({
...DEFAULT_MATERIALS_OVERLAY_LAYOUT,
cx: 0.82,
cy: 0.5,
scale: 0.85,
rotationDeg: 0,
});
function layoutFor(state: MaterialsOverlayState, materialId: MaterialId): MaterialsOverlayLayout {
return state.layouts[materialId] ?? { ...DEFAULT_MATERIALS_OVERLAY_LAYOUT };
}
function legendLayoutFor(state: MaterialsOverlayState, materialId: MaterialId): MaterialsOverlayLayout {
return state.legendLayouts[materialId] ?? defaultLegendLayoutForMaterial();
}
export class MaterialsOverlayStore {
@@ -44,14 +44,15 @@ export class MaterialsOverlayStore {
}
clear(): MaterialsOverlayState {
if (this.state.activeMaterialId === null && this.state.zoomTool === null) {
if (this.state.activeMaterialIds.length === 0 && this.state.zoomTool === null) {
return this.state;
}
this.state = {
revision: this.state.revision + 1,
activeMaterialId: null,
layout: { ...DEFAULT_MATERIALS_OVERLAY_LAYOUT },
legendLayout: initialLegendLayout(),
activeMaterialIds: [],
layouts: {},
legendLayouts: {},
focusMaterialId: null,
zoomTool: null,
};
return this.state;
@@ -61,50 +62,98 @@ export class MaterialsOverlayStore {
switch (event.kind) {
case 'hide':
return this.clear();
case 'show':
this.state = {
revision: this.state.revision + 1,
activeMaterialId: event.materialId,
layout: initialLayout(event.rotationDeg),
legendLayout: initialLegendLayout(),
zoomTool: this.state.zoomTool,
};
return this.state;
case 'toggle': {
if (this.state.activeMaterialId === event.materialId) {
return this.clear();
case 'show': {
if (this.state.activeMaterialIds.includes(event.materialId)) {
this.state = {
...this.state,
revision: this.state.revision + 1,
focusMaterialId: event.materialId,
};
return this.state;
}
this.state = {
revision: this.state.revision + 1,
activeMaterialId: event.materialId,
layout: initialLayout(event.rotationDeg),
legendLayout: initialLegendLayout(),
activeMaterialIds: [...this.state.activeMaterialIds, event.materialId],
layouts: {
...this.state.layouts,
[event.materialId]: initialLayout(event.rotationDeg),
},
legendLayouts: {
...this.state.legendLayouts,
[event.materialId]: defaultLegendLayoutForMaterial(),
},
focusMaterialId: event.materialId,
zoomTool: this.state.zoomTool,
};
return this.state;
}
case 'toggle': {
if (this.state.activeMaterialIds.includes(event.materialId)) {
const activeMaterialIds = this.state.activeMaterialIds.filter((id) => id !== event.materialId);
const layouts = { ...this.state.layouts };
const legendLayouts = { ...this.state.legendLayouts };
delete layouts[event.materialId];
delete legendLayouts[event.materialId];
const focusMaterialId =
this.state.focusMaterialId === event.materialId
? (activeMaterialIds[activeMaterialIds.length - 1] ?? null)
: this.state.focusMaterialId;
this.state = {
revision: this.state.revision + 1,
activeMaterialIds,
layouts,
legendLayouts,
focusMaterialId,
zoomTool: activeMaterialIds.length === 0 ? null : this.state.zoomTool,
};
return this.state;
}
this.state = {
revision: this.state.revision + 1,
activeMaterialIds: [...this.state.activeMaterialIds, event.materialId],
layouts: {
...this.state.layouts,
[event.materialId]: initialLayout(event.rotationDeg),
},
legendLayouts: {
...this.state.legendLayouts,
[event.materialId]: defaultLegendLayoutForMaterial(),
},
focusMaterialId: event.materialId,
zoomTool: this.state.zoomTool,
};
return this.state;
}
case 'layout.set': {
if (this.state.activeMaterialId === null) return this.state;
if (!this.state.activeMaterialIds.includes(event.materialId)) return this.state;
this.state = {
...this.state,
revision: this.state.revision + 1,
layout: clampMaterialsLayout({
...this.state.layout,
...event.layout,
}),
focusMaterialId: event.materialId,
layouts: {
...this.state.layouts,
[event.materialId]: clampMaterialsLayout({
...layoutFor(this.state, event.materialId),
...event.layout,
}),
},
};
return this.state;
}
case 'legendLayout.set': {
if (this.state.activeMaterialId === null) return this.state;
if (!this.state.activeMaterialIds.includes(event.materialId)) return this.state;
this.state = {
...this.state,
revision: this.state.revision + 1,
legendLayout: clampMaterialsLayout({
...this.state.legendLayout,
...event.layout,
rotationDeg: 0,
}),
focusMaterialId: event.materialId,
legendLayouts: {
...this.state.legendLayouts,
[event.materialId]: clampMaterialsLayout({
...legendLayoutFor(this.state, event.materialId),
...event.layout,
rotationDeg: 0,
}),
},
};
return this.state;
}
@@ -118,10 +167,18 @@ export class MaterialsOverlayStore {
return this.state;
}
case 'zoomAt': {
if (this.state.activeMaterialId === null || !this.state.zoomTool) return this.state;
if (this.state.activeMaterialIds.length === 0 || !this.state.zoomTool) return this.state;
const targetId =
(event.materialId && this.state.activeMaterialIds.includes(event.materialId)
? event.materialId
: null) ??
this.state.focusMaterialId ??
this.state.activeMaterialIds[this.state.activeMaterialIds.length - 1] ??
null;
if (!targetId) return this.state;
const factor = this.state.zoomTool === 'zoomIn' ? 1.25 : 1 / 1.25;
const layout: MaterialsOverlayLayout = zoomMaterialsLayoutAt(
this.state.layout,
layoutFor(this.state, targetId),
event.nx,
event.ny,
factor,
@@ -129,7 +186,11 @@ export class MaterialsOverlayStore {
this.state = {
...this.state,
revision: this.state.revision + 1,
layout,
focusMaterialId: targetId,
layouts: {
...this.state.layouts,
[targetId]: layout,
},
};
return this.state;
}
@@ -139,8 +200,29 @@ export class MaterialsOverlayStore {
}
ensureMaterialStillExists(materialIds: ReadonlySet<MaterialId>): MaterialsOverlayState {
const active = this.state.activeMaterialId;
if (active === null || materialIds.has(active)) return this.state;
return this.clear();
const activeMaterialIds = this.state.activeMaterialIds.filter((id) => materialIds.has(id));
if (activeMaterialIds.length === this.state.activeMaterialIds.length) return this.state;
if (activeMaterialIds.length === 0) return this.clear();
const layouts: Record<string, MaterialsOverlayLayout> = {};
const legendLayouts: Record<string, MaterialsOverlayLayout> = {};
for (const id of activeMaterialIds) {
const layout = this.state.layouts[id];
if (layout) layouts[id] = layout;
const legend = this.state.legendLayouts[id];
if (legend) legendLayouts[id] = legend;
}
const focusMaterialId =
this.state.focusMaterialId && activeMaterialIds.includes(this.state.focusMaterialId)
? this.state.focusMaterialId
: (activeMaterialIds[activeMaterialIds.length - 1] ?? null);
this.state = {
revision: this.state.revision + 1,
activeMaterialIds,
layouts,
legendLayouts,
focusMaterialId,
zoomTool: this.state.zoomTool,
};
return this.state;
}
}