#ifndef LAYERS_H #define LAYERS_H #ifdef __cplusplus extern "C" { #endif #include #include typedef struct ViewportHandle ViewportHandle; /// Run paths setup + logging + single-instance acquisition. /// /// Returns: /// 0 — primary instance; proceed to create the viewport. /// 1 — another instance was running and has been signalled to raise; /// the caller should exit cleanly without creating a window. /// 2 — setup failed (fs/log error). int32_t layers_startup(void); /// Must be called BEFORE `layers_startup` if you want Rust to read resources/colors.toml /// from the installed plugin directory. No-ops after the colour cache is initialised. void layers_set_plugin_root(const char* path_utf8); ViewportHandle* layers_create(void* nsview, float width, float height, float scale); void layers_destroy(ViewportHandle* handle); void layers_render(ViewportHandle* handle); void layers_resize(ViewportHandle* handle, float width, float height, float scale); void layers_mouse_move(ViewportHandle* handle, float x, float y); void layers_mouse_left(ViewportHandle* handle); /// `button`: 0=Left, 1=Right, 2=Middle. Other codes are ignored. void layers_mouse_button(ViewportHandle* handle, float x, float y, uint32_t button, bool pressed); void layers_mouse_scroll(ViewportHandle* handle, float x, float y, float dx, float dy); /// `named`: 0=Character, 1=Enter, 2=Escape, 3=Backspace, 4=Tab, 5=ArrowLeft, /// 6=ArrowRight, 7=ArrowUp, 8=ArrowDown, 9=Delete, 10=Home, 11=End. /// `mods`: bitflags — 1=Shift, 2=Ctrl, 4=Alt, 8=Logo (Command). /// `utf8`: text produced by the key for Character kind; NULL for named keys. void layers_key_event(ViewportHandle* handle, uint32_t named, const char* utf8, uint32_t mods, uint16_t native_keycode, bool pressed); #ifdef __cplusplus } #endif #endif /* LAYERS_H */