Every public declaration of Raven, in the order of its headers, with the comments of the headers. 928 functions, 59 callback types, 54 enumerations, 26 structures. Generated from include/ and web/include/.
#include <Raven.h> brings in everything below except raven_web.h. Every function is called from the thread that called Rinit unless its comment says otherwise.
Lightweight, multithreaded, retained-mode GUI library in C.
raven_core.h : base types, lifecycle, main loop, threading, errors.
Conventions: - every object is an opaque Rid handle, R_INVALID_ID on failure - functions are R<object>_<action>: Rwindow_create, Rwindow_destroy,
Rwindow_is_valid, Rwindow_set_title, Rwindow_get_size...
- types are RName (RInitDesc, REvent, RKey), callbacks are RNameCallback,
constants and enum values are R_NAME
- booleans are ints (R_TRUE / R_FALSE), colors are float r, g, b, a - strings are UTF-8 and always copied by the library
Threading: unless a function is documented as thread-safe, it must be called from the UI thread (the thread that called Rinit).
#define RAVEN_VERSION_MAJOR 0
#define RAVEN_VERSION_MINOR 1
#define RAVEN_VERSION_PATCH 0
#define RAVEN_API_VERSION "0.1"
#define R_FALSE 0
#define R_TRUE 1
#define R_INVALID_ID ((Rid)-1)
typedef enum RBackend
R_BACKEND_VULKAN | Built-in Vulkan renderer. |
R_BACKEND_NULL | Renders nothing. Used for headless runs and unit tests. |
R_BACKEND_CUSTOM | Backend supplied with Rbackend_register (see raven_backend.h). |
typedef enum RError
R_NO_ERROR | |
R_ERROR_INVALID_ID | |
R_ERROR_INVALID_ENUM | |
R_ERROR_INVALID_VALUE | |
R_ERROR_INVALID_OPERATION | |
R_ERROR_BACKEND | |
R_ERROR_PLATFORM | |
R_ERROR_OUT_OF_MEMORY | |
R_ERROR_INVALID_FILE_FORMAT | |
R_ERROR_FILE_NOT_FOUND | |
R_ERROR_XML | |
R_ERROR_WRONG_THREAD |
typedef enum RSeverity
R_SEVERITY_WEAK_WARNING | |
R_SEVERITY_WARNING | |
R_SEVERITY_ERROR | |
R_SEVERITY_FATAL |
typedef struct RInitDesc
Optional settings for Rinit_ex. A zero-initialized structure selects the default for every field, so new fields can be added without breaking code.
RBackend backend | Rendering backend. 0 selects R_BACKEND_VULKAN. |
const char* app_name | Application name reported to the graphics driver. May be NULL. |
int worker_threads | Worker threads of the job system. 0 = one per spare CPU core, negative = none. |
int disable_render_thread | R_TRUE renders on the UI thread instead of a dedicated render thread. |
int disable_vsync | R_TRUE presents without waiting for the vertical blank. |
int enable_validation | R_TRUE enables the backend debug layer (Vulkan validation) when installed. |
int headless | R_TRUE opens no OS window (null platform). Combine with R_BACKEND_NULL for tests. |
float ui_scale | Global UI scale multiplier applied on top of the monitor scale. 0 = 1.0. |
typedef struct RAllocator
Memory functions of the application, to replace the allocator of Raven. See Rset_allocator.
(function) alloc | |
(function) realloc | |
(function) free | |
void* user_data |
typedef struct RMemoryStats
What the library holds. See Rmemory_get_stats.
size_t used_bytes | Bytes in the blocks currently allocated. 0 with the allocator of the application. |
size_t peak_bytes | Highest value of used_bytes since the start. |
size_t reserved_bytes | Bytes taken from the OS: used_bytes, plus what is free in the heap. |
size_t allocation_count | Blocks currently allocated. 0 after Rshutdown: anything else is a leak of the library. |
uint64_t total_allocations | Allocations made since the start. |
typedef struct RFrameStats
Timings and counters of the last frame produced for a window.
double layout_ms | |
double paint_ms | |
double render_ms | |
Ruint widget_count | |
Ruint instance_count | |
Ruint draw_call_count | |
Ruint backdrop_count | Glass: times the frame was copied and blurred to be seen through (0 without glass). |
Ruint paint_job_count | |
uint64_t frame_index |
int Rinit(RBackend backend);
Starts the library with default settings on the given backend. The calling thread becomes the UI thread.
int Rinit_ex(const RInitDesc* desc);
Starts the library with explicit settings.
void Rshutdown(void);
Destroys every window, widget and resource, stops the worker and render threads and releases the backend.
int Ris_initialized(void);
int Ris_free_edition(void);
@deprecated Raven no longer has editions: it is open source (Apache License 2.0) and never shows a watermark. Always R_FALSE.
const char* Rget_version(void);
void Rset_allocator(const RAllocator* allocator);
Replaces the allocator of Raven with the functions of the application (an engine allocator, a tracker...). NULL selects the allocator of Raven again. Must be called before Rinit, and before any other function that allocates. The functions are called from several threads; alloc must return memory aligned for any type (16 bytes).
const RAllocator* Rallocator_get_system(void);
void* Rmemory_alloc(size_t size);
Memory from the allocator of Raven (or from the one given to Rset_allocator), for the application: custom widgets, pixel buffers. Aligned on 16 bytes. Never returns NULL: running out of memory is a fatal error. Thread-safe.
void* Rmemory_realloc(void* ptr, size_t size);
Resizes a block, keeping its content. A NULL block is allocated. Thread-safe.
void Rmemory_free(void* ptr);
Frees a block. NULL is ignored. Thread-safe.
void Rmemory_get_stats(RMemoryStats* stats);
What the library holds right now. Thread-safe.
int Rmemory_check(void);
Walks the whole heap of Raven and verifies its structure.
void Rmemory_trim(void);
Returns to the OS the regions of the heap that hold nothing. Thread-safe.
int Rdraw_frame(void);
Produces one frame: processes the pending OS events without waiting, runs the posted tasks and the timers, then lays out, paints and submits every window that changed. A window in which nothing changed is not drawn again, so the call is cheap when the UI is idle.
int Rwait_frame(double timeout_seconds);
Same as Rdraw_frame, but first sleeps until there is something to do: an OS event, a posted task, a timer, an animation, a pending redraw.
void Rquit(int exit_code);
Makes Rdraw_frame and Rwait_frame return R_FALSE. Thread-safe.
int Rget_exit_code(void);
void Rpoll_events(void);
Processes the pending OS events without producing a frame. Rdraw_frame does it already: only useful to keep the windows responsive during a long operation.
void Rwait_events(double timeout_seconds);
Sleeps until an OS event, a posted task, a timer or a pending redraw, and processes the OS events. Rwait_frame does it already.
typedef void (*RFrameCallback)(double delta_seconds, void* user_data);
Registers a function called once per frame, before the layout. The body of your loop does the same job; the callback is also called while the OS keeps the thread in a loop of its own (on Windows, while the user moves or resizes a window), when your loop is not running.
void Rset_frame_callback(RFrameCallback callback, void* user_data);
double Rget_delta_time(void);
double Rget_time(void);
void Rset_ui_scale(float scale);
Scale of the whole interface, on top of the one of the monitor (RInitDesc.ui_scale at start): every window is laid out again. 0.25 .. 4.
void Rset_vsync(int enabled);
R_TRUE: every frame waits for the vertical synchronization of the screen (no tearing, no wasted frames); R_FALSE: as fast as possible (RInitDesc.disable_vsync at start). Takes effect at the next frame.
int Rget_vsync(void);
float Rget_ui_scale(void);
void Rset_animations_enabled(int enabled);
R_FALSE makes every change immediate: for users who ask for reduced motion (Raccessibility_set_reduce_motion), and for tests that read the state right after an input.
int Rget_animations_enabled(void);
void Rset_animation_speed(float speed);
Multiplies the speed of every animation. 1 is the default, 0.25 a slow motion.
float Rget_animation_speed(void);
void Rset_animation_time_step(double seconds);
When positive, each frame advances the animations by exactly this many seconds instead of the time really elapsed: frames rendered one by one for a video or a screenshot, deterministic tests. 0 follows the clock.
typedef void (*RTaskCallback)(void* user_data);
typedef void (*RParallelRangeCallback)(Ruint begin, Ruint end, void* user_data);
void Rtask_post(RTaskCallback task, void* user_data);
Queues a function to run on the UI thread during the next frame and wakes Rwait_frame. Thread-safe: this is how worker threads touch the UI.
void Rtask_run_async(RTaskCallback task, void* user_data);
Runs a function on a worker thread of the job system. Thread-safe.
void Rparallel_for(Ruint count, Ruint grain, RParallelRangeCallback function, void* user_data);
Splits [0, count) into ranges of at most grain items and runs them on the worker threads and the calling thread. Returns when all are done.
void Rwake_up(void);
Wakes Rwait_frame and Rwait_events from any thread.
int Rget_worker_thread_count(void);
int Ris_ui_thread(void);
typedef void (*RTimerCallback)(Rid timer, void* user_data);
Rid Rtimer_create(double interval_seconds, int repeat, RTimerCallback callback, void* user_data);
Calls a function on the UI thread after interval_seconds.
void Rtimer_destroy(Rid timer);
int Rtimer_is_valid(Rid timer);
typedef void (*RActionCallback)(Rid sender, const char* action, void* user_data);
Actions connect widgets to application code by name. A widget carries an action name (set from XML with OnClicked="file.save", or from C with Rwidget_set_action); when its main event fires, the function bound to that name is called. Names are resolved when the event fires, so actions can be bound before or after the widgets are created.
void Raction_bind(const char* name, RActionCallback callback, void* user_data);
void Raction_unbind(const char* name);
void Raction_fire(const char* name, Rid sender);
Fires an action as a widget would: the function bound to the name is called, or the default handler. What a tool bar button, a script or a test uses to do what a menu item does.
void Raction_set_default_handler(RActionCallback callback, void* user_data);
Receives every action that has no bound function (e.g. a script bridge).
int Ropen_url(const char* url);
Opens an address with the program the user has for it: a web page in the browser, a mailto: in the mail program, a file in its application. Returns at once.
void Rclipboard_set_text(const char* text);
const char* Rclipboard_get_text(void);
RError Rerror_get_last(const char** detail, RSeverity* severity);
Retrieves and clears the last recorded error.
const char* Rerror_to_string(RError error);
const char* Rseverity_to_string(RSeverity severity);
typedef void (*RErrorCallback)(RError code, RSeverity severity, const char* detail);
Registers a function called whenever an error is raised. The function may be registered before Rinit. It is called on the thread that raised the error: errors of the renderer (and the messages of the Vulkan validation layers) come from the render thread.
void Rerror_set_callback(RErrorCallback callback);
void Rwindow_get_frame_stats(Rid window, RFrameStats* stats);
OS windows, input enums and events.
Raven creates and owns its windows (Win32, X11, Cocoa on macOS). Sizes and positions are in logical units; multiply by Rwindow_get_scale to get pixels.
typedef enum RWindowFlags
R_WINDOW_DEFAULT | |
R_WINDOW_NO_RESIZE | |
R_WINDOW_HIDDEN | |
R_WINDOW_BORDERLESS | |
R_WINDOW_MAXIMIZED | |
R_WINDOW_CUSTOM_HEADER | No title bar from the OS: the content covers the whole window and draws its own header, with a R_WIDGET_HEADER_BAR (raven_shell.h) or with any widget given to Rwidget_set_window_drag. The window is still moved, resized, snapped and maximized by the OS, as it does for its own title bars. |
R_WINDOW_TRANSPARENT | The window can be seen through: where the application draws nothing opaque, what is behind the window on the screen shows (the desktop, the other applications), not a color of the application. Glass then looks at the screen itself. What the OS does to what shows through is chosen with Rwindow_set_backdrop. See RBackdrop for what each window system can do. |
typedef enum RBackdrop
What is seen behind a window created with R_WINDOW_TRANSPARENT.
Windows 11 every value Windows 10 TRANSPARENT, BLUR, ACRYLIC (MICA gives ACRYLIC) macOS TRANSPARENT; other backdrops fall back to transparency X11 TRANSPARENT with any compositing manager; BLUR where
the compositor blurs on request (KWin; picom and
others with their own settings); ACRYLIC and MICA
give BLUR
no compositor nothing: the window stays opaque
R_BACKDROP_NONE | Opaque: the window color, or the wallpaper of the theme. |
R_BACKDROP_TRANSPARENT | The screen behind the window, as it is. |
R_BACKDROP_BLUR | The screen behind the window, blurred by the OS. |
R_BACKDROP_ACRYLIC | Blurred, tinted and grained by the OS (the acrylic of Windows). |
R_BACKDROP_MICA | A soft tint taken from the wallpaper of the desktop (the mica of Windows 11). |
typedef enum RWindowSystem
R_WINDOW_SYSTEM_NONE | |
R_WINDOW_SYSTEM_WIN32 | |
R_WINDOW_SYSTEM_X11 | |
R_WINDOW_SYSTEM_WAYLAND | |
R_WINDOW_SYSTEM_COCOA |
typedef struct RNativeWindow
Native handles of a window or of a native viewport. Win32 : display = HINSTANCE, window = HWND X11 : display = Display*, window = Window (XID), visual = VisualID Cocoa : display = NSWindow*, window = CAMetalLayer* for Vulkan presentation
RWindowSystem system | |
void* display | |
uintptr_t window | |
uintptr_t visual | |
int transparent | R_TRUE when the window was created with R_WINDOW_TRANSPARENT and the window system gave it an alpha channel: what is presented in it must carry alpha (premultiplied), which a rendering backend asks for when it creates its surface. |
typedef enum RWindowEdge
Edges and corners of a window, for Rwindow_begin_resize.
R_EDGE_LEFT | |
R_EDGE_RIGHT | |
R_EDGE_TOP | |
R_EDGE_BOTTOM | |
R_EDGE_TOP_LEFT | |
R_EDGE_TOP_RIGHT | |
R_EDGE_BOTTOM_LEFT | |
R_EDGE_BOTTOM_RIGHT |
typedef enum RMouseButton
R_MOUSE_LEFT | |
R_MOUSE_RIGHT | |
R_MOUSE_MIDDLE | |
R_MOUSE_X1 | |
R_MOUSE_X2 |
typedef enum RModifier
R_MOD_SHIFT | |
R_MOD_CTRL | |
R_MOD_ALT | |
R_MOD_SUPER |
typedef enum RCursor
R_CURSOR_ARROW | |
R_CURSOR_IBEAM | |
R_CURSOR_HAND | |
R_CURSOR_CROSSHAIR | |
R_CURSOR_RESIZE_H | |
R_CURSOR_RESIZE_V | |
R_CURSOR_RESIZE_NWSE | |
R_CURSOR_RESIZE_NESW | |
R_CURSOR_MOVE | |
R_CURSOR_NOT_ALLOWED | |
R_CURSOR_NONE | No pointer at all (a game that hides it). Windows; elsewhere the arrow. |
typedef enum RKey
Keyboard keys. Printable keys use their upper-case ASCII code.
R_KEY_UNKNOWN | |
R_KEY_SPACE | |
R_KEY_APOSTROPHE | |
R_KEY_COMMA | |
R_KEY_MINUS | |
R_KEY_PERIOD | |
R_KEY_SLASH | |
R_KEY_0 | |
R_KEY_1 | |
R_KEY_2 | |
R_KEY_3 | |
R_KEY_4 | |
R_KEY_5 | |
R_KEY_6 | |
R_KEY_7 | |
R_KEY_8 | |
R_KEY_9 | |
R_KEY_SEMICOLON | |
R_KEY_EQUAL | |
R_KEY_A | |
R_KEY_B | |
R_KEY_C | |
R_KEY_D | |
R_KEY_E | |
R_KEY_F | |
R_KEY_G | |
R_KEY_H | |
R_KEY_I | |
R_KEY_J | |
R_KEY_K | |
R_KEY_L | |
R_KEY_M | |
R_KEY_N | |
R_KEY_O | |
R_KEY_P | |
R_KEY_Q | |
R_KEY_R | |
R_KEY_S | |
R_KEY_T | |
R_KEY_U | |
R_KEY_V | |
R_KEY_W | |
R_KEY_X | |
R_KEY_Y | |
R_KEY_Z | |
R_KEY_LEFT_BRACKET | |
R_KEY_BACKSLASH | |
R_KEY_RIGHT_BRACKET | |
R_KEY_GRAVE | |
R_KEY_ESCAPE | |
R_KEY_ENTER | |
R_KEY_TAB | |
R_KEY_BACKSPACE | |
R_KEY_INSERT | |
R_KEY_DELETE | |
R_KEY_RIGHT | |
R_KEY_LEFT | |
R_KEY_DOWN | |
R_KEY_UP | |
R_KEY_PAGE_UP | |
R_KEY_PAGE_DOWN | |
R_KEY_HOME | |
R_KEY_END | |
R_KEY_CAPS_LOCK | |
R_KEY_PRINT_SCREEN | |
R_KEY_PAUSE | |
R_KEY_F1 | |
R_KEY_F2 | |
R_KEY_F3 | |
R_KEY_F4 | |
R_KEY_F5 | |
R_KEY_F6 | |
R_KEY_F7 | |
R_KEY_F8 | |
R_KEY_F9 | |
R_KEY_F10 | |
R_KEY_F11 | |
R_KEY_F12 | |
R_KEY_KP_0 | |
R_KEY_KP_1 | |
R_KEY_KP_2 | |
R_KEY_KP_3 | |
R_KEY_KP_4 | |
R_KEY_KP_5 | |
R_KEY_KP_6 | |
R_KEY_KP_7 | |
R_KEY_KP_8 | |
R_KEY_KP_9 | |
R_KEY_KP_DECIMAL | |
R_KEY_KP_DIVIDE | |
R_KEY_KP_MULTIPLY | |
R_KEY_KP_SUBTRACT | |
R_KEY_KP_ADD | |
R_KEY_KP_ENTER | |
R_KEY_LEFT_SHIFT | |
R_KEY_LEFT_CTRL | |
R_KEY_LEFT_ALT | |
R_KEY_LEFT_SUPER | |
R_KEY_RIGHT_SHIFT | |
R_KEY_RIGHT_CTRL | |
R_KEY_RIGHT_ALT | |
R_KEY_RIGHT_SUPER | |
R_KEY_MENU | |
R_KEY_COUNT |
typedef enum REventType
R_EVENT_NONE | |
R_EVENT_MOUSE_MOVE | |
R_EVENT_MOUSE_DOWN | |
R_EVENT_MOUSE_UP | |
R_EVENT_MOUSE_WHEEL | |
R_EVENT_MOUSE_ENTER | |
R_EVENT_MOUSE_LEAVE | |
R_EVENT_KEY_DOWN | |
R_EVENT_KEY_UP | |
R_EVENT_TEXT | A character was typed. codepoint holds the Unicode scalar value. |
R_EVENT_FOCUS_GAINED | |
R_EVENT_FOCUS_LOST |
typedef struct REvent
Input event delivered to a widget. Mouse and key events bubble from the target widget to its parents until one of them handles the event.
REventType type | |
Rid window | |
Rid target | Widget the event was first sent to. |
float x | Cursor position in the window, in logical units. |
float y | Cursor position in the window, in logical units. |
float local_x | Cursor position relative to the widget receiving the event. |
float local_y | Cursor position relative to the widget receiving the event. |
float delta_x | Mouse movement since the previous event (R_EVENT_MOUSE_MOVE). |
float delta_y | Mouse movement since the previous event (R_EVENT_MOUSE_MOVE). |
float wheel_x | Scroll amount in lines, positive = up / left (R_EVENT_MOUSE_WHEEL). |
float wheel_y | Scroll amount in lines, positive = up / left (R_EVENT_MOUSE_WHEEL). |
RMouseButton button | |
int clicks | 1 = single click, 2 = double click, ... (R_EVENT_MOUSE_DOWN). |
RKey key | |
Ruint modifiers | Bitmask of RModifier. |
int repeat | R_TRUE when the key event comes from auto-repeat. |
Ruint codepoint |
typedef enum RDropPhase
Moments of a drag coming from another application (files from the file manager, text...).
R_DROP_ENTER | The pointer came over the target. |
R_DROP_MOVE | It moves over the target. |
R_DROP_LEAVE | It left the target without dropping. |
R_DROP_DROPPED | The user dropped: paths and text hold what was dropped. |
typedef struct RDropEvent
What a drop target receives. The files and the text are only known when the drop happens (R_DROP_DROPPED), and are valid during the callback.
RDropPhase phase | |
Rid window | |
float x | Pointer position in the window, and relative to the target widget. |
float y | Pointer position in the window, and relative to the target widget. |
float local_x | |
float local_y | |
const char*const* paths | Dropped files and folders, as UTF-8 paths. |
int path_count | |
const char* text | Dropped text when it is not files, or NULL. For a drag inside the application: its data. |
const char* drag_type | Drag inside the application (Rdrag_begin): its type, else NULL. Set in every phase. |
Rid drag_source | Widget the drag started from, or R_INVALID_ID. |
typedef int (*RDropCallback)(Rid target, const RDropEvent* event, void* user_data);
Called for a drop target (a widget, or a window: target is its handle). Return R_TRUE to accept: while the pointer is over the target this shows the "can drop here" cursor and highlights the target; for R_DROP_DROPPED it tells the source that the data was taken.
Rid Rwindow_create(const char* title, int width, int height, Ruint flags);
Opens a top-level window.
void Rwindow_destroy(Rid window);
Closes a window and deletes its content widgets.
int Rwindow_is_valid(Rid window);
void Rwindow_set_content(Rid window, Rid widget);
Sets the root widget of the window. The window takes ownership of the widget; the previous content is deleted.
void Rwindow_set_title(Rid window, const char* title);
const char* Rwindow_get_title(Rid window);
void Rwindow_set_size(Rid window, int width, int height);
void Rwindow_get_size(Rid window, int* width, int* height);
void Rwindow_set_min_size(Rid window, int width, int height);
void Rwindow_set_position(Rid window, int x, int y);
void Rwindow_get_position(Rid window, int* x, int* y);
void Rwindow_get_framebuffer_size(Rid window, int* width, int* height);
Size of the drawable area in pixels.
float Rwindow_get_scale(Rid window);
void Rwindow_show(Rid window);
void Rwindow_hide(Rid window);
void Rwindow_maximize(Rid window);
void Rwindow_minimize(Rid window);
void Rwindow_restore(Rid window);
int Rwindow_is_maximized(Rid window);
int Rwindow_is_minimized(Rid window);
void Rwindow_close(Rid window);
Asks to close the window, as the close button of its title bar does: the close callback is asked first and may refuse.
void Rwindow_begin_move(Rid window);
Custom headers. Call these from a mouse-down handler, while the left button is held: the window follows the pointer until the button is released (the widget does not receive the release). A R_WIDGET_HEADER_BAR and the widgets given to Rwidget_set_window_drag do it by themselves.
void Rwindow_begin_resize(Rid window, RWindowEdge edge);
void Rwindow_set_icon(Rid window, const uint8_t* rgba, int width, int height);
Icon of the window (title bar, task bar), from tightly packed RGBA8 pixels; NULL goes back to the default: on Windows the first icon of the executable, when it has one. Windows and X11.
void Rwindow_set_clear_color(Rid window, float r, float g, float b, float a);
void Rwindow_set_background(Rid window, Rid texture);
Image drawn behind the content, scaled to cover the window: what the glass of a glass theme looks through. R_INVALID_ID removes it.
int Rwindow_set_backdrop(Rid window, RBackdrop backdrop);
Chooses what shows behind a window created with R_WINDOW_TRANSPARENT (see RBackdrop). With anything but R_BACKDROP_NONE the window is not cleared with its color and the wallpaper of the theme is not drawn: only what the widgets draw hides the screen. In XML: <Window Backdrop="Blur">.
int Rwindow_set_opacity(Rid window, float opacity);
Opacity of the whole window, its frame included, from 0 to 1: a window that fades, a tool that lets what is under it show.
float Rwindow_get_opacity(Rid window);
int Rwindow_set_topmost(Rid window, int topmost);
Keeps the window above the other windows (splash screens, tools).
void Rwindow_center(Rid window);
Centers the window on the work area of its monitor (no task bar).
void Rwindow_request_redraw(Rid window);
Asks for a new frame even if no widget changed. Thread-safe.
void Rwindow_set_continuous_redraw(Rid window, int enabled);
R_TRUE redraws the window every frame (games, live viewports).
typedef int (*RWindowCloseCallback)(Rid window, void* user_data);
Called when the user asks to close the window. Return R_TRUE to let the window close, R_FALSE to keep it open.
void Rwindow_set_close_callback(Rid window, RWindowCloseCallback callback, void* user_data);
typedef void (*RWindowResizeCallback)(Rid window, int width, int height, void* user_data);
Called after the window was resized. Sizes are in logical units.
void Rwindow_set_resize_callback(Rid window, RWindowResizeCallback callback, void* user_data);
void Rwindow_set_drop_callback(Rid window, RDropCallback callback, void* user_data);
Takes what is dropped on the window from other applications, where no widget takes it (Rwidget_set_drop_callback). NULL removes it.
void Rwindow_set_user_handle(Rid window, void* handle);
void* Rwindow_get_user_handle(Rid window);
int Rwindow_get_native_handle(Rid window, RNativeWindow* native);
Fills native with the OS handles of the window.
uint8_t* Rwindow_capture(Rid window, int* width, int* height);
Reads back the last rendered frame as tightly packed RGBA8 pixels. Blocks until the frame is rendered. Free the result with Rpixels_free. The alpha is 255, except for a window that is seen through (R_WINDOW_TRANSPARENT): its pixels are then premultiplied by their alpha, as the window system receives them.
Rid Rwindow_get_focused_widget(Rid window);
Widget that has the keyboard focus in the window, or R_INVALID_ID.
Rid Rwindow_get_hovered_widget(Rid window);
Deepest widget under the cursor, or R_INVALID_ID.
void Rwindow_get_mouse_position(Rid window, float* x, float* y);
int Rwindow_get_watermark_rect(Rid window, float* x, float* y, float* width, float* height);
@deprecated Raven no longer shows a watermark. Always R_FALSE, with zeros.
void Rwindow_inject_mouse_move(Rid window, float x, float y);
Inject input as if it came from the OS. Positions are in logical units. Useful for automated tests, replays and when Raven is driven by a host application.
void Rwindow_inject_mouse_button(Rid window, RMouseButton button, int pressed);
void Rwindow_inject_mouse_wheel(Rid window, float wheel_x, float wheel_y);
void Rwindow_inject_text(Rid window, const char* text);
int Rwindow_inject_drag(Rid window, float x, float y, int inside);
A drag from another application moves over the window (inside R_TRUE) or leaves it.
int Rwindow_inject_drop(Rid window, float x, float y, const char*const* paths, int path_count, const char* text);
Drops files and / or text at a position. Returns R_TRUE when a target took them.
int Rwindow_is_key_down(Rid window, RKey key);
R_TRUE while the key is held down in the window (cleared when the window loses the keyboard).
int Rwindow_is_mouse_button_down(Rid window, RMouseButton button);
R_TRUE while the mouse button is held down over (or captured by) the window.
int Rwindow_wants_text_input(Rid window);
R_TRUE when the keyboard focus is in a text input, spin box or text editor.
typedef int (*RWindowEventHook)(Rid window, const REvent* event, void* user_data);
Sees every input event of the window (mouse, wheel, keys, text) before any widget, with target set to the widget under the pointer. Returning R_TRUE consumes the event: the widgets do not get it. The state read by Rwindow_is_key_down is updated either way.
void Rwindow_set_event_hook(Rid window, RWindowEventHook hook, void* user_data);
int Rdrag_begin(Rid source, const char* type, const char* data, const char* label);
Starts dragging data from source (call it while a mouse button is held, typically from a mouse-move event once the pointer has moved a few units). Until the button is released, the widgets with a drop callback (Rwidget_set_drop_callback) under the pointer receive R_DROP_ENTER / MOVE / LEAVE and, on release, R_DROP_DROPPED, with drag_type set and text = data. Returning R_FALSE from the callback refuses the drop there. Escape cancels. label follows the pointer.
int Rdrag_is_active(Rid window);
R_TRUE while a drag started by Rdrag_begin is in progress in the window.
const char* Rdrag_get_type(Rid window);
Type of the drag in progress, or NULL.
const char* Rdrag_get_data(Rid window);
Data of the drag in progress, or NULL.
void Rdrag_cancel(Rid window);
Ends the drag in progress without dropping (the target receives R_DROP_LEAVE).
Themes (colors, metrics, materials, styles, theme files).
Every widget reads its colors and sizes from a theme. A value is looked for in this order:
1. the widget itself Rwidget_set_color, Rwidget_set_metric, Color.Accent="#f00" 2. the styles rules of the theme for a type of widget ("Button"),
for a class (Class="danger"), or for both
3. the theme the theme of the application, or the one given to
an ancestor of the widget (Rwidget_set_theme,
Theme="Night"): a part of a window can have its own
A theme is one of the four built-in ones, or a file (see docs/THEMES.md):
<Theme Name="Night" Base="GlassDark" Accent="#FF9F0A">
<Colors Panel="#101018B0" Text="#FFF4E0"/>
<Metrics CornerRadius="14" ControlHeight="34"/>
<Style Widget="Button" Class="danger" Accent="#FF453A"/>
</Theme>
typedef enum RTheme
R_THEME_DARK | Flat, dense themes for tools. |
R_THEME_LIGHT | |
R_THEME_GLASS_DARK | Glass themes: controls are capsules of translucent glass that refract and blur what is behind them, catch the light on their rim and react to the pointer with short animations. Windows get a soft colored background unless they have their own (Rwindow_set_background, Rwindow_set_clear_color). |
R_THEME_GLASS_LIGHT | |
R_THEME_HIGH_CONTRAST_DARK | High contrast, for low vision: pure black and white, yellow (or blue) focus and selection, thick borders, larger text (raven_accessibility.h, Raccessibility_set_high_contrast). |
R_THEME_HIGH_CONTRAST_LIGHT |
typedef enum RMaterial
What surfaces are made of, from the clearest to the most opaque. A theme has one material for everything (Rtheme_set_material); any widget can be given its own (Rwidget_set_material, Material="..." in XML).
The three glasses share the same anatomy (a tint over what is behind, a rim that bends it and catches the light, a shadow) and differ by how much they let through. Within one material, surfaces are also told apart by their height above the window: bars lie flat, panels float a little, controls a little more, menus and dialogs highest; each level has a brighter rim and a deeper shadow than the one below.
R_MATERIAL_SOLID | Opaque: filled with the colors of the theme. The material of R_THEME_DARK and R_THEME_LIGHT. |
R_MATERIAL_GLASS | Clear glass: what is behind stays sharp enough to be recognized, strongly bent at the rim. |
R_MATERIAL_FROSTED_GLASS | Frosted glass: what is behind is blurred into soft colors. The material of the glass themes. |
R_MATERIAL_TINTED_GLASS | Frosted glass colored by the accent color of the theme (or of the widget): for what must stand out. |
R_MATERIAL_DEFAULT | Not a material: "the one of the theme". Removes the material given to a widget. |
typedef enum RColorRole
Color roles. The comment lists the widgets reading each role.
R_COLOR_WINDOW | Window clear color. |
R_COLOR_PANEL | Border background. |
R_COLOR_BORDER | Border outline, list and input outlines. |
R_COLOR_TEXT | Text. Inherited by the children of the widget it is set on. |
R_COLOR_TEXT_DISABLED | |
R_COLOR_TEXT_PLACEHOLDER | |
R_COLOR_ACCENT | Primary buttons, checked boxes, slider fill, progress fill. |
R_COLOR_ACCENT_HOVERED | |
R_COLOR_ACCENT_PRESSED | |
R_COLOR_ACCENT_TEXT | Text and marks drawn on top of the accent color. |
R_COLOR_CONTROL | Button, combo box, check box background. |
R_COLOR_CONTROL_HOVERED | |
R_COLOR_CONTROL_PRESSED | |
R_COLOR_CONTROL_BORDER | |
R_COLOR_INPUT | Text input, spin box, list and tree background. |
R_COLOR_FOCUS | Keyboard focus outline. |
R_COLOR_SELECTION | Selected rows and selected text. |
R_COLOR_ROW_HOVERED | |
R_COLOR_TRACK | Slider track, progress background, scrollbar track. |
R_COLOR_HANDLE | Scrollbar thumb, slider handle. |
R_COLOR_HANDLE_HOVERED | |
R_COLOR_SEPARATOR | |
R_COLOR_HEADER | Menu bar, tab bar, expander header. |
R_COLOR_HEADER_HOVERED | |
R_COLOR_TAB_ACTIVE | Active tab. |
R_COLOR_POPUP | Menus, combo box lists. |
R_COLOR_POPUP_BORDER | |
R_COLOR_SHADOW | |
R_COLOR_TOOLTIP | |
R_COLOR_TOOLTIP_TEXT | |
R_COLOR_SWITCH | Track of a switch that is on. |
R_COLOR_SUCCESS | What went well, what needs attention, what is wrong or destroys something (markers, badges, classes). |
R_COLOR_WARNING | |
R_COLOR_DANGER | |
R_COLOR_LINK | Links of formatted text. |
R_COLOR_CODE | Background of code in formatted text. |
typedef enum RMetric
Sizes, in logical units.
R_METRIC_FONT_SIZE | |
R_METRIC_CORNER_RADIUS | |
R_METRIC_BORDER_WIDTH | |
R_METRIC_CONTROL_HEIGHT | Height of buttons, inputs, combo boxes, tabs, menu bars. |
R_METRIC_PADDING_X | Horizontal / vertical padding inside controls. |
R_METRIC_PADDING_Y | |
R_METRIC_SPACING | Gap between an icon or a check mark and its text. |
R_METRIC_SCROLLBAR_SIZE | |
R_METRIC_ROW_HEIGHT | Height of list, tree and menu rows. |
R_METRIC_INDENT | Indentation per tree level. |
R_METRIC_SPLITTER_SIZE | |
R_METRIC_CHECK_SIZE | |
R_METRIC_SLIDER_HANDLE_SIZE | |
R_METRIC_POPUP_RADIUS | Corner radius of menus, drop-down lists and tooltips. |
R_METRIC_GLASS_FROST | The glass of the theme: each one multiplies what the material gives, 1 = unchanged. Frost (how much is blurred), refraction (how far the rim bends what is behind), saturation (of what is seen through), rim (the light it catches) and shadow (the one it drops). |
R_METRIC_GLASS_REFRACTION | |
R_METRIC_GLASS_SATURATION | |
R_METRIC_GLASS_RIM | |
R_METRIC_GLASS_SHADOW | |
R_METRIC_BLUR_RADIUS | Radius of the blur of a BackgroundBlur that was not given one. |
void Rtheme_apply(RTheme theme);
Switches to a built-in theme: replaces every theme color and metric. Colors and metrics changed with Rtheme_set_color and Rtheme_set_metric are lost; per-widget overrides are kept.
void Rtheme_set_color(RColorRole role, float r, float g, float b, float a);
void Rtheme_get_color(RColorRole role, float* r, float* g, float* b, float* a);
void Rtheme_set_metric(RMetric metric, float value);
float Rtheme_get_metric(RMetric metric);
void Rtheme_set_material(RMaterial material);
Material of every widget that was not given one with Rwidget_set_material. Rtheme_apply sets it: solid for the flat themes, frosted glass for the glass themes.
RMaterial Rtheme_get_material(void);
void Rtheme_set_font(Rid font);
Font used by widgets that have no font of their own.
Rid Rtheme_get_font(void);
void Rtheme_set_accent(float r, float g, float b);
Sets the accent color and everything that follows from it: its hovered and pressed shades, the focus outline, the selection, the links.
void Rtheme_set_dark(int dark);
Tells whether the theme is a dark one. It decides the tint of the glass, the colors of the code and which wallpaper the glass themes use. Rtheme_apply and the theme files set it.
int Rtheme_is_dark(void);
void Rtheme_set_wallpaper(Rid texture);
Image drawn behind the content of the windows that have no background of their own, or R_INVALID_ID for none (the window color).
Rid Rtheme_get_wallpaper(void);
void Rtheme_set_style_color(const char* widget, const char* style_class, RColorRole role, float r, float g, float b, float a);
Gives a color to the widgets of a type and / or of a class, instead of the color of the theme.
When several styles give the same value to a widget, the one with a type and a class wins over the one with a class, which wins over the one with a type; between equals, the last one set wins.
void Rtheme_set_style_metric(const char* widget, const char* style_class, RMetric metric, float value);
void Rtheme_set_style_material(const char* widget, const char* style_class, RMaterial material);
R_MATERIAL_DEFAULT removes the material of the style.
void Rtheme_clear_styles(void);
Removes every style of the theme. Rtheme_apply and Rtheme_use do it too.
const char* Rtheme_load(const char* path);
Reads a theme file and keeps the theme under its name (the Name attribute, else the name of the file). It does not change the theme in use unless a theme of that name is the one in use.
The file is watched like the interface files (Rxml_set_live_reload): saving it updates every widget that uses the theme.
const char* Rtheme_load_from_memory(const char* xml, size_t size);
Same, from a text. size may be 0 for a null-terminated text.
int Rtheme_use(const char* name);
Makes a named theme the theme of the application: "Dark", "Light", "GlassDark", "GlassLight", or a theme given by Rtheme_load. Values changed with Rtheme_set_... are lost.
const char* Rtheme_get_name(void);
Name of the theme in use ("Dark" at start).
int Rtheme_get_count(void);
Number of named themes, the four built-in ones included.
const char* Rtheme_get_name_at(int index);
Name of the index-th one, or NULL.
int Rtheme_save(const char* path, const char* name);
Writes the theme in use, with every change made since it was applied, as a theme file.
Fonts and textures.
typedef enum RFontStyle
The styles of a font (Rfont_get_variant).
R_FONT_REGULAR | |
R_FONT_BOLD | |
R_FONT_ITALIC | |
R_FONT_BOLD_ITALIC |
typedef enum RFilterType
R_FILTER_LINEAR | |
R_FILTER_NEAREST | No smoothing: keeps pixel art sharp. |
Rid Rfont_create(const char* data, size_t data_size);
Creates a font from the content of a .ttf / .otf file. The buffer is copied. Glyphs are rasterized on demand, at the exact pixel size needed by each window scale, into a shared atlas.
Rid Rfont_create_from_file(const char* path);
void Rfont_destroy(Rid font);
int Rfont_is_valid(Rid font);
Rid Rfont_get_default(void);
Rid Rfont_get_monospace(void);
void Rfont_set_fallback(Rid font, Rid fallback);
Font used for the characters missing from font (symbols, icons, other scripts). Fallbacks can be chained.
void Rfont_set_variant(Rid font, RFontStyle style, Rid variant);
Gives a font the font to use for one of its styles: the bold file of the same family, its italic file. Formatted text (Markdown labels, the Markdown of the text editor) uses them.
A font that was given none still has the three styles: Raven draws its glyphs thicker for bold and slanted for italic, keeping their advances, so that text does not move when its style changes.
Rid Rfont_get_variant(Rid font, RFontStyle style);
font: the one given with Rfont_set_variant, else the one Raven derives from it (made on first use; it lives as long as font and cannot be deleted by itself). Usable wherever a font is: Rlabel_set_font, Rdraw_text...void Rfont_measure_text(Rid font, float size, const char* text, float* width, float* height);
Measures a UTF-8 string, in logical units, at scale 1.
Rid Rtexture_create(const char* data, size_t data_size);
Creates a texture from the content of an image file (PNG, JPEG, BMP, TGA, GIF, PSD). Decoding happens on the calling thread.
Rid Rtexture_create_async(const char* data, size_t data_size);
Same as Rtexture_create, decoded on a worker thread. The handle is usable at once; widgets showing it draw nothing until it is ready. The buffer is copied.
Rid Rtexture_create_from_file(const char* path);
Rid Rtexture_create_from_file_async(const char* path);
Reads and decodes the file on a worker thread.
Rid Rtexture_create_from_pixels(const uint8_t* rgba, int width, int height);
Creates a texture from tightly packed RGBA8 pixels (straight alpha).
void Rtexture_update(Rid texture, const uint8_t* rgba, int width, int height);
Replaces the pixels of a texture. The size may change. Use it to show frames produced on the CPU or read back from another renderer.
uint8_t* Rimage_decode(const void* data, size_t data_size, int* width, int* height);
Decodes an image file held in memory (PNG, JPEG, BMP, TGA) into tightly packed RGBA8 pixels, without making a texture: for pictures that arrive one after the other and go to Rtexture_update. Thread-safe, so that the decoding can be done away from the UI thread.
void Rpixels_free(uint8_t* pixels);
Releases pixels returned by Raven (Rimage_decode, Rwindow_capture). Thread-safe.
int Rtexture_is_ready(Rid texture);
void Rtexture_wait(Rid texture);
Blocks until an asynchronous texture is ready.
void Rtexture_destroy(Rid texture);
int Rtexture_is_valid(Rid texture);
void Rtexture_get_size(Rid texture, int* width, int* height);
void Rtexture_set_filter(Rid texture, RFilterType filter);
Widget tree, slots and properties shared by every widget.
The layout model follows Unreal's Slate: - a widget computes a desired size from its content (bottom-up pass), - a panel then arranges its children inside the space it received
(top-down pass),
- how a child is placed inside its parent is described by its *slot*:
padding, alignment, auto / fill sizing, grid cell, canvas anchors.
A widget has at most one parent, so the slot is stored with the child and is edited with Rslot_set_...(child, ...). Slot values a panel does not use are ignored.
typedef enum RWidgetType
R_WIDGET_VBOX | Stacks children top to bottom. Slate: SVerticalBox. |
R_WIDGET_HBOX | Stacks children left to right. Slate: SHorizontalBox. |
R_WIDGET_GRID | Rows and columns with spans and fill coefficients. Slate: SGridPanel. |
R_WIDGET_UNIFORM_GRID | Grid whose cells all have the same size. Slate: SUniformGridPanel. |
R_WIDGET_OVERLAY | Draws children on top of each other. Slate: SOverlay. |
R_WIDGET_BORDER | One child with a background, an outline and inner padding. Slate: SBorder. |
R_WIDGET_SIZE_BOX | One child with size constraints or a fixed aspect ratio. Slate: SBox. |
R_WIDGET_SPACER | Empty space. Slate: SSpacer. |
R_WIDGET_SCROLL_BOX | Scrollable stack of children. Slate: SScrollBox. |
R_WIDGET_SPLITTER | Children separated by draggable handles. Slate: SSplitter. |
R_WIDGET_WRAP_BOX | Flows children and wraps to the next line. Slate: SWrapBox. |
R_WIDGET_CANVAS | Children placed with anchors and offsets. Slate: SConstraintCanvas. |
R_WIDGET_SWITCHER | Shows one child at a time. Slate: SWidgetSwitcher. |
R_WIDGET_TAB_VIEW | Tab bar + one page per child. |
R_WIDGET_EXPANDER | Collapsible header + one child. Slate: SExpandableArea. |
R_WIDGET_LABEL | |
R_WIDGET_BUTTON | |
R_WIDGET_CHECKBOX | |
R_WIDGET_SLIDER | |
R_WIDGET_PROGRESSBAR | |
R_WIDGET_IMAGE | |
R_WIDGET_TEXT_INPUT | |
R_WIDGET_SPIN_BOX | |
R_WIDGET_COMBO_BOX | |
R_WIDGET_SEPARATOR | |
R_WIDGET_LIST_VIEW | |
R_WIDGET_TREE_VIEW | |
R_WIDGET_MENU_BAR | |
R_WIDGET_MENU | |
R_WIDGET_MENU_ITEM | |
R_WIDGET_VIEWPORT | Area showing content rendered by the application. |
R_WIDGET_CUSTOM | Widget painted and measured by application callbacks. |
R_WIDGET_TEXT_EDITOR | Multi-line text editor. |
R_WIDGET_HEADER_BAR | Title bar of a window with a custom header, holding any widget. |
R_WIDGET_DOCK_AREA | Panels docked side by side or behind tabs, that the user rearranges. |
R_WIDGET_ISLAND | A capsule that unfolds into a panel, at the top of a window. |
R_WIDGET_FILE_BROWSER | Explorer of the files of the computer. |
R_WIDGET_BACKGROUND_BLUR | One child over a blurred view of what is behind it. |
R_WIDGET_COLOR_PICKER | Chooses a color: hue, saturation, value, opacity, by hand or by numbers. |
R_WIDGET_TIMELINE | Tracks of clips and keys along a time ruler. |
R_WIDGET_NODE_GRAPH | Nodes linked by wires, on a canvas that pans and zooms. |
R_WIDGET_TILE_VIEW | Grid of tiles (an icon over a name), virtualized. Slate: STileView. |
R_WIDGET_BLOCK_EDITOR | Blocks that snap into each other, in the style of Scratch. |
typedef enum RHAlign
R_HALIGN_FILL | |
R_HALIGN_LEFT | |
R_HALIGN_CENTER | |
R_HALIGN_RIGHT |
typedef enum RVAlign
R_VALIGN_FILL | |
R_VALIGN_TOP | |
R_VALIGN_CENTER | |
R_VALIGN_BOTTOM |
typedef enum RVisibility
R_VISIBLE | Drawn and laid out. |
R_HIDDEN | Not drawn, but still takes its space in the layout. |
R_COLLAPSED | Not drawn and takes no space. |
typedef enum RTransition
How a widget arrives. A transition animates what the widget and its children draw; the layout is not affected, the widget is in place from the first frame for its neighbours and for the mouse.
R_TRANSITION_NONE | |
R_TRANSITION_FADE | Becomes opaque. |
R_TRANSITION_POP | Grows from a smaller size and bounces a little past its own. |
R_TRANSITION_ZOOM | Shrinks from a larger size. |
R_TRANSITION_FLY_UP | Flies in from below / above / the right / the left, and settles with a bounce. |
R_TRANSITION_FLY_DOWN | |
R_TRANSITION_FLY_LEFT | |
R_TRANSITION_FLY_RIGHT | |
R_TRANSITION_DROP | Falls from above, squashes on landing and wobbles. |
R_TRANSITION_SLIDE_LEFT | Short slide from the right / from the left, without bounce: pages that replace one another. |
R_TRANSITION_SLIDE_RIGHT |
typedef enum ROrientation
R_HORIZONTAL | |
R_VERTICAL |
Rid Rwidget_create(RWidgetType type);
Creates a widget. It is not shown until it is added to a parent that belongs to a window (Rwidget_add_child, Rwindow_set_content).
void Rwidget_destroy(Rid widget);
Deletes a widget and all its descendants.
int Rwidget_is_valid(Rid widget);
RWidgetType Rwidget_get_type(Rid widget);
Rid Rwidget_add_child(Rid parent, Rid child);
Appends a child to a panel. The parent takes ownership. A widget that already has a parent is moved.
child, so calls can be nested: Rid ok = Rwidget_add_child(row, Rbutton_create("OK"));void Rwidget_remove_child(Rid parent, Rid child);
Detaches a child without deleting it. The caller owns it again.
void Rwidget_clear_children(Rid parent);
Deletes every child of a panel.
int Rwidget_get_child_count(Rid widget);
Rid Rwidget_get_window(Rid widget);
void Rwidget_set_name(Rid widget, const char* name);
const char* Rwidget_get_name(Rid widget);
Rid Rwidget_find(Rid scope, const char* name);
Finds a widget by name.
void Rslot_set_padding(Rid child, float left, float top, float right, float bottom);
Space kept around the child, inside its slot. All panels.
void Rslot_set_halign(Rid child, RHAlign align);
Alignment of the child inside its slot. Default: fill. All panels.
void Rslot_set_auto(Rid child);
The slot takes the desired size of the child along the panel direction (Slate AutoWidth / AutoHeight). This is the default. VBox, HBox.
void Rslot_set_fill(Rid child, float coefficient);
The slot shares the space left by the auto slots, in proportion to coefficient (Slate FillWidth / FillHeight). VBox, HBox. In a Splitter, the coefficient is the relative size of the pane.
void Rslot_set_max_size(Rid child, float max_size);
Upper bound of the slot along the panel direction. 0 = none. VBox, HBox.
void Rslot_set_grid(Rid child, int column, int row);
Cell of the child. Grid, UniformGrid.
void Rslot_set_grid_span(Rid child, int column_span, int row_span);
void Rslot_set_anchors(Rid child, float min_x, float min_y, float max_x, float max_y);
Canvas placement. Anchors are fractions of the canvas size (0..1). - anchors equal on an axis: the child is at anchor + position, with
the slot size (or its desired size when the slot size is <= 0);
- anchors different on an axis: the child stretches between them,
position and size are then the near and far margins.
Alignment is the pivot of the child (0,0 = top-left, 0.5,0.5 = center).
void Rslot_set_position(Rid child, float x, float y);
void Rslot_set_size(Rid child, float width, float height);
void Rslot_set_alignment(Rid child, float x, float y);
void Rslot_set_title(Rid child, const char* title);
Title of the tab showing the child. TabView.
void Rwidget_set_visibility(Rid widget, RVisibility visibility);
RVisibility Rwidget_get_visibility(Rid widget);
void Rwidget_set_enabled(Rid widget, int enabled);
A disabled widget ignores input and is drawn dimmed, with its descendants.
int Rwidget_is_enabled(Rid widget);
void Rwidget_set_hit_testable(Rid widget, int hit_testable);
R_FALSE lets mouse events pass through the widget (not its children).
void Rwidget_set_opacity(Rid widget, float opacity);
Opacity multiplier applied to the widget and its descendants (0..1).
void Rwidget_set_transition(Rid widget, RTransition transition, float delay_seconds);
Gives the widget a transition that plays each time it appears: when its window is first drawn, when it is added to a window that is shown, and when it becomes visible again (Rwidget_set_visibility, a tab or a switcher showing it). In XML: Appear="FlyUp" AppearDelay="0.1".
void Rwidget_play_transition(Rid widget, RTransition transition, float delay_seconds);
Plays a transition once, now, whatever the widget was given with Rwidget_set_transition.
void Rwidget_set_clipping(Rid widget, int clip);
R_TRUE clips the descendants to the bounds of the widget.
void Rwidget_set_tooltip(Rid widget, const char* text);
Text shown when the cursor rests on the widget. NULL removes it.
const char* Rwidget_get_tooltip(Rid widget);
void Rwidget_set_size(Rid widget, float width, float height);
Size constraints, in logical units. They apply to the desired size the widget reports to its parent. A negative value removes the constraint on that axis.
void Rwidget_set_min_size(Rid widget, float width, float height);
void Rwidget_set_max_size(Rid widget, float width, float height);
void Rwidget_get_rect(Rid widget, float* x, float* y, float* width, float* height);
Bounds of the widget in its window, in logical units, after the last layout.
void Rwidget_get_desired_size(Rid widget, float* width, float* height);
int Rwidget_is_hovered(Rid widget);
void Rwidget_set_focusable(Rid widget, int focusable);
void Rwidget_focus(Rid widget);
Gives the keyboard focus to the widget.
int Rwidget_is_focused(Rid widget);
void Rwidget_set_user_handle(Rid widget, void* handle);
void* Rwidget_get_user_handle(Rid widget);
typedef void (*RWidgetDestroyCallback)(Rid widget, void* user_data);
Called once when the widget is gone: deleted by the application, with its parent or its window, or by Rshutdown. The place to release what belonged to it (a texture, a connection). The handle it receives names nothing any more: it is only there to tell widgets apart. Called on the UI thread, shortly after the deletion.
void Rwidget_set_destroy_callback(Rid widget, RWidgetDestroyCallback callback, void* user_data);
typedef int (*RWidgetEventCallback)(Rid widget, const REvent* event, void* user_data);
Receives the input events of a widget before the widget itself. Return R_TRUE to consume the event (the widget and its parents will not see it), R_FALSE to let it continue.
void Rwidget_set_event_callback(Rid widget, RWidgetEventCallback callback, void* user_data);
void Rwidget_set_action(Rid widget, const char* action);
Name of the action fired by the main event of the widget: button click, value change, text commit, item activation (see Raction_bind).
const char* Rwidget_get_action(Rid widget);
void Rwidget_set_drop_callback(Rid widget, RDropCallback callback, void* user_data);
Makes the widget a target for what is dragged from other applications: files from the file manager, text. It is highlighted while a drop on it would be accepted. NULL removes the callback.
void Rwidget_set_window_drag(Rid widget, int enabled);
In a window created with R_WINDOW_CUSTOM_HEADER: dragging the widget moves the window and a double click maximizes it, as a title bar does. The buttons, fields and other controls inside it keep working. In XML: WindowDrag="true".
Rid Rwidget_hit_test(Rid root, float x, float y);
Deepest widget of a subtree under a point of its window, or R_INVALID_ID.
Rid Rwidget_pick(Rid root, float x, float y);
Deepest visible widget of a subtree under a point of its window, whether it reacts to the pointer or not: a label, a panel, a disabled button. What a design tool selects with a click.
void Rwidget_invalidate(Rid widget);
Asks for the widget to be laid out and painted again.
void Rwidget_set_color(Rid widget, RColorRole role, float r, float g, float b, float a);
Overrides a theme color for one widget. R_COLOR_TEXT is also inherited by its descendants.
void Rwidget_clear_color(Rid widget, RColorRole role);
void Rwidget_get_color(Rid widget, RColorRole role, float* r, float* g, float* b, float* a);
The color the widget is drawn with for a role: its own, else the one of the styles of its theme that apply to it, else the one of its theme. What a custom widget should draw itself with.
void Rwidget_set_material(Rid widget, RMaterial material);
Gives one widget a material of its own, whatever the theme: a solid button in a glass window, a panel of clear glass in a flat one. A widget that draws no surface (a box, a label) gets one of this material behind it: any widget can become a panel of glass. In XML: Material="Glass | FrostedGlass | TintedGlass | Solid".
RMaterial Rwidget_get_material(Rid widget);
void Rwidget_set_metric(Rid widget, RMetric metric, float value);
Overrides a theme metric for one widget.
float Rwidget_get_metric(Rid widget, RMetric metric);
void Rwidget_set_class(Rid widget, const char* classes);
Classes of the widget, separated by spaces ("danger large"): the styles of the theme made for these classes apply to it (Rtheme_set_style_color, <Style Class="danger" .../> in a theme file). In XML: Class="...". NULL or "" removes them.
const char* Rwidget_get_class(Rid widget);
void Rwidget_add_class(Rid widget, const char* style_class);
void Rwidget_remove_class(Rid widget, const char* style_class);
int Rwidget_has_class(Rid widget, const char* style_class);
int Rwidget_set_theme(Rid widget, const char* name);
Gives the widget and everything inside it a theme of their own, by name ("Dark", "GlassLight", or a theme of Rtheme_load): a dark side bar in a light window, a preview of another theme. Menus and lists opened from inside follow. In XML: Theme="...".
const char* Rwidget_get_theme(Rid widget);
Panels (widgets that arrange children).
Children are added with Rwidget_add_child and placed according to their slot (Rslot_set_..., raven_widget.h). This header holds the settings that belong to the panel itself.
Panel Slot values it reads ------------- ---------------------------------------------------------- VBox / HBox padding, halign, valign, auto / fill, max size Grid padding, halign, valign, grid cell, grid span UniformGrid padding, halign, valign, grid cell Overlay padding, halign, valign Border padding, halign, valign (single child) SizeBox padding, halign, valign (single child) ScrollBox padding, halign / valign across the scroll direction Splitter fill coefficient = relative pane size WrapBox padding Canvas anchors, position, size, alignment Switcher padding, halign, valign TabView title, padding Expander padding (single child)
typedef enum RBlurStyle
The looks of a R_WIDGET_BACKGROUND_BLUR. The first three are drawn by Raven from what the window shows behind the widget; the last one is the blur of the OS, which sees what is behind the window itself.
R_BLUR_PLAIN | What is behind, out of focus, and nothing else (a Gaussian blur). |
R_BLUR_FROSTED | Frosted: blurred, its colors a little stronger, under a veil of the panel color of the theme, a fine grain and a hairline. The default. |
R_BLUR_GLASS | Glass: a slab that bends what is behind at its rim and catches the light, as the glass materials do (RMaterial); the radius says how frosted it is. |
R_BLUR_NATIVE | Native: the widget opens the window there, and what shows is what the OS puts behind the window (Rwindow_set_backdrop: the blurred desktop, acrylic, mica), under a light veil. It needs a window created with R_WINDOW_TRANSPARENT that the OS could make see-through; anywhere else it is drawn as R_BLUR_FROSTED. The radius is the one of the OS. |
void Rpanel_set_spacing(Rid panel, float spacing);
Gap inserted between neighbouring children.
float Rpanel_get_spacing(Rid panel);
void Rgrid_set_column_fill(Rid grid, int column, float coefficient);
Lets a column / row grow to take a share of the free space (Slate FillColumn / FillRow). 0 sizes it to its content (default).
void Rgrid_set_row_fill(Rid grid, int row, float coefficient);
void Runiform_grid_set_columns(Rid grid, int columns);
Places children automatically, left to right then top to bottom, in the given number of columns. 0 uses the grid cell of each slot (default).
void Runiform_grid_set_min_cell_size(Rid grid, float width, float height);
void Rborder_set_padding(Rid border, float left, float top, float right, float bottom);
Space between the outline and the child.
void Rborder_set_background(Rid border, float r, float g, float b, float a);
Background color (R_COLOR_PANEL of this widget). Alpha 0 draws no background.
void Rborder_set_outline(Rid border, float width, float r, float g, float b, float a);
Outline width and color. Width 0 draws no outline (default).
void Rborder_set_corner_radius(Rid border, float top_left, float top_right, float bottom_right, float bottom_left);
void Rborder_set_shadow(Rid border, float blur, float offset_x, float offset_y);
Soft drop shadow behind the border. Blur 0 disables it (default).
void Rborder_set_material(Rid border, RMaterial material);
What the border is made of. R_MATERIAL_GLASS turns it into a panel of glass tinted by its background color (the alpha of the color is the strength of the tint): floating tool bars, side bars, cards.
void Rsize_box_set_aspect_ratio(Rid size_box, float ratio);
Keeps the child at a fixed width / height ratio, as large as fits. 0 disables it (default). The fixed, minimum and maximum sizes are set with Rwidget_set_size, Rwidget_set_min_size and Rwidget_set_max_size.
void Rspacer_set_size(Rid spacer, float width, float height);
void Rscroll_box_set_orientation(Rid scroll_box, ROrientation orientation);
Direction in which children are stacked and scrolled. Default: R_VERTICAL.
void Rscroll_box_set_scroll_both(Rid scroll_box, int enabled);
R_TRUE also scrolls across the stacking direction when the content is too large.
void Rscroll_box_set_offset(Rid scroll_box, float x, float y);
void Rscroll_box_get_offset(Rid scroll_box, float* x, float* y);
void Rscroll_box_scroll_to_end(Rid scroll_box);
void Rwidget_scroll_into_view(Rid widget);
Scrolls every ScrollBox above the widget so that the widget is visible.
void Rsplitter_set_orientation(Rid splitter, ROrientation orientation);
R_HORIZONTAL puts the panes side by side (default), R_VERTICAL stacks them.
void Rsplitter_set_min_pane_size(Rid splitter, float size);
Rid Rbackground_blur_create(void);
Creates a panel that shows what is behind it out of focus, with one child over it. In XML:
<BackgroundBlur Style="Frosted" Radius="24" CornerRadius="18" Padding="16">
<Label>Over a blurred view of the window</Label>
</BackgroundBlur>
It works in any theme and with any material: it is not the glass of the glass themes (which bends and reflects), but the looks of RBlurStyle. Unlike the opacity of a widget, it does not let what is behind show sharp.
void Rbackground_blur_set_style(Rid blur, RBlurStyle style);
RBlurStyle Rbackground_blur_get_style(Rid blur);
void Rbackground_blur_set_radius(Rid blur, float radius);
How far what is behind goes out of focus, in logical units: 4 softens, 20 hides the details, 60 leaves only colors. A negative value (the default) uses R_METRIC_BLUR_RADIUS of the theme.
float Rbackground_blur_get_radius(Rid blur);
void Rbackground_blur_set_tint(Rid blur, float r, float g, float b, float a);
Color laid over the blur; its alpha is how much of it. Without one, R_BLUR_PLAIN has none and the other styles take theirs from the theme (R_COLOR_PANEL).
void Rbackground_blur_clear_tint(Rid blur);
Removes the tint given with Rbackground_blur_set_tint.
void Rbackground_blur_set_saturation(Rid blur, float saturation);
Saturation of what is seen through: 1 = as it is, 0 = gray, 1.5 = vivid. Negative = the one of the style.
void Rbackground_blur_set_grain(Rid blur, float grain);
Fine grain over the blur, 0 = none .. 1. Negative = the one of the style.
void Rbackground_blur_set_corner_radius(Rid blur, float top_left, float top_right, float bottom_right, float bottom_left);
void Rbackground_blur_set_padding(Rid blur, float left, float top, float right, float bottom);
Space between the edge and the child.
void Rbackground_blur_set_shadow(Rid blur, float shadow_blur);
Soft shadow under the panel; blur 0 = none (default).
void Rswitcher_set_index(Rid switcher, int index);
int Rswitcher_get_index(Rid switcher);
int Rtab_view_add_tab(Rid tab_view, const char* title, Rid content);
Adds a page. Same as Rwidget_add_child followed by Rslot_set_title.
void Rtab_view_set_active(Rid tab_view, int index);
int Rtab_view_get_active(Rid tab_view);
typedef void (*RTabChangedCallback)(Rid tab_view, int index, void* user_data);
void Rtab_view_set_changed_callback(Rid tab_view, RTabChangedCallback callback, void* user_data);
void Rtab_view_set_documents(Rid tab_view, int documents);
Documents mode: the major tabs of an application (the level, then one tab per open asset, as in Unreal): tabs on the left with an icon and a close button (a middle click closes too), shrinking when they do not fit, no slide between pages. XML: Documents="true".
int Rtab_view_get_tab_count(Rid tab_view);
Rid Rtab_view_get_tab(Rid tab_view, int index);
The page of a tab, R_INVALID_ID if none.
void Rtab_view_set_tab_icon(Rid tab_view, Rid content, Rid texture, float u0, float v0, float u1, float v1, int tint);
Icon before the title (documents). R_INVALID_ID removes it; tint: a mask in the text color.
void Rtab_view_set_tab_closable(Rid tab_view, Rid content, int closable);
R_FALSE: no close button (documents ; the level tab). Tabs can be closed by default.
void Rtab_view_show_tab(Rid tab_view, Rid content);
Shows the tab of a page (the changed callback is called).
typedef int (*RTabCloseCallback)(Rid tab_view, int index, Rid content, void* user_data);
The user closes a tab (its button, a middle click). Return R_TRUE to delete its page now, R_FALSE to keep it (the application may ask to save, then delete the page itself with Rwidget_destroy).
void Rtab_view_set_close_callback(Rid tab_view, RTabCloseCallback callback, void* user_data);
void Rexpander_set_title(Rid expander, const char* title);
const char* Rexpander_get_title(Rid expander);
void Rexpander_set_expanded(Rid expander, int expanded);
int Rexpander_is_expanded(Rid expander);
typedef void (*RExpanderChangedCallback)(Rid expander, int expanded, void* user_data);
void Rexpander_set_changed_callback(Rid expander, RExpanderChangedCallback callback, void* user_data);
A right-to-left layout is a mirror of the left-to-right one: rows start on the right, texts are aligned to the right, the first column of a grid is on the right. By default (R_DIRECTION_AUTO) the windows follow the language (Rlocale_set_language: Arabic, Hebrew, Persian, Urdu...). The surfaces of their own (canvas, node graph, timeline, text editor, viewport) are not mirrored inside. In XML: Direction="RTL|LTR|Inherit".
typedef enum RDirection
R_DIRECTION_INHERIT | A widget: the direction of its parent (the default). |
R_DIRECTION_LTR | |
R_DIRECTION_RTL | |
R_DIRECTION_AUTO | The windows: the direction of the language. |
void Rset_layout_direction(RDirection direction);
Direction of every window: R_DIRECTION_AUTO (the default), _LTR or _RTL.
RDirection Rget_layout_direction(void);
The direction the windows use now: R_DIRECTION_LTR or _RTL.
void Rwidget_set_direction(Rid widget, RDirection direction);
Direction of a part of a window: R_DIRECTION_INHERIT, _LTR or _RTL.
RDirection Rwidget_get_direction(Rid widget);
The direction the widget is laid out in: R_DIRECTION_LTR or _RTL.
Interactive widgets and their settings.
Every control is created with Rwidget_create(type). Its colors and sizes come from the theme and can be overridden per widget (Rwidget_set_color, Rwidget_set_metric). Its main event can be received either through the typed callback declared here, or by name through an action (Rwidget_set_action + Raction_bind).
typedef enum RTextAlign
R_TEXT_ALIGN_LEFT | |
R_TEXT_ALIGN_CENTER | |
R_TEXT_ALIGN_RIGHT |
typedef enum RButtonStyle
R_BUTTON_DEFAULT | Filled with R_COLOR_CONTROL. |
R_BUTTON_PRIMARY | Filled with R_COLOR_ACCENT. |
R_BUTTON_FLAT | No background until hovered (toolbars). |
typedef enum RCheckboxStyle
R_CHECKBOX_CHECK | |
R_CHECKBOX_RADIO | Round mark. Checking one unchecks the other radio boxes of the same parent. |
R_CHECKBOX_SWITCH | On / off switch. |
typedef enum RStretch
R_STRETCH_FILL | Stretches the image to the widget, ignoring its aspect ratio. |
R_STRETCH_FIT | Largest size that fits entirely, keeping the aspect ratio. |
R_STRETCH_COVER | Smallest size that covers the widget, keeping the aspect ratio (cropped). |
R_STRETCH_NONE | Original size, centered. |
Rid Rlabel_create(const char* text);
Shortcut for Rwidget_create(R_WIDGET_LABEL) + Rlabel_set_text.
void Rlabel_set_text(Rid label, const char* text);
Sets the text. '\n' starts a new line.
const char* Rlabel_get_text(Rid label);
void Rlabel_set_font(Rid label, Rid font);
R_INVALID_ID uses the theme font.
void Rlabel_set_text_size(Rid label, float size);
Font size in logical units. 0 uses R_METRIC_FONT_SIZE.
void Rlabel_set_text_align(Rid label, RTextAlign align);
void Rlabel_set_color(Rid label, float r, float g, float b, float a);
Text color (R_COLOR_TEXT of this widget).
void Rlabel_set_markdown(Rid label, int enabled);
R_TRUE reads the text as Markdown and shows it formatted (Markdown="true" in XML):
# titles, **strong**, *emphasis*, code, ~~struck~~, [links](url), lists and lists in lists, - [x] task lists, > quotes, --- rules, | tables |, images alone on their line, and `` blocks of code with the colors of their language (`c, ``python...: the languages of the text editor, raven_text_editor.h).
The text wraps on the width of the label unless Rlabel_set_wrap said otherwise; put the label in a scroll box for a long document. Strong and emphasized text use the bold and italic of the font (Rfont_set_variant), which Raven derives from the font itself when it was given none. The colors come from the theme: R_COLOR_LINK, R_COLOR_CODE, R_COLOR_SEPARATOR, R_COLOR_ACCENT.
int Rlabel_get_markdown(Rid label);
typedef void (*RLabelLinkCallback)(Rid label, const char* url, void* user_data);
Called when the user clicks a link of a Markdown label.
Without a callback, a link written [Save](action:file.save) fires the action "file.save" (Raction_bind), and http, https and mailto links open in the browser or the mail program of the user (Ropen_url).
void Rlabel_set_link_callback(Rid label, RLabelLinkCallback callback, void* user_data);
const char* Rlabel_get_plain_text(Rid label);
The text of a Markdown label without its marks, as a reader sees it. Valid until the next call.
Rid Rbutton_create(const char* text);
Shortcut for Rwidget_create(R_WIDGET_BUTTON) + Rbutton_set_text.
void Rbutton_set_text(Rid button, const char* text);
Sets the content of the button to a label. A button can instead hold any single child widget (Rwidget_add_child), e.g. an HBox with an icon.
void Rbutton_set_style(Rid button, RButtonStyle style);
typedef void (*RButtonClickedCallback)(Rid button, void* user_data);
void Rbutton_set_clicked_callback(Rid button, RButtonClickedCallback callback, void* user_data);
Rid Rcheckbox_create(const char* text);
void Rcheckbox_set_text(Rid checkbox, const char* text);
const char* Rcheckbox_get_text(Rid checkbox);
void Rcheckbox_set_checked(Rid checkbox, int checked);
int Rcheckbox_is_checked(Rid checkbox);
void Rcheckbox_set_style(Rid checkbox, RCheckboxStyle style);
typedef void (*RCheckboxChangedCallback)(Rid checkbox, int checked, void* user_data);
void Rcheckbox_set_changed_callback(Rid checkbox, RCheckboxChangedCallback callback, void* user_data);
void Rslider_set_range(Rid slider, float minimum, float maximum);
void Rslider_set_value(Rid slider, float value);
float Rslider_get_value(Rid slider);
void Rslider_get_range(Rid slider, float* minimum, float* maximum, float* step);
The range given with Rslider_set_range and the step (NULL for what is not wanted).
void Rslider_set_step(Rid slider, float step);
Snaps the value to multiples of step. 0 = continuous (default).
void Rslider_set_orientation(Rid slider, ROrientation orientation);
typedef void (*RSliderChangedCallback)(Rid slider, float value, void* user_data);
void Rslider_set_changed_callback(Rid slider, RSliderChangedCallback callback, void* user_data);
void Rprogress_bar_set_value(Rid progress_bar, float value);
Progress between 0 and 1.
float Rprogress_bar_get_value(Rid progress_bar);
void Rimage_set_tint_color(Rid image, float r, float g, float b, float a);
void Rimage_set_tint_text(Rid image, int enabled);
R_TRUE: the image is tinted with the text color around it (white icons that follow the theme). XML: TintText.
void Rimage_set_region(Rid image, float min_u, float min_v, float max_u, float max_v);
Part of the texture to show, in UV coordinates. Default: 0, 0, 1, 1.
void Rimage_set_corner_radius(Rid image, float radius);
void Rtext_input_set_text(Rid text_input, const char* text);
const char* Rtext_input_get_text(Rid text_input);
void Rtext_input_set_placeholder(Rid text_input, const char* text);
Dimmed text shown while the input is empty.
void Rtext_input_set_password(Rid text_input, int password);
int Rtext_input_is_password(Rid text_input);
int Rtext_input_is_read_only(Rid text_input);
void Rtext_input_set_read_only(Rid text_input, int read_only);
void Rtext_input_set_max_length(Rid text_input, int max_length);
Maximum number of characters. 0 = no limit (default).
void Rtext_input_select_all(Rid text_input);
typedef void (*RTextChangedCallback)(Rid text_input, const char* text, void* user_data);
void Rtext_input_set_changed_callback(Rid text_input, RTextChangedCallback callback, void* user_data);
Called on every edit.
void Rtext_input_set_committed_callback(Rid text_input, RTextChangedCallback callback, void* user_data);
Called when Enter is pressed. This also fires the action of the widget.
void Rspin_box_set_range(Rid spin_box, double minimum, double maximum);
void Rspin_box_set_value(Rid spin_box, double value);
double Rspin_box_get_value(Rid spin_box);
void Rspin_box_get_range(Rid spin_box, double* minimum, double* maximum, double* step);
The range and the step (NULL for what is not wanted).
void Rspin_box_set_step(Rid spin_box, double step);
void Rspin_box_set_decimals(Rid spin_box, int decimals);
Digits shown after the decimal point. Default: 2.
typedef void (*RSpinBoxChangedCallback)(Rid spin_box, double value, void* user_data);
void Rspin_box_set_changed_callback(Rid spin_box, RSpinBoxChangedCallback callback, void* user_data);
int Rcombo_box_add_item(Rid combo_box, const char* text);
void Rcombo_box_clear_items(Rid combo_box);
int Rcombo_box_get_item_count(Rid combo_box);
const char* Rcombo_box_get_item_text(Rid combo_box, int index);
void Rcombo_box_set_selected(Rid combo_box, int index);
Selects an item. -1 selects nothing.
int Rcombo_box_get_selected(Rid combo_box);
typedef void (*RComboBoxChangedCallback)(Rid combo_box, int index, void* user_data);
void Rcombo_box_set_changed_callback(Rid combo_box, RComboBoxChangedCallback callback, void* user_data);
void Rseparator_set_orientation(Rid separator, ROrientation orientation);
R_HORIZONTAL draws a horizontal line (default).
int Rlist_view_add_item(Rid list_view, const char* text);
void Rlist_view_set_item_text(Rid list_view, int index, const char* text);
const char* Rlist_view_get_item_text(Rid list_view, int index);
void Rlist_view_remove_item(Rid list_view, int index);
void Rlist_view_clear_items(Rid list_view);
int Rlist_view_get_item_count(Rid list_view);
typedef const char* (*RListItemTextCallback)(Rid list_view, int index, void* user_data);
Virtual mode, for large or computed data: the list stores nothing and asks for the text of the rows it draws. The returned string must stay valid until the next call.
void Rlist_view_set_virtual_items(Rid list_view, int count, RListItemTextCallback callback, void* user_data);
void Rlist_view_set_selected(Rid list_view, int index);
Selects a row. -1 selects nothing.
int Rlist_view_get_selected(Rid list_view);
void Rlist_view_scroll_to_item(Rid list_view, int index);
typedef void (*RListEventCallback)(Rid list_view, int index, void* user_data);
void Rlist_view_set_selection_changed_callback(Rid list_view, RListEventCallback callback, void* user_data);
void Rlist_view_set_activated_callback(Rid list_view, RListEventCallback callback, void* user_data);
Called on double click or Enter. This also fires the action of the widget.
Rid Rtree_view_add_item(Rid tree_view, Rid parent_item, const char* text);
Adds an item.
void Rtree_item_destroy(Rid item);
Deletes an item and its descendants.
void Rtree_view_clear_items(Rid tree_view);
int Rtree_item_is_valid(Rid item);
void Rtree_item_set_text(Rid item, const char* text);
const char* Rtree_item_get_text(Rid item);
void Rtree_item_set_expanded(Rid item, int expanded);
int Rtree_item_is_expanded(Rid item);
void Rtree_item_set_user_handle(Rid item, void* handle);
void* Rtree_item_get_user_handle(Rid item);
int Rtree_view_get_item_count(Rid tree_view);
Top-level items of a tree.
Rid Rtree_item_get_parent(Rid item);
int Rtree_item_get_child_count(Rid item);
void Rtree_view_set_selected_item(Rid tree_view, Rid item);
Selects an item. R_INVALID_ID selects nothing.
void Rtree_view_set_selection_changed_callback(Rid tree_view, RTreeEventCallback callback, void* user_data);
void Rtree_view_set_activated_callback(Rid tree_view, RTreeEventCallback callback, void* user_data);
Called on double click or Enter. This also fires the action of the widget.
void Rtree_item_set_icon(Rid item, Rid texture, float u0, float v0, float u1, float v1);
Icon drawn before the text of the item (a region u0,v0,u1,v1 of the texture). R_INVALID_ID removes it.
void Rtree_item_set_text_color(Rid item, float r, float g, float b, float a);
Color of the text of the item; alpha 0 goes back to the theme.
void Rtree_view_set_multi_select(Rid tree_view, int enabled);
Several items can be selected: Ctrl + click adds or removes one, Shift + click selects a range. The selection callback receives the item clicked last (the primary one, Rtree_view_get_selected_item).
void Rtree_item_set_selected(Rid item, int selected);
int Rtree_item_is_selected(Rid item);
void Rtree_view_clear_selection(Rid tree_view);
int Rtree_view_get_selection_count(Rid tree_view);
Selected items, top to bottom.
typedef void (*RTreeContextCallback)(Rid tree_view, Rid item, float x, float y, void* user_data);
Right click: item is the item under the pointer (selected first), or R_INVALID_ID in the empty space; x, y in the window, for Rmenu_open.
void Rtree_view_set_context_callback(Rid tree_view, RTreeContextCallback callback, void* user_data);
void Rtree_view_set_drag_type(Rid tree_view, const char* type);
Items can be dragged: the selection is given to Rdrag_begin with this type and, as data, the handles of the items in decimal separated by spaces. NULL: no drag (default).
Rid Rtree_view_get_item_at(Rid tree_view, float local_x, float local_y);
Item at a point relative to the tree (drop callbacks give local_x, local_y), or R_INVALID_ID.
void Rtree_view_set_drop_highlight(Rid tree_view, Rid item, int whole_tree);
Highlights where a drop would go: an item, or the whole tree (whole_tree). R_INVALID_ID, 0 removes it.
typedef void (*RMenuItemClickedCallback)(Rid item, void* user_data);
void Rwindow_close_popups(Rid window);
Closes every open menu and popup of the window.
typedef struct RTileItem
What a tile shows, filled by the application when the tile is drawn.
const char* text | Name under the icon (valid until the callback returns). |
const char* detail | Second line, dimmer, or NULL. |
const char* badge | Small text at the top right of the tile, or NULL. |
Rid icon | Icon texture (R_INVALID_ID: none), the region of it and its tint (white by default). |
float uv[4] | |
float tint[4] | |
float icon_radius | |
float text_color[4] | Color of the name; alpha 0 = the theme. |
typedef void (*RTileItemCallback)(Rid tile_view, int index, RTileItem* item, void* user_data);
Fills item for tile index. Called on the UI thread, only for the tiles in view.
typedef void (*RTileEventCallback)(Rid tile_view, int index, void* user_data);
Selection change (index: the current tile, or -1) and activation (double click, Enter).
typedef void (*RTileContextCallback)(Rid tile_view, int index, float x, float y, void* user_data);
Right click: the tile under the pointer (selected first), or -1 in the empty space; x, y in the window.
void Rtile_view_set_items(Rid tile_view, int count, RTileItemCallback callback, void* user_data);
Gives the tiles: count of them, described by callback. The selection is cleared.
void Rtile_view_refresh(Rid tile_view);
Draws the tiles again (their description changed, not their number).
int Rtile_view_get_count(Rid tile_view);
void Rtile_view_set_tile_size(Rid tile_view, float width, float height, float icon_size);
Size of a tile (its name included) and of its icon. Default 112 x 112, icon 64.
void Rtile_view_set_empty_text(Rid tile_view, const char* text);
void Rtile_view_set_selected(Rid tile_view, int index, int selected);
int Rtile_view_is_selected(Rid tile_view, int index);
void Rtile_view_clear_selection(Rid tile_view);
void Rtile_view_select_only(Rid tile_view, int index);
int Rtile_view_get_current(Rid tile_view);
The tile clicked last, or -1.
int Rtile_view_get_selection_count(Rid tile_view);
int Rtile_view_get_selection(Rid tile_view, int nth);
Index of the nth selected tile, in order.
void Rtile_view_scroll_to(Rid tile_view, int index);
int Rtile_view_get_item_at(Rid tile_view, float local_x, float local_y);
Tile at a point relative to the widget (drop callbacks give local_x, local_y), or -1.
void Rtile_view_set_drop_highlight(Rid tile_view, int index);
Highlights the tile a drop would go to; -1 removes it.
void Rtile_view_set_drag_type(Rid tile_view, const char* type);
Tiles can be dragged: the selected tiles are given to Rdrag_begin with this type and, as data, their indices separated by spaces.
typedef const char* (*RTileDragDataCallback)(Rid tile_view, void* user_data);
The data of a drag, given by the application (paths of files...) instead of the indices: the dragged tiles are the selected ones (Rtile_view_get_selection). The text returned is copied; NULL keeps the indices.
void Rtile_view_set_drag_data_callback(Rid tile_view, RTileDragDataCallback callback, void* user_data);
void Rtile_view_set_selection_changed_callback(Rid tile_view, RTileEventCallback callback, void* user_data);
void Rtile_view_set_activated_callback(Rid tile_view, RTileEventCallback callback, void* user_data);
void Rtile_view_set_context_callback(Rid tile_view, RTileContextCallback callback, void* user_data);
Multi-line text editor, and the languages it knows.
R_WIDGET_TEXT_EDITOR edits a text of any number of lines: selection with the mouse and the keyboard, clipboard, undo and redo, line numbers, word wrap. It scrolls by itself. In XML:
<TextEditor Name="notes" Wrap="true" Placeholder="Write here"/>
<TextEditor Language="Rust" LineNumbers="true" Slot.Fill="1"/>
Given a language, the editor colors the text, proposes words while typing (the words of the language and the names already written in the text), shows which bracket closes which, indents after an opening bracket, closes brackets and quotes, and comments lines out. C, C++, C#, Java, JavaScript, TypeScript, Python, Rust, GLSL, JSON, CSS, XML and HTML are built in; any of them can be changed, and others declared, with Rlanguage_register.
This is what the editor knows from the text alone. What needs to understand a whole program (the type of an expression, the errors of a compiler) comes from outside, through two doors: a completion callback that adds its own proposals, and markers that underline a part of the text with a message.
Positions are a line and a column, both starting at 0; a column is a byte offset in the UTF-8 text of its line. Out-of-range positions are clamped.
Keys: arrows, Home / End, Page Up / Down, with Ctrl to move by word or to the ends of the text and with Shift to select; Ctrl+A, C, X, V; Ctrl+Z, Ctrl+Y or Ctrl+Shift+Z; Tab and Shift+Tab indent the selected lines; Ctrl+Space proposes words; Ctrl+/ comments the selected lines out. A double click selects a word, a triple click a line.
typedef enum RSyntax
Shorthands of Rtext_editor_set_language for two languages.
R_SYNTAX_NONE | |
R_SYNTAX_XML | |
R_SYNTAX_C |
typedef enum RLanguageFlags
R_LANGUAGE_MARKUP | Tags and attributes instead of code: XML, HTML. The words and the comments of the description are not used. |
R_LANGUAGE_STYLE_SHEET | Selectors, properties and values: CSS. |
R_LANGUAGE_NESTED_COMMENTS | A block comment may hold another one (Rust). |
R_LANGUAGE_CHAR_LITERALS | Between single quotes there is one character; any other single quote is not a text (C, Java, Rust). |
R_LANGUAGE_INDENT_ON_COLON | A line that ends with ':' indents the next one (Python). |
R_LANGUAGE_IGNORE_CASE | The words of the language are recognized whatever their case. |
R_LANGUAGE_EMBEDS | Markup that holds JavaScript in script elements and CSS in style elements (HTML). |
R_LANGUAGE_FORMATTED_TEXT | Formatted text written in Markdown: titles, strong and emphasized text, code, links, lists. The editor shows the text as it is written, marks included, with strong text in bold, emphasized text in italic and titles in bold: what will be formatted is seen while typing. |
typedef struct RLanguageDesc
What the editor knows of a language. Every field but the name may be NULL. Lists of words are separated by spaces.
const char* name | "Rust". Compared without case. |
const char* extensions | Extensions of its files, separated by ';': "rs". |
const char* keywords | Words of the language itself: if, while, return... |
const char* types | Names of types and of what is always there: int, String, print... |
const char* constants | Values with a name: true, false, null... |
const char* line_comment | What starts a comment that ends with its line: two slashes, a hash. |
const char* block_comment_start | What opens and closes a comment that may span lines. |
const char* block_comment_end | |
const char* string_quotes | Characters that open and close a text on one line: a double quote, a single quote. |
const char* multiline_strings | Marks of the texts that span lines, separated by spaces: three double quotes, a backquote. When what closes such a text is not what opens it, write both around three dots: R"(...)" . Nothing is escaped in those. |
const char* directive | What starts a line for the preprocessor: "#". |
const char* annotation | What starts an annotation: "@" (@Override), or "#[" up to its closing bracket. |
Ruint flags | Bitmask of RLanguageFlags. |
const char* script_language | Markup with R_LANGUAGE_EMBEDS: the language of what is between <script> and </script> (the name of a language: "C", "Rust"...). NULL: JavaScript, as in HTML. The XMLC, XMLRS, XMLPY... languages of Raven use it for the code of their files. |
typedef enum RToken
What a part of the text is, for the language of the editor (Rtext_editor_get_token).
R_TOKEN_TEXT | |
R_TOKEN_COMMENT | |
R_TOKEN_STRING | |
R_TOKEN_NUMBER | |
R_TOKEN_KEYWORD | |
R_TOKEN_TYPE | A type, or a name that is always there. |
R_TOKEN_FUNCTION | A name followed by an opening parenthesis. |
R_TOKEN_TAG | The name of an element, in markup and in the selectors of a style sheet. |
R_TOKEN_ATTRIBUTE | The name of an attribute (markup), of a class or of a property (style sheets), of a key (JSON). |
R_TOKEN_PUNCTUATION | |
R_TOKEN_DIRECTIVE | A line for the preprocessor, an annotation, a declaration of a document. |
R_TOKEN_HEADING | Formatted text (the Markdown language): a title, strong text, emphasized text, a link. |
R_TOKEN_STRONG | |
R_TOKEN_EMPHASIS | |
R_TOKEN_LINK |
typedef enum RMarkerKind
What a marker says about the text it underlines.
R_MARKER_ERROR | |
R_MARKER_WARNING | |
R_MARKER_INFO |
Rid Rtext_editor_create(const char* text);
void Rtext_editor_set_text(Rid editor, const char* text);
Replaces the whole text. The history of undo is cleared; the changed callback is not called.
const char* Rtext_editor_get_text(Rid editor);
int Rtext_editor_get_length(Rid editor);
int Rtext_editor_get_line_count(Rid editor);
const char* Rtext_editor_get_line(Rid editor, int line);
line is out of range.void Rtext_editor_insert_text(Rid editor, const char* text);
Types a text at the cursor, replacing the selection, as the user would: it can be undone and the changed callback is called.
void Rtext_editor_set_cursor(Rid editor, int line, int column);
void Rtext_editor_get_cursor(Rid editor, int* line, int* column);
void Rtext_editor_select(Rid editor, int from_line, int from_column, int to_line, int to_column);
Selects from one position to another; the cursor is on the second.
void Rtext_editor_select_all(Rid editor);
int Rtext_editor_get_selection(Rid editor, int* from_line, int* from_column, int* to_line, int* to_column);
Start and end of the selection, in the order of the text. Returns R_FALSE when nothing is selected.
const char* Rtext_editor_get_selected_text(Rid editor);
void Rtext_editor_scroll_to_line(Rid editor, int line);
Scrolls so that a line is visible.
void Rtext_editor_undo(Rid editor);
void Rtext_editor_redo(Rid editor);
int Rtext_editor_can_undo(Rid editor);
int Rtext_editor_can_redo(Rid editor);
void Rtext_editor_set_read_only(Rid editor, int read_only);
A read-only editor can still be scrolled, selected and copied.
void Rtext_editor_set_word_wrap(Rid editor, int enabled);
Long lines continue on the next row instead of scrolling sideways. Off by default.
void Rtext_editor_set_line_numbers(Rid editor, int enabled);
Shows the line numbers in a margin. Off by default.
void Rtext_editor_set_tab_size(Rid editor, int spaces);
Width of a tab, in spaces (4 by default).
void Rtext_editor_set_tab_inserts_spaces(Rid editor, int enabled);
R_TRUE makes the Tab key insert spaces instead of a tab character. Off by default.
void Rtext_editor_set_syntax(Rid editor, RSyntax syntax);
The same as Rtext_editor_set_language with "XML", "C" or NULL.
void Rtext_editor_set_font(Rid editor, Rid font, float size);
void Rtext_editor_set_placeholder(Rid editor, const char* text);
Text shown, dimmed, while the editor is empty.
void Rtext_editor_set_zoom(Rid editor, float zoom);
Zoom of the text: a factor of its font size, 1 = 100 % (0.5 .. 4). The user zooms with Ctrl + wheel (around the pointer), Ctrl + '+', Ctrl + '-' and Ctrl + 0 (back to 100 %), keypad included. Set by the program, the top of the view stays and the zoom callback is not called. XML: Zoom="1.25".
float Rtext_editor_get_zoom(Rid editor);
void Rtext_editor_set_zoomable(Rid editor, int zoomable);
R_FALSE: Ctrl + wheel and the keys do not zoom (the wheel scrolls). On by default. XML: Zoomable="false".
typedef void (*RTextEditorZoomCallback)(Rid editor, float zoom, void* user_data);
Called when the user zoomed (to zoom other editors the same, or to keep it for the next time).
void Rtext_editor_set_zoom_callback(Rid editor, RTextEditorZoomCallback callback, void* user_data);
int Rlanguage_register(const RLanguageDesc* desc);
Declares a language, or replaces the one that has this name: to add words to a built-in language, read it with Rlanguage_get, change what you want and register it again. The strings are copied.
int Rlanguage_get(const char* name, RLanguageDesc* desc);
Reads the description of a language. The strings belong to the library. Returns R_FALSE when it is unknown.
int Rlanguage_get_count(void);
const char* Rlanguage_get_name(int index);
const char* Rlanguage_for_file(const char* path);
void Rtext_editor_set_language(Rid editor, const char* name);
Gives the editor a language, by name ("C++", "Python"...), by another usual name ("cpp", "js") or by the extension of its files ("rs"). NULL or "" removes it. An editor with a language uses the fixed-width font unless it was given a font.
const char* Rtext_editor_get_language(Rid editor);
void Rtext_editor_set_markdown(Rid editor, int enabled);
R_TRUE makes the editor an editor of Markdown (the "Markdown" language; Markdown="true" in XML): the text stays as it is written, and what it formats shows while typing, strong text in bold, emphasized text in italic, titles in bold, code, links and marks in their colors. A label with Rlabel_set_markdown shows the same text formatted. R_FALSE removes the language.
int Rtext_editor_get_markdown(Rid editor);
RToken Rtext_editor_get_token(Rid editor, int line, int column);
What the language of the editor makes of the character at a position: the colors come from it. R_TOKEN_TEXT without a language.
void Rtext_editor_set_completion(Rid editor, int enabled);
R_FALSE stops the editor from proposing words by itself; Ctrl+Space still does. On by default.
void Rtext_editor_show_completions(Rid editor);
Proposes words for what is before the cursor, as Ctrl+Space does.
int Rtext_editor_is_completing(Rid editor);
typedef void (*RCompletionCallback)(Rid editor, const char* prefix, void* user_data);
Called each time the editor gathers its proposals, with the start of the word being typed: add your own with Rtext_editor_add_completion (the fields of a structure, the answers of a language server...). They are listed before the others.
void Rtext_editor_set_completion_callback(Rid editor, RCompletionCallback callback, void* user_data);
void Rtext_editor_add_completion(Rid editor, const char* text, const char* detail);
Adds a proposal. Only from a completion callback. Proposals that do not start with the prefix are left out; the others keep the order they were added in.
void Rtext_editor_set_auto_pairs(Rid editor, int enabled);
R_FALSE stops the editor from closing brackets and quotes and from indenting after them. On by default; it only acts with a language.
void Rtext_editor_add_marker(Rid editor, int line, int from_column, int to_column, RMarkerKind kind, const char* message);
Underlines a part of a line and attaches a message to it, shown when the pointer rests there: an error of a compiler, a warning. Markers follow their line when text is added or removed above it, and go away when their own line is edited.
void Rtext_editor_clear_markers(Rid editor);
int Rtext_editor_get_marker_count(Rid editor);
void Rtheme_set_token_color(RToken token, float r, float g, float b, float a);
Color of a kind of token in the theme in use, instead of the one Raven picks for dark and for light themes. Theme files set them with <Syntax Keyword="#FF7AB2" String="..."/>.
void Rtheme_get_token_color(RToken token, float* r, float* g, float* b, float* a);
void Rtheme_clear_token_colors(void);
Back to the colors Raven picks.
typedef void (*RTextEditorChangedCallback)(Rid editor, void* user_data);
Called after each change made by the user (typing, pasting, undoing...) or by Rtext_editor_insert_text. The action of the widget (OnChanged in XML) fires at the same time.
void Rtext_editor_set_changed_callback(Rid editor, RTextEditorChangedCallback callback, void* user_data);
What frames an application: its header bar and its docked panels.
HEADER BAR
A window created with R_WINDOW_CUSTOM_HEADER has no title bar from the OS: its content covers the whole window and draws the title bar itself. The simplest way is a R_WIDGET_HEADER_BAR at the top of the content:
<Window Title="Notes" CustomHeader="true" Width="900" Height="600">
<VBox>
<HeaderBar>
<Button Text="Open" Style="Flat"/>
<TextInput Placeholder="Search" Width="180" Slot.HAlign="Right"/>
</HeaderBar>
...
</VBox>
</Window>
The bar shows the title of the window and the close / minimize / maximize buttons, and holds any widget: its children are placed from the left, and from the right for those with Slot.HAlign="Right". Dragging the bar moves the window, a double click maximizes it, the edges of the window resize it: all of that is done by the window system itself where it can (Windows: snapping, the system menu and the shake gesture keep working).
Any other widget becomes a handle to move the window with Rwidget_set_window_drag (raven_widget.h), without a header bar at all.
DOCK AREA
A R_WIDGET_DOCK_AREA arranges its children as panels with a tab each: side by side, one above the other, or stacked behind the same tabs. The user drags a tab to move its panel elsewhere, drags the borders to resize, and closes panels. In XML, how a child is docked is given by its slot:
<DockArea Name="dock" Slot.Fill="1">
<TextEditor Name="source" Slot.Title="Source"/>
<TreeView Name="files" Slot.Title="Files" Slot.Dock="Left" Slot.DockSize="0.22"/>
<ListView Name="log" Slot.Title="Output" Slot.Dock="Bottom" Slot.DockSize="0.3"/>
<Label Slot.Title="Problems" Slot.Dock="Tab" Slot.DockTo="log"/>
</DockArea>
ISLAND
A R_WIDGET_ISLAND is a small dark capsule that unfolds into a panel when the pointer comes over it or when it is clicked, and folds back: a notch made useful, for what is going on right now (a download, a timer, the track being played) and the controls that go with it. Its first child is what it shows folded, its second child what it shows unfolded; both are any widgets. Nothing has to use one.
In XML, an <Island> written in a <Window> next to its content floats at the top of the window, in the middle, above the content:
<Window Title="Player">
<Island Slot.Padding="0,8,0,0">
<Label>Now playing</Label>
<VBox Spacing="8" Width="260">
<Label>Clair de lune</Label>
<Slider Name="position"/>
</VBox>
</Island>
<VBox> ... </VBox>
</Window>
An island is also a widget like any other, to place anywhere in a layout.
typedef enum RHeaderButtons
Buttons of a header bar.
R_HEADER_NO_BUTTONS | |
R_HEADER_CLOSE | |
R_HEADER_MINIMIZE | |
R_HEADER_MAXIMIZE | |
R_HEADER_ALL_BUTTONS |
typedef enum RDockSide
Where a panel goes in a dock area, relative to another panel or to the whole area.
R_DOCK_LEFT | |
R_DOCK_RIGHT | |
R_DOCK_TOP | |
R_DOCK_BOTTOM | |
R_DOCK_TAB | Behind the same tabs as the other panel. |
Rid Rheader_bar_create(const char* title);
void Rheader_bar_set_title(Rid bar, const char* title);
void Rheader_bar_set_buttons(Rid bar, Ruint buttons);
void Rheader_bar_set_button_side(Rid bar, RHAlign side);
void Rheader_bar_set_title_align(Rid bar, RHAlign align);
void Rheader_bar_set_title_notch(Rid bar, int notch);
R_TRUE: the title sits in a dark tab hanging from the top edge of the bar (slanted sides, round bottom corners). XML: TitleStyle="Notch".
void Rheader_bar_set_background(Rid bar, int enabled);
R_FALSE removes the background of the bar: for a header that floats above the content (in an Overlay) or sits inside a glass panel.
Rid Rdock_area_create(void);
void Rdock_area_add_panel(Rid area, Rid panel, const char* title, RDockSide side, Rid relative, float size);
Adds a panel. The dock area takes ownership of the widget.
void Rdock_area_move_panel(Rid area, Rid panel, RDockSide side, Rid relative, float size);
Moves a panel of the area somewhere else in it.
void Rdock_area_set_panel_icon(Rid area, Rid panel, Rid texture, float u0, float v0, float u1, float v1, int tint);
Icon drawn before the title of the tab of a panel (and on the chip while it is dragged).
void Rdock_area_set_panel_closable(Rid area, Rid panel, int closable);
R_FALSE removes the close button of the tab of a panel. Panels can be closed by default.
void Rdock_area_hide_panel(Rid area, Rid panel);
Takes a panel out of the arrangement without deleting it (a window of an application closed from its menu). Its tab disappears and its neighbours take its place; the area remembers where it was.
void Rdock_area_open_panel(Rid area, Rid panel);
Puts a hidden panel back where it was, and brings its tab to the front (also for a panel that is not hidden).
int Rdock_area_is_panel_open(Rid area, Rid panel);
void Rdock_area_set_close_hides(Rid area, int hides);
R_TRUE: the close button of a tab hides its panel (Rdock_area_hide_panel) instead of deleting it. XML: CloseHides="true". The close callback is asked first either way.
int Rdock_area_is_panel_shown(Rid area, Rid panel);
void Rdock_area_set_movable(Rid area, int movable);
R_FALSE stops the user from moving the panels (the borders can still be dragged).
const char* Rdock_area_save_layout(Rid area);
Describes how the panels are arranged, as a short text to keep in a settings file. Panels are named by their widget name (Rwidget_set_name): unnamed panels are not part of the description.
int Rdock_area_load_layout(Rid area, const char* layout);
Arranges the panels as a saved description says. Panels of the area that the description does not name keep a place; names it has that match no panel are ignored.
typedef int (*RDockCloseCallback)(Rid area, Rid panel, void* user_data);
Called when the user closes a panel, before it is deleted. Return R_FALSE to keep the panel.
void Rdock_area_set_close_callback(Rid area, RDockCloseCallback callback, void* user_data);
void Rdock_area_set_tearable(Rid area, int tearable);
Tearing: a tab dragged out of the area takes its panel to a window of its own (a floating area of the same family), and a tab dragged from such a window over the area docks it back where it is dropped. A double click on the tab of a floating window, or closing that window, puts its panels back where they were. Dragging the only tab of a floating window moves the window. R_TRUE by default; XML: Tearable="false". The functions of this area that take a panel also work on its panels that are in floating windows.
int Rdock_area_is_tearable(Rid area);
Rid Rdock_area_float_panel(Rid area, Rid panel, int x, int y);
Takes a panel to a window of its own, its top left corner at (x, y) on the screen. Returns the window.
void Rdock_area_dock_panel(Rid area, Rid panel);
A floating panel goes back where it was in the area.
Rid Rdock_area_get_panel_window(Rid area, Rid panel);
The window a floating panel is in, R_INVALID_ID when it is docked in the area.
typedef void (*RDockChangedCallback)(Rid area, void* user_data);
Called after the user moved, resized, showed or closed a panel.
void Rdock_area_set_changed_callback(Rid area, RDockChangedCallback callback, void* user_data);
Rid Risland_create(void);
void Risland_set_expanded(Rid island, int expanded);
Unfolds or folds the island. The changed callback is not called.
int Risland_is_expanded(Rid island);
void Risland_expand_for(Rid island, double seconds);
Unfolds the island, and folds it back by itself after a while: to tell something to the user. It stays open while the pointer is on it.
void Risland_set_expand_on_hover(Rid island, int enabled);
R_TRUE (default): the island unfolds under the pointer and folds back when it leaves.
void Risland_set_expand_on_click(Rid island, int enabled);
R_TRUE (default): a click on the island unfolds or folds it.
void Risland_set_attached(Rid island, int attached);
R_TRUE gives the island square upper corners: a notch that hangs from the edge it touches, instead of a capsule that floats under it.
typedef void (*RIslandChangedCallback)(Rid island, int expanded, void* user_data);
Called when the user unfolds or folds the island. The action of the widget (OnChanged) fires too.
void Risland_set_changed_callback(Rid island, RIslandChangedCallback callback, void* user_data);
void Rwindow_set_island(Rid window, Rid widget);
Shows a widget (usually an island) floating at the top of a window, in the middle, above its content. The window takes ownership; the previous one is deleted. R_INVALID_ID removes it. The padding of its slot (Rslot_set_padding) is its distance from the top edge.
The widgets of creative tools.
R_WIDGET_COLOR_PICKER chooses a color R_WIDGET_TIMELINE tracks of clips and keys along a time ruler (a sequencer) R_WIDGET_NODE_GRAPH nodes linked by wires R_WIDGET_BLOCK_EDITOR blocks that snap into each other (Scratch)
Each of them holds a small model (a color; tracks, clips and keys; nodes, pins and links) that the application fills and reads through the functions below, or writes in XML. The things inside a timeline or a graph are named by integers that are only meaningful for that widget, 0 meaning "none"; they are never reused while the widget lives.
A square of saturation and value, a strip of hues, a strip of opacity over a checkerboard, the color before and the color now side by side, its hexadecimal code, its numbers (red green blue, or hue saturation value), and a row of swatches. Everything is linked: dragging in the square moves the numbers, typing a code moves the square.
<ColorPicker Name="tint" Color="#3B82F6" Alpha="true" OnChanged="tint.changed"/>
With Popup="true" the widget is a swatch the size of a button, which opens the picker in a popup when clicked.
Rid Rcolor_picker_create(void);
void Rcolor_picker_set_color(Rid picker, float r, float g, float b, float a);
Sets the color (0..1 each). The callback is not called.
void Rcolor_picker_get_color(Rid picker, float* r, float* g, float* b, float* a);
void Rcolor_picker_set_hsv(Rid picker, float hue, float saturation, float value);
The same color as hue (0..360), saturation and value (0..1). The picker remembers the hue of a gray and the saturation of black, which red, green and blue cannot tell.
void Rcolor_picker_get_hsv(Rid picker, float* hue, float* saturation, float* value);
int Rcolor_picker_set_hex(Rid picker, const char* text);
Sets the color from text: "#RGB", "#RRGGBB", "#RRGGBBAA" (the '#' may be left out) or one of the color names of the XML attributes. A code without opacity leaves the opacity as it is.
const char* Rcolor_picker_get_hex(Rid picker);
void Rcolor_picker_set_alpha_enabled(Rid picker, int enabled);
R_TRUE (default) shows the opacity strip and the fourth number. R_FALSE: colors are opaque.
void Rcolor_picker_set_previous_color(Rid picker, float r, float g, float b, float a);
The color shown next to the current one, to compare with what was there before: clicking it comes back to it. Rcolor_picker_set_color does not change it; a popup picker takes it when it opens.
void Rcolor_picker_add_swatch(Rid picker, float r, float g, float b, float a);
Adds a color to the row of swatches: one click takes it.
void Rcolor_picker_clear_swatches(Rid picker);
int Rcolor_picker_get_swatch_count(Rid picker);
void Rcolor_picker_set_popup(Rid picker, int popup);
R_TRUE turns the widget into a swatch that opens the picker in a popup.
void Rcolor_picker_set_compact(Rid picker, int compact);
R_TRUE hides the code and the numbers: only the square, the strips and the swatches.
typedef void (*RColorChangedCallback)(Rid picker, float r, float g, float b, float a, void* user_data);
Called each time the user changes the color: while dragging, and when a code or a number is entered. The action of the widget (OnChanged in XML) fires too.
void Rcolor_picker_set_changed_callback(Rid picker, RColorChangedCallback callback, void* user_data);
void Rcolor_rgb_to_hsv(float r, float g, float b, float* hue, float* saturation, float* value);
Red, green, blue (0..1) to hue (0..360), saturation, value (0..1).
void Rcolor_hsv_to_rgb(float hue, float saturation, float value, float* r, float* g, float* b);
A sequencer: a ruler of time at the top, a playhead, and tracks one under the other. A track holds clips (something that lasts: a start and a length) and keys (a moment). The user scrubs the playhead on the ruler, moves clips along their track or to another one, stretches them by their ends, moves keys, selects by clicking or with a rectangle, zooms with Ctrl + wheel, pans with the wheel, the middle button or the scrollbars. Moves snap to the frames, to the playhead, to the markers and to the ends of the other clips.
<Timeline Name="sequence" Duration="12" FrameRate="24">
<Track Name="Camera" Color="#0A84FF">
<Clip Start="0" Length="3.5" Label="Wide shot"/>
<Clip Start="4" Length="2" Label="Close up" Color="#FF9F0A"/>
</Track>
<Track Name="Opacity">
<Key Time="1"/> <Key Time="2.5"/>
</Track>
<Marker Time="6" Label="Drop"/>
</Timeline>
Times are in seconds. Tracks and items (clips, keys, markers) are named by the integers the add functions return.
typedef enum RTimelineItem
What an item of a timeline is.
R_TIMELINE_NONE | |
R_TIMELINE_CLIP | |
R_TIMELINE_KEY | |
R_TIMELINE_MARKER |
Rid Rtimeline_create(void);
void Rtimeline_set_duration(Rid timeline, double seconds);
Length of the sequence. The view and the playhead stay within 0 .. duration.
double Rtimeline_get_duration(Rid timeline);
void Rtimeline_set_time(Rid timeline, double seconds);
Moves the playhead. The time callback is not called.
double Rtimeline_get_time(Rid timeline);
void Rtimeline_set_frame_rate(Rid timeline, double frames_per_second);
Frames per second. With a frame rate the ruler counts in frames ("2:12" is second 2, frame 12) and everything snaps to frames; 0 (default) counts in seconds and snaps to the marks of the ruler.
double Rtimeline_get_frame_rate(Rid timeline);
void Rtimeline_set_snapping(Rid timeline, int enabled);
R_FALSE lets items be placed anywhere (holding Alt while dragging does it for one move).
void Rtimeline_set_view(Rid timeline, double start, double end);
The part of the sequence that is shown. Zooming is showing less.
void Rtimeline_get_view(Rid timeline, double* start, double* end);
void Rtimeline_set_playing(Rid timeline, int playing);
Makes the playhead run by itself, at the speed of the clock, calling the time callback at each frame; at the end it stops, or starts again with Rtimeline_set_loop.
int Rtimeline_is_playing(Rid timeline);
void Rtimeline_set_loop(Rid timeline, int loop);
int Rtimeline_add_track(Rid timeline, const char* name);
void Rtimeline_remove_track(Rid timeline, int track);
Removes a track and everything on it.
int Rtimeline_get_track_count(Rid timeline);
int Rtimeline_get_track(Rid timeline, int index);
void Rtimeline_set_track_name(Rid timeline, int track, const char* name);
const char* Rtimeline_get_track_name(Rid timeline, int track);
void Rtimeline_set_track_color(Rid timeline, int track, float r, float g, float b);
Color of the clips and keys of the track that have none of their own.
void Rtimeline_set_track_height(Rid timeline, int track, float height);
Height of the track in logical units; 0 = the default.
void Rtimeline_set_track_locked(Rid timeline, int track, int locked);
A locked track shows its items but does not let the user change them.
void Rtimeline_set_track_muted(Rid timeline, int track, int muted);
A muted track is drawn dimmed; what muting means is up to the application.
int Rtimeline_is_track_muted(Rid timeline, int track);
int Rtimeline_add_clip(Rid timeline, int track, double start, double length, const char* label);
int Rtimeline_add_key(Rid timeline, int track, double time);
int Rtimeline_add_marker(Rid timeline, double time, const char* label);
A named moment of the whole sequence, shown on the ruler and across the tracks.
void Rtimeline_remove_item(Rid timeline, int item);
void Rtimeline_clear(Rid timeline);
Removes every track, clip, key and marker.
RTimelineItem Rtimeline_get_item_type(Rid timeline, int item);
int Rtimeline_get_item_track(Rid timeline, int item);
double Rtimeline_get_item_start(Rid timeline, int item);
double Rtimeline_get_item_length(Rid timeline, int item);
void Rtimeline_set_item(Rid timeline, int item, int track, double start, double length);
Moves an item: to another track (0 = keep), another start, another length (clips; negative = keep).
void Rtimeline_set_item_label(Rid timeline, int item, const char* label);
const char* Rtimeline_get_item_label(Rid timeline, int item);
void Rtimeline_set_item_color(Rid timeline, int item, float r, float g, float b);
int Rtimeline_get_item_count(Rid timeline);
int Rtimeline_get_item(Rid timeline, int index);
void Rtimeline_select(Rid timeline, int item, int add);
Selects an item, alone or (add) with the ones already selected.
void Rtimeline_clear_selection(Rid timeline);
int Rtimeline_is_selected(Rid timeline, int item);
int Rtimeline_get_selection_count(Rid timeline);
int Rtimeline_get_selected(Rid timeline, int index);
typedef void (*RTimelineTimeCallback)(Rid timeline, double seconds, void* user_data);
The playhead moved: scrubbed by the user, or running by itself.
void Rtimeline_set_time_callback(Rid timeline, RTimelineTimeCallback callback, void* user_data);
typedef void (*RTimelineItemCallback)(Rid timeline, int item, void* user_data);
Something happened to an item; which thing depends on the function the callback was given to.
void Rtimeline_set_changed_callback(Rid timeline, RTimelineItemCallback callback, void* user_data);
Called for each item the user moved, stretched or retimed, as it happens. The action of the widget (OnChanged in XML) fires once per gesture, when the button is released.
void Rtimeline_set_selection_callback(Rid timeline, RTimelineItemCallback callback, void* user_data);
Called when the selection changed; item is the item just clicked, or 0.
void Rtimeline_set_activated_callback(Rid timeline, RTimelineItemCallback callback, void* user_data);
Called when an item is double-clicked.
void Rtimeline_set_removed_callback(Rid timeline, RTimelineItemCallback callback, void* user_data);
Called when the user deletes an item (the Delete key), before it is removed: its values can still be read. Without this callback the Delete key does nothing: the application decides what can be deleted.
Nodes on a canvas that pans (drag the background, or the middle button) and zooms (the wheel). A node has a title, input pins on its left, output pins on its right, and may hold any widget (a slider, a color picker, a preview). The user links an output to an input by dragging from one pin to the other; dragging a link away from its input removes it. Links are wires: they hang between their pins, swing when a node is moved and settle, and carry a slow flow from their output to their input.
<NodeGraph Name="graph">
<Node Name="noise" Title="Noise" X="40" Y="60" Color="#FF9F0A">
<Input Name="scale" Label="Scale" Type="number"/>
<Output Name="value" Label="Value" Type="number"/>
<Slider Value="0.4"/>
</Node>
<Node Name="blend" Title="Blend" X="320" Y="90">
<Input Name="a" Label="A" Type="number"/>
<Output Name="out" Label="Result" Type="number"/>
</Node>
<Link From="noise.value" To="blend.a"/>
</NodeGraph>
Pins have a type, a free text ("number", "color", "mesh"...): an output only links to an input of the same type, or to a pin without a type. Each type has a color (Rnode_graph_set_type_color, or one Raven picks from its name); a link shades from the color of one pin to the color of the other. An input takes one link (a new one replaces it); an output feeds as many as wanted.
Nodes, pins and links are named by the integers the functions return, all different within one graph.
Rid Rnode_graph_create(void);
int Rnode_graph_add_node(Rid graph, const char* title, float x, float y);
void Rnode_graph_remove_node(Rid graph, int node);
Removes a node, its pins, their links, and the widget it holds.
void Rnode_graph_clear(Rid graph);
int Rnode_graph_get_node_count(Rid graph);
int Rnode_graph_get_node(Rid graph, int index);
void Rnode_graph_set_node_title(Rid graph, int node, const char* title);
const char* Rnode_graph_get_node_title(Rid graph, int node);
void Rnode_graph_set_node_position(Rid graph, int node, float x, float y);
void Rnode_graph_get_node_position(Rid graph, int node, float* x, float* y);
void Rnode_graph_get_node_size(Rid graph, int node, float* width, float* height);
Size of a node on the canvas: Raven works it out from its title, its pins and its content.
void Rnode_graph_set_node_color(Rid graph, int node, float r, float g, float b);
Color of the header of the node; without one it takes the accent color of the theme.
void Rnode_graph_set_node_content(Rid graph, int node, Rid widget);
Puts a widget inside the node, under its pins: the graph owns it from now on. R_INVALID_ID removes (and deletes) the one it had.
void Rnode_graph_set_node_name(Rid graph, int node, const char* name);
Name of the node, the Name of its XML element: what <Link From="name.pin"> and Rnode_graph_find_node look for. Not shown.
const char* Rnode_graph_get_node_name(Rid graph, int node);
int Rnode_graph_find_node(Rid graph, const char* name);
void Rnode_graph_set_node_user_data(Rid graph, int node, void* user_data);
Value the application attaches to a node.
void* Rnode_graph_get_node_user_data(Rid graph, int node);
int Rnode_graph_add_input(Rid graph, int node, const char* label, const char* type);
int Rnode_graph_add_output(Rid graph, int node, const char* label, const char* type);
void Rnode_graph_remove_pin(Rid graph, int pin);
int Rnode_graph_get_pin_node(Rid graph, int pin);
int Rnode_graph_is_pin_output(Rid graph, int pin);
const char* Rnode_graph_get_pin_label(Rid graph, int pin);
const char* Rnode_graph_get_pin_type(Rid graph, int pin);
void Rnode_graph_set_pin_name(Rid graph, int pin, const char* name);
Name of the pin for Rnode_graph_find_pin and for the links of XML; a pin without one answers to its label.
int Rnode_graph_find_pin(Rid graph, int node, const char* name);
void Rnode_graph_get_pin_position(Rid graph, int pin, float* x, float* y);
Where a pin is on the canvas (the middle of its dot).
int Rnode_graph_get_input(Rid graph, int node, int index);
int Rnode_graph_get_output(Rid graph, int node, int index);
void Rnode_graph_set_type_color(Rid graph, const char* type, float r, float g, float b);
Color of the pins of a type and of the links between them.
int Rnode_graph_connect(Rid graph, int output_pin, int input_pin);
Links an output to an input, as the user does by dragging. The connect callback is not asked.
void Rnode_graph_disconnect(Rid graph, int link);
int Rnode_graph_get_link_count(Rid graph);
int Rnode_graph_get_link(Rid graph, int index);
int Rnode_graph_get_link_output(Rid graph, int link);
int Rnode_graph_get_link_input(Rid graph, int link);
int Rnode_graph_get_input_link(Rid graph, int input_pin);
void Rnode_graph_set_view(Rid graph, float center_x, float center_y, float zoom);
What the middle of the widget shows: a point of the canvas, and how large (1 = one unit per logical unit).
void Rnode_graph_get_view(Rid graph, float* center_x, float* center_y, float* zoom);
void Rnode_graph_to_canvas(Rid graph, float x, float y, float* canvas_x, float* canvas_y);
Converts a point of the widget (from its corner, as in the events) to the canvas, and back, with the view as it is shown now.
void Rnode_graph_from_canvas(Rid graph, float canvas_x, float canvas_y, float* x, float* y);
void Rnode_graph_frame_all(Rid graph);
Moves and zooms so that every node shows.
void Rnode_graph_set_grid_visible(Rid graph, int visible);
R_FALSE hides the grid of dots (shown by default).
void Rnode_graph_set_flow_visible(Rid graph, int visible);
The pulses of light that run along the links, from output to input. By default they run while the pointer is over the graph, and the window rests the rest of the time. R_TRUE makes them run all the time (the window then draws without pause); R_FALSE stops them.
void Rnode_graph_set_read_only(Rid graph, int read_only);
R_TRUE: the user can look but not move, link or delete.
void Rnode_graph_select_node(Rid graph, int node, int add);
void Rnode_graph_clear_selection(Rid graph);
int Rnode_graph_is_node_selected(Rid graph, int node);
int Rnode_graph_get_selection_count(Rid graph);
int Rnode_graph_get_selected_node(Rid graph, int index);
typedef int (*RNodeGraphConnectCallback)(Rid graph, int output_pin, int input_pin, void* user_data);
Asked when the user is about to link two pins that may be linked: return R_FALSE to refuse (a loop, a rule of the application).
void Rnode_graph_set_connect_callback(Rid graph, RNodeGraphConnectCallback callback, void* user_data);
typedef void (*RNodeGraphItemCallback)(Rid graph, int item, void* user_data);
Something happened to a link or to a node; which thing depends on the function the callback was given to.
void Rnode_graph_set_linked_callback(Rid graph, RNodeGraphItemCallback callback, void* user_data);
Called after the user made a link, and before a link the user removed goes (its pins can still be read).
void Rnode_graph_set_unlinked_callback(Rid graph, RNodeGraphItemCallback callback, void* user_data);
void Rnode_graph_set_moved_callback(Rid graph, RNodeGraphItemCallback callback, void* user_data);
Called for each node the user moved, when the button is released.
void Rnode_graph_set_selection_callback(Rid graph, RNodeGraphItemCallback callback, void* user_data);
Called when the selection changed; item is the node just clicked, or 0.
void Rnode_graph_set_removed_callback(Rid graph, RNodeGraphItemCallback callback, void* user_data);
Called when the user deletes a node (the Delete key), before it is removed. Without this callback the Delete key only removes links: the application decides whether nodes can be deleted.
void Rnode_graph_set_activated_callback(Rid graph, RNodeGraphItemCallback callback, void* user_data);
Called when the user double-clicks a node (to open what it stands for).
typedef void (*RNodeGraphContextCallback)(Rid graph, int node, float x, float y, void* user_data);
Right click: node is the node under the pointer (selected first), or 0 on the empty canvas; x, y are in the widget (Rnode_graph_to_canvas). Without this callback the right button does nothing.
void Rnode_graph_set_context_callback(Rid graph, RNodeGraphContextCallback callback, void* user_data);
void Rnode_graph_set_pin_multiple(Rid graph, int pin, int multiple);
R_TRUE: this input keeps every link made to it (a state that several transitions enter) instead of one. Pulling a wire from it starts a new one.
void Rnode_graph_set_node_active(Rid graph, int node, int active);
R_TRUE: the node is running (live debug) : a soft ring breathes around it.
void Rnode_graph_set_node_active_color(Rid graph, int node, float r, float g, float b);
Color of that ring (the success color of the theme by default).
void Rnode_graph_set_node_deletable(Rid graph, int node, int deletable);
R_FALSE: the Delete key does not remove this node (the root of a tree, the output of a graph).
void Rnode_graph_set_node_badge(Rid graph, int node, const char* text);
A short text in a pill on the top right corner of the node ("1", "!"...); NULL or "" removes it.
Programs made of blocks that snap into each other, in the style of Scratch: a palette on the left (one block of each kind, by category), the scripts on a canvas that pans (drag the background, middle button) and zooms (Ctrl + wheel).
A kind has a label: words and slots. %n a number, %s a text, %b a condition, %r any value, %m a choice in a menu (its choices : Rblock_editor_set_slot_options); {text} right after a slot is its default; | separates the sections of a C block (each one is followed by a mouth): "repeat %n{10}", "if %b then|else", "%n + %n".
Blocks are named by integers (> 0). A block hangs under another one (R_BLOCK_NEXT), in a mouth of a C block (R_BLOCK_BODY, index = the mouth) or in a value slot (R_BLOCK_INPUT, index = the slot), or is the top of a script of its own.
The user drags a block with what is under it; the place it would go opens and shows its shadow; dropped on the palette, it is deleted. A left click selects a block (Ctrl / Shift : adds it), a left drag on the canvas draws a selection rectangle, and dragging a block of the selection moves the whole selection; Delete removes it. A right drag (or middle, or Alt + left) pans, a right click opens the context menu. A click on a script fires the clicked callback (to run it); the application makes the running blocks glow.
typedef enum RBlockShape
R_BLOCK_STATEMENT | A step: snaps under another one, others snap under it. |
R_BLOCK_HAT | Starts a script ("when the game starts"): nothing goes above it. |
R_BLOCK_CAP | Ends a script ("stop"): nothing goes under it. |
R_BLOCK_C | Wraps stacks in its mouths ("repeat", "if ... else"). |
R_BLOCK_REPORTER | A rounded value that goes into a slot. |
R_BLOCK_BOOLEAN | A hexagonal condition that goes into a %b slot (or a %r one). |
typedef enum RBlockPlace
R_BLOCK_NEXT | |
R_BLOCK_BODY | |
R_BLOCK_INPUT |
typedef void (*RBlockEditorCallback)(Rid editor, int block, void* user_data);
A block changed (0: several, or one was deleted), or a script was clicked (its top block).
typedef void (*RBlockEditorContextCallback)(Rid editor, int block, float x, float y, void* user_data);
Right click: on a block (0 on the canvas), at x, y in the widget.
Rid Rblock_editor_create(void);
int Rblock_editor_add_kind(Rid editor, const char* name, const char* label, RBlockShape shape, const char* category);
A kind of block, and its block in the palette. Returns its index, -1 on an error.
void Rblock_editor_set_category_color(Rid editor, const char* category, float r, float g, float b);
Color of the blocks of a category (Raven picks one from its name otherwise).
void Rblock_editor_set_palette_visible(Rid editor, int visible);
int Rblock_editor_add_block(Rid editor, const char* kind, float x, float y);
A new block, the top of a script of its own at x, y (canvas units). Returns it, 0 on an error.
void Rblock_editor_remove_block(Rid editor, int block);
Removes a block and everything that hangs under it.
void Rblock_editor_clear(Rid editor);
int Rblock_editor_attach(Rid editor, int block, int target, RBlockPlace place, int index);
Puts a block (with what is under it) at a place of another one. R_FALSE when it does not fit there.
void Rblock_editor_detach(Rid editor, int block, float x, float y);
Takes a block (with what is under it) out: a script of its own at x, y.
int Rblock_editor_get_script_count(Rid editor);
int Rblock_editor_get_script(Rid editor, int index);
The top block of a script.
const char* Rblock_editor_get_kind(Rid editor, int block);
int Rblock_editor_get_next(Rid editor, int block);
The block under it, 0 if none.
int Rblock_editor_get_mouth_count(Rid editor, int block);
int Rblock_editor_get_body(Rid editor, int block, int mouth);
The first block in a mouth of a C block, 0 if empty.
int Rblock_editor_get_slot_count(Rid editor, int block);
int Rblock_editor_get_input(Rid editor, int block, int slot);
The value block in a slot, 0 if the slot holds a typed value.
const char* Rblock_editor_get_value(Rid editor, int block, int slot);
The typed value of a slot.
void Rblock_editor_set_value(Rid editor, int block, int slot, const char* value);
int Rblock_editor_get_parent(Rid editor, int block, RBlockPlace* place, int* index);
Where a block hangs: the block it hangs from (0: the top of a script).
void Rblock_editor_get_position(Rid editor, int block, float* x, float* y);
void Rblock_editor_set_block_glow(Rid editor, int block, int glow);
R_TRUE: the block is running: a halo breathes around it.
const char* Rblock_editor_save(Rid editor);
Every script as text (valid until the next call).
int Rblock_editor_load(Rid editor, const char* text);
Replaces the scripts with those of a text from Rblock_editor_save.
void Rblock_editor_set_changed_callback(Rid editor, RBlockEditorCallback callback, void* user_data);
void Rblock_editor_set_clicked_callback(Rid editor, RBlockEditorCallback callback, void* user_data);
void Rblock_editor_set_context_callback(Rid editor, RBlockEditorContextCallback callback, void* user_data);
void Rblock_editor_set_slot_options(Rid editor, const char* kind, int slot, const char* options);
The choices of a %m slot of a kind, separated by '\n' ("" : the slot is typed in).
void Rblock_editor_set_kind_visible(Rid editor, const char* kind, int visible);
R_FALSE: the kind is not in the palette (its blocks stay where they are).
int Rblock_editor_set_kind_label(Rid editor, const char* kind, const char* label);
A new label for a kind (a function that takes one more input...). The blocks of that kind keep the values of the slots that are still there.
void Rblock_editor_set_block_deletable(Rid editor, int block, int deletable);
R_FALSE: the user cannot delete the block (the entry of a function). Not saved.
int Rblock_editor_get_selection_count(Rid editor);
int Rblock_editor_get_selected(Rid editor, int index);
void Rblock_editor_select(Rid editor, int block, int add);
Selects a block (add: R_FALSE clears the selection first ; block 0 : only clears).
void Rblock_editor_get_view(Rid editor, float* x, float* y, float* zoom);
Pan (canvas units at the top left) and zoom.
void Rblock_editor_set_view(Rid editor, float x, float y, float zoom);
Dialogs, message boxes, file dialogs and the file browser.
DIALOGS
A dialog is any widget shown as a sheet over the content of a window: a veil falls on the window, the sheet rises in the middle, and the window only listens to the sheet until it is closed. Rdialog_open returns at once; Rdialog_run waits for the dialog to close and returns its result.
FILE DIALOGS
Rfile_dialog_open / _save / _select_folder ask the user for a path and return when it is chosen. They show the dialog of the operating system (Windows: the Explorer dialog; Linux: the one of the desktop, through zenity or kdialog) and, where there is none, the file browser of Raven in a dialog. R_FILE_DIALOG_RAVEN always uses the latter.
The file browser is also a widget, R_WIDGET_FILE_BROWSER, to put in any layout: a side panel showing a project folder, a custom "open" page...
<FileBrowser Name="files" Directory="~/Projects" Filter="*.xml;*.c" Controls="false"/>
The functions that wait (Rdialog_run, Rmessage_box, Rfile_dialog_...) run the frames of the application themselves while they wait: timers, tasks and the frame callback keep running, the windows keep being drawn.
typedef struct RFileFilter
A kind of file in a file dialog.
const char* name | Shown to the user: "Images". |
const char* patterns | Patterns separated by ';': "*.png;*.jpg". "*" matches everything. |
typedef enum RFileDialogFlags
R_FILE_DIALOG_MULTIPLE | Several files can be chosen (Rfile_dialog_open): see Rfile_dialog_get_result. |
R_FILE_DIALOG_RAVEN | Never the dialog of the OS: the file browser of Raven, in a dialog of the parent window. |
R_FILE_DIALOG_SHOW_HIDDEN |
typedef struct RFileDialogDesc
Every field may be left to zero.
Rid parent | Window the dialog belongs to. R_INVALID_ID: none (a window is opened when Raven needs one). |
const char* title | NULL: "Open", "Save as"... |
const char* directory | Folder shown first. NULL: the one of the previous dialog, else the home of the user. |
const char* file_name | Name proposed to the user (save dialogs). |
const RFileFilter* filters | |
int filter_count | |
const char* default_extension | Save dialogs: added to a name typed without extension ("xml"). |
Ruint flags | Bitmask of RFileDialogFlags. |
typedef enum RFileBrowserMode
R_FILE_BROWSER_OPEN | Choose an existing file. |
R_FILE_BROWSER_SAVE | Choose where to save: a name is typed; an existing file must be confirmed. |
R_FILE_BROWSER_FOLDER | Choose a folder. |
typedef enum RMessageButtons
R_MESSAGE_OK | |
R_MESSAGE_OK_CANCEL | |
R_MESSAGE_YES_NO | |
R_MESSAGE_YES_NO_CANCEL |
typedef enum RMessageResult
R_MESSAGE_RESULT_CANCEL | Dismissed (Escape), or the Cancel button. |
R_MESSAGE_RESULT_OK | |
R_MESSAGE_RESULT_YES | |
R_MESSAGE_RESULT_NO |
typedef void (*RDialogClosedCallback)(Rid content, int result, void* user_data);
Called when a dialog closes. result is the value given to Rdialog_close, 0 when dismissed.
void Rdialog_open(Rid window, Rid content, RDialogClosedCallback closed, void* user_data);
Shows a widget as a dialog of a window. The window takes ownership of content: it is deleted when the dialog closes, so read what you need from it before, or in closed. The Escape key dismisses the dialog (result 0).
void Rdialog_close(Rid widget, int result);
Closes the dialog that contains a widget (the content itself or anything inside it: the button that was clicked).
int Rdialog_run(Rid window, Rid content);
Shows a dialog and waits until it closes. Returns its result.
RMessageResult Rmessage_box(Rid window, const char* title, const char* text, RMessageButtons buttons);
Shows a message with buttons and waits for the answer.
const char* Rfile_dialog_open(const RFileDialogDesc* desc);
Asks for a file to open.
const char* Rfile_dialog_save(const RFileDialogDesc* desc);
Asks where to save a file. An existing file was confirmed by the user.
const char* Rfile_dialog_select_folder(const RFileDialogDesc* desc);
Asks for a folder.
int Rfile_dialog_get_result_count(void);
What the last file dialog returned: several paths with R_FILE_DIALOG_MULTIPLE.
const char* Rfile_dialog_get_result(int index);
int Rfile_register_memory(const char* path, const void* data, size_t size, int copy);
Registers a file held in memory under a path: every file Raven reads (XML documents and their Include, Source and Font attributes, themes, textures, fonts, Rfile_read) is looked up here first, so that resources embedded in the executable need no file beside it. A relative path names the file as it is written in the XML once joined to the folder of the document that names it (Rxml_set_base_path for a document given as text), e.g. "ui/editor.xml". Paths compare with '/' and '\\' alike. Memory files are not watched for live reload. Call it after Rinit; Rshutdown forgets every file.
void Rfile_unregister_memory(const char* path);
int Rfile_is_memory(const char* path);
R_TRUE when path is a file registered with Rfile_register_memory.
char* Rfile_read(const char* path, size_t* size);
Whole files, with UTF-8 paths on every platform.
size may be NULL.int Rfile_write(const char* path, const void* data, size_t size);
Rid Rfile_browser_create(void);
void Rfile_browser_set_mode(Rid browser, RFileBrowserMode mode);
int Rfile_browser_set_directory(Rid browser, const char* path);
Shows a folder. "~" is the home of the user. Returns R_FALSE when it cannot be read.
const char* Rfile_browser_get_directory(Rid browser);
void Rfile_browser_refresh(Rid browser);
Reads the folder again.
void Rfile_browser_set_filters(Rid browser, const RFileFilter* filters, int count);
Kinds of files the user chooses from; the first one is active. The strings are copied.
void Rfile_browser_set_multiple(Rid browser, int multiple);
R_TRUE lets several files be selected (Ctrl and Shift with a click).
void Rfile_browser_set_controls_visible(Rid browser, int visible);
R_FALSE hides the name field, the filter list and the buttons: what remains is an explorer to put in a side panel. Shown by default.
void Rfile_browser_set_places_visible(Rid browser, int visible);
R_FALSE hides the list of places on the left.
void Rfile_browser_set_file_name(Rid browser, const char* name);
Name typed in the name field (save mode).
void Rfile_browser_set_default_extension(Rid browser, const char* extension);
Added to a name typed without extension, in save mode.
int Rfile_browser_get_selection_count(Rid browser);
Paths of the selected entries. The strings are valid until the selection or the folder changes.
const char* Rfile_browser_get_selection(Rid browser, int index);
void Rfile_browser_select(Rid browser, const char* name);
Selects an entry of the folder by its name.
typedef void (*RFileBrowserCallback)(Rid browser, const char* path, void* user_data);
Called when the user chooses: a double click or Enter on a file, the Open / Save button. path is the first chosen path; with several files, read them with Rfile_browser_get_selection. The action of the widget (OnActivated in XML) fires at the same time.
void Rfile_browser_set_accepted_callback(Rid browser, RFileBrowserCallback callback, void* user_data);
void Rfile_browser_set_cancelled_callback(Rid browser, RFileBrowserCallback callback, void* user_data);
Called by the Cancel button.
void Rfile_browser_set_selection_changed_callback(Rid browser, RFileBrowserCallback callback, void* user_data);
Called when the selection changes; path is the entry under the cursor, or NULL.
Embedding content rendered by the application.
A VIEWPORT widget reserves an area of the layout and shows external content in it. Three modes cover every graphics API:
1. Texture (Rviewport_set_texture)
The application renders to an image and Raven draws it like any widget:
it is clipped, can have UI on top, and follows the layout exactly.
- Vulkan : wrap your VkImageView with
Rvulkan_texture_create_from_image_view (raven_vulkan.h), zero copy.
- OpenGL : share memory with Rvulkan_texture_create_shared and
GL_EXT_memory_object (zero copy), or read pixels back and
call Rtexture_update.
- Any : Rtexture_update with CPU pixels.
2. Draw callback (Rviewport_set_draw_callback)
Raven calls the application while it records its own frame, with the
viewport and scissor set to the widget. The application draws straight
into the window: no intermediate image, UI can still be drawn on top.
With the Vulkan backend the callback receives the VkCommandBuffer.
The callback runs on the render thread.
3. Native child window (Rviewport_set_native)
Raven creates a child OS window (HWND / X11 Window) kept on the widget.
The application attaches its own swapchain or context to it: OpenGL,
Vulkan, Direct3D, anything. Raven cannot draw over or clip that area.
Input: a viewport is focusable and forwards its mouse and keyboard events through Rwidget_set_event_callback.
typedef struct RViewportDrawInfo
Passed to the draw callback of a viewport. Sizes are in pixels.
RBackend backend | |
Rid viewport | |
Rid window | |
int x | Area of the viewport in the window framebuffer. |
int y | Area of the viewport in the window framebuffer. |
int width | Area of the viewport in the window framebuffer. |
int height | Area of the viewport in the window framebuffer. |
int clip_x | Visible part of that area. Already set as the scissor rectangle. |
int clip_y | Visible part of that area. Already set as the scissor rectangle. |
int clip_width | Visible part of that area. Already set as the scissor rectangle. |
int clip_height | Visible part of that area. Already set as the scissor rectangle. |
int framebuffer_width | |
int framebuffer_height | |
uint64_t frame_index | |
void* command_buffer | Vulkan: VkCommandBuffer being recorded, inside the render pass. |
void* render_pass | Vulkan: VkRenderPass in use (one color attachment, no depth). |
Ruint color_format | Vulkan: VkFormat of the color attachment. |
void Rviewport_set_texture(Rid viewport, Rid texture);
Shows a texture. R_INVALID_ID shows nothing.
void Rviewport_set_stretch(Rid viewport, RStretch stretch);
How the texture is fitted in the widget. Default: R_STRETCH_FILL.
void Rviewport_set_flip_y(Rid viewport, int flip);
R_TRUE flips the texture vertically (OpenGL framebuffers are bottom-up).
typedef void (*RViewportDrawCallback)(const RViewportDrawInfo* info, void* user_data);
Called on the render thread each time the window is rendered. State you bind (pipeline, descriptor sets, viewport, scissor) does not need to be restored. NULL removes the callback.
void Rviewport_set_draw_callback(Rid viewport, RViewportDrawCallback callback, void* user_data);
int Rviewport_set_native(Rid viewport, int enabled);
Creates (or destroys) the native child window of the viewport. The viewport must already be in a window.
int Rviewport_get_native_handle(Rid viewport, RNativeWindow* native);
Fills native with the handles of the child window.
void Rviewport_get_pixel_size(Rid viewport, int* width, int* height);
Size of the viewport in pixels after the last layout.
typedef void (*RViewportResizeCallback)(Rid viewport, int width, int height, void* user_data);
Called on the UI thread when the pixel size changes: resize your render target here.
void Rviewport_set_resize_callback(Rid viewport, RViewportResizeCallback callback, void* user_data);
void Rviewport_set_realtime(Rid viewport, int realtime);
R_TRUE redraws the window every frame while the viewport is visible (game view). R_FALSE redraws only on Rwidget_invalidate (default).
Custom-painted widgets.
A CUSTOM widget is measured and painted by the application. Coordinates are in logical units, relative to the top-left corner of the widget; Raven applies the window scale, pixel snapping, clipping and opacity.
The paint callback runs on the UI thread and may only call Rdraw_... functions with the painter it received.
typedef enum RMotion
How a spring moves. Animations in Raven are springs, as on iOS: a value is pulled toward its target and may run past it before settling, which is what makes a control feel alive rather than mechanical.
R_MOTION_SNAPPY | Fast, no bounce: hover, highlights. |
R_MOTION_SMOOTH | Slower, no bounce: scrolling, fades, sizes. |
R_MOTION_BOUNCY | Runs a little past the target and comes back: switches, popups, pressed buttons. |
R_MOTION_WOBBLY | Swings several times around the target: things that fly in or get dropped. |
typedef struct RSpring
State of one animated value. Zero-initialize it and keep it with the widget.
float value | |
float velocity | |
int started |
typedef void (*RPaintCallback)(Rid widget, RPainter* painter, float width, float height, void* user_data);
typedef void (*RMeasureCallback)(Rid widget, float* width, float* height, void* user_data);
void Rcustom_set_paint_callback(Rid widget, RPaintCallback callback, void* user_data);
void Rcustom_set_measure_callback(Rid widget, RMeasureCallback callback, void* user_data);
Reports the desired size of the widget. Without it the widget asks for 0 x 0.
void Rdraw_rect(RPainter* painter, float x, float y, float width, float height, float radius, float r, float g, float b, float a);
Filled rectangle with rounded corners (radius 0 = sharp).
void Rdraw_rect_outline(RPainter* painter, float x, float y, float width, float height, float radius, float thickness, float r, float g, float b, float a);
Outline of a rounded rectangle, drawn inside its bounds.
void Rdraw_circle(RPainter* painter, float center_x, float center_y, float radius, float r, float g, float b, float a);
void Rdraw_line(RPainter* painter, float x0, float y0, float x1, float y1, float thickness, float r, float g, float b, float a);
Anti-aliased line with round caps.
void Rdraw_curve(RPainter* painter, float x0, float y0, float cx0, float cy0, float cx1, float cy1, float x1, float y1, float thickness, float r, float g, float b, float a);
Anti-aliased cubic Bezier curve from (x0, y0) to (x1, y1), pulled by two control points.
void Rdraw_triangle(RPainter* painter, float x0, float y0, float x1, float y1, float x2, float y2, float r, float g, float b, float a);
void Rdraw_image(RPainter* painter, Rid texture, float x, float y, float width, float height, float r, float g, float b, float a);
Texture stretched to a rectangle and multiplied by a tint color.
void Rdraw_text(RPainter* painter, Rid font, float size, float x, float y, const char* text, float r, float g, float b, float a);
Draws UTF-8 text; (x, y) is the top-left corner of the first line.
void Rdraw_glass(RPainter* painter, float x, float y, float width, float height, float radius, float r, float g, float b, float a);
Rounded rectangle of glass. It shows what was drawn before it, frosted and bent along its rim, under a tint: (r, g, b) is the color of the tint and a its strength (0 = clear glass, 1 = opaque color). Works with any theme. Needs a backend that implements glass (the Vulkan backend does).
float Rdraw_spring(RPainter* painter, RSpring* spring, float target, RMotion motion);
Animates a value from the paint callback of a custom widget. Moves the spring toward target by the time elapsed since the last frame and returns its value. While it moves, the window keeps drawing frames by itself. The first call puts the spring on its target.
static RSpring size; (zeroed) float s = Rdraw_spring(painter, &size, hovered ? 1.0f : 0.0f, R_MOTION_BOUNCY); Rdraw_circle(painter, cx, cy, 20.0f + 8.0f * s, ...);
void Rspring_kick(RSpring* spring, float velocity);
Pushes a spring away from its target (units per second): it bounces back.
void Rspring_set(RSpring* spring, float value);
Puts a spring at rest on a value, without animation.
void Rdraw_push_clip_rect(RPainter* painter, float x, float y, float width, float height);
Restricts the following draws to a rectangle, intersected with the current one.
void Rdraw_pop_clip_rect(RPainter* painter);
@file raven_shader.h Effects: fragment shaders that color a rounded rectangle.
An effect is a fragment shader that Raven runs on a rectangle of a widget, with rounded corners, anti-aliased edges, the clipping and the opacity of the widget already taken care of. It receives where the pixel is (0..1 in the rectangle, and in pixels), the size of the rectangle, two colors, four parameters, the time, an optional texture and, when it asks for it, what was drawn behind the rectangle (sharp and blurred).
Raven comes with effects of its own (REffect: aurora, shimmer, neon edge, ripple, plasma, grain, spotlight, mesh gradient), and an application can write its own in GLSL, compiled to SPIR-V with glslangValidator or glslc:
#version 450
#extension GL_GOOGLE_include_directive : require
#include "raven_effect.glsl" // include/raven/shaders in a package
vec4 raven_effect(RavenEffect fx) {
float wave = 0.5 + 0.5 * sin(fx.uv.x * 12.0 + fx.time * 3.0);
return mix(fx.color, fx.color2, wave); // straight alpha
}
glslangValidator -V -I<raven package>/include/raven/shaders wave.frag -o wave.spv
Then, in XML: <Border Effect="wave.spv" EffectColor="#0A84FF" EffectColor2="#BF5AF2" CornerRadius="16"/> or in C: Rid wave = Rshader_create_from_file("wave.spv", 0);
Rborder_set_effect(border, wave, &look); // or Rdraw_shader in a paint callback
Effects follow the pointer: fx.pointer is where it is (pixels, from the corner of the rectangle), fx.hover and fx.press how much it is over the widget and pressing it. The effects of Raven all react to it.
The guide docs/shaders.html describes everything an effect can use. The Vulkan backend runs effects; a backend without them (R_BACKEND_NULL, a custom backend whose CreateShader is NULL) draws the rectangle in color.
typedef enum REffect
The effects that come with Raven (Reffect_get).
R_EFFECT_AURORA | Soft lights that drift slowly: color, color2; params: speed, scale, intensity, -. Animated. |
R_EFFECT_SHIMMER | A band of light that sweeps across (loading placeholders): color = base, color2 = light; params: speed, width, angle, -. Animated. |
R_EFFECT_NEON | A glowing edge whose colors run around the shape: color, color2; params: speed, width, glow, -. Animated. |
R_EFFECT_RIPPLE | Rings that ripple what is behind, like water (reads the backdrop): color = tint; params: speed, strength, density, center x (0..1). Animated. |
R_EFFECT_PLASMA | Bands of color that flow into each other: color, color2; params: speed, scale, contrast, -. Animated. |
R_EFFECT_GRAIN | A gradient with the fine grain of film: color (top left) to color2 (bottom right); params: grain, angle, -, -. Animated grain. |
R_EFFECT_SPOTLIGHT | A soft light that follows a point: color = light, color2 = background; params: x, y (0..1), radius (0..1), -. |
R_EFFECT_MESH | Four colors blended across the surface, slowly moving: color, color2 and their mix; params: speed, -, -, -. Animated. |
typedef enum RShaderFlags
Flags of Rshader_create.
R_SHADER_BACKDROP | The effect reads what is drawn behind it (raven_backdrop, raven_backdrop_blur). |
R_SHADER_ANIMATED | The effect changes with time: the window keeps drawing frames while it is shown. |
typedef struct RShaderLook
How an effect is drawn. Start from Rshader_look_init.
float color[4] | First and second color, 0..1, straight alpha. |
float color2[4] | |
float params[4] | Four numbers the effect reads as fx.params (their meaning is the effect's). |
float radius | Radius of the corners, in logical units. |
Rid texture | Texture the effect reads with raven_texture(), or R_INVALID_ID. |
int animate | -1: animated when the shader is (R_SHADER_ANIMATED); R_TRUE / R_FALSE forces it. |
int pointer | R_TRUE (the default): the effect knows where the pointer is (fx.pointer, fx.hover, fx.press). |
float hover | How much the pointer is over it and how much it is pressed, 0..1, as the effect reads them (fx.hover, fx.press). -1 (the default): 1 while the pointer is in the rectangle, and while the left button is down there; a Border eases them itself. |
float press |
Rid Rshader_create(const void* spirv, size_t size, Ruint flags);
A shader from SPIR-V code (a fragment shader written with raven_effect.glsl, as in a .spv file): size bytes, copied. R_INVALID_ID when the code is not SPIR-V; a backend that refuses it reports an error and the effect is drawn as a rectangle.
Rid Rshader_create_from_file(const char* path, Ruint flags);
The same, from a .spv file (UTF-8 path, relative to the current folder).
void Rshader_destroy(Rid shader);
int Rshader_is_valid(Rid shader);
Ruint Rshader_get_flags(Rid shader);
Rid Reffect_find(const char* name);
A built-in effect by its name ("aurora", "shimmer", "neon", "ripple", "plasma", "grain", "spotlight", "mesh"), or R_INVALID_ID.
const char* Reffect_get_name(REffect effect);
void Reffect_get_defaults(REffect effect, RShaderLook* look);
Its colors and parameters when nothing else is given (Rshader_look_init uses them).
void Rshader_look_init(RShaderLook* look);
White to white, no parameter, no texture, square corners, animated when the shader is.
void Rshader_look_defaults(Rid shader, RShaderLook* look);
Fills a look with the defaults of the shader when it is a built-in effect (else Rshader_look_init).
void Rdraw_shader(RPainter* painter, Rid shader, float x, float y, float width, float height, const RShaderLook* look);
From a paint callback: draws the effect over a rectangle of the widget (logical units, from its top left corner).
void Rborder_set_effect(Rid border, Rid shader, const RShaderLook* look);
The background of a border becomes an effect (its Background, if any, is drawn under it; its child over it). R_INVALID_ID removes it. XML: Effect="aurora" or Effect="file.spv", EffectColor, EffectColor2, EffectParams="a,b,c,d", EffectAnimate, EffectBackdrop (for a file).
Building windows and widget trees from XML.
<Window Title="Editor" Width="1280" Height="720">
<VBox>
<Label Text="Hello" Slot.Padding="8" Slot.HAlign="Center"/>
<HBox Slot.Fill="1" Spacing="4">
<Button Name="save" Text="Save" OnClicked="file.save"/>
<Viewport Name="scene" Slot.Fill="1"/>
</HBox>
</VBox>
</Window>
- An element is a widget; its tag is the widget type (VBox, Button, ...). - Child elements are child widgets, in order. - Attributes set properties. Attributes starting with "Slot." set the
slot of the widget inside its parent (same meaning as Rslot_set_...).
- Tags and attribute names are not case sensitive. - Name="..." gives the widget a name for Rwidget_find. - OnClicked / OnChanged / OnCommitted / OnActivated="name" set the action
of the widget (Raction_bind).
NEW TAGS
A document can declare its own tags: a <Widget> names a piece of interface, with parameters, and is then used like any built-in widget.
<Widget Name="Field" Label="Name" Hint="" Wide="false">
<HBox Spacing="8">
<Label Text="{Label}:" Width="{Wide ? 140 : 90}"/>
<TextInput Placeholder="{Hint}" Slot.Fill="1"/>
<Children/>
</HBox>
</Widget>
<Field Label="Email" Hint="you@example.com" Name="email"/>
<Field Label="Password" Wide="true"><Button Text="Show"/></Field>
- The attributes of <Widget> other than Name are its parameters, with
their default values.
- Inside it, {...} is computed: a parameter, or an expression of them
(+ - * / %, comparisons, && || !, a ? b : c, 'text', min, max, round,
floor, ceil, abs, len, upper, lower, empty, default). "{{" is a brace.
- <Children/> is replaced by the children given where the tag is used;
<Children Name="x"/> by those marked Into="x".
- Where the tag is used, the attributes that are not parameters go to the
widget it becomes (Name, Slot.Fill, OnClicked, Material...).
- If="..." keeps or drops an element; <Repeat Count="3" Var="i"> and
<ForEach Items="a|b|c" Var="item"> repeat their content;
<Include Source="file.xml"/> brings in another file.
- A declaration is known from the moment it is read until the library
shuts down, in every document loaded afterwards.
DOCUMENTS
A tool that edits an interface (the designer does) needs more than loading a text: Rxml_document_parse gives the document as a tree of nodes that can be read, changed, written back and built. A widget built from a document knows the node it comes from, and the node the widget it became:
Rid document = Rxml_document_load("main.xml");
Rid button = Rxml_node_add_child(Rxml_document_get_root(document), "Button", -1);
Rxml_node_set_attribute(button, "Text", "Save");
Rid preview = Rxml_document_create_widget(document);
...
Rid node = Rwidget_get_xml_node(Rwidget_hit_test(preview, x, y));
Rxml_document_save(document, "main.xml");
Rxml_get_tag_count and Rxml_get_attribute_info list what can be written: the tags, and for each tag its attributes with the kind of value they take.
The complete list of tags and attributes is in docs/XML.md.
typedef struct RXmlError
Where and why a text could not be read (Rxml_document_parse).
int line | Both start at 1. |
int column | |
char message[160] |
typedef enum RXmlValueType
The kind of value an attribute takes.
R_XML_TEXT | |
R_XML_BOOL | "true" or "false". |
R_XML_NUMBER | |
R_XML_CHOICE | One of the words of choices. |
R_XML_COLOR | "#RGB", "#RRGGBB", "#RRGGBBAA", or a name: white, black, red, transparent... |
R_XML_ACTION | The name of an action (Raction_bind). |
R_XML_FILE | The path of a file. |
R_XML_NUMBERS | Several numbers separated by commas: "8,4", "0,0,1,1". |
R_XML_LIST | Texts separated by '|': "One|Two|Three". |
typedef struct RXmlAttributeInfo
One attribute of a tag (Rxml_get_attribute_info). The strings belong to the library.
const char* name | |
RXmlValueType type | |
const char* choices | R_XML_CHOICE: the words, separated by '|'. NULL otherwise. |
const char* group | What it belongs to: the tag itself ("Button"), "Widget" for what every widget has, "Slot" for the place in the parent. |
const char* description | One line saying what it does. |
Rid Rwindow_create_from_xml(const char* xml, size_t size);
Creates a window from a document whose root element is <Window>.
Rid Rwindow_create_from_xml_file(const char* path);
Rid Rwidget_create_from_xml(const char* xml, size_t size);
Creates a widget tree from a document whose root element is a widget. The caller owns the returned widget until it is added to a parent.
Rid Rwidget_create_from_xml_file(const char* path);
ravenc turns an .xmlc file into C: the elements become a table of RXmlCompiledNode, built by the functions below without reading any XML at run time. They give the same result as the same XML loaded with Rwindow_create_from_xml. Written by ravenc, rarely by hand.
typedef struct RXmlCompiledNode
const char* tag | Tag of the element ("VBox", "Button", "Item"...). |
const char* text | Its text content ("" when none). |
const char*const* attributes | name, value, name, value... (attribute_count pairs). |
int attribute_count | |
int parent | Index of the parent in the table, -1 for the root. The table lists a parent before its children, children in order. |
int line | Line in the source file, for the errors. |
Rid Rwindow_create_from_compiled(const RXmlCompiledNode* nodes, int count, const char* source);
Builds the window described by a compiled table whose root is <Window>. source names the file in the errors.
Rid Rwidget_create_from_compiled(const RXmlCompiledNode* nodes, int count, const char* source);
Builds the widget tree described by a compiled table.
void Rxml_set_base_path(const char* path);
Folder used to resolve relative paths found in XML (Source="...", Font="..."). The *FromXmlFile functions use the folder of the file.
What is created from a file (Rwindow_create_from_xml_file, Rwidget_create_from_xml_file, the files they <Include>, the files of Rxml_register_widgets_from_file, the theme files) follows its file: save it in any editor and the window changes while the application runs. Nothing is rebuilt that did not change: an element that is still in the file keeps its widget, so the handles of the application, its callbacks, what was typed and where things were scrolled all stay; only the attributes that changed are set again. Elements are matched by their Name when they have one, else by tag and order. A file with a mistake leaves the interface as it was and reports the error.
Texts given from memory are not concerned.
void Rxml_set_live_reload(int enabled);
Turns live reload on or off. It is on by default; the environment variable RAVEN_LIVE_RELOAD=0 turns it off without rebuilding. When off, files are never looked at again.
int Rxml_get_live_reload(void);
typedef void (*RXmlReloadCallback)(const char* path, int ok, void* user_data);
Called each time a file was loaded again.
Widgets that had to be built again have new handles: this is the place to look them up again (Rwidget_find).
void Rxml_set_reload_callback(RXmlReloadCallback callback, void* user_data);
int Rxml_check_files(void);
Looks at the files now, without waiting for the next look (there are five per second), even when live reload is off.
int Rxml_register_widgets(const char* xml, size_t size);
Reads the <Widget Name="..."> declarations of a document (its root, or the children of a <Widgets> root) so that the tags they declare can be used in the documents loaded afterwards.
int Rxml_register_widgets_from_file(const char* path);
void Rxml_unregister_widget(const char* name);
int Rxml_is_widget_registered(const char* name);
int Rxml_get_registered_widget_count(void);
The declared tags, for tools that list them.
const char* Rxml_get_registered_widget_name(int index);
typedef Rid (*RXmlTagCreateCallback)(const char* tag, void* user_data);
Tags made by code. A library or an application that builds a widget of its own (a R_WIDGET_CUSTOM with its callbacks, or an assembly of widgets) can give it a tag: documents then write <MyWidget .../> as they write <Button/>.
create makes the widget and returns it. set_attribute (may be NULL) receives the attributes of the element before Raven looks at them: it returns R_TRUE for those it understands, R_FALSE to leave them to the widget (Name, Width, Slot..., and what its type knows). Rwidget_set_attribute goes through it too.
typedef int (*RXmlTagAttributeCallback)(Rid widget, const char* name, const char* value, void* user_data);
int Rxml_register_tag(const char* tag, RXmlTagCreateCallback create, RXmlTagAttributeCallback set_attribute, void* user_data);
Registers a tag (or replaces what it was registered with).
void Rxml_unregister_tag(const char* tag);
int Rxml_is_tag_registered(const char* tag);
const char* Rxml_resolve_path(const char* path);
The path of a file named in a document: as the attributes Source of Raven read it, relative to the folder of the document being loaded (while it loads), else to the base path. For the attributes of the tags made by code that name files.
int Rwidget_set_attribute(Rid widget, const char* name, const char* value);
Sets a property from text, with the names and value syntax of the XML attributes. Handy for scripting and data-driven tools.
Rid Rxml_document_create(const char* root_tag);
A new document with one element.
Rid Rxml_document_parse(const char* xml, size_t size, RXmlError* error);
Reads a text into a document. Comments are kept.
Rid Rxml_document_load(const char* path);
Reads a file. The paths written in it are relative to its folder.
void Rxml_document_destroy(Rid document);
Releases a document and its nodes. What was built from it lives on.
int Rxml_document_is_valid(Rid document);
const char* Rxml_document_to_string(Rid document);
Writes the document as text, one element per line, indented with tabs. Rxml_node_get_line then says where each node was written.
int Rxml_document_save(Rid document, const char* path);
Rid Rxml_document_create_widget(Rid document);
Builds the widgets the document describes, as Rwidget_create_from_xml does. When the root is a <Window>, builds what the window would show (R_INVALID_ID when it is empty).
Rid Rxml_document_create_window(Rid document);
Builds the window the document describes, as Rwindow_create_from_xml does.
int Rxml_node_is_valid(Rid node);
const char* Rxml_node_get_tag(Rid node);
void Rxml_node_set_tag(Rid node, const char* tag);
int Rxml_node_is_comment(Rid node);
const char* Rxml_node_get_text(Rid node);
The text inside an element (<Label>this</Label>), or the text of a comment.
void Rxml_node_set_text(Rid node, const char* text);
int Rxml_node_get_child_count(Rid node);
int Rxml_node_get_index(Rid node);
Rid Rxml_node_add_child(Rid parent, const char* tag, int index);
Rid Rxml_node_add_xml(Rid parent, const char* xml, size_t size, int index);
Reads a piece of XML (one element and what it contains) and adds it: what a palette, a paste or a template inserts.
void Rxml_node_remove(Rid node);
Removes a node and what it contains. The root stays.
int Rxml_node_move(Rid node, Rid new_parent, int index);
Moves a node, with what it contains, under another parent of the same document or elsewhere under its own.
Rid Rxml_node_duplicate(Rid node);
Copies a node and what it contains, right after it. Returns the copy.
const char* Rxml_node_to_string(Rid node);
The node as text. Valid until the next call for this document.
int Rxml_node_get_attribute_count(Rid node);
const char* Rxml_node_get_attribute_name(Rid node, int index);
const char* Rxml_node_get_attribute_value(Rid node, int index);
const char* Rxml_node_get_attribute(Rid node, const char* name);
void Rxml_node_set_attribute(Rid node, const char* name, const char* value);
Sets an attribute, added after the others when it is new. A NULL value removes it.
int Rxml_node_get_line(Rid node);
Rid Rxml_node_get_widget(Rid node);
Rid Rwidget_get_xml_node(Rid widget);
int Rxml_get_tag_count(void);
The tags of the library, <Window> included. Those declared with <Widget> are listed by Rxml_get_registered_widget_name.
const char* Rxml_get_tag_name(int index);
const char* Rxml_get_tag_description(const char* tag);
int Rxml_get_tag_children(const char* tag);
int Rxml_get_attribute_count(const char* tag);
The attributes of a tag: its own first, then those every widget has, then those of its place in its parent. For a tag declared with <Widget>, its own are its parameters.
int Rxml_get_attribute_info(const char* tag, int index, RXmlAttributeInfo* info);
Translations and the conventions of a language.
Translations live in CSV tables: one row per text, one column per language. The first row names the columns: "key", then a language code per column (the codes are free: "en", "fr", "pt-BR", "ar"...).
key,en,fr,ar
menu.file,File,Fichier,ملف
greeting,"Hello, {0}!","Bonjour, {0} !",مرحبا {0}
files.one,{n} file,{n} fichier,ملف واحد
files.other,{n} files,{n} fichiers,{n} ملفات
The usual CSV rules apply: fields with commas, quotes or line breaks are quoted, "" inside quotes is one quote. Lines starting with # are comments. A UTF-8 BOM is accepted. Several tables can be loaded: they add up, and a key loaded again replaces the old text. A table loaded from a file is read again when the file is saved, while live reload is on (Rxml_set_live_reload).
In C:
Rlocale_load_csv("strings.csv");
Rlocale_set_language(Rlocale_get_system_language());
Rlabel_set_text(label, Rtr("menu.file"));
In XML, an attribute that starts with @ is a key: the widget shows its translation and follows the language when it changes ("@@" for a text that really starts with @):
<Button Text="@menu.file" Tooltip="@menu.file.tip"/>
and a document can load its tables itself:
<Strings Source="strings.csv"/>
A key with no translation in the language shows the text of the fallback language (the first column, or Rlocale_set_fallback_language), then the key.
The functions are for the UI thread. The strings they return stay valid until the tables or the language change (Rtr), or for the next 16 calls (Rtr_format, Rtr_plural, Rlocale_format_number).
int Rlocale_load_csv(const char* path);
Loads a CSV table of translations from a file. Returns the number of keys read, -1 on an error.
int Rlocale_load_csv_from_memory(const char* csv, size_t size);
Same, from text in memory (UTF-8).
void Rlocale_clear(void);
Forgets every table.
void Rlocale_set_text(const char* language, const char* key, const char* text);
Adds or replaces one text of one language.
int Rlocale_get_language_count(void);
Number of languages in the tables, and their codes, in the order of the columns.
const char* Rlocale_get_language_at(int index);
int Rlocale_set_language(const char* code);
Chooses the language: an exact code ("pt-BR"), or its first part ("pt") when the tables have no such column. Every widget that shows a key is updated, and the layout of the windows follows its direction (an Arabic, Hebrew, Persian or Urdu language is laid out from right to left, see Rset_layout_direction). Returns R_FALSE when no column matches (the language is set all the same: the texts fall back).
const char* Rlocale_get_language(void);
const char* Rlocale_get_system_language(void);
The language of the user, from the system ("fr-FR", "en-US"...).
void Rlocale_set_fallback_language(const char* code);
The language whose texts are shown when the current one has none (default: the first column).
int Rlocale_is_rtl(void);
R_TRUE when the language is written from right to left.
typedef void (*RLocaleChangedCallback)(const char* language, void* user_data);
void Rlocale_set_changed_callback(RLocaleChangedCallback callback, void* user_data);
Called after the language or the tables changed (the widgets are already updated).
const char* Rtr(const char* key);
The text of a key in the current language (see the fallbacks above). Never NULL.
int Rtr_exists(const char* key);
R_TRUE when the key has a text in the current language or the fallback one.
const char* Rtr_format(const char* key, const char*const* args, int arg_count);
The text of a key with its {0} {1} ... replaced by the arguments (translators may put them in any order). "{{" is a brace.
const char* Rtr_plural(const char* key, int count);
The plural form of a key for a count: the key followed by the CLDR category of the count in the current language (".zero", ".one", ".two", ".few", ".many", ".other"), else ".other", else the key itself. {n} is replaced by the count, written in the conventions of the language.
void Rwidget_set_text_key(Rid widget, const char* attribute, const char* key);
Makes a widget show a key: an attribute ("Text", "Tooltip", "Title", "Placeholder"... any attribute that takes a text) is set to the translation now and every time the language changes. NULL or "" stops it. Same as Rwidget_set_attribute(widget, attribute, "@key").
const char* Rlocale_format_number(double value, int decimals);
A number written in the conventions of the language: decimal separator and digit grouping ("1 234,5" in French).
Interfaces for everyone.
Screen readers. Every window of Raven is exposed to the screen reader of the system: UI Automation on Windows (Narrator, NVDA, JAWS), NSAccessibility on macOS (VoiceOver), AT-SPI on Linux (Orca). Nothing is needed for that: the widgets say what they are (a button, a check box, a slider, a list and its items, a tab...), their name (the text they show, or the label just before them), their value and their state, and they can be used from the screen reader (press, toggle, set a value, expand). The focus is followed, and the application can have a message read (Raccessibility_announce). What a widget cannot know (an icon button, a drawing) is given with Rwidget_set_accessible_name / _description / _role, or in XML with the attributes AccessibleName, AccessibleDescription, AccessibleRole and AccessibleHidden.
Sight. The size of every text (Raccessibility_set_text_scale), themes of high contrast, a focus that is always shown and thicker, animations that can be stopped, and color filters for the color blind: a correction that moves the colors they confuse to colors they tell apart, and simulations for those who design for them. Raccessibility_follow_system takes the settings of the system.
Writings. Right-to-left languages (Arabic, Hebrew, Persian, Urdu) are drawn in their order, with their letters joined, and the layout mirrors itself for them (raven_layout.h, Rset_layout_direction). The characters that the fonts of the application do not have (other alphabets, Chinese, Japanese, Korean, symbols, emoji in color) are taken from the fonts of the system. See raven_locale.h for translations.
void Raccessibility_set_text_scale(float scale);
Size of every text, 1 = as designed (0.5 to 4). Controls grow with their text.
float Raccessibility_get_text_scale(void);
void Raccessibility_set_high_contrast(int enabled);
Themes of high contrast: black and white, yellow focus, thick borders (the dark one, or the light one when the theme in use is light). R_FALSE goes back to the theme used before.
int Raccessibility_get_high_contrast(void);
void Raccessibility_set_focus_always_visible(int enabled);
R_TRUE: the focus ring is always shown (not only after the keyboard was used), and thicker.
int Raccessibility_get_focus_always_visible(void);
void Raccessibility_set_reduce_motion(int enabled);
Reduced motion, for the whole application: R_TRUE and nothing moves by itself. Changes are immediate (no spring, no slide, no bounce, no transition), and the effects (raven_shader.h) stand still; they still follow the pointer. Same as Rset_animations_enabled(R_FALSE).
int Raccessibility_get_reduce_motion(void);
typedef enum RColorFilter
R_COLOR_FILTER_NONE | |
R_COLOR_FILTER_PROTANOPIA | Corrections: the colors that cannot be told apart are moved to colors that can. |
R_COLOR_FILTER_DEUTERANOPIA | |
R_COLOR_FILTER_TRITANOPIA | |
R_COLOR_FILTER_GRAYSCALE | |
R_COLOR_FILTER_INVERT | |
R_COLOR_FILTER_SIMULATE_PROTANOPIA | Simulations, to see an interface as the color blind see it. |
R_COLOR_FILTER_SIMULATE_DEUTERANOPIA | |
R_COLOR_FILTER_SIMULATE_TRITANOPIA | |
R_COLOR_FILTER_SIMULATE_ACHROMATOPSIA |
void Raccessibility_set_color_filter(RColorFilter filter);
A filter on the colors of the interface (pictures and viewports keep theirs).
RColorFilter Raccessibility_get_color_filter(void);
typedef struct RAccessibilitySettings
What the system asks for.
float text_scale | Size of the texts asked by the user (1 = normal). |
int high_contrast | |
int reduce_motion | |
int screen_reader | R_TRUE when a screen reader is running. |
void Raccessibility_get_system_settings(RAccessibilitySettings* settings);
void Raccessibility_follow_system(void);
Applies the settings of the system (text size, contrast, motion).
typedef enum RAccessibleRole
R_ROLE_AUTO | The role of the type of the widget (the default). |
R_ROLE_NONE | Not exposed: its children are seen as the children of its parent. |
R_ROLE_WINDOW | |
R_ROLE_GROUP | |
R_ROLE_TEXT | |
R_ROLE_HEADING | |
R_ROLE_LINK | |
R_ROLE_BUTTON | |
R_ROLE_TOGGLE_BUTTON | |
R_ROLE_CHECKBOX | |
R_ROLE_RADIO_BUTTON | |
R_ROLE_SLIDER | |
R_ROLE_PROGRESS_BAR | |
R_ROLE_SPIN_BUTTON | |
R_ROLE_TEXT_FIELD | |
R_ROLE_DOCUMENT | |
R_ROLE_COMBO_BOX | |
R_ROLE_LIST | |
R_ROLE_LIST_ITEM | |
R_ROLE_TREE | |
R_ROLE_TREE_ITEM | |
R_ROLE_TABLE | |
R_ROLE_MENU_BAR | |
R_ROLE_MENU | |
R_ROLE_MENU_ITEM | |
R_ROLE_TAB_LIST | |
R_ROLE_TAB | |
R_ROLE_TAB_PANEL | |
R_ROLE_TOOLBAR | |
R_ROLE_STATUS_BAR | |
R_ROLE_DIALOG | |
R_ROLE_ALERT | |
R_ROLE_IMAGE | |
R_ROLE_CANVAS | |
R_ROLE_SEPARATOR | |
R_ROLE_SCROLL_BAR | |
R_ROLE_PANE |
void Rwidget_set_accessible_name(Rid widget, const char* name);
What the screen reader says of the widget; NULL: what it shows (or the label before it).
const char* Rwidget_get_accessible_name(Rid widget);
The name the screen reader uses (given, or found). Valid until the next call.
void Rwidget_set_accessible_description(Rid widget, const char* description);
A longer explanation, read after the name.
void Rwidget_set_accessible_role(Rid widget, RAccessibleRole role);
RAccessibleRole Rwidget_get_accessible_role(Rid widget);
The role the screen reader sees (given, or the one of the type).
void Rwidget_set_accessible_labelled_by(Rid widget, Rid label);
The widget is named by another one (a label): its text is the name.
void Raccessibility_announce(const char* text, int assertive);
Has a message read (a save that ended, an error). assertive: interrupts what is being read.
int Raccessibility_is_screen_reader_active(void);
R_TRUE when a screen reader is reading the windows of the application.
Vulkan-specific API.
C only: not part of the bindings of other languages.
IMPORTANT: this header intentionally does not include the Vulkan SDK. Vulkan handles are exchanged as opaque pointers (dispatchable handles) or 64-bit integers (non-dispatchable handles); cast them back in the source file that includes <vulkan/vulkan.h>.
Raven loads the Vulkan loader library at run time: no Vulkan library is needed to link an application.
Device selection: Raven uses a discrete GPU when there is one, then an integrated one. The environment variable RAVEN_VK_DEVICE=<index> forces the device with that index in the enumeration order of the driver.
const char*const* Rvulkan_get_required_instance_extensions(Ruint* count);
By default Raven creates its own VkInstance and VkDevice. To make Raven render with the device of the application (or of HRL), create the instance and the device with the extensions returned below, then pass them here.
const char*const* Rvulkan_get_required_device_extensions(Ruint* count);
void Rvulkan_set_external_device(void* instance, void* physical_device, void* device, void* queue, Ruint queue_family);
Makes Raven use an existing device. Raven does not destroy these objects.
queuetypedef void (*RVulkanQueueLockCallback)(void* user_data);
A VkQueue must not be used by two threads at once. When the queue is shared with the application, Raven calls lock before and unlock after each use of the queue from its render thread.
void Rvulkan_set_queue_lock_callbacks(RVulkanQueueLockCallback lock, RVulkanQueueLockCallback unlock, void* user_data);
void* Rvulkan_get_instance(void);
Opaque VkInstance, or NULL before initialization / on another backend.
void* Rvulkan_get_physical_device(void);
Opaque VkPhysicalDevice.
void* Rvulkan_get_device(void);
Opaque VkDevice.
void* Rvulkan_get_graphics_queue(void);
Opaque VkQueue used for rendering and presentation.
Ruint Rvulkan_get_graphics_queue_family(void);
Rid Rvulkan_texture_create_from_image_view(uint64_t image_view, uint64_t sampler, int width, int height);
Wraps an application image so that widgets (Image, Viewport) can show it. The image must be in VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL whenever Raven renders, and must outlive the texture. Raven does not destroy it: destroy it after Rtexture_destroy, which returns once Raven no longer uses the image.
The values of the image are shown as they are (the UI is not color managed): use a UNORM view of an sRGB-encoded image. Alpha is honored, so clear the image with alpha 1 unless the viewport should be see-through.
void Rvulkan_texture_set_image_view(Rid texture, uint64_t image_view, uint64_t sampler, int width, int height);
Points an existing wrapped texture to another image view (after a resize). Returns once Raven no longer uses the previous view, which can then be destroyed.
Rendering backend interface.
C only: not part of the bindings of other languages.
Include this header only to write a backend (OpenGL, Direct3D, Metal, or on top of another renderer such as HRL). Applications do not need it.
Raven turns the widget tree into a flat list of *instances*. Every primitive of the UI is one instance: a quad expanded by the vertex shader and shaded analytically (signed distance) by the fragment shader. A backend only has to 1. manage one presentation surface per window, 2. manage textures, 3. upload the instance array and issue one instanced draw per command, 4. optionally, keep a blurred copy of the frame for the glass primitives.
The reference shaders are src/render/vulkan/shaders/ui.vert and ui.frag.
Threading: every function of the table is called from a single thread, the render thread (or the UI thread when the render thread is disabled).
#define R_PRIM_RECT 0
#define R_PRIM_GLYPH 1
#define R_PRIM_SHADOW 2
#define R_PRIM_LINE 3
#define R_PRIM_TRIANGLE 4
#define R_PRIM_GLASS 5
#define R_PRIM_BLUR 6
#define R_PRIM_CURVE 7
#define R_PRIM_SHADER 8
#define R_PRIM_MASK 15
#define R_INSTANCE_TEXTURED 16
#define R_INSTANCE_NO_POINTER 32
typedef struct RDrawInstance
One primitive. All positions are in framebuffer pixels, origin top-left. Colors are 4 bytes R, G, B, A in memory order, straight (not premultiplied).
kind rect uv radii border_width RECT x0, y0, x1, y1 u0, v0, u1, v1 tl, tr, br, bl outline width GLYPH x0, y0, x1, y1 u0, v0, u1, v1 - - SHADOW x0, y0, x1, y1 - tl, tr, br, bl blur radius LINE ax, ay, bx, by - [0] = thickness - TRIANGLE ax, ay, bx, by - [0], [1] = cx, cy - GLASS x0, y0, x1, y1 see below tl, tr, br, bl bevel width BLUR x0, y0, x1, y1 see below tl, tr, br, bl outline width CURVE ax, ay, dx, dy see below bx, by, cx, cy thickness SHADER x0, y0, x1, y1 params 0..3 tl, tr, br, bl time (seconds)
Fragments outside clip (x0, y0, x1, y1) are discarded.
GLASS shows the *backdrop*: the frame as it was when the last R_DRAW_BACKDROP command was executed, sharp and blurred. Its fields are uv[0] frost, 0 = clear glass .. 1 = fully blurred uv[1] refraction: how far, in pixels, the rim bends the backdrop uv[2] saturation of the backdrop, 1 = unchanged uv[3] brightness added to the result (pressed / highlighted glass) color tint laid over the backdrop; its alpha is the strength border_color color of the light caught by the rim; its alpha is the intensity border_width width in pixels of the curved rim that refracts flags bits 8..15 = opacity of the whole primitive, 0..255 A backend without backdrop support may draw GLASS as a rounded rectangle filled with color.
CURVE is the cubic Bezier curve from a (rect[0], rect[1]) to d (rect[2], rect[3]) with the control points b and c (radii), drawn as a stroke with round ends: color color at a border_color color at d; the stroke shades from one to the other border_width thickness of the stroke, in pixels uv[0] radius of the halo around the stroke, in pixels (0 = none) uv[1] opacity of the halo next to the stroke, 0..1 uv[2] where the pulses are: they move from a to d as it grows (one pulse takes the place of the next every 1) uv[3] number of pulses along the curve (0 = none) flags bits 8..15 = how bright the pulses are, 0..255 A backend may draw it as a chain of LINE primitives.
BLUR shows the backdrop out of focus, flat (no rim, no bending): uv[0] radius of the blur, in pixels uv[1] grain, 0 = none .. 1 = frosted uv[2] saturation of the backdrop, 1 = unchanged uv[3] brightness added to the result color tint laid over the backdrop; its alpha is the strength border_color color of the outline, when border_width is not 0 flags bits 8..15 = opacity of the whole primitive, 0..255 A backend without backdrop support may draw it as a rounded rectangle filled with color.
SHADER is drawn by the fragment shader of its command (R_DRAW_SHADER), an effect of the application or of Raven (raven_shader.h): uv four parameters of the effect, as the application gave them color first color of the effect border_color second color of the effect border_width time of the frame, in seconds (for animated effects) flags bits 8..15 = opacity of the whole primitive, 0..255;
bits 16..23 = how much the pointer is over it (hover), 0..255;
bits 24..31 = how much it is pressed, 0..255;
R_INSTANCE_NO_POINTER: the effect does not follow the pointer
The effect also gets RDrawData::pointer. A backend without custom shaders may draw it as a rounded rectangle filled with color.
In a window that can be seen through (RNativeWindow::transparent), the alpha of the frame is what the window system blends with: GLASS and BLUR keep the alpha of the backdrop where they are not tinted.
float rect[4] | |
float uv[4] | |
float clip[4] | |
float radii[4] | |
uint32_t color | |
uint32_t border_color | |
float border_width | |
uint32_t flags |
typedef enum RDrawCommandType
R_DRAW_INSTANCES | Draw instance_count instances starting at first_instance. |
R_DRAW_CALLBACK | Call the viewport callback (see raven_viewport.h), then restore the UI state. |
R_DRAW_BACKDROP | Capture what has been drawn so far as the backdrop of the GLASS
instances that follow. rect is the area to capture, in pixels: the
rest of the backdrop keeps what the earlier captures of the frame put
there. Raven only emits the captures that are needed: one of the whole
frame before its first glass, then one each time glass covers something
drawn since that place was last captured. A backend may always capture
the whole frame; a backend without glass ignores the command. |
R_DRAW_ERASE | Like R_DRAW_INSTANCES, but the instances remove what was drawn where they are instead of drawing over it: the frame becomes transparent there, by as much as their coverage times the alpha of their color. That is how a window that can be seen through (R_WINDOW_TRANSPARENT) opens a hole in itself. With premultiplied colors it is the blend (ZERO, ONE_MINUS_SRC_ALPHA) for the color and for the alpha. A backend whose windows are never transparent ignores the command. |
R_DRAW_SHADER | Like R_DRAW_INSTANCES (SHADER primitives), drawn with the fragment
shader shader instead of the one of the UI. The shader sees the same
inputs and bindings as the UI shader: the texture of the command, and
the backdrop of glass when an R_DRAW_BACKDROP came before. A backend
without custom shaders draws the instances as rounded rectangles. |
typedef struct RDrawCommand
RDrawCommandType type | |
Rid texture | Texture sampled by the textured instances of the command, or R_INVALID_ID. |
Ruint first_instance | |
Ruint instance_count | |
RViewportDrawCallback callback | |
void* user_data | |
Rid viewport | |
int rect[4] | x, y, width, height in pixels. |
int clip[4] | |
Rid shader |
typedef struct RDrawData
Everything needed to render one frame of one window.
Rid window | |
const RDrawInstance* instances | |
Ruint instance_count | |
const RDrawCommand* commands | |
Ruint command_count | |
Ruint framebuffer_width | |
Ruint framebuffer_height | |
float clear_color[4] | |
uint64_t frame_index | |
float scale | Pixels per logical unit of the window: effects sized in pixels (blur) follow it. |
int vsync | R_TRUE: the frame waits for the vertical synchronization (Rset_vsync). |
float pointer[2] | Where the pointer is, in framebuffer pixels; -1e6, -1e6 when it is not over the window (for the effects, R_DRAW_SHADER). |
typedef enum RTextureFormat
R_TEXTURE_RGBA8 | 4 bytes per pixel: R, G, B, A. |
R_TEXTURE_ALPHA8 | 1 byte per pixel, sampled as (1, 1, 1, value). Used by the glyph atlas. |
typedef struct RTextureDesc
Ruint width | |
Ruint height | |
RTextureFormat format | |
RFilterType filter |
typedef struct RBackendInitInfo
const char* app_name | |
int enable_validation | |
int vsync | |
RWindowSystem window_system | |
void* native_display | Display connection of the window system (X11 Display*), or NULL. |
typedef struct RCapture
Filled by RenderFrame when a capture is requested.
uint8_t* pixels | RGBA8, allocated with Rpixels_alloc. NULL when capture is unsupported. |
int width | |
int height |
typedef struct RBackendVTable
const char* name | |
(function) Init | |
(function) Shutdown | |
(function) CreateSurface | Creates the presentation surface (swapchain) of a window. |
(function) DestroySurface | |
(function) CreateTexture | pixels may be NULL (content undefined until UpdateTexture). |
(function) UpdateTexture | |
(function) SetTextureFilter | |
(function) DestroyTexture | |
(function) RenderFrame | Renders and presents one frame. The surface must follow data->framebuffer_width / height (recreate the swapchain when they change). @param capture NULL, or a structure to fill with the rendered pixels. |
(function) WaitIdle | Blocks until the GPU finished all submitted work. |
(function) CreateShader | Optional (NULL: SHADER primitives are drawn as plain rounded
rectangles). Makes a fragment shader of SPIR-V words usable by the
R_DRAW_SHADER commands that name shader. R_FALSE when it is refused. |
(function) DestroyShader |
void Rbackend_register(const RBackendVTable* vtable);
Supplies the backend used by Rinit(R_BACKEND_CUSTOM). The table is copied. Must be called before Rinit.
uint8_t* Rpixels_alloc(size_t size);
Allocates a pixel buffer released by Rpixels_free. Thread-safe.
Declared in raven_web.h, which is not included by Raven.h; part of the same library.
Raven Web raven_web.h : web pages inside a Raven interface.
A separate, optional library (target raven_web, CMake option RAVEN_BUILD_WEB). Raven itself knows nothing about it; it only uses the public functions of Raven, and an application that does not link it pays nothing.
It does not contain a browser. It drives one that is already installed: any browser of the Chromium family (Microsoft Edge, which comes with Windows 10 and 11, Google Chrome, Chromium, Brave...). The browser runs hidden, in its own process, with a profile of its own; Raven Web talks to it through a pipe (the DevTools protocol) and:
- receives the picture of the page each time it changes, and shows it
in a texture, as any image of the interface: it can be clipped,
scrolled, put under glass, animated;
- sends it the mouse, the keys and the text the widget receives; - runs JavaScript in the page and receives messages from it.
So HTML, CSS and JavaScript are those of a real, up to date browser, and the library weighs a few thousand lines. The price: a browser must be installed (Rweb_is_available tells), pages are pictures that arrive a frame late, and the cursor does not change over links.
Rweb_register_xml(); // once, after Rinit: <WebView> exists
Rid view = Rweb_view_create();
Rweb_view_load_url(view, "https://example.org");
<WebView Name="docs" Url="https://example.org" Slot.Fill="1"/>
<WebView Source="pages/help.html"/>
<WebView><![CDATA[<h1>Hello</h1><p>From <b>HTML</b>.</p>]]></WebView>
Everything here is to be called from the UI thread, after Rinit.
int Rweb_is_available(void);
One browser process serves every web view. It starts with the first view and stops when the last one is deleted.
void Rweb_set_browser_path(const char* path);
Path of the browser program to use (NULL: look for one). To call before the first view is created.
const char* Rweb_get_browser_path(void);
void Rweb_set_profile_folder(const char* path);
Folder where the browser keeps its profile (cookies, storage, cache). By default a temporary folder, deleted when the browser stops: nothing is remembered from one run to the next. To call before the first view is created.
void Rweb_set_browser_arguments(const char* arguments);
More arguments for the command line of the browser, separated by spaces (e.g. "--proxy-server=localhost:8080"). Without a call to this function, those of the environment variable RAVEN_WEB_ARGUMENTS.
void Rweb_register_xml(void);
Makes the tag <WebView> known to the XML loader. To call once after Rinit.
void Rweb_shutdown(void);
Stops the browser now and forgets every setting. The views that remain show their last picture. Rshutdown deletes the views, and that stops the browser too: this is only for stopping it earlier.
Rid Rweb_view_create(void);
Creates a web view: a widget like the others (size, slot, visibility...).
void Rweb_view_load_url(Rid view, const char* url);
Goes to an address ("https://...", "file:///...", "about:blank").
void Rweb_view_load_file(Rid view, const char* path);
Shows a file of the computer (an .html file and what it refers to).
void Rweb_view_load_html(Rid view, const char* html, const char* base_url);
Shows HTML given as text.
void Rweb_view_reload(Rid view);
void Rweb_view_stop(Rid view);
void Rweb_view_go_back(Rid view);
void Rweb_view_go_forward(Rid view);
int Rweb_view_can_go_back(Rid view);
int Rweb_view_can_go_forward(Rid view);
const char* Rweb_view_get_url(Rid view);
const char* Rweb_view_get_title(Rid view);
int Rweb_view_is_loading(Rid view);
int Rweb_view_is_ready(Rid view);
const char* Rweb_view_get_error(Rid view);
Rid Rweb_view_get_texture(Rid view);
The texture that holds the last picture of the page, or R_INVALID_ID before the first one arrived. It belongs to the view; use it to draw the page somewhere else as well (Rdraw_image, an Image).
void Rweb_view_set_zoom(Rid view, float zoom);
Size of the content of the page: 1 = as the page asks, 1.25 = a quarter larger.
float Rweb_view_get_zoom(Rid view);
typedef enum RWebFrames
R_WEB_FRAMES_PNG | Exact pictures (default): text stays sharp. |
R_WEB_FRAMES_JPEG | Lighter pictures, slightly blurred: for pages that move a lot (video, animation). |
void Rweb_view_set_frames(Rid view, RWebFrames format, int quality);
typedef void (*RWebResultCallback)(Rid view, const char* result, const char* error, void* user_data);
Receives the result of a script: result is its value written as JSON ("42", "\"text\"", "{\"a\":1}", "null"), or NULL when the script failed, error then telling why.
void Rweb_view_run_javascript(Rid view, const char* script, RWebResultCallback callback, void* user_data);
Runs JavaScript in the page. If the script gives a promise, the result is what the promise resolves to.
typedef void (*RWebMessageCallback)(Rid view, const char* message, void* user_data);
Receives what the page sends with window.raven.postMessage(value): a string as it is, anything else written as JSON.
void Rweb_view_set_message_callback(Rid view, RWebMessageCallback callback, void* user_data);
typedef enum RWebEvent
R_WEB_EVENT_NAVIGATED | The view shows another address (Rweb_view_get_url). |
R_WEB_EVENT_TITLE | The title of the page changed (Rweb_view_get_title). |
R_WEB_EVENT_LOADING | A page starts loading. |
R_WEB_EVENT_LOADED | The page and what it refers to are loaded. |
R_WEB_EVENT_FAILED | The view cannot show pages any more (Rweb_view_get_error). |
void Rweb_view_set_event_callback(Rid view, RWebEventCallback callback, void* user_data);
Called when something happens in the page. The action of the widget (Rwidget_set_action, OnChanged in XML) is fired as well each time the address changes.
A Raccessibility_announce · Raccessibility_follow_system · Raccessibility_get_color_filter · Raccessibility_get_focus_always_visible · Raccessibility_get_high_contrast · Raccessibility_get_reduce_motion · Raccessibility_get_system_settings · Raccessibility_get_text_scale · Raccessibility_is_screen_reader_active · Raccessibility_set_color_filter · Raccessibility_set_focus_always_visible · Raccessibility_set_high_contrast · Raccessibility_set_reduce_motion · Raccessibility_set_text_scale · Raction_bind · Raction_fire · Raction_set_default_handler · Raction_unbind · Rallocator_get_system
B Rbackend_register · Rbackground_blur_clear_tint · Rbackground_blur_create · Rbackground_blur_get_radius · Rbackground_blur_get_style · Rbackground_blur_set_corner_radius · Rbackground_blur_set_grain · Rbackground_blur_set_padding · Rbackground_blur_set_radius · Rbackground_blur_set_saturation · Rbackground_blur_set_shadow · Rbackground_blur_set_style · Rbackground_blur_set_tint · Rblock_editor_add_block · Rblock_editor_add_kind · Rblock_editor_attach · Rblock_editor_clear · Rblock_editor_create · Rblock_editor_detach · Rblock_editor_get_body · Rblock_editor_get_input · Rblock_editor_get_kind · Rblock_editor_get_mouth_count · Rblock_editor_get_next · Rblock_editor_get_parent · Rblock_editor_get_position · Rblock_editor_get_script · Rblock_editor_get_script_count · Rblock_editor_get_selected · Rblock_editor_get_selection_count · Rblock_editor_get_slot_count · Rblock_editor_get_value · Rblock_editor_get_view · Rblock_editor_load · Rblock_editor_remove_block · Rblock_editor_save · Rblock_editor_select · Rblock_editor_set_block_deletable · Rblock_editor_set_block_glow · Rblock_editor_set_category_color · Rblock_editor_set_changed_callback · Rblock_editor_set_clicked_callback · Rblock_editor_set_context_callback · Rblock_editor_set_kind_label · Rblock_editor_set_kind_visible · Rblock_editor_set_palette_visible · Rblock_editor_set_slot_options · Rblock_editor_set_value · Rblock_editor_set_view · Rborder_get_effect · Rborder_set_background · Rborder_set_corner_radius · Rborder_set_effect · Rborder_set_material · Rborder_set_outline · Rborder_set_padding · Rborder_set_shadow · Rbutton_create · Rbutton_set_clicked_callback · Rbutton_set_style · Rbutton_set_text
C Rcheckbox_create · Rcheckbox_get_text · Rcheckbox_is_checked · Rcheckbox_set_changed_callback · Rcheckbox_set_checked · Rcheckbox_set_style · Rcheckbox_set_text · Rclipboard_get_text · Rclipboard_set_text · Rcolor_hsv_to_rgb · Rcolor_picker_add_swatch · Rcolor_picker_clear_swatches · Rcolor_picker_create · Rcolor_picker_get_color · Rcolor_picker_get_hex · Rcolor_picker_get_hsv · Rcolor_picker_get_swatch_count · Rcolor_picker_set_alpha_enabled · Rcolor_picker_set_changed_callback · Rcolor_picker_set_color · Rcolor_picker_set_compact · Rcolor_picker_set_hex · Rcolor_picker_set_hsv · Rcolor_picker_set_popup · Rcolor_picker_set_previous_color · Rcolor_rgb_to_hsv · Rcombo_box_add_item · Rcombo_box_clear_items · Rcombo_box_get_item_count · Rcombo_box_get_item_text · Rcombo_box_get_selected · Rcombo_box_set_changed_callback · Rcombo_box_set_selected · Rcustom_set_measure_callback · Rcustom_set_paint_callback
D Rdialog_close · Rdialog_open · Rdialog_run · Rdock_area_add_panel · Rdock_area_close_panel · Rdock_area_create · Rdock_area_dock_panel · Rdock_area_float_panel · Rdock_area_get_panel_window · Rdock_area_hide_panel · Rdock_area_is_panel_open · Rdock_area_is_panel_shown · Rdock_area_is_tearable · Rdock_area_load_layout · Rdock_area_move_panel · Rdock_area_open_panel · Rdock_area_save_layout · Rdock_area_set_changed_callback · Rdock_area_set_close_callback · Rdock_area_set_close_hides · Rdock_area_set_movable · Rdock_area_set_panel_closable · Rdock_area_set_panel_icon · Rdock_area_set_panel_title · Rdock_area_set_tearable · Rdock_area_show_panel · Rdrag_begin · Rdrag_cancel · Rdrag_get_data · Rdrag_get_type · Rdrag_is_active · Rdraw_circle · Rdraw_curve · Rdraw_frame · Rdraw_glass · Rdraw_image · Rdraw_line · Rdraw_pop_clip_rect · Rdraw_push_clip_rect · Rdraw_rect · Rdraw_rect_outline · Rdraw_shader · Rdraw_spring · Rdraw_text · Rdraw_triangle
E Reffect_find · Reffect_get · Reffect_get_defaults · Reffect_get_name · Rerror_get_last · Rerror_set_callback · Rerror_to_string · Rexpander_get_title · Rexpander_is_expanded · Rexpander_set_changed_callback · Rexpander_set_expanded · Rexpander_set_title
F Rfile_browser_create · Rfile_browser_get_directory · Rfile_browser_get_selection · Rfile_browser_get_selection_count · Rfile_browser_refresh · Rfile_browser_select · Rfile_browser_set_accepted_callback · Rfile_browser_set_cancelled_callback · Rfile_browser_set_controls_visible · Rfile_browser_set_default_extension · Rfile_browser_set_directory · Rfile_browser_set_file_name · Rfile_browser_set_filters · Rfile_browser_set_mode · Rfile_browser_set_multiple · Rfile_browser_set_places_visible · Rfile_browser_set_selection_changed_callback · Rfile_browser_set_show_hidden · Rfile_dialog_get_result · Rfile_dialog_get_result_count · Rfile_dialog_open · Rfile_dialog_save · Rfile_dialog_select_folder · Rfile_is_memory · Rfile_read · Rfile_register_memory · Rfile_unregister_memory · Rfile_write · Rfont_create · Rfont_create_from_file · Rfont_destroy · Rfont_get_default · Rfont_get_monospace · Rfont_get_variant · Rfont_is_valid · Rfont_measure_text · Rfont_set_fallback · Rfont_set_variant
G Rget_animation_speed · Rget_animations_enabled · Rget_delta_time · Rget_exit_code · Rget_layout_direction · Rget_time · Rget_ui_scale · Rget_version · Rget_vsync · Rget_worker_thread_count · Rgrid_set_column_fill · Rgrid_set_row_fill
H Rheader_bar_create · Rheader_bar_set_background · Rheader_bar_set_button_side · Rheader_bar_set_buttons · Rheader_bar_set_title · Rheader_bar_set_title_align · Rheader_bar_set_title_notch
I Rid · Rimage_decode · Rimage_set_corner_radius · Rimage_set_region · Rimage_set_stretch · Rimage_set_texture · Rimage_set_tint_color · Rimage_set_tint_text · Rinit · Rinit_ex · Ris_free_edition · Ris_initialized · Ris_running · Ris_ui_thread · Risland_create · Risland_expand_for · Risland_is_expanded · Risland_set_attached · Risland_set_changed_callback · Risland_set_expand_on_click · Risland_set_expand_on_hover · Risland_set_expanded
L Rlabel_create · Rlabel_get_markdown · Rlabel_get_plain_text · Rlabel_get_text · Rlabel_set_color · Rlabel_set_font · Rlabel_set_link_callback · Rlabel_set_markdown · Rlabel_set_text · Rlabel_set_text_align · Rlabel_set_text_size · Rlabel_set_wrap · Rlanguage_for_file · Rlanguage_get · Rlanguage_get_count · Rlanguage_get_name · Rlanguage_register · Rlist_view_add_item · Rlist_view_clear_items · Rlist_view_get_item_count · Rlist_view_get_item_text · Rlist_view_get_selected · Rlist_view_remove_item · Rlist_view_scroll_to_item · Rlist_view_set_activated_callback · Rlist_view_set_item_text · Rlist_view_set_selected · Rlist_view_set_selection_changed_callback · Rlist_view_set_virtual_items · Rlocale_clear · Rlocale_format_number · Rlocale_get_language · Rlocale_get_language_at · Rlocale_get_language_count · Rlocale_get_system_language · Rlocale_is_rtl · Rlocale_load_csv · Rlocale_load_csv_from_memory · Rlocale_set_changed_callback · Rlocale_set_fallback_language · Rlocale_set_language · Rlocale_set_text
M Rmemory_alloc · Rmemory_check · Rmemory_free · Rmemory_get_stats · Rmemory_realloc · Rmemory_trim · Rmenu_add_item · Rmenu_add_menu · Rmenu_add_separator · Rmenu_item_get_text · Rmenu_item_is_checked · Rmenu_item_set_checkable · Rmenu_item_set_checked · Rmenu_item_set_clicked_callback · Rmenu_item_set_icon · Rmenu_item_set_shortcut · Rmenu_item_set_text · Rmenu_open · Rmenu_set_title · Rmessage_box
N Rnode_graph_add_input · Rnode_graph_add_node · Rnode_graph_add_output · Rnode_graph_clear · Rnode_graph_clear_selection · Rnode_graph_connect · Rnode_graph_create · Rnode_graph_disconnect · Rnode_graph_find_node · Rnode_graph_find_pin · Rnode_graph_frame_all · Rnode_graph_from_canvas · Rnode_graph_get_input · Rnode_graph_get_input_link · Rnode_graph_get_link · Rnode_graph_get_link_count · Rnode_graph_get_link_input · Rnode_graph_get_link_output · Rnode_graph_get_node · Rnode_graph_get_node_content · Rnode_graph_get_node_count · Rnode_graph_get_node_name · Rnode_graph_get_node_position · Rnode_graph_get_node_size · Rnode_graph_get_node_title · Rnode_graph_get_node_user_data · Rnode_graph_get_output · Rnode_graph_get_pin_label · Rnode_graph_get_pin_node · Rnode_graph_get_pin_position · Rnode_graph_get_pin_type · Rnode_graph_get_selected_node · Rnode_graph_get_selection_count · Rnode_graph_get_view · Rnode_graph_is_node_selected · Rnode_graph_is_pin_output · Rnode_graph_remove_node · Rnode_graph_remove_pin · Rnode_graph_select_node · Rnode_graph_set_activated_callback · Rnode_graph_set_connect_callback · Rnode_graph_set_context_callback · Rnode_graph_set_flow_visible · Rnode_graph_set_grid_visible · Rnode_graph_set_linked_callback · Rnode_graph_set_moved_callback · Rnode_graph_set_node_active · Rnode_graph_set_node_active_color · Rnode_graph_set_node_badge · Rnode_graph_set_node_color · Rnode_graph_set_node_content · Rnode_graph_set_node_deletable · Rnode_graph_set_node_name · Rnode_graph_set_node_position · Rnode_graph_set_node_title · Rnode_graph_set_node_user_data · Rnode_graph_set_pin_multiple · Rnode_graph_set_pin_name · Rnode_graph_set_read_only · Rnode_graph_set_removed_callback · Rnode_graph_set_selection_callback · Rnode_graph_set_type_color · Rnode_graph_set_unlinked_callback · Rnode_graph_set_view · Rnode_graph_to_canvas
P Rpanel_get_spacing · Rpanel_set_spacing · Rparallel_for · Rpixels_alloc · Rpixels_free · Rpoll_events · Rprogress_bar_get_value · Rprogress_bar_set_value
Q Rquit
S Rscroll_box_get_offset · Rscroll_box_scroll_to_end · Rscroll_box_set_offset · Rscroll_box_set_orientation · Rscroll_box_set_scroll_both · Rseparator_set_orientation · Rset_allocator · Rset_animation_speed · Rset_animation_time_step · Rset_animations_enabled · Rset_frame_callback · Rset_layout_direction · Rset_ui_scale · Rset_vsync · Rseverity_to_string · Rshader_create · Rshader_create_from_file · Rshader_destroy · Rshader_get_flags · Rshader_is_valid · Rshader_look_defaults · Rshader_look_init · Rshutdown · Rsize_box_set_aspect_ratio · Rslider_get_range · Rslider_get_value · Rslider_set_changed_callback · Rslider_set_orientation · Rslider_set_range · Rslider_set_step · Rslider_set_value · Rslot_set_alignment · Rslot_set_anchors · Rslot_set_auto · Rslot_set_fill · Rslot_set_grid · Rslot_set_grid_span · Rslot_set_halign · Rslot_set_max_size · Rslot_set_padding · Rslot_set_position · Rslot_set_size · Rslot_set_title · Rslot_set_valign · Rspacer_set_size · Rspin_box_get_range · Rspin_box_get_value · Rspin_box_set_changed_callback · Rspin_box_set_decimals · Rspin_box_set_range · Rspin_box_set_step · Rspin_box_set_value · Rsplitter_set_min_pane_size · Rsplitter_set_orientation · Rspring_kick · Rspring_set · Rswitcher_get_index · Rswitcher_set_index
T Rtab_view_add_tab · Rtab_view_find_tab · Rtab_view_get_active · Rtab_view_get_tab · Rtab_view_get_tab_count · Rtab_view_set_active · Rtab_view_set_changed_callback · Rtab_view_set_close_callback · Rtab_view_set_documents · Rtab_view_set_tab_closable · Rtab_view_set_tab_icon · Rtab_view_set_tab_title · Rtab_view_show_tab · Rtask_post · Rtask_run_async · Rtext_editor_add_completion · Rtext_editor_add_marker · Rtext_editor_can_redo · Rtext_editor_can_undo · Rtext_editor_clear_markers · Rtext_editor_create · Rtext_editor_get_cursor · Rtext_editor_get_language · Rtext_editor_get_length · Rtext_editor_get_line · Rtext_editor_get_line_count · Rtext_editor_get_markdown · Rtext_editor_get_marker_count · Rtext_editor_get_selected_text · Rtext_editor_get_selection · Rtext_editor_get_text · Rtext_editor_get_token · Rtext_editor_get_zoom · Rtext_editor_insert_text · Rtext_editor_is_completing · Rtext_editor_redo · Rtext_editor_scroll_to_line · Rtext_editor_select · Rtext_editor_select_all · Rtext_editor_set_auto_pairs · Rtext_editor_set_changed_callback · Rtext_editor_set_completion · Rtext_editor_set_completion_callback · Rtext_editor_set_cursor · Rtext_editor_set_font · Rtext_editor_set_language · Rtext_editor_set_line_numbers · Rtext_editor_set_markdown · Rtext_editor_set_placeholder · Rtext_editor_set_read_only · Rtext_editor_set_syntax · Rtext_editor_set_tab_inserts_spaces · Rtext_editor_set_tab_size · Rtext_editor_set_text · Rtext_editor_set_word_wrap · Rtext_editor_set_zoom · Rtext_editor_set_zoom_callback · Rtext_editor_set_zoomable · Rtext_editor_show_completions · Rtext_editor_undo · Rtext_input_get_text · Rtext_input_is_password · Rtext_input_is_read_only · Rtext_input_select_all · Rtext_input_set_changed_callback · Rtext_input_set_committed_callback · Rtext_input_set_max_length · Rtext_input_set_password · Rtext_input_set_placeholder · Rtext_input_set_read_only · Rtext_input_set_text · Rtexture_create · Rtexture_create_async · Rtexture_create_from_file · Rtexture_create_from_file_async · Rtexture_create_from_pixels · Rtexture_destroy · Rtexture_get_size · Rtexture_is_ready · Rtexture_is_valid · Rtexture_set_filter · Rtexture_update · Rtexture_wait · Rtheme_apply · Rtheme_clear_styles · Rtheme_clear_token_colors · Rtheme_get_color · Rtheme_get_count · Rtheme_get_font · Rtheme_get_material · Rtheme_get_metric · Rtheme_get_name · Rtheme_get_name_at · Rtheme_get_token_color · Rtheme_get_wallpaper · Rtheme_is_dark · Rtheme_load · Rtheme_load_from_memory · Rtheme_save · Rtheme_set_accent · Rtheme_set_color · Rtheme_set_dark · Rtheme_set_font · Rtheme_set_material · Rtheme_set_metric · Rtheme_set_style_color · Rtheme_set_style_material · Rtheme_set_style_metric · Rtheme_set_token_color · Rtheme_set_wallpaper · Rtheme_use · Rtile_view_clear_selection · Rtile_view_get_count · Rtile_view_get_current · Rtile_view_get_item_at · Rtile_view_get_selection · Rtile_view_get_selection_count · Rtile_view_is_selected · Rtile_view_refresh · Rtile_view_scroll_to · Rtile_view_select_only · Rtile_view_set_activated_callback · Rtile_view_set_context_callback · Rtile_view_set_drag_data_callback · Rtile_view_set_drag_type · Rtile_view_set_drop_highlight · Rtile_view_set_empty_text · Rtile_view_set_items · Rtile_view_set_selected · Rtile_view_set_selection_changed_callback · Rtile_view_set_tile_size · Rtimeline_add_clip · Rtimeline_add_key · Rtimeline_add_marker · Rtimeline_add_track · Rtimeline_clear · Rtimeline_clear_selection · Rtimeline_create · Rtimeline_get_duration · Rtimeline_get_frame_rate · Rtimeline_get_item · Rtimeline_get_item_count · Rtimeline_get_item_label · Rtimeline_get_item_length · Rtimeline_get_item_start · Rtimeline_get_item_track · Rtimeline_get_item_type · Rtimeline_get_selected · Rtimeline_get_selection_count · Rtimeline_get_time · Rtimeline_get_track · Rtimeline_get_track_count · Rtimeline_get_track_name · Rtimeline_get_view · Rtimeline_is_playing · Rtimeline_is_selected · Rtimeline_is_track_muted · Rtimeline_remove_item · Rtimeline_remove_track · Rtimeline_select · Rtimeline_set_activated_callback · Rtimeline_set_changed_callback · Rtimeline_set_duration · Rtimeline_set_frame_rate · Rtimeline_set_item · Rtimeline_set_item_color · Rtimeline_set_item_label · Rtimeline_set_loop · Rtimeline_set_playing · Rtimeline_set_removed_callback · Rtimeline_set_selection_callback · Rtimeline_set_snapping · Rtimeline_set_time · Rtimeline_set_time_callback · Rtimeline_set_track_color · Rtimeline_set_track_height · Rtimeline_set_track_locked · Rtimeline_set_track_muted · Rtimeline_set_track_name · Rtimeline_set_view · Rtimer_create · Rtimer_destroy · Rtimer_is_valid · Rtr · Rtr_exists · Rtr_format · Rtr_plural · Rtree_item_destroy · Rtree_item_get_child · Rtree_item_get_child_count · Rtree_item_get_parent · Rtree_item_get_text · Rtree_item_get_user_handle · Rtree_item_is_expanded · Rtree_item_is_selected · Rtree_item_is_valid · Rtree_item_set_expanded · Rtree_item_set_icon · Rtree_item_set_selected · Rtree_item_set_text · Rtree_item_set_text_color · Rtree_item_set_user_handle · Rtree_view_add_item · Rtree_view_clear_items · Rtree_view_clear_selection · Rtree_view_get_item · Rtree_view_get_item_at · Rtree_view_get_item_count · Rtree_view_get_selected_item · Rtree_view_get_selection · Rtree_view_get_selection_count · Rtree_view_scroll_to_item · Rtree_view_set_activated_callback · Rtree_view_set_context_callback · Rtree_view_set_drag_type · Rtree_view_set_drop_highlight · Rtree_view_set_multi_select · Rtree_view_set_selected_item · Rtree_view_set_selection_changed_callback
U Runiform_grid_set_columns · Runiform_grid_set_min_cell_size
V Rviewport_get_native_handle · Rviewport_get_pixel_size · Rviewport_set_draw_callback · Rviewport_set_flip_y · Rviewport_set_native · Rviewport_set_realtime · Rviewport_set_resize_callback · Rviewport_set_stretch · Rviewport_set_texture · Rvulkan_get_device · Rvulkan_get_graphics_queue · Rvulkan_get_graphics_queue_family · Rvulkan_get_instance · Rvulkan_get_physical_device · Rvulkan_get_required_device_extensions · Rvulkan_get_required_instance_extensions · Rvulkan_set_external_device · Rvulkan_set_queue_lock_callbacks · Rvulkan_texture_create_from_image_view · Rvulkan_texture_create_shared · Rvulkan_texture_get_shared_info · Rvulkan_texture_set_image_view
W Rwait_events · Rwait_frame · Rwake_up · Rweb_get_browser_path · Rweb_is_available · Rweb_register_xml · Rweb_set_browser_arguments · Rweb_set_browser_path · Rweb_set_profile_folder · Rweb_shutdown · Rweb_view_can_go_back · Rweb_view_can_go_forward · Rweb_view_create · Rweb_view_get_error · Rweb_view_get_texture · Rweb_view_get_title · Rweb_view_get_url · Rweb_view_get_zoom · Rweb_view_go_back · Rweb_view_go_forward · Rweb_view_is_loading · Rweb_view_is_ready · Rweb_view_is_valid · Rweb_view_load_file · Rweb_view_load_html · Rweb_view_load_url · Rweb_view_reload · Rweb_view_run_javascript · Rweb_view_set_event_callback · Rweb_view_set_frames · Rweb_view_set_message_callback · Rweb_view_set_zoom · Rweb_view_stop · Rwidget_add_child · Rwidget_add_class · Rwidget_clear_children · Rwidget_clear_color · Rwidget_clear_metric · Rwidget_create · Rwidget_create_from_compiled · Rwidget_create_from_xml · Rwidget_create_from_xml_file · Rwidget_destroy · Rwidget_find · Rwidget_focus · Rwidget_get_accessible_name · Rwidget_get_accessible_role · Rwidget_get_action · Rwidget_get_child · Rwidget_get_child_count · Rwidget_get_class · Rwidget_get_color · Rwidget_get_desired_size · Rwidget_get_direction · Rwidget_get_material · Rwidget_get_metric · Rwidget_get_name · Rwidget_get_parent · Rwidget_get_rect · Rwidget_get_theme · Rwidget_get_tooltip · Rwidget_get_type · Rwidget_get_user_handle · Rwidget_get_visibility · Rwidget_get_window · Rwidget_get_xml_node · Rwidget_has_class · Rwidget_hit_test · Rwidget_insert_child · Rwidget_invalidate · Rwidget_is_enabled · Rwidget_is_focused · Rwidget_is_hovered · Rwidget_is_valid · Rwidget_pick · Rwidget_play_transition · Rwidget_remove_child · Rwidget_remove_class · Rwidget_scroll_into_view · Rwidget_set_accessible_description · Rwidget_set_accessible_hidden · Rwidget_set_accessible_labelled_by · Rwidget_set_accessible_name · Rwidget_set_accessible_role · Rwidget_set_action · Rwidget_set_attribute · Rwidget_set_class · Rwidget_set_clipping · Rwidget_set_color · Rwidget_set_context_menu · Rwidget_set_cursor · Rwidget_set_destroy_callback · Rwidget_set_direction · Rwidget_set_drop_callback · Rwidget_set_enabled · Rwidget_set_event_callback · Rwidget_set_focusable · Rwidget_set_hit_testable · Rwidget_set_material · Rwidget_set_max_size · Rwidget_set_metric · Rwidget_set_min_size · Rwidget_set_name · Rwidget_set_opacity · Rwidget_set_size · Rwidget_set_text_key · Rwidget_set_theme · Rwidget_set_tooltip · Rwidget_set_transition · Rwidget_set_user_handle · Rwidget_set_visibility · Rwidget_set_window_drag · Rwindow_begin_move · Rwindow_begin_resize · Rwindow_capture · Rwindow_center · Rwindow_close · Rwindow_close_popups · Rwindow_create · Rwindow_create_from_compiled · Rwindow_create_from_xml · Rwindow_create_from_xml_file · Rwindow_destroy · Rwindow_get_backdrop · Rwindow_get_content · Rwindow_get_focused_widget · Rwindow_get_frame_stats · Rwindow_get_framebuffer_size · Rwindow_get_hovered_widget · Rwindow_get_island · Rwindow_get_modifiers · Rwindow_get_mouse_position · Rwindow_get_native_handle · Rwindow_get_opacity · Rwindow_get_position · Rwindow_get_scale · Rwindow_get_size · Rwindow_get_title · Rwindow_get_user_handle · Rwindow_get_watermark_rect · Rwindow_has_dialog · Rwindow_has_popup · Rwindow_hide · Rwindow_inject_drag · Rwindow_inject_drop · Rwindow_inject_key · Rwindow_inject_mouse_button · Rwindow_inject_mouse_move · Rwindow_inject_mouse_wheel · Rwindow_inject_text · Rwindow_is_active · Rwindow_is_key_down · Rwindow_is_maximized · Rwindow_is_minimized · Rwindow_is_mouse_button_down · Rwindow_is_mouse_inside · Rwindow_is_valid · Rwindow_maximize · Rwindow_minimize · Rwindow_register_shortcut · Rwindow_request_redraw · Rwindow_restore · Rwindow_set_backdrop · Rwindow_set_background · Rwindow_set_clear_color · Rwindow_set_close_callback · Rwindow_set_content · Rwindow_set_continuous_redraw · Rwindow_set_drop_callback · Rwindow_set_event_hook · Rwindow_set_icon · Rwindow_set_island · Rwindow_set_min_size · Rwindow_set_opacity · Rwindow_set_position · Rwindow_set_resize_callback · Rwindow_set_size · Rwindow_set_tab_navigation · Rwindow_set_title · Rwindow_set_topmost · Rwindow_set_user_handle · Rwindow_show · Rwindow_unregister_shortcut · Rwindow_wants_text_input
X Rxml_check_files · Rxml_document_create · Rxml_document_create_widget · Rxml_document_create_window · Rxml_document_destroy · Rxml_document_get_root · Rxml_document_is_valid · Rxml_document_load · Rxml_document_parse · Rxml_document_save · Rxml_document_to_string · Rxml_get_attribute_count · Rxml_get_attribute_info · Rxml_get_live_reload · Rxml_get_registered_widget_count · Rxml_get_registered_widget_name · Rxml_get_tag_children · Rxml_get_tag_count · Rxml_get_tag_description · Rxml_get_tag_name · Rxml_is_tag_registered · Rxml_is_widget_registered · Rxml_node_add_child · Rxml_node_add_comment · Rxml_node_add_xml · Rxml_node_duplicate · Rxml_node_get_attribute · Rxml_node_get_attribute_count · Rxml_node_get_attribute_name · Rxml_node_get_attribute_value · Rxml_node_get_child · Rxml_node_get_child_count · Rxml_node_get_document · Rxml_node_get_index · Rxml_node_get_line · Rxml_node_get_parent · Rxml_node_get_tag · Rxml_node_get_text · Rxml_node_get_widget · Rxml_node_is_comment · Rxml_node_is_valid · Rxml_node_move · Rxml_node_remove · Rxml_node_set_attribute · Rxml_node_set_tag · Rxml_node_set_text · Rxml_node_to_string · Rxml_register_tag · Rxml_register_widgets · Rxml_register_widgets_from_file · Rxml_resolve_path · Rxml_set_base_path · Rxml_set_live_reload · Rxml_set_reload_callback · Rxml_unregister_tag · Rxml_unregister_widget
Raven 0.1 — Apache License 2.0 — raven home · source