forked from jimrandomh/faceclaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeometry.ts
More file actions
81 lines (73 loc) · 2.79 KB
/
Copy pathgeometry.ts
File metadata and controls
81 lines (73 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { G2_LENS_HEIGHT, G2_LENS_WIDTH } from "../../graphics/image";
import { verticalPositionSetting } from "../dashboard-settings";
/** Top bar: 24px notification icons plus a little padding. */
export const TOP_BAR_HEIGHT = 28;
/** One sidebar column: 32px window icons plus a little padding. */
export const SIDEBAR_COLUMN_WIDTH = 36;
/**
* Sidebar icon columns. The right column (against the app area) fills first;
* windows past that overflow into the left column, so the common few-window
* case keeps every icon next to the content it belongs to.
*/
export const SIDEBAR_COLUMNS = 2;
export const SIDEBAR_WIDTH = SIDEBAR_COLUMN_WIDTH * SIDEBAR_COLUMNS;
/**
* On the color-key shell surface, pixel value 0 is transparent; 1 is the
* darkest opaque shade (identical to 0 after 4bpp quantization). Shell
* painting must use this for intentional black.
*/
export const SHELL_OPAQUE_BLACK = 1;
/**
* Windows come in two heights. "min" covers the same 288px band the stock
* firmware uses, leaving most of the field of view clear; "max" uses the
* whole 480px screen (terminal views). Both include a top bar drawn by the
* shell at the window's top edge.
*/
export type WindowHeightMode = "min" | "max";
/** Total height (top bar + content) of a min-height window. */
export const MIN_WINDOW_HEIGHT = 288;
/** Farthest down a min-height window can start. */
export const MIN_WINDOW_MAX_TOP = G2_LENS_HEIGHT - MIN_WINDOW_HEIGHT;
/**
* Top edge (y) of a min-height window, from the Display > Vertical position
* setting. The sidebar and shell overlays always align to this band, even
* while a max-height window is foreground.
*/
export function minWindowTop(): number {
switch (verticalPositionSetting.get()) {
case "top":
return 0;
case "upper":
return Math.round(MIN_WINDOW_MAX_TOP * 0.25);
case "lower":
return Math.round(MIN_WINDOW_MAX_TOP * 0.75);
case "bottom":
return MIN_WINDOW_MAX_TOP;
default:
return Math.round(MIN_WINDOW_MAX_TOP * 0.5);
}
}
/** Top edge (y) of a window's top bar; max-height windows pin to the screen top. */
export function windowTop(mode: WindowHeightMode): number {
return mode === "max" ? 0 : minWindowTop();
}
/** App-content viewport size for a height mode (independent of vertical position). */
export function appViewportSize(mode: WindowHeightMode): { width: number; height: number } {
return {
width: G2_LENS_WIDTH - SIDEBAR_WIDTH,
height: (mode === "max" ? G2_LENS_HEIGHT : MIN_WINDOW_HEIGHT) - TOP_BAR_HEIGHT,
};
}
/** Screen rect of a window's app-content viewport (below its top bar). */
export function appViewportRect(mode: WindowHeightMode): {
x: number;
y: number;
width: number;
height: number;
} {
return {
x: SIDEBAR_WIDTH,
y: windowTop(mode) + TOP_BAR_HEIGHT,
...appViewportSize(mode),
};
}