forked from Blendman974/faceclaw
First iteration of glanceboard
This commit is contained in:
1 parent
a3660fac61
commit
8a340fc4ad
36 files changed
+2874
-357
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import { type GrayImage } from "../../graphics/image";
|
||||
|
||||
/**
|
||||
* A Glanceboard widget: a small self-contained view that paints into a slot
|
||||
* of the board. Widgets are sized by the layout (the first layout is four
|
||||
* 288x144 quadrants) and own their data subscriptions and any hardware they
|
||||
* need between start and stop, so a board that is not showing costs nothing.
|
||||
*
|
||||
* Layouts are expected to be swapped out and iterated on; widgets are the
|
||||
* stable part, so keep them independent of any particular board geometry
|
||||
* beyond the slot size they are handed.
|
||||
*/
|
||||
export interface GlanceWidget {
|
||||
/**
|
||||
* The board became visible (or this widget was added to a visible board):
|
||||
* subscribe to data, start timers, enable hardware. `requestRender` asks
|
||||
* the board to repaint when something changed.
|
||||
*/
|
||||
start(requestRender: () => void): void;
|
||||
/** Undo start. Called once for every start; must be safe to call twice. */
|
||||
stop(): void;
|
||||
/**
|
||||
* Paint the widget into `image`, a fresh 0-filled canvas of the slot's
|
||||
* size. Deferred draws (text, drawImage) are welcome and keep the cheap
|
||||
* texture-cache wire path.
|
||||
*/
|
||||
paint(image: GrayImage): void;
|
||||
}
|
||||
|
||||
export type GlanceWidgetId = "system-card" | "nightscout" | "compass" | "music";
|
||||
|
||||
export type GlanceWidgetDefinition = {
|
||||
id: GlanceWidgetId;
|
||||
/** Picker label in the Glanceboard app. */
|
||||
label: string;
|
||||
create: () => GlanceWidget;
|
||||
};
|
||||
Reference in new issue
Block a user