forked from Blendman974/faceclaw
Depth effects
This commit is contained in:
1 parent
4320021222
commit
392554dd37
26 files changed
+623
-136
No files matched your search
+2
-1
@@ -80,6 +80,7 @@ export interface LayerContext {
|
||||
}
|
||||
|
||||
export interface Layer {
|
||||
readonly depth?: number;
|
||||
paintParts?(): Plane[];
|
||||
readonly paintOverBase?: boolean;
|
||||
/**
|
||||
@@ -284,7 +285,7 @@ export class LayerStack {
|
||||
return canvas;
|
||||
}),
|
||||
);
|
||||
const ownPlane: Plane = { image, x: 0, y: 0, shellKey: key, dimUnderneath: layer.dimUnderneath === false ? 1 : layer.dimUnderneath };
|
||||
const ownPlane: Plane = { image, x: 0, y: 0, shellKey: key, depth: layer.depth, dimUnderneath: layer.dimUnderneath === false ? 1 : layer.dimUnderneath };
|
||||
if (index <= 0) {
|
||||
this.lastBaseDim = dimSoFar;
|
||||
return [ownPlane];
|
||||
|
||||
+13
-16
@@ -19,6 +19,8 @@ const MENU_HIGHLIGHT_SELECTED_BACKGROUND_FILL = 15;
|
||||
const MENU_HIGHLIGHT_SELECTED_BORDER_STROKE = 45;
|
||||
|
||||
export type MenuLayout = {
|
||||
/** Stereo depth of the menu surface; selected rows add +2. */
|
||||
depth?: number;
|
||||
/** Left edge, or "center" to center horizontally on the painted surface. */
|
||||
x: number | "center";
|
||||
y: number;
|
||||
@@ -192,6 +194,8 @@ export class MenuLayer implements Layer {
|
||||
private selectedIndex = 0;
|
||||
private scrollRow = 0;
|
||||
|
||||
get depth(): number { return this.layout.depth ?? 0; }
|
||||
|
||||
get dimUnderneath(): false | number {
|
||||
return this.layout.dimUnderneath ?? false;
|
||||
}
|
||||
@@ -227,7 +231,7 @@ export class MenuLayer implements Layer {
|
||||
const maxHeight = Math.min(
|
||||
this.layout.maxHeight ?? image.height - y - DEFAULT_MENU_Y,
|
||||
image.height - y,
|
||||
this.layout.squareCorners ? Math.floor(65530 / Math.ceil(width / 2)) : Infinity,
|
||||
(this.layout.squareCorners || this.depth !== 0) ? Math.floor(65530 / Math.ceil(width / 2)) : Infinity,
|
||||
);
|
||||
const footerHeight = this.layout.footer ? MENU_FOOTER_GAP + lineStep(font) : 0;
|
||||
const contentHeight = chromeTop + this.items.length * rowHeight + footerHeight + MENU_BODY_PADDING;
|
||||
@@ -266,22 +270,14 @@ export class MenuLayer implements Layer {
|
||||
const rowY = bodyY + (index - this.scrollRow) * rowHeight;
|
||||
const selected = index === this.selectedIndex;
|
||||
const disabled = isMenuItemDisabled(item);
|
||||
if (selected) {
|
||||
drawSelectionHighlight(
|
||||
image,
|
||||
x + 12,
|
||||
rowY,
|
||||
width - 24,
|
||||
rowHeight - 1,
|
||||
focused,
|
||||
8,
|
||||
);
|
||||
}
|
||||
const row = selected ? new GrayImage(width - 24, rowHeight - 1, 0) : image;
|
||||
const textX = selected ? 10 : x + 22;
|
||||
const textY = selected ? 0 : rowY;
|
||||
if (item.render) {
|
||||
item.render({
|
||||
image,
|
||||
x: x + 22,
|
||||
y: rowY,
|
||||
image: row,
|
||||
x: textX,
|
||||
y: textY,
|
||||
width: width - 44,
|
||||
height: rowHeight - 3,
|
||||
selected,
|
||||
@@ -290,8 +286,9 @@ export class MenuLayer implements Layer {
|
||||
ctx,
|
||||
});
|
||||
} else {
|
||||
image.drawText(font, x + 22, rowY + LIST_ROW_TEXT_INSET, item.label, disabled ? 70 : selected ? 255 : 200);
|
||||
row.drawText(font, textX, textY + LIST_ROW_TEXT_INSET, item.label, disabled ? 70 : selected ? 255 : 200);
|
||||
}
|
||||
if (selected) image.drawMenuSelection(row, x + 12, rowY, focused ? MENU_HIGHLIGHT_SELECTED_BACKGROUND_FILL : 0, MENU_HIGHLIGHT_SELECTED_BORDER_STROKE, 8, 2);
|
||||
}
|
||||
|
||||
if (this.items.length > visibleRowCount) {
|
||||
|
||||
@@ -228,7 +228,7 @@ export class ShellChromeLayer implements Layer {
|
||||
const canvas = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
||||
this.drawTopBar(canvas, state);
|
||||
const left = sidebarStripVisible(state.focus, state.foregroundAppId) ? SIDEBAR_WIDTH : 0;
|
||||
parts.push(shellCrop(canvas, left, windowTop(state.foregroundHeightMode, state.foregroundAppId), G2_LENS_WIDTH-left, TOP_BAR_HEIGHT, 2));
|
||||
parts.push({ ...shellCrop(canvas, left, windowTop(state.foregroundHeightMode, state.foregroundAppId), G2_LENS_WIDTH-left, TOP_BAR_HEIGHT, 2), depth: -2 });
|
||||
drawAmbientCards(canvas, parts);
|
||||
return parts;
|
||||
}
|
||||
@@ -288,14 +288,16 @@ export class ShellChromeLayer implements Layer {
|
||||
// the icon drawn inverted. Only the right column touches the separator;
|
||||
// a selected overflow icon gets a self-contained box instead.
|
||||
const sep = SIDEBAR_WIDTH - 1;
|
||||
// Start beside the app content, leaving the area alongside the top bar open.
|
||||
const sepTop = Math.max(bandTop, windowTop(state.foregroundHeightMode, state.foregroundAppId) + TOP_BAR_HEIGHT);
|
||||
const selVisible = state.selectedIndex >= this.scrollRow && state.selectedIndex < lastVisible;
|
||||
const selSlot = selVisible ? slotOf(state.selectedIndex) : null;
|
||||
const selTabTop = selSlot && selSlot.column === firstColumn ? selSlot.y - 2 : null;
|
||||
if (selTabTop !== null) {
|
||||
image.drawLine(sep, bandTop, sep, selTabTop, BORDER_VALUE);
|
||||
image.drawLine(sep, sepTop, sep, selTabTop, BORDER_VALUE);
|
||||
image.drawLine(sep, selTabTop + iconSize + 4, sep, bandBottom - 1, BORDER_VALUE);
|
||||
} else {
|
||||
image.drawLine(sep, bandTop, sep, bandBottom - 1, BORDER_VALUE);
|
||||
image.drawLine(sep, sepTop, sep, bandBottom - 1, BORDER_VALUE);
|
||||
}
|
||||
|
||||
for (let index = this.scrollRow; index < lastVisible; index++) {
|
||||
@@ -312,13 +314,17 @@ export class ShellChromeLayer implements Layer {
|
||||
// slot, so anything wider would clip at the screen edge.
|
||||
drawSelectionBox(image, left, y - 2, variant.columnWidth, iconSize + 4, focused);
|
||||
}
|
||||
window.drawIcon(image, x, y, iconSize, focused);
|
||||
// Paint unselected icons into their own resource so only the replayed copy moves.
|
||||
const icon = selected ? image : new GrayImage(iconSize, iconSize + 1);
|
||||
const iconX = selected ? x : 0, iconY = selected ? y : 1;
|
||||
window.drawIcon(icon, iconX, iconY, iconSize, focused);
|
||||
if (window.attention) {
|
||||
// Black dot on the white focused tab, white dot otherwise. A deferred
|
||||
// image (not a raster fill) so it renders above the icon, which is
|
||||
// itself a deferred draw.
|
||||
image.drawImage(attentionDot(focused ? SHELL_OPAQUE_BLACK : 255), x + iconSize - 7, y - 1);
|
||||
icon.drawImage(attentionDot(focused ? SHELL_OPAQUE_BLACK : 255), iconX + iconSize - 7, iconY - 1);
|
||||
}
|
||||
if (!selected) image.drawDepthImage(icon, x, y - 1, -2);
|
||||
}
|
||||
|
||||
// Chevrons center over the icon area, which in the one-column variant is
|
||||
|
||||
@@ -233,6 +233,7 @@ class ShellOverlayMenuLayer extends MenuLayer {
|
||||
squareCorners: true,
|
||||
footer,
|
||||
dimUnderneath: CONTEXT_MENU_DIM,
|
||||
depth: 4,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ export const WINDOW_MENU_LAYOUT: MenuLayout = {
|
||||
minHeight: 150,
|
||||
footer: gestureHints([[GESTURE_LONG_PRESS, "system menu"]]),
|
||||
dimUnderneath: CONTEXT_MENU_DIM,
|
||||
depth: 4,
|
||||
};
|
||||
|
||||
export class WindowMenuLayer extends MenuLayer {
|
||||
|
||||
Reference in new issue
Block a user