Refactor editor dock and panel chrome styling
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "Core/EditorEvents.h"
|
||||
#include "ComponentEditors/ComponentEditorRegistry.h"
|
||||
#include "ComponentEditors/IComponentEditor.h"
|
||||
#include "UI/PanelChrome.h"
|
||||
#include "Utils/UndoUtils.h"
|
||||
#include <imgui.h>
|
||||
#include <string>
|
||||
@@ -30,9 +31,10 @@ void InspectorPanel::OnSelectionChanged(const SelectionChangedEvent& event) {
|
||||
}
|
||||
|
||||
void InspectorPanel::Render() {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||
ImGui::Begin(m_name.c_str(), nullptr, ImGuiWindowFlags_None);
|
||||
ImGui::PopStyleVar();
|
||||
UI::PanelWindowScope panel(m_name.c_str());
|
||||
if (!panel.IsOpen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_selectionHandlerId && m_context) {
|
||||
m_selectionHandlerId = m_context->GetEventBus().Subscribe<SelectionChangedEvent>(
|
||||
@@ -60,17 +62,20 @@ void InspectorPanel::Render() {
|
||||
ImGui::TextColored(ImVec4(0.55f, 0.55f, 0.55f, 1.0f), "Select an object in Hierarchy");
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void InspectorPanel::RenderGameObject(::XCEngine::Components::GameObject* gameObject) {
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10.0f, 0.0f));
|
||||
ImGui::BeginChild("InspectorContent", ImVec2(0.0f, 0.0f), false, ImGuiWindowFlags_None);
|
||||
ImGui::PopStyleVar();
|
||||
UI::PanelContentScope content(
|
||||
"InspectorContent",
|
||||
UI::InspectorPanelContentPadding(),
|
||||
ImGuiWindowFlags_None,
|
||||
true,
|
||||
ImVec2(style.ItemSpacing.x, 0.0f));
|
||||
if (!content.IsOpen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x, 0.0f));
|
||||
|
||||
auto components = gameObject->GetComponents<::XCEngine::Components::Component>();
|
||||
for (auto* component : components) {
|
||||
RenderComponent(component, gameObject);
|
||||
@@ -80,13 +85,10 @@ void InspectorPanel::RenderGameObject(::XCEngine::Components::GameObject* gameOb
|
||||
ImGui::OpenPopup("AddComponent");
|
||||
}
|
||||
RenderAddComponentPopup(gameObject);
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
if (m_context->GetUndoManager().HasPendingInteractiveChange() && !ImGui::IsAnyItemActive()) {
|
||||
m_context->GetUndoManager().FinalizeInteractiveChange();
|
||||
}
|
||||
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void InspectorPanel::RenderAddComponentPopup(::XCEngine::Components::GameObject* gameObject) {
|
||||
|
||||
Reference in New Issue
Block a user