Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,9 @@ jobs:
run: |
cd examples/glfw_opengl3
mcpp build

- name: Build docking example (features=["docking"])
shell: bash
run: |
cd examples/docking
mcpp build
2 changes: 1 addition & 1 deletion .xlings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"workspace": {
"xim:mcpp": "0.0.44"
"xim:mcpp": "0.0.48"
}
}
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ alias — the rest of the consumer code is identical. Cross-platform GL/GLSL
configuration (incl. macOS forward-compat) is handled by `RecommendedGlConfig()`,
which `CreateWindow`/`Init` use by default.

## Features

- `docking` — exports the Dock* API surface (`DockSpace`, `DockSpaceOverViewport`,
`SetNextWindowDockID`, `IsWindowDocked`, ...) and makes the `imgui.app` facade
enable `ImGuiConfigFlags_DockingEnable` automatically:

```toml
[dependencies]
imgui = { version = "0.0.4", features = ["docking"] }
```

See `examples/docking/`. Sources come from upstream's docking tag
(`compat.imgui 1.92.8-docking`, a superset of mainline — identical behavior
while the feature is off).

## Dependencies

The root package depends on:
Expand Down
8 changes: 8 additions & 0 deletions examples/docking/mcpp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "imgui-docking"
version = "0.1.0"
description = "Dockable-windows demo using the imgui `docking` feature"
license = "MIT"

[dependencies]
imgui = { path = "../..", features = ["docking"] }
26 changes: 26 additions & 0 deletions examples/docking/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Docking demo — `imgui = { ..., features = ["docking"] }`.
// The imgui.app facade auto-enables ImGuiConfigFlags_DockingEnable when the
// feature is active; DockSpaceOverViewport turns the whole window into a
// dock host, so the two panels below can be dragged into / split around it.
import imgui.core;
import imgui.app;

int main() {
return ImGui::App::run({.title = "mcpp imgui docking demo"}, [] {
const auto dockspace = ImGui::DockSpaceOverViewport();

// Pre-dock both panels into the dockspace on first run; they remain
// freely draggable/splittable afterwards.
ImGui::SetNextWindowDockID(dockspace, ImGui::Cond_FirstUseEver);
ImGui::Begin("Toolbox");
ImGui::TextUnformatted("Drag this panel onto the dockspace.");
ImGui::TextUnformatted("Docked: ");
ImGui::TextUnformatted(ImGui::IsWindowDocked() ? "yes" : "no");
ImGui::End();

ImGui::SetNextWindowDockID(dockspace, ImGui::Cond_FirstUseEver);
ImGui::Begin("Inspector");
ImGui::TextUnformatted("Split me against the Toolbox.");
ImGui::End();
});
}
8 changes: 7 additions & 1 deletion mcpp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ sources = [
"src/backends/opengl3_impl.cpp",
]

[features]
default = []
# docking: export the Dock* API surface and auto-enable
# ImGuiConfigFlags_DockingEnable in the imgui.app facade.
docking = []

[dependencies]
compat.imgui = "1.92.8"
compat.imgui = "1.92.8-docking"
compat.glfw = "3.4"
compat.opengl = "2026.05.31"

Expand Down
4 changes: 4 additions & 0 deletions src/app.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export namespace ImGui::App {

ImGuiContext* context = ImGui::CreateContext();
ImGui::SetCurrentContext(context);
#ifdef MCPP_FEATURE_DOCKING
// `docking` feature: enable dockable windows out of the box.
ImGui::GetIO().ConfigFlags |= ImGui::ConfigFlags_DockingEnable;
#endif

if (!Backend::Init(window)) {
const auto error = Backend::LastError();
Expand Down
22 changes: 22 additions & 0 deletions src/core.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,25 @@ export namespace ImGui {
using ::ImGui::SetCurrentContext;
using ::ImGui::TextUnformatted;
}

// Docking surface — gated by the `docking` feature
// (`imgui = { ..., features = ["docking"] }`). Requires the upstream docking
// sources (compat.imgui 1.92.8-docking); with the feature off, the docking
// sources behave exactly like mainline.
#ifdef MCPP_FEATURE_DOCKING
// (ImGuiID / ImGuiDockNodeFlags are plain-integer typedefs; GMF typedefs
// cannot be re-aliased under the same global name in a module. Consumers
// take DockSpace* return values with `auto`.)
export namespace ImGui {
using ::ImGui::DockSpace;
using ::ImGui::DockSpaceOverViewport;
using ::ImGui::SetNextWindowDockID;
using ::ImGui::GetWindowDockID;
using ::ImGui::IsWindowDocked;

// Unscoped global enumerators, re-exported as namespaced constants for
// module consumers.
inline constexpr int ConfigFlags_DockingEnable = ::ImGuiConfigFlags_DockingEnable;
inline constexpr int Cond_FirstUseEver = ::ImGuiCond_FirstUseEver;
}
#endif
Loading