Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ All notable changes to **blenderui** (BUI). The format follows
moves or the text changes); Blender's own fields keep Blender's solid caret. The window wakes only for the next toggle, so an idle window still sleeps.

### Fixed
- **Lua bindings** set_menus on menubar fix; ctx:free() no-ops fix; widget tests
- **Browser-look text fields** take the CSS `color` and `font-size` the field itself is given (one that differs from its parent's); without them they keep Chrome's black 13.33px, as before.
- **Browser-look form controls** drew their text with Blender's UI drop shadow, which made it look heavy next to the page's text. They draw none now, as in a browser.
- **macOS:** the npm `bui-runtime` (and the release build of the addon) failed to link with `Undefined symbols: ___isPlatformVersionAtLeast`: the
Expand Down
204 changes: 139 additions & 65 deletions README.md

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions bindings/lua/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,39 @@ ctx:key("a", "a", 0)
`canvas`, `list`, `tree`, `gridview`, `ramp`, `curve`, `normal`, `histogram`,
`radio`, `meter`, `filebrowser`

## Menus

Menu items are plain tables, matching the Python binding's `MenuItem`:

```lua
mb = bui.Node("menubutton")
mb:set("text", "File")
mb:set_menus({
{text = "New", icon = "FILE_NEW", fn = new_file}, -- icon: name or id
{text = "Bold", checked = true, fn = toggle_bold}, -- checked/enabled: bool or number
{text = "Save", shortcut = "Ctrl S", enabled = false},
{text = "-"}, -- separator
{text = "Recent", sub = { -- submenu
{text = "doc1.blend", fn = open_recent},
}},
})

-- A menubar builds one menubutton child per top-level item (like Python's MenuBar)
bar = bui.Node("menubar")
bar:set_menus({
{text = "File", sub = {{text = "New", fn = new_file}, {text = "Quit", fn = quit}}},
{text = "Edit", sub = {{text = "Undo", fn = undo}}},
})

-- Popup menus from code
ctx:open_menu(owner, {{text = "Cut", fn = cut}}, "Edit", 120, 90)
ctx:open_pie({{text = "W", fn = w}, {text = "E", fn = e}}, "Direction")
```

`fn` callbacks live in the Lua registry for exactly as long as the kit holds a
copy of the item (menu button, open popup, search filter) — they are released
automatically when the items are replaced or the node/context is freed.

## Examples

```sh
Expand All @@ -105,4 +138,12 @@ ctx:key("a", "a", 0)
# collapsible panel, undo/redo,
# search/filter, export, metatable
# display, Ctrl+Z / Ctrl+Shift+Z)
./bui-lua bindings/lua/examples/ph_nutrients.lua # soil pH / nutrient availability chart
# (canvas-drawn pH scale, nutrient
# availability bands, two overlapping
# curves, redraws on window resize via
# EV_CONFIGURE, editable via number
# fields and sliders; a Table tab edits
# the same data as a Lua table — tree
# view, Apply, add/delete, undo/redo)
```
Loading
Loading