Switch to imgui docking branch, vendor it
This commit is contained in:
54
src/main.cpp
54
src/main.cpp
@@ -1,6 +1,26 @@
|
||||
#include "platform/platform.h"
|
||||
#include "renderer/renderer.h"
|
||||
#include "imgui.h"
|
||||
#include "imgui_internal.h"
|
||||
|
||||
static void build_default_layout(ImGuiID dockspace_id)
|
||||
{
|
||||
ImGui::DockBuilderRemoveNode(dockspace_id);
|
||||
ImGui::DockBuilderAddNode(dockspace_id, ImGuiDockNodeFlags_DockSpace);
|
||||
ImGui::DockBuilderSetNodeSize(dockspace_id, ImGui::GetMainViewport()->Size);
|
||||
|
||||
ImGuiID center = dockspace_id;
|
||||
ImGuiID left = ImGui::DockBuilderSplitNode(center, ImGuiDir_Left, 0.15f, nullptr, ¢er);
|
||||
ImGuiID right = ImGui::DockBuilderSplitNode(center, ImGuiDir_Right, 0.20f, nullptr, ¢er);
|
||||
ImGuiID bottom = ImGui::DockBuilderSplitNode(center, ImGuiDir_Down, 0.25f, nullptr, ¢er);
|
||||
|
||||
ImGui::DockBuilderDockWindow("Browser", left);
|
||||
ImGui::DockBuilderDockWindow("Main", center);
|
||||
ImGui::DockBuilderDockWindow("Properties", right);
|
||||
ImGui::DockBuilderDockWindow("Log", bottom);
|
||||
|
||||
ImGui::DockBuilderFinish(dockspace_id);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@@ -27,6 +47,7 @@ int main(int argc, char **argv)
|
||||
|
||||
int32_t last_w = w, last_h = h;
|
||||
bool show_demo = true;
|
||||
bool first_frame = true;
|
||||
|
||||
while (platform_poll_events(window)) {
|
||||
platform_get_size(window, &w, &h);
|
||||
@@ -39,6 +60,39 @@ int main(int argc, char **argv)
|
||||
if (!renderer_begin_frame(renderer))
|
||||
continue;
|
||||
|
||||
// Full-window dockspace
|
||||
ImGuiID dockspace_id = ImGui::GetID("MainDockSpace");
|
||||
ImGui::DockSpaceOverViewport(dockspace_id, ImGui::GetMainViewport());
|
||||
|
||||
if (first_frame) {
|
||||
build_default_layout(dockspace_id);
|
||||
first_frame = false;
|
||||
}
|
||||
|
||||
// Left panel
|
||||
ImGui::Begin("Browser");
|
||||
ImGui::Text("Instruments");
|
||||
ImGui::Separator();
|
||||
ImGui::End();
|
||||
|
||||
// Main content
|
||||
ImGui::Begin("Main");
|
||||
ImGui::Text("Main content area");
|
||||
ImGui::End();
|
||||
|
||||
// Right panel
|
||||
ImGui::Begin("Properties");
|
||||
ImGui::Text("Details");
|
||||
ImGui::Separator();
|
||||
ImGui::End();
|
||||
|
||||
// Bottom panel
|
||||
ImGui::Begin("Log");
|
||||
ImGui::Text("Output / Log");
|
||||
ImGui::Separator();
|
||||
ImGui::End();
|
||||
|
||||
// Demo window
|
||||
if (show_demo)
|
||||
ImGui::ShowDemoWindow(&show_demo);
|
||||
|
||||
|
||||
@@ -276,6 +276,7 @@ static void init_imgui(Renderer *r)
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||
|
||||
ImGui::StyleColorsDark();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user