Files
lightgui_rust/crates/lightgui-designer/README.md
T
Muse 9e6f882575 Regen data tables from lightgui e474894: kTypes 36->38, EventDef lazarus
- tools/extract_palette.py: kTypes expectation 36->38 (ToggleButton and
  CheckListBox added in C); palette total 598->600
- tools/extract_events.py: parse 6th EventDef field `lazarus` (Flag 10
  Lazarus Object Inspector name); scope table/dispatch parsing to
  events_for() (raw_events_for() has its own `raw` table, deliberately
  excluded); dispatch now tests the normalised key `t`, not `type`
- data/*.json regenerated via `make regen`: registry default sizes per
  the C rule (incl. the 15 monitor widgets' hand-written sizes),
  palette Misc/X order per C xframe_palette.h, props 37 types / 270
  props / 25 enum tables / 35 common props, events 29 types with
  lazarus names; indicators provenance head only
- crates/xframe-common: palette asserts 598->600, LightGUI 36->38
- crates/xframe-widgets: *_gen.rs regenerated; gen_data.py opt_f now
  emits float literals for Option<f64> lo/hi (pre-existing latent bug:
  running it on the old data also emitted Some(0)); stale eb0b5fc /
  547 / 9 / 35 / 27 counts updated to e474894 / 562 / 25 / 37 / 29

make check: all 5 tables OK. cargo build warning-free. cargo test
--workspace --no-fail-fast: all suites green except 5 pre-existing
environmental failures, verified identical on HEAD: lightgui-debug
console (37) + gtk (7) need /usr/bin/gdb (not installed on dallas),
lightgui-support font/theme need a display (gtk::init fails), and
lightgui-gen fixtures is stale vs the Task 4 event routing in gen.rs.
2026-12-05 19:20:00 +00:00

4.8 KiB

lightgui-designer

The LightGUI visual designer on gtk-rs 0.18 (GTK 3.24) — a port of src/main.cpp (4,751 lines) + ui/designer.ui from lightgui (HEAD eb0b5fc), with the unified XFrame-native canvas treatment.

What it is

  • Main window (LightGUI — C++/XFrame, 1150x720): menu bar, XFrame canvas in a scrolled window, statusbar. The canvas is a GtkDrawingArea (double-buffered FALSE) drawn on with x11rb by the XFrame-native core in src/canvas.rs; the placed widgets are the real XFrame widget classes: click to select, drag to move (8px drag threshold), double-click for 16px resize handles, Delete removes. Palette clicks arm a widget for placement in-process — no selection file, no separate layout window.
  • Widget palette (LightGUI — Widgets, 250x780): the XFrame-only 562-entry palette — all 562 XFrame widgets in their 11 section groups, built in code from data/palette.json with 16x16 .ico icons.
  • Object Inspector (LightGUI — Object Inspector, 340x700): its own top-level window. Property editor (per-type tables + common props from lightgui-core, resolved through the XFrame class name), geometry spins, events pane (signal → handler() checkbuttons), plus the Bulk parameter and Colour palette sections. The 340px width is not in the .ui (which says 300): like the C build, the bulk combo-with-entry and colour grid widen the inspector's box to 340 at startup — verified against the C binary on the same display.
  • Code window (LightGUI — Code, 1000x700): its own top-level window showing the generated C++/XFrame code for the current canvas, regenerated from lightgui-gen on every open and Generate.
  • The four windows open together and park in a cascade (palette left of main, inspector right, code below/right) instead of stacking over the canvas; closing one only hides it and its View-menu entry brings it back.

ui/designer.ui is embedded verbatim via include_str! and loaded through GtkBuilder. There is no separate layout process any more: the standalone xframe-layout crate is deleted and the canvas lives inside this designer.

Wiring

  • lightgui-core: palette types, property/event tables, .fdj load/save (File → Open/Save), canonicalisation. .fdj is XFrame-only: GTK widgets in an old file are dropped on load, never migrated.
  • lightgui-gen: File → Generate writes a C++/XFrame project; the code window shows it.
  • data/palette.json (562 XFrame entries) and data/registry.json (562 widgets) are embedded at compile time (src/palette.rs). The palette extract still carries the old 38 LightGUI entries, but the designer reads the XFrame part only.

Build & run

cargo build -p lightgui-designer
./target/debug/lightgui-designer        # needs an X display

Tests

cargo test -p lightgui-designer        # palette + seam tests, no display
  • tests/palette.rs — XFrame-only counts, 11 sections, families, registry cross-checks.
  • tests/seam.rs — Rust port of widgets/tests/test_layout_to_lightgui.py: all 562 registry names through the layout → .fdj converter (identity mapping now), real lightgui-core load, real lightgui-gen generate. With LIGHTGUI_SEAM_CMAKE_BUILD=1 it also CMake-builds the generated project (step 4 of the Python test).

Live (Xvfb) hooks, same names as the C++ designer:

LIGHTGUI_SELFTEST=1 xvfb-run -a ./target/debug/lightgui-designer
# -> SELFTEST PASS items=1, exit 0

LIGHTGUI_PALETTE_SELFTEST=/tmp/pal.log xvfb-run -a ./target/debug/lightgui-designer
# -> SUMMARY pass=562 fail=0, exit 0

LIGHTGUI_PALETTE_DUMP=/tmp/pal.txt xvfb-run -a ./target/debug/lightgui-designer
# -> 562 XFRAME position lines

LIGHTGUI_ICONS overrides the XFrame .ico directory.

Deliberately not here (sibling crates own them)

  • GDB debugger window/settings/toggles → lightgui-debug. The Debug menu entries report that on the statusbar instead of pretending.
  • Codeview widget (syntax highlight, folding, breakpoints), themes, preferences, CMake build → lightgui-support. Same treatment for their menu entries.
  • The standalone XFrame palette process → xframe-palette (kept as dead code, mirroring the C repo).

Known gaps vs src/main.cpp

  • StockChart draws candles from its CSV data file (fake seeded candles until one loads); compare series and indicator panes are model-only, not drawn.
  • Spreadsheet rows/columns are model-only at design time (the generator still emits them); the design-time grid stays 5x4.
  • The code window shows generated code as plain monospace text — the full codeview widget (highlight/folding/breakpoints) is the lightgui-support crate's job.
  • Shape/Plot draw simple design-time placeholders (outline / sine wave), not the full C draw routines.