nandi/jolt-nativepublic Fork 0
71cdc877e694ff5acadac0f1dcc3320531bd6f19
Commits
Clone
git clone https://git.rickub.com/nandi/jolt-native.git
git clone ssh://git@rickub.com/nandi/jolt-native.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Let the media plane cross to the phone, camera and all fd0e21a · on 71cdc877e694ff5acadac0f1dcc3320531bd6f19 · nandi · 18d ago
vidya.h · 84 lines · 2.9 KBC Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef VIDYA_H
#define VIDYA_H

#include <stddef.h>

#if defined(_WIN32)
#  if defined(VIDYA_BUILD)
#    define VIDYA_API __declspec(dllexport)
#  else
#    define VIDYA_API __declspec(dllimport)
#  endif
#elif defined(__GNUC__)
#  define VIDYA_API __attribute__((visibility("default")))
#else
#  define VIDYA_API
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef enum VidyaMode {
    VIDYA_DARK = 0,
    VIDYA_LIGHT = 1
} VidyaMode;

typedef enum VidyaButtonKind {
    VIDYA_BUTTON_DEFAULT = 0,
    VIDYA_BUTTON_PRIMARY = 1,
    VIDYA_BUTTON_DESTRUCTIVE = 2
} VidyaButtonKind;

/* Window and frame lifecycle. There is one UI context per process for now.
 * All calls must remain on the window thread. */
VIDYA_API int vidya_open(int width, int height, const char *title);
VIDYA_API void vidya_close(void);
VIDYA_API int vidya_should_close(void);
VIDYA_API void vidya_set_target_fps(int fps);
VIDYA_API void vidya_set_mode(int mode);
VIDYA_API int vidya_get_mode(void);
/* Replace the UI font. Returns 1 on success. atlas_size is the size the direct
 * backend bakes its atlas at, which controls then scale down to the semantic
 * type sizes; 32 is a good default. Call between frames, not inside one. */
VIDYA_API int vidya_load_font(const char *path, int atlas_size);
VIDYA_API void vidya_begin_frame(void);
VIDYA_API void vidya_end_frame(void);

/* A frame is a vertical immediate-mode page. Containers save and restore its
 * horizontal bounds; every leaf advances the vertical cursor. */
VIDYA_API void vidya_page_begin(float max_width);
VIDYA_API void vidya_page_end(void);
VIDYA_API void vidya_card_begin(void);
VIDYA_API void vidya_card_end(void);
VIDYA_API void vidya_gap(float pixels);
VIDYA_API void vidya_separator(void);

/* Semantic text roles. */
VIDYA_API void vidya_title(const char *text);
VIDYA_API void vidya_title_2(const char *text);
VIDYA_API void vidya_body(const char *text);
VIDYA_API void vidya_dim_label(const char *text);

/* Controls return 1 only on activation/change during the current frame. */
VIDYA_API int vidya_button(const char *label, int kind);
VIDYA_API int vidya_checkbox(const char *label, int *checked);
/* FFI-friendly checkbox variant: returns the current value after handling input. */
VIDYA_API int vidya_checkbox_value(const char *label, int checked);
VIDYA_API void vidya_status(const char *label, int live);
VIDYA_API int vidya_text_field(char *text, size_t capacity, const char *placeholder);

/* Android only, and null until the activity's glue has started.
 *
 * The process's JavaVM and its Activity, for a *different* shared object that
 * needs them: libjoltmoq reaches Camera2 over JNI, and the handles only arrive
 * in the library holding android-activity's glue, which is this one. Neither is
 * of any use to a desktop caller. See crates/jolt-vidya/src/android.rs. */
VIDYA_API void *vidya_android_vm(void);
VIDYA_API void *vidya_android_activity(void);

#ifdef __cplusplus
}
#endif

#endif