forked from Blendman974/faceclaw
Modify sidebar size and vertical sizing options to allow 576x288 EvenHub apps to fit cleanly
This commit is contained in:
1 parent
6df7e9bc81
commit
d7d12afcaa
3 files changed
+108
-68
No files matched your search
+40
-22
@@ -3,15 +3,12 @@ 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.
|
||||
* Sidebar width. Leaves the app viewport exactly 576px wide — the surface
|
||||
* width EvenHub apps expect. Icon column layout within the strip (one wide
|
||||
* column vs. two narrow ones) is the chrome layer's business.
|
||||
*/
|
||||
export const SIDEBAR_COLUMNS = 2;
|
||||
export const SIDEBAR_WIDTH = SIDEBAR_COLUMN_WIDTH * SIDEBAR_COLUMNS;
|
||||
export const SIDEBAR_WIDTH = 64;
|
||||
|
||||
/**
|
||||
* On the color-key shell surface, pixel value 0 is transparent; 1 is the
|
||||
@@ -21,48 +18,69 @@ export const SIDEBAR_WIDTH = SIDEBAR_COLUMN_WIDTH * SIDEBAR_COLUMNS;
|
||||
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.
|
||||
* Windows come in three heights. "min" covers the same 288px band the stock
|
||||
* firmware uses, leaving most of the field of view clear; "medium" is one
|
||||
* top bar taller, so the content area below the bar is a full 288px (the
|
||||
* EvenHub app surface height); "max" uses the whole 480px screen (terminal
|
||||
* views). All include a top bar drawn by the shell at the window's top edge.
|
||||
*/
|
||||
export type WindowHeightMode = "min" | "max";
|
||||
export type WindowHeightMode = "min" | "medium" | "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;
|
||||
|
||||
/** Total height (top bar + content) of a window's band in the given mode. */
|
||||
export function windowBandHeight(mode: WindowHeightMode): number {
|
||||
switch (mode) {
|
||||
case "max":
|
||||
return G2_LENS_HEIGHT;
|
||||
case "medium":
|
||||
return MIN_WINDOW_HEIGHT + TOP_BAR_HEIGHT;
|
||||
default:
|
||||
return 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.
|
||||
* Fraction of the slack above a window band, from the Display > Vertical
|
||||
* position setting: each band height distributes its own free space by the
|
||||
* same fraction, so all heights sit consistently within the screen.
|
||||
*/
|
||||
export function minWindowTop(): number {
|
||||
function verticalPositionFraction(): number {
|
||||
switch (verticalPositionSetting.get()) {
|
||||
case "top":
|
||||
return 0;
|
||||
case "upper":
|
||||
return Math.round(MIN_WINDOW_MAX_TOP * 0.25);
|
||||
return 0.25;
|
||||
case "lower":
|
||||
return Math.round(MIN_WINDOW_MAX_TOP * 0.75);
|
||||
return 0.75;
|
||||
case "bottom":
|
||||
return MIN_WINDOW_MAX_TOP;
|
||||
return 1;
|
||||
default:
|
||||
return Math.round(MIN_WINDOW_MAX_TOP * 0.5);
|
||||
return 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Top edge (y) of a min-height window. The sidebar and shell overlays always
|
||||
* align to this band, even while a taller window is foreground.
|
||||
*/
|
||||
export function minWindowTop(): number {
|
||||
return windowTop("min");
|
||||
}
|
||||
|
||||
/** 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();
|
||||
return Math.round((G2_LENS_HEIGHT - windowBandHeight(mode)) * verticalPositionFraction());
|
||||
}
|
||||
|
||||
/** 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,
|
||||
height: windowBandHeight(mode) - TOP_BAR_HEIGHT,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user