WASM Backend: - src/backend/wasm.zig: Browser backend using extern JS functions - web/zcatgui.js: Canvas 2D rendering bridge (~200 LOC) - web/index.html: Demo page with event handling - examples/wasm_demo.zig: Widget showcase for browser - Output: 18KB WASM binary Android Backend: - src/backend/android.zig: ANativeActivity + ANativeWindow - examples/android_demo.zig: Touch-enabled demo - Touch-to-mouse event mapping - Logging via __android_log_print - Targets: ARM64 (device), x86_64 (emulator) iOS Backend: - src/backend/ios.zig: UIKit bridge via extern C functions - ios/ZcatguiBridge.h: Objective-C header - ios/ZcatguiBridge.m: UIKit implementation (~320 LOC) - CADisplayLink render loop - Touch event queue with @synchronized - Targets: ARM64 (device), ARM64 simulator Build System: - WASM: zig build wasm - Android: zig build android / android-x86 - iOS: zig build ios / ios-sim - Conditional compilation for platform detection Documentation: - docs/MOBILE_WEB_BACKENDS.md: Comprehensive guide (~400 lines) - Updated DEVELOPMENT_PLAN.md with FASE 10 - Updated CLAUDE.md with new commands Stats: 3 backends, ~1500 new LOC, cross-platform ready 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
68 lines
1.6 KiB
Objective-C
68 lines
1.6 KiB
Objective-C
// ZcatguiBridge.h - Objective-C bridge header for zcatgui iOS backend
|
|
//
|
|
// Include this in your iOS project and link with the zcatgui static library.
|
|
// See ZcatguiBridge.m for implementation.
|
|
|
|
#ifndef ZCATGUI_BRIDGE_H
|
|
#define ZCATGUI_BRIDGE_H
|
|
|
|
#import <UIKit/UIKit.h>
|
|
#import <stdint.h>
|
|
|
|
// Event types (must match ios.zig)
|
|
typedef NS_ENUM(uint32_t, ZcatguiEventType) {
|
|
ZcatguiEventNone = 0,
|
|
ZcatguiEventTouchDown = 1,
|
|
ZcatguiEventTouchUp = 2,
|
|
ZcatguiEventTouchMove = 3,
|
|
ZcatguiEventKeyDown = 4,
|
|
ZcatguiEventKeyUp = 5,
|
|
ZcatguiEventResize = 6,
|
|
ZcatguiEventQuit = 7,
|
|
};
|
|
|
|
// Event structure
|
|
typedef struct {
|
|
ZcatguiEventType type;
|
|
uint8_t data[64];
|
|
} ZcatguiEvent;
|
|
|
|
// Bridge view that renders zcatgui framebuffer
|
|
@interface ZcatguiView : UIView
|
|
|
|
@property (nonatomic, readonly) CGSize framebufferSize;
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame;
|
|
- (void)presentPixels:(const uint32_t *)pixels width:(uint32_t)width height:(uint32_t)height;
|
|
|
|
@end
|
|
|
|
// Main view controller
|
|
@interface ZcatguiViewController : UIViewController
|
|
|
|
@property (nonatomic, strong) ZcatguiView *zcatguiView;
|
|
@property (nonatomic, assign) BOOL running;
|
|
|
|
- (void)startRenderLoop;
|
|
- (void)stopRenderLoop;
|
|
|
|
@end
|
|
|
|
// Bridge functions called by Zig
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
void ios_view_init(uint32_t width, uint32_t height);
|
|
uint32_t ios_view_get_width(void);
|
|
uint32_t ios_view_get_height(void);
|
|
void ios_view_present(const uint32_t *pixels, uint32_t width, uint32_t height);
|
|
uint32_t ios_poll_event(uint8_t *buffer);
|
|
void ios_log(const uint8_t *ptr, size_t len);
|
|
uint64_t ios_get_time_ms(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // ZCATGUI_BRIDGE_H
|