add argument delta to ILayout#adjust

Deltas are and will be used in every `adjust` implementation, and
injecting delta allows arbitrary adjustment of layout and, thus, window
size.
This commit is contained in:
Eon S. Jeon 2019-12-27 14:24:00 +09:00
parent c7fee18a10
commit 1b725d1092
5 changed files with 5 additions and 9 deletions

View File

@ -119,7 +119,7 @@ interface ILayout {
readonly enabled: boolean;
/* methods */
adjust?(area: Rect, tiles: Window[], basis: Window): void;
adjust?(area: Rect, tiles: Window[], basis: Window, delta: RectDelta): void;
apply(ctx: EngineContext, tileables: Window[], area: Rect): void;
toString(): string;

View File

@ -42,7 +42,7 @@ class TilingEngine {
fullArea.height - (CONFIG.screenGapTop + CONFIG.screenGapBottom),
);
const tiles = this.windows.getVisibleTiles(srf);
layout.adjust(area, tiles, basis);
layout.adjust(area, tiles, basis, basis.geometryDelta);
}
}

View File

@ -53,7 +53,7 @@ class ColumnLayout implements ILayout {
this.tileWeights = new LayoutWeightMap();
}
public adjust(area: Rect, tiles: Window[], basis: Window): void {
public adjust(area: Rect, tiles: Window[], basis: Window, delta: RectDelta): void {
/* TODO: make this function simpler by spliting layout-building logic into a new method */
const entry = this.tileCache[basis.id];
@ -61,7 +61,6 @@ class ColumnLayout implements ILayout {
const numColumns = this.columnMasters.length;
const [basisColumn, basisIndex] = entry;
const delta = basis.geometryDelta;
/* horizontal adjustment */
if (basisColumn === null) {

View File

@ -35,7 +35,7 @@ class QuarterLayout implements ILayout {
this.vsplit = 0.5;
}
public adjust(area: Rect, tiles: Window[], basis: Window) {
public adjust(area: Rect, tiles: Window[], basis: Window, delta: RectDelta) {
if (tiles.length <= 1 || tiles.length > 4)
return;
@ -43,8 +43,6 @@ class QuarterLayout implements ILayout {
if (idx < 0)
return;
const delta = basis.geometryDelta;
/* vertical split */
if ((idx === 0 || idx === 3) && delta.east !== 0)
this.vsplit = (Math.floor(area.width * this.vsplit) + delta.east) / area.width;

View File

@ -36,7 +36,7 @@ class TileLayout implements ILayout {
this.weights = new LayoutWeightMap();
}
public adjust(area: Rect, tiles: Window[], basis: Window) {
public adjust(area: Rect, tiles: Window[], basis: Window, delta: RectDelta) {
if (tiles.length <= this.numMaster)
return;
@ -44,7 +44,6 @@ class TileLayout implements ILayout {
if (idx < 0)
return;
const delta = basis.geometryDelta;
if (idx < this.numMaster) { /* master tiles */
if (delta.east !== 0) {
const newMasterWidth = Math.floor(area.width * this.masterRatio) + delta.east;