view.h(3)Bark

NAME

view.h - Bark reactive UI viewport, layout, input events, video slots, and asset loading.

SYNOPSIS

Classes

struct bark_rect

Axis-aligned layout rectangle in logical viewport pixels.

struct bark_view_event

Normalized input event passed to bark_view_on_event() callbacks.

struct bark_view_cfg

Window and stylesheet configuration for bark_view_open().

struct bark_view_key_ev

Parsed DOM KeyboardEvent JSON payload delivered to onKeyDown handlers.

Macros

#define BARK_MOD_SHIFT 1
#define BARK_MOD_CTRL 2
#define BARK_MOD_ALT 4
#define BARK_MOD_META 8
#define BARK_MOUSE_LEFT 0
#define BARK_MOUSE_RIGHT 1
#define BARK_MOUSE_MIDDLE 2

Typedefs

typedef struct bark_view bark_view_t

Opaque visual document host handle.

typedef struct bark_rect bark_rect_t

Axis-aligned layout rectangle in logical viewport pixels.

typedef enum bark_ev_type bark_ev_type_t

Input and window event categories delivered to bark_view_event_fn.

typedef struct bark_view_event bark_view_event_t

Normalized input event passed to bark_view_on_event() callbacks.

typedef bud_node *(* bark_view_render_fn) (void *ctx)

Application render callback returning the root bud_node* VDOM tree.

typedef void(* bark_view_term_input_fn) (void *ctx, const char *data, size_t len)

Callback receiving UTF-8 bytes typed into an embedded #term ANSI terminal.

typedef void(* bark_view_img_fetch_fn) (void *ctx, const char *src)

Optional custom image fetcher callback when an <img> source is not cached.

typedef int(* bark_view_event_fn) (void *user, const bark_view_event_t *ev)

Raw event interceptor; return non-zero to consume the event before VDOM dispatch.

typedef struct bark_view_cfg bark_view_cfg_t

Window and stylesheet configuration for bark_view_open().

typedef void(* bark_view_post_sync_fn) (void *user)

Optional callback executed immediately after each VDOM reconciliation pass.

typedef struct bark_view_key_ev bark_view_key_ev_t

Parsed DOM KeyboardEvent JSON payload delivered to onKeyDown handlers.

Enumerations

enum bark_ev_type { BARK_EV_NONE = 0, BARK_EV_RESIZE = 1, BARK_EV_MOUSE_MOVE = 2, BARK_EV_MOUSE_BTN = 3, BARK_EV_SCROLL = 4, BARK_EV_KEY = 5, BARK_EV_CHAR = 6, BARK_EV_FILE_DROP = 7 }

Input and window event categories delivered to bark_view_event_fn.

Functions

bark_view_t * bark_view_open (const bark_view_cfg_t *cfg)

Open a windowed or headless visual host from cfg.

void bark_view_close (bark_view_t *view)

Close and destroy a host opened with bark_view_open().

bark_view_t * bark_view_create (int vw, int vh)

Create a bare offscreen/headless visual host of size vw x vh.

void bark_view_destroy (bark_view_t *view)

Destroy a visual host created with bark_view_create().

int bark_view_load_css_file (bark_view_t *view, const char *path)

Load and parse a CSS stylesheet from a file path.

int bark_view_load_css (bark_view_t *view, const char *css, size_t len)

Load and parse a CSS stylesheet from an in-memory string.

int bark_view_set_css_var (bark_view_t *view, const char *name, const char *val)

Set a CSS custom property (e.g. --accent")atruntime.

void bark_view_set_fonts (bark_view_t *view, uint32_t sans, uint32_t sans_bold, uint32_t mono, uint32_t mono_bold)

Override loaded font handles for sans/mono regular and bold faces.

void bark_view_set_asset_root (bark_view_t *view, const char *htdocs_dir)

Set the base directory for resolving relative <img src=...">paths.

int bark_view_load_bundle_assets (bark_view_t *view, const char *argv0, const char *config_dir, const char *app_share_name, const char *css_filename, int set_assets)

Auto-discover installed/bundled CSS and asset directory relative to argv0 and config_dir.

void bark_view_set_img_fetch (bark_view_t *view, bark_view_img_fetch_fn fn, void *ctx)

Install a custom image fetch callback for uncached <img> URLs.

int bark_view_provide_img (bark_view_t *view, const char *src, const uint8_t *bytes, size_t len, const char *mime)

Supply encoded image bytes for a cached src URL or data URI.

int bark_view_img_ready (const bark_view_t *view, const char *src, uint32_t *w_out, uint32_t *h_out)

Check whether src is decoded and ready, optionally returning pixel dimensions.

int bark_view_bind_net (bark_view_t *view, bark_net_t *net, const char *origin)

Bind a bark_net_t handle so relative/HTTP <img> tags auto-fetch from origin.

int bark_view_pending_imgs (const bark_view_t *view)

Return the count of in-flight network image fetches.

int bark_view_wait_imgs (bark_view_t *view, bark_net_t *net, uint32_t timeout_ms)

Block up to timeout_ms pumping net until pending images finish loading.

void bark_view_bind_sys (bark_view_t *view, bark_sys_t *sys)

Bind a bark_sys_t handle for clipboard and file drag-and-drop integration.

void bark_view_set_render (bark_view_t *view, bark_view_render_fn fn, void *ctx)

Register the application's declarative render function invoked on sync.

void bark_view_set_post_sync (bark_view_t *view, bark_view_post_sync_fn fn, void *user)

Register a post-reconciliation hook (useful for updating video slot bindings).

void bark_view_set_term_input (bark_view_t *view, bark_view_term_input_fn fn, void *ctx)

Register an input callback for an embedded #term ANSI terminal widget.

void bark_view_set_dark_mode (bark_view_t *view, int dark)

Toggle dark mode defaults at runtime.

void bark_view_set_active_global (bark_view_t *view)

Set the active global view instance used by WASM DOM callbacks.

int bark_view_push_video_rgba (bark_view_t *view, const char *id, const uint8_t *rgba, uint16_t w, uint16_t h)

Upload an RGBA8 frame directly to a <video id=...">element.

int bark_view_set_video_rgba (bark_view_t *view, const char *id, const uint8_t *rgba, uint16_t w, uint16_t h)

Alias for bark_view_push_video_rgba().

int bark_view_push_video_source_rgba (bark_view_t *view, const char *source_key, const uint8_t *rgba, uint16_t w, uint16_t h)

Upload an RGBA8 frame to a named video source key shared across video slots.

void bark_view_clear_video_source (bark_view_t *view, const char *source_key)

Clear and release a named video source key.

void bark_view_set_video_source (bark_view_t *view, const char *id, const char *source_key)

Bind a <video id=...">elementtoanamedsourcekey(orNULLtoclear).

void bark_view_set_video_tex (bark_view_t *view, const char *id, uint32_t gl_tex, uint32_t w, uint32_t h)

Bind an existing OpenGL texture ID directly to a <video id=...">element.

void bark_view_clear_video (bark_view_t *view, const char *id)

Detach any video frame or source from <video id=...">.

void bark_view_scroll_bottom (bark_view_t *view, const char *id)

Scroll a scrollable container element (id) to its bottom edge.

void bark_view_mark_dirty (bark_view_t *view)

Mark the VDOM dirty so the next bark_view_sync() re-renders.

int bark_view_is_dirty (const bark_view_t *view)

Return non-zero if a re-render is pending.

void bark_view_resize (bark_view_t *view, int vw, int vh)

Resize the logical viewport (primarily for headless tests).

void bark_view_viewport_size (const bark_view_t *view, int *w_out, int *h_out)

Query the current logical viewport width and height.

int bark_view_poll_events (bark_view_t *view)

Poll OS window/input events; returns 0 when the user closes the window.

int bark_view_sync (bark_view_t *view)

Invoke the render callback (if dirty) and reconcile the VDOM diff.

void bark_view_render (bark_view_t *view)

Render the reconciled layout tree to the active OpenGL framebuffer.

void bark_view_present (bark_view_t *view, uint32_t clear_rgb, int target_fps)

Sync (if dirty), clear with clear_rgb, render, swap buffers, and pace to target_fps.

void bark_view_on_event (bark_view_t *view, bark_view_event_fn fn, void *user)

Register a raw input event interceptor invoked before VDOM event dispatch.

void bark_view_inject_event (bark_view_t *view, const bark_view_event_t *ev)

Inject a synthetic bark_view_event_t (useful in headless automated tests).

void bark_view_attach_input (bark_view_t *view)

Attach native window input callbacks to the VDOM dispatcher.

int bark_view_dispatch_root (bark_view_t *view, const char *event_name, void *user)

Dispatch a named event directly on the VDOM root node.

int bark_view_webgl_size (const bark_view_t *view, int *w_out, int *h_out)

Query pixel dimensions of the active <canvas> WebGL2 stage surface.

int bark_view_webgl_begin (bark_view_t *view)

Bind and prepare the <canvas> WebGL2 stage surface for custom 3D rendering.

void bark_view_webgl_end (bark_view_t *view)

Finish custom 3D rendering on the <canvas> stage surface.

void bark_view_term_write (bark_view_t *view, const char *data, size_t len)

Append ANSI-formatted terminal output bytes to an embedded #term widget.

int bark_view_term_line_count (const bark_view_t *view)

Return the number of rendered lines in the #term scrollback buffer.

const char * bark_view_term_line_text (const bark_view_t *view, int idx_from_bottom, char *buf, size_t cap)

Copy plain text of line idx_from_bottom from the #term widget into buf.

bud_node * bark_view_bud_root (const bark_view_t *view)

Return the last rendered root bud_node* tree (read-only inspection).

int bark_view_rect (const bark_view_t *view, const char *id, bark_rect_t *out)

Query the computed layout bounding box of element id. Returns 1 if found.

int bark_view_hit_has_id (const bark_view_t *view, int x, int y, const char *id)

Hit-test whether an element with id lies at viewport coordinates (x, y).

int bark_view_hit_has_class (const bark_view_t *view, int x, int y, const char *cls)

Hit-test whether an element with CSS class cls lies at (x, y).

int bark_view_hit_has_tag (const bark_view_t *view, int x, int y, const char *tag)

Hit-test whether an element with HTML tag tag lies at (x, y).

int bark_view_hit_ancestor_attr (const bark_view_t *view, int x, int y, const char *cls, const char *attr, char *out, size_t cap, bark_rect_t *rect_out)

Walk ancestors at (x, y) matching class cls and extract attribute attr and rect.

int bark_view_is_typing_focused (const bark_view_t *view)

Return non-zero when a text <input> or <textarea> currently has keyboard focus.

int bark_view_is_term_focused (const bark_view_t *view)

Return non-zero when the embedded #term widget currently has keyboard focus.

int bark_view_is_visible (const bark_view_t *view)

Return non-zero when the document / window is currently visible to the user.

Detailed Description

Bark reactive UI viewport, layout, input events, video slots, and asset loading.

Visual browser-like declarative UI host (libbud VDOM + CSS on native OpenGL or browser DOM).

Reconciles declarative libbud VDOM trees and CSS stylesheets into either a native desktop window (OpenGL/GLFW/liblamina), an offscreen headless layout engine for automated UI tests, or the live browser DOM in WASM.

Macro Definition Documentation

#define BARK_MOD_ALT 4

Alt/Option modifier bit.

#define BARK_MOD_CTRL 2

Control modifier bit.

#define BARK_MOD_META 8

Super/Command modifier bit.

#define BARK_MOD_SHIFT 1

Shift modifier bit.

#define BARK_MOUSE_LEFT 0

Primary mouse button.

#define BARK_MOUSE_MIDDLE 2

Middle mouse button.

#define BARK_MOUSE_RIGHT 1

Secondary mouse button.

Enumeration Type Documentation

enum bark_ev_type

Input and window event categories delivered to bark_view_event_fn.

Enumerator

BARK_EV_NONE
No event.
BARK_EV_RESIZE
Viewport resized.
BARK_EV_MOUSE_MOVE
Pointer moved.
BARK_EV_MOUSE_BTN
Mouse button pressed or released.
BARK_EV_SCROLL
Mouse wheel or trackpad scroll.
BARK_EV_KEY
Physical key press/repeat/release.
BARK_EV_CHAR
Unicode text character input.
BARK_EV_FILE_DROP
OS file dropped onto window.

Author

Generated automatically by Doxygen for Bark from the source code.