| Build libvidya for the phone, and hold the glue that boots it d942053 nandi 19d ago | 1 | #ifndef VIDYA_H |
| 2 | #define VIDYA_H |
| 3 | |
| 4 | #include <stddef.h> |
| 5 | |
| 6 | #if defined(_WIN32) |
| 7 | # if defined(VIDYA_BUILD) |
| 8 | # define VIDYA_API __declspec(dllexport) |
| 9 | # else |
| 10 | # define VIDYA_API __declspec(dllimport) |
| 11 | # endif |
| 12 | #elif defined(__GNUC__) |
| 13 | # define VIDYA_API __attribute__((visibility("default"))) |
| 14 | #else |
| 15 | # define VIDYA_API |
| 16 | #endif |
| 17 | |
| 18 | #ifdef __cplusplus |
| 19 | extern "C" { |
| 20 | #endif |
| 21 | |
| 22 | typedef enum VidyaMode { |
| 23 | VIDYA_DARK = 0, |
| 24 | VIDYA_LIGHT = 1 |
| 25 | } VidyaMode; |
| 26 | |
| 27 | typedef enum VidyaButtonKind { |
| 28 | VIDYA_BUTTON_DEFAULT = 0, |
| 29 | VIDYA_BUTTON_PRIMARY = 1, |
| 30 | VIDYA_BUTTON_DESTRUCTIVE = 2 |
| 31 | } VidyaButtonKind; |
| 32 | |
| 33 | /* Window and frame lifecycle. There is one UI context per process for now. |
| 34 | * All calls must remain on the window thread. */ |
| 35 | VIDYA_API int vidya_open(int width, int height, const char *title); |
| 36 | VIDYA_API void vidya_close(void); |
| 37 | VIDYA_API int vidya_should_close(void); |
| 38 | VIDYA_API void vidya_set_target_fps(int fps); |
| 39 | VIDYA_API void vidya_set_mode(int mode); |
| 40 | VIDYA_API int vidya_get_mode(void); |
| 41 | /* Replace the UI font. Returns 1 on success. atlas_size is the size the direct |
| 42 | * backend bakes its atlas at, which controls then scale down to the semantic |
| 43 | * type sizes; 32 is a good default. Call between frames, not inside one. */ |
| 44 | VIDYA_API int vidya_load_font(const char *path, int atlas_size); |
| 45 | VIDYA_API void vidya_begin_frame(void); |
| 46 | VIDYA_API void vidya_end_frame(void); |
| 47 | |
| 48 | /* A frame is a vertical immediate-mode page. Containers save and restore its |
| 49 | * horizontal bounds; every leaf advances the vertical cursor. */ |
| 50 | VIDYA_API void vidya_page_begin(float max_width); |
| 51 | VIDYA_API void vidya_page_end(void); |
| 52 | VIDYA_API void vidya_card_begin(void); |
| 53 | VIDYA_API void vidya_card_end(void); |
| 54 | VIDYA_API void vidya_gap(float pixels); |
| 55 | VIDYA_API void vidya_separator(void); |
| 56 | |
| 57 | /* Semantic text roles. */ |
| 58 | VIDYA_API void vidya_title(const char *text); |
| 59 | VIDYA_API void vidya_title_2(const char *text); |
| 60 | VIDYA_API void vidya_body(const char *text); |
| 61 | VIDYA_API void vidya_dim_label(const char *text); |
| 62 | |
| 63 | /* Controls return 1 only on activation/change during the current frame. */ |
| 64 | VIDYA_API int vidya_button(const char *label, int kind); |
| 65 | VIDYA_API int vidya_checkbox(const char *label, int *checked); |
| 66 | /* FFI-friendly checkbox variant: returns the current value after handling input. */ |
| 67 | VIDYA_API int vidya_checkbox_value(const char *label, int checked); |
| 68 | VIDYA_API void vidya_status(const char *label, int live); |
| 69 | VIDYA_API int vidya_text_field(char *text, size_t capacity, const char *placeholder); |
| 70 | |
| Let the media plane cross to the phone, camera and all fd0e21a nandi 18d ago | 71 | /* Android only, and null until the activity's glue has started. |
| 72 | * |
| 73 | * The process's JavaVM and its Activity, for a *different* shared object that |
| 74 | * needs them: libjoltmoq reaches Camera2 over JNI, and the handles only arrive |
| 75 | * in the library holding android-activity's glue, which is this one. Neither is |
| 76 | * of any use to a desktop caller. See crates/jolt-vidya/src/android.rs. */ |
| 77 | VIDYA_API void *vidya_android_vm(void); |
| 78 | VIDYA_API void *vidya_android_activity(void); |
| 79 | |
| Build libvidya for the phone, and hold the glue that boots it d942053 nandi 19d ago | 80 | #ifdef __cplusplus |
| 81 | } |
| 82 | #endif |
| 83 | |
| 84 | #endif |