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
2 changed files with 35 additions and 7 deletions
Showing only changes of commit 6b19a635e3 - Show all commits

View File

@ -77,7 +77,7 @@ namespace SHADE
ImGui::PushID(SHFamilyID<SHComponent>::GetID<T>());
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine();
if (ImGui::CollapsingHeader(componentType.get_name().data()))
if (ImGui::CollapsingHeader(componentType.get_name().data(), ImGuiTreeNodeFlags_DefaultOpen))
{
DrawContextMenu(component);
auto const& properties = componentType.get_properties();
@ -234,7 +234,7 @@ namespace SHADE
const auto componentType = rttr::type::get<SHRigidBodyComponent>();
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine();
if (ImGui::CollapsingHeader(componentType.get_name().data()))
if (ImGui::CollapsingHeader(componentType.get_name().data(), ImGuiTreeNodeFlags_DefaultOpen))
{
DrawContextMenu(component);
@ -328,7 +328,7 @@ namespace SHADE
const auto componentType = rttr::type::get(*component);
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine();
if (ImGui::CollapsingHeader(componentType.get_name().data()))
if (ImGui::CollapsingHeader(componentType.get_name().data(), ImGuiTreeNodeFlags_DefaultOpen))
{
DrawContextMenu(component);
@ -446,7 +446,7 @@ namespace SHADE
const auto componentType = rttr::type::get(*component);
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine();
if (ImGui::CollapsingHeader(componentType.get_name().data()))
if (ImGui::CollapsingHeader(componentType.get_name().data(), ImGuiTreeNodeFlags_DefaultOpen))
{
DrawContextMenu(component);
@ -478,7 +478,7 @@ namespace SHADE
const auto componentType = rttr::type::get(*component);
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine();
if (ImGui::CollapsingHeader(componentType.get_name().data()))
if (ImGui::CollapsingHeader(componentType.get_name().data(), ImGuiTreeNodeFlags_DefaultOpen))
{
DrawContextMenu(component);
Handle<SHMesh> const& mesh = component->GetMesh();
@ -536,7 +536,7 @@ namespace SHADE
const auto componentType = rttr::type::get(*component);
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
ImGui::SameLine();
if (ImGui::CollapsingHeader(componentType.get_name().data()))
if (ImGui::CollapsingHeader(componentType.get_name().data(), ImGuiTreeNodeFlags_DefaultOpen))
{
DrawContextMenu(component);
Handle<SHFont> const& font = component->GetFont();

View File

@ -13,6 +13,8 @@
#include "Command/SHCommandManager.h"
#include "SHImGuiHelpers.hpp"
#include "SH_API.h"
#include "Assets/SHAssetMacros.h"
#include "ECS_Base/SHECSMacros.h"
//#==============================================================#
//|| Library Includes ||
@ -454,7 +456,33 @@ namespace SHADE
ImGui::BeginGroup();
ImGui::PushID(label.data());
TextLabel(label);
const bool hasChange = ImGui::InputScalar("##dragScalar", data_type, &value);
bool hasChange = ImGui::DragScalar("##dragScalar", data_type, &value);
if constexpr(std::is_same_v<T, uint32_t>) //EID or Resource
{
if (SHDragDrop::BeginTarget())
{
if(AssetID * payload = SHDragDrop::AcceptPayload<T>(SHDragDrop::DRAG_RESOURCE))
{
value = *payload;
SHCommandManager::PerformCommand(std::reinterpret_pointer_cast<SHBaseCommand>(std::make_shared<SHCommand<T>>(get(), value, set)), false);
hasChange = true;
SHDragDrop::EndTarget();
}
else if (std::vector<EntityID>* payload = SHDragDrop::AcceptPayload<std::vector<EntityID>>(SHDragDrop::DRAG_EID))
{
value = payload->back();
SHCommandManager::PerformCommand(std::reinterpret_pointer_cast<SHBaseCommand>(std::make_shared<SHCommand<T>>(get(), value, set)), false);
hasChange = true;
SHDragDrop::EndTarget();
}
if(hasChange)
{
ImGui::PopID();
ImGui::EndGroup();
return true;
}
}
}
static bool startRecording = false;
if (hasChange)
{