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#ifdef ENGINE_MAX_SLOTS
26#define ENGINE_SLOTS_MAX ENGINE_MAX_SLOTS
27#else
28#define ENGINE_SLOTS_MAX 10
29#endif
30#endif
31
33#ifndef ENGINE_MAX_SLOTS
34#define ENGINE_MAX_SLOTS ENGINE_SLOTS_MAX
35#endif
36
37// a face that sets both names to different numbers would size its own loops by one and the engine's
38// arrays by the other
39#if ENGINE_MAX_SLOTS != ENGINE_SLOTS_MAX
40#error "ENGINE_SLOTS_MAX and the old ENGINE_MAX_SLOTS are set to different values"
41#endif
42
43// the slot count and every slot index are a uint8_t, and the clamp on the count needs one value
44// above the cap to compare against. at 255 the SDK's -Werror stops the build on a compare that
45// can never be true
46#if ENGINE_SLOTS_MAX < 1 || ENGINE_SLOTS_MAX > 254
47#error "ENGINE_SLOTS_MAX, or the old ENGINE_MAX_SLOTS, has to be 1 to 254"
48#endif
49
55typedef struct
56{
57 GRect frame;
58 void (*draw)(GContext *ctx, GRect bounds, const void *data);
59 const void *data;
60
61 const Zone *zone;
62 void (*text)(char *out, size_t n);
63
64 uint32_t tags;
66
78typedef uint8_t (*EngineBuild)(EngineSlot *out, uint8_t max, GRect bounds);
79
86void engine_init(Window *window, EngineBuild build);
87
89void engine_deinit(void);
90
92void engine_rebuild(void);
93
95void engine_mark_dirty(void);
96
103void engine_mark_dirty_tags(uint32_t changed);
104
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:78
One slot of a face. Set zone (+ text) for a text-slot, or frame (+ draw) for a draw-slot....
Definition engine.h:56
GRect frame
Draw slot layer frame.
Definition engine.h:57
void(*) draw(GContext *ctx, GRect bounds, const void *data)
Draw slot paint.
Definition engine.h:58
const void * data
Draw slot data.
Definition engine.h:59
uint32_t tags
Which stores this slot reads from, for engine_mark_dirty_tags (0 means repaint on any change).
Definition engine.h:64
const Zone * zone
Text slot area and font tiers.
Definition engine.h:61
void(*) text(char *out, size_t n)
Text slot, pulls and formats from a store.
Definition engine.h:62
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.