diff --git a/Engine/Source/Runtime/ImGui/ImGuiUtils.hpp b/Engine/Source/Runtime/ImGui/ImGuiUtils.hpp index d5c589fd..9391689a 100644 --- a/Engine/Source/Runtime/ImGui/ImGuiUtils.hpp +++ b/Engine/Source/Runtime/ImGui/ImGuiUtils.hpp @@ -16,6 +16,16 @@ static bool ImGuiBoolProperty(const char* pName, bool& value) return ImGui::Checkbox(pName, &value); } +static void Text(const char *pText, float fontScale = 1.0f) +{ + float old_fontScale = ImGui::GetFont()->Scale; + ImGui::GetFont()->Scale *= fontScale; + ImGui::PushFont(ImGui::GetFont()); + ImGui::Text(pText); + ImGui::GetFont()->Scale = old_fontScale; + ImGui::PopFont(); +} + template static bool ImGuiEnumProperty(const char* pName, EnumType& value) { @@ -26,7 +36,7 @@ static bool ImGuiEnumProperty(const char* pName, EnumType& value) ImGui::NextColumn(); ImGui::PushItemWidth(-1); - if (ImGui::BeginCombo("##combo", nameof::nameof_enum(value).data())) + if (ImGui::BeginCombo(pName, nameof::nameof_enum(value).data())) { auto enumCount = nameof::enum_count(); for (uint32_t enumIndex = 0U; enumIndex < enumCount; ++enumIndex) @@ -133,11 +143,14 @@ static bool ImGuiVectorProperty(const char* pName, T& value, cd::Unit unit = cd: value.Normalize(); } - ImGui::Columns(2); - ImGui::TextUnformatted(pName); - ImGui::NextColumn(); - ImGui::PushItemWidth(-1); + constexpr float labelIndetation = 10.0f; + ImGui::Indent(labelIndetation); + ImGuiUtils::Text(pName, 0.8f); + ImGui::Unindent(labelIndetation); + ImGui::PushItemWidth(350); + ImGui::SameLine(100.0f); + //std::string metricName = std::format("%.2f{}", cd::GetUnitName(unit)); std::string metricName = "%.2f"; metricName += cd::GetUnitName(unit); @@ -145,30 +158,27 @@ static bool ImGuiVectorProperty(const char* pName, T& value, cd::Unit unit = cd: float dragSpeed = (speed <= 0.0) ? (cd::Math::IsEqualToZero(delta) ? 1.0f : delta * 0.05f) : speed; if constexpr (std::is_same()) { - if (ImGui::DragFloat2(pName, value.begin(), dragSpeed, minValue.x(), maxValue.x(), metricName.c_str())) + if (ImGui::DragFloat2("##no_label", value.begin(), dragSpeed, minValue.x(), maxValue.x(), metricName.c_str())) { dirty = true; } } else if constexpr (std::is_same()) { - if (ImGui::DragFloat3(pName, value.begin(), dragSpeed, minValue.x(), maxValue.x(), metricName.c_str())) + if (ImGui::DragFloat3("##no_label", value.begin(), dragSpeed, minValue.x(), maxValue.x(), metricName.c_str())) { dirty = true; } } else if constexpr (std::is_same()) { - if (ImGui::DragFloat4(pName, value.begin(), dragSpeed, minValue.x(), maxValue.x(), metricName.c_str())) + if (ImGui::DragFloat4("##no_label", value.begin(), dragSpeed, minValue.x(), maxValue.x(), metricName.c_str())) { dirty = true; } } ImGui::PopItemWidth(); - ImGui::NextColumn(); - ImGui::Columns(1); - return dirty; } @@ -189,18 +199,18 @@ static bool ImGuiTransformProperty(const char* pName, cd::Transform& value) value.SetRotation(cd::Quaternion::FromPitchYawRoll(pitch, eularAngles.y(), eularAngles.z())); dirty = true; } + constexpr float labelIndetation = 10.0f; cd::Vec3f originScale = value.GetScale(); cd::Vec3f scale = originScale; - ImGui::TextUnformatted("Scale"); - ImGui::SameLine(); + ImGui::Indent(labelIndetation); + ImGuiUtils::Text("Scale", 0.8f); + ImGui::Unindent(labelIndetation); bool UniformScaleEnabled = engine::TransformComponent::DoUseUniformScale(); - ImGui::Checkbox("Uniform", &UniformScaleEnabled); - engine::TransformComponent::SetUseUniformScale(UniformScaleEnabled); ImGui::NextColumn(); - ImGui::PushItemWidth(-1); - + ImGui::PushItemWidth(350); + ImGui::SameLine(100.0f); if (ImGui::DragFloat3("##Scale", scale.begin(), 0.1f, 0.001f, 999.0f)) { if (!cd::Math::IsEqualTo(scale.x(), originScale.x())) @@ -258,6 +268,9 @@ static bool ImGuiTransformProperty(const char* pName, cd::Transform& value) ImGui::PopItemWidth(); ImGui::NextColumn(); + ImGui::SameLine(); + ImGui::Checkbox("Uniform", &UniformScaleEnabled); + engine::TransformComponent::SetUseUniformScale(UniformScaleEnabled); ImGui::Columns(1); return dirty;