Adjusted design of list on scripts and all numbers now use sliders

This commit is contained in:
Kah Wei 2022-11-12 03:53:30 +08:00
parent d6764b4551
commit 6dbda12f30
3 changed files with 39 additions and 60 deletions

View File

@ -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<int>::min(),
std::numeric_limits<int>::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<float>::lowest(),
std::numeric_limits<float>::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);
}
bool SHEditorUI::InputAngle(const std::string& label, double& value, bool* isHovered)
float val = value;
const bool CHANGED = InputFloat(label, val, isHovered);
if (CHANGED)
{
ImGui::Text(label.c_str());
if (isHovered)
*isHovered = ImGui::IsItemHovered();
ImGui::SameLine();
return ImGui::InputDouble("##", &value,
1.0, 45.0, "%.3f",
ImGuiInputTextFlags_EnterReturnsTrue);
value = static_cast<double>(val);
}
return CHANGED;
}
bool SHEditorUI::InputSlider(const std::string& label, int min, int max, int& value, bool* isHovered /*= nullptr*/)
{
ImGui::Text(label.c_str());

View File

@ -219,17 +219,6 @@ namespace SHADE
/// <returns>True if the value was changed.</returns>
static bool InputDouble(const std::string& label, double& value, bool* isHovered = nullptr);
/// <summary>
/// Creates a decimal field widget for double input with increments of higher
/// steps meant for angle variables.
/// <br/>
/// Wraps up ImGui::InputDouble().
/// </summary>
/// <param name="label">Label used to identify this widget.</param>
/// <param name="value">Reference to the variable to store the result.</param>
/// <param name="isHovered>If set, stores the hover state of this widget.</param>
/// <returns>True if the value was changed.</returns>
static bool InputAngle(const std::string& label, double& value, bool* isHovered = nullptr);
/// <summary>
/// Creates an int slider field widget for double input.
/// <br/>
/// Wraps up ImGui::SliderInt().

View File

@ -178,17 +178,14 @@ namespace SHADE
RangeAttribute^ rangeAttrib = hasAttribute<RangeAttribute^>(field);
System::Collections::IList^ iList = safe_cast<System::Collections::IList^>(field->GetValue(object));
SHEditorUI::Text(Convert::ToNative(field->Name));
SHEditorUI::SameLine();
if (SHEditorUI::Button("+"))
if (SHEditorUI::CollapsingHeader(Convert::ToNative(field->Name)))
{
if (SHEditorUI::Button("Add Item"))
{
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);
@ -210,7 +207,7 @@ namespace SHADE
}
SHEditorUI::PopID();
}
SHEditorUI::Unindent();
}
}
else
{