| 2184 | |
| 2185 | template<typename TYPE> |
| 2186 | TYPE ImGui::RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, TYPE v) |
| 2187 | { |
| 2188 | IM_UNUSED(data_type); |
| 2189 | IM_ASSERT(data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double); |
| 2190 | const char* fmt_start = ImParseFormatFindStart(format); |
| 2191 | if (fmt_start[0] != '%' || fmt_start[1] == '%') // Don't apply if the value is not visible in the format string |
| 2192 | return v; |
| 2193 | |
| 2194 | // Sanitize format |
| 2195 | char fmt_sanitized[32]; |
| 2196 | ImParseFormatSanitizeForPrinting(fmt_start, fmt_sanitized, IM_ARRAYSIZE(fmt_sanitized)); |
| 2197 | fmt_start = fmt_sanitized; |
| 2198 | |
| 2199 | // Format value with our rounding, and read back |
| 2200 | char v_str[64]; |
| 2201 | ImFormatString(v_str, IM_ARRAYSIZE(v_str), fmt_start, v); |
| 2202 | const char* p = v_str; |
| 2203 | while (*p == ' ') |
| 2204 | p++; |
| 2205 | v = (TYPE)ImAtof(p); |
| 2206 | |
| 2207 | return v; |
| 2208 | } |
| 2209 | |
| 2210 | //------------------------------------------------------------------------- |
| 2211 | // [SECTION] Widgets: DragScalar, DragFloat, DragInt, etc. |
nothing calls this directly
no test coverage detected