Skip to content

Commit 1c5b861

Browse files
authored
Merge pull request #11858 from oharboe/web-table-columns
web: widening a table column widens the table (Qt parity)
2 parents fe21127 + d7e0437 commit 1c5b861

10 files changed

Lines changed: 465 additions & 55 deletions

‎src/web/src/hierarchy-browser.js‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
// Hierarchy browser widget — module tree with coloring.
55

66
import { CheckboxTreeModel } from './checkbox-tree-model.js';
7-
import { isStaticMode, makeResizableHeaders } from './ui-utils.js';
7+
import { ColumnWidths, isStaticMode, makeResizableHeaders }
8+
from './ui-utils.js';
89

910
const COLS = [
1011
'Instance', 'Module', 'Instances', 'Macros', 'Modules',
@@ -31,6 +32,7 @@ export class HierarchyBrowser {
3132
this._nameGrouped = false; // tree synthesized from instance names
3233
this._nameGroupsCapped = false;
3334
this._rows = []; // DFS-ordered rows with depth
35+
this._columns = new ColumnWidths();
3436
this._childrenMap = new Map(); // id → [child ids]
3537
this._collapsed = new Set(); // collapsed node ids
3638

@@ -101,6 +103,7 @@ export class HierarchyBrowser {
101103
this._nameGrouped = !!data.name_grouped;
102104
this._nameGroupsCapped = !!data.name_groups_capped;
103105
this._buildTree();
106+
this._columns.reset();
104107
this._readServerColors();
105108
this._computeEffectiveColors();
106109
this._render();
@@ -405,7 +408,7 @@ export class HierarchyBrowser {
405408
}
406409

407410
this._table.appendChild(tbody);
408-
makeResizableHeaders(this._table);
411+
makeResizableHeaders(this._table, this._columns);
409412
}
410413

411414
_isHidden(node) {

‎src/web/src/selection-browser.js‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@
88
// rows without mapToSource and mis-target under sorting).
99

1010
import { dbuRectToBounds } from './coordinates.js';
11-
import { isStaticMode, makeResizableHeaders } from './ui-utils.js';
11+
import { ColumnWidths, isStaticMode, makeResizableHeaders }
12+
from './ui-utils.js';
1213

1314
export class SelectionBrowser {
1415
constructor(container, app, refreshOverlay) {
1516
this._app = app;
1617
this._refreshOverlay = refreshOverlay || (() => {});
1718
this._data = { selection: [], groups: [], truncated: false };
1819
this._tab = 'selected';
20+
// the tabs have different columns; each keeps its own widths
21+
this._columns = {
22+
selected: new ColumnWidths(),
23+
highlighted: new ColumnWidths(),
24+
};
1925
this._filter = '';
2026
this._sortKey = null; // 'name' | 'type' | null (fetch order)
2127
this._sortAsc = true;
@@ -88,6 +94,7 @@ export class SelectionBrowser {
8894
.then((data) => {
8995
if (data.ok) {
9096
this._data = data;
97+
Object.values(this._columns).forEach((c) => c.reset());
9198
this._render();
9299
}
93100
settle();
@@ -388,6 +395,6 @@ export class SelectionBrowser {
388395
}
389396
table.appendChild(tbody);
390397
this._tableWrap.appendChild(table);
391-
makeResizableHeaders(table);
398+
makeResizableHeaders(table, this._columns[this._tab]);
392399
}
393400
}

‎src/web/src/style.css‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2543,13 +2543,13 @@ body.is-resizing-h * {
25432543

25442544
.timing-path-table-container {
25452545
flex: 1;
2546-
overflow-y: auto;
2546+
overflow: auto;
25472547
min-height: 80px;
25482548
}
25492549

25502550
.timing-detail-table-container {
25512551
flex: 1;
2552-
overflow-y: auto;
2552+
overflow: auto;
25532553
min-height: 80px;
25542554
border-top: 1px solid var(--border);
25552555
}
@@ -2599,6 +2599,10 @@ body.is-resizing-h * {
25992599
.timing-table tbody td {
26002600
padding: 3px var(--space-md);
26012601
white-space: nowrap;
2602+
/* a column narrower than its longest name elides it, as Qt does,
2603+
rather than writing over the next column */
2604+
overflow: hidden;
2605+
text-overflow: ellipsis;
26022606
color: var(--fg-primary);
26032607
font-family: var(--font-mono);
26042608
}
@@ -2678,12 +2682,6 @@ body.is-resizing-h * {
26782682
background: var(--col-resize);
26792683
}
26802684

2681-
.timing-table td:first-child {
2682-
white-space: normal;
2683-
word-break: break-all;
2684-
overflow-wrap: break-word;
2685-
}
2686-
26872685
/* ─── Hierarchy Browser ──────────────────────────────────────────────── */
26882686

26892687
.hierarchy-widget {
@@ -2697,7 +2695,7 @@ body.is-resizing-h * {
26972695

26982696
.hierarchy-table-container {
26992697
flex: 1;
2700-
overflow-y: auto;
2698+
overflow: auto;
27012699
min-height: 0;
27022700
}
27032701

‎src/web/src/timing-widget.js‎

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
// Timing report widget — path summary + detail tables.
55

6-
import { isStaticMode, makeResizableHeaders, withBusyCursor }
7-
from './ui-utils.js';
6+
import {
7+
ColumnWidths, isStaticMode, makeResizableHeaders, withBusyCursor,
8+
} from './ui-utils.js';
89

910
// The rows a path's detail table shows, as the Qt GUI's "Expand clock"
1011
// setting does. Collapsed (the default), the clock network -- every clock
@@ -33,6 +34,8 @@ export class TimingWidget {
3334
this._currentTab = 'setup';
3435
this._setupPaths = [];
3536
this._holdPaths = [];
37+
this._pathColumns = new ColumnWidths();
38+
this._detailColumns = new ColumnWidths();
3639
this._selectedPathIndex = -1;
3740
this._detailTab = 'data';
3841
this._selectedDetailIndex = -1;
@@ -426,13 +429,20 @@ export class TimingWidget {
426429
this._setupTab.classList.remove('active');
427430
}
428431
this._applySort();
432+
this._resetColumnWidths();
429433
this._selectedPathIndex = -1;
430434
this._pathCountLabel.textContent = paths.length + ' paths';
431435
this._renderPathTable();
432436
this._renderDetailTable();
433437
this._clearTimingHighlight();
434438
}
435439

440+
// New paths: both tables measure their columns afresh.
441+
_resetColumnWidths() {
442+
this._pathColumns.reset();
443+
this._detailColumns.reset();
444+
}
445+
436446
async update() {
437447
const generation = ++this._updateGeneration;
438448
this._updateBtn.disabled = true;
@@ -460,6 +470,7 @@ export class TimingWidget {
460470
hold: { ...reportOptions },
461471
};
462472
this._applySort();
473+
this._resetColumnWidths();
463474
this._selectedPathIndex = -1;
464475
this._renderPathTable();
465476
this._renderDetailTable();
@@ -604,10 +615,6 @@ export class TimingWidget {
604615
const paths = this._currentTab === 'setup' ? this._setupPaths : this._holdPaths;
605616
this._pathCountLabel.textContent = paths.length + ' paths';
606617

607-
// Preserve column widths across re-renders.
608-
const oldHeaders = this._pathTable.querySelectorAll('thead th');
609-
const savedWidths = Array.from(oldHeaders, th => th.style.width);
610-
611618
this._pathTable.innerHTML = '';
612619

613620
const thead = document.createElement('thead');
@@ -681,9 +688,7 @@ export class TimingWidget {
681688

682689
this._pathTable.appendChild(tbody);
683690

684-
// Install resize grips, reusing any previously saved widths to
685-
// avoid a measuring reflow.
686-
makeResizableHeaders(this._pathTable, savedWidths);
691+
makeResizableHeaders(this._pathTable, this._pathColumns);
687692
}
688693

689694
_selectDetailRow(idx) {
@@ -707,10 +712,6 @@ export class TimingWidget {
707712
}
708713

709714
_renderDetailTable() {
710-
// Preserve column widths across re-renders.
711-
const oldHeaders = this._detailTable.querySelectorAll('thead th');
712-
const savedWidths = Array.from(oldHeaders, th => th.style.width);
713-
714715
this._detailTable.innerHTML = '';
715716
this._selectedDetailIndex = -1;
716717
const paths = this._currentTab === 'setup' ? this._setupPaths : this._holdPaths;
@@ -764,16 +765,7 @@ export class TimingWidget {
764765
});
765766
this._detailTable.appendChild(tbody);
766767

767-
// Install resize grips, reusing any previously saved widths to
768-
// avoid a measuring reflow.
769-
makeResizableHeaders(this._detailTable, savedWidths);
770-
if (!savedWidths[0]) {
771-
// Pin column: set initial width to 30 characters
772-
const pinTh = this._detailTable.querySelector('thead th');
773-
if (pinTh) {
774-
pinTh.style.width = '30ch';
775-
}
776-
}
768+
makeResizableHeaders(this._detailTable, this._detailColumns);
777769
}
778770

779771
}

0 commit comments

Comments
 (0)