Skip to content

Commit

Permalink
Dockspace Working
Browse files Browse the repository at this point in the history
  • Loading branch information
tomheeleynz committed Sep 12, 2021
1 parent 67d8620 commit 5907cd4
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 4 deletions.
26 changes: 22 additions & 4 deletions EnchantingTable/imgui.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
[Window][Debug##Default]
Pos=60,60
Size=400,400
Pos=176,125
Size=1088,877
Collapsed=0

[Window][Hello World]
Pos=29,42
Size=411,1092
Pos=1264,19
Size=336,1181
Collapsed=0
DockId=0x00000002,0

[Window][Hello World 2]
Pos=184,152
Size=610,842
Collapsed=0
DockId=0x39930E19,0

[Window][DockSpace Demo]
Pos=0,0
Size=1600,1200
Collapsed=0

[Docking][Data]
DockSpace ID=0x39930E19 Pos=184,152 Size=1072,842 CentralNode=1 Selected=0x4A17B156
DockSpace ID=0x3BC79352 Window=0x4647B76E Pos=0,19 Size=1600,1181 Split=X
DockNode ID=0x00000001 Parent=0x3BC79352 SizeRef=1262,1181 CentralNode=1
DockNode ID=0x00000002 Parent=0x3BC79352 SizeRef=336,1181 Selected=0x4A17B156

45 changes: 45 additions & 0 deletions EnchantingTable/src/EditorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,48 @@ void EditorLayer::OnUpdate(float deltaTime)

void EditorLayer::OnImGuiRender()
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////// Dock Space Setup
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static bool dockspaceOpen = true;
static bool opt_fullscreen_persistant = true;
bool opt_fullscreen = opt_fullscreen_persistant;
static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;

// because it would be confusing to have two docking targets within each others.
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
if (opt_fullscreen)
{
ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->Pos);
ImGui::SetNextWindowSize(viewport->Size);
ImGui::SetNextWindowViewport(viewport->ID);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
}

// When using ImGuiDockNodeFlags_PassthruCentralNode, DockSpace() will render our background and handle the pass-thru hole, so we ask Begin() to not render a background.
if (dockspace_flags & ImGuiDockNodeFlags_PassthruCentralNode)
window_flags |= ImGuiWindowFlags_NoBackground;

ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::Begin("DockSpace Demo", &dockspaceOpen, window_flags);
ImGui::PopStyleVar();

if (opt_fullscreen)
ImGui::PopStyleVar(2);

ImGuiIO& io = ImGui::GetIO();

if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
{
ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
}


ImGui::Begin("Hello World");
{
if (ImGui::Button("Test Button"))
Expand All @@ -101,4 +143,7 @@ void EditorLayer::OnImGuiRender()
}
}
ImGui::End();

//End Dockspace
ImGui::End();
}

0 comments on commit 5907cd4

Please sign in to comment.