Advertisement
LxrdKxnny

FrostEd.cpp

May 5th, 2023
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.46 KB | None | 0 0
  1. #include "FrostEd.h"
  2. #include "Modules/ModuleManager.h"
  3. #include "Logging/LogMacros.h"
  4. #include "Windows/WindowsApplication.h"
  5. #include "HierarchyModule.h"
  6.  
  7. #include "imgui.h"
  8.  
  9. void FFrostEd::Initialize()
  10. {
  11.     FROST_LOG_INFO("Initializing FrostEd...");
  12.  
  13.     // Editor initialization
  14.     // ...
  15.  
  16.     FHierarchyModule& HierarchyModule = FModuleManager::Get().LoadModule<FHierarchyModule>("Hierarchy");
  17.  
  18.     FWindowsApplication::Get()->GetLayerStack()->PushOverlay(new FFrostEd());
  19.  
  20.     FROST_LOG_INFO("Initialized FrostEd!");
  21. }
  22.  
  23. void FFrostEd::OnAttach()
  24. {
  25.     // Setup the editor
  26.     // ...
  27. }
  28.  
  29. void FFrostEd::OnImGuiRender()
  30. {
  31.     static bool OptFullscreen = true;
  32.     static bool OptPadding = false;
  33.  
  34.     static ImGuiDockNodeFlags DockspaceFlags = ImGuiDockNodeFlags_None;
  35.  
  36.     ImGuiWindowFlags WindowFlags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
  37.  
  38.     if (OptFullscreen)
  39.     {
  40.         const ImGuiViewport* Viewport = ImGui::GetMainViewport();
  41.  
  42.         ImGui::SetNextWindowPos(Viewport->WorkPos);
  43.         ImGui::SetNextWindowSize(Viewport->WorkSize);
  44.  
  45.         ImGui::SetNextWindowViewport(Viewport->ID);
  46.  
  47.         ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
  48.         ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
  49.  
  50.         WindowFlags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
  51.         WindowFlags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
  52.     }
  53.     else
  54.     {
  55.         DockspaceFlags &= ~ImGuiDockNodeFlags_PassthruCentralNode;
  56.     }
  57.  
  58.     if (DockspaceFlags & ImGuiDockNodeFlags_PassthruCentralNode)
  59.     {
  60.         WindowFlags |= ImGuiWindowFlags_NoBackground;
  61.     }
  62.  
  63.     if (!OptPadding)
  64.     {
  65.         ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
  66.     }
  67.  
  68.     ImGui::Begin("FrostEd", (bool*)true, WindowFlags);
  69.  
  70.     if (!OptPadding)
  71.     {
  72.         ImGui::PopStyleVar();
  73.     }
  74.  
  75.     if (OptFullscreen)
  76.     {
  77.         ImGui::PopStyleVar(2);
  78.     }
  79.  
  80.     ImGuiIO& IO = ImGui::GetIO();
  81.     if (IO.ConfigFlags & ImGuiConfigFlags_DockingEnable)
  82.     {
  83.         ImGuiID DockspaceID = ImGui::GetID("FrostEd");
  84.         ImGui::DockSpace(DockspaceID, ImVec2(0.0f, 0.0f), DockspaceFlags);
  85.     }
  86.  
  87.     // Render the editor
  88.     // ...
  89.  
  90.     ImGui::End();
  91. }
  92.  
  93. void FFrostEd::OnDetach()
  94. {
  95.     // Cleanup the editor
  96.     // ...
  97.  
  98.     FModuleManager::Get().UnloadModule("Hierarchy");
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement