Blender's GPU Accelerated UI, Decoupled from it's original codebase. Supports Rust, Python, JS, React, C & C++. Twice as good as GPUI
ime docs
Preetham Pemmasanid71ef9fcebe0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4a65702..4c805ae 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -6,6 +6,20 @@ All notable changes to **blenderui** (BUI). The format follows## [Unreleased]+### Added+- **Input methods (IME) on Windows**, ported from Blender (`GHOST_ImeWin32`, the text button's IME handling in+ `interface_handlers.cc` and its drawing in `interface_widgets.cc`). Chinese, Japanese and Korean input now+ works in text fields and text areas: the composition is drawn underlined at the caret (a thicker line under+ the clause being converted), the candidate window follows the caret instead of the top left corner of the+ window (issue #14), and the result is typed in like any other text. The IME is on only while a field is being+ edited, so shortcuts keep working with a CJK keyboard; number fields and password fields take no IME, as in+ Blender. A composition that is still going when another field takes over stays in the field it was in.+- **C API changes:** one platform independent IME API for every window host and binding: `BKImeEvent`,+ `BK_ime_event()`, `BKImeState`, `BK_ime_state()` and `BK_ime_composing()` (`BUI_kit.h`). Only the Win32 host+ uses it so far; X11 and Cocoa do nothing and are unchanged. `bench/ime_bench.c` measures what it costs+ (nothing measurable on the paths that did not change: keystroke + repaint 18.5 vs 18.4 us, idle frame 35 ns,+ the host's poll 7 ns).+### Changed- **README and website:** the FAQ says macOS has been tried by hand on two Apple Silicon Macs (it said nobodyhad checked), and a new FAQ entry and the roadmap list what people asked for: Vue and Angular (adaptersdiff --git a/README.md b/README.mdindex 4ed12a9..fa0b547 100644--- a/README.md+++ b/README.md@@ -1171,8 +1171,8 @@ Blender's:`gdi-text`): ClearType-style hinting and system fonts, without Slug.Limits worth knowing: no per-glyph font fallback yet (missing characters show-as boxes), no IME, right-to-left text is reordered but not shaped, no OpenType-features. Font fallback and IME are coming soon. More:+as boxes), IME on Windows only (X11 and macOS are coming), right-to-left text is+reordered but not shaped, no OpenType features. Font fallback is coming soon. More:[Text and fonts](https://bui.preetham.top/docs/concepts/text-and-fonts/).## 22. Themes: dark and light@@ -1845,8 +1845,8 @@ ship. The tables below have the details.software that has to be accessible. Accessibility is planned.- **Text.** Blender's bundled Inter font only (system fonts only with theWindows GDI option). No per-glyph font fallback (missing characters show as- boxes), no input methods (IME), right-to-left text is reordered but not- shaped, and no OpenType features.+ boxes), input methods (IME) on Windows only, right-to-left text is+ reordered but not shaped, and no OpenType features.- **It doesn't look native.** BUI looks like Blender: its Dark and Light themes(other Blender theme files can't be loaded yet). It doesn't follow youroperating system's theme, accent color or fonts.@@ -1897,7 +1897,7 @@ ship. The tables below have the details.| ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- || Qt syntax (~24%) | Model/view classes, docks, toolbars, splitters, Qt stylesheets ([details](docs/qt.md#coverage)) || CSS (261 of 745 W3C properties render, 129 more parse) | 3D transforms, OpenType font features, multi-column layout; hit testing ignores 2D transforms. Most of the remaining W3C list is drafts, speech, print and SVG ([breakdown](docs/rust.md#coverage)) |-| Text | No text wrapping around floats; right-to-left text is reordered (bidi) but not shaped (Arabic joining); no OpenType features; no per-glyph font fallback yet (characters missing from the font show as boxes); no IME |+| Text | No text wrapping around floats; right-to-left text is reordered (bidi) but not shaped (Arabic joining); no OpenType features; no per-glyph font fallback yet (characters missing from the font show as boxes); IME on Windows only || Rust components | No async resources (`use_resource`); no generic components || Dear ImGui | Python and safe Rust skip the `va_list`, `void*` and C-callback functions (reachable from C and the Rust FFI); with Blender widgets, window title bars, tooltips, plain popups, tables and the color picker keep ImGui's drawing || JavaScript / React packages | npm packages are prebuilt for Windows x64 only (on Linux, build the addon from source); events reach JavaScript after BUI handled them (no native `preventDefault`), and `event.target` is the deepest _listening_ element |@@ -1910,7 +1910,7 @@ ship. The tables below have the details.| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- || **WebAssembly** | The kit in the browser: the raster blits to `<canvas>`, DOM events feed the kit; `@blender-ui/react` and the DOM-like API on top, unchanged || **egui** | BUI panels inside egui, plus a Blender-styled theme |-| **More from Blender's source** | Per-glyph font fallback (BLF), IME, search-as-you-type popups, units in number fields, widget drag and drop |+| **More from Blender's source** | Per-glyph font fallback (BLF), IME on X11 and macOS, search-as-you-type popups, units in number fields, widget drag and drop || **macOS GPU and JavaScript windows** | The GPU renderer on Metal (or the OpenGL backend), and Node windows on the main thread || **More GPU backends** | Vulkan / WebGPU drawing the same instance stream as Direct3D 11 and OpenGL || **Accessibility** | Screen-reader support through UI Automation (Windows), AT-SPI (Linux) and NSAccessibility (macOS) |diff --git a/docs/c-api.md b/docs/c-api.mdindex c53eb0e..50c08c1 100644--- a/docs/c-api.md+++ b/docs/c-api.md@@ -77,7 +77,7 @@ int main(void)| **Nodes** | `BK_node_new(type)`, `BK_node_add(parent, child, index)`, `BK_node_remove`, `BK_node_child(_count)`, `BK_node_parent`, `BK_node_rect`, `BK_node_natural`, `BK_node_invalidate`, `BK_node_relayout`, `BK_node_free` || **Properties** | `BK_set_num / BK_set_str / BK_set_color / BK_set_strs` and `BK_get_*`, by name (`"value"`, `"text"`, `"label"`, `"min"`, `"items"`, `"enabled"` ...). `"set_value"` sets a value *and* notifies. || **Geometry** | `BK_geom_set_manager(node, BK_GEOM_PACK / GRID / PLACE)`, `BK_geom_set(node, key, v)` (`side`, `fill`, `expand`, `anchor`, `padx0`..., `row`, `column`, `sticky`, `x`, `relx`, `reqwidth` ...), `BK_frame_grid_weight`. Children of `frame` and `canvas` nodes. |-| **Context** | `BK_context_new(root)`: input state, popups, focus, undo. Input goes in with `BK_press`, `BK_release`, `BK_motion`, `BK_wheel`, `BK_key`, `BK_key_release`, `BK_button`, `BK_context_menu`; frames come out of `BK_render(ctx, raster, w, h, full)`, which returns the number of redrawn regions (0 means nothing changed). |+| **Context** | `BK_context_new(root)`: input state, popups, focus, undo. Input goes in with `BK_press`, `BK_release`, `BK_motion`, `BK_wheel`, `BK_key`, `BK_key_release`, `BK_button`, `BK_context_menu` (input methods: `BK_ime_event`, `BK_ime_state`, see below); frames come out of `BK_render(ctx, raster, w, h, full)`, which returns the number of redrawn regions (0 means nothing changed). || **Host** | `BKHost`: `request` (schedule a render), `set_cursor`, `warp`, clipboard, `schedule` (timers), `emit` (events). A `BKWindow` provides all of them. || **Events** | `emit(data, node, kind, ref, a, b)`. Kinds: `BK_EV_CHANGE`, `CLICK`, `CALL` (menu item or hotkey), `RENAME`, `ACTIVATE`, `TOGGLE`, `BROWSE`, `SUBMIT`. With the `"events"` property you also get raw `PRESS` / `RELEASE` / `DOUBLE` / `MOTION` / `ENTER` / `LEAVE` / `KEY` / `KEYRELEASE` / `WHEEL` / `CONFIGURE`, plus `VIEW` and `SCROLL` for scrolling. || **Windows** | `BK_window_new`, `show`, `close`, `set_title`, `set_size`, `wm(key, a, b)` (position, topmost, alpha, resizable, minsize, state ...), `timer`, `run`, `pump`, `quit` |diff --git a/website/src/components/landing/Coming.astro b/website/src/components/landing/Coming.astroindex fba0e00..796d0dd 100644--- a/website/src/components/landing/Coming.astro+++ b/website/src/components/landing/Coming.astro@@ -8,7 +8,7 @@ const items = [{ title: "egui", body: "BUI panels inside egui apps, plus a Blender-styled egui theme.", tag: "Planned" },{ title: "Vue and Angular", body: "Thin adapters over @blender-ui/native, the layer React and Svelte already share.", tag: "Planned" },{ title: "More languages", body: "Lua (a community pull request is in review), Ruby, Go through cgo, C#, Zig, Swift, Kotlin and MyGo over the same C header; Godot, Unity, Bevy and Flutter.", tag: "Planned" },- { title: "Font fallback and IME", body: "Per-glyph fallback (Blender's BLF), input methods, units in number fields and widget drag and drop.", tag: "Planned" },+ { title: "Font fallback and more IME", body: "Per-glyph fallback (Blender's BLF), input methods on X11 and macOS (Windows has them), units in number fields and widget drag and drop.", tag: "Planned" },{ title: "Vulkan and WebGPU", body: "More GPU backends drawing the same instance stream as Direct3D 11 and OpenGL.", tag: "Planned" },{ title: "More Qt", body: "Model/view classes, docks, toolbars, splitters and Qt stylesheets, on top of today's everyday subset.", tag: "In progress" },];diff --git a/website/src/content/docs/c/c-api.mdx b/website/src/content/docs/c/c-api.mdxindex f6ec5bf..ac5f68f 100644--- a/website/src/content/docs/c/c-api.mdx+++ b/website/src/content/docs/c/c-api.mdx@@ -188,6 +188,8 @@ A `BKWindow` fills in all of them except `emit`, which you keep. If you host the**Input goes in** through `BK_press`, `BK_release`, `BK_motion`, `BK_wheel`, `BK_scroll` (precise deltas), `BK_key`, `BK_key_release`, `BK_button` and `BK_context_menu`. Each returns non-zero when something changed.+**Input methods (IME)** follow Blender's model (`GHOST_ImeWin32`, `wmIMEData`). The IME is off until a text field or text area is being edited, so shortcuts keep working with a CJK keyboard. A window host forwards the platform's composition events with `BK_ime_event(ctx, BK_IME_COMPOSITION_START | BK_IME_COMPOSITION | BK_IME_COMPOSITION_END, &event)`, where `BKImeEvent` carries the committed `result`, the `composite` text still being composed, the IME `cursor_pos` and the `sel_start`/`sel_end` clause being converted. After each render it calls `BK_ime_state(ctx, &state)`, which returns non-zero only when the IME must be started, ended or moved (`state.enabled`, `state.restart`, `state.x`, `state.y` is where the candidate window goes). The kit draws the composition underlined at the caret and inserts the result like typed text. The Windows window host does all of this; an embedder with its own window can use the same two calls. Number fields and password fields take no IME.+**Frames come out** of `BK_render(ctx, raster, w, h, full)`. It redraws only damaged regions (unless `full`) and returns how many it redrew: 0 means nothing changed.## Eventsdiff --git a/website/src/content/docs/concepts/text-and-fonts.mdx b/website/src/content/docs/concepts/text-and-fonts.mdxindex 10048c0..ddb7b18 100644--- a/website/src/content/docs/concepts/text-and-fonts.mdx+++ b/website/src/content/docs/concepts/text-and-fonts.mdx@@ -104,13 +104,13 @@ On Windows, you can build BUI with Windows' own GDI text engine and system fonts## Limits worth knowing- **No per-glyph font fallback.** Characters that Inter (or the chosen face) doesn't have show as boxes. A family list in CSS picks one face per element; it doesn't mix faces within a line.-- **No IME.** Input methods for Chinese, Japanese and Korean aren't supported yet.+- **IME works on Windows only.** Input methods for Chinese, Japanese and Korean work in text fields and text areas on Windows, ported from Blender's GHOST (the candidate window follows the caret, the composition is drawn underlined at the caret). X11 and macOS aren't supported yet, and number fields and password fields take no IME, as in Blender.- **Right-to-left text** is reordered (bidi) but not shaped, so Arabic letters don't join.- **No OpenType features** (`font-feature-settings` and friends): the text engine doesn't shape, and Blender's doesn't either.- **Rust only:** text doesn't wrap around floats, and `text-align: justify` aligns left.-<ComingSoon feature="Per-glyph font fallback and IME">-Both are next on the list of things to port from Blender's source: BLF's fallback fonts, so missing characters find a face that has them, and input-method support.+<ComingSoon feature="Per-glyph font fallback and IME on X11 and macOS">+Both are next on the list of things to port from Blender's source: BLF's fallback fonts, so missing characters find a face that has them, and input methods for the X11 and Cocoa windows (they use the same kit API as Windows).</ComingSoon>## Troubleshootingdiff --git a/website/src/content/docs/project/limitations.mdx b/website/src/content/docs/project/limitations.mdxindex 5fd06a9..8ce5d2e 100644--- a/website/src/content/docs/project/limitations.mdx+++ b/website/src/content/docs/project/limitations.mdx@@ -16,7 +16,7 @@ BUI has **no accessibility support**. It draws its own widgets and doesn't talk- The font is Blender's Inter, embedded and drawn with FreeType. System fonts are used only with the Windows GDI text option.- There is no per-glyph font fallback yet, so a character the font doesn't have shows as a box.-- There are no input methods (IME): composed input such as Japanese or Chinese, and possibly dead-key accents, isn't expected to work.+- Input methods (IME) work on Windows only: composed input such as Japanese or Chinese works there, and isn't expected to work on Linux (X11) or macOS yet.- Right-to-left text is reordered but not shaped (Arabic joining), and there are no OpenType features.More in [Text and fonts](../../concepts/text-and-fonts/).diff --git a/website/src/content/docs/project/roadmap.mdx b/website/src/content/docs/project/roadmap.mdxindex c053727..bdc39e3 100644--- a/website/src/content/docs/project/roadmap.mdx+++ b/website/src/content/docs/project/roadmap.mdx@@ -34,7 +34,7 @@ Each row has a status: **Works** when it works and is tested, **Partial** when crows={[["Qt syntax", "partial", "About 25% of Qt's methods on the main widget classes. Missing: model/view classes, docks, toolbars, splitters, Qt stylesheets"],["CSS (Rust, JavaScript)", "partial", "261 of 745 W3C properties render and 129 more parse. Missing: 3D transforms, OpenType font features, multi-column layout"],- ["Text", "partial", "No text wrapping around floats; right-to-left text is reordered but not shaped; no per-glyph font fallback yet; no IME"],+ ["Text", "partial", "No text wrapping around floats; right-to-left text is reordered but not shaped; no per-glyph font fallback yet; IME on Windows only"],["Rust components", "partial", "No async resources (<code>use_resource</code>) and no generic components yet"],["Dear ImGui", "partial", "Python and safe Rust skip the <code>va_list</code>, <code>void*</code> and C-callback functions; in the Blender-widgets build, title bars, tooltips, plain popups, tables and the color picker keep ImGui's drawing"],["npm packages", "partial", "Prebuilt for Windows x64 only; on Linux, build the addon from source"],@@ -48,7 +48,7 @@ Each row has a status: **Works** when it works and is tested, **Partial** when crows={[["WebAssembly", "planned", "The kit in the browser: the raster blits to a <code><canvas></code>, DOM events feed the kit, and the React and DOM-like APIs run on top, unchanged"],["egui", "planned", "BUI panels inside egui, plus a Blender-styled theme"],- ["More from Blender's source", "planned", "Per-glyph font fallback (BLF), IME, search-as-you-type popups, units in number fields, widget drag and drop"],+ ["More from Blender's source", "planned", "Per-glyph font fallback (BLF), IME on X11 and macOS, search-as-you-type popups, units in number fields, widget drag and drop"],["macOS GPU and JavaScript windows", "planned", "The GPU renderer on Metal (or the OpenGL backend), and Node windows on the main thread"],["More GPU backends", "planned", "Vulkan and WebGPU, drawing the same instance stream as Direct3D 11 and OpenGL"],["Accessibility", "planned", "Screen-reader support through UI Automation (Windows), AT-SPI (Linux) and NSAccessibility (macOS)"],