SliderAngle: Added optional format argument to allow users customize precision and make localization. (#2150)

This commit is contained in:
Konstantin Podsvirov
2018-10-25 21:53:45 +03:00
committed by omar
parent 12c72d2893
commit faecf90383
3 changed files with 6 additions and 3 deletions

View File

@ -2391,10 +2391,12 @@ bool ImGui::SliderFloat4(const char* label, float v[4], float v_min, float v_max
return SliderScalarN(label, ImGuiDataType_Float, v, 4, &v_min, &v_max, format, power);
}
bool ImGui::SliderAngle(const char* label, float* v_rad, float v_degrees_min, float v_degrees_max)
bool ImGui::SliderAngle(const char* label, float* v_rad, float v_degrees_min, float v_degrees_max, const char* format)
{
if (format == NULL)
format = "%.0f deg";
float v_deg = (*v_rad) * 360.0f / (2*IM_PI);
bool value_changed = SliderFloat(label, &v_deg, v_degrees_min, v_degrees_max, "%.0f deg", 1.0f);
bool value_changed = SliderFloat(label, &v_deg, v_degrees_min, v_degrees_max, format, 1.0f);
*v_rad = v_deg * (2*IM_PI) / 360.0f;
return value_changed;
}