Skip to content
rigkidPublic

About

RigKit UI pack (Dear ImGui + StyleKit)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

rigImGui

preview

rigImGui is the default RigKit UI pack.

cmake -S examples/host_shell -B examples/host_shell/build
cmake --build examples/host_shell/build --target host_shell

Format first-party src/ + examples/ with ./tools/format.sh. Install the pre-commit hook once: ./tools/install-hooks.sh. From a RigKit host checkout, ./tools/install-hooks.sh also wires every other pack git repo.

Also: sample_menubar, example_filebrowser, example_ImGuizmo.

It fulfills UI via IMui - part of a SUDE-ECS-UI fulfillment, not SUDE alone. Show/headless hosts may omit it and remain SUDE or SUDE-ECS.

Dear ImGui docking is a submodule of GitBruno/imgui (features/font-kerning-fn-v1.92.1) - v1.92.1 plus optional ImFont::KerningFn (ocornut/imgui#9516). After that PR merges, retarget third_party/imgui to ocornut/imgui @ docking. Other third_party/ trees stay vendored.

git submodule update --init --recursive

The pack extends RigKit with a complete UI system built on Dear ImGui. It provides:

  • Window Management: Create, manage, and organize ImGui windows
  • Host shell: Edit menu + undo bind, full screen (F11), File > Export PNG, shortcuts panel with remapping (persisted in user settings), status bar, open/save dialogs. Edit Mode (enableEditMode(true); panels hidden until Ctrl+E) adds Scene, Layers, and the Select / Move / Rotate / Scale tools (V W E R). A bound content view adds rulers (F2) and 2D handles. A gizmo drawer adds those same tool rows. Apps register their own Tools rows with registerToolAction.
  • Standard Windows: Pre-built windows for common tasks (debug, properties, logs)
  • Custom UI: Easy creation of custom windows and UI components
  • Portable panels: Visible CUiPanel / CUiGroup / CUiControl / CUiAction draw as tool windows or HUD overlays (presentUiPanels). Controls bind target + propertyKey. Actions fire SEvent.
  • ECS Integration: Seamless integration with RigKit's Entity-Component-System
  • Engine Access: Windows can access all RigKit managers through the engine

Apps wire 3D gizmos with Mui::setGizmoDrawer (see example-lowpoly). Undo history stays outside UI - IMui::setUndoStack. Ortho camera panels: registerOrthoViewMenu / openOrthoView (OrthoViewWindow).

Core Components

ImGuiPanel - dock panel base

Dear ImGui panel base (fulfillment type — not a RigKit host I*). Provides:

  • Immediate mode rendering with render() method
  • Visibility control with setVisible() and isVisible()
  • Engine access through setEngine() and getEngine()

MWindow - Window Manager

Manages all ImGuiPanel instances:

  • Window creation and destruction
  • Visibility management
  • Workspace save/load functionality
  • Engine integration for ECS access

Mui - UI Manager

The main UI system that orchestrates everything:

  • ImGui initialization and shutdown
  • Theme / font / style extras via ImGuiStyleKit
  • Notification and modal system
  • Event system integration
  • Window manager coordination

ImGuiStyleKit - Themes and fonts

  • Metrics, borders, rounding, and Dark / Light bases
  • Built-in bases: Dark (default charcoal/teal) and Light. Named palettes are JSON in themes/
  • Color-scheme JSON - shipped themes/ plus user saves under <userData>/user/themes/
  • Theme panel - Dark / Light + scheme combo with credits (full Style Editor is Preferences)
  • Full Style Editor - Preferences > Interface > ImGui::ShowStyleEditor() (Dear ImGui stock)
  • Custom font - Theme panel / Preferences: TTF path (under data/fonts or absolute) + size; Apply Font reloads atlas
  • Prefs (rigImGui.ui): Theme, Theme File, Font File, Font Size - File > Preferences...
  • Roboto + Font Awesome 5 shipped under fonts/ (also copied to repo assets/fonts/ for AppPaths)

Standard Windows

Built-in host panels are created on demand - ask for the ones you need:

HostPanel Window
Log Scrollable log with filtering
Windows Window visibility manager
Debug Debugging tools
Properties ECS component property editor
Scene Entity scene tree
Layers Layer list
Viewport GL viewport panel
Shortcuts Shortcut list + click-to-remap (persists under settings key shortcuts)
Theme Quick theme / JSON / font accents (full Style Editor is Preferences)
Preferences File > Preferences...

Ortho camera windows

Instantiable Top / Left / Right / Bottom panels (COrthoView + inactive CCamera). Any author app that already links SMeshPresent3D can register them — they do not live in an example:

#include "OrthoViewWindow.h"

if (auto* mui = dynamic_cast<rigkit::Mui*>(m_engine->getUiManager())) {
	rigkit::registerOrthoViewMenu(*mui); // View > Camera > Top / Bottom / Left / Right
	// or one shot: rigkit::openOrthoView(*mui, rigkit::ecs::COrthoView::Face::Top);
}

Do not add the mesh-present dependency to rigImGui pack.json — only apps that call these functions pull the window at link.

Example Usage

void MyApp::setup() {
    if (auto* mui = dynamic_cast<rigkit::Mui*>(m_engine->getUiManager())) {
        // Sketch apps: every host panel + first-run dock layout
        mui->addAllHostPanels();

        // Or pick a subset (tool apps):
        // mui->addHostPanel(rigkit::HostPanel::Properties);
        // mui->addHostPanels({rigkit::HostPanel::Properties, rigkit::HostPanel::Log});
    }
}

Creating Custom Windows

Basic Custom Window

class MyApp : public rigkit::IApp {
public:
    // Custom window as nested class
    class MyCustomWindow : public rigkit::ImGuiPanel {
    public:
        MyCustomWindow() : ImGuiPanel("My Window", ImGuiWindowFlags_None) {}

        void renderContents() override {
            ImGui::Text("Hello from my custom window!");
            if (ImGui::Button("Click me!")) {
                // Handle button click
            }
        }
    };

    void setup() override {
        auto* mui = dynamic_cast<rigkit::Mui*>(engine->getUiManager());
        auto* windowManager = mui ? mui->getWindowManager() : nullptr;

        // Create and show custom window
        auto myWindow = std::make_shared<MyCustomWindow>();
        windowManager->createWindow(myWindow);
        windowManager->showWindow("My Window");
    }
};

Advanced Custom Window

class MyApp : public rigkit::IApp {
public:
    // Advanced custom window as nested class
    class AdvancedWindow : public rigkit::ImGuiPanel {
    private:
        float m_value = 0.0f;
        std::string m_text;

    public:
        AdvancedWindow() : ImGuiPanel("Advanced Window", ImGuiWindowFlags_MenuBar) {}

        void renderContents() override {
            // Menu bar
            if (ImGui::BeginMenuBar()) {
                if (ImGui::BeginMenu("File")) {
                    if (ImGui::MenuItem("Save")) {
                        // Handle save
                    }
                    ImGui::EndMenu();
                }
                ImGui::EndMenuBar();
            }

            // Window contents
            ImGui::SliderFloat("Value", &m_value, 0.0f, 100.0f);
            ImGui::InputText("Text", &m_text);

            if (ImGui::Button("Reset")) {
                m_value = 0.0f;
                m_text.clear();
            }
        }
    };
};

Window Management

Standard Windows

Standard windows are automatically created by the pack and can be controlled via visibility:

// In your IApp::setup() method
void MyApp::setup() {
    // Show/hide standard windows
    setWindowVisibility("LogWindow", true);
    setWindowVisibility("DebugPanel", true);
    setWindowVisibility("PropertiesWindow", false);
}

Creating Custom Windows

// In your IApp::setup() method
void MyApp::setup() {
    auto* mui = dynamic_cast<rigkit::Mui*>(engine->getUiManager());
    auto* windowManager = mui ? mui->getWindowManager() : nullptr;

    // Create and show a custom window
    auto window = std::make_shared<MyCustomWindow>();
    windowManager->createWindow(window);
    windowManager->showWindow("My Window");
}

Window Visibility

// Show/hide specific windows
uiManager->setWindowVisibility("My Window", true);
uiManager->setWindowVisibility("Debug Panel", false);

// Show/hide all windows
uiManager->setWindowVisibilityAll(true);

Window Access

// Get window by name
auto window = windowManager->getWindow<MyWindow>("My Window");

// Get all window names
auto windowNames = uiManager->getAllWindowNames();

Theme Management

Built-in Themes

// Set theme
uiManager->setImGuiTheme(rigkit::ImGuiTheme::Dark);
uiManager->setImGuiTheme(rigkit::ImGuiTheme::Light);

Custom Themes

// Save current theme
uiManager->saveCurrentTheme("themes/my_theme.json");

// Load theme
uiManager->loadTheme("themes/my_theme.json");

Workspaces

Named dock layouts, Photoshop-style: snapshot the current layout and window visibility under a name, switch between snapshots from App > Workspace. Each workspace is a <name>.ini under AppPaths::getWorkspacesDir() (data/user/workspaces/) - ImGui dock data plus a [RigVisibility][Windows] section. The live session keeps autosaving to imgui.ini there.

On startup, rigImGui restores the session autosave (imgui.ini) - you get back exactly the windows and docks you quit with. Named workspaces are explicit presets: they apply only via App > Workspace (or loadWorkspace), except on the very first launch, where the last used name (settings key workspace) or Standard seeds the session. If Standard.ini is missing too, a one-shot dock builder (host setFirstRunHostDockLayout and/or the app’s setDockLayoutBuilder) seeds it from the first settled split, then that file becomes the durable default - not a hardcoded layout forever. A visibility-only preset (no [Docking] section) still rebuilds docks from seed registered with Mui::setWorkspaceDockBuilder. Workspace names match files on disk case-insensitively, so Windows and Pi agree on one file per name.

// Snapshot the current dock layout + which ImGuiPanels are visible
uiManager->saveWorkspace("plotting");

// Apply a saved layout (deferred to the next frame boundary)
uiManager->loadWorkspace("editing");

// Enumerate / remove (Standard cannot be deleted via the API/menu)
auto names = uiManager->workspaceNames();
uiManager->deleteWorkspace("old_layout");

Menu: App > Workspace lists saved workspaces (checkmark on the active one), Save Workspace As... prompts for a name, Delete Workspace confirms before removing (Standard is omitted). Loading a workspace that includes [RigVisibility] hides every registered window, then shows only those marked visible - panels not in the snapshot stay hidden.

Legacy .ini files without [RigVisibility] still restore docks; visibility is left unchanged until the next save writes the section.

Chrome rules

Host chrome (dock layout, notifications, prefs-driven spacing) stays inside the main viewport work rect and scales with DPI.

  • Prefer relative layout (WorkSize fractions, GetContentRegionAvail, AlwaysAutoResize) so you never multiply by scale.
  • When a design (1x) size is required, convert with uiPx / uiSize from UiDpi.h (reads style.FontScaleDpi after Mui::applyDpiStyle). Do not store a private m_dpiScale or push setDpiScale into child widgets.
  • Keep chrome inside GetMainViewport()->WorkPos / WorkSize: SetNextWindowPos with a pivot plus SetNextWindowSizeConstraints, never a corrective SetWindowPos after Begin. Absolute sizes that must stay on-screen can use uiClampToWork / uiWindowSize.
  • Default layout is the Standard workspace (Standard.ini), seeded once from a dock builder when missing; startup loads last used or Standard.
  • Chrome preferences live on UiPrefs (section rigImGui.ui) and must be read where they apply.
  • No emoji in UI text; IconFont glyphs are fine.

Notification System

Notifications

Duration defaults to Interface Notification Seconds when omitted (or negative). Width and placement follow Chrome rules and Notification Width.

// Show different types of notifications
uiManager->showNotification("Operation completed successfully!", 
                          rigkit::NotificationType::Success);
uiManager->showNotification("Warning: Low memory", 
                          rigkit::NotificationType::Warning);
uiManager->showNotification("Error: Failed to save", 
                          rigkit::NotificationType::Error);
uiManager->showNotification("Info: New update available", 
                          rigkit::NotificationType::Info);

Modal Dialogs

// Show modal with callback
uiManager->showModal("Confirm Delete", 
                    "Are you sure you want to delete this item?",
                    rigkit::NotificationType::Warning,
                    []() { /* Handle OK */ });

// Show simple modal
uiManager->showModal("Information", 
                    "This is an informational message.",
                    rigkit::NotificationType::Info);

Event System Integration

Mui reaches the bus through the engine it is attached to - nothing is pushed in:

auto& events = engine->getECSManager()->getEventSystem();

Apps register their own actions in IApp::registerUIActions(SEvent&).

Style

Format first-party src/ and examples/ with clang-format before commit (never third_party/).

./tools/format.sh
./tools/install-hooks.sh    # once per clone - pre-commit formats staged C/C++

Hooks only look for clang-format on PATH and warn, without formatting, when it is missing. Put it on PATH:

  • Windows: install LLVM (enable "Add LLVM to the system PATH"), or winget install LLVM.LLVM, then open a new shell. Confirm: clang-format --version.
  • macOS: brew install clang-format
  • Linux: sudo apt install clang-format

From a RigKit host checkout, ./tools/install-hooks.sh wires every pack repo. Full policy: RigKit packs Style.

API/docs

About

RigKit UI pack (Dear ImGui + StyleKit)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages