From 9e927df91ebf8977c6e12d085510ef2d36f31991 Mon Sep 17 00:00:00 2001 From: ozlb Date: Fri, 18 Sep 2020 00:35:14 +0200 Subject: [PATCH] ImPlotTimeFmt_HrMinSMs time format ImPlotTimeFmt_HrMinSMs, // 7:21:29.428pm (19:21:29.428) --- implot.cpp | 4 ++++ implot_internal.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/implot.cpp b/implot.cpp index 9c57229..bf38d69 100644 --- a/implot.cpp +++ b/implot.cpp @@ -845,6 +845,7 @@ int FormatTime12(const ImPlotTime& t, char* buffer, int size, ImPlotTimeFmt fmt) case ImPlotTimeFmt_SUs: return snprintf(buffer, size, ":%02d.%03d %03d", sec, ms, us); case ImPlotTimeFmt_SMs: return snprintf(buffer, size, ":%02d.%03d", sec, ms); case ImPlotTimeFmt_S: return snprintf(buffer, size, ":%02d", sec); + case ImPlotTimeFmt_HrMinSMs: return snprintf(buffer, size, "%d:%02d:%02d.%03d%s", hr, min, sec, ms, ap); case ImPlotTimeFmt_HrMinS: return snprintf(buffer, size, "%d:%02d:%02d%s", hr, min, sec, ap); case ImPlotTimeFmt_HrMin: return snprintf(buffer, size, "%d:%02d%s", hr, min, ap); case ImPlotTimeFmt_Hr: return snprintf(buffer, size, "%d%s", hr, ap); @@ -881,6 +882,7 @@ int FormatTime24(const ImPlotTime& t, char* buffer, int size, ImPlotTimeFmt fmt) case ImPlotTimeFmt_SUs: return snprintf(buffer, size, ":%02d.%03d %03d", sec, ms, us); case ImPlotTimeFmt_SMs: return snprintf(buffer, size, ":%02d.%03d", sec, ms); case ImPlotTimeFmt_S: return snprintf(buffer, size, ":%02d", sec); + case ImPlotTimeFmt_HrMinSMs: return snprintf(buffer, size, "%02d:%02d:%02d.%03d", hr, min, sec, ms); case ImPlotTimeFmt_HrMinS: return snprintf(buffer, size, "%02d:%02d:%02d", hr, min, sec); case ImPlotTimeFmt_HrMin: return snprintf(buffer, size, "%02d:%02d", hr, min); case ImPlotTimeFmt_Hr: return snprintf(buffer, size, "%02d:00", hr); @@ -905,6 +907,7 @@ inline float GetTimeLabelWidth12(ImPlotTimeFmt fmt) { case ImPlotTimeFmt_SUs: return ImGui::CalcTextSize(":88.888 888").x; // :29.428 552 case ImPlotTimeFmt_SMs: return ImGui::CalcTextSize(":88.888").x; // :29.428 case ImPlotTimeFmt_S: return ImGui::CalcTextSize(":88").x; // :29 + case ImPlotTimeFmt_HrMinSMs: return ImGui::CalcTextSize("88:88:88.888pm").x; // 7:21:29.428pm case ImPlotTimeFmt_HrMinS: return ImGui::CalcTextSize("88:88:88pm").x; // 7:21:29pm case ImPlotTimeFmt_HrMin: return ImGui::CalcTextSize("88:88pm").x; // 7:21pm case ImPlotTimeFmt_Hr: return ImGui::CalcTextSize("88pm").x; // 7pm @@ -929,6 +932,7 @@ inline float GetTimeLabelWidth24(ImPlotTimeFmt fmt) { case ImPlotTimeFmt_SUs: return ImGui::CalcTextSize(":88.888 888").x; // :29.428 552 case ImPlotTimeFmt_SMs: return ImGui::CalcTextSize(":88.888").x; // :29.428 case ImPlotTimeFmt_S: return ImGui::CalcTextSize(":88").x; // :29 + case ImPlotTimeFmt_HrMinSMs: return ImGui::CalcTextSize("88:88:88.888").x; // 19:21:29.428 case ImPlotTimeFmt_HrMinS: return ImGui::CalcTextSize("88:88:88").x; // 19:21:29 case ImPlotTimeFmt_HrMin: return ImGui::CalcTextSize("88:88").x; // 19:21 case ImPlotTimeFmt_Hr: return ImGui::CalcTextSize("88:00").x; // 19:00 diff --git a/implot_internal.h b/implot_internal.h index 4b93004..e6eb290 100644 --- a/implot_internal.h +++ b/implot_internal.h @@ -187,6 +187,7 @@ enum ImPlotTimeFmt_ { ImPlotTimeFmt_SUs, // :29.428 552 ImPlotTimeFmt_SMs, // :29.428 ImPlotTimeFmt_S, // :29 + ImPlotTimeFmt_HrMinSMs, // 7:21:29.428pm (19:21:29.428) ImPlotTimeFmt_HrMinS, // 7:21:29pm (19:21:29) ImPlotTimeFmt_HrMin, // 7:21pm (19:21) ImPlotTimeFmt_Hr, // 7pm (19:00) @@ -874,4 +875,4 @@ IMPLOT_API void PlotRects(const char* label_id, const float* xs, const float* ys IMPLOT_API void PlotRects(const char* label_id, const double* xs, const double* ys, int count, int offset = 0, int stride = sizeof(double)); IMPLOT_API void PlotRects(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset = 0); -} // namespace ImPlot \ No newline at end of file +} // namespace ImPlot