First commit of the Phase 8 platform abstraction (see current/PLATFORM_PLAN.md):
- `library/modules/platform/types.sx` — `FrameContext` (viewport_w/h,
pixel_w/h, dpi_scale, delta_time) and `KeyboardState` (visible, height
+ `zero()`). `EdgeInsets`/`Point`/`Size` and `Event` are reused from
`modules/ui/types.sx` / `modules/ui/events.sx`.
- `library/modules/platform/api.sx` — `Platform :: protocol { init,
run_frame_loop, poll_events, begin_frame, end_frame, safe_insets,
keyboard, show_keyboard, hide_keyboard, shutdown }`. Protocol bodies
omit `self` (matches the `View`/`Allocator` convention).
- `run_frame_loop` takes `Closure()` so backends own the run loop:
SDL drives a `while !quit`, UIKit hands it to a `CADisplayLink` tick,
Emscripten hands it to `emscripten_set_main_loop`.
No backend yet. Regression suite still 50/50; game build still green.
23 lines
493 B
Plaintext
23 lines
493 B
Plaintext
#import "modules/std.sx";
|
|
#import "modules/ui/types.sx";
|
|
#import "modules/ui/events.sx";
|
|
#import "modules/platform/types.sx";
|
|
|
|
Platform :: protocol {
|
|
init :: (title: [:0]u8, w: s32, h: s32) -> bool;
|
|
|
|
run_frame_loop :: (frame_fn: Closure());
|
|
|
|
poll_events :: () -> []Event;
|
|
|
|
begin_frame :: () -> FrameContext;
|
|
end_frame :: ();
|
|
|
|
safe_insets :: () -> EdgeInsets;
|
|
keyboard :: () -> KeyboardState;
|
|
show_keyboard :: ();
|
|
hide_keyboard :: ();
|
|
|
|
shutdown :: ();
|
|
}
|