1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#include "EditorResources.hpp"
#include "EditorCore.hpp"
#include "EditorNotification.hpp"
#include "EditorUtils.hpp"
#include "Shader.hpp"
#include <imgui.h>
EditorContentBrowser::EditorContentBrowser(EditorInstance* editor)
: mEditor{ editor } {
}
EditorContentBrowser::~EditorContentBrowser() {
}
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::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::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->first;
auto shader = it->second.Get();
shader->GatherInfoIfAbsent();
auto details = shader->GetInfo();
bool selected = mEditor->GetSelectedItPtr() == shader;
if (ImGui::Selectable(name.data(), selected)) {
mEditor->SelectIt(shader, EditorInstance::ITT_Shader);
}
}
} break;
}
}
ImGui::EndChild();
ImGui::End();
}
|