add shortcut and action karousel-column-expand-visible
This commit is contained in:
@@ -175,6 +175,12 @@ function initActions(world: World) {
|
||||
});
|
||||
},
|
||||
|
||||
columnExpandVisible: () => {
|
||||
const grid = world.getCurrentGrid();
|
||||
grid.expandColumnsVisible();
|
||||
grid.arrange();
|
||||
},
|
||||
|
||||
gridScrollLeft: () => {
|
||||
gridScroll(world, -world.config.manualScrollStep);
|
||||
},
|
||||
|
||||
@@ -114,6 +114,31 @@ class Grid {
|
||||
return last;
|
||||
}
|
||||
|
||||
expandColumnsVisible() {
|
||||
const startColumn = this.getLeftmostVisibleColumn(true);
|
||||
const endColumn = this.getRightmostVisibleColumn(true);
|
||||
if (startColumn === null || endColumn === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const startX = startColumn.gridX;
|
||||
const endX = endColumn.gridX + endColumn.width;
|
||||
const width = endX - startX;
|
||||
const scaleRatio = this.tilingArea.width / width;
|
||||
let remainingWidth = this.tilingArea.width;
|
||||
|
||||
for (const column of this.columns.iteratorFrom(startColumn)) {
|
||||
if (column !== endColumn) {
|
||||
const newWidth = Math.round(column.width * scaleRatio);
|
||||
column.setWidth(newWidth, true);
|
||||
remainingWidth -= newWidth + this.world.config.gapsInnerHorizontal;
|
||||
} else {
|
||||
column.setWidth(remainingWidth, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scrollToColumn(column: Column) {
|
||||
const left = column.gridX - this.scrollX; // in screen space
|
||||
const right = left + column.width; // in screen space
|
||||
|
||||
@@ -45,6 +45,7 @@ function registerShortcuts(world: World) {
|
||||
registerShortcutDbg("karousel-column-move-start", "Karousel: Move column to start", "Meta+Ctrl+Shift+Home", actions.columnMoveStart);
|
||||
registerShortcutDbg("karousel-column-move-end", "Karousel: Move column to end", "Meta+Ctrl+Shift+End", actions.columnMoveEnd);
|
||||
registerShortcutDbg("karousel-column-expand", "Karousel: Expand column", "Meta+Ctrl+X", actions.columnExpand);
|
||||
registerShortcutDbg("karousel-column-expand-visible", "Karousel: Expand visible columns", "Meta+Ctrl+Alt+X", actions.columnExpandVisible)
|
||||
|
||||
registerShortcutDbg("karousel-grid-scroll-focused", "Karousel: Scroll to focused window", "Meta+Alt+Return", actions.gridScrollFocused);
|
||||
registerShortcutDbg("karousel-grid-scroll-left-column", "Karousel: Scroll one column to the left", "Meta+Alt+A", actions.gridScrollLeftColumn);
|
||||
|
||||
Reference in New Issue
Block a user