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
8 changes: 8 additions & 0 deletions .agents/docs/2026-10-25-unified-mwrap-checkpoint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Unified mwrap first release

Package/module: `mcpplibs.mwrap.imgui`; upstream version: `1.92.8`.

This checkpoint migrates wrapper identity while retaining upstream API names and SDK sources.
Default README is English with a mandatory Chinese counterpart; original section order is preserved.
Validation and release evidence are recorded in the PR and the index ecosystem ledger.
No old release tag or source resource is rewritten.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Mwrap identity and bilingual README contract
run: python3 tools/check_mwrap_release.py

- name: Install Xlings (Linux/macOS)
if: runner.os != 'Windows'
env:
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release
on:
push:
tags: ["mwrap-*"]
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write
actions: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Check tag, upstream version and bilingual entry pages
run: python3 tools/check_mwrap_release.py --tag "$GITHUB_REF_NAME"
- name: Require successful source CI at this exact commit
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
result=$(gh run list --repo "$GITHUB_REPOSITORY" --workflow ci.yml --commit "$GITHUB_SHA" --limit 1 --json status,conclusion --jq '.[0] | .status == "completed" and .conclusion == "success"')
test "$result" = true || { echo 'No successful source CI at the tag commit'; exit 1; }
- name: Build immutable source asset and publish
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#mwrap-}"
repo="${GITHUB_REPOSITORY#*/}"
asset="${repo}-${version}.tar.gz"
git archive --format=tar.gz --prefix="${repo}-${version}/" "$GITHUB_SHA" > "$RUNNER_TEMP/$asset"
(cd "$RUNNER_TEMP" && sha256sum "$asset" > "$asset.sha256")
if gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
echo 'Release already exists; refusing to change immutable assets'; exit 1
fi
extra=()
if [[ "$version" == *-rc* ]]; then extra+=(--prerelease); fi
gh release create "$GITHUB_REF_NAME" "$RUNNER_TEMP/$asset" "$RUNNER_TEMP/$asset.sha256" \
--repo "$GITHUB_REPOSITORY" --verify-tag --title "$repo $version" \
--notes "Module wrapper for upstream $version. New mwrap package identities become installable after mcpp-index publication; see the bilingual README for the tested support scope." "${extra[@]}"
54 changes: 54 additions & 0 deletions .github/workflows/templates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Actual project templates
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: templates-${{ github.ref }}
cancel-in-progress: true
env:
MCPP_VERSION: "2026.10.24.1"
jobs:
templates:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.mcpp/registry
key: template-registry-${{ github.repository }}-${{ env.MCPP_VERSION }}-${{ hashFiles('mcpp.toml') }}
restore-keys: |
template-registry-${{ github.repository }}-${{ env.MCPP_VERSION }}-
- name: Install current mcpp
shell: bash
run: |
archive="mcpp-${MCPP_VERSION}-linux-x86_64.tar.gz"
curl -L -fsS -o "$archive" "https://github.com/mcpp-community/mcpp/releases/download/v${MCPP_VERSION}/$archive"
tar -xzf "$archive"
root="$PWD/mcpp-${MCPP_VERSION}-linux-x86_64"
mkdir -p "$HOME/.mcpp/registry"
cp -a "$root/registry/." "$HOME/.mcpp/registry/"
echo "$root/bin" >> "$GITHUB_PATH"
- name: Install toolchains
run: |
mcpp toolchain install gcc 16.1.0
mcpp toolchain install llvm 23.1.3
- uses: actions/checkout@v4
with:
repository: mcpplibs/mcpp-index
ref: f0f8e48c396dad2ac67315f2ac54a197772e6555
path: .candidate-index
- name: Actual default scaffold without a display
run: env -u DISPLAY -u WAYLAND_DISPLAY python3 tools/test_template.py --toolchain llvm@23.1.3 --index .candidate-index
- name: Virtual display
run: sudo apt-get update && sudo apt-get install -y xvfb
- name: Actual window and docking scaffolds render three frames
env:
LIBGL_ALWAYS_SOFTWARE: "1"
run: |
xvfb-run -a python3 tools/test_template.py --template window --toolchain llvm@23.1.3 --run-arg=--smoke-test --index .candidate-index
xvfb-run -a python3 tools/test_template.py --template docking --toolchain llvm@23.1.3 --run-arg=--smoke-test --index .candidate-index
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": "2026.8.5.4"
"xim:mcpp": "2026.10.24.1"
}
}
107 changes: 35 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,101 +1,64 @@
# imgui

> Dear ImGui 的 C++23 模块化封装 — `import` 即用 · 跨平台 · 特性可插拔
> Dear ImGui through C++23 modules, with optional app and docking interfaces.

**English** · [简体中文](README.zh.md) · [Upstream](https://github.com/ocornut/imgui) · [Releases](https://github.com/mcpplibs/imgui-m/releases) · [mcpp](https://github.com/mcpp-community/mcpp) · [Index](https://github.com/mcpplibs/mcpp-index)

[![Release](https://img.shields.io/github/v/release/mcpplibs/imgui-m)](https://github.com/mcpplibs/imgui-m/releases)
[![C++23](https://img.shields.io/badge/C%2B%2B-23-blue.svg)](https://en.cppreference.com/w/cpp/23)
[![Module](https://img.shields.io/badge/module-ok-green.svg)](https://en.cppreference.com/w/cpp/language/modules)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![CI](https://github.com/mcpplibs/imgui-m/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/mcpplibs/imgui-m/actions/workflows/ci.yml)

| [mcpp 构建工具](https://github.com/mcpp-community/mcpp) · [包索引 mcpp-index](https://github.com/mcpp-community/mcpp-index) · [Dear ImGui 上游](https://github.com/ocornut/imgui) · [Issues](https://github.com/mcpplibs/imgui-m/issues) · [Releases](https://github.com/mcpplibs/imgui-m/releases) |
|:---:|
| [![CI](https://github.com/mcpplibs/imgui-m/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/mcpplibs/imgui-m/actions/workflows/ci.yml) |
Keep `ImGui::` APIs. Core, backend contracts and the optional app facade remain separate.

## 核心特性
## Modules

- **纯模块导入** — `import imgui.core;`,消费者代码零 `#include`
- **三档使用体验** — `imgui.app` 一行出窗口(默认档)/ `imgui.backend` 编译期契约(自动档)/ `imgui.backend.<impl>` 显式选后端(专家档),换后端 = 改一行 import + alias
- **特性可插拔** — `features = ["docking-full"]` 解锁面板停靠 + 拖出主窗口变独立 OS 窗口;`app` 档
开启 `imgui.app` facade(它是本仓库的发明,不属于上游 Dear ImGui,所以默认不给)
- **不绑定工具链、不打包 GL 驱动** — Linux / macOS / Windows 三平台 CI;GL 运行时由 mcpp 生态自动闭合
- `import mcpplibs.mwrap.imgui;`: Core API and macro mappings
- `import mcpplibs.mwrap.imgui.core;`: Dear ImGui contexts, frames and widgets
- `import mcpplibs.mwrap.imgui.app;`: Optional app frame loop; requires app
- `import mcpplibs.mwrap.imgui.backend;`: Backend contracts and shared types
- `import mcpplibs.mwrap.imgui.backend.headless;`: Display-independent backend
- `import mcpplibs.mwrap.imgui.backend.glfw_opengl3;`: GLFW/OpenGL3 window backend

## 快速开始
> More Modules API -> [Usage and API](docs/usage.md)

```bash
mcpp new myapp --template imgui && cd myapp && mcpp run # 窗口直接出现
# 模板随库分发、版本自动对齐:
# mcpp new --list-templates imgui # 列出库提供的模板
# mcpp new ide --template imgui:docking # IDE 式停靠布局(docking-full)
```
## Getting started

或在已有项目中手动接入:
```sh
mcpp new ui --template mcpplibs.mwrap.imgui@1.92.8
cd ui
mcpp run
```

```toml
[dependencies.ocornut]
imgui = { version = "1.92.8", features = ["app"] }
[dependencies]
mcpplibs.mwrap.imgui = "1.92.8"
```

```cpp
import imgui.core;
import imgui.app;

int main() {
return ImGui::App::run([] {
ImGui::Begin("hello");
ImGui::TextUnformatted("mcpp + imgui");
ImGui::End();
});
}
import mcpplibs.mwrap.imgui;
int main() { ImGui::CreateContext(); ImGui::DestroyContext(); }
```

## 模块一览

| 模块 | 说明 |
|---|---|
| `imgui.core` | Dear ImGui 核心:context / frame / widgets / draw-data |
| `imgui.app` | Tier-0 facade:平台默认后端 + 一行帧循环 |
| `imgui.backend` | 后端契约:`BackendApi` concept + 共享类型(`GlConfig`/`Error`/`FbSize`) |
| `imgui.backend.glfw_opengl3` | GLFW + OpenGL3 窗口后端(单一 `Backend` 类型) |
| `imgui.backend.headless` | 无显示后端:同一业务循环跑 CI / 逻辑测试 |

后端实现模块**不 re-export** `imgui.core`,消费者需各自显式 `import`;换后端只改 import 行与一行 `using Backend = ...;`。

## Features

| Feature | 说明 |
| Feature | Purpose |
|---|---|
| `docking` | 主窗口内面板停靠(Wayland 安全) |
| `viewports` | 面板拖出主窗口分离为独立 OS 窗口(X11 / Windows / macOS) |
| `docking-full` | 组合糖 = `["docking", "viewports"]`,完整 docking 体验 |
| `app` | App frame loop |
| `docking` | Dockable panels |
| `viewports` | Separate OS windows |
| `docking-full` | docking + viewports |

```toml
[dependencies.ocornut]
imgui = { version = "1.92.8", features = ["docking-full", "app"] }
```

docking/viewports 源码来自上游 docking tag(`compat.imgui 1.92.8-docking`,主线超集——特性关闭时行为与主线一致)。需 mcpp ≥ 0.0.47。
The provider is upstream `1.92.8-docking`; desktop templates need a display.

## 示例

| 示例 | 内容 |
|---|---|
| [`examples/app_minimal`](examples/app_minimal) | facade 三行出窗口 |
| [`examples/docking`](examples/docking) | IDE 式四分屏 + 面板分离为独立 OS 窗口 |
| [`examples/minimal_window`](examples/minimal_window) | 显式后端 API 的最小窗口(带诊断) |
| [`examples/glfw_opengl3`](examples/glfw_opengl3) | 显式后端的完整事件循环 |
| [`examples/basic`](examples/basic) | headless 核心 API(CI 可跑) |

```bash
cd examples/docking && mcpp run
```
## Examples

## 工具链与运行时
Default: display-independent context/frame checks. `:window` and `:docking` require a desktop.
[Examples](examples) · [Usage](docs/usage.md) · [Architecture](docs/architecture.md)

包不固定工具链(mcpp 解析环境默认,如 Linux glibc gcc);GL/GLX 运行时由生态包 `compat.glx-runtime` 透传闭合,不打包驱动。解析结果可用 `mcpp why` / `mcpp self doctor` 查看。
## Build and runtime

> [!NOTE]
> 早期版本,接口可能调整。问题与想法欢迎提 [issue](https://github.com/mcpplibs/imgui-m/issues)。
Linux, macOS and Windows CI. OpenGL/GLX runtime adapters do not redistribute the host GPU driver.

## License

封装代码 MIT;Dear ImGui 本体 MIT(经 `compat.imgui` 提供)。
[MIT](LICENSE); the upstream provider has its own MIT notice.
64 changes: 64 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# imgui

> Dear ImGui 的 C++23 模块封装,提供可选 app 与 docking 接口。

[English](README.md) · **简体中文** · [Upstream](https://github.com/ocornut/imgui) · [Releases](https://github.com/mcpplibs/imgui-m/releases) · [mcpp](https://github.com/mcpp-community/mcpp) · [Index](https://github.com/mcpplibs/mcpp-index)

[![C++23](https://img.shields.io/badge/C%2B%2B-23-blue.svg)](https://en.cppreference.com/w/cpp/23)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![CI](https://github.com/mcpplibs/imgui-m/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/mcpplibs/imgui-m/actions/workflows/ci.yml)

保留 `ImGui::` API,core、后端契约与可选 app facade 分层。

## 模块

- `import mcpplibs.mwrap.imgui;`: 核心 API 与宏映射
- `import mcpplibs.mwrap.imgui.core;`: Dear ImGui 上下文、帧与控件
- `import mcpplibs.mwrap.imgui.app;`: 可选应用帧循环,需 app feature
- `import mcpplibs.mwrap.imgui.backend;`: 后端契约与共享类型
- `import mcpplibs.mwrap.imgui.backend.headless;`: 无显示依赖后端
- `import mcpplibs.mwrap.imgui.backend.glfw_opengl3;`: GLFW/OpenGL3 窗口后端

> More Modules API -> [模块与 API](docs/usage.md)

## 快速开始

```sh
mcpp new ui --template mcpplibs.mwrap.imgui@1.92.8
cd ui
mcpp run
```

```toml
[dependencies]
mcpplibs.mwrap.imgui = "1.92.8"
```

```cpp
import mcpplibs.mwrap.imgui;
int main() { ImGui::CreateContext(); ImGui::DestroyContext(); }
```

## 特性

| Feature | 用途 |
|---|---|
| `app` | 应用帧循环 |
| `docking` | 面板停靠 |
| `viewports` | 独立系统窗口 |
| `docking-full` | 组合 docking 与 viewports |

供应者为上游 `1.92.8-docking`;桌面模板需要显示环境。

## 示例

默认模板验证无显示依赖的 context/frame;`:window` 与 `:docking` 需要桌面。
[示例](examples) · [使用](docs/usage.md) · [架构](docs/architecture.md)

## 工具链与运行时

Linux、macOS、Windows CI 覆盖;OpenGL/GLX 运行时适配不分发宿主 GPU 驱动。

## 许可证

[MIT](LICENSE);上游供应者保留其 MIT 通知。
26 changes: 13 additions & 13 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ upstream source ownership in compat packages.
## Goals

- Offer a three-tier consumer UX:
- Tier-0 `imgui.app` — convenience facade owning the full lifecycle.
- Tier-1 automatic via the `imgui.backend` contract (`BackendApi` concept).
- Tier-0 `mcpplibs.mwrap.imgui.app` — convenience facade owning the full lifecycle.
- Tier-1 automatic via the `mcpplibs.mwrap.imgui.backend` contract (`BackendApi` concept).
- Tier-2 explicit `imgui.backend.<impl>` module + alias.
- Let consumers use explicit module imports:
- `import imgui.app;` (Tier-0 facade; `export import`s `imgui.core`)
- `import imgui.core;`
- `import imgui.backend;` (generic abstraction layer: shared types + contract)
- `import imgui.backend.platform.glfw;`
- `import imgui.backend.renderer.opengl3;`
- `import imgui.backend.glfw_opengl3;`
- `import mcpplibs.mwrap.imgui.app;` (Tier-0 facade; `export import`s `mcpplibs.mwrap.imgui.core`)
- `import mcpplibs.mwrap.imgui.core;`
- `import mcpplibs.mwrap.imgui.backend;` (generic abstraction layer: shared types + contract)
- `import mcpplibs.mwrap.imgui.backend.platform.glfw;`
- `import mcpplibs.mwrap.imgui.backend.renderer.opengl3;`
- `import mcpplibs.mwrap.imgui.backend.glfw_opengl3;`
- Provide a uniform, compile-time-constrained backend surface so swapping a
backend is just a different import plus a one-line alias, with cross-platform
GL/GLSL defaults handled by the abstraction layer.
Expand Down Expand Up @@ -52,7 +52,7 @@ upstream source ownership in compat packages.

## Package Configuration

The root `mcpp.toml` declares package `imgui`, lists the module wrappers and
The root `mcpp.toml` declares package `mcpplibs.mwrap.imgui`, lists the module wrappers and
backend implementation translation units, and depends on compat packages:

```toml
Expand Down Expand Up @@ -83,17 +83,17 @@ a transitive dependency of `compat.glfw` on Linux), not bundled by this package.

## Module Wrappers

`src/core.cppm` adapts upstream `imgui.h` internally, then exports selected
`src/core.cppm` adapts upstream `mcpplibs.mwrap.imgui.h` internally, then exports selected
types and functions with explicit `using` declarations. This keeps consumer code
on `import imgui.core;` instead of requiring direct header usage.
on `import mcpplibs.mwrap.imgui.core;` instead of requiring direct header usage.

Backend module interfaces similarly adapt the official backend headers
internally and export explicit wrapper functions. The implementation `.cpp`
files compile upstream backend sources from `compat.imgui/backends` so consumers
do not need to copy backend sources into their own package.

`src/app.cppm` (`imgui.app`) is the Tier-0 facade. It `export import`s
`imgui.core` and privately imports `imgui.backend.glfw_opengl3`, exposing
`src/app.cppm` (`mcpplibs.mwrap.imgui.app`) is the Tier-0 facade. It `export import`s
`mcpplibs.mwrap.imgui.core` and privately imports `mcpplibs.mwrap.imgui.backend.glfw_opengl3`, exposing
`ImGui::App::run(...)` as an inline header-style template (the UI callback is a
template parameter, so there is no `<functional>` dependency). It drives the
full lifecycle so a consumer supplies only a per-frame UI callback.
Expand Down
Loading
Loading