Loading...
Searching...
No Matches
engine.h
Go to the documentation of this file.
1
12#pragma once
13#include <pebble.h>
14
15#include "ui/zone.h"
16
21
24#ifndef ENGINE_SLOTS_MAX
25#define ENGINE_SLOTS_MAX 10
26#endif
27
28// the engine sizes its arrays by ENGINE_SLOTS_MAX alone, so a face setting this name for twelve slots
29// would size its own loops by twelve and write past the engine's ten
30#ifdef ENGINE_MAX_SLOTS
31#error "ENGINE_MAX_SLOTS is not read by the engine. Set ENGINE_SLOTS_MAX instead"
32#endif
33
34// the slot count and every slot index are a uint8_t, and the clamp on the count needs one value
35// above the cap to compare against. at 255 the SDK's -Werror stops the build on a compare that
36// can never be true
37#if ENGINE_SLOTS_MAX < 1 || ENGINE_SLOTS_MAX > 254
38#error "ENGINE_SLOTS_MAX has to be 1 to 254"
39#endif
40
46typedef struct
47{
48 GRect frame;
49 void (*draw)(GContext *ctx, GRect bounds, const void *data);
50 const void *data;
51
52 const Zone *zone;
53 void (*text)(char *out, size_t n);
54
55 uint32_t tags;
57
69typedef uint8_t (*EngineBuild)(EngineSlot *out, uint8_t max, GRect bounds);
70
77void engine_init(Window *window, EngineBuild build);
78
80void engine_deinit(void);
81
83void engine_rebuild(void);
84
86void engine_mark_dirty(void);
87
94void engine_mark_dirty_tags(uint32_t changed);
95
void engine_deinit(void)
Tear down the slot layers.
Definition engine.c:106
void engine_init(Window *window, EngineBuild build_cb)
Build the slot layers for a face and paint them once.
Definition engine.c:99
void engine_rebuild(void)
Rebuild the slot layers (after a layout or theme change).
Definition engine.c:111
void engine_mark_dirty_tags(uint32_t changed)
Repaint only the slots whose tags intersect changed (plus any slot with no tags). Lets a face route a...
Definition engine.c:154
void engine_mark_dirty(void)
Repaint every slot: text-slots re-pull + fit, draw-slots mark dirty.
Definition engine.c:148
uint8_t(*) EngineBuild(EngineSlot *out, uint8_t max, GRect bounds)
Fills the caller's slots and returns the count. A static face returns a fixed list....
Definition engine.h:69
One slot of a face. Set zone (+ text) for a text-slot, or frame (+ draw) for a draw-slot....
Definition engine.h:47
GRect frame
Draw slot layer frame.
Definition engine.h:48
void(*) draw(GContext *ctx, GRect bounds, const void *data)
Draw slot paint.
Definition engine.h:49
const void * data
Draw slot data.
Definition engine.h:50
uint32_t tags
Which stores this slot reads from, for engine_mark_dirty_tags (0 means repaint on any change).
Definition engine.h:55
const Zone * zone
Text slot area and font tiers.
Definition engine.h:52
void(*) text(char *out, size_t n)
Text slot, pulls and formats from a store.
Definition engine.h:53
Everything needed to present one text slot. Where it sits, and which registered font,...
Definition zone.h:26
Layout primitives. Defines paintable areas and their text alignments.