@@ -19,13 +19,13 @@ public final class ImGui {
19
19
20
20
private static final ImDrawData DRAW_DATA ;
21
21
private static final ImGuiIO IMGUI_IO ;
22
- private static final ImGuiStyle IMGUI_STYLE ;
23
22
24
23
private static final ImDrawList IM_DRAW_LIST_WINDOW = new ImDrawList (ImDrawList .TYPE_WINDOW );
25
24
private static final ImDrawList IM_DRAW_LIST_BACKGROUND = new ImDrawList (ImDrawList .TYPE_BACKGROUND );
26
25
private static final ImDrawList IM_DRAW_LIST_FOREGROUND = new ImDrawList (ImDrawList .TYPE_FOREGROUND );
27
26
28
27
private static ImFont font ;
28
+ private static ImGuiStyle style ;
29
29
30
30
static {
31
31
final String libPath = System .getProperty (LIB_PATH_PROP );
@@ -44,7 +44,6 @@ public final class ImGui {
44
44
45
45
DRAW_DATA = new ImDrawData (100_000 , 100_000 , 1000 );
46
46
IMGUI_IO = new ImGuiIO ();
47
- IMGUI_STYLE = new ImGuiStyle ();
48
47
49
48
nInitJni ();
50
49
ImDrawList .nInit ();
@@ -53,6 +52,7 @@ public final class ImGui {
53
52
ImFontConfig .nInit ();
54
53
ImFontGlyph .nInit ();
55
54
ImFont .nInit ();
55
+ ImGuiStyle .nInit ();
56
56
nInitInputTextData ();
57
57
}
58
58
@@ -150,9 +150,16 @@ public static ImGuiIO getIO() {
150
150
* Access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame.
151
151
*/
152
152
public static ImGuiStyle getStyle () {
153
- return IMGUI_STYLE ;
153
+ if (style == null ) {
154
+ style = new ImGuiStyle (nGetStyle ());
155
+ }
156
+ return style ;
154
157
}
155
158
159
+ private static native long nGetStyle (); /*
160
+ return (long)(intptr_t)&ImGui::GetStyle();
161
+ */
162
+
156
163
/**
157
164
* Start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame().
158
165
*/
@@ -248,6 +255,14 @@ public static void showMetricsWindow(ImBool pOpen) {
248
255
ImGui::ShowStyleEditor();
249
256
*/
250
257
258
+ public static void showStyleEditor (ImGuiStyle ref ) {
259
+ nShowStyleEditor (ref .ptr );
260
+ }
261
+
262
+ private static native void nShowStyleEditor (long ref ); /*
263
+ ImGui::ShowStyleEditor((ImGuiStyle*)ref);
264
+ */
265
+
251
266
/**
252
267
* Add style selector block (not a window), essentially a combo listing the default styles.
253
268
*/
@@ -285,20 +300,44 @@ public static void showMetricsWindow(ImBool pOpen) {
285
300
ImGui::StyleColorsDark();
286
301
*/
287
302
303
+ public static void styleColorsDark (ImGuiStyle ref ) {
304
+ nStyleColorsDark (ref .ptr );
305
+ }
306
+
307
+ private static native void nStyleColorsDark (long ref ); /*
308
+ ImGui::StyleColorsDark((ImGuiStyle*)ref);
309
+ */
310
+
288
311
/**
289
312
* Classic imgui style
290
313
*/
291
314
public static native void styleColorsClassic (); /*
292
315
ImGui::StyleColorsClassic();
293
316
*/
294
317
318
+ public static void styleColorsClassic (ImGuiStyle ref ) {
319
+ nStyleColorsClassic (ref .ptr );
320
+ }
321
+
322
+ private static native void nStyleColorsClassic (long ref ); /*
323
+ ImGui::StyleColorsClassic((ImGuiStyle*)ref);
324
+ */
325
+
295
326
/**
296
327
* Best used with borders and a custom, thicker font
297
328
*/
298
329
public static native void styleColorsLight (); /*
299
330
ImGui::StyleColorsLight();
300
331
*/
301
332
333
+ public static void styleColorsLight (ImGuiStyle ref ) {
334
+ nStyleColorsLight (ref .ptr );
335
+ }
336
+
337
+ private static native void nStyleColorsLight (long ref ); /*
338
+ ImGui::StyleColorsLight((ImGuiStyle*)ref);
339
+ */
340
+
302
341
// Windows
303
342
// - Begin() = push window to the stack and start appending to it. End() = pop window from the stack.
304
343
// - You may append multiple times to the same window during the same frame.
0 commit comments