Skip to content

Commit 51930a5

Browse files
committed
fix imgui backward compat, YAxis[3], and add new demo benchmark option for LineG
1 parent 5ab78cb commit 51930a5

File tree

4 files changed

+26
-18
lines changed

4 files changed

+26
-18
lines changed

implot.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ You can read releases logs https://github.com/epezent/implot/releases for more d
8383
#define ImDrawFlags_RoundCornersAll ImDrawCornerFlags_All
8484
#endif
8585

86-
// Support for pre-1.84 versions. ImPool's GetSize() -> GetBufSize()
87-
#if (IMGUI_VERSION_NUM < 18303)
88-
#define GetBufSize GetSize // A little bit ugly since 'GetBufSize' could technically be used elsewhere (but currently isn't). Could use a proxy define if needed.
89-
#endif
90-
9186
// Global plot context
9287
ImPlotContext* GImPlot = NULL;
9388

@@ -4483,7 +4478,7 @@ void ShowMetricsWindow(bool* p_popen) {
44834478
if (ImHasFlag(plot->Flags, ImPlotFlags_YAxis2))
44844479
fg.AddRect(plot->YAxis[1].HoverRect.Min, plot->YAxis[1].HoverRect.Max, IM_COL32(0,255,0,255));
44854480
if (ImHasFlag(plot->Flags, ImPlotFlags_YAxis3))
4486-
fg.AddRect(plot->YAxis[3].HoverRect.Min, plot->YAxis[2].HoverRect.Max, IM_COL32(0,255,0,255));
4481+
fg.AddRect(plot->YAxis[2].HoverRect.Min, plot->YAxis[2].HoverRect.Max, IM_COL32(0,255,0,255));
44874482
}
44884483
}
44894484
for (int p = 0; p < n_subplots; ++p) {

implot_demo.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,9 +2063,10 @@ struct BenchData {
20632063

20642064
enum BenchMode {
20652065
Line = 0,
2066-
Shaded = 1,
2067-
Scatter = 2,
2068-
Bars = 3
2066+
LineG = 1,
2067+
Shaded = 2,
2068+
Scatter = 3,
2069+
Bars = 4
20692070
};
20702071

20712072
struct BenchRecord {
@@ -2074,6 +2075,11 @@ struct BenchRecord {
20742075
ImVector<ImPlotPoint> Data;
20752076
};
20762077

2078+
ImPlotPoint BenchmarkGetter(void* data, int idx) {
2079+
float* values = (float*)data;
2080+
return ImPlotPoint(idx, values[idx]);
2081+
}
2082+
20772083
void ShowBenchmarkTool() {
20782084
static const int max_items = 500;
20792085
static BenchData items[max_items];
@@ -2083,7 +2089,7 @@ void ShowBenchmarkTool() {
20832089
static int F = 0;
20842090
static double t1, t2;
20852091
static int mode = BenchMode::Line;
2086-
const char* names[] = {"Line","Shaded","Scatter","Bars"};
2092+
const char* names[] = {"Line","LineG","Shaded","Scatter","Bars"};
20872093

20882094
static ImVector<BenchRecord> records;
20892095

@@ -2143,6 +2149,14 @@ void ShowBenchmarkTool() {
21432149
ImGui::PopID();
21442150
}
21452151
}
2152+
else if (mode == BenchMode::LineG) {
2153+
for (int i = 0; i < L; ++i) {
2154+
ImGui::PushID(i);
2155+
ImPlot::SetNextLineStyle(items[i].Col);
2156+
ImPlot::PlotLineG("##item",BenchmarkGetter,items[i].Data,1000);
2157+
ImGui::PopID();
2158+
}
2159+
}
21462160
else if (mode == BenchMode::Shaded) {
21472161
for (int i = 0; i < L; ++i) {
21482162
ImGui::PushID(i);

implot_internal.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
#error Must include implot.h before implot_internal.h
4343
#endif
4444

45+
// Support for pre-1.84 versions. ImPool's GetSize() -> GetBufSize()
46+
#if (IMGUI_VERSION_NUM < 18303)
47+
#define GetBufSize GetSize
48+
#endif
49+
4550
//-----------------------------------------------------------------------------
4651
// [SECTION] Constants
4752
//-----------------------------------------------------------------------------
@@ -1264,8 +1269,8 @@ void FillRange(ImVector<T>& buffer, int n, T vmin, T vmax) {
12641269

12651270
// Offsets and strides a data buffer
12661271
template <typename T>
1267-
static inline T OffsetAndStride(const T* data, int idx, int count, int offset, int stride) {
1268-
idx = ImPosMod(offset + idx, count);
1272+
static inline T OffsetAndStride(const T* data, int idx, int , int , int stride) {
1273+
// idx = ImPosMod(offset + idx, count);
12691274
return *(const T*)(const void*)((const unsigned char*)data + (size_t)idx * stride);
12701275
}
12711276

implot_items.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@
4747
#define ImDrawFlags_RoundCornersAll ImDrawCornerFlags_All
4848
#endif
4949

50-
// Support for pre-1.84 versions. ImPool's GetSize() -> GetBufSize()
51-
#if (IMGUI_VERSION_NUM < 18303)
52-
#define GetBufSize GetSize // A little bit ugly since 'GetBufSize' could technically be used elsewhere (but currently isn't). Could use a proxy define if needed.
53-
#endif
54-
55-
5650
namespace ImPlot {
5751

5852
//-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)