Skip to content

Commit 4a7f640

Browse files
committed
Fix: Editor now floats and can dock to main
1 parent 4f88dc1 commit 4a7f640

2 files changed

Lines changed: 34 additions & 25 deletions

File tree

imgui.ini

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ Collapsed=0
55
DockId=0xCCBD8CF7
66

77
[Window][DockSpace]
8-
Pos=0,0
98
Size=1280,800
109
Collapsed=0
1110

@@ -20,29 +19,33 @@ Size=476,221
2019
Collapsed=0
2120

2221
[Window][Explorer]
23-
Pos=0,24
22+
Pos=1052,363
2423
Size=226,776
2524
Collapsed=0
2625
DockId=0x00000005,0
2726

27+
[Window][MainDock]
28+
Pos=0,0
29+
Size=1280,800
30+
Collapsed=0
31+
2832
[Docking][Data]
29-
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,24 Size=1280,776 Split=X Selected=0xDF0EC458
30-
DockNode ID=0x00000005 Parent=0xCCBD8CF7 SizeRef=226,776 Selected=0x00F0E82E
31-
DockNode ID=0x00000006 Parent=0xCCBD8CF7 SizeRef=1052,776 Split=X
32-
DockNode ID=0x00000011 Parent=0x00000006 SizeRef=1306,851 Split=Y
33-
DockNode ID=0x0000000F Parent=0x00000011 SizeRef=1280,480 Split=Y
34-
DockNode ID=0x0000000D Parent=0x0000000F SizeRef=1280,472 Split=Y
35-
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1280,720 Split=Y
36-
DockNode ID=0x00000009 Parent=0x0000000B SizeRef=1280,686 Split=Y
37-
DockNode ID=0x00000007 Parent=0x00000009 SizeRef=1280,703 Split=Y
38-
DockNode ID=0x00000001 Parent=0x00000007 SizeRef=1280,386 Selected=0x00F0E82E
39-
DockNode ID=0x00000002 Parent=0x00000007 SizeRef=1280,261 Split=X
40-
DockNode ID=0x00000003 Parent=0x00000002 SizeRef=678,778 CentralNode=1 Selected=0xDF0EC458
41-
DockNode ID=0x00000004 Parent=0x00000002 SizeRef=600,778 Selected=0xD33228A6
42-
DockNode ID=0x00000008 Parent=0x00000009 SizeRef=1280,64 HiddenTabBar=1 Selected=0x2AB9DED9
43-
DockNode ID=0x0000000A Parent=0x0000000B SizeRef=1280,81 HiddenTabBar=1 Selected=0x2AB9DED9
44-
DockNode ID=0x0000000C Parent=0x0000000D SizeRef=1280,47 HiddenTabBar=1 Selected=0x2AB9DED9
45-
DockNode ID=0x0000000E Parent=0x0000000F SizeRef=1280,300 Selected=0xD33228A6
46-
DockNode ID=0x00000010 Parent=0x00000011 SizeRef=1280,300 Selected=0xD33228A6
47-
DockNode ID=0x00000012 Parent=0x00000006 SizeRef=612,851 Selected=0xD33228A6
33+
DockNode ID=0x00000005 Pos=1052,363 Size=226,776
34+
DockSpace ID=0xCCBD8CF7 Pos=0,24 Size=1280,776 Split=X Selected=0xDF0EC458
35+
DockNode ID=0x00000011 Parent=0xCCBD8CF7 SizeRef=1306,851 Split=Y
36+
DockNode ID=0x0000000F Parent=0x00000011 SizeRef=1280,480 Split=Y
37+
DockNode ID=0x0000000D Parent=0x0000000F SizeRef=1280,472 Split=Y
38+
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1280,720 Split=Y
39+
DockNode ID=0x00000009 Parent=0x0000000B SizeRef=1280,686 Split=Y
40+
DockNode ID=0x00000007 Parent=0x00000009 SizeRef=1280,703 Split=Y
41+
DockNode ID=0x00000001 Parent=0x00000007 SizeRef=1280,386 Selected=0x00F0E82E
42+
DockNode ID=0x00000002 Parent=0x00000007 SizeRef=1280,261 Split=X
43+
DockNode ID=0x00000003 Parent=0x00000002 SizeRef=678,778 CentralNode=1 Selected=0xDF0EC458
44+
DockNode ID=0x00000004 Parent=0x00000002 SizeRef=600,778 Selected=0xD33228A6
45+
DockNode ID=0x00000008 Parent=0x00000009 SizeRef=1280,64 HiddenTabBar=1 Selected=0x2AB9DED9
46+
DockNode ID=0x0000000A Parent=0x0000000B SizeRef=1280,81 HiddenTabBar=1 Selected=0x2AB9DED9
47+
DockNode ID=0x0000000C Parent=0x0000000D SizeRef=1280,47 HiddenTabBar=1 Selected=0x2AB9DED9
48+
DockNode ID=0x0000000E Parent=0x0000000F SizeRef=1280,300 Selected=0xD33228A6
49+
DockNode ID=0x00000010 Parent=0x00000011 SizeRef=1280,300 Selected=0xD33228A6
50+
DockNode ID=0x00000012 Parent=0xCCBD8CF7 SizeRef=612,851 Selected=0xD33228A6
4851

src/editor_app.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static void settings_load(AppSettings& s, const std::string& path) {
159159
// Version
160160
// ============================================================================
161161
std::string EditorApp::get_version() {
162-
return "pCode Editor version 0.2.28";
162+
return "pCode Editor version 0.2.29";
163163
}
164164

165165
// ============================================================================
@@ -1786,7 +1786,7 @@ void EditorApp::render() {
17861786
}
17871787
}
17881788

1789-
// Main dockspace window
1789+
// Main dockspace window with docking support
17901790
ImGuiViewport* viewport = ImGui::GetMainViewport();
17911791
ImGui::SetNextWindowPos(viewport->Pos);
17921792
ImGui::SetNextWindowSize(viewport->Size);
@@ -1802,21 +1802,27 @@ void EditorApp::render() {
18021802
ImGui::Begin("MainDock", nullptr, flags);
18031803
ImGui::PopStyleVar(3);
18041804

1805+
// Dockspace allows windows to dock into main
1806+
ImGuiID dockspace_id = ImGui::GetID("MainDockSpace");
1807+
ImGui::DockSpace(dockspace_id, ImVec2(0, 0), ImGuiDockNodeFlags_PassthruCentralNode);
1808+
18051809
// Menu and sidebar in main window
18061810
render_menu_bar();
18071811
render_sidebar();
18081812

18091813
ImGui::End();
18101814

1811-
// Floating editor window - can be dragged anywhere and docked
1815+
// Floating editor window - can float and dock to main window
18121816
ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x + 60, viewport->Pos.y + 60));
18131817
ImGui::SetNextWindowSize(ImVec2(800, 600));
18141818
ImGui::SetNextWindowViewport(viewport->ID);
18151819

1816-
ImGuiWindowFlags editor_flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings;
1820+
ImGuiWindowFlags editor_flags = ImGuiWindowFlags_NoSavedSettings;
18171821
editor_flags |= ImGuiWindowFlags_UnsavedDocument;
18181822

18191823
if (ImGui::Begin("Editor", nullptr, editor_flags)) {
1824+
// Register with dockspace for docking
1825+
ImGui::DockBuilderDockWindow("Editor", dockspace_id);
18201826
render_editor_area();
18211827
ImGui::End();
18221828
}

0 commit comments

Comments
 (0)