Added open by default for component inspector toggle headers, Added drag/drop receiving for all uint32_t fields #315
|
@ -0,0 +1,33 @@
|
|||
#include "SHpch.h"
|
||||
#include "SHEditorPopups.h"
|
||||
#include "Editor/SHEditor.h"
|
||||
#include "misc/cpp/imgui_stdlib.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
void SHSceneSavePrompt::Draw()
|
||||
{
|
||||
if(Begin())
|
||||
{
|
||||
static std::string newSceneName{};
|
||||
ImGui::Text("Enter new scene name");
|
||||
ImGui::InputText("##name", &newSceneName);
|
||||
ImGui::BeginDisabled(newSceneName.empty());
|
||||
if (ImGui::Button("Save"))
|
||||
{
|
||||
editor->SaveScene(newSceneName);
|
||||
newSceneName.clear();
|
||||
isOpen = false;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel"))
|
||||
{
|
||||
isOpen = false;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include "Editor/EditorWindow/SHPopUpWindow.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
class SHSceneSavePrompt : SHPopUpWindow
|
||||
{
|
||||
public:
|
||||
SHSceneSavePrompt():SHPopUpWindow("Save Scene As", true, 0, 0){}
|
||||
void Draw() override;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
}
|
|
@ -4,5 +4,7 @@
|
|||
namespace SHADE
|
||||
{
|
||||
SHEditorWindowManager::EditorWindowMap SHEditorWindowManager::editorWindows{};
|
||||
SHEditorWindowManager::PopupWindowMap SHEditorWindowManager::popupWindows{};
|
||||
SHEditorWindowManager::EditorWindowID SHEditorWindowManager::windowCount{};
|
||||
SHEditorWindowManager::EditorWindowID SHEditorWindowManager::popupWindowCount{};
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include "SHEditorWindow.h"
|
||||
#include "SHPopUpWindow.h"
|
||||
#include "Tools/Logger/SHLog.h"
|
||||
|
||||
namespace SHADE
|
||||
|
@ -16,6 +17,10 @@ namespace SHADE
|
|||
using EditorWindowID = uint8_t;
|
||||
using EditorWindowPtr = std::unique_ptr<SHEditorWindow>;
|
||||
using EditorWindowMap = std::unordered_map<EditorWindowID, EditorWindowPtr>;
|
||||
|
||||
using PopupWindowPtr = std::unique_ptr<SHPopUpWindow>;
|
||||
using PopupWindowMap = std::unordered_map<EditorWindowID, PopupWindowPtr>;
|
||||
|
||||
/**
|
||||
* @brief Get ID for the Editor Window Type
|
||||
*
|
||||
|
@ -67,10 +72,63 @@ namespace SHADE
|
|||
return reinterpret_cast<T*>(editorWindows[GetEditorWindowID<T>()].get());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ID for the Popup Window Type
|
||||
*
|
||||
* @tparam T Type of Popup Window
|
||||
* @return EditorWindowID ID of Popup Window Type
|
||||
*/
|
||||
template <typename T, std::enable_if_t<std::is_base_of_v<SHPopUpWindow, T>, bool> = true>
|
||||
static EditorWindowID GetPopupWindowID()
|
||||
{
|
||||
static EditorWindowID id;
|
||||
static bool idCreated = false;
|
||||
if (!idCreated)
|
||||
{
|
||||
id = popupWindowCount++;
|
||||
idCreated = true;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create an Popup Window
|
||||
*
|
||||
* @tparam T Type of Popup Window to create
|
||||
*/
|
||||
template <typename T, std::enable_if_t<std::is_base_of_v<SHPopUpWindow, T>, bool> = true>
|
||||
static void CreatePopupWindow()
|
||||
{
|
||||
static bool isCreated = false;
|
||||
if (!isCreated)
|
||||
{
|
||||
popupWindows[GetPopupWindowID<T>()] = std::make_unique<T>();
|
||||
isCreated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SHLog::Warning("Attempt to create duplicate of Popup window type");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get pointer to the Editor Window
|
||||
*
|
||||
* @tparam T Type of editor window to retrieve
|
||||
* @return T* Pointer to the editor window
|
||||
*/
|
||||
template <typename T, std::enable_if_t<std::is_base_of_v<SHPopUpWindow, T>, bool> = true>
|
||||
static T* GetPopupWindow()
|
||||
{
|
||||
return reinterpret_cast<T*>(popupWindows[GetPopupWindowID<T>()].get());
|
||||
}
|
||||
|
||||
static EditorWindowMap editorWindows;
|
||||
static PopupWindowMap popupWindows;
|
||||
private:
|
||||
// Number of windows; used for Editor Window ID Generation
|
||||
static EditorWindowID windowCount;
|
||||
static EditorWindowID popupWindowCount;
|
||||
// Map of Editor Windows
|
||||
friend class SHEditor;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#include "SHpch.h"
|
||||
#include "SHPopUpWindow.h"
|
||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||
#include "Editor/SHEditor.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
SHPopUpWindow::SHPopUpWindow(std::string_view const& name, bool modal, ImGuiPopupFlags inPopupFlags, ImGuiWindowFlags inWindowFlags)
|
||||
:editor(nullptr), windowName(name), popupFlags(inPopupFlags), windowFlags(inWindowFlags), isOpen(false), isModal(modal)
|
||||
{
|
||||
editor = SHSystemManager::GetSystem<SHEditor>();
|
||||
}
|
||||
|
||||
bool SHPopUpWindow::Begin()
|
||||
{
|
||||
if (isOpen)
|
||||
ImGui::OpenPopup(windowName.data(), popupFlags);
|
||||
|
||||
return isModal ? ImGui::BeginPopupModal(windowName.data(), &isOpen, windowFlags) : ImGui::BeginPopup(windowName.data(), windowFlags);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
//#==============================================================#
|
||||
//|| STL Includes ||
|
||||
//#==============================================================#
|
||||
#include <string>
|
||||
#include <imgui.h>
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
class SHEditor;
|
||||
class SHPopUpWindow
|
||||
{
|
||||
public:
|
||||
SHPopUpWindow(std::string_view const& name, bool modal, ImGuiPopupFlags inPopupFlags, ImGuiWindowFlags inWindowFlags);
|
||||
|
||||
virtual void Draw(){};
|
||||
|
||||
protected:
|
||||
virtual bool Begin();
|
||||
|
||||
SHEditor* editor;
|
||||
std::string_view windowName;
|
||||
ImGuiPopupFlags popupFlags;
|
||||
ImGuiWindowFlags windowFlags;
|
||||
bool isOpen;
|
||||
bool isModal;
|
||||
};
|
||||
}
|
|
@ -150,7 +150,7 @@ namespace SHADE
|
|||
{
|
||||
(void)dt;
|
||||
NewFrame();
|
||||
for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values)
|
||||
for (auto const& window : SHEditorWindowManager::editorWindows | std::views::values)
|
||||
{
|
||||
if(window->isOpen)
|
||||
{
|
||||
|
@ -158,6 +158,11 @@ namespace SHADE
|
|||
}
|
||||
}
|
||||
|
||||
for(auto const& popupWindow : SHEditorWindowManager::popupWindows | std::views::values)
|
||||
{
|
||||
popupWindow->Draw();
|
||||
}
|
||||
|
||||
RenderSceneNamePrompt();
|
||||
RenderUnsavedChangesPrompt();
|
||||
//PollPicking();
|
||||
|
|
Loading…
Reference in New Issue