diff --git a/library/modules/platform/api.sx b/library/modules/platform/api.sx new file mode 100644 index 0000000..3563c95 --- /dev/null +++ b/library/modules/platform/api.sx @@ -0,0 +1,22 @@ +#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 :: (); +} diff --git a/library/modules/platform/types.sx b/library/modules/platform/types.sx new file mode 100644 index 0000000..37b1e39 --- /dev/null +++ b/library/modules/platform/types.sx @@ -0,0 +1,19 @@ +#import "modules/std.sx"; +#import "modules/ui/types.sx"; +#import "modules/ui/events.sx"; + +FrameContext :: struct { + viewport_w: f32; + viewport_h: f32; + pixel_w: s32; + pixel_h: s32; + dpi_scale: f32; + delta_time: f32; +} + +KeyboardState :: struct { + visible: bool; + height: f32; + + zero :: () -> KeyboardState => .{ visible = false, height = 0.0 }; +}