1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-11-26 20:28:50 -05:00

bandaid for zero formatting issues

This commit is contained in:
epezent 2021-03-03 09:10:33 -06:00
parent 67e0876f89
commit b958abf459

View File

@ -644,10 +644,15 @@ void ShowLegendEntries(ImPlotPlot& plot, const ImRect& legend_bb, bool interacta
// Tick Utils // Tick Utils
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#define BASICALLY_ZERO 1e-16
void LabelTickDefault(ImPlotTick& tick, ImGuiTextBuffer& buffer) { void LabelTickDefault(ImPlotTick& tick, ImGuiTextBuffer& buffer) {
char temp[32]; char temp[32];
if (tick.ShowLabel) { if (tick.ShowLabel) {
tick.TextOffset = buffer.size(); tick.TextOffset = buffer.size();
if (ImAbs(tick.PlotPos) < BASICALLY_ZERO)
snprintf(temp, 32, "0");
else
snprintf(temp, 32, "%.10g", tick.PlotPos); snprintf(temp, 32, "%.10g", tick.PlotPos);
buffer.append(temp, temp + strlen(temp) + 1); buffer.append(temp, temp + strlen(temp) + 1);
tick.LabelSize = ImGui::CalcTextSize(buffer.Buf.Data + tick.TextOffset); tick.LabelSize = ImGui::CalcTextSize(buffer.Buf.Data + tick.TextOffset);
@ -3480,7 +3485,6 @@ void ShowColormapScale(double scale_min, double scale_max, float height) {
AddTicksDefault(range, 10, 0, ticks); AddTicksDefault(range, 10, 0, ticks);
ImGuiContext &G = *GImGui; ImGuiContext &G = *GImGui;
ImGuiWindow * Window = G.CurrentWindow; ImGuiWindow * Window = G.CurrentWindow;
if (Window->SkipItems) if (Window->SkipItems)