From 9a36fa9aadec1cd38ce322aa3c28c6b008308fa3 Mon Sep 17 00:00:00 2001 From: muit Date: Thu, 30 Jun 2022 20:49:01 +0200 Subject: [PATCH] Adde details pannel --- Libs/Editor/Include/Components/CTypeEditor.h | 11 +++- Libs/Editor/Include/Utils/DetailsPanel.h | 24 +++++++ .../Utils/{Properties.h => ElementsPanel.h} | 6 +- Libs/Editor/Include/Utils/ProjectManager.h | 2 +- Libs/Editor/Src/Systems/EditorSystem.cpp | 66 ++++++++++++------- Libs/Editor/Src/Utils/DetailsPanel.cpp | 40 +++++++++++ .../{Properties.cpp => ElementsPanel.cpp} | 20 +++--- Libs/Editor/Src/Utils/FunctionGraph.cpp | 11 +++- Libs/Editor/Src/Utils/ProjectManager.cpp | 2 +- 9 files changed, 136 insertions(+), 46 deletions(-) create mode 100644 Libs/Editor/Include/Utils/DetailsPanel.h rename Libs/Editor/Include/Utils/{Properties.h => ElementsPanel.h} (82%) create mode 100644 Libs/Editor/Src/Utils/DetailsPanel.cpp rename Libs/Editor/Src/Utils/{Properties.cpp => ElementsPanel.cpp} (93%) diff --git a/Libs/Editor/Include/Components/CTypeEditor.h b/Libs/Editor/Include/Components/CTypeEditor.h index cd063f5c..66a423d8 100644 --- a/Libs/Editor/Include/Components/CTypeEditor.h +++ b/Libs/Editor/Include/Components/CTypeEditor.h @@ -15,21 +15,26 @@ namespace rift { STRUCT(CTypeEditor, p::Struct, p::Struct_NotSerialized) - static const Name rightNode; + static const Name rightTopNode; + static const Name rightBottomNode; static const Name centralNode; ImGuiID dockspaceID = 0; DockSpaceLayout layout; bool pendingFocus = false; + bool showGraph = true; + bool showElements = true; + bool showDetails = true; AST::Id selectedPropertyId = AST::NoId; AST::Id pendingDeletePropertyId = AST::NoId; Nodes::EditorContext nodesEditor; - ImGuiTextFilter propertiesFilter; + ImGuiTextFilter elementsFilter; }; - inline const Name CTypeEditor::rightNode{"rightNode"}; + inline const Name CTypeEditor::rightTopNode{"rightTopNode"}; + inline const Name CTypeEditor::rightBottomNode{"rightBottomNode"}; inline const Name CTypeEditor::centralNode{"centralNode"}; } // namespace rift diff --git a/Libs/Editor/Include/Utils/DetailsPanel.h b/Libs/Editor/Include/Utils/DetailsPanel.h new file mode 100644 index 00000000..80c79ed2 --- /dev/null +++ b/Libs/Editor/Include/Utils/DetailsPanel.h @@ -0,0 +1,24 @@ +// Copyright 2015-2022 Piperift - All rights reserved + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace rift +{ + void DrawDetailsPanel(AST::Tree& ast, AST::Id typeId); +} // namespace rift diff --git a/Libs/Editor/Include/Utils/Properties.h b/Libs/Editor/Include/Utils/ElementsPanel.h similarity index 82% rename from Libs/Editor/Include/Utils/Properties.h rename to Libs/Editor/Include/Utils/ElementsPanel.h index 5078007d..976028d2 100644 --- a/Libs/Editor/Include/Utils/Properties.h +++ b/Libs/Editor/Include/Utils/ElementsPanel.h @@ -38,9 +38,5 @@ namespace rift void DrawVariable(TVariableAccessRef access, CTypeEditor& editor, AST::Id variableId); void DrawFunction(AST::Tree& ast, CTypeEditor& editor, AST::Id functionId); - void DrawVariables(TVariableAccessRef access, TransactionAccess transAccess, - CTypeEditor& editor, AST::Id typeId); - void DrawFunctions(AST::Tree& ast, CTypeEditor& editor, AST::Id typeId); - - void DrawProperties(AST::Tree& ast, AST::Id typeId); + void DrawElementsPanel(AST::Tree& ast, AST::Id typeId); } // namespace rift diff --git a/Libs/Editor/Include/Utils/ProjectManager.h b/Libs/Editor/Include/Utils/ProjectManager.h index d7bfd994..f0e304c3 100644 --- a/Libs/Editor/Include/Utils/ProjectManager.h +++ b/Libs/Editor/Include/Utils/ProjectManager.h @@ -1,6 +1,6 @@ // Copyright 2015-2022 Piperift - All rights reserved -#include "Utils/Properties.h" +#include "Utils/ElementsPanel.h" #include diff --git a/Libs/Editor/Src/Systems/EditorSystem.cpp b/Libs/Editor/Src/Systems/EditorSystem.cpp index ed73cd31..8fc0aef6 100644 --- a/Libs/Editor/Src/Systems/EditorSystem.cpp +++ b/Libs/Editor/Src/Systems/EditorSystem.cpp @@ -7,12 +7,14 @@ #include "Components/CTypeEditor.h" #include "DockSpaceLayout.h" #include "Editor.h" +#include "imgui.h" #include "imgui_internal.h" #include "Statics/SEditor.h" +#include "Utils/DetailsPanel.h" +#include "Utils/ElementsPanel.h" #include "Utils/FunctionGraph.h" #include "Utils/ModuleUtils.h" #include "Utils/ProjectManager.h" -#include "Utils/Properties.h" #include "Utils/TypeUtils.h" #include @@ -62,18 +64,21 @@ namespace rift::EditorSystem { auto& typeEditor = ast.Get(typeId); typeEditor.layout.OnBuild([](auto& builder) { - // =================================== // - // | // - // | // - // Central | Right // - // (Graph) |(Details)// - // | // - // | // - // =================================== // - builder.Split(builder.GetRootNode(), ImGuiDir_Right, 0.2f, CTypeEditor::rightNode, - CTypeEditor::centralNode); - - builder.GetNodeLocalFlags(CTypeEditor::rightNode) |= ImGuiDockNodeFlags_AutoHideTabBar; + // ==================================== // + // | // + // | Elements // + // Graph | // + // |----------// + // | Details // + // | // + // ==================================== // + Name rightNode{"rightNode"}; + builder.Split( + builder.GetRootNode(), ImGuiDir_Right, 0.25f, rightNode, CTypeEditor::centralNode); + + builder.Split(rightNode, ImGuiDir_Up, 0.4f, CTypeEditor::rightTopNode, + CTypeEditor::rightBottomNode); + builder.GetNodeLocalFlags(CTypeEditor::centralNode) |= ImGuiDockNodeFlags_CentralNode | i32(ImGuiDockNodeFlags_AutoHideTabBar); }); @@ -454,6 +459,7 @@ namespace rift::EditorSystem void DrawTypeMenuBar(AST::Tree& ast, AST::Id typeId) { + auto& typeEditor = ast.Get(typeId); if (UI::BeginMenuBar()) { if (UI::MenuItem(ICON_FA_SAVE, "CTRL+S")) @@ -470,8 +476,12 @@ namespace rift::EditorSystem } if (UI::BeginMenu("View")) { - if (Types::CanContainFunctions(ast, typeId) && UI::MenuItem("Graph")) {} - if (UI::MenuItem("Properties")) {} + if (Types::CanContainFunctions(ast, typeId)) + { + UI::MenuItem("Graph", nullptr, &typeEditor.showGraph); + } + UI::MenuItem("Elements", nullptr, &typeEditor.showElements); + UI::MenuItem("Details", nullptr, &typeEditor.showDetails); UI::EndMenu(); } UI::EndMenuBar(); @@ -482,13 +492,13 @@ namespace rift::EditorSystem { ZoneScoped; - TAccess, CType, CFileRef> typeEditors{ast}; - for (AST::Id typeId : ecs::ListAll(typeEditors)) + TAccess, CType, CFileRef> access{ast}; + for (AST::Id typeId : ecs::ListAll(access)) { ZoneScopedN("Draw Type"); - auto& typeEditor = typeEditors.Get(typeId); - const auto& file = typeEditors.Get(typeId); + auto& typeEditor = access.Get(typeId); + const auto& file = access.Get(typeId); bool isOpen = true; const String path = p::ToString(file.path); @@ -518,15 +528,21 @@ namespace rift::EditorSystem if (Types::CanContainFunctions(ast, typeId)) { Graph::DrawTypeGraph(ast, typeId, typeEditor); - } - Name propertiesNode = CTypeEditor::rightNode; - if (!Types::CanContainFunctions(ast, typeId)) + typeEditor.layout.BindNextWindowToNode( + CTypeEditor::rightBottomNode, ImGuiCond_Appearing); + DrawDetailsPanel(ast, typeId); + + typeEditor.layout.BindNextWindowToNode( + CTypeEditor::rightTopNode, ImGuiCond_Appearing); + DrawElementsPanel(ast, typeId); + } + else { - propertiesNode = DockSpaceLayout::rootNodeId; + typeEditor.layout.BindNextWindowToNode( + DockSpaceLayout::rootNodeId, ImGuiCond_Appearing); + DrawElementsPanel(ast, typeId); } - typeEditor.layout.BindNextWindowToNode(propertiesNode, ImGuiCond_Appearing); - DrawProperties(ast, typeId); } else { diff --git a/Libs/Editor/Src/Utils/DetailsPanel.cpp b/Libs/Editor/Src/Utils/DetailsPanel.cpp new file mode 100644 index 00000000..2c5380af --- /dev/null +++ b/Libs/Editor/Src/Utils/DetailsPanel.cpp @@ -0,0 +1,40 @@ +// Copyright 2015-2022 Piperift - All rights reserved + +#include "AST/Id.h" +#include "Components/CTypeEditor.h" +#include "DockSpaceLayout.h" +#include "imgui.h" +#include "UI/Style.h" +#include "UI/Widgets.h" +#include "Utils/EditorStyle.h" +#include "Utils/ElementsPanel.h" +#include "Utils/FunctionGraphContextMenu.h" +#include "Utils/Nodes.h" +#include "Utils/Widgets.h" + +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace rift +{ + void DrawDetailsPanel(AST::Tree& ast, AST::Id typeId) + { + auto& editor = ast.Get(typeId); + + if (!editor.showDetails) + { + return; + } + + const String windowName = Strings::Format("Details##{}", typeId); + if (UI::Begin(windowName.c_str(), &editor.showDetails)) {} + UI::End(); + } +} // namespace rift diff --git a/Libs/Editor/Src/Utils/Properties.cpp b/Libs/Editor/Src/Utils/ElementsPanel.cpp similarity index 93% rename from Libs/Editor/Src/Utils/Properties.cpp rename to Libs/Editor/Src/Utils/ElementsPanel.cpp index cc077fc4..6a1196f1 100644 --- a/Libs/Editor/Src/Utils/Properties.cpp +++ b/Libs/Editor/Src/Utils/ElementsPanel.cpp @@ -1,6 +1,6 @@ // Copyright 2015-2022 Piperift - All rights reserved -#include "Utils/Properties.h" +#include "Utils/ElementsPanel.h" #include "AST/Id.h" #include "Components/CTypeEditor.h" @@ -27,7 +27,6 @@ namespace rift { // using namespace EnumOperators; - void DrawVariable(TVariableAccessRef access, CTypeEditor& editor, AST::Id variableId) { auto* identifier = access.TryGet(variableId); @@ -37,7 +36,7 @@ namespace rift return; } String name = identifier->name.ToString(); - if (!editor.propertiesFilter.PassFilter(name.data(), name.data() + name.size())) + if (!editor.elementsFilter.PassFilter(name.data(), name.data() + name.size())) { return; } @@ -137,7 +136,7 @@ namespace rift return; } String name = identifier->name.ToString(); - if (!editor.propertiesFilter.PassFilter(name.data(), name.data() + name.size())) + if (!editor.elementsFilter.PassFilter(name.data(), name.data() + name.size())) { return; } @@ -237,15 +236,20 @@ namespace rift } } - void DrawProperties(AST::Tree& ast, AST::Id typeId) + void DrawElementsPanel(AST::Tree& ast, AST::Id typeId) { auto& editor = ast.Get(typeId); - const String windowName = Strings::Format("Properties##{}", typeId); - if (UI::Begin(windowName.c_str())) + if (!editor.showElements) + { + return; + } + + const String windowName = Strings::Format("Elements##{}", typeId); + if (UI::Begin(windowName.c_str(), &editor.showElements)) { UI::SetNextItemWidth(UI::GetContentRegionAvailWidth()); - editor.propertiesFilter.Draw("##filter"); + editor.elementsFilter.Draw("##filter"); if (Types::CanContainVariables(ast, typeId)) { diff --git a/Libs/Editor/Src/Utils/FunctionGraph.cpp b/Libs/Editor/Src/Utils/FunctionGraph.cpp index ef1ba95f..a56c6248 100644 --- a/Libs/Editor/Src/Utils/FunctionGraph.cpp +++ b/Libs/Editor/Src/Utils/FunctionGraph.cpp @@ -847,13 +847,18 @@ namespace rift::Graph void DrawTypeGraph(AST::Tree& ast, AST::Id typeId, CTypeEditor& typeEditor) { - typeEditor.layout.BindNextWindowToNode(CTypeEditor::centralNode, ImGuiCond_Appearing); + if (!typeEditor.showGraph) + { + return; + } + static String graphId; graphId.clear(); Strings::FormatTo(graphId, "Graph##{}", typeId); bool wantsToOpenContextMenu = false; - UI::Begin(graphId.c_str(), nullptr, ImGuiWindowFlags_NoCollapse); + typeEditor.layout.BindNextWindowToNode(CTypeEditor::centralNode, ImGuiCond_Appearing); + if (UI::Begin(graphId.c_str(), &typeEditor.showGraph, ImGuiWindowFlags_NoCollapse)) { Nodes::SetEditorContext(&typeEditor.nodesEditor); Nodes::GetCurrentContext()->canCreateLinks = Types::CanEditFunctionBodies(ast, typeId); @@ -920,8 +925,8 @@ namespace rift::Graph ImGui::OpenPopup("ContextMenu", ImGuiPopupFlags_AnyPopup); } DrawContextMenu(ast, typeId, hoveredNodeId, hoveredLinkId); - UI::End(); } + UI::End(); } void SetNodePosition(AST::Id id, v2 position) diff --git a/Libs/Editor/Src/Utils/ProjectManager.cpp b/Libs/Editor/Src/Utils/ProjectManager.cpp index 9f0541d7..c70a577b 100644 --- a/Libs/Editor/Src/Utils/ProjectManager.cpp +++ b/Libs/Editor/Src/Utils/ProjectManager.cpp @@ -1,7 +1,7 @@ // Copyright 2015-2022 Piperift - All rights reserved #include "Editor.h" -#include "Utils/Properties.h" +#include "Utils/ElementsPanel.h" #include #include