diff --git a/SHADE_Engine/src/Editor/SHEditorUI.cpp b/SHADE_Engine/src/Editor/SHEditorUI.cpp index ba394f77..06c3f5c5 100644 --- a/SHADE_Engine/src/Editor/SHEditorUI.cpp +++ b/SHADE_Engine/src/Editor/SHEditorUI.cpp @@ -75,7 +75,7 @@ namespace SHADE bool SHEditorUI::BeginMenu(const std::string& label) { - return ImGui::BeginMenu(label.data()); + return ImGui::BeginMenu(label.data()); } bool SHEditorUI::BeginMenu(const std::string& label, const char* icon) @@ -143,7 +143,7 @@ namespace SHADE bool SHEditorUI::Selectable(const std::string& label) { - return ImGui::Selectable(label.data()); + return ImGui::Selectable(label.data()); } bool SHEditorUI::Selectable(const std::string& label, const char* icon) @@ -165,8 +165,10 @@ namespace SHADE if (isHovered) *isHovered = ImGui::IsItemHovered(); ImGui::SameLine(); - return ImGui::InputInt("##", &value, - 1, 10, + return ImGui::DragInt("##", &value, 0.001f, + std::numeric_limits::min(), + std::numeric_limits::max(), + "%d", ImGuiInputTextFlags_EnterReturnsTrue); } bool SHEditorUI::InputUnsignedInt(const std::string& label, unsigned int& value, bool* isHovered) @@ -190,31 +192,22 @@ namespace SHADE if (isHovered) *isHovered = ImGui::IsItemHovered(); ImGui::SameLine(); - return ImGui::InputFloat("##", &value, - 0.1f, 1.0f, "%.3f", + return ImGui::DragFloat("##", &value, 0.001f, + std::numeric_limits::lowest(), + std::numeric_limits::max(), + "%.3f", ImGuiInputTextFlags_EnterReturnsTrue); } bool SHEditorUI::InputDouble(const std::string& label, double& value, bool* isHovered) { - ImGui::Text(label.c_str()); - if (isHovered) - *isHovered = ImGui::IsItemHovered(); - ImGui::SameLine(); - return ImGui::InputDouble("##", &value, - 0.1, 1.0, "%.3f", - ImGuiInputTextFlags_EnterReturnsTrue); + float val = value; + const bool CHANGED = InputFloat(label, val, isHovered); + if (CHANGED) + { + value = static_cast(val); + } + return CHANGED; } - bool SHEditorUI::InputAngle(const std::string& label, double& value, bool* isHovered) - { - ImGui::Text(label.c_str()); - if (isHovered) - *isHovered = ImGui::IsItemHovered(); - ImGui::SameLine(); - return ImGui::InputDouble("##", &value, - 1.0, 45.0, "%.3f", - ImGuiInputTextFlags_EnterReturnsTrue); - } - bool SHEditorUI::InputSlider(const std::string& label, int min, int max, int& value, bool* isHovered /*= nullptr*/) { ImGui::Text(label.c_str()); diff --git a/SHADE_Engine/src/Editor/SHEditorUI.h b/SHADE_Engine/src/Editor/SHEditorUI.h index e0ea0521..4f11a025 100644 --- a/SHADE_Engine/src/Editor/SHEditorUI.h +++ b/SHADE_Engine/src/Editor/SHEditorUI.h @@ -219,17 +219,6 @@ namespace SHADE /// True if the value was changed. static bool InputDouble(const std::string& label, double& value, bool* isHovered = nullptr); /// - /// Creates a decimal field widget for double input with increments of higher - /// steps meant for angle variables. - ///
- /// Wraps up ImGui::InputDouble(). - ///
- /// Label used to identify this widget. - /// Reference to the variable to store the result. - /// Name))) { - System::Object^ obj = System::Activator::CreateInstance(listType); - iList->Add(obj); - registerUndoListAddAction(listType, iList, iList->Count - 1, obj); - } - - SHEditorUI::Indent(); - for (int i = 0; i < iList->Count; ++i) - { - SHEditorUI::PushID(i); - System::Object^ obj = iList[i]; - System::Object^ oldObj = iList[i]; - if (renderFieldEditor(std::to_string(i), obj, rangeAttrib)) + if (SHEditorUI::Button("Add Item")) { - iList[i] = obj; - registerUndoListChangeAction(listType, iList, i, obj, oldObj); + System::Object^ obj = System::Activator::CreateInstance(listType); + iList->Add(obj); + registerUndoListAddAction(listType, iList, iList->Count - 1, obj); } - SHEditorUI::SameLine(); - if (SHEditorUI::Button("-")) + for (int i = 0; i < iList->Count; ++i) { + SHEditorUI::PushID(i); System::Object^ obj = iList[i]; - iList->RemoveAt(i); - registerUndoListRemoveAction(listType, iList, i, obj); + System::Object^ oldObj = iList[i]; + if (renderFieldEditor(std::to_string(i), obj, rangeAttrib)) + { + iList[i] = obj; + registerUndoListChangeAction(listType, iList, i, obj, oldObj); + } + SHEditorUI::SameLine(); + if (SHEditorUI::Button("-")) + { + System::Object^ obj = iList[i]; + iList->RemoveAt(i); + registerUndoListRemoveAction(listType, iList, i, obj); + SHEditorUI::PopID(); + break; + } SHEditorUI::PopID(); - break; } - SHEditorUI::PopID(); } - SHEditorUI::Unindent(); } else {