Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,5 +284,5 @@ jobs:
run: |
python bindings/rust/scripts/vendor_c.py
cd bindings/rust
cargo package -p blenderui-sys --allow-dirty
cargo package -p bui-a11y -p blenderui-sys --allow-dirty
ls -l target/package/*.crate
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
version="${TAG#v}"
for crate in blenderui-tailwind blenderui-macros blenderui-sys blenderui-paint blenderui-table blenderui-vlist blenderui blenderui-imgui; do
for crate in blenderui-tailwind blenderui-macros bui-a11y blenderui-sys blenderui-paint blenderui-table blenderui-vlist blenderui blenderui-imgui; do
# crates.io's API wants an identifying User-Agent (curl's default can be refused, which made
# this check fail and a re-run try to publish a crate that was already there)
if [ "$(curl -s -A 'bui-release-ci (https://github.com/ppmpreetham/BUI)' -o /dev/null -w '%{http_code}' "https://crates.io/api/v1/crates/$crate/$version")" = 200 ]; then
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ All notable changes to **blenderui** (BUI). The format follows
## [Unreleased]

### Added
- **Accessibility: screen readers see BUI apps on Windows, through [AccessKit](https://accesskit.dev).** The kit keeps one accessibility tree per window: its widgets add themselves (role, name, value, states, bounds; menus, tabs, enum, list and tree rows as items), and the Rust HTML engine adds the page under its canvas, with roles and names mapped as browsers map HTML and ARIA (HTML-AAM, accname: `aria-labelledby`, `aria-label`, `<label for>`, `alt` ...; `display:none`, `visibility:hidden` and `aria-hidden` left out). Readers' requests come back as real input: press, toggle, set a value, increment and decrement, expand and collapse, focus, context menu. The new `a11y/` crate (`bui-a11y`) is the only code that uses AccessKit: it validates the kit's flat nodes, sends only changed ones and runs UI Automation through the window's `WM_GETOBJECT`. Nothing is built until a reader asks, so apps nobody inspects pay nothing (`bench_frames`: no change). C API: `BK_a11y_set_subtree`, `BK_a11y_tree`, `BK_a11y_action`, `BK_ROLE_*`, `BK_A11Y_*` in `BUI_kit.h`; the `a11y` feature is on for Rust (and Node) and optional for the C kit's CMake build, where it needs cargo. `examples/a11y.rs` is a small app to try with Narrator. macOS and Linux are next.
- **Windows: a Direct3D 12 renderer, opt-in.** `Application::gpu_api(GpuApi::D3d12)` (C: `BUI_gpu_set_api`), `BUI_GPU_API=d3d12` or `bui build --gpu d3d12` start the GPU renderer on Direct3D 12; Direct3D 11 stays the default, and a device that can't start on 12 starts on 11. Both backends now share one core (`gpu/intern/gpu_device.c`) and fill a table of 15 device operations; the frames they draw are byte-identical. Direct3D 12 costs about 0.4 to 1 ms more CPU per presented frame here, so it is for apps that embed BUI in Direct3D 12 or profile it with Nsight's GPU Trace. `BUI_GPU_DEBUG=2` turns on the Direct3D 12 debug layer.
- **`bui` CLI: Windows releases as MSIX, and the Direct3D to start with.** `bui build app.jsx --msix` makes an MSIX package (the installable, Store-ready form of a Win32 app) instead of a bare `.exe`; `--gpu d3d11|d3d12` sets the Direct3D the GPU renderer starts with, stored in the executable. `bui package app.exe --msix` / `--gpu` releases any BUI executable the same way, so Rust and C apps get it too. The package takes `--name`, `--version`, `--display-name`, `--description`, `--publisher`, `--icon`, `--include` and `--cert` (unsigned without one: `Add-AppxPackage -AllowUnsigned` installs it); `makeappx` comes from the Windows SDK.
- **Windows: `BUI_GPU_ADAPTER=high-performance` renders on the discrete GPU.** Direct3D took the display's adapter, on a hybrid laptop the integrated GPU, where NVIDIA Nsight and other vendor profilers see nothing; this asks DXGI for the high-performance one (`EnumAdapterByGpuPreference`). The default stays the display's GPU, which uses less power.
- **Android: real apps in Rust.** `blenderui::android_main!(run)` writes the entry point the NativeActivity shell calls, so the app crate has no `unsafe`; before `run` it gives the activity's JNI handles to `ndk-context` (cpal and other crates that call into Java need them) and sends stdout, stderr and panics to logcat (tag `bui`). The kit points `HOME` at the app's files folder and `XDG_CACHE_HOME` / `TMPDIR` at its cache folder on attach (`dirs::cache_dir()` worked nowhere), and `BK_android_activity()` gives the `ANativeActivity *`. `build.py` takes `--label`, `--package` and `--permission` (repeatable: `INTERNET` for an app that goes online) and links the system libraries the Rust staticlib needs (rustc's `native-static-libs`, through `cargo rustc`, so dependencies don't build again): an app that plays sound through cpal links AAudio. Characters Roboto lacks come from the phone's Noto fonts (`/system/fonts`, `/product/fonts` in the font folders). SpotiTube's Android build is the first app that uses it.
- **Back on Android walks back through an app's screens.** `App::prevent_default()` in a key listener marks the key as taken (`BK_key_taken` in C, for any binding that sees raw key events): `BK_key` returns 1 and nothing else acts on it. Back is the key `Escape`, so a listener that closes a screen on it keeps the app open, and only a Back that nothing took finishes the activity.
- **WebAssembly frames copy twice as fast.** The kit's pixels become the canvas's RGBA bytes in a loop the compiler vectorizes: a 1280 x 800 redraw drops from about 10 ms to 5 ms under Node.js. `examples/wasm/bench.mjs` times it.
Expand Down Expand Up @@ -187,6 +191,7 @@ All notable changes to **blenderui** (BUI). The format follows
- Out-of-range `rgb()` channels clamp (`rgb(300 -20 0)` is red) instead of being gamut-mapped.
- `:nth-last-child(An+B of S)` counts the following siblings that match `S` (it saw none, since they aren't built when rules match; `S` may name the element's ancestors).
- `light-dark()`, the system colors (`Canvas`, `LinkText` ...) and `@media (prefers-color-scheme)` follow the theme's mode (they were always dark). Light mode uses a browser's light system colors. Windows re-render when the theme changes, with no `notify_all()` needed.
- **Windows: the system's maximize button maximizes again.** The kit took every press on a maximize button as the app's, so on a window with the system's title bar the press went to the app and Windows never maximized; only a title bar the app draws (`WindowDecorations::Client`) hands its maximize button's presses to the app now.
- **Android: the app runs again after Back.** The host's state (`g_quit`, the wake callback, keep-alive, the stop check) starts over on each `BK_android_attach`, so a relaunch in the same process is not a dead window; the activity is `singleTask`, so a second launch brings the running one back instead of attaching a second activity. `BK_android_detach` (new; `android_main` calls it before the glue frees the app) ends wakes from other threads, which used the freed looper. A Lua script that fails after opening its window shows its error (the error window came back NULL and crashed). A second finger joining a one-finger scroll no longer jumps it; `BK_window_timer` returns -1 (not 0) when the window's timers are full, as `BUI_kit.h` says; a failed window allocation returns NULL (the C demo checks it); a frame whose post fails is redrawn. `build.py` aligns the APK with `zipalign 4` (the libraries are deflated: `-P 16` aligned nothing and failed on build-tools 34) and builds a Rust app's crate with `--lib`.
- **WebAssembly: an unstyled canvas keeps its size after a zoom.** At a pixel ratio of 1 its CSS size was not pinned, so after a zoom or a move to a retina screen it grew on every frame; every resize now sizes the backing store and pins it. `build.py --serve` serves `.wasm` and `.js` with their web types on Windows (the override was set on a `functools.partial`, where it did nothing). The wasm workflow runs on changes to the kit, the GPU raster, core and blenderui too, and the smoke test's click check compares against the hovered button, so it can fail.
- **QuickJS (`bui run`, `bui build`, Android `--js`): timers set from promise jobs run.** A `setTimeout` made in a `.then` was missed (a headless app quit with it pending, a windowed one stalled until the next event); timers now run one task at a time with the promise jobs after each, as in HTML's event loop, and the next deadline is read after the last job. A pump that runs out of rounds with work left schedules the next one. `setTimeout(f, Infinity)` (or `NaN`, negative, past 2^31-1 ms) is a 0 ms delay, as in browsers, instead of panicking the runtime.
Expand Down
55 changes: 55 additions & 0 deletions a11y/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[package]
name = "bui-a11y"
description = "Screen-reader accessibility for the BUI kit: its flat node trees as AccessKit trees, and the platform adapters"
# a member of the Rust bindings' workspace: one version and lock with the crates that use it, and
# blenderui-sys can be packaged against it before it is on crates.io (`cargo package -p bui-a11y
# -p blenderui-sys`)
workspace = "../bindings/rust"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
homepage.workspace = true
authors.workspace = true
rust-version.workspace = true
# include/bui_a11y.h: the C declarations of the ABI (the kit includes it)
include = ["src/**", "include/**", "Cargo.toml"]

# An rlib for Rust programs (blenderui-sys links it with the kit); C builds of the kit run
# `cargo rustc --crate-type staticlib` (kit/CMakeLists.txt), so no staticlib is built here.
[lib]
path = "src/lib.rs"

[dependencies]
accesskit = "0.25"

[target.'cfg(windows)'.dependencies]
accesskit_windows = "0.35"

[lints.clippy]
all = { level = "warn", priority = -2 }
pedantic = { level = "warn", priority = -2 }
perf = { level = "warn", priority = -1 }
complexity = { level = "warn", priority = -1 }
inline_always = "allow"
unseparated_literal_suffix = "allow"
similar_names = "allow"
missing_panics_doc = "allow"
missing_errors_doc = "allow"
absolute_paths = "allow"
module_name_repetitions = "allow"
doc_markdown = "allow"
too_many_lines = "allow"
unused_self = "allow"
cast_possible_truncation = "allow"
cast_sign_loss = "allow"
cast_precision_loss = "allow"
unreadable_literal = "allow"
implicit_hasher = "allow"
significant_drop_tightening = "warn"
redundant_clone = "warn"
use_self = "warn"
redundant_else = "warn"
or_fun_call = "warn"
missing_const_for_fn = "warn"
derive_partial_eq_without_eq = "warn"
58 changes: 58 additions & 0 deletions a11y/include/bui_a11y.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* bui-a11y's C ABI (a11y/src/ffi.rs): the platform accessibility adapter of a native window, fed
* the kit's flat trees (BKA11yNode, BUI_kit.h) and turning them into AccessKit updates. Only the
* kit calls it (kit/intern/a11y and the window hosts).
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once

#include <stdint.h>

#include "BUI_kit.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct BuiA11y BuiA11y;

typedef struct BuiA11yHost {
void *data;
/* The whole tree now (a reader attached): the nodes, their count and the focused id, valid
* until the next call. Returns 0 when it has none. Called on the window's thread. */
int (*tree)(void *data, const BKA11yNode **r_nodes, int *r_count, uint64_t *r_focus);
/* A request waits for bui_a11y_take. Called from any thread. */
void (*wake)(void *data);
} BuiA11yHost;

/* bui_a11y_validate's results: 0 valid, else why not. */
enum {
BUI_A11Y_INVALID_ARRAY = 1,
BUI_A11Y_INVALID_ID,
BUI_A11Y_INVALID_PARENT,
BUI_A11Y_INVALID_ROLE,
BUI_A11Y_INVALID_FLAGS,
BUI_A11Y_INVALID_UTF8,
BUI_A11Y_INVALID_WIDGET,
};
/* `subtree`: a host's subtree (any number of top nodes, widgets allowed), else a whole tree (its
* root first, no widgets). */
int bui_a11y_validate(const BKA11yNode *nodes, int n, int subtree);

/* The adapter of a native window (HWND), NULL where this platform has none yet. */
BuiA11y *bui_a11y_new(void *window, const BuiA11yHost *host);
void bui_a11y_free(BuiA11y *a);
/* 1 once a reader asked for the tree: then send it after each change. */
int bui_a11y_active(const BuiA11y *a);
/* The tree as it is now (only what changed goes out): 0, or a BUI_A11Y_INVALID_* code. */
int bui_a11y_update(BuiA11y *a, const BKA11yNode *nodes, int n, uint64_t focus);
void bui_a11y_window_focus(BuiA11y *a, int focused);
/* The next request (its text valid until the next call): 1, or 0 when none waits. */
int bui_a11y_take(BuiA11y *a, BKA11yRequest *r_req);
#ifdef _WIN32
/* WM_GETOBJECT: 1 and *r_result when the adapter answers it, else 0 (DefWindowProc). */
int bui_a11y_wm_getobject(BuiA11y *a, uintptr_t wparam, intptr_t lparam, intptr_t *r_result);
#endif

#ifdef __cplusplus
}
#endif
Loading
Loading