Files
lightgui/docs/ide.md
cnmcdee c31b4b6a8b Step 5: cut .fdj to XFrame-only, drop the GTK palette (547 XFrame entries)
Palette is XFrame-only: the 36 GTK widgets are gone from designer.ui
and main.cpp (547 entries from xframe_palette.h). .fdj holds only
XFrame widgets; on load a GTK/unknown type is skipped with a clear
message, never migrated. snapshot/load now go through the embedded
XFrame canvas; the GTK Item machinery stays only as selftest
scaffolding (legacy_gtk_snapshot) until it is removed in a follow-up.
Selftest phases 3-8 rewritten for the step-4 XFrame generator (4
files, lg::Holder markers, file-level + XFrame round-trips, GTK skip
rule, bad-file rejection). Palette/converter tests updated to 547;
xframe_palette.h regenerated (one stale comment line). Docs updated.
Also: selftest cleans scratch generation dirs first, and the cleanup
call assigns its return value (void cast does not silence
-Wunused-result for system() on this toolchain).
2026-11-30 00:42:10 +00:00

461 lines
24 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# The Combined IDE — Designer + XFrame Widgets + GDB Debugger
> **Status: landed.** Written against the LightGUI tree as of Nov 29, 2026
> (rename from FDesigner/cfree + 547-widget merge + Object Inspector split;
> see `git log`).
> The combined top-level build (`make`) and the single `./ide`
> launcher are in the tree — see [Build](#build) and [Launch](#launch) —
> as is the layout → designer seam
> (`widgets/tools/layout_to_lightgui.py`).
One repository, one IDE, two halves that fit together:
- **LightGUI (repo root)** — a C++/GTK 3 visual designer. Place
widgets on a canvas, edit properties, generate compilable C++/GTK
code, and step through it with a built-in GDB debugger. The
designer itself is GTK, built with GtkBuilder from a Glade `.ui`
file. No Qt anywhere.
- **`widgets/` — XFrame**, a pure X11/Xlib hand-drawn C++17 widget
library: **547 widgets** (102 `Gtk*`, 90 `T*`, 250 `Ind*`, 37 `Stock*`, 66 `Inst*`, plus `XGraph` and
`XSpreadsheet`), drawn with raw Xlib calls. No GTK, no Qt, no
toolkit at all — despite the `Gtk*` names. The `Gtk*` components
recreate the look of GTK widgets as standalone X11 classes; the
`T*` components are the same idea in Lazarus/Delphi style.
The two halves share one repo, one launcher, and one workflow:
design a form, place widgets from a palette, generate code, build it,
debug it. The full widget API reference lives in
[docs/index.md](index.md) (the shared contract) and the ten section
pages; the designer's own design notes live in
[DESIGN.md](../DESIGN.md).
## The windows
Starting the designer opens four top-level windows at once (the
palette, the Object Inspector, and the code window open together with
the designer, parked in a cascade instead of over the canvas).
`./ide` adds the XFrame palette and layout windows, for six in total.
Each is a plain top-level window — never
transient or modal — so they coexist; closing one only hides it, and
its View-menu entry brings it back.
| Window | Title | Size | What it is |
|---|---|---|---|
| Designer | `LightGUI — C++/GTK — <name>` | 1150x720 | Canvas, Events pane, menus (properties live in the Object Inspector window) |
| Object Inspector | `LightGUI — Object Inspector` | 300x700 | Property editor in its own top-level window, separate from the layout window |
| Widget palette | `LightGUI — Widgets` | 250x780 | **XFrame-only palette, 547 entries**: all 547 XFrame widgets in their 11 section groups, each with its 16x16 icon; the window scrolls |
| Code | `LightGUI — Code` | 1000x700 | Generated C++ with gutter, folding, themes, breakpoints, automatic variable inspection |
| Debugger | `LightGUI Debugger` | — | GDB/MI stepping debugger (Debug → Open Debugger…) |
The **palette** (`LightGUI — Widgets`) is XFrame-only since step 5
(Nov 29, 2026): 547 entries in 11 section groups. Clicking an entry
selects that XFrame widget in-process; clicking the embedded canvas
places the *real* XFrame widget class, and it can be moved, resized
(double-click for handles), and deleted there. There is no separate
palette process and no selection file anymore, and the standalone
layout window is deleted (step 6) — the canvas lives inside the
designer. `widgets/palette/` (`lightgui_palette`) is still in the
tree but is dead code: `./ide` no longer launches it.
## Build
Prerequisites: a C++17 compiler (`g++`), CMake >= 3.20, X11 dev
headers (`libx11-dev` on Debian/Ubuntu), GTK 3 dev files
(`libgtk-3-dev`), and `gdb` for the debugger. Everything needs an X
display — a real X server or Xvfb (see
[Troubleshooting](#troubleshooting)).
**Combined build:** a top-level `Makefile` builds both halves:
```sh
make # designer + widgets (547 demos + palette)
make lightgui # designer/lightgui only
make widgets # widgets/build only
make test # seam test: layout -> .fdj -> codegen -> CMake build
make clean # remove built artefacts
```
**Building each half today** (verified against the current trees):
```sh
# Designer: plain Makefile, g++ -O2 -Wall -Wextra -std=c++17, GTK 3 via pkg-config
make lightgui # builds ./lightgui, zero warnings
make clean && make lightgui # from scratch
# XFrame library: CMake, one target per component demo + palette + layout
cd widgets
cmake -S . -B build
cmake --build build -j"$(nproc)" # all 547 demos, 0 errors, 0 warnings (-Wall -Wextra)
```
Binaries: `lightgui`, `widgets/build/palette/lightgui_palette`
(dead code — no longer launched),
`widgets/build/components/<Name>/<Name>`.
A single component builds standalone — copy its directory out and
run `cmake -S . -B build` in it; each component ships its own copy of
`core/xframe_core.h`, byte-identical to the canonical
`widgets/core/xframe_core.h`.
## Launch
**Single launcher:** `./ide` at the repo root starts the designer
(single process). It builds anything missing first (`--build` forces
a rebuild), then execs `./lightgui`. Run under Xvfb if there is no
real X server.
**Launching each half today:**
```sh
./lightgui # designer + palette + inspector + code windows together
```
The designer is a single process. Under Xvfb:
```sh
Xvfb :99 -screen 0 1920x1080x24 &
DISPLAY=:99 ./lightgui
```
## End-to-end workflow
### 1. Design a form (designer)
Click a widget in the `LightGUI — Widgets` palette to add it to the
canvas; click to select, drag to move, Delete to remove it. The
the Object Inspector window edits the selected widget's properties (per-type
tables in `src/props.h`); bulk operations set or clear a
parameter on all, selected, or filtered widgets. The Events pane
lists the widget type's natural GTK signals — ticking one connects
it: the generator emits a stub handler plus `g_signal_connect` for
it, ready to fill in.
Widget set on the canvas: the original Tk set (Button, Label, Entry,
CheckButton, RadioButton, ComboBox, ListBox, Frame, Scale, Text,
StockChart, Spreadsheet, Toplevel, Canvas, Scrollbar, MenuButton)
plus 20 Lazarus-style widgets (Memo, GroupBox, Panel, Image, Shape,
Notebook, ScrollBox, Splitter, StatusBar, ToolBar, MenuBar,
SpinEdit, TrackBar, ProgressBar, DateTimePicker, ColorBox, ListView,
TreeView, StringGrid, Plot). `StockChart` is the chart widget: candle
charts from CSV (`data-file`, `up-color`, `down-color`,
`max-candles`), with 250 named technical indicators
(`indicators` property, e.g. `"SMA(20), RSI, MACD(12,26,9)"`),
drawings, comparison files, and a percent scale — see
[DESIGN.md](../DESIGN.md).
Save the design as a JSON project file (`.fdj`).
### 2. Place XFrame widgets (palette + layout)
Pick the widget in the palette (`LightGUI — Widgets`): scroll to
the XFrame section group and click an entry — its 16x16 icon and name
are shown. Click empty canvas in the designer to place the real
XFrame widget class at its default size, drag a placed widget to move
it, Delete to remove it. Double-click a placed widget for resize
handles; drag a handle to resize live; Escape dismisses the handles.
Save the design with File → Save project (`.fdj`, XFrame-only) and
reopen it with File → Open project.
**From layout file to designer (the seam):** a layout text file (one
`<XFrameName> <x> <y> <width> <height>` per line, as the old layout
window saved) converts to a LightGUI project:
```sh
python3 widgets/tools/layout_to_lightgui.py /tmp/lightgui-layout.txt /tmp/layout.fdj
```
Open `/tmp/layout.fdj` in the designer (**File → Open project**) and
continue with section 3 (generate) and section 5 (debug) below.
All 547 XFrame widgets map straight through — the .fdj carries the
XFrame class name as the widget type, and the generated app
instantiates the XFrame classes directly. Names that are not in the
registry are reported and skipped, never forced into a wrong type.
Proved end to end by
`widgets/tests/test_layout_to_lightgui.py` (`make test`).
### 3. Generate code (designer)
**File → Generate C++/GTK…** asks for a folder and writes a complete
project (step 4, Nov 29, 2026). The output is a plain X11/XFrame
program — **no GTK, no `.ui` file** — in a single `main.cpp`: it opens
the display, creates the top-level window, sets up the
`SStyle_Manager`, constructs one `lg::Holder<T>` per placed widget
(T is the XFrame class), applies properties through the widgets'
getter/setter API, wires connected signals to stub handlers that
print `EVENT <Widget> <signal>`, and runs an X event loop dispatching
through `lg::IWidget`.
Every generated project also gets a `CMakeLists.txt` next to its
`Makefile` (`cmake_minimum_required(VERSION 3.20)`,
`project(<ClassName> CXX)`, C++17, `find_package(X11 REQUIRED)`,
`add_executable(app main.cpp)`). The executable is named `app`,
matching the Makefile target, and builds with:
```sh
cmake -S . -B build && cmake --build build
# or
make
```
From the designer, **File → Generate C++/GTK…** offers **Build with
CMake** right after generating (the default build path for a
generated project); **File → Build with CMake…** rebuilds the last
generated project (or asks for a folder); **File → Open CMake
Project…** points the designer at any directory holding a
`CMakeLists.txt` — generated or hand-written — and builds it
(configure + build), reporting success/failure plus the executable
path in a log dialog. A missing or broken `CMakeLists.txt`, or a
compile error, is reported as a failure, never as success. CMake
settings (command, generator, build type, build directory) live in
`~/.config/lightgui/cmake.conf` and are edited via **File → CMake
Settings…**.
### 4. Read the code (code window)
**View → Code View** shows the generated C++ for the current canvas
in the `LightGUI — Code` window. If nothing has been generated yet
it says so (`Generate a design first: File -> Generate C++/GTK...`).
The view is a `GtkTextView` with a gutter beside it in one
`GtkScrolledWindow`, so the gutter scrolls in lockstep:
- **Line numbers** in the left gutter.
- **Red-dot breakpoints:** click anywhere in the gutter (outside the
fold-marker column) to toggle a breakpoint at that line. This goes
through the real debugger backend and persists with the other
breakpoints (see [Debug](#5-debug-with-the-stepping-debugger)).
- **Folding:** `[-]` / `[+]` toggles in the fold-marker column.
Everything foldable folds: `#region` / `#endregion` (bare and the
`// #region` form the generator emits), every matched-brace span
(functions, if/else, loops, classes, structs, namespaces,
initializers), multi-line `/* */` comments, and `#if` / `#ifdef` /
`#ifndef` … `#endif` blocks — nested in all directions. Folded
lines collapse to zero height, so file line numbers stay exact.
- **Colour themes:** **View → Color Theme…** picks one of four
built-ins — Light, Dark, Monokai, Solarized Dark — colouring
keywords, types, strings, comments, numbers, preprocessor lines,
background/foreground and the current line; per-role colours are
customisable in the picker. The choice persists to
`~/.config/lightgui/theme.conf`.
- **Fonts:** **Edit → Preferences…** sets the interface font and the
code/text-view font (defaults `Sans 10` / `Monospace 11`, sizes
clamped to 6–48 pt), persisted to
`~/.config/lightgui/settings.conf` and applied live.
### 5. Debug with the stepping debugger
**Debug → Open Debugger…** opens the `LightGUI Debugger` window. It
drives a real `gdb` over the MI protocol (`gdb -q -i=mi2`, backend in
`src/debugger.h` / `debugger.cpp`) — no mock, no simulation.
- **Toolbar:** Run, Continue (**F5**), Step Over (**F10**), Step Into
(**F11**), Step Out, Stop (interrupts a running target; press again
to kill it), Restart, Settings.
- **Targets:** any program compiled with `-g` — console programs and
GTK apps alike (a GTK app runs under the same X display as the
designer).
- **Breakpoints:** type `file.cpp:123` or a function name and press
Add BP. The list shows id / location / enabled toggle / hit count.
The Add/Edit dialog sets the full handler set for a breakpoint:
**kind** — Plain, Conditional (stops only when a gdb expression is
true, e.g. `i == 5`), or Logpoint (a gdb `dprintf`: prints a
message and never stops) — plus **ignore count** (skip the first N
hits), **log message** template (literal text plus `{expr}`
placeholders; `{s:expr}` prints a string, `{f:expr}` a float,
`{x:expr}` hex, `{p:expr}` a pointer), and a **group** label.
Breakpoints persist to `~/.config/lightgui/debugger_bps.conf`
(one per line:
`location|enabled|kind|condition|ignore|log_message|group`) and are
restored on the next run.
- **Variables:** Locals (name / type / value) and a watch list (add
any expression, e.g. `sum + 1`) refresh on every stop; the Stack
pane shows the current frames; the status line shows the stopped
file:line and function. Target stdout/stderr appears in the bottom
pane; logpoint output lands in the gdb log (it arrives on gdb's
console stream, not the target's output).
- **Settings:** the Settings toolbar button, **Debug → Debugger
Settings…**, and the **Debug → Debugger** sub-menu (which also has
Break on main / Stop on entry / Pretty-print values toggles).
Settings live in `~/.config/lightgui/debugger.conf`: `gdb_path`
(default `/usr/bin/gdb`), `break_on_main`, `stop_on_entry`,
`pretty_print`, `print_all_locals`, `default_args`. They take
effect on the next Run.
**What happens in the code window when the debugger pauses:** the
code window shares the debugger's `GdbSession` and polls it every
200 ms — one session, no second gdb. On a stop it loads the stopped
file (if it is not already shown), unfolds any region hiding the
paused line, and:
- the paused line's **background goes solid red (`#c00000`) with
white text**, plus a white ▶ arrow in the gutter — the Lazarus
execution-point style (full-line background + gutter arrow,
distinct from the red-dot breakpoint marker). If the paused line
is also a breakpoint line, both marks show (the arrow tip touches
the red dot by ~2px).
- the **automatic variable inspection pane** at the bottom of the
code window shows the scope (`func() — file:line (reason)`) and
the locals of the current frame, refreshed on every stop/step.
While the target is running it shows "running" and clears the
paused line — it never presents stale values as current. With no
target it says so; after exit it shows the exit code.
Step with F10/F11 (or the toolbar) and the red line and the
variables follow the execution point. Click a red dot in the gutter
while paused to add or remove a breakpoint at that line; it stages
into the shared session and persists.
## The XFrame widget library
The library reference is [docs/index.md](index.md) plus one page per
section. Every widget shares the same contract: the identical
constructor
```cpp
<Name>(Display* display, int screen, Window window, GC gc,
SStyle_Manager* styles, int x, int y, int width, int height)
```
`set_bounds` / `width` / `height` / `contains`, visibility and
enabled state, `set_style_name` / `style`, `draw()`, the four event
handlers (`on_button_press`, `on_button_release`, `on_motion`,
`on_key`), and signals as public `std::function` members (most
commonly `on_click`). The exact constructor, widget-specific
methods, signals, and a minimal working example per widget are on
its section page — never guess a signal name: if it is not in the
header, it does not exist.
| Section | Widgets | Page |
|---|---|---|
| Windows & Dialogs | 28 | [windows-dialogs.md](windows-dialogs.md) |
| Containers & Layout | 34 | [containers-layout.md](containers-layout.md) |
| Buttons | 24 | [buttons.md](buttons.md) |
| Display | 33 | [display.md](display.md) |
| Text & Entry | 28 | [text-entry.md](text-entry.md) |
| Choosers | 10 | [choosers.md](choosers.md) |
| Views & Lists | 17 | [views-lists.md](views-lists.md) |
| Menus & Toolbars | 16 | [menus-toolbars.md](menus-toolbars.md) |
| Misc / X | 4 | [misc-x.md](misc-x.md) |
| Stock Market | 287 | [stock-market.md](stock-market.md) |
| Instrumentation | 66 | [instrumentation.md](instrumentation.md) |
| **Total** | **547** | |
Section assignment is defined in `widgets/tools/sections.py` — every
widget belongs to exactly one section. Every example in the docs was
built with `g++ -std=c++17 -I widgets/components/<Name> -lX11` and
is byte-identical to the code in the pages. Where a header leaves
something unclear, the docs say so instead of inventing an answer.
Test status (VPS, Debian 12, g++ 12.2, Xvfb; re-verified Nov 29, 2026 in
LightGUI on Ubuntu 26.04, g++ 15.2): all 547 demos build
with 0 warnings; the original 194: 193 draw (`GtkInvisible` is non-visual
by design); 125 show a visible click response (the rest are display-only
by design); all 194 survive keypresses and exit cleanly; zero crashes,
zero hangs. Stock Market section: OHLC 8/8, comparative/volume 15/15,
drawing 14/14, trend 85/85, momentum 85/85, volatility/other 80/80.
Palette self-test 547/547; layout placement 547/547 and
draw 547/547, all 547 alive at once. Full tables:
`widgets/test-results/results.md` and
`widgets/test-results/palette_layout_results.csv`.
Designer test status (Nov 29, 2026 tree): `make clean && make`, zero
warnings; palette self-test 547/547 (XFrame-only);
debugger suite 46/46; widget tests pass; code-window suite all pass;
palette-window tests 16/16; palette-icons tests 13/13; seam test
(`make test`) ALL PASS — 547 mapped, 0 unmapped; placement test
547/547 place, 547/547 draw.
## Repo layout
```
. # combined IDE repo (LightGUI)
├── ide # single launcher — starts the IDE
├── Makefile # top-level build: designer + widgets
├── README.md # this repo: IDE headline, library, designer
├── LICENSE # MIT, 2026 cnmcdee
├── DESIGN.md # designer design notes (all phases)
├── Makefile # top-level build: designer + widgets
├── src/ # designer, code view, debugger, CMake, generator
├── ui/designer.ui # main window + palette + inspector windows (Glade)
├── tests/ # self-test, matrix, debugger, theme, font, CMake
├── screenshots/ # 01–14: designer, code view, debugger, 3-window shots
├── widgets/ # XFrame library (547 widgets)
│ ├── components/<Name>/ # <Name>.h + main_<Name>.cpp + CMakeLists.txt
│ ├── core/xframe_core.h # canonical shared core
│ ├── palette/ # lightgui_palette (dead code, step 6)
│ ├── common/ # registry.h, ipc.h, ico.h
│ ├── icons/ # 547 real 16x16 .ico icons
│ ├── tools/ # docgen, gen_icons.py, gen_registry.py, sections.py
│ │ └── layout_to_lightgui.py # seam: layout file -> .fdj project
│ ├── tests/ # test_palette_layout.py, test_layout_to_lightgui.py
│ ├── test-results/ # results.md/csv, build.log, palette_layout_results.*
│ └── screenshots/ # all_widgets.png + one PNG per demo + palette/layout
└── docs/
├── index.md # XFrame shared contract + tools
├── ide.md # this file — the combined IDE guide
├── windows-dialogs.md # 28 widgets
├── containers-layout.md
├── buttons.md
├── display.md
├── text-entry.md
├── choosers.md
├── views-lists.md
├── menus-toolbars.md
├── misc-x.md
├── stock-market.md # 287 widgets
└── instrumentation.md # 66 widgets
└── screenshots/ # combined-IDE screenshots (ide_*.png)
```
## Troubleshooting
| Symptom | Cause / fix |
|---|---|
| `cannot open display` | No X server. Run under Xvfb (`Xvfb :99 -screen 0 1920x1080x24 &`, `DISPLAY=:99 …`) or a real X session. Give each project its own display number — never take over another project's display. |
| Designer opens but a window is missing | The palette, inspector, and code windows open together at startup; closing one only hides it. Reopen with **View → Widget Palette** / **View → Object Inspector** / **View → Code View**. Under bare Xvfb the palette has no title bar (expected); use the View menu, not the window decoration, to close it. |
| Code view is empty / shows "Generate a design first" | The code view shows the generated code for the current canvas. Design something, then **File → Generate C++/GTK…** (or reopen the view — it refreshes on open). |
| Breakpoint red dot does not appear | Dots come from the persisted breakpoint file (`~/.config/lightgui/debugger_bps.conf`). Gutter clicks toggle through the real session; a dot on a line whose file is not the one shown belongs to that file. Check the file exists and the code view is showing the same file. |
| Paused line is not red / variables are stale | The red line and the inspection pane follow the shared `GdbSession` (200 ms poll). If the target is running, the pane deliberately shows "running" and clears the line — that is the design, not a bug. If it never updates, the debugger window's session is not the one running the target. |
| `gdb` fails to start / target never runs | Check **Debug → Debugger Settings…**: `gdb_path` (default `/usr/bin/gdb`), and that the target was compiled with `-g`. The debugger reports a bad gdb path or a missing executable as a start failure. |
| CMake build reports failure | Read the log dialog: a missing or broken `CMakeLists.txt` or a compile error is reported as failure, never as success. **File → CMake Settings…** edits command, generator, build type, and build directory (`~/.config/lightgui/cmake.conf`). |
| Layout window does not pick up the palette selection | The palette writes `/tmp/lightgui-selection.txt`; the layout window polls it every 100 ms. If the file is stale, click a widget in the palette again. Both programs must run on the same machine/display. |
| Palette exits with "FATAL: not all icons loaded" | It needs all 547 icons from `icons/`. Set `LIGHTGUI_ICONS` to the icons directory, or run from the repo root so the `icons` / `../icons` candidates resolve. A missing icon is also drawn as a red box, never silently skipped. |
| A generated project does not compile | Generated projects are covered by the matrix (`tests/run_matrix.sh`): every type, property, enum, menu, and hostile string compiles with `-Wall -Wextra`, zero warnings. Re-generate from the current canvas; if it still fails, the compiler output names the file — the per-widget classes are one `.h`/`.cpp` pair each, so the fault is local to one widget class. |
| `GtkInvisible` draws nothing | By design — it is a non-visual widget. The test suite expects it blank. |
## Sources
Every claim above was checked against one of these (LightGUI tree as
of Nov 29, 2026, combined IDE in this repo):
- `DESIGN.md` — designer phases, debugger, CMake, Lazarus
widgets, fonts, themes/code view.
- `src/main.cpp` — window titles/sizes/parking, View/File/
Debug/Edit menus, 200 ms code-window poll, startup behaviour.
- `src/codeview.h` — gutter, folding, `#c00000` paused line,
inspection states.
- `src/debugger.h` / `debugger_ui.cpp` — GDB/MI backend,
breakpoint kinds, F5/F10/F11, settings and persistence paths.
- `src/preferences.h`, `theme.h`, `generator.h`, `Makefile`,
`ui/designer.ui` — fonts, themes, all-code generation, build.
- `docs/index.md` — XFrame contract, palette/layout tools,
test status.
- `widgets/palette/main_palette.cpp`, `widgets/layout/main_layout.cpp`,
`widgets/common/ipc.h` — palette/layout behaviour, selection file,
save paths, script commands.
- `widgets/README.md` (pre-combination) — build, test status,
screenshots.
Verified in the integration pass (VPS, Nov 29, 2026): the top-level
build, the `./ide` launcher, the repo-root + `widgets/` split paths
used above, the XFrame-only 547-entry palette
(`src/xframe_palette.h`, generated by
`widgets/tools/gen_xframe_palette_data.py`, covered by
`widgets/tests/test_combined_palette.py`: presence 547 exact,
self-test 547/547, real-mouse place of GtkAboutDialog in the embedded
canvas), and the
layout → designer seam (`widgets/tools/layout_to_lightgui.py`,
covered by `widgets/tests/test_layout_to_lightgui.py`).
Combined-IDE test results are in the repo README and in the
integration report; the per-half suites still apply unchanged (see
the test-status paragraphs above).