Skip to content

Commit 025bff2

Browse files
committed
feat(implot): add length-aware overloads for ImPlotSpec array setters
Mirror the convention used by plot methods (plotStairsV, plotScatterV, etc.) which accept a separate length parameter, letting callers pass a backing array larger than the logical count without having to Arrays.copyOf to an exactly-sized array per frame. Added (arr, len) overloads to: setLineColors setFillColors setMarkerSizes setMarkerLineColors setMarkerFillColors Motivation: when plotting bubble markers with per-point sizes that change every frame (trade prints, live signals), the existing setMarkerSizes(float[]) required an exactly-sized array each call, defeating any attempt to reuse a growing scratch buffer. The new overload lets callers keep a single float[] sized to capacity and pass the current logical length.
1 parent 65c3f3c commit 025bff2

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

imgui-binding/src/generated/java/imgui/extension/implot/ImPlotSpec.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,16 @@ public void setFlags(final int value) {
409409

410410
// Per-index color array for lines (ImU32 packed RGBA). Pass null to clear.
411411
// Ownership: the backing buffer is allocated in native memory and freed on destroy()
412-
// or when reassigned.
412+
// or when reassigned. The (arr, len) overloads mirror the plot methods and let
413+
// callers reuse a backing array larger than the logical count.
413414
public void setLineColors(final int[] colors) {
414415
nSetLineColors(colors, colors != null ? colors.length : 0);
415416
}
416417

418+
public void setLineColors(final int[] colors, final int len) {
419+
nSetLineColors(colors, len);
420+
}
421+
417422
private native void nSetLineColors(int[] colors, int len); /*
418423
if (THIS->LineColors) { ImGui::MemFree(THIS->LineColors); THIS->LineColors = NULL; }
419424
if (colors != NULL && len > 0) {
@@ -427,6 +432,10 @@ public void setFillColors(final int[] colors) {
427432
nSetFillColors(colors, colors != null ? colors.length : 0);
428433
}
429434

435+
public void setFillColors(final int[] colors, final int len) {
436+
nSetFillColors(colors, len);
437+
}
438+
430439
private native void nSetFillColors(int[] colors, int len); /*
431440
if (THIS->FillColors) { ImGui::MemFree(THIS->FillColors); THIS->FillColors = NULL; }
432441
if (colors != NULL && len > 0) {
@@ -440,6 +449,10 @@ public void setMarkerSizes(final float[] sizes) {
440449
nSetMarkerSizes(sizes, sizes != null ? sizes.length : 0);
441450
}
442451

452+
public void setMarkerSizes(final float[] sizes, final int len) {
453+
nSetMarkerSizes(sizes, len);
454+
}
455+
443456
private native void nSetMarkerSizes(float[] sizes, int len); /*
444457
if (THIS->MarkerSizes) { ImGui::MemFree(THIS->MarkerSizes); THIS->MarkerSizes = NULL; }
445458
if (sizes != NULL && len > 0) {
@@ -453,6 +466,10 @@ public void setMarkerLineColors(final int[] colors) {
453466
nSetMarkerLineColors(colors, colors != null ? colors.length : 0);
454467
}
455468

469+
public void setMarkerLineColors(final int[] colors, final int len) {
470+
nSetMarkerLineColors(colors, len);
471+
}
472+
456473
private native void nSetMarkerLineColors(int[] colors, int len); /*
457474
if (THIS->MarkerLineColors) { ImGui::MemFree(THIS->MarkerLineColors); THIS->MarkerLineColors = NULL; }
458475
if (colors != NULL && len > 0) {
@@ -466,6 +483,10 @@ public void setMarkerFillColors(final int[] colors) {
466483
nSetMarkerFillColors(colors, colors != null ? colors.length : 0);
467484
}
468485

486+
public void setMarkerFillColors(final int[] colors, final int len) {
487+
nSetMarkerFillColors(colors, len);
488+
}
489+
469490
private native void nSetMarkerFillColors(int[] colors, int len); /*
470491
if (THIS->MarkerFillColors) { ImGui::MemFree(THIS->MarkerFillColors); THIS->MarkerFillColors = NULL; }
471492
if (colors != NULL && len > 0) {

imgui-binding/src/main/java/imgui/extension/implot/ImPlotSpec.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,16 @@ public void destroy() {
8484

8585
// Per-index color array for lines (ImU32 packed RGBA). Pass null to clear.
8686
// Ownership: the backing buffer is allocated in native memory and freed on destroy()
87-
// or when reassigned.
87+
// or when reassigned. The (arr, len) overloads mirror the plot methods and let
88+
// callers reuse a backing array larger than the logical count.
8889
public void setLineColors(final int[] colors) {
8990
nSetLineColors(colors, colors != null ? colors.length : 0);
9091
}
9192

93+
public void setLineColors(final int[] colors, final int len) {
94+
nSetLineColors(colors, len);
95+
}
96+
9297
private native void nSetLineColors(int[] colors, int len); /*
9398
if (THIS->LineColors) { ImGui::MemFree(THIS->LineColors); THIS->LineColors = NULL; }
9499
if (colors != NULL && len > 0) {
@@ -102,6 +107,10 @@ public void setFillColors(final int[] colors) {
102107
nSetFillColors(colors, colors != null ? colors.length : 0);
103108
}
104109

110+
public void setFillColors(final int[] colors, final int len) {
111+
nSetFillColors(colors, len);
112+
}
113+
105114
private native void nSetFillColors(int[] colors, int len); /*
106115
if (THIS->FillColors) { ImGui::MemFree(THIS->FillColors); THIS->FillColors = NULL; }
107116
if (colors != NULL && len > 0) {
@@ -115,6 +124,10 @@ public void setMarkerSizes(final float[] sizes) {
115124
nSetMarkerSizes(sizes, sizes != null ? sizes.length : 0);
116125
}
117126

127+
public void setMarkerSizes(final float[] sizes, final int len) {
128+
nSetMarkerSizes(sizes, len);
129+
}
130+
118131
private native void nSetMarkerSizes(float[] sizes, int len); /*
119132
if (THIS->MarkerSizes) { ImGui::MemFree(THIS->MarkerSizes); THIS->MarkerSizes = NULL; }
120133
if (sizes != NULL && len > 0) {
@@ -128,6 +141,10 @@ public void setMarkerLineColors(final int[] colors) {
128141
nSetMarkerLineColors(colors, colors != null ? colors.length : 0);
129142
}
130143

144+
public void setMarkerLineColors(final int[] colors, final int len) {
145+
nSetMarkerLineColors(colors, len);
146+
}
147+
131148
private native void nSetMarkerLineColors(int[] colors, int len); /*
132149
if (THIS->MarkerLineColors) { ImGui::MemFree(THIS->MarkerLineColors); THIS->MarkerLineColors = NULL; }
133150
if (colors != NULL && len > 0) {
@@ -141,6 +158,10 @@ public void setMarkerFillColors(final int[] colors) {
141158
nSetMarkerFillColors(colors, colors != null ? colors.length : 0);
142159
}
143160

161+
public void setMarkerFillColors(final int[] colors, final int len) {
162+
nSetMarkerFillColors(colors, len);
163+
}
164+
144165
private native void nSetMarkerFillColors(int[] colors, int len); /*
145166
if (THIS->MarkerFillColors) { ImGui::MemFree(THIS->MarkerFillColors); THIS->MarkerFillColors = NULL; }
146167
if (colors != NULL && len > 0) {

0 commit comments

Comments
 (0)