Bug #14527
openWGridLayout with re-sizable row/column has inconsistent handling of RESIZE_HANDLE_MARGIN
0%
Description
When a WGridLayout has any row (or column) marked resizable via setRowResizable() / setColumnResizable(), the layout reserves more total margin in its measure pass than its position pass actually consumes.
Each resize handle leaks RESIZE_HANDLE_MARGIN (= 5 px) of space, which manifests as a gap between the last cell and the layout container's trailing edge.
In src/js/StdGridLayoutImpl2.js:
Around line 783, each resizable row gets 2 * RESIZE_HANDLE_MARGIN margin reserved for not-the-first-row, eg.
totalMargin += DC.margins[SPACING];
if (rh) {
totalMargin += RESIZE_HANDLE_MARGIN * 2; // 10 px
}
But in the position pass, around line 1494:
if (resizeHandle) {
...
left += DC.margins[SPACING] / 2;
setCss(handle, DC.left, left + "px");
left += RESIZE_HANDLE_MARGIN;
}
...
else if (resizeHandle) {
left += DC.margins[SPACING] / 2; // 2.5
}
This results in an extra RESIZE_HANDLE_MARGIN after the last element.
I think just changing totalMargin += RESIZE_HANDLE_MARGIN * 2; to totalMargin += RESIZE_HANDLE_MARGIN; should fix this - and I think the column logic would need a similar fixup.
For the meantime, this can be compensated for by setting a wtGetPS JS member of the layout container, of:
container->setJavaScriptMember( "wtGetPS",
"function(c,w,d,r){"
"if(d!==1)return 0;"
"return -5 * w.querySelectorAll(':scope > .Wt-hrh2').length;"
"}" );
(.Wt-vrh2 for the horizontal-direction case.)
Updated by Romain Mardulyn 2 days ago
- Status changed from InProgress to Review
- Assignee deleted (
Romain Mardulyn)