diff options
Diffstat (limited to 'source/EditorResources.cpp')
-rw-r--r-- | source/EditorResources.cpp | 74 |
1 files changed, 39 insertions, 35 deletions
diff --git a/source/EditorResources.cpp b/source/EditorResources.cpp index 722c1f1..c6d4d09 100644 --- a/source/EditorResources.cpp +++ b/source/EditorResources.cpp @@ -1,72 +1,76 @@ #include "EditorResources.hpp" -#include "EditorAttachmentImpl.hpp" #include "EditorCore.hpp" -#include "EditorInspector.hpp" #include "EditorNotification.hpp" #include "EditorUtils.hpp" #include "Shader.hpp" #include <imgui.h> -EditorContentBrowser::EditorContentBrowser(EditorInspector* inspector) - : mInspector{ inspector } { +EditorContentBrowser::EditorContentBrowser(EditorInstance* editor) + : mEditor{ editor } { } -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); +EditorContentBrowser::~EditorContentBrowser() { +} - ImGui::Splitter(true, kSplitterThickness, &splitterLeft, &splitterRight, kLeftPaneMinWidth, kRightPaneMinWidth); +void EditorContentBrowser::Show(bool* open) { + 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", open, windowFlags); - ImGui::BeginChild("LeftPane", ImVec2(splitterLeft - kPadding, 0.0f)); + 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(); - ImGui::EndChild(); // Window "LeftPane" - - ImGui::SameLine(0.0f, kPadding + kSplitterThickness + kPadding); - ImGui::BeginChild("RightPane"); // Fill remaining space - + 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: { + // TODO reload shaders while keeping existing references working + // if (ImGui::Button("Reload from disk")) { + // ShaderManager::instance->DiscoverShaders(); + // } + auto& shaders = ShaderManager::instance->GetShaders(); for (auto it = shaders.begin(); it != shaders.end(); ++it) { - auto name = it.key(); - auto shader = it.value().Get(); + auto name = it->first; + auto shader = it->second.Get(); - shader->GatherDetailsIfAbsent(); - auto details = shader->GetDetails(); - auto ea = static_cast<EaShader*>(shader->GetEditorAttachment()); + shader->GatherInfoIfAbsent(); + auto details = shader->GetInfo(); - if (ImGui::Selectable(name, mInspector->GetCurrentTarget() == ea)) { - mInspector->SetCurrentTarget(ea); + bool selected = mEditor->GetSelectedItPtr() == shader; + if (ImGui::Selectable(name.data(), selected)) { + mEditor->SelectIt(shader, EditorInstance::ITT_Shader); } } } break; } - - ImGui::EndChild(); // Window "RightPane" - - ImGui::End(); } + ImGui::EndChild(); + + ImGui::End(); } |