Add "Increase column width to maximum/minimum" actions (#148)
The width is set to the maximum/minimum of preset widths.
This commit is contained in:
@@ -86,4 +86,22 @@ class ContextualResizer {
|
||||
column.setWidth(newWidth, true);
|
||||
desktop.scrollCenterVisible(column);
|
||||
}
|
||||
|
||||
public maximizeWidth(column: Column) {
|
||||
const grid = column.grid;
|
||||
const desktop = grid.desktop;
|
||||
const presetWidths = this.presetWidths.getWidths(column.getMinWidth(), column.getMaxWidth());
|
||||
const maxWidth = presetWidths[presetWidths.length-1];
|
||||
column.setWidth(maxWidth, true);
|
||||
desktop.scrollCenterVisible(column);
|
||||
}
|
||||
|
||||
public minimizeWidth(column: Column) {
|
||||
const grid = column.grid;
|
||||
const desktop = grid.desktop;
|
||||
const presetWidths = this.presetWidths.getWidths(column.getMinWidth(), column.getMaxWidth());
|
||||
const minWidth = presetWidths[0];
|
||||
column.setWidth(minWidth, true);
|
||||
desktop.scrollCenterVisible(column);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,4 +28,16 @@ class RawResizer {
|
||||
}
|
||||
column.setWidth(newWidth, true);
|
||||
}
|
||||
|
||||
public maximizeWidth(column: Column) {
|
||||
const presetWidths = this.presetWidths.getWidths(column.getMinWidth(), column.getMaxWidth());
|
||||
const maxWidth = presetWidths[presetWidths.length-1];
|
||||
column.setWidth(maxWidth, true);
|
||||
}
|
||||
|
||||
public minimizeWidth(column: Column) {
|
||||
const presetWidths = this.presetWidths.getWidths(column.getMinWidth(), column.getMaxWidth());
|
||||
const minWidth = presetWidths[0];
|
||||
column.setWidth(minWidth, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,6 +192,15 @@ class Actions {
|
||||
this.config.columnResizer.decreaseWidth(column);
|
||||
};
|
||||
|
||||
public readonly columnWidthMaximize = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||
this.config.columnResizer.maximizeWidth(column);
|
||||
};
|
||||
|
||||
|
||||
public readonly columnWidthMinimize = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||
this.config.columnResizer.minimizeWidth(column);
|
||||
};
|
||||
|
||||
public readonly cyclePresetWidths = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||
const nextWidth = this.config.presetWidths.next(column.getWidth(), column.getMinWidth(), column.getMaxWidth());
|
||||
column.setWidth(nextWidth, true);
|
||||
@@ -471,5 +480,7 @@ namespace Actions {
|
||||
export interface ColumnResizer {
|
||||
increaseWidth(column: Column): void;
|
||||
decreaseWidth(column: Column): void;
|
||||
maximizeWidth(column: Column): void;
|
||||
minimizeWidth(column: Column): void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,6 +146,16 @@ function getKeyBindings(world: World, actions: Actions): KeyBinding[] {
|
||||
defaultKeySequence: "Meta+Ctrl+-",
|
||||
action: () => world.doIfTiledFocused(actions.columnWidthDecrease),
|
||||
},
|
||||
{
|
||||
name: "column-width-maximize",
|
||||
description: "Increase column width to maximum",
|
||||
action: () => world.doIfTiledFocused(actions.columnWidthMaximize),
|
||||
},
|
||||
{
|
||||
name: "column-width-minimize",
|
||||
description: "Decrease column width to minimum",
|
||||
action: () => world.doIfTiledFocused(actions.columnWidthMinimize),
|
||||
},
|
||||
{
|
||||
name: "cycle-preset-widths",
|
||||
description: "Cycle through preset column widths",
|
||||
|
||||
Reference in New Issue
Block a user