make WindowResizeDelta dumb

This commit is contained in:
Eon S. Jeon 2019-12-21 21:35:07 +09:00
parent c134e60fcd
commit f119d47a4e
3 changed files with 17 additions and 14 deletions

View File

@ -19,23 +19,26 @@
// DEALINGS IN THE SOFTWARE.
class WindowResizeDelta {
public readonly diff: Rect;
public readonly east: number;
public readonly west: number;
public readonly south: number;
public readonly north: number;
public static fromWindow(window: Window): WindowResizeDelta {
const diff = window.actualGeometry.subtract(window.geometry);
return new WindowResizeDelta(
diff.width + diff.x,
-diff.x,
diff.height + diff.y,
-diff.y,
);
}
public constructor(window: Window) {
this.diff = window.actualGeometry.subtract(window.geometry);
this.east = this.diff.width + this.diff.x;
this.west = -this.diff.x;
this.south = this.diff.height + this.diff.y;
this.north = -this.diff.y;
constructor(
public readonly east: number,
public readonly west: number,
public readonly south: number,
public readonly north: number,
) {
}
public toString(): string {
return "WindowResizeDelta(" + [
"diff=" + this.diff,
"east=" + this.east,
"west=" + this.west,
"north=" + this.north,

View File

@ -43,7 +43,7 @@ class QuarterLayout implements ILayout {
if (idx < 0)
return;
const delta = new WindowResizeDelta(basis);
const delta = WindowResizeDelta.fromWindow(basis);
/* vertical split */
if ((idx === 0 || idx === 3) && delta.east !== 0)

View File

@ -44,7 +44,7 @@ class TileLayout implements ILayout {
if (idx < 0)
return;
const delta = new WindowResizeDelta(basis);
const delta = WindowResizeDelta.fromWindow(basis);
if (idx < this.numMaster) { /* master tiles */
if (delta.east !== 0) {
const newMasterWidth = Math.floor(area.width * this.masterRatio) + delta.east;