From 69c91f18970ba61c01347ac1a7006d0ca9da352b Mon Sep 17 00:00:00 2001 From: Moritz Heinemann Date: Fri, 27 Dec 2024 16:48:46 +0100 Subject: [PATCH] cleanup object widgets header --- map/src/MapWindow/UI/ObjectWidgets.h | 73 ++++++++++++++++++---------- 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/map/src/MapWindow/UI/ObjectWidgets.h b/map/src/MapWindow/UI/ObjectWidgets.h index acdbf5f..4f7c35d 100644 --- a/map/src/MapWindow/UI/ObjectWidgets.h +++ b/map/src/MapWindow/UI/ObjectWidgets.h @@ -25,6 +25,7 @@ namespace s = SatisfactorySave; namespace Satisfactory3DMap::UI { + // Property Table bool BeginEditorTable(); void EndEditorTable(); // Need extra Push/Pop for style, because style must be set before BeginTable() and EndEditorTable() must be only @@ -33,7 +34,52 @@ namespace Satisfactory3DMap::UI { void PopEditorTableStyle(); template - inline void EditorSectionWrap(const char* label, Callable callable) { + void EditorSectionWrap(const char* label, Callable callable); + + // Tree Utils + bool TreeNodeSmall(const char* label, ImGuiTreeNodeFlags flags = 0); + bool EditorTreeNode(const char* label, ImGuiTreeNodeFlags flags = 0); + bool EditorTreeStartLeaf(const char* label, ImGuiTreeNodeFlags flags = 0); + void EditorTreeEndLeaf(); + + // Container Utils + template + void EditorList(const char* label, std::vector& list, Callable itemHandler); + template + void EditorMap(const char* label, s::TMap& map, Key_Callable keyHandler, + Value_Callable valueHandler); + template + void EditorOptional(const char* label, std::optional& opt, Callable itemHandler); + + // Text Widgets + void ClassOrPathButton(const std::string& name, const EventContext& ctx = {}); + void EditorShowSelectable(const char* label, const std::string& name, const EventContext& ctx = {}); + void EditorShowText(const char* label, const char* text); + + // Arithmetic Type Widgets + bool EditorBool(const char* label, bool& v); + bool EditorScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_step = nullptr, + const void* p_step_fast = nullptr, const char* format = nullptr, ImGuiInputTextFlags flags = 0); + + // UE Core Type Widgets + bool EditorName(const char* label, s::FName& name); + bool EditorObjectReference(const char* label, s::FObjectReferenceDisc& r, const EventContext& ctx = {}); + + // UE Math Type Widgets + bool EditorVector(const char* label, s::FVector& v); + bool EditorQuat(const char* label, s::FQuat& q); + template + bool EditorTransform(s::TTransform& t); + + // Struct Widgets + bool EditorLinearColor(const char* label, s::FLinearColor& c); + bool EditorInventoryItem(const char* label, s::FInventoryItem& i, const EventContext& ctx = {}); + bool EditorConveyorBeltItem(const char* label, s::FConveyorBeltItem& i, const EventContext& ctx = {}); + + // Template implementations + + template + void EditorSectionWrap(const char* label, Callable callable) { if (ImGui::CollapsingHeader(label, ImGuiTreeNodeFlags_DefaultOpen)) { PushEditorTableStyle(); if (BeginEditorTable()) { @@ -44,11 +90,6 @@ namespace Satisfactory3DMap::UI { } } - bool TreeNodeSmall(const char* label, ImGuiTreeNodeFlags flags = 0); - bool EditorTreeNode(const char* label, ImGuiTreeNodeFlags flags = 0); - bool EditorTreeStartLeaf(const char* label, ImGuiTreeNodeFlags flags = 0); - void EditorTreeEndLeaf(); - template void EditorList(const char* label, std::vector& list, Callable itemHandler) { if (EditorTreeNode(label, ImGuiTreeNodeFlags_DefaultOpen)) { @@ -93,26 +134,6 @@ namespace Satisfactory3DMap::UI { } } - void ClassOrPathButton(const std::string& name, const EventContext& ctx = {}); - void EditorShowSelectable(const char* label, const std::string& name, const EventContext& ctx = {}); - void EditorShowText(const char* label, const char* text); - - bool EditorBool(const char* label, bool& v); - bool EditorScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_step = nullptr, - const void* p_step_fast = nullptr, const char* format = nullptr, ImGuiInputTextFlags flags = 0); - - bool EditorName(const char* label, s::FName& name); - bool EditorObjectReference(const char* label, s::FObjectReferenceDisc& r, const EventContext& ctx = {}); - - bool EditorVector(const char* label, s::FVector& v); - bool EditorQuat(const char* label, s::FQuat& q); - - bool EditorLinearColor(const char* label, s::FLinearColor& c); - - bool EditorInventoryItem(const char* label, s::FInventoryItem& i, const EventContext& ctx = {}); - - bool EditorConveyorBeltItem(const char* label, s::FConveyorBeltItem& i, const EventContext& ctx = {}); - template bool EditorTransform(s::TTransform& t) { // For better UX we want to show euler angles in the UI with the full range of 0 to 360 degree on