From a849c199d970e153580c312a24cfdfa099bc7b69 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sat, 9 Apr 2022 13:29:41 -0700 Subject: Changeset: 4 More work on editor --- source/EditorResources.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'source/EditorResources.cpp') diff --git a/source/EditorResources.cpp b/source/EditorResources.cpp index 0f91523..722c1f1 100644 --- a/source/EditorResources.cpp +++ b/source/EditorResources.cpp @@ -1 +1,72 @@ #include "EditorResources.hpp" + +#include "EditorAttachmentImpl.hpp" +#include "EditorCore.hpp" +#include "EditorInspector.hpp" +#include "EditorNotification.hpp" +#include "EditorUtils.hpp" +#include "Shader.hpp" + +#include + +EditorContentBrowser::EditorContentBrowser(EditorInspector* inspector) + : mInspector{ inspector } { +} + +void EditorContentBrowser::Show() { + if (visible) { + ImGuiWindowFlags windowFlags; + if (docked) { + // Center window horizontally, align bottom vertically + auto& viewportSize = ImGui::GetMainViewport()->Size; + ImGui::SetNextWindowPos(ImVec2(viewportSize.x / 2, viewportSize.y), ImGuiCond_Always, ImVec2(0.5f, 1.0f)); + ImGui::SetNextWindowSizeRelScreen(0.8f, 0.5f); + windowFlags = ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse; + } else { + windowFlags = 0; + } + ImGui::Begin("Content Browser", &visible, windowFlags); + + ImGui::Splitter(true, kSplitterThickness, &splitterLeft, &splitterRight, kLeftPaneMinWidth, kRightPaneMinWidth); + + ImGui::BeginChild("LeftPane", ImVec2(splitterLeft - kPadding, 0.0f)); + + if (ImGui::Selectable("Settings", mPane == P_Settings)) { + mPane = P_Settings; + } + if (ImGui::Selectable("Shaders", mPane == P_Shader)) { + mPane = P_Shader; + } + + ImGui::EndChild(); // Window "LeftPane" + + ImGui::SameLine(0.0f, kPadding + kSplitterThickness + kPadding); + ImGui::BeginChild("RightPane"); // Fill remaining space + + switch (mPane) { + case P_Settings: { + ImGui::Checkbox("Docked", &docked); + } break; + + case P_Shader: { + auto& shaders = ShaderManager::instance->GetShaders(); + for (auto it = shaders.begin(); it != shaders.end(); ++it) { + auto name = it.key(); + auto shader = it.value().Get(); + + shader->GatherDetailsIfAbsent(); + auto details = shader->GetDetails(); + auto ea = static_cast(shader->GetEditorAttachment()); + + if (ImGui::Selectable(name, mInspector->GetCurrentTarget() == ea)) { + mInspector->SetCurrentTarget(ea); + } + } + } break; + } + + ImGui::EndChild(); // Window "RightPane" + + ImGui::End(); + } +} -- cgit v1.2.3-70-g09d2