Added open by default for component inspector toggle headers, Added drag/drop receiving for all uint32_t fields #315

Merged
srishamharan merged 6 commits from SP3-4-Editor into main 2023-01-18 04:05:49 +08:00
4 changed files with 16 additions and 45 deletions
Showing only changes of commit 34f22808ee - Show all commits

View File

@ -1,10 +1,11 @@
#pragma once
#include "SH_API.h"
#include "Editor/EditorWindow/SHPopUpWindow.h"
namespace SHADE
{
class SHSceneSavePrompt : SHPopUpWindow
class SHSceneSavePrompt : public SHPopUpWindow
{
public:
SHSceneSavePrompt():SHPopUpWindow("Save Scene As", true, 0, 0){}

View File

@ -5,6 +5,7 @@
//#==============================================================#
#include <string>
#include <imgui.h>
#include "SH_API.h"
namespace SHADE
{
@ -13,9 +14,11 @@ namespace SHADE
{
public:
SHPopUpWindow(std::string_view const& name, bool modal, ImGuiPopupFlags inPopupFlags, ImGuiWindowFlags inWindowFlags);
virtual ~SHPopUpWindow() = default;
virtual void Draw(){};
bool isOpen;
protected:
virtual bool Begin();
@ -23,7 +26,6 @@ namespace SHADE
std::string_view windowName;
ImGuiPopupFlags popupFlags;
ImGuiWindowFlags windowFlags;
bool isOpen;
bool isModal;
};
}

View File

@ -32,6 +32,9 @@
#include "EditorWindow/SHEditorWindowManager.h"
#include "EditorWindow/SHEditorWindowIncludes.h"
#include "EditorWindow/SHPopUpWindow.h"
#include "EditorWindow/EditorPopups/SHEditorPopups.h"
//#==============================================================#
//|| Library Includes ||
//#==============================================================#
@ -107,6 +110,9 @@ namespace SHADE
SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>();
//Add popup windows
SHEditorWindowManager::CreatePopupWindow<SHSceneSavePrompt>();
io = &ImGui::GetIO();
io->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
@ -163,7 +169,6 @@ namespace SHADE
popupWindow->Draw();
}
RenderSceneNamePrompt();
RenderUnsavedChangesPrompt();
//PollPicking();
@ -182,37 +187,6 @@ namespace SHADE
}
}
void SHEditor::RenderSceneNamePrompt() noexcept
{
if(isSceneNamePromptOpen)
{
ImGui::OpenPopup(sceneNamePromptName.data());
}
if(ImGui::BeginPopupModal(sceneNamePromptName.data(), &isSceneNamePromptOpen))
{
static std::string newSceneName{};
ImGui::Text("Enter new scene name");
ImGui::InputText("##name", &newSceneName);
ImGui::BeginDisabled(newSceneName.empty());
if(ImGui::Button("Save"))
{
SaveScene(newSceneName);
newSceneName.clear();
isSceneNamePromptOpen = false;
ImGui::CloseCurrentPopup();
}
ImGui::EndDisabled();
ImGui::SameLine();
if(ImGui::Button("Cancel"))
{
isSceneNamePromptOpen = false;
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
}
void SHEditor::RenderUnsavedChangesPrompt() noexcept
{
if(isUnsavedChangesPromptOpen)
@ -225,12 +199,12 @@ namespace SHADE
ImGui::Text("You have unsaved changes!");
if(ImGui::Button("Save"))
{
isSceneNamePromptOpen = true;
SHEditorWindowManager::GetPopupWindow<SHSceneSavePrompt>()->isOpen = true;
}
ImGui::SameLine();
if(ImGui::Button("Cancel"))
{
isUnsavedChangesPromptOpen = false;
SHEditorWindowManager::GetPopupWindow<SHSceneSavePrompt>()->isOpen = true;
ImGui::CloseCurrentPopup();
}
}
@ -568,7 +542,7 @@ namespace SHADE
if (newSceneName.empty())
{
//Prompt for scene name
isSceneNamePromptOpen = true;
SHEditorWindowManager::GetPopupWindow<SHSceneSavePrompt>()->isOpen = true;
return false;
}
//Else We have a new name
@ -649,7 +623,7 @@ namespace SHADE
editorState = SHEditor::State::STOP;
SHCommandManager::SwapStacks();
SHEventManager::BroadcastEvent<SHEditorStateChangeEvent>(STATE_CHANGE_EVENT, SH_EDITOR_ON_STOP_EVENT);
LoadScene(SHSceneManager::GetCurrentSceneAssetID());
LoadScene(editorConfig->workingSceneID);
}
void SHEditor::ProcessShortcuts()

View File

@ -37,8 +37,6 @@ namespace SHADE
class SHVkCommandBuffer;
class SHVkCommandPool;
/**
* @brief SHEditor static class contains editor variables and implementation of editor functions.
*
@ -144,8 +142,6 @@ namespace SHADE
*/
void Render();
void RenderSceneNamePrompt() noexcept;
void RenderUnsavedChangesPrompt() noexcept;
void InitLayout() noexcept;
@ -156,8 +152,6 @@ namespace SHADE
SHEventHandle onEditorStateChanged(SHEventPtr eventPtr);
bool isSceneNamePromptOpen = false;
bool isUnsavedChangesPromptOpen = false;
static constexpr std::string_view sceneNamePromptName = "Save scene as...";