rigImGui 0.1.1
RigKit pack API - rigImGui
Loading...
Searching...
No Matches
rigkit::Mui Class Reference

rigImGui IMui fulfillment - default RigKit UI pack. More...

#include <rigImGui/src/Mui.h>

Public Types

using ChromeKernFn = float (*)(unsigned left, unsigned right, float sizePx, void* user)
 Extra advance (pixels at sizePx) for a chrome label pair.

Public Member Functions

bool saveCurrentTheme (const std::string &path, bool notify=true)
 Save / load custom theme JSON. Relative paths resolve under AppPaths::getThemesDir().
void applyUiPrefs ()
 Apply UiPrefs theme enum + optional themeFile / font settings.
bool reloadFonts ()
 Reload body font (+ icons) from UiPrefs. Defers if a frame is open.
void bindChromeKerning ()
 Bind pair kerning on the body ImFont (TTF kern or setChromeKernFn).
bool saveWorkspace (const std::string &name, bool notify=true) override
 Save the current dock layout and window visibility as a named workspace.
bool loadWorkspace (const std::string &name, bool notify=true) override
 Apply a saved workspace at the next frame boundary.
bool deleteWorkspace (const std::string &name)
 Remove a saved workspace. Standard and session imgui cannot be deleted.
std::string currentWorkspace () const override
 Active workspace name; empty when the session layout is unnamed.
std::vector< std::string > workspaceNames () const
 Saved workspace names, sorted (session imgui.ini excluded).
void addHostPanel (HostPanel panel)
 Create (if needed) and show one built-in host panel.
void addHostPanels (std::initializer_list< HostPanel > panels)
 Create and show several host panels.
void addAllHostPanels ()
 Create every host panel at sketch defaults.
void showPreferences ()
 Ensure Preferences exists and show it (File to Preferences...).
void showNotification (const std::string &message, NotificationType type=NotificationType::Info, float duration=-1.f)
 Show a transient notification in the host chrome.
void showAbout ()
 Help to About - RigKit version, app identity, loaded packs.
void setDockLayoutBuilder (std::function< void(ImGuiID dockspaceId)> fn)
 Build default docks once before DockSpace submits (same GetID scope).
void setWorkspaceDockBuilder (std::string name, std::function< void(ImGuiID dockspaceId)> fn)
 Dock seed for a named workspace.
void setFirstRunHostDockLayout (std::vector< std::string > extraRightWindows={})
 One-shot host dock layout used to seed Standard.ini when missing.
bool editModeEnabled () const
 Reads the engine's opt-in flag - Mui keeps no copy.
void openFilesDialog (const std::string &title, std::vector< std::string > filters, std::function< void(const std::vector< std::string > &)> onSelected)
 Open dialog that can return more than one file.
void setUnclaimedFileDropHandler (std::function< void(const std::vector< std::string > &paths)> handler)
 Files dropped on the window while no file dialog is open.
void registerFontAtlasHook (std::function< void(ImFontAtlas &atlas)> hook)
 Extra font-atlas hooks registered by the host.
int chromeKernPairCount () const
 Loaded kern pairs, or 0 when using a custom fn / none.
ImMidiMapper * midiMap ()
 Shared MIDI mapper owned by the host, or nullptr before the ImGui context exists.
void registerPreferencesDrawer (const std::string &id, const std::string &label, std::function< void()> draw, const std::string &group={})
 Extra Preferences sections (ImGui draw; not MSettings persistence).
void setGizmoDrawer (std::function< void(float x, float y, float w, float h, GizmoOp op)> drawer)
 Optional per-frame gizmo draw (apps wire MeshGizmo here).
bool centralViewRect (float &outX, float &outY, float &outW, float &outH) const override
 Window-client rect of the empty central dock (GL bed) when valid.
int addViewportOverlay (std::function< void(float x, float y, float w, float h)> draw)
 Draw on the GL bed during UI render (after dock layout).
void setMenuBarRightStatus (std::function< std::string()> text)
 Optional right-aligned status text in the host main menu bar.
bool view2DChrome () const
 Rulers and 2D handles.
bool gizmoChrome () const
 Select / Move / Rotate / Scale.
void setContentView (const View2D *view, const char *contentUnit="px")
 Bind the central bed's View2D so host rulers / 2D handles match the sheet.
void requestExportPng ()
 Queue a full-window PNG export after this frame's UI present.
void setQuitHandler (std::function< void()> handler)
 Let the app answer the Quit menu item (for example to ask about unsaved work).
std::string fpsStatusText () const
 Host FPS text for status bar / menu bar chrome (smoothed).

Static Public Attributes

static constexpr const char * kStandardWorkspace = "Standard"
 Built-in default workspace name (seeded once from the first settled layout).

Detailed Description

rigImGui IMui fulfillment - default RigKit UI pack.

Themes/fonts/style extras: ImGuiStyleKit.

Member Typedef Documentation

◆ ChromeKernFn

using rigkit::Mui::ChromeKernFn = float (*)(unsigned left, unsigned right, float sizePx, void* user)

Extra advance (pixels at sizePx) for a chrome label pair.

0 = no kern. Bind VarFont GetKernTablePairPx / GetGposPairExtraPx here. Absent = TTF kern table when present. ImGui-only — not on IMui.

Member Function Documentation

◆ addAllHostPanels()

void rigkit::Mui::addAllHostPanels ( )

Create every host panel at sketch defaults.

Installs first-run dock layout only when no builder is set and Standard.ini is missing (seed path). Later launches restore the session autosave instead.

◆ addHostPanel()

void rigkit::Mui::addHostPanel ( HostPanel panel)

Create (if needed) and show one built-in host panel.

Idempotent. Does not install a dock layout - call setFirstRunHostDockLayout / setDockLayoutBuilder separately when needed.

◆ addViewportOverlay()

int rigkit::Mui::addViewportOverlay ( std::function< void(float x, float y, float w, float h)> draw)

Draw on the GL bed during UI render (after dock layout).

Callback gets the bed rect in ImGui screen space. Returns a non-zero id; 0 is none.

◆ applyUiPrefs()

void rigkit::Mui::applyUiPrefs ( )

Apply UiPrefs theme enum + optional themeFile / font settings.

Font atlas rebuild is deferred until the next frame (safe mid-UI).

◆ centralViewRect()

bool rigkit::Mui::centralViewRect ( float & outX,
float & outY,
float & outW,
float & outH ) const
override

Window-client rect of the empty central dock (GL bed) when valid.

Subtracts main viewport origin so coords match GLFW cursor space.

◆ gizmoChrome()

bool rigkit::Mui::gizmoChrome ( ) const
inline

Select / Move / Rotate / Scale.

Edit Mode or a gizmo drawer.

◆ loadWorkspace()

bool rigkit::Mui::loadWorkspace ( const std::string & name,
bool notify = true )
override

Apply a saved workspace at the next frame boundary.

Restores dock layout and, when the file has [RigVisibility], hides every registered window then shows only those marked visible. Files without [Docking] keep that visibility swap and run the workspace dock seed registered via setWorkspaceDockBuilder.

Parameters
notifyWhen true, warn if the workspace file is missing.
Returns
False when the name is invalid or no such workspace exists.

◆ midiMap()

ImMidiMapper * rigkit::Mui::midiMap ( )
inline

Shared MIDI mapper owned by the host, or nullptr before the ImGui context exists.

Created in initImGui() so its widget value callback is installed on the live context; Mui::render() calls update(), drawStatus() and flushTwoWay() once per frame. Apps feed it with pushCC()/pushNoteOn() from their MIDI backend and configure output, persistence and editor extras on it. The host opens no MIDI device and saves no mapping file - both stay with the app.

◆ openFilesDialog()

void rigkit::Mui::openFilesDialog ( const std::string & title,
std::vector< std::string > filters,
std::function< void(const std::vector< std::string > &)> onSelected )

Open dialog that can return more than one file.

Ctrl+click, Shift+click, and Ctrl+A. Save and folder dialogs stay single-path. Cancel runs no callback. Lives on Mui: a second chrome is not expected to grow a multi-path dialog.

◆ registerFontAtlasHook()

void rigkit::Mui::registerFontAtlasHook ( std::function< void(ImFontAtlas &atlas)> hook)

Extra font-atlas hooks registered by the host.

Called during font load / reload, before the atlas is used. Multiple packs may register; order is FIFO.

◆ registerPreferencesDrawer()

void rigkit::Mui::registerPreferencesDrawer ( const std::string & id,
const std::string & label,
std::function< void()> draw,
const std::string & group = {} )

Extra Preferences sections (ImGui draw; not MSettings persistence).

Use for project-scoped UI that should appear under App > Preferences without writing rigkit_settings.json. A non-empty group nests the drawer as a collapsing header inside that group's page instead of adding a sidebar entry.

◆ saveWorkspace()

bool rigkit::Mui::saveWorkspace ( const std::string & name,
bool notify = true )
override

Save the current dock layout and window visibility as a named workspace.

Workspaces are snapshots stored as <name>.ini under AppPaths::getWorkspacesDir() (ImGui dock tree plus [RigVisibility]). They are explicit presets: startup restores the session autosave (imgui.ini); a named workspace only seeds the first session, before any autosave exists. Names match files on disk case-insensitively so Windows and Pi agree on one file per name.

Parameters
notifyWhen true, show a success/error notification.
Returns
False when the name is invalid or the file could not be written.

◆ setContentView()

void rigkit::Mui::setContentView ( const View2D * view,
const char * contentUnit = "px" )
inline

Bind the central bed's View2D so host rulers / 2D handles match the sheet.

Pass the live view each frame (or a stable pointer). contentUnit is the page unit ("in", "mm", "cm", "px"). Null view falls back to CAD cm.

◆ setDockLayoutBuilder()

void rigkit::Mui::setDockLayoutBuilder ( std::function< void(ImGuiID dockspaceId)> fn)
inline

Build default docks once before DockSpace submits (same GetID scope).

Called each frame until the builder clears itself / no-ops. Packs that need an OF-style first layout register here from setup().

◆ setFirstRunHostDockLayout()

void rigkit::Mui::setFirstRunHostDockLayout ( std::vector< std::string > extraRightWindows = {})

One-shot host dock layout used to seed Standard.ini when missing.

No-ops when a dock split already exists (restored ini / prior seed).

Parameters
extraRightWindowsOptional titles docked with Properties on the right. Call after those windows exist.

◆ setMenuBarRightStatus()

void rigkit::Mui::setMenuBarRightStatus ( std::function< std::string()> text)
inline

Optional right-aligned status text in the host main menu bar.

Called each frame while the menu bar is open. Empty string hides it.

◆ setQuitHandler()

void rigkit::Mui::setQuitHandler ( std::function< void()> handler)
inline

Let the app answer the Quit menu item (for example to ask about unsaved work).

With a handler set, Quit calls it instead of closing the window; the handler closes the window itself once quitting is fine. Does not intercept the window X or Alt+F4 - those are the app's to catch through the window close callback.

◆ setUnclaimedFileDropHandler()

void rigkit::Mui::setUnclaimedFileDropHandler ( std::function< void(const std::vector< std::string > &paths)> handler)

Files dropped on the window while no file dialog is open.

The open dialog still takes a drop when it is showing. Paths match Open. An empty handler clears it.

◆ setWorkspaceDockBuilder()

void rigkit::Mui::setWorkspaceDockBuilder ( std::string name,
std::function< void(ImGuiID dockspaceId)> fn )
inline

Dock seed for a named workspace.

Used when loadWorkspace applies an ini that has no [Docking] tree - visibility-only presets still get a correct first layout. Pass an empty function to remove a seed. Names match workspace files case-sensitively after resolveWorkspaceCase.

◆ showNotification()

void rigkit::Mui::showNotification ( const std::string & message,
NotificationType type = NotificationType::Info,
float duration = -1.f )

Show a transient notification in the host chrome.

Parameters
messageBody text (wrapped to Notification Width).
typeSeverity tint.
durationSeconds visible; negative uses UiPrefs::notificationSeconds.

◆ view2DChrome()

bool rigkit::Mui::view2DChrome ( ) const
inline

Rulers and 2D handles.

A bound content view or Edit Mode.


The documentation for this class was generated from the following file:
  • packs/rigImGui/src/Mui.h