PresetWidths: order widths from small to large
This commit is contained in:
@@ -7,7 +7,7 @@ class PresetWidths {
|
||||
|
||||
public get(minWidth: number, maxWidth: number) {
|
||||
const widths = this.presets.map(f => clamp(f(maxWidth), minWidth, maxWidth));
|
||||
widths.sort((a, b) => b - a);
|
||||
widths.sort((a, b) => a - b);
|
||||
return uniq(widths);
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ class Actions {
|
||||
}
|
||||
const widths = this.config.presetWidths.get(column.getMinWidth(), column.getMaxWidth());
|
||||
const currentWidth = column.getWidth();
|
||||
const nextIndex = widths.findIndex(width => width < currentWidth);
|
||||
const nextIndex = widths.findIndex(width => width > currentWidth);
|
||||
const nextWidth = nextIndex >= 0 ? widths[nextIndex] : widths[0];
|
||||
column.setWidth(nextWidth, true);
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@ tests.register("Preset Widths default", 1, () => {
|
||||
workspaceMock.createWindow(kwinClient);
|
||||
Assert.equalRects(kwinClient.frameGeometry, getRect(300));
|
||||
|
||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||
Assert.equalRects(kwinClient.frameGeometry, getRect(maxWidth));
|
||||
|
||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||
Assert.equalRects(kwinClient.frameGeometry, getRect(halfWidth));
|
||||
|
||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||
Assert.equalRects(kwinClient.frameGeometry, getRect(maxWidth));
|
||||
|
||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||
Assert.equalRects(kwinClient.frameGeometry, getRect(halfWidth));
|
||||
});
|
||||
|
||||
tests.register("Preset Widths custom", 1, () => {
|
||||
@@ -48,7 +48,7 @@ tests.register("Preset Widths custom", 1, () => {
|
||||
1,
|
||||
"app1",
|
||||
"Application 1",
|
||||
new MockQmlRect(10, 20, 300, 200),
|
||||
new MockQmlRect(10, 20, 200, 200),
|
||||
);
|
||||
|
||||
function getRect(columnWidth: number) {
|
||||
@@ -61,19 +61,19 @@ tests.register("Preset Widths custom", 1, () => {
|
||||
}
|
||||
|
||||
workspaceMock.createWindow(kwinClient);
|
||||
Assert.equalRects(kwinClient.frameGeometry, getRect(300));
|
||||
Assert.equalRects(kwinClient.frameGeometry, getRect(200));
|
||||
|
||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||
Assert.equalRects(kwinClient.frameGeometry, getRect(250));
|
||||
|
||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||
Assert.equalRects(kwinClient.frameGeometry, getRect(100));
|
||||
Assert.equalRects(kwinClient.frameGeometry, getRect(halfWidth));
|
||||
|
||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||
Assert.equalRects(kwinClient.frameGeometry, getRect(500));
|
||||
|
||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||
Assert.equalRects(kwinClient.frameGeometry, getRect(halfWidth));
|
||||
Assert.equalRects(kwinClient.frameGeometry, getRect(100));
|
||||
|
||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||
Assert.equalRects(kwinClient.frameGeometry, getRect(250));
|
||||
@@ -123,7 +123,7 @@ tests.register("Preset Widths fill screen non-uniform", 1, () => {
|
||||
1,
|
||||
"app1",
|
||||
"Application 1",
|
||||
new MockQmlRect(10, 20, 300, 200),
|
||||
new MockQmlRect(10, 20, 100, 200),
|
||||
);
|
||||
workspaceMock.createWindow(clientThin1);
|
||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||
@@ -132,7 +132,7 @@ tests.register("Preset Widths fill screen non-uniform", 1, () => {
|
||||
2,
|
||||
"app2",
|
||||
"Application 2",
|
||||
new MockQmlRect(10, 20, 300, 200),
|
||||
new MockQmlRect(10, 20, 100, 200),
|
||||
);
|
||||
workspaceMock.createWindow(clientThin2);
|
||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||
@@ -141,7 +141,7 @@ tests.register("Preset Widths fill screen non-uniform", 1, () => {
|
||||
10,
|
||||
"app10",
|
||||
"Application 10",
|
||||
new MockQmlRect(10, 20, 410, 200),
|
||||
new MockQmlRect(10, 20, 300, 200),
|
||||
);
|
||||
workspaceMock.createWindow(clientWide);
|
||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||
|
||||
@@ -4,12 +4,12 @@ tests.register("PresetWidths", 1, () => {
|
||||
const spacing = 10;
|
||||
|
||||
const testCases = [
|
||||
{ str: "100%, 50%", result: [800, 395] },
|
||||
{ str: "105%, 50%", result: [800, 395] },
|
||||
{ str: "100px,50 px", result: [100, 50] },
|
||||
{ str: "900px,25 px", result: [800, 50] },
|
||||
{ str: " 100px, 25 % , 0.1 ", result: [192, 100, 71] },
|
||||
{ str: "100px, 25%, 0.1, 100px", result: [192, 100, 71] },
|
||||
{ str: "100%, 50%", result: [395, 800] },
|
||||
{ str: "105%, 50%", result: [395, 800] },
|
||||
{ str: "100px,50 px", result: [50, 100] },
|
||||
{ str: "900px,25 px", result: [50, 800] },
|
||||
{ str: " 100px, 25 % , 0.1 ", result: [71, 100, 192] },
|
||||
{ str: "100px, 25%, 0.1, 100px", result: [71, 100, 192] },
|
||||
{ str: "100px, -25 % , 0.1 ", error: true },
|
||||
{ str: "100px, 25 % , -0.1 ", error: true },
|
||||
{ str: "100px, 25 % , 0.1p", error: true },
|
||||
|
||||
Reference in New Issue
Block a user