1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-10-09 23:57:26 -04:00

ensure next plot data is initialized

This commit is contained in:
Evan Pezent 2020-06-03 09:50:06 -05:00
parent 6ea8b45d75
commit 6c9a720d2c

View File

@ -304,13 +304,23 @@ struct ImPlotState {
int CurrentYAxis; int CurrentYAxis;
}; };
struct ImNextPlotData { struct ImPlotNextPlotData {
ImPlotNextPlotData() {
HasXRange = false;
HasUserXTickLabels = false;
for (int i = 0; i < MAX_Y_AXES; ++i) {
HasYRange[i] = false;
HasUserYTickLabels[i] = false;
}
}
ImGuiCond XRangeCond; ImGuiCond XRangeCond;
ImGuiCond YRangeCond[MAX_Y_AXES]; ImGuiCond YRangeCond[MAX_Y_AXES];
bool HasXRange; bool HasXRange;
bool HasYRange[MAX_Y_AXES]; bool HasYRange[MAX_Y_AXES];
ImPlotRange X; ImPlotRange X;
ImPlotRange Y[MAX_Y_AXES]; ImPlotRange Y[MAX_Y_AXES];
bool HasUserXTickLabels;
bool HasUserYTickLabels[MAX_Y_AXES];
}; };
/// Holds Plot state information that must persist only between calls to BeginPlot()/EndPlot() /// Holds Plot state information that must persist only between calls to BeginPlot()/EndPlot()
@ -374,7 +384,7 @@ struct ImPlotContext {
ImPlotStyle Style; ImPlotStyle Style;
ImVector<ImGuiColorMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor() ImVector<ImGuiColorMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar() ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar()
ImNextPlotData NextPlotData; ImPlotNextPlotData NextPlotData;
// Digital plot item count // Digital plot item count
int DigitalPlotItemCnt; int DigitalPlotItemCnt;
int DigitalPlotOffset; int DigitalPlotOffset;
@ -740,7 +750,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons
ImGuiContext &G = *GImGui; ImGuiContext &G = *GImGui;
ImGuiWindow * Window = G.CurrentWindow; ImGuiWindow * Window = G.CurrentWindow;
if (Window->SkipItems) { if (Window->SkipItems) {
gp.NextPlotData = ImNextPlotData(); gp.NextPlotData = ImPlotNextPlotData();
return false; return false;
} }
@ -886,7 +896,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons
gp.BB_Frame = ImRect(Window->DC.CursorPos, Window->DC.CursorPos + frame_size); gp.BB_Frame = ImRect(Window->DC.CursorPos, Window->DC.CursorPos + frame_size);
ImGui::ItemSize(gp.BB_Frame); ImGui::ItemSize(gp.BB_Frame);
if (!ImGui::ItemAdd(gp.BB_Frame, 0, &gp.BB_Frame)) { if (!ImGui::ItemAdd(gp.BB_Frame, 0, &gp.BB_Frame)) {
gp.NextPlotData = ImNextPlotData(); gp.NextPlotData = ImPlotNextPlotData();
gp.CurrentPlot = NULL; gp.CurrentPlot = NULL;
if (!HasFlag(plot.Flags, ImPlotFlags_NoChild)) if (!HasFlag(plot.Flags, ImPlotFlags_NoChild))
ImGui::EndChild(); ImGui::EndChild();
@ -1736,7 +1746,7 @@ void EndPlot() {
// Null current plot/data // Null current plot/data
gp.CurrentPlot = NULL; gp.CurrentPlot = NULL;
// Reset next plot data // Reset next plot data
gp.NextPlotData = ImNextPlotData(); gp.NextPlotData = ImPlotNextPlotData();
// Pop ImGui::PushID at the end of BeginPlot // Pop ImGui::PushID at the end of BeginPlot
ImGui::PopID(); ImGui::PopID();
// End child window // End child window