Skip to content

Commit 92ef92d

Browse files
authored
feat: ship project templates (window default, docking) (#10)
templates/window (default): minimal imgui.app window. templates/docking: IDE-style DockBuilder layout with docking-full. Generated projects pin {{self.version}}, so the scaffold can never drift from the library version it shipped with. Consumed by mcpp's package templates: `mcpp new app --template imgui[:docking]` / `mcpp new --list-templates imgui` (requires mcpp > 0.0.48).
1 parent e9082ed commit 92ef92d

6 files changed

Lines changed: 61 additions & 0 deletions

File tree

templates/docking/mcpp.toml.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "{{project.name}}"
3+
version = "0.1.0"
4+
5+
[dependencies]
6+
{{self.name}} = { version = "{{self.version}}", features = ["docking-full"] }

templates/docking/src/main.cpp.in

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// {{project.name}} — generated from {{self.name}}@{{self.version}}:docking
2+
import imgui.core;
3+
import imgui.app;
4+
5+
int main() {
6+
return ImGui::App::run({.title = "{{project.name}}"}, [] {
7+
auto dockspace = ImGui::DockSpaceOverViewport();
8+
9+
static bool layout_built = false;
10+
if (!layout_built) {
11+
layout_built = true;
12+
const auto root = dockspace;
13+
auto left = ImGui::DockBuilderSplitNode(
14+
dockspace, ImGui::Dir_Left, 0.22f, nullptr, &dockspace);
15+
auto down = ImGui::DockBuilderSplitNode(
16+
dockspace, ImGui::Dir_Down, 0.28f, nullptr, &dockspace);
17+
auto right = ImGui::DockBuilderSplitNode(
18+
dockspace, ImGui::Dir_Right, 0.30f, nullptr, &dockspace);
19+
ImGui::DockBuilderDockWindow("Scene", left);
20+
ImGui::DockBuilderDockWindow("Console", down);
21+
ImGui::DockBuilderDockWindow("Inspector", right);
22+
ImGui::DockBuilderDockWindow("Viewport", dockspace);
23+
ImGui::DockBuilderFinish(root);
24+
}
25+
26+
ImGui::Begin("Scene"); ImGui::TextUnformatted("scene tree"); ImGui::End();
27+
ImGui::Begin("Viewport"); ImGui::TextUnformatted("drag tabs to re-split / detach"); ImGui::End();
28+
ImGui::Begin("Inspector"); ImGui::TextUnformatted("properties"); ImGui::End();
29+
ImGui::Begin("Console"); ImGui::TextUnformatted("logs"); ImGui::End();
30+
});
31+
}

templates/docking/template.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[template]
2+
description = "IDE-style docking layout + detachable OS windows (docking-full)"
3+
post_message = "`mcpp run`: four docked panes; drag a tab outside to detach it."

templates/window/mcpp.toml.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "{{project.name}}"
3+
version = "0.1.0"
4+
5+
[dependencies]
6+
{{self.name}} = "{{self.version}}"

templates/window/src/main.cpp.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// {{project.name}} — generated from {{self.name}}@{{self.version}}:window
2+
import imgui.core;
3+
import imgui.app;
4+
5+
int main() {
6+
return ImGui::App::run({.title = "{{project.name}}"}, [] {
7+
ImGui::Begin("{{project.name}}");
8+
ImGui::TextUnformatted("Hello from mcpp + imgui");
9+
ImGui::End();
10+
});
11+
}

templates/window/template.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[template]
2+
description = "Minimal imgui.app window"
3+
default = true
4+
post_message = "cd into the project and run `mcpp run` — the window appears."

0 commit comments

Comments
 (0)