Fix editor component view bug where fields from different components that have the same name clash

This commit is contained in:
Sri Sham Haran 2022-10-27 18:34:19 +08:00
parent 3518004266
commit c7e2116df0
5 changed files with 38 additions and 17 deletions

View File

@ -15,6 +15,7 @@
#include "Editor/SHEditorWidgets.hpp"
#include "Physics/Components/SHColliderComponent.h"
#include "Reflection/SHReflectionMetadata.h"
namespace SHADE
{
template<typename T, std::enable_if_t<std::is_base_of<SHComponent, T>::value, bool> = true>
@ -52,7 +53,7 @@ namespace SHADE
if (!component)
return;
const auto componentType = rttr::type::get<T>();
ImGui::PushID(component->GetEID());
ImGui::PushID(SHFamilyID<SHComponent>::GetID<T>());
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::PopID();
ImGui::SameLine();

View File

@ -293,6 +293,7 @@ namespace SHADE
//#==============================================================#
void SHEditor::InitBackend()
{
#ifdef SHEDITOR
if(ImGui_ImplSDL2_InitForVulkan(sdlWindow) == false)
{
SHLOG_CRITICAL("Editor backend initialisation; Failed to perform SDL initialisation for Vulkan")
@ -339,6 +340,7 @@ namespace SHADE
renderGraph->GetNode("ImGui Node")->GetSubpass("ImGui Draw")->AddExteriorDrawCalls([](Handle<SHVkCommandBuffer>& cmd) {
ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), cmd->GetVkCommandBuffer());
});
#endif
}
void SHEditor::PollPicking()

View File

@ -41,7 +41,7 @@ namespace SHADE
ImGui::BeginGroup();
auto itemSpacing = ImGui::GetStyle().ItemSpacing;
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f));
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.2f));
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f));
auto frameHeight = ImGui::GetFrameHeight();
@ -86,7 +86,7 @@ namespace SHADE
auto itemSpacing = ImGui::GetStyle().ItemSpacing;
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f));
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.2f));
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f));
auto frameHeight = ImGui::GetFrameHeight();
@ -127,7 +127,7 @@ namespace SHADE
ImGui::GetWindowDrawList()->AddRect(
frameRect.Min, frameRect.Max,
ImColor(ImGui::GetStyleColorVec4(ImGuiCol_Button)),
ImColor(ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled)),
halfFrame.x);
ImGui::PopClipRect();

View File

@ -54,13 +54,14 @@ namespace SHADE
if (wndData.isFullscreen)
{
dwExStyle = WS_EX_APPWINDOW | WS_EX_ACCEPTFILES;
dwExStyle = WS_EX_APPWINDOW;
dwStyle = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
dwExStyle |= WS_EX_ACCEPTFILES;
}
else
{
dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE | WS_EX_ACCEPTFILES;
dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
dwExStyle |= WS_EX_ACCEPTFILES;
if (wndData.frameEnabled)
{
dwStyle = WNDSTYLE::SHWS_WINDOWED;
@ -87,7 +88,7 @@ namespace SHADE
}
}
//DPI_AWARENESS_CONTEXT prevDPIContext = SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
DPI_AWARENESS_CONTEXT prevDPIContext = SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
RECT windowRect;
windowRect.left = wndData.x; //or CW_USEDEFAULT ?
@ -97,13 +98,16 @@ namespace SHADE
AdjustWindowRectEx(&windowRect, dwStyle, false, dwExStyle);
//Create window
wndHWND = CreateWindowEx(0, (LPWSTR) wndData.name.c_str(), (LPWSTR)wndData.title.c_str(), dwStyle, 0, 0, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, parent, NULL, hInstance, NULL);
wndHWND = CreateWindowEx(dwExStyle, (LPWSTR) wndData.name.c_str(), (LPWSTR)wndData.title.c_str(), dwStyle, 0, 0, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, parent, NULL, hInstance, NULL);
if (!wndHWND)
{
//DWORD err = GetLastError();
return false;
}
BOOL help = ChangeWindowMessageFilter (WM_DROPFILES, MSGFLT_ADD);
help &= ChangeWindowMessageFilter (WM_COPYDATA, MSGFLT_ADD);
help &= ChangeWindowMessageFilter (0x0049, MSGFLT_ADD);
if (wndData.isVisible)
{
@ -318,13 +322,13 @@ namespace SHADE
case WM_CREATE:
OnCreate(hwnd, reinterpret_cast<LPCREATESTRUCT>(wparam));
break;
case WM_QUIT:
case WM_CLOSE:
case WM_DESTROY:
OnDestroy();
return 0;
case WM_DROPFILES:
//OnFileDrop(reinterpret_cast<HDROP>(wparam));
OnFileDrop(reinterpret_cast<HDROP>(wparam));
break;
case WM_ENTERSIZEMOVE:
case WM_EXITSIZEMOVE:
@ -386,12 +390,25 @@ namespace SHADE
void SHWindow::OnDestroy()
{
OnClose();
DragAcceptFiles(wndHWND, false);
this->Destroy();
}
//void SHWindow::OnFileDrop(HDROP drop)
//{
//}
void SHWindow::OnFileDrop(HDROP drop)
{
int const numFiles = static_cast<int>(DragQueryFile(drop, 0xFFFFFFFF, nullptr, 0));
for(int i = 0; i < numFiles; ++i)
{
//char fileNameBuffer[MAX_PATH];
std::wstring fileNameBuffer;
fileNameBuffer.reserve(MAX_PATH);
DragQueryFile(drop, static_cast<UINT>(i), fileNameBuffer.data(), MAX_PATH);
std::string name(fileNameBuffer.begin(), fileNameBuffer.end());
SHLOG_INFO("Dropped: {}", name)
}
DragFinish(drop);
}
void SHWindow::OnSize([[maybe_unused]] UINT msg,[[maybe_unused]] UINT type, SIZE size)
{

View File

@ -2,6 +2,7 @@
#define SH_WINDOW_H
#include <Windows.h>
#include <shellapi.h>
#include <functional>
#include <unordered_map>
#include "SHWindowMap.h"
@ -10,7 +11,7 @@
namespace SHADE
{
constexpr uint16_t MAX_BUFFER = 1024;
enum WNDSTYLE : DWORD
{
SHWS_WINDOWED = WS_OVERLAPPEDWINDOW,
@ -168,7 +169,7 @@ namespace SHADE
void OnCreate(HWND hwnd, LPCREATESTRUCT create_struct);
void OnClose();
void OnDestroy();
//void OnFileDrop(HDROP drop);
void OnFileDrop(HDROP drop);
void OnSize(UINT msg, UINT type, SIZE size);
void OnPosChange(LPWINDOWPOS pos);
void OnPaint(HDC hdc, LPPAINTSTRUCT paint);