Skip to content

Commit 358628d

Browse files
committed
Refactor color params
Make places where it's needed to provide or get a color to use 'int' instead of 'long'.
1 parent 6d6d88b commit 358628d

File tree

2 files changed

+38
-37
lines changed

2 files changed

+38
-37
lines changed

imgui-binding/src/main/java/imgui/ImDrawList.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -63,87 +63,87 @@ public final class ImDrawList {
6363
// Primitives
6464
// - For rectangular primitives, "pMin" and "pMax" represent the upper-left and lower-right corners.
6565

66-
public native void addLine(float p1X, float p1Y, float p2X, float p2Y, long col); /*
66+
public native void addLine(float p1X, float p1Y, float p2X, float p2Y, int col); /*
6767
getDrawList(env->GetIntField(object, drawListTypeID))->AddLine(ImVec2(p1X, p1Y), ImVec2(p2X, p2Y), col);
6868
*/
6969

70-
public native void addLine(float p1X, float p1Y, float p2X, float p2Y, long col, float thickness); /*
70+
public native void addLine(float p1X, float p1Y, float p2X, float p2Y, int col, float thickness); /*
7171
getDrawList(env->GetIntField(object, drawListTypeID))->AddLine(ImVec2(p1X, p1Y), ImVec2(p2X, p2Y), col, thickness);
7272
*/
7373

74-
public native void addRect(float pMinX, float pMinY, float pMaxX, float pMaxY, long col); /*
74+
public native void addRect(float pMinX, float pMinY, float pMaxX, float pMaxY, int col); /*
7575
getDrawList(env->GetIntField(object, drawListTypeID))->AddRect(ImVec2(pMinX, pMinY), ImVec2(pMaxX, pMaxY), col);
7676
*/
7777

78-
public native void addRect(float pMinX, float pMinY, float pMaxX, float pMaxY, long col, float rounding); /*
78+
public native void addRect(float pMinX, float pMinY, float pMaxX, float pMaxY, int col, float rounding); /*
7979
getDrawList(env->GetIntField(object, drawListTypeID))->AddRect(ImVec2(pMinX, pMinY), ImVec2(pMaxX, pMaxY), col, rounding);
8080
*/
8181

82-
public native void addRect(float pMinX, float pMinY, float pMaxX, float pMaxY, long col, float rounding, int roundingCornersFlags); /*
82+
public native void addRect(float pMinX, float pMinY, float pMaxX, float pMaxY, int col, float rounding, int roundingCornersFlags); /*
8383
getDrawList(env->GetIntField(object, drawListTypeID))->AddRect(ImVec2(pMinX, pMinY), ImVec2(pMaxX, pMaxY), col, rounding, roundingCornersFlags);
8484
*/
8585

86-
public native void addRect(float pMinX, float pMinY, float pMaxX, float pMaxY, long col, float rounding, int roundingCornersFlags, float thickness); /*
86+
public native void addRect(float pMinX, float pMinY, float pMaxX, float pMaxY, int col, float rounding, int roundingCornersFlags, float thickness); /*
8787
getDrawList(env->GetIntField(object, drawListTypeID))->AddRect(ImVec2(pMinX, pMinY), ImVec2(pMaxX, pMaxY), col, rounding, roundingCornersFlags, thickness);
8888
*/
8989

90-
public native void addRectFilled(float pMinX, float pMinY, float pMaxX, float pMaxY, long col); /*
90+
public native void addRectFilled(float pMinX, float pMinY, float pMaxX, float pMaxY, int col); /*
9191
getDrawList(env->GetIntField(object, drawListTypeID))->AddRectFilled(ImVec2(pMinX, pMinY), ImVec2(pMaxX, pMaxY), col);
9292
*/
9393

94-
public native void addRectFilled(float pMinX, float pMinY, float pMaxX, float pMaxY, long col, float rounding); /*
94+
public native void addRectFilled(float pMinX, float pMinY, float pMaxX, float pMaxY, int col, float rounding); /*
9595
getDrawList(env->GetIntField(object, drawListTypeID))->AddRectFilled(ImVec2(pMinX, pMinY), ImVec2(pMaxX, pMaxY), col, rounding);
9696
*/
9797

98-
public native void addRectFilled(float pMinX, float pMinY, float pMaxX, float pMaxY, long col, float rounding, int roundingCornersFlags); /*
98+
public native void addRectFilled(float pMinX, float pMinY, float pMaxX, float pMaxY, int col, float rounding, int roundingCornersFlags); /*
9999
getDrawList(env->GetIntField(object, drawListTypeID))->AddRectFilled(ImVec2(pMinX, pMinY), ImVec2(pMaxX, pMaxY), col, rounding, roundingCornersFlags);
100100
*/
101101

102102
public native void addRectFilledMultiColor(float pMinX, float pMinY, float pMaxX, float pMaxY, long colUprLeft, long colUprRight, long colBotRight, long colBotLeft); /*
103103
getDrawList(env->GetIntField(object, drawListTypeID))->AddRectFilledMultiColor(ImVec2(pMinX, pMinY), ImVec2(pMaxX, pMaxY), colUprLeft, colUprRight, colBotRight, colBotLeft);
104104
*/
105105

106-
public native void addQuad(float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, float p4X, float p4Y, long col); /*
106+
public native void addQuad(float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, float p4X, float p4Y, int col); /*
107107
getDrawList(env->GetIntField(object, drawListTypeID))->AddQuad(ImVec2(p1X, p1Y), ImVec2(p2X, p2Y), ImVec2(p3X, p3Y), ImVec2(p4X, p4Y), col);
108108
*/
109109

110-
public native void addQuad(float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, float p4X, float p4Y, long col, float thickness); /*
110+
public native void addQuad(float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, float p4X, float p4Y, int col, float thickness); /*
111111
getDrawList(env->GetIntField(object, drawListTypeID))->AddQuad(ImVec2(p1X, p1Y), ImVec2(p2X, p2Y), ImVec2(p3X, p3Y), ImVec2(p4X, p4Y), col, thickness);
112112
*/
113113

114-
public native void addQuadFilled(float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, float p4X, float p4Y, long col); /*
114+
public native void addQuadFilled(float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, float p4X, float p4Y, int col); /*
115115
getDrawList(env->GetIntField(object, drawListTypeID))->AddQuadFilled(ImVec2(p1X, p1Y), ImVec2(p2X, p2Y), ImVec2(p3X, p3Y), ImVec2(p4X, p4Y), col);
116116
*/
117117

118-
public native void addTriangle(float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, long col); /*
118+
public native void addTriangle(float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, int col); /*
119119
getDrawList(env->GetIntField(object, drawListTypeID))->AddTriangle(ImVec2(p1X, p1Y), ImVec2(p2X, p2Y), ImVec2(p3X, p3Y), col);
120120
*/
121121

122-
public native void addTriangle(float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, long col, float thickness); /*
122+
public native void addTriangle(float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, int col, float thickness); /*
123123
getDrawList(env->GetIntField(object, drawListTypeID))->AddTriangle(ImVec2(p1X, p1Y), ImVec2(p2X, p2Y), ImVec2(p3X, p3Y), col, thickness);
124124
*/
125125

126-
public native void addTriangleFilled(float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, long col); /*
126+
public native void addTriangleFilled(float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, int col); /*
127127
getDrawList(env->GetIntField(object, drawListTypeID))->AddTriangleFilled(ImVec2(p1X, p1Y), ImVec2(p2X, p2Y), ImVec2(p3X, p3Y), col);
128128
*/
129129

130-
public native void addCircle(float centreX, float centreY, float radius, float col); /*
130+
public native void addCircle(float centreX, float centreY, float radius, int col); /*
131131
getDrawList(env->GetIntField(object, drawListTypeID))->AddCircle(ImVec2(centreX, centreY), radius, col);
132132
*/
133133

134-
public native void addCircle(float centreX, float centreY, float radius, float col, int numSegments); /*
134+
public native void addCircle(float centreX, float centreY, float radius, int col, int numSegments); /*
135135
getDrawList(env->GetIntField(object, drawListTypeID))->AddCircle(ImVec2(centreX, centreY), radius, col, numSegments);
136136
*/
137137

138-
public native void addCircle(float centreX, float centreY, float radius, float col, int numSegments, float thickness); /*
138+
public native void addCircle(float centreX, float centreY, float radius, int col, int numSegments, float thickness); /*
139139
getDrawList(env->GetIntField(object, drawListTypeID))->AddCircle(ImVec2(centreX, centreY), radius, col, numSegments, thickness);
140140
*/
141141

142-
public native void addCircleFilled(float centreX, float centreY, float radius, float col); /*
142+
public native void addCircleFilled(float centreX, float centreY, float radius, int col); /*
143143
getDrawList(env->GetIntField(object, drawListTypeID))->AddCircleFilled(ImVec2(centreX, centreY), radius, col);
144144
*/
145145

146-
public native void addCircleFilled(float centreX, float centreY, float radius, float col, int numSegments); /*
146+
public native void addCircleFilled(float centreX, float centreY, float radius, int col, int numSegments); /*
147147
getDrawList(env->GetIntField(object, drawListTypeID))->AddCircleFilled(ImVec2(centreX, centreY), radius, col, numSegments);
148148
*/
149149

@@ -157,7 +157,7 @@ public final class ImDrawList {
157157

158158
// TODO add text with font support
159159

160-
public native void addPolyline(ImVec2[] points, int numPoints, long col, boolean closed, float thickness); /*
160+
public native void addPolyline(ImVec2[] points, int numPoints, int col, boolean closed, float thickness); /*
161161
int points_num = env->GetArrayLength(points);
162162
ImVec2 _points[points_num];
163163
for (int i = 0; i < points_num; i++) {
@@ -170,7 +170,7 @@ public final class ImDrawList {
170170
*/
171171

172172
// Note: Anti-aliased filling requires points to be in clockwise order.
173-
public native void addConvexPolyFilled(ImVec2[] points, int numPoints, long col); /*
173+
public native void addConvexPolyFilled(ImVec2[] points, int numPoints, int col); /*
174174
int points_num = env->GetArrayLength(points);
175175
ImVec2 _points[points_num];
176176
for (int i = 0; i < points_num; i++) {
@@ -182,11 +182,11 @@ public final class ImDrawList {
182182
getDrawList(env->GetIntField(object, drawListTypeID))->AddConvexPolyFilled(_points, numPoints, col);
183183
*/
184184

185-
public native void addBezierCurve(float pos0X, float pos0Y, float cp0X, float cp0Y, float cp1X, float cp1Y, float pos1X, float pos1Y, long col, float thickness); /*
185+
public native void addBezierCurve(float pos0X, float pos0Y, float cp0X, float cp0Y, float cp1X, float cp1Y, float pos1X, float pos1Y, int col, float thickness); /*
186186
getDrawList(env->GetIntField(object, drawListTypeID))->AddBezierCurve(ImVec2(pos0X, pos0Y), ImVec2(cp0X, cp0Y), ImVec2(cp1X, cp1Y), ImVec2(pos1X, pos1Y), col, thickness);
187187
*/
188188

189-
public native void addBezierCurve(float pos0X, float pos0Y, float cp0X, float cp0Y, float cp1X, float cp1Y, float pos1X, float pos1Y, long col, float thickness, int numSegments); /*
189+
public native void addBezierCurve(float pos0X, float pos0Y, float cp0X, float cp0Y, float cp1X, float cp1Y, float pos1X, float pos1Y, int col, float thickness, int numSegments); /*
190190
getDrawList(env->GetIntField(object, drawListTypeID))->AddBezierCurve(ImVec2(pos0X, pos0Y), ImVec2(cp0X, cp0Y), ImVec2(cp1X, cp1Y), ImVec2(pos1X, pos1Y), col, thickness, numSegments);
191191
*/
192192

@@ -210,7 +210,7 @@ public final class ImDrawList {
210210
drawList->AddImage((ImTextureID)textureID, ImVec2(pMinX, pMinY), ImVec2(pMaxX, pMaxY), ImVec2(uvMinX, uvMinY), ImVec2(uvMaxX, uvMaxY));
211211
*/
212212

213-
public native void addImage(int textureID, float pMinX, float pMinY, float pMaxX, float pMaxY, float uvMinX, float uvMinY, float uvMaxX, float uvMaxY, long col); /*
213+
public native void addImage(int textureID, float pMinX, float pMinY, float pMaxX, float pMaxY, float uvMinX, float uvMinY, float uvMaxX, float uvMaxY, int col); /*
214214
ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID));
215215
drawList->AddImage((ImTextureID)textureID, ImVec2(pMinX, pMinY), ImVec2(pMaxX, pMaxY), ImVec2(uvMinX, uvMinY), ImVec2(uvMaxX, uvMaxY), col);
216216
*/
@@ -240,17 +240,17 @@ public final class ImDrawList {
240240
drawList->AddImageQuad((ImTextureID)textureID, ImVec2(p1X, p1Y), ImVec2(p2X, p2Y), ImVec2(p3X, p3Y), ImVec2(p4X, p4Y), ImVec2(uv1X, uv1Y), ImVec2(uv2X, uv2Y), ImVec2(uv3X, uv3Y), ImVec2(uv4X, uv4Y));
241241
*/
242242

243-
public native void addImageQuad(int textureID, float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, float p4X, float p4Y, float uv1X, float uv1Y, float uv2X, float uv2Y, float uv3X, float uv3Y, float uv4X, float uv4Y, long col); /*
243+
public native void addImageQuad(int textureID, float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, float p4X, float p4Y, float uv1X, float uv1Y, float uv2X, float uv2Y, float uv3X, float uv3Y, float uv4X, float uv4Y, int col); /*
244244
ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID));
245245
drawList->AddImageQuad((ImTextureID)textureID, ImVec2(p1X, p1Y), ImVec2(p2X, p2Y), ImVec2(p3X, p3Y), ImVec2(p4X, p4Y), ImVec2(uv1X, uv1Y), ImVec2(uv2X, uv2Y), ImVec2(uv3X, uv3Y), ImVec2(uv4X, uv4Y), col);
246246
*/
247247

248-
public native void addImageRounded(int textureID, float pMinX, float pMinY, float pMaxX, float pMaxY, float uvMinX, float uvMinY, float uvMaxX, float uvMaxY, long col, float rounding); /*
248+
public native void addImageRounded(int textureID, float pMinX, float pMinY, float pMaxX, float pMaxY, float uvMinX, float uvMinY, float uvMaxX, float uvMaxY, int col, float rounding); /*
249249
ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID));
250250
drawList->AddImageRounded((ImTextureID)textureID, ImVec2(pMinX, pMinY), ImVec2(pMaxX, pMaxY), ImVec2(uvMinX, uvMinY), ImVec2(uvMaxX, uvMaxY), col, rounding);
251251
*/
252252

253-
public native void addImageRounded(int textureID, float pMinX, float pMinY, float pMaxX, float pMaxY, float uvMinX, float uvMinY, float uvMaxX, float uvMaxY, long col, float rounding, int imDrawCornerFlags); /*
253+
public native void addImageRounded(int textureID, float pMinX, float pMinY, float pMaxX, float pMaxY, float uvMinX, float uvMinY, float uvMaxX, float uvMaxY, int col, float rounding, int imDrawCornerFlags); /*
254254
ImDrawList* drawList = getDrawList(env->GetIntField(object, drawListTypeID));
255255
drawList->AddImageRounded((ImTextureID)textureID, ImVec2(pMinX, pMinY), ImVec2(pMaxX, pMaxY), ImVec2(uvMinX, uvMinY), ImVec2(uvMaxX, uvMaxY), col, rounding, imDrawCornerFlags);
256256
*/
@@ -270,15 +270,15 @@ public final class ImDrawList {
270270
*/
271271

272272
// Note: Anti-aliased filling requires points to be in clockwise order.
273-
public native void pathFillConvex(long col); /*
273+
public native void pathFillConvex(int col); /*
274274
getDrawList(env->GetIntField(object, drawListTypeID))->PathFillConvex(col);
275275
*/
276276

277-
public native void pathStroke(long col, boolean closed); /*
277+
public native void pathStroke(int col, boolean closed); /*
278278
getDrawList(env->GetIntField(object, drawListTypeID))->PathStroke(col, closed);
279279
*/
280280

281-
public native void pathStroke(long col, boolean closed, float thickness); /*
281+
public native void pathStroke(int col, boolean closed, float thickness); /*
282282
getDrawList(env->GetIntField(object, drawListTypeID))->PathStroke(col, closed, thickness);
283283
*/
284284

imgui-binding/src/main/java/imgui/ImGui.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ public static ImDrawList getWindowDrawList() {
718718
ImGui::PopFont();
719719
*/
720720

721-
public static native void pushStyleColor(int imGuiCol, long col); /*
721+
public static native void pushStyleColor(int imGuiCol, int col); /*
722722
ImGui::PushStyleColor(imGuiCol, col);
723723
*/
724724

@@ -777,28 +777,29 @@ public static ImDrawList getWindowDrawList() {
777777
/**
778778
* Retrieve given style color with style alpha applied and optional extra alpha multiplier
779779
*/
780-
public static native long getColorU32(int imGuiCol); /*
780+
public static native int getColorU32(int imGuiCol); /*
781781
return ImGui::GetColorU32((ImGuiCol)imGuiCol);
782782
*/
783783

784784
/**
785785
* Retrieve given style color with style alpha applied and optional extra alpha multiplier
786786
*/
787-
public static native long getColorU32(int imGuiCol, float alphaMul); /*
787+
public static native int getColorU32(int imGuiCol, float alphaMul); /*
788788
return ImGui::GetColorU32(imGuiCol, alphaMul);
789789
*/
790790

791791
/**
792792
* Retrieve given color with style alpha applied
793793
*/
794-
public static native long getColorU32(float r, float g, float b, float a); /*
794+
public static native int getColorU32(float r, float g, float b, float a); /*
795795
return ImGui::GetColorU32(ImVec4(r, g, b, a));
796796
*/
797797

798798
/**
799799
* Retrieve given color with style alpha applied
800+
* BINDING NOTICE: Since {@link #getColorU32(int)} has the same signature, this specific method has an 'i' suffix.
800801
*/
801-
public static native long getColorU32(long col); /*
802+
public static native int getColorU32i(int col); /*
802803
return ImGui::GetColorU32((ImU32)col);
803804
*/
804805

@@ -4309,7 +4310,7 @@ public static ImDrawList getForegroundDrawList() {
43094310
Jni::ImVec4Cpy(env, ImGui::ColorConvertU32ToFloat4(in), dstImVec4);
43104311
*/
43114312

4312-
public static native long colorConvertFloat4ToU32(float r, float g, float b, float a); /*
4313+
public static native int colorConvertFloat4ToU32(float r, float g, float b, float a); /*
43134314
return ImGui::ColorConvertFloat4ToU32(ImVec4(r, g, b, a));
43144315
*/
43154316

0 commit comments

Comments
 (0)