Add SDK.md for NeoUI C/C++/Yabasic SDK and update documentation
This commit is contained in:
1 parent
c8b90640fb
commit
4264877868
5 files changed
+544
-6
No files matched your search
@@ -43,4 +43,4 @@ All cross-compilation scripts run inside rootless Docker (`alpine:3.24` `armv7`
|
|||||||
- **No Emojis**: Never use emojis in source code, UI strings, logs, or commit messages (use Nerd Font PUA codepoints defined in `phone_data.h` / `dmenu.c` for UI icons).
|
- **No Emojis**: Never use emojis in source code, UI strings, logs, or commit messages (use Nerd Font PUA codepoints defined in `phone_data.h` / `dmenu.c` for UI icons).
|
||||||
- **Unified Theming**: Never hardcode UI colors or font sizes in `dwm`, `dmenu`, `st`, or any DWM plugin. Read colors and proportional font sizes from `PluginTheme` (`src/dwm-plugins/theme.h`) / `.Xresources` (`theme.*`), and handle `RELOAD_THEME` on the plugin FIFO.
|
- **Unified Theming**: Never hardcode UI colors or font sizes in `dwm`, `dmenu`, `st`, or any DWM plugin. Read colors and proportional font sizes from `PluginTheme` (`src/dwm-plugins/theme.h`) / `.Xresources` (`theme.*`), and handle `RELOAD_THEME` on the plugin FIFO.
|
||||||
- **Zero-Lag Plugin Model**: Phone UI apps must run as preloaded resident daemons (`--preload`) guarded by `/tmp/dwm_plugin_<name>.lock`, sleeping at 0% CPU on `poll()` over `ConnectionNumber(dpy)` and `/tmp/dwm_plugin_<name>.fifo`, and rendering into an offscreen `Pixmap` (`240x296` at `X=0, Y=24`) copied with `XCopyArea` to prevent flicker.
|
- **Zero-Lag Plugin Model**: Phone UI apps must run as preloaded resident daemons (`--preload`) guarded by `/tmp/dwm_plugin_<name>.lock`, sleeping at 0% CPU on `poll()` over `ConnectionNumber(dpy)` and `/tmp/dwm_plugin_<name>.fifo`, and rendering into an offscreen `Pixmap` (`240x296` at `X=0, Y=24`) copied with `XCopyArea` to prevent flicker.
|
||||||
- **Documentation**: Keep `README.md` and `MANUAL.md` synchronized with any new user-facing features or keybindings, and do not leave third-party `.md` files inside `src/` or `edl/`.
|
- **Documentation**: Keep `README.md`, `MANUAL.md`, and `SDK.md` synchronized with any new user-facing features, SDK functions, or keybindings, and do not leave third-party `.md` files inside `src/` or `edl/`.
|
||||||
+9
-1
@@ -23,7 +23,15 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
|
|||||||
- **Preinstalled scripting, calculation tools, and File Manager (`xfiles`) integration**:
|
- **Preinstalled scripting, calculation tools, and File Manager (`xfiles`) integration**:
|
||||||
- Added **Lua** (`lua5.5` and `lua5.4` with `/usr/bin/lua` and `/usr/bin/luac`), **GNU `bc` / `dc`**, and **Yabasic (`yabasic`)** to the default system image.
|
- Added **Lua** (`lua5.5` and `lua5.4` with `/usr/bin/lua` and `/usr/bin/luac`), **GNU `bc` / `dc`**, and **Yabasic (`yabasic`)** to the default system image.
|
||||||
- Selecting any `.yab` file in **File Manager (`xfiles`)** (or choosing **Run in Yabasic (Terminal)** in its Actions menu) runs `yabasic` inside the `st` terminal and pauses on exit so output can be inspected.
|
- Selecting any `.yab` file in **File Manager (`xfiles`)** (or choosing **Run in Yabasic (Terminal)** in its Actions menu) runs `yabasic` inside the `st` terminal and pauses on exit so output can be inspected.
|
||||||
- Added an **integrated GUI Text Editor (`Edit in Text Editor`)** inside `xfiles`, available as an action on any file (and automatically opened when creating a **New File** or pressing **Edit** in the text viewer), featuring line numbers, 2D cursor navigation, 5 multi-tap input modes (`[abc]`, `[Abc]`, `[ABC]`, `[123]`, `[Sym]`), live candidate bar, and an **Editor Menu** (`Save File`, `Save & Close`, `Insert New Line`, `Insert Space`, `Duplicate Line`, `Delete Line`, `Close Without Saving`).
|
- Added an **integrated GUI Text Editor (`Edit in Text Editor`)** inside `xfiles`, available as an action on any file (and automatically opened when creating a **New File** or pressing **Edit** in the text viewer), featuring line numbers, 2D cursor navigation, 5 multi-tap input modes (`[abc]`, `[Abc]`, `[ABC]`, `[123]`, `[Sym]`), a scrolling bottom candidate bar for long symbol tables (`1` key), and an **Editor Menu** (`Save File`, `Save & Close`, `Insert New Line`, `Insert Space`, `Duplicate Line`, `Delete Line`, `Close Without Saving`).
|
||||||
|
- **NeoUI `240x320` UI SDK (`libneoui.so` + `/usr/include/neoui.h` + `neoui.yab`)**:
|
||||||
|
- Standardized all Bananarchy `240x320` X11/Xft/Pango UI components, `.Xresources` / `~/.xthemes/*.xth` live theme resolution, offscreen `Pixmap` double-buffering, FIFO IPC, softkey chord detection (`xdrawer`), and multi-tap input into a shared library (`/usr/lib/libneoui.so`) and header (`/usr/include/neoui.h`) with both C++20 classes and a C-compatible FFI (`neoui_*`).
|
||||||
|
- Migrated all 14 custom GUI plugins (`xdrawer`, `dialer`, `calllog`, `callscreen`, `contacts`, `sms`, `files`, `camera`, `themes`, `modem`, `networks`, `ringtones`, `wallpapers`, `music`) to use `NeoUI`.
|
||||||
|
- Added a complete Yabasic native C FFI wrapper (`~/Projects/neoui.yab`, symlinked at `/usr/lib/neoui.yab`), an interactive 3-tab showcase program (`~/Projects/neoui_demo.yab`), and full SDK documentation in `SDK.md`.
|
||||||
|
- **Camera viewfinder and capture orientation fix (`xcamera` and `bananarchy-photo`)**:
|
||||||
|
- Rotated the raw `800x600` `GC2395` sensor frames 90 degrees clockwise in both the live `240x180` 4:3 viewfinder (`downscaleViewfinder800x600To240x180`) and captured JPEG photos (`600x800` portrait output in `xcamera` and `bananarchy-photo`).
|
||||||
|
- **Menu refinements**:
|
||||||
|
- Removed the non-applicable `Toggle Bar` entry from the `Config` menu.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ This manual covers flashing, operating, and customizing **Bananarchy Linux** (`2
|
|||||||
- **Patched `dwm`** provides a `240x320` vertical bottom-stack (`bstack`) layout, a 24px top status bar, a transparent `"Menu"` / `"Names"` desktop softkey bar, a Conky desktop clock and status widget (which refreshes automatically when changing time, timezone, or wallpaper, or when logging out), and `< 2 ms` handling of physical slider (`SW_LID`) and wake keys.
|
- **Patched `dwm`** provides a `240x320` vertical bottom-stack (`bstack`) layout, a 24px top status bar, a transparent `"Menu"` / `"Names"` desktop softkey bar, a Conky desktop clock and status widget (which refreshes automatically when changing time, timezone, or wallpaper, or when logging out), and `< 2 ms` handling of physical slider (`SW_LID`) and wake keys.
|
||||||
2. **Preloaded resident DWM plugins (`< 2 ms` wakeup)**:
|
2. **Preloaded resident DWM plugins (`< 2 ms` wakeup)**:
|
||||||
- Core phone applications (`dmenu`, `xdrawer`, `dialer`, `calllog`, `callscreen`, `contacts`, `sms`, `files`, `camera`, `themes`, `modem`, `networks`, `ringtones`, `wallpapers`, `music`) run as preloaded resident daemons (`dwm-plugin <name> --preload`) that sleep at 0% CPU and open instantaneously over FIFO/socket IPC.
|
- Core phone applications (`dmenu`, `xdrawer`, `dialer`, `calllog`, `callscreen`, `contacts`, `sms`, `files`, `camera`, `themes`, `modem`, `networks`, `ringtones`, `wallpapers`, `music`) run as preloaded resident daemons (`dwm-plugin <name> --preload`) that sleep at 0% CPU and open instantaneously over FIFO/socket IPC.
|
||||||
- All UI elements share the **NeoUI SDK (`libneoui.so` + `/usr/include/neoui.h`)** and a single **XRDB theming engine** (`~/.xthemes/*.xth` -> `~/.Xresources`) with 20 preinstalled color schemes, proportional font sizing (`theme.baseFontSize`), and live reload without restarting X11. NeoUI exposes both C++20 classes and a C-compatible FFI (`neoui_*`) for building custom native or scripted (`yabasic`, etc.) `240x320` GUI applications.
|
- All UI elements share the **NeoUI SDK (`libneoui.so` + `/usr/include/neoui.h`)** and a single **XRDB theming engine** (`~/.xthemes/*.xth` -> `~/.Xresources`) with 20 preinstalled color schemes, proportional font sizing (`theme.baseFontSize`), and live reload without restarting X11. NeoUI exposes both C++20 classes and a C-compatible FFI (`neoui_*`) for building custom native or scripted (`yabasic` via `~/Projects/neoui.yab`, etc.) `240x320` GUI applications — see [SDK.md](./SDK.md) for the complete API reference and examples.
|
||||||
3. **First-class terminal (`st`) and 6-mode `fcitx5-t9` keypad input**:
|
3. **First-class terminal (`st`) and 6-mode `fcitx5-t9` keypad input**:
|
||||||
- `st` is patched with HarfBuzz OpenType ligature shaping (`Fira Code` default) and live `.Xresources` reload.
|
- `st` is patched with HarfBuzz OpenType ligature shaping (`Fira Code` default) and live `.Xresources` reload.
|
||||||
- `fcitx5-t9` provides 6 keypad input modes (`abc`, `Abc`, `ABC`, `Sym`, `Ctl`, `123` + `*` long-press `Ctrl+` latch) in a fixed bottom candidate bar (`Y = 290, H = 30`).
|
- `fcitx5-t9` provides 6 keypad input modes (`abc`, `Abc`, `ABC`, `Sym`, `Ctl`, `123` + `*` long-press `Ctrl+` latch) in a fixed bottom candidate bar (`Y = 290, H = 30`).
|
||||||
@@ -349,7 +349,7 @@ The `msm8905-cam` kernel module drives the rear 2MP GalaxyCore `GC2395` sensor t
|
|||||||
--stream-mmap --stream-count=1 --stream-to=/tmp/frame.rgb && \
|
--stream-mmap --stream-count=1 --stream-to=/tmp/frame.rgb && \
|
||||||
ffmpeg -hide_banner -loglevel error \
|
ffmpeg -hide_banner -loglevel error \
|
||||||
-f rawvideo -pixel_format rgb24 -video_size 800x600 \
|
-f rawvideo -pixel_format rgb24 -video_size 800x600 \
|
||||||
-i /tmp/frame.rgb -frames:v 1 -y ~/photo.jpg && \
|
-i /tmp/frame.rgb -vf "transpose=1" -frames:v 1 -y ~/photo.jpg && \
|
||||||
rm -f /tmp/frame.rgb
|
rm -f /tmp/frame.rgb
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
|
|
||||||
**Bananarchy** is a keypad-first Linux distribution hardforked from postmarketOS (`v26.06` / Alpine `edge` `armv7`), built for **Qualcomm MSM8905 (Snapdragon 205)** and **Qualcomm MSM8909 (Snapdragon 210)** smart feature phones with **240x320 QVGA non-touch displays** and **physical 12-key T9 keypads**.
|
**Bananarchy** is a keypad-first Linux distribution hardforked from postmarketOS (`v26.06` / Alpine `edge` `armv7`), built for **Qualcomm MSM8905 (Snapdragon 205)** and **Qualcomm MSM8909 (Snapdragon 210)** smart feature phones with **240x320 QVGA non-touch displays** and **physical 12-key T9 keypads**.
|
||||||
|
|
||||||
- **Current public release**: `a1025` (codenamed `argonaut`) — see the [changelog](./CHANGELOG.md) for release notes.
|
- **Current public release**: `a1026` — see the [changelog](./CHANGELOG.md) for release notes.
|
||||||
- **Download the recent images for your device from this link**: https://cloud.disroot.org/s/dB7bM7sRTScetDJ
|
- **Download the recent images for your device from this link**: https://cloud.disroot.org/s/dB7bM7sRTScetDJ
|
||||||
- **Project philosophy**: read [The Bananarchy Manifesto](./MANIFESTO.md) for the background and goals behind the distribution.
|
- **Project philosophy**: read [The Bananarchy Manifesto](./MANIFESTO.md) for the background and goals behind the distribution.
|
||||||
- **User and flashing guide**: see the [user manual](./MANUAL.md) for installation, keypad navigation, and hardware details.
|
- **User and flashing guide**: see the [user manual](./MANUAL.md) for installation, keypad navigation, and hardware details.
|
||||||
|
- **UI SDK reference**: see the [NeoUI SDK guide](./SDK.md) for building native C, C++, and Yabasic `240x320` GUI applications.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ Instead of spawning slow shell scripts for everyday phone tasks, Bananarchy runs
|
|||||||
- **6-mode `fcitx5-t9` keypad input**: press `#` to cycle between `abc`, `Abc`, `ABC`, `Sym` (all 32 ASCII punctuation symbols), `Ctl` (`Ctrl` sequences, arrows, `PageUp`/`PageDown`, `F1`–`F12`), and `123` numeric modes with a fixed bottom candidate bar.
|
- **6-mode `fcitx5-t9` keypad input**: press `#` to cycle between `abc`, `Abc`, `ABC`, `Sym` (all 32 ASCII punctuation symbols), `Ctl` (`Ctrl` sequences, arrows, `PageUp`/`PageDown`, `F1`–`F12`), and `123` numeric modes with a fixed bottom candidate bar.
|
||||||
- **First-class Linux terminal (`st`)**: patched with HarfBuzz OpenType ligatures (`Fira Code` as the default system and terminal font), XIM T9 input, and live theme reloading.
|
- **First-class Linux terminal (`st`)**: patched with HarfBuzz OpenType ligatures (`Fira Code` as the default system and terminal font), XIM T9 input, and live theme reloading.
|
||||||
- **On-device development, scripting, and gaming**: preinstalled `gcc`/`g++`, `make`, `git`, GNU `coreutils`, GNU `bc`/`dc`, `nano`, `ed`, `sqlite3`, `lua` (`5.5` and `5.4`), `yabasic`, `perl`, `tcl`, the [Janet](https://janet-lang.org/) language and `jpm`, the [Bantam](https://bantam.luxferre.top/) coding agent, `frotz` (interactive fiction), standalone X11 keypad games (`Snake` and `Tetris`), and a full-featured Gambatte-based Game Boy / Game Boy Color emulator (`gambatte` / `gbemu`) with readjustable keypad controls (`B=8`, `Turbo B=5`, `A=9`, `Turbo A=6`, `D-pad`, `Start=2`, `Select=3`, `Palette=*`), 10 color palettes, save states, and File Manager `.gb`/`.gbc` integration.
|
- **On-device development, scripting, and gaming**: preinstalled `gcc`/`g++`, `make`, `git`, GNU `coreutils`, GNU `bc`/`dc`, `nano`, `ed`, `sqlite3`, `lua` (`5.5` and `5.4`), `yabasic`, `perl`, `tcl`, the [Janet](https://janet-lang.org/) language and `jpm`, the [Bantam](https://bantam.luxferre.top/) coding agent, `frotz` (interactive fiction), standalone X11 keypad games (`Snake` and `Tetris`), and a full-featured Gambatte-based Game Boy / Game Boy Color emulator (`gambatte` / `gbemu`) with readjustable keypad controls (`B=8`, `Turbo B=5`, `A=9`, `Turbo A=6`, `D-pad`, `Start=2`, `Select=3`, `Palette=*`), 10 color palettes, save states, and File Manager `.gb`/`.gbc` integration.
|
||||||
- **NeoUI 240x320 UI SDK (`libneoui.so` + `/usr/include/neoui.h`)**: unified C-compatible FFI and C++20 UI SDK wrapping Xlib, Xft, Pango, `libjpeg`/`libpng`, `.Xresources` / `~/.xthemes/*.xth` live theme resolution, offscreen `Pixmap` double buffering, standardized OS shell widgets (headers, tabs, softkey bars, list/toggle/slider rows, input boxes, progress bars, scrollbars, modals, popup menus, and toasts), keypad/softkey chord handling, and multi-tap text entry—usable from C, C++, or any FFI-capable scripting language such as Yabasic (`frnfn_call` / `frnfn_call$`).
|
- **NeoUI 240x320 UI SDK (`libneoui.so` + `/usr/include/neoui.h` + `neoui.yab`)**: unified C-compatible FFI and C++20 UI SDK wrapping Xlib, Xft, Pango, `libjpeg`/`libpng`, `.Xresources` / `~/.xthemes/*.xth` live theme resolution, offscreen `Pixmap` double buffering, standardized OS shell widgets (headers, tabs, softkey bars, list/toggle/slider rows, input boxes, progress bars, scrollbars, modals, popup menus, and toasts), keypad/softkey chord handling, and multi-tap text entry—usable from C, C++, or Yabasic (`~/Projects/neoui.yab` and `~/Projects/neoui_demo.yab`). See [SDK.md](./SDK.md) for full documentation.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ bananarchy/
|
|||||||
├── CHANGELOG.md # Public release build history
|
├── CHANGELOG.md # Public release build history
|
||||||
├── MANIFESTO.md # The Bananarchy Manifesto
|
├── MANIFESTO.md # The Bananarchy Manifesto
|
||||||
├── MANUAL.md # Complete flashing, keypad, plugin, T9, camera, and modem manual
|
├── MANUAL.md # Complete flashing, keypad, plugin, T9, camera, and modem manual
|
||||||
|
├── SDK.md # NeoUI 240x320 UI SDK reference for C, C++, and Yabasic
|
||||||
├── flash-edl.sh # Automated USB EDL flasher wrapper (sudo + ModemManager handling)
|
├── flash-edl.sh # Automated USB EDL flasher wrapper (sudo + ModemManager handling)
|
||||||
├── flash-edl.py # Multi-device Qualcomm Sahara/Firehose EDL flasher
|
├── flash-edl.py # Multi-device Qualcomm Sahara/Firehose EDL flasher
|
||||||
├── rebuild-image.sh # Builds boot.img and partitioned MBR .img
|
├── rebuild-image.sh # Builds boot.img and partitioned MBR .img
|
||||||
|
|||||||
@@ -0,0 +1,528 @@
|
|||||||
|
# Bananarchy NeoUI SDK Reference (`SDK.md`)
|
||||||
|
|
||||||
|
**NeoUI** (`libneoui.so` + `/usr/include/neoui.h`) is the native `240x320` QVGA graphical user interface SDK for **Bananarchy Linux**.
|
||||||
|
|
||||||
|
It encapsulates all low-level X11 (`Xlib`), `Xft`, `Pango`, `libjpeg-turbo`, `libpng`, `.Xresources` / `~/.xthemes/*.xth` live theme resolution, offscreen `Pixmap` double-buffering, standardized OS shell widgets, FIFO IPC, softkey chord handling (`Left+Right` softkey -> `xdrawer`), and multi-tap T9 keypad input behind:
|
||||||
|
1. A **C-compatible FFI (`neoui_*`)** designed for both C programs and foreign-function interfaces (such as **Yabasic** `frnfn_call` / `frnfn_call$`, LuaJIT FFI, Janet, Python `ctypes`, etc.).
|
||||||
|
2. A **C++20 SDK (`namespace bananarchy`)** providing `ThemeSpec`, `PluginTheme`, `NeoWindow`, and direct Pango/Xft/image helpers used across all 14 built-in Bananarchy DWM plugins.
|
||||||
|
3. A **Yabasic wrapper library (`neoui.yab`)** preinstalled in `/home/user/Projects/neoui.yab` (and symlinked at `/usr/lib/neoui.yab`), paired with a full showcase application (`/home/user/Projects/neoui_demo.yab`).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Architecture & Files
|
||||||
|
|
||||||
|
| Path on Target Device | Source in Repository | Description |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| `/usr/lib/libneoui.so` | `src/neoui/neoui.cpp` | Shared library (`armv7` hard-float) implementing the C FFI and C++20 SDK |
|
||||||
|
| `/usr/include/neoui.h` | `src/neoui/neoui.h` | Unified C99 and C++20 header file |
|
||||||
|
| `/home/user/Projects/neoui.yab` | `overlay/rootfs/home/user/Projects/neoui.yab` | Yabasic native C FFI wrapper module (`import neoui`) |
|
||||||
|
| `/usr/lib/neoui.yab` | `overlay/rootfs/usr/lib/neoui.yab` | Symlink to `/home/user/Projects/neoui.yab` so `import neoui` works from any working directory |
|
||||||
|
| `/home/user/Projects/neoui_demo.yab` | `overlay/rootfs/home/user/Projects/neoui_demo.yab` | Interactive 3-tab Yabasic showcase demonstrating all NeoUI widgets, multi-tap input, custom drawing, modals, and live theme reload |
|
||||||
|
|
||||||
|
### Key Design Principles
|
||||||
|
- **Zero-Flicker Offscreen Double Buffering**: Every NeoUI window (`240x296` at `X=0, Y=24`, directly below the 24px `dwm` top status bar) renders into an offscreen X11 `Pixmap` during `neoui_begin_frame()` .. `neoui_end_frame()` and copies the completed frame to the visible window in a single `XCopyArea` call.
|
||||||
|
- **Automatic `.Xresources` / `.xth` Theme Resolution**: NeoUI automatically parses the active theme from X11 `RESOURCE_MANAGER` and `~/.Xresources`, derives 29 semantic color tokens and 4 proportional Pango font sizes (`Small`, `Main`, `Icon`, `Large` scaled from `theme.baseFontSize`), and hot-reloads on the fly whenever `RELOAD_THEME` arrives on `/tmp/dwm_plugin_<app_name>.fifo` or `.Xresources` changes on disk.
|
||||||
|
- **FFI-Safe Return Types**: Every `extern "C"` function in `neoui.h` returns `int` (`int32`), `uint32_t` (`uint32`), or `const char*` (`string`)—never `void`—so FFI callers like Yabasic's `frnfn_call` work without `void`-return restrictions.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Constants & Enumerations
|
||||||
|
|
||||||
|
### 2.1 Screen Geometry (`NeoGeometry`)
|
||||||
|
| C Constant | Yabasic Constant | Value | Meaning |
|
||||||
|
| :--- | :--- | :--- | :--- |
|
||||||
|
| `NEO_SCREEN_W` | `neoui.SCREEN_W` | `240` | Full physical display width in pixels |
|
||||||
|
| `NEO_SCREEN_H` | `neoui.SCREEN_H` | `320` | Full physical display height in pixels |
|
||||||
|
| `NEO_TOPBAR_H` | `neoui.TOPBAR_H` | `24` | Height of the `dwm` top status bar |
|
||||||
|
| `NEO_WIN_X` | `neoui.WIN_X` | `0` | Default app window X coordinate |
|
||||||
|
| `NEO_WIN_Y` | `neoui.WIN_Y` | `24` | Default app window Y coordinate (below top bar) |
|
||||||
|
| `NEO_WIN_W` | `neoui.WIN_W` | `240` | Default app window width |
|
||||||
|
| `NEO_WIN_H` | `neoui.WIN_H` | `296` | Default app window height (`320 - 24`) |
|
||||||
|
| `NEO_HEADER_H` | `neoui.HEADER_H` | `34` | Standard NeoUI header height |
|
||||||
|
| `NEO_SOFTBAR_H` | `neoui.SOFTBAR_H` | `26` | Standard bottom softkey bar height |
|
||||||
|
|
||||||
|
### 2.2 Theme Color Token IDs (`NeoColorId` for `neoui_color(color_id)`)
|
||||||
|
| ID | C Constant | Yabasic Constant | Description |
|
||||||
|
| :--- | :--- | :--- | :--- |
|
||||||
|
| `0` | `NEO_COLOR_BG_MAIN` | `neoui.COLOR_BG_MAIN` | Primary window background |
|
||||||
|
| `1` | `NEO_COLOR_BG_BAR` | `neoui.COLOR_BG_BAR` | Top status bar background |
|
||||||
|
| `2` | `NEO_COLOR_BG_HEADER` | `neoui.COLOR_BG_HEADER` | App header / tab bar background |
|
||||||
|
| `3` | `NEO_COLOR_BG_FOOTER` | `neoui.COLOR_BG_FOOTER` | Bottom softkey bar background |
|
||||||
|
| `4` | `NEO_COLOR_BG_OVERLAY` | `neoui.COLOR_BG_OVERLAY` | Modal / popup overlay background |
|
||||||
|
| `5` | `NEO_COLOR_BG_ALT_EVEN` | `neoui.COLOR_BG_ALT_EVEN` | Alternating list row background (even) |
|
||||||
|
| `6` | `NEO_COLOR_BG_ALT_ODD` | `neoui.COLOR_BG_ALT_ODD` | Alternating list row background (odd) |
|
||||||
|
| `7` | `NEO_COLOR_BG_INPUT` | `neoui.COLOR_BG_INPUT` | Unfocused input box / slider track background |
|
||||||
|
| `8` | `NEO_COLOR_BG_INPUT_FOCUS` | `neoui.COLOR_BG_INPUT_FOCUS` | Focused input box / active pill background |
|
||||||
|
| `9` | `NEO_COLOR_BG_BUTTON` | `neoui.COLOR_BG_BUTTON` | Unselected button background |
|
||||||
|
| `10` | `NEO_COLOR_BG_SEARCH` | `neoui.COLOR_BG_SEARCH` | Search bar / candidate bar background |
|
||||||
|
| `11` | `NEO_COLOR_BG_BUBBLE_IN` | `neoui.COLOR_BG_BUBBLE_IN` | Incoming message bubble background |
|
||||||
|
| `12` | `NEO_COLOR_BG_BUBBLE_OUT` | `neoui.COLOR_BG_BUBBLE_OUT` | Outgoing message bubble background |
|
||||||
|
| `13` | `NEO_COLOR_BG_TOAST` | `neoui.COLOR_BG_TOAST` | Toast banner background |
|
||||||
|
| `14` | `NEO_COLOR_FG_MAIN` | `neoui.COLOR_FG_MAIN` | Primary foreground text color |
|
||||||
|
| `15` | `NEO_COLOR_FG_BRIGHT` | `neoui.COLOR_FG_BRIGHT` | High-contrast bright foreground color |
|
||||||
|
| `16` | `NEO_COLOR_FG_MUTED` | `neoui.COLOR_FG_MUTED` | Muted / secondary subtitle color |
|
||||||
|
| `17` | `NEO_COLOR_SEL_BG` | `neoui.COLOR_SEL_BG` | Selected row / button background |
|
||||||
|
| `18` | `NEO_COLOR_SEL_FG` | `neoui.COLOR_SEL_FG` | Selected row / button foreground |
|
||||||
|
| `19` | `NEO_COLOR_ACCENT` | `neoui.COLOR_ACCENT` | Primary theme accent color |
|
||||||
|
| `20` | `NEO_COLOR_ACCENT_ALT` | `neoui.COLOR_ACCENT_ALT` | Secondary accent shade |
|
||||||
|
| `21` | `NEO_COLOR_HIGHLIGHT` | `neoui.COLOR_HIGHLIGHT` | Bright highlight color |
|
||||||
|
| `22` | `NEO_COLOR_BORDER` | `neoui.COLOR_BORDER` | Box / widget border color |
|
||||||
|
| `23` | `NEO_COLOR_DIVIDER` | `neoui.COLOR_DIVIDER` | Divider line / scrollbar thumb color |
|
||||||
|
| `24` | `NEO_COLOR_SUCCESS` | `neoui.COLOR_SUCCESS` | Semantic green (success / active / call) |
|
||||||
|
| `25` | `NEO_COLOR_INFO` | `neoui.COLOR_INFO` | Semantic blue (info / link) |
|
||||||
|
| `26` | `NEO_COLOR_WARNING` | `neoui.COLOR_WARNING` | Semantic orange (warning) |
|
||||||
|
| `27` | `NEO_COLOR_DANGER` | `neoui.COLOR_DANGER` | Semantic red (danger / error / reject) |
|
||||||
|
| `28` | `NEO_COLOR_DANGER_BG` | `neoui.COLOR_DANGER_BG` | Selected danger button background |
|
||||||
|
|
||||||
|
### 2.3 Font Roles (`NeoFontRole`) & Text Color Roles (`NeoTextColor`)
|
||||||
|
| ID | Font Role (`NeoFontRole`) | Yabasic | Description |
|
||||||
|
| :--- | :--- | :--- | :--- |
|
||||||
|
| `0` | `NEO_FONT_SMALL` | `neoui.FONT_SMALL` | Small UI font (`baseFontSize - 2`, min `10px`) |
|
||||||
|
| `1` | `NEO_FONT_MAIN` | `neoui.FONT_MAIN` | Main UI Bold font (`baseFontSize`, default `13px`) |
|
||||||
|
| `2` | `NEO_FONT_ICON` | `neoui.FONT_ICON` | Nerd Font icon glyph layout (`baseFontSize + 2`, default `15px`) |
|
||||||
|
| `3` | `NEO_FONT_LARGE` | `neoui.FONT_LARGE` | Large Bold title/number font (`baseFontSize + 3`, default `16px`) |
|
||||||
|
|
||||||
|
| ID | Text Color Role (`NeoTextColor`) | Yabasic | Mapped Theme Token |
|
||||||
|
| :--- | :--- | :--- | :--- |
|
||||||
|
| `0` | `NEO_TEXT_WHITE` | `neoui.TEXT_WHITE` | `theme.fgBright` |
|
||||||
|
| `1` | `NEO_TEXT_LIGHT` | `neoui.TEXT_LIGHT` | `theme.fgMain` |
|
||||||
|
| `2` | `NEO_TEXT_MUTED` | `neoui.TEXT_MUTED` | `theme.fgMuted` |
|
||||||
|
| `3` | `NEO_TEXT_YELLOW` | `neoui.TEXT_YELLOW` | `theme.accent` |
|
||||||
|
| `4` | `NEO_TEXT_GREEN` | `neoui.TEXT_GREEN` | `theme.success` |
|
||||||
|
| `5` | `NEO_TEXT_BLUE` | `neoui.TEXT_BLUE` | `theme.info` |
|
||||||
|
| `6` | `NEO_TEXT_ORANGE` | `neoui.TEXT_ORANGE` | `theme.warning` |
|
||||||
|
| `7` | `NEO_TEXT_RED` | `neoui.TEXT_RED` | `theme.danger` |
|
||||||
|
|
||||||
|
### 2.4 Event Types (`NeoEventType`) & Logical Keypad Keys (`NeoKey`)
|
||||||
|
| Event ID | C Constant | Yabasic Constant | Description |
|
||||||
|
| :--- | :--- | :--- | :--- |
|
||||||
|
| `0` | `NEO_EV_NONE` | `neoui.EV_NONE` | Timeout elapsed with no event |
|
||||||
|
| `1` | `NEO_EV_EXPOSE` | `neoui.EV_EXPOSE` | Window exposed or multi-tap candidate auto-committed; redraw frame |
|
||||||
|
| `2` | `NEO_EV_KEY_PRESS` | `neoui.EV_KEY_PRESS` | Keypad key pressed (query key via `neoui_event_key()`) |
|
||||||
|
| `3` | `NEO_EV_KEY_RELEASE` | `neoui.EV_KEY_RELEASE` | Keypad key released |
|
||||||
|
| `4` | `NEO_EV_SOFTKEY_LEFT` | `neoui.EV_SOFTKEY_LEFT` | Left softkey (`Menu` / `F1`) pressed (after chord disambiguation) |
|
||||||
|
| `5` | `NEO_EV_SOFTKEY_RIGHT` | `neoui.EV_SOFTKEY_RIGHT` | Right softkey (`Back` / `F2`) pressed (after chord disambiguation) |
|
||||||
|
| `6` | `NEO_EV_SOFTKEY_CHORD` | `neoui.EV_SOFTKEY_CHORD` | Both softkeys pressed together (`xdrawer` toggled automatically) |
|
||||||
|
| `7` | `NEO_EV_FIFO_CMD` | `neoui.EV_FIFO_CMD` | Custom command received on `/tmp/dwm_plugin_<app>.fifo` (`neoui_event_command()`) |
|
||||||
|
| `8` | `NEO_EV_THEME_RELOAD` | `neoui.EV_THEME_RELOAD` | Theme reloaded (`RELOAD_THEME`); redraw frame |
|
||||||
|
| `9` | `NEO_EV_CLOSE_REQ` | `neoui.EV_CLOSE_REQ` | `CLOSE` received on FIFO |
|
||||||
|
|
||||||
|
| Key ID | C Constant | Yabasic Constant | Physical Key |
|
||||||
|
| :--- | :--- | :--- | :--- |
|
||||||
|
| `0` | `NEO_KEY_NONE` | `neoui.KEY_NONE` | Unmapped key |
|
||||||
|
| `1`..`4` | `NEO_KEY_UP`, `DOWN`, `LEFT`, `RIGHT` | `neoui.KEY_UP`, `KEY_DOWN`, `KEY_LEFT`, `KEY_RIGHT` | D-Pad directions |
|
||||||
|
| `5` | `NEO_KEY_OK` | `neoui.KEY_OK` | Center `OK` (`Return` / `KP_Enter`) |
|
||||||
|
| `6` | `NEO_KEY_BACK` | `neoui.KEY_BACK` | `BackSpace` / `Delete` / `Escape` |
|
||||||
|
| `7` | `NEO_KEY_CALL` | `neoui.KEY_CALL` | Green Call / Send key (`XF86PickupPhone` / `F3`) |
|
||||||
|
| `8` | `NEO_KEY_END` | `neoui.KEY_END` | Red End / Power key (`XF86HangupPhone` / `F4`) |
|
||||||
|
| `9` | `NEO_KEY_SOFT_LEFT` | `neoui.KEY_SOFT_LEFT` | Left Softkey (`XF86KbdLcdMenu1` / `F1`) |
|
||||||
|
| `10` | `NEO_KEY_SOFT_RIGHT` | `neoui.KEY_SOFT_RIGHT` | Right Softkey (`XF86KbdLcdMenu2` / `F2`) |
|
||||||
|
| `32` | `NEO_KEY_SPACE` | `neoui.KEY_SPACE` | Space |
|
||||||
|
| `35` | `NEO_KEY_HASH` | `neoui.KEY_HASH` | `#` key (`numbersign`) |
|
||||||
|
| `42` | `NEO_KEY_STAR` | `neoui.KEY_STAR` | `*` key (`asterisk`) |
|
||||||
|
| `43` | `NEO_KEY_PLUS` | `neoui.KEY_PLUS` | `+` key (`plus`) |
|
||||||
|
| `48`..`57` | `NEO_KEY_0` .. `NEO_KEY_9` | `neoui.KEY_0` .. `neoui.KEY_9` | Keypad digits `0`–`9` |
|
||||||
|
|
||||||
|
### 2.5 Built-in Nerd Font Icon Names (`neoui_icon(name)`)
|
||||||
|
Any widget parameter accepting `icon_str` (or `neoui_icon(name)`) resolves the following symbolic names to their Nerd Font UTF-8 codepoints (or passes raw UTF-8 strings through unchanged):
|
||||||
|
- **Telephony & Messaging**: `"phone"`, `"hangup"`, `"contacts"`, `"user"`, `"sms"`, `"reply"`, `"in_call"`, `"out_call"`, `"missed_call"`, `"sim"`, `"signal"`, `"ussd"`, `"voicemail"`
|
||||||
|
- **Connectivity & Hardware**: `"wifi"`, `"bluetooth"`, `"globe"`, `"hotspot"`, `"usb"`, `"torch"`, `"sun"`, `"speaker"`, `"earpiece"`, `"mute"`, `"mic"`, `"mic_off"`, `"bell"`, `"vibrate"`, `"silent"`, `"dnd"`, `"camera"`, `"battery"`, `"lock"`
|
||||||
|
- **Files, Media & UI Actions**: `"folder"`, `"file"`, `"image"`, `"music"`, `"Gamepad"`, `"term"`, `"theme"`, `"settings"`, `"search"`, `"plus"`, `"edit"`, `"trash"`, `"check"`, `"close"`, `"info"`, `"warning"`, `"star"`, `"refresh"`, `"copy"`, `"sort"`, `"eye"`, `"backspace"`, `"up"`, `"down"`, `"left"`, `"right"`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. C SDK Reference (`/usr/include/neoui.h`)
|
||||||
|
|
||||||
|
### 3.1 Compiling C Applications on the Device
|
||||||
|
```bash
|
||||||
|
gcc -O2 myapp.c -lneoui -o myapp
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.2 C Function Summary
|
||||||
|
|
||||||
|
#### Window & Daemon Lifecycle
|
||||||
|
```c
|
||||||
|
int neoui_init(const char* app_name, int preload_mode);
|
||||||
|
int neoui_init_ex(const char* app_name, const char* res_name,
|
||||||
|
const char* res_class, const char* win_title,
|
||||||
|
int x, int y, int w, int h,
|
||||||
|
int override_redirect, int preload_mode);
|
||||||
|
int neoui_shutdown(void);
|
||||||
|
|
||||||
|
int neoui_show(void);
|
||||||
|
int neoui_hide(void);
|
||||||
|
int neoui_is_visible(void);
|
||||||
|
int neoui_raise_and_grab(void);
|
||||||
|
int neoui_ungrab(void);
|
||||||
|
|
||||||
|
int neoui_width(void);
|
||||||
|
int neoui_height(void);
|
||||||
|
|
||||||
|
int neoui_begin_frame(void);
|
||||||
|
int neoui_end_frame(void);
|
||||||
|
int neoui_flush(void);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Unified `.Xresources` / `.xth` Theme & Icon Resolution
|
||||||
|
```c
|
||||||
|
int neoui_reload_theme(void);
|
||||||
|
int neoui_check_reload_theme(void);
|
||||||
|
int neoui_apply_theme_file(const char* xth_path);
|
||||||
|
int neoui_broadcast_theme_reload(const char* skip_plugin);
|
||||||
|
|
||||||
|
const char* neoui_theme_name(void);
|
||||||
|
const char* neoui_font_face(void);
|
||||||
|
const char* neoui_icon_font_face(void);
|
||||||
|
int neoui_base_font_size(void);
|
||||||
|
int neoui_font_size(int font_role);
|
||||||
|
|
||||||
|
uint32_t neoui_color(int color_id);
|
||||||
|
uint32_t neoui_adjust_rgb(uint32_t rgb, int delta);
|
||||||
|
uint32_t neoui_blend_rgb(uint32_t c1, uint32_t c2, int weight2_pct);
|
||||||
|
uint32_t neoui_parse_hex_rgb(const char* hex_str, uint32_t fallback_rgb);
|
||||||
|
const char* neoui_format_hex_rgb(uint32_t rgb);
|
||||||
|
const char* neoui_icon(const char* icon_name);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Drawing Primitives, Text & Image Rendering
|
||||||
|
```c
|
||||||
|
int neoui_clear(uint32_t rgb);
|
||||||
|
int neoui_fill_rect(int x, int y, int w, int h, uint32_t rgb);
|
||||||
|
int neoui_draw_rect(int x, int y, int w, int h, uint32_t rgb);
|
||||||
|
int neoui_draw_line(int x1, int y1, int x2, int y2, uint32_t rgb);
|
||||||
|
int neoui_set_clip(int x, int y, int w, int h);
|
||||||
|
int neoui_reset_clip(void);
|
||||||
|
|
||||||
|
int neoui_draw_text(int font_role, int color_role, int x, int y, int h,
|
||||||
|
const char* text, int max_w);
|
||||||
|
int neoui_draw_text_centered(int font_role, int color_role, int x, int y,
|
||||||
|
int w, int h, const char* text);
|
||||||
|
int neoui_draw_text_right(int font_role, int color_role, int right_x, int y,
|
||||||
|
int h, const char* text, int max_w);
|
||||||
|
int neoui_draw_text_wrapped(int font_role, int color_role, int x, int y,
|
||||||
|
int w, int h, const char* text, int scroll_line);
|
||||||
|
int neoui_text_width(int font_role, const char* text);
|
||||||
|
const char* neoui_tail_fit_text(int font_role, const char* text, int max_w);
|
||||||
|
|
||||||
|
int neoui_draw_image_file(const char* path, int x, int y, int w, int h,
|
||||||
|
int scale_mode);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Standardized OS Shell Widgets
|
||||||
|
```c
|
||||||
|
int neoui_draw_header(const char* icon_str, int icon_color_role,
|
||||||
|
const char* title, const char* right_badge);
|
||||||
|
int neoui_draw_header_ex(int h, const char* icon_str, int icon_color_role,
|
||||||
|
const char* title, int title_color_role,
|
||||||
|
const char* right_badge, int right_color_role);
|
||||||
|
|
||||||
|
int neoui_draw_tabs(const char* pipe_labels, int active_idx, int y, int h);
|
||||||
|
|
||||||
|
int neoui_draw_softkeys(const char* left_label, const char* center_label,
|
||||||
|
const char* right_label);
|
||||||
|
int neoui_draw_softkeys_ex(const char* left_label, const char* center_label,
|
||||||
|
const char* right_label, int center_color_role);
|
||||||
|
|
||||||
|
int neoui_draw_list_row(int row_index, int y, int h, int is_selected,
|
||||||
|
const char* icon_str, int icon_color_role,
|
||||||
|
const char* title, const char* subtitle,
|
||||||
|
const char* right_text);
|
||||||
|
|
||||||
|
int neoui_draw_slider_row(int row_index, int y, int h, int is_selected,
|
||||||
|
const char* icon_str, int icon_color_role,
|
||||||
|
const char* label, int pct, const char* value_text);
|
||||||
|
|
||||||
|
int neoui_draw_toggle_row(int row_index, int y, int h, int is_selected,
|
||||||
|
const char* icon_str, int icon_color_role,
|
||||||
|
const char* label, int is_on,
|
||||||
|
const char* state_text);
|
||||||
|
|
||||||
|
int neoui_draw_button(int x, int y, int w, int h, int is_selected,
|
||||||
|
int is_danger, const char* icon_str, const char* label);
|
||||||
|
|
||||||
|
int neoui_draw_input_box(int x, int y, int w, int h, int is_focused,
|
||||||
|
const char* label, const char* value,
|
||||||
|
const char* placeholder, int password_mask);
|
||||||
|
|
||||||
|
int neoui_draw_progress_bar(int x, int y, int w, int h, int pct,
|
||||||
|
uint32_t fill_rgb);
|
||||||
|
|
||||||
|
int neoui_draw_scrollbar(int x, int y, int h, int total_items,
|
||||||
|
int visible_items, int scroll_offset);
|
||||||
|
|
||||||
|
int neoui_draw_modal_box(int x, int y, int w, int h, const char* icon_str,
|
||||||
|
int icon_color_role, const char* title);
|
||||||
|
|
||||||
|
int neoui_draw_confirm_dialog(const char* title, const char* line1,
|
||||||
|
const char* line2, const char* no_label,
|
||||||
|
const char* yes_label, int selected_yes);
|
||||||
|
|
||||||
|
int neoui_draw_menu_popup(const char* pipe_items, const char* pipe_icons,
|
||||||
|
int selected_idx, int max_visible_rows);
|
||||||
|
|
||||||
|
int neoui_draw_toast(const char* message);
|
||||||
|
int neoui_show_toast(const char* message, int duration_ms);
|
||||||
|
int neoui_clear_toast(void);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Event Loop, Keypad & Multi-Tap Input
|
||||||
|
```c
|
||||||
|
int neoui_poll_event(int timeout_ms);
|
||||||
|
int neoui_event_key(void);
|
||||||
|
int neoui_event_keycode(void);
|
||||||
|
int neoui_event_keysym(void);
|
||||||
|
const char* neoui_event_command(void);
|
||||||
|
int neoui_set_chord_xdrawer(int enabled);
|
||||||
|
|
||||||
|
int neoui_input_reset(const char* initial_text);
|
||||||
|
int neoui_input_set_text(const char* text);
|
||||||
|
const char* neoui_input_get_text(void);
|
||||||
|
int neoui_input_set_mode(int mode);
|
||||||
|
int neoui_input_get_mode(void);
|
||||||
|
int neoui_input_cycle_mode(void);
|
||||||
|
const char* neoui_input_mode_badge(void);
|
||||||
|
int neoui_input_feed_key(int neo_key);
|
||||||
|
int neoui_input_commit_tap(void);
|
||||||
|
int neoui_input_backspace(void);
|
||||||
|
int neoui_input_is_tap_active(void);
|
||||||
|
const char* neoui_input_candidate_bar(const char* idle_hint);
|
||||||
|
int neoui_draw_multitap_bar(int x, int y, int w, int h, const char* idle_hint);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### System & IPC Utilities
|
||||||
|
```c
|
||||||
|
int neoui_send_plugin_cmd(const char* plugin_name, const char* cmd);
|
||||||
|
int neoui_vibrate(int duration_ms);
|
||||||
|
int neoui_now_ms(void);
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.3 Minimal C Example
|
||||||
|
```c
|
||||||
|
#include <neoui.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
static void render(int sel, int enabled, int pct) {
|
||||||
|
char pct_str[16];
|
||||||
|
snprintf(pct_str, sizeof(pct_str), "%d%%", pct);
|
||||||
|
|
||||||
|
neoui_begin_frame();
|
||||||
|
neoui_draw_header("settings", NEO_TEXT_YELLOW, "My NeoUI App", neoui_theme_name());
|
||||||
|
neoui_draw_toggle_row(0, 40, 38, sel == 0, "wifi", NEO_TEXT_BLUE,
|
||||||
|
"Wireless Radio", enabled, enabled ? "ON" : "OFF");
|
||||||
|
neoui_draw_slider_row(1, 78, 38, sel == 1, "speaker", NEO_TEXT_GREEN,
|
||||||
|
"Output Level", pct, pct_str);
|
||||||
|
neoui_draw_softkeys("Toast", "Toggle", "Quit");
|
||||||
|
neoui_end_frame();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
if (!neoui_init("my_c_app", 0)) return 1;
|
||||||
|
|
||||||
|
int sel = 0, enabled = 1, pct = 70, running = 1;
|
||||||
|
render(sel, enabled, pct);
|
||||||
|
|
||||||
|
while (running) {
|
||||||
|
int ev = neoui_poll_event(250);
|
||||||
|
if (ev == NEO_EV_CLOSE_REQ || ev == NEO_EV_SOFTKEY_RIGHT) {
|
||||||
|
running = 0;
|
||||||
|
} else if (ev == NEO_EV_EXPOSE || ev == NEO_EV_THEME_RELOAD) {
|
||||||
|
render(sel, enabled, pct);
|
||||||
|
} else if (ev == NEO_EV_SOFTKEY_LEFT) {
|
||||||
|
neoui_show_toast("Hello from C!", 1800);
|
||||||
|
render(sel, enabled, pct);
|
||||||
|
} else if (ev == NEO_EV_KEY_PRESS) {
|
||||||
|
int k = neoui_event_key();
|
||||||
|
if (k == NEO_KEY_BACK) running = 0;
|
||||||
|
else if (k == NEO_KEY_UP || k == NEO_KEY_DOWN) sel = 1 - sel;
|
||||||
|
else if (k == NEO_KEY_OK && sel == 0) enabled = 1 - enabled;
|
||||||
|
else if (k == NEO_KEY_LEFT && sel == 1 && pct >= 5) pct -= 5;
|
||||||
|
else if (k == NEO_KEY_RIGHT && sel == 1 && pct <= 95) pct += 5;
|
||||||
|
render(sel, enabled, pct);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
neoui_shutdown();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. C++20 SDK Reference (`namespace bananarchy`)
|
||||||
|
|
||||||
|
When `#include <neoui.h>` is compiled under C++, it also exposes the `bananarchy` namespace used by Bananarchy's native DWM plugins (`src/dwm-plugins/*.cpp` and `src/xdrawer/xdrawer.cpp`).
|
||||||
|
|
||||||
|
### 4.1 Compiling C++ Applications or Plugins
|
||||||
|
```bash
|
||||||
|
g++ -O2 -std=c++17 myapp.cpp \
|
||||||
|
$(pkgconf --cflags --libs x11 xft fontconfig freetype2 pango pangoxft) \
|
||||||
|
-lneoui -o myapp
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4.2 Core C++ Classes & Helpers
|
||||||
|
- **`bananarchy::ThemeSpec`**:
|
||||||
|
- Holds all 29 RGB color tokens (`bgMain`, `bgHeader`, `bgFooter`, `selBg`, `selFg`, `accent`, `fgMain`, `fgBright`, `fgMuted`, `border`, `divider`, `success`, `info`, `warning`, `danger`, etc.), `fontFace`, `iconFontFace`, and `baseFontSize`.
|
||||||
|
- Methods: `loadActive(dpy, screen)`, `loadFromFile(path)`, `saveToFile(path)`, `serializeXresources()`, `recomputeDerivedFromCore()`, `colorById(id)`, `sizeSmall()`, `sizeMain()`, `sizeIcon()`, `sizeLarge()`.
|
||||||
|
- **`bananarchy::PluginTheme`**:
|
||||||
|
- Manages allocated `XftColor` instances (`colWhite`, `colLight`, `colMuted`, `colYellow`, `colGreen`, `colBlue`, `colOrange`, `colRed`) and `PangoLayout*` instances (`layoutMain`, `layoutSmall`, `layoutIcon`, `layoutNum`) with automatic `.Xresources` mtime/size change detection (`checkAndReload()`).
|
||||||
|
- **`bananarchy::NeoWindow`**:
|
||||||
|
- RAII wrapper managing the X11 `Display*`, `Window`, offscreen `Pixmap`, `GC`, `XftDraw*`, `PangoContext*`, `PangoLayout*` (`layoutMain`, `layoutSmall`, `layoutIcon`, `layoutNum`), and `PluginTheme theme`.
|
||||||
|
- Methods:
|
||||||
|
- `bool create(resName, resClass, title, winX, winY, winW, winH, overrideRedirect, eventMask)`
|
||||||
|
- `void destroy()`
|
||||||
|
- `int drawPango(layout, color, x, y, h, text, maxW = -1, align = 0)` (`align`: `0=left`, `1=center`, `2=right`)
|
||||||
|
- `int pangoWidth(layout, text)`
|
||||||
|
- `void drawSoftbar(leftLabel, centerLabel, rightLabel, centerCol = nullptr, softbarH = 26)`
|
||||||
|
- `void drawScrollbar(x, y, h, totalItems, visibleItems, scrollOffset)`
|
||||||
|
- `void drawToast(msg, softbarH = 26)`
|
||||||
|
- `void clearBg()` / `void present()`
|
||||||
|
- `bool checkReloadTheme()` / `void reloadTheme()`
|
||||||
|
- **Shared Text, Multi-Tap & Image Helpers in `libneoui.so`**:
|
||||||
|
- `std::string formatMultiTapBar(prefix, table, activeIdx, makeUpper, maxItems = 7, maxChars = 21)`: formats a scrolling candidate bar window centered around `activeIdx` so long symbol sequences (such as the 33-character `1` key table) never overflow the `240px` viewport.
|
||||||
|
- `std::string tailFitPangoText(layout, text, maxWidthPx)`: returns the UTF-8 suffix of `text` that fits within `maxWidthPx`.
|
||||||
|
- `bool loadImageRgb24(path, &outRgb, &outW, &outH)`: decodes JPEG (`libjpeg-turbo`), PNG (`libpng`), or other formats (`ffmpeg` fallback) into 24-bit RGB.
|
||||||
|
- `void scaleRgb24ToBgrxCanvas(srcRgb, srcW, srcH, dstBgrx, canvasW, canvasH, bgPixel, scaleMode)`: scales 24-bit RGB into a 32-bit BGRX `XImage` buffer (`NEO_SCALE_FIT`, `NEO_SCALE_FILL`, or `NEO_SCALE_STRETCH`).
|
||||||
|
- `void downscaleViewfinder800x600To240x180(srcRgb, dstBgrx, zoomFactor)`: rotates the raw `800x600` `GC2395` camera frame 90 degrees clockwise and samples the centered 4:3 region (`600x450`) into the `240x180` viewfinder buffer.
|
||||||
|
- `bool saveRgb24AsJpeg(path, rgb, width, height, quality = 92)`
|
||||||
|
- `std::string formatFileSize(bytes)`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. Yabasic SDK Reference (`neoui.yab`)
|
||||||
|
|
||||||
|
Bananarchy includes `/home/user/Projects/neoui.yab` (symlinked to `/usr/lib/neoui.yab`), which wraps every C FFI function in `/usr/lib/libneoui.so` using Yabasic's native `libffi` foreign function interface (`frnfn_call` and `frnfn_call$`).
|
||||||
|
|
||||||
|
### 5.1 Running Yabasic NeoUI Programs
|
||||||
|
- **From the File Manager (`xfiles`)**: navigate to `/home/user/Projects/`, highlight `neoui_demo.yab` (or your own `.yab` file), and press **Center `OK` (`Return`)**.
|
||||||
|
- **From a terminal or SSH**:
|
||||||
|
```bash
|
||||||
|
DISPLAY=:0 yabasic ~/Projects/neoui_demo.yab
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5.2 Importing `neoui.yab`
|
||||||
|
Because `/usr/lib/neoui.yab` is symlinked to `/home/user/Projects/neoui.yab`, any `.yab` script in any directory can import `neoui` with a single line:
|
||||||
|
```yabasic
|
||||||
|
import neoui
|
||||||
|
```
|
||||||
|
- All exported subroutines can be called directly (e.g. `neoui_init("myapp", 0)`, `neoui_draw_header(...)`) or qualified with `neoui.` (`neoui.neoui_init(...)`).
|
||||||
|
- All module constants are accessed with the `neoui.` prefix (e.g. `neoui.TEXT_YELLOW`, `neoui.FONT_MAIN`, `neoui.COLOR_ACCENT`, `neoui.EV_KEY_PRESS`, `neoui.KEY_OK`).
|
||||||
|
|
||||||
|
### 5.3 Exported Yabasic Functions in `neoui.yab`
|
||||||
|
|
||||||
|
#### 1. Window & Frame Lifecycle
|
||||||
|
- `neoui_init(app_name$, preload_mode)` -> `1` on success, `0` on error
|
||||||
|
- `neoui_init_ex(app_name$, res_name$, res_class$, win_title$, x, y, w, h, override_redirect, preload_mode)`
|
||||||
|
- `neoui_shutdown()`
|
||||||
|
- `neoui_show()` / `neoui_hide()` / `neoui_is_visible()`
|
||||||
|
- `neoui_raise_and_grab()` / `neoui_ungrab()`
|
||||||
|
- `neoui_width()` / `neoui_height()`
|
||||||
|
- `neoui_begin_frame()` / `neoui_end_frame()` / `neoui_flush()`
|
||||||
|
|
||||||
|
#### 2. Theme, Color & Icon Resolution
|
||||||
|
- `neoui_reload_theme()` / `neoui_check_reload_theme()`
|
||||||
|
- `neoui_apply_theme_file(xth_path$)` / `neoui_broadcast_theme_reload(skip_plugin$)`
|
||||||
|
- `neoui_theme_name$()` / `neoui_font_face$()` / `neoui_icon_font_face$()`
|
||||||
|
- `neoui_base_font_size()` / `neoui_font_size(font_role)`
|
||||||
|
- `neoui_color(color_id)`
|
||||||
|
- `neoui_adjust_rgb(rgb, delta)` / `neoui_blend_rgb(c1, c2, weight2_pct)`
|
||||||
|
- `neoui_parse_hex_rgb(hex_str$, fallback_rgb)` / `neoui_format_hex_rgb$(rgb)`
|
||||||
|
- `neoui_icon$(icon_name$)`
|
||||||
|
|
||||||
|
#### 3. Drawing Primitives, Text & Images
|
||||||
|
- `neoui_clear(rgb)`
|
||||||
|
- `neoui_fill_rect(x, y, w, h, rgb)` / `neoui_draw_rect(x, y, w, h, rgb)`
|
||||||
|
- `neoui_draw_line(x1, y1, x2, y2, rgb)`
|
||||||
|
- `neoui_set_clip(x, y, w, h)` / `neoui_reset_clip()`
|
||||||
|
- `neoui_draw_text(font_role, color_role, x, y, h, text$, max_w)`
|
||||||
|
- `neoui_draw_text_centered(font_role, color_role, x, y, w, h, text$)`
|
||||||
|
- `neoui_draw_text_right(font_role, color_role, right_x, y, h, text$, max_w)`
|
||||||
|
- `neoui_draw_text_wrapped(font_role, color_role, x, y, w, h, text$, scroll_line)`
|
||||||
|
- `neoui_text_width(font_role, text$)` / `neoui_tail_fit_text$(font_role, text$, max_w)`
|
||||||
|
- `neoui_draw_image_file(path$, x, y, w, h, scale_mode)`
|
||||||
|
|
||||||
|
#### 4. Standardized OS Shell Widgets
|
||||||
|
- `neoui_draw_header(icon_str$, icon_color_role, title$, right_badge$)`
|
||||||
|
- `neoui_draw_header_ex(h, icon_str$, icon_color_role, title$, title_color_role, right_badge$, right_color_role)`
|
||||||
|
- `neoui_draw_tabs(pipe_labels$, active_idx, y, h)`
|
||||||
|
- `neoui_draw_softkeys(left_label$, center_label$, right_label$)`
|
||||||
|
- `neoui_draw_softkeys_ex(left_label$, center_label$, right_label$, center_color_role)`
|
||||||
|
- `neoui_draw_list_row(row_index, y, h, is_selected, icon_str$, icon_color_role, title$, subtitle$, right_text$)`
|
||||||
|
- `neoui_draw_slider_row(row_index, y, h, is_selected, icon_str$, icon_color_role, label$, pct, value_text$)`
|
||||||
|
- `neoui_draw_toggle_row(row_index, y, h, is_selected, icon_str$, icon_color_role, label$, is_on, state_text$)`
|
||||||
|
- `neoui_draw_button(x, y, w, h, is_selected, is_danger, icon_str$, label$)`
|
||||||
|
- `neoui_draw_input_box(x, y, w, h, is_focused, label$, value$, placeholder$, password_mask)`
|
||||||
|
- `neoui_draw_progress_bar(x, y, w, h, pct, fill_rgb)`
|
||||||
|
- `neoui_draw_scrollbar(x, y, h, total_items, visible_items, scroll_offset)`
|
||||||
|
- `neoui_draw_modal_box(x, y, w, h, icon_str$, icon_color_role, title$)`
|
||||||
|
- `neoui_draw_confirm_dialog(title$, line1$, line2$, no_label$, yes_label$, selected_yes)`
|
||||||
|
- `neoui_draw_menu_popup(pipe_items$, pipe_icons$, selected_idx, max_visible_rows)`
|
||||||
|
- `neoui_draw_toast(message$)` / `neoui_show_toast(message$, duration_ms)` / `neoui_clear_toast()`
|
||||||
|
|
||||||
|
#### 5. Event Loop, Keypad & Multi-Tap Input
|
||||||
|
- `neoui_poll_event(timeout_ms)`
|
||||||
|
- `neoui_event_key()` / `neoui_event_keycode()` / `neoui_event_keysym()` / `neoui_event_command$()`
|
||||||
|
- `neoui_set_chord_xdrawer(enabled)`
|
||||||
|
- `neoui_input_reset(initial_text$)` / `neoui_input_set_text(text$)` / `neoui_input_get_text$()`
|
||||||
|
- `neoui_input_set_mode(mode)` / `neoui_input_get_mode()` / `neoui_input_cycle_mode()` / `neoui_input_mode_badge$()`
|
||||||
|
- `neoui_input_feed_key(neo_key)` / `neoui_input_commit_tap()` / `neoui_input_backspace()` / `neoui_input_is_tap_active()`
|
||||||
|
- `neoui_input_candidate_bar$(idle_hint$)` / `neoui_draw_multitap_bar(x, y, w, h, idle_hint$)`
|
||||||
|
|
||||||
|
#### 6. System & IPC Utilities
|
||||||
|
- `neoui_send_plugin_cmd(plugin_name$, cmd$)`
|
||||||
|
- `neoui_vibrate(duration_ms)`
|
||||||
|
- `neoui_now_ms()`
|
||||||
|
|
||||||
|
### 5.4 Minimal Yabasic Starter Template
|
||||||
|
```yabasic
|
||||||
|
#!/usr/bin/yabasic
|
||||||
|
import neoui
|
||||||
|
|
||||||
|
if neoui_init("hello_neoui", 0) = 0 then
|
||||||
|
print "Failed to open X11 window"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
sel = 0
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
sub render()
|
||||||
|
neoui_begin_frame()
|
||||||
|
neoui_draw_header(neoui_icon$("star"), neoui.TEXT_YELLOW, "Hello NeoUI", neoui_theme_name$())
|
||||||
|
neoui_draw_list_row(0, 42, 38, sel = 0, neoui_icon$("plus"), neoui.TEXT_GREEN, "Increment Counter", "Press OK to add 1", str$(count))
|
||||||
|
neoui_draw_list_row(1, 80, 38, sel = 1, neoui_icon$("bell"), neoui.TEXT_BLUE, "Vibrate & Toast", "Test haptic feedback", "60ms")
|
||||||
|
neoui_draw_softkeys("Toast", "Select", "Quit")
|
||||||
|
neoui_end_frame()
|
||||||
|
end sub
|
||||||
|
|
||||||
|
render()
|
||||||
|
|
||||||
|
running = 1
|
||||||
|
while running
|
||||||
|
ev = neoui_poll_event(250)
|
||||||
|
if ev = neoui.EV_CLOSE_REQ or ev = neoui.EV_SOFTKEY_RIGHT then
|
||||||
|
running = 0
|
||||||
|
elsif ev = neoui.EV_EXPOSE or ev = neoui.EV_THEME_RELOAD then
|
||||||
|
render()
|
||||||
|
elsif ev = neoui.EV_SOFTKEY_LEFT then
|
||||||
|
neoui_show_toast("Theme: " + neoui_theme_name$(), 1500)
|
||||||
|
render()
|
||||||
|
elsif ev = neoui.EV_KEY_PRESS then
|
||||||
|
k = neoui_event_key()
|
||||||
|
if k = neoui.KEY_BACK then
|
||||||
|
running = 0
|
||||||
|
elsif k = neoui.KEY_UP or k = neoui.KEY_DOWN then
|
||||||
|
sel = 1 - sel
|
||||||
|
elsif k = neoui.KEY_OK then
|
||||||
|
if sel = 0 then
|
||||||
|
count = count + 1
|
||||||
|
else
|
||||||
|
neoui_vibrate(60)
|
||||||
|
neoui_show_toast("Counter = " + str$(count), 1500)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
render()
|
||||||
|
fi
|
||||||
|
wend
|
||||||
|
|
||||||
|
neoui_shutdown()
|
||||||
|
```
|
||||||
Reference in new issue
Block a user