How raysan5/raygui works
Project type + purpose (what you are diagramming)
• Host Application (your tool/game/editor) owns the main loop.
• raylib (or another backend) provides rendering, windowing, input, font/texture primitives.
• Repo also includes examples (consumers) and build/project scaffolding (CMake/VS).
So the “system” is best expressed as (A) build-time packaging + (B) runtime frame loop interactions.
Core library
• src/raygui.h
The entire public API + implementation (when RAYGUI_IMPLEMENTATION is defined in exactly one translation unit). This is the core component.
Styles subsystem (data + loaders)
• styles/** and styles/README.md
• Each style folder has .rgs sources and generated style_*.h.
Examples (reference consumers / integration)
• examples/*/*.c and some local headers (gui_*_editor.h, gui_window_file_dialog.h, etc.)
Build + IDE integration
• projects/CMake/** (incl. FindRaylib.cmake)
• projects/VS2022/**
These define how raygui + raylib are located and built. This is “build-time architecture”.
Repo meta
• README.md, HISTORY.md, LICENSE
Not architectural components, but README contains the key constraints: header-only, immediate mode, raylib alignment.
Key README constraints to reflect
• Immediate-mode GUI: controls are re-described every frame; raygui keeps minimal internal state (no “retained widget tree”).
• Header-only / single compilation unit rule: RAYGUI_IMPLEMENTATION defined once.
• Dependency alignment: raygui master aligns with raylib master.
• Standalone backend supported: raygui can be adapted to other engines (explicit extension point).
Host App (C/C++)
2. raygui (src/raygui.h) (header-only; may be turned into raygui.c for shared lib builds)
Build System (CMake project / VS solution)
• Host App → includes → raygui.h
• Host App → links against → raylib
• raygui → uses → raylib API (rendering/input/font/texture primitives)
• Build System → resolves/locates → raylib (e.g., FindRaylib.cmake)
• Optional branch: “Build as shared library” path (copy/rename to raygui.c + -DRAYGUI_IMPLEMENTATION -DBUILD_LIBTYPE_SHARED)
Callouts to annotate:
• “Define RAYGUI_IMPLEMENTATION in exactly one TU”
• “Master branch alignment with raylib”
Goal: show the per-frame interactions (this is the core of immediate mode).
Nodes:
raygui style table / metrics / font
Edges:
• Style sources → (external tool: rGuiStyler) → generated headers / style files
• Host app → loads style at runtime → raygui style state
Callouts:
• “Default style auto-loaded”
Because this is a library, accuracy comes from showing *who calls whom*:
• Host App calls raygui (not the other way around).
• raygui depends on raylib/backend for:
• drawing primitives
• input state
• fonts/texture handling (as applicable)
optional mode:
• raygui ↔ Backend Adapter Layer ↔ Other graphics/input lib
And point to examples/standalone/raygui_custom_backend.h as the concrete hint in-tree that this seam exists.