forked from Blendman974/faceclaw
App-launcher UI: Wrapping, fix a minor folder-selection UI bug
This commit is contained in:
1 parent
37e95627b1
commit
474844f961
2 files changed
+34
-16
No files matched your search
@@ -272,8 +272,23 @@ export class FileBrowserLayer implements Layer {
|
|||||||
case "scroll-up":
|
case "scroll-up":
|
||||||
case "scroll-down": {
|
case "scroll-down": {
|
||||||
const delta = event.type === "scroll-down" ? 1 : -1;
|
const delta = event.type === "scroll-down" ? 1 : -1;
|
||||||
if (this.iconMode === "item" && row?.kind === "grid") {
|
if (this.iconMode === "item") {
|
||||||
this.selectedCol = clamp(this.selectedCol + delta, 0, row.items.length - 1);
|
// Item selection traverses linearly: past a row's edge it continues
|
||||||
|
// onto the adjacent row (a special row counts as a single item).
|
||||||
|
if (row?.kind === "grid") {
|
||||||
|
const next = clamp(this.selectedCol, 0, row.items.length - 1) + delta;
|
||||||
|
if (next >= 0 && next < row.items.length) {
|
||||||
|
this.selectedCol = next;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const adjacentIndex = this.selectedRow + delta;
|
||||||
|
if (adjacentIndex < 0 || adjacentIndex >= iconRows.length) return;
|
||||||
|
this.selectedRow = adjacentIndex;
|
||||||
|
const adjacent = iconRows[adjacentIndex]!;
|
||||||
|
if (adjacent.kind === "grid") {
|
||||||
|
this.selectedCol = delta > 0 ? 0 : adjacent.items.length - 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.selectedRow = clamp(this.selectedRow + delta, 0, Math.max(0, iconRows.length - 1));
|
this.selectedRow = clamp(this.selectedRow + delta, 0, Math.max(0, iconRows.length - 1));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ class LauncherGridLayer implements Layer {
|
|||||||
private selectedRow = 0;
|
private selectedRow = 0;
|
||||||
private selectedCol = 1;
|
private selectedCol = 1;
|
||||||
private scrollRow = 0;
|
private scrollRow = 0;
|
||||||
private wasFocused = false;
|
|
||||||
/** Folder whose contents the grid is showing, or null for the top grid. */
|
/** Folder whose contents the grid is showing, or null for the top grid. */
|
||||||
private currentFolder: string | null = null;
|
private currentFolder: string | null = null;
|
||||||
|
|
||||||
@@ -135,14 +134,6 @@ class LauncherGridLayer implements Layer {
|
|||||||
const { width, height } = ctx.stack.getBaseSize();
|
const { width, height } = ctx.stack.getBaseSize();
|
||||||
const image = new GrayImage(width, height, 0);
|
const image = new GrayImage(width, height, 0);
|
||||||
const focused = ctx.stack.isFocused();
|
const focused = ctx.stack.isFocused();
|
||||||
// Re-entering the launcher (focus gained) resets to the top grid's row
|
|
||||||
// selection, so the view never resumes inside a stale folder.
|
|
||||||
if (focused && !this.wasFocused) {
|
|
||||||
this.mode = "row";
|
|
||||||
this.currentFolder = null;
|
|
||||||
}
|
|
||||||
this.wasFocused = focused;
|
|
||||||
|
|
||||||
const entries = this.entries();
|
const entries = this.entries();
|
||||||
const rows = this.rowCount(entries.length);
|
const rows = this.rowCount(entries.length);
|
||||||
this.selectedRow = clamp(this.selectedRow, 0, rows - 1);
|
this.selectedRow = clamp(this.selectedRow, 0, rows - 1);
|
||||||
@@ -216,11 +207,19 @@ class LauncherGridLayer implements Layer {
|
|||||||
if (this.mode === "row") {
|
if (this.mode === "row") {
|
||||||
this.selectedRow = clamp(this.selectedRow + delta, 0, rows - 1);
|
this.selectedRow = clamp(this.selectedRow + delta, 0, rows - 1);
|
||||||
} else {
|
} else {
|
||||||
this.selectedCol = clamp(
|
// Item selection traverses the grid linearly: past a row's edge it
|
||||||
this.selectedCol + delta,
|
// continues onto the adjacent row (stopping at the grid's ends).
|
||||||
0,
|
const itemCount = this.itemsInRow(entries.length, this.selectedRow);
|
||||||
Math.max(0, this.itemsInRow(entries.length, this.selectedRow) - 1),
|
const next = clamp(this.selectedCol, 0, itemCount - 1) + delta;
|
||||||
);
|
if (next >= 0 && next < itemCount) {
|
||||||
|
this.selectedCol = next;
|
||||||
|
} else if (next < 0 && this.selectedRow > 0) {
|
||||||
|
this.selectedRow--;
|
||||||
|
this.selectedCol = this.itemsInRow(entries.length, this.selectedRow) - 1;
|
||||||
|
} else if (next >= itemCount && this.selectedRow < rows - 1) {
|
||||||
|
this.selectedRow++;
|
||||||
|
this.selectedCol = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -241,6 +240,10 @@ class LauncherGridLayer implements Layer {
|
|||||||
this.selectedRow = 0;
|
this.selectedRow = 0;
|
||||||
this.scrollRow = 0;
|
this.scrollRow = 0;
|
||||||
} else {
|
} else {
|
||||||
|
// Return to the top grid before launching, so the launcher never
|
||||||
|
// shows (even briefly) stale folder contents when re-entered.
|
||||||
|
if (this.currentFolder !== null) this.exitFolder();
|
||||||
|
this.mode = "row";
|
||||||
await this.options.launchApp(entry.appId);
|
await this.options.launchApp(entry.appId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user