forked from Blendman974/faceclaw
Apps are variable height; add vertical position setting
This commit is contained in:
1 parent
6d42f0e65e
commit
7d2a41bd56
14 files changed
+301
-109
No files matched your search
+22
-14
@@ -1,23 +1,30 @@
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { DashboardInputEvent, Layer, LayerActions, LayerContext, LayerStack, PaintBelow } from "../layers";
|
||||
import { APP_VIEWPORT, SHELL_OPAQUE_BLACK } from "./geometry";
|
||||
import { appViewportRect, appViewportSize, SHELL_OPAQUE_BLACK } from "./geometry";
|
||||
|
||||
// The modal covers most of the app viewport, leaving a little of the
|
||||
// foreground app visible around the edges.
|
||||
// The modal covers most of the min-height app viewport, leaving a little of
|
||||
// the foreground app visible around the edges. Its size is fixed (min-height
|
||||
// windows have a fixed viewport size); its position follows the vertical
|
||||
// position setting, so it is computed per paint.
|
||||
const MODAL_MARGIN = 14;
|
||||
const MODAL_PADDING = 4;
|
||||
export const MODAL_RECT = {
|
||||
x: APP_VIEWPORT.x + MODAL_MARGIN,
|
||||
y: APP_VIEWPORT.y + MODAL_MARGIN,
|
||||
width: APP_VIEWPORT.width - 2 * MODAL_MARGIN,
|
||||
height: APP_VIEWPORT.height - 2 * MODAL_MARGIN,
|
||||
} as const;
|
||||
|
||||
export const MODAL_INTERIOR = {
|
||||
width: MODAL_RECT.width - 2 * MODAL_PADDING,
|
||||
height: MODAL_RECT.height - 2 * MODAL_PADDING,
|
||||
width: appViewportSize("min").width - 2 * MODAL_MARGIN - 2 * MODAL_PADDING,
|
||||
height: appViewportSize("min").height - 2 * MODAL_MARGIN - 2 * MODAL_PADDING,
|
||||
} as const;
|
||||
|
||||
/** Screen rect of the modal box, aligned to the min-height window band. */
|
||||
export function modalRect(): { x: number; y: number; width: number; height: number } {
|
||||
const viewport = appViewportRect("min");
|
||||
return {
|
||||
x: viewport.x + MODAL_MARGIN,
|
||||
y: viewport.y + MODAL_MARGIN,
|
||||
width: viewport.width - 2 * MODAL_MARGIN,
|
||||
height: viewport.height - 2 * MODAL_MARGIN,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A shell overlay hosting an inner layer stack in a bordered box over the
|
||||
* app viewport (used for new-notification popups). The inner stack paints at
|
||||
@@ -37,9 +44,10 @@ export class ShellModalLayer implements Layer {
|
||||
paint(ctx: LayerContext, paintBelow: PaintBelow): GrayImage {
|
||||
const image = paintBelow();
|
||||
const inner = this.stack.paint();
|
||||
image.fillRoundedRect(MODAL_RECT.x, MODAL_RECT.y, MODAL_RECT.width, MODAL_RECT.height, SHELL_OPAQUE_BLACK, 8);
|
||||
image.drawRoundedRect(MODAL_RECT.x, MODAL_RECT.y, MODAL_RECT.width, MODAL_RECT.height, 110, 8);
|
||||
image.bitBlt(inner, MODAL_RECT.x + MODAL_PADDING, MODAL_RECT.y + MODAL_PADDING, { transparentZero: true });
|
||||
const rect = modalRect();
|
||||
image.fillRoundedRect(rect.x, rect.y, rect.width, rect.height, SHELL_OPAQUE_BLACK, 8);
|
||||
image.drawRoundedRect(rect.x, rect.y, rect.width, rect.height, 110, 8);
|
||||
image.bitBlt(inner, rect.x + MODAL_PADDING, rect.y + MODAL_PADDING, { transparentZero: true });
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user