move user width resize logic to Column.onUserResizeWidth

This commit is contained in:
Peter Fajdiga
2024-10-13 20:04:27 +02:00
parent 92144e8e83
commit 9dafb92f47
2 changed files with 22 additions and 12 deletions

View File

@@ -133,6 +133,27 @@ class Column {
return this.gridX + this.width;
}
public onUserResizeWidth(
startWidth: number,
currentDelta: number,
resizingLeftSide: boolean,
neighbor?: { column: Column, startWidth: number },
) {
const oldColumnWidth = this.getWidth();
this.setWidth(startWidth + currentDelta, true);
const actualDelta = this.getWidth() - startWidth;
let leftEdgeDeltaStep = resizingLeftSide ? oldColumnWidth - this.getWidth() : 0;
if (neighbor !== undefined) {
const oldNeighborWidth = neighbor.column.getWidth();
neighbor.column.setWidth(neighbor.startWidth - actualDelta, true);
if (resizingLeftSide) {
leftEdgeDeltaStep -= neighbor.column.getWidth() - oldNeighborWidth;
}
}
this.grid.desktop.adjustScroll(-leftEdgeDeltaStep, true);
}
public adjustWindowHeight(window: Window, heightDelta: number, top: boolean) {
const otherWindow = top ? this.windows.getPrev(window) : this.windows.getNext(window);
if (otherWindow === null) {

View File

@@ -118,18 +118,7 @@ class Window {
if (widthDelta !== 0) {
const resizingLeftSide = newGeometry.left !== oldGeometry.left;
let widthDeltaTotal = newGeometry.width - startWidth;
const oldColumnWidth = this.column.getWidth();
this.column.setWidth(startWidth + widthDeltaTotal, true);
widthDeltaTotal = this.column.getWidth() - startWidth;
let leftEdgeDelta = resizingLeftSide ? oldColumnWidth - this.column.getWidth() : 0;
if (neighbor !== undefined) {
const oldNeighborWidth = neighbor.column.getWidth();
neighbor.column.setWidth(neighbor.startWidth - widthDeltaTotal, true);
if (resizingLeftSide) {
leftEdgeDelta -= neighbor.column.getWidth() - oldNeighborWidth;
}
}
this.column.grid.desktop.adjustScroll(-leftEdgeDelta, true);
this.column.onUserResizeWidth(startWidth, widthDeltaTotal, resizingLeftSide, neighbor);
}
if (heightDelta !== 0) {
this.column.adjustWindowHeight(this, heightDelta, newGeometry.y !== oldGeometry.y);