Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
348 changes: 308 additions & 40 deletions src/web/src/grid-layout.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/web/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1300,9 +1300,10 @@ app.syncLayoutSize = syncLayoutSize;

window.addEventListener('resize', syncLayoutSize);

// Focus a component tab, or re-create it if it was closed.
function focusComponent(componentType) {
app.goldenLayout.focusComponent(componentType);
// Focus a component tab, or re-create it if it was closed. `options.reveal`
// also restores a maximized pane that hides it (see GridLayoutManager).
function focusComponent(componentType, options) {
app.goldenLayout.focusComponent(componentType, options);
}

app.focusComponent = focusComponent;
Expand Down
32 changes: 18 additions & 14 deletions src/web/src/menu-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export function eventShortcut(e) {
// Builds the bar and returns nothing; call app.rebuildMenuBar() after
// updating app.customMenu to re-render live.
export function createMenuBar(app) {
// Picking a window from a menu must show it, even behind a maximized pane.
const show = (componentType) =>
() => app.focusComponent(componentType, { reveal: true });

const staticMenus = [
{ label: 'File', items: [
{ label: 'Open DB...', action: () => showPathDialog(app, 'Open DB', 'read_db'),
Expand Down Expand Up @@ -135,24 +139,24 @@ export function createMenuBar(app) {
enabledWhen: () => !!app.designScale },
]},
{ label: 'Windows', items: [
{ label: 'Layout Viewer', action: () => app.focusComponent('LayoutViewer') },
{ label: '3D Viewer', action: () => app.focusComponent('3DViewer') },
{ label: 'Display Controls', action: () => app.focusComponent('DisplayControls') },
{ label: 'Inspector', action: () => app.focusComponent('Inspector') },
{ label: 'Selection Browser',
action: () => app.focusComponent('SelectHighlight') },
{ label: 'Tcl Console', action: () => app.focusComponent('TclConsole') },
{ label: 'Hierarchy Browser', action: () => app.focusComponent('Browser') },
{ label: 'Timing', action: () => app.focusComponent('TimingWidget') },
{ label: 'DRC Viewer', action: () => app.focusComponent('DRCWidget') },
{ label: 'Clock Tree', action: () => app.focusComponent('ClockWidget') },
{ label: 'Charts', action: () => app.focusComponent('ChartsWidget') },
{ label: 'Help', action: () => app.focusComponent('HelpWidget') },
{ label: 'Layout Viewer', action: show('LayoutViewer') },
{ label: 'Schematic', action: show('SchematicWidget') },
{ label: '3D Viewer', action: show('3DViewer') },
{ label: 'Display Controls', action: show('DisplayControls') },
{ label: 'Inspector', action: show('Inspector') },
{ label: 'Selection Browser', action: show('SelectHighlight') },
{ label: 'Tcl Console', action: show('TclConsole') },
{ label: 'Hierarchy Browser', action: show('Browser') },
{ label: 'Timing', action: show('TimingWidget') },
{ label: 'DRC Viewer', action: show('DRCWidget') },
{ label: 'Clock Tree', action: show('ClockWidget') },
{ label: 'Charts', action: show('ChartsWidget') },
{ label: 'Help', action: show('HelpWidget') },
{ type: 'separator' },
{ label: 'Reset to Default Layout', action: () => app.resetLayout() },
]},
{ label: 'Help', items: [
{ label: 'Keyboard Shortcuts', action: () => app.focusComponent('HelpWidget') },
{ label: 'Keyboard Shortcuts', action: show('HelpWidget') },
]},
];

Expand Down
24 changes: 18 additions & 6 deletions src/web/src/schematic-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class SchematicWidget {
this.container.element.appendChild(this.element);

// Button listeners
this.controls.querySelector('#schematic-refresh').addEventListener('click', () => this.refresh());
this.controls.querySelector('#schematic-refresh').addEventListener('click', () => this._onRefresh());
this.controls.querySelector('#schematic-back').addEventListener('click', () => this._goBackSchematic());
this.controls.querySelector('#schematic-fit').addEventListener('click', () => this.fitView());
this.controls.querySelector('#schematic-zoom-in').addEventListener('click', () => this._zoomStep(1.5));
Expand Down Expand Up @@ -278,6 +278,8 @@ export class SchematicWidget {
return {
netlist: this._currentNetlist,
selectedInstanceName: this.appState.selectedInstanceName || null,
// The instance Refresh redraws while this view is shown.
instName: this._instName,
};
}

Expand Down Expand Up @@ -332,6 +334,7 @@ export class SchematicWidget {
}
this._setBackButtonEnabled();
this._leaveTimingSchematic();
this._instName = snapshot.instName;
if (!snapshot.selectedInstanceName) {
return true;
}
Expand Down Expand Up @@ -466,7 +469,7 @@ export class SchematicWidget {
if (load === 'path') {
this._loadPathSchematic(++this._timingRequestId);
} else if (load === 'refresh') {
this.refresh();
this._onRefresh();
}
}

Expand Down Expand Up @@ -971,22 +974,30 @@ export class SchematicWidget {
};
apply(faninEl, detail.fanin, detail.fanin_depth);
apply(fanoutEl, detail.fanout, detail.fanout_depth);
this.refresh();
// The cone's instance, which a path pin picks without selecting it.
this.refresh(detail.inst_name);
// Applying with "sync schematic" asks to see it, past a maximized pane.
if (this.appState.focusComponent) {
this.appState.focusComponent('SchematicWidget');
this.appState.focusComponent('SchematicWidget', { reveal: true });
}
}

// ── Refresh ──────────────────────────────────────────────────────────────

// Redraws the instance last asked for, including one a timing cone picked
// without selecting it.
_onRefresh() {
return this.refresh(this._instName);
}

// Resolve to whether a schematic was drawn so callers can sequence updates.
async refresh() {
async refresh(instName = this.appState.selectedInstanceName) {
this._instName = instName;
if (!this._netlistsvgReady) {
this.setStatus(this._unreadyStatus());
return false;
}

const instName = this.appState.selectedInstanceName;
if (!instName) {
this.setStatus(kIdleStatus);
return false;
Expand Down Expand Up @@ -1084,6 +1095,7 @@ export class SchematicWidget {
// Record Back history only after expansion renders.
this._pushSchematicHistory(previousSnapshot);
this._leaveTimingSchematic();
this._instName = instName;
return true;
} catch (err) {
if (isCurrent()) this.setStatus(`Error: ${err}`);
Expand Down
42 changes: 30 additions & 12 deletions src/web/src/timing-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export class TimingWidget {
this._selectedPathIndex = -1;
this._detailTab = 'data';
this._selectedDetailIndex = -1;
// app.selectionToken when a path row was last picked (_coneTarget).
this._rowSelectionToken = null;
// Default to sorting by slack, matching the Qt GUI.
this._sortCol = 'slack';
this._sortAscending = true;
Expand Down Expand Up @@ -310,7 +312,7 @@ export class TimingWidget {
this._coneApplyBtn = document.createElement('button');
this._coneApplyBtn.className = 'or-btn';
this._coneApplyBtn.textContent = 'Cone';
this._coneApplyBtn.title = 'Show the timing cone for the selected instance';
this._coneApplyBtn.title = 'Show the timing cone for the selected path pin or instance';
this._coneClearBtn = document.createElement('button');
this._coneClearBtn.className = 'or-btn';
this._coneClearBtn.textContent = 'Clear';
Expand All @@ -326,11 +328,19 @@ export class TimingWidget {
return panel;
}

// The cone target: the currently selected instance. (The backend also
// accepts pin_name for a future per-pin cone, but the web UI has no pin
// selection yet, so we always target the instance.)
// The cone target: the pin of the path row picked last, unless any selection
// (layout, Inspector, Charts…) came after it; else the selected instance.
// The backend prefers pin_name and falls back to inst_name.
_coneTarget() {
return this._app.selectedInstanceName || '';
const row = this._detailRows?.[this._selectedDetailIndex];
const node = row && this._detailNodes[row.node];
const inst = this._app.selectedInstanceName || '';
if (node?.pin && this._app.selectionToken === this._rowSelectionToken) {
// A port's inst is empty; its name alone can't tell (3DBlox
// prefixes a chiplet port with its chip-inst).
return { pin: node.pin, inst: node.inst || '' };
}
return { pin: '', inst };
}

async _applyCone() {
Expand All @@ -340,9 +350,9 @@ export class TimingWidget {
this._coneStatus.textContent = 'select fanin and/or fanout';
return;
}
const inst = this._coneTarget();
if (!inst) {
this._coneStatus.textContent = 'select an instance first';
const { pin, inst } = this._coneTarget();
if (!pin && !inst) {
this._coneStatus.textContent = 'select an instance or a path pin first';
return;
}
const req = {
Expand All @@ -354,6 +364,7 @@ export class TimingWidget {
color_mode: this._coneColorMode.value,
inst_name: inst,
};
if (pin) req.pin_name = pin;
this._coneApplyBtn.disabled = true;
this._coneStatus.textContent = 'computing…';
try {
Expand Down Expand Up @@ -701,24 +712,31 @@ export class TimingWidget {
rows[idx].classList.add('timing-selected-row');
rows[idx].scrollIntoView({ block: 'nearest' });
this._detailTableContainer.focus();
this._rowSelectionToken = this._app.selectionToken;

const paths = this._currentTab === 'setup' ? this._setupPaths : this._holdPaths;
const path = paths[this._selectedPathIndex];
const nodes = this._detailTab === 'data' ? path.data_nodes : path.capture_nodes;
const node = nodes[this._detailRows[idx].node];
const node = this._detailNodes[this._detailRows[idx].node];
this._app.websocketManager.request(this._highlightRequest(
path, this._selectedPathIndex, { pin_name: node.pin }))
.then(() => this._refreshOverlay());
}

// The nodes the detail table shows: the selected path's data or capture side.
get _detailNodes() {
const paths = this._currentTab === 'setup' ? this._setupPaths : this._holdPaths;
const path = paths[this._selectedPathIndex];
if (!path) return [];
return (this._detailTab === 'data' ? path.data_nodes : path.capture_nodes) || [];
}

_renderDetailTable() {
this._detailTable.innerHTML = '';
this._selectedDetailIndex = -1;
const paths = this._currentTab === 'setup' ? this._setupPaths : this._holdPaths;
if (this._selectedPathIndex < 0 || this._selectedPathIndex >= paths.length) return;

const path = paths[this._selectedPathIndex];
const nodes = this._detailTab === 'data' ? path.data_nodes : path.capture_nodes;
const nodes = this._detailNodes;

const thead = document.createElement('thead');
const hr = document.createElement('tr');
Expand Down
10 changes: 6 additions & 4 deletions src/web/src/ui-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ export function installWheelPanning(map, wheelZoomEnabled) {
map.getContainer().addEventListener('wheel', (e) => {
e.preventDefault();
if (wheelZoomEnabled() === e.ctrlKey) {
const [dx, dy] = wheelDeltaPx(e, map.getContainer());
const [dx, dy] = wheelDeltaPx(e, () => map.getContainer().clientHeight);
map.panBy([dx, dy], { animate: false });
return;
}
Expand All @@ -830,14 +830,16 @@ export function installWheelPanning(map, wheelZoomEnabled) {
// A wheel event's scroll amount in CSS pixels. deltaMode is not always pixels:
// Firefox reports lines, and a page-mode event (rare, but produced by some
// remote-desktop stacks) means a viewport at a time. Treating either as pixels
// would make one notch pan by a couple of pixels.
function wheelDeltaPx(e, container) {
// would make one notch pan by a couple of pixels. `pagePx()` gives the
// viewport's size along the direction the caller scrolls; it is called only
// for page-mode events, keeping the layout read off the common path.
export function wheelDeltaPx(e, pagePx) {
const kLineHeightPx = 16;
let scale = 1;
if (e.deltaMode === 1) {
scale = kLineHeightPx;
} else if (e.deltaMode === 2) {
scale = container.clientHeight || kLineHeightPx;
scale = pagePx() || kLineHeightPx;
}
return [e.deltaX * scale, e.deltaY * scale];
}
Comment on lines +836 to 845

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The signature of wheelDeltaPx has been changed from accepting a DOM element (container) to a function (pagePx). Since wheelDeltaPx is an exported utility function, this breaking change could cause runtime errors (TypeError: pagePx is not a function) if other modules or external plugins call it using the old signature. Making it backward-compatible by checking the type of pagePx ensures robustness and prevents crashes.

Suggested change
export function wheelDeltaPx(e, pagePx) {
const kLineHeightPx = 16;
let scale = 1;
if (e.deltaMode === 1) {
scale = kLineHeightPx;
} else if (e.deltaMode === 2) {
scale = container.clientHeight || kLineHeightPx;
scale = pagePx() || kLineHeightPx;
}
return [e.deltaX * scale, e.deltaY * scale];
}
export function wheelDeltaPx(e, pagePx) {
const kLineHeightPx = 16;
let scale = 1;
if (e.deltaMode === 1) {
scale = kLineHeightPx;
} else if (e.deltaMode === 2) {
scale = (typeof pagePx === 'function' ? pagePx() : pagePx?.clientHeight) || kLineHeightPx;
}
return [e.deltaX * scale, e.deltaY * scale];
}

Expand Down
Loading
Loading