forked from inkyblackness/imgui-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimguiWrapper.cpp
More file actions
500 lines (407 loc) · 10.5 KB
/
imguiWrapper.cpp
File metadata and controls
500 lines (407 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
#include "imguiWrappedHeader.h"
#include "imguiWrapper.h"
#include "WrapperConverter.h"
IggContext iggCreateContext(IggFontAtlas sharedFontAtlas)
{
ImGuiContext *context = ImGui::CreateContext(reinterpret_cast<ImFontAtlas *>(sharedFontAtlas));
return reinterpret_cast<IggContext>(context);
}
void iggDestroyContext(IggContext context)
{
ImGui::DestroyContext(reinterpret_cast<ImGuiContext *>(context));
}
IggContext iggGetCurrentContext()
{
return reinterpret_cast<IggContext>(ImGui::GetCurrentContext());
}
void iggSetCurrentContext(IggContext context)
{
ImGui::SetCurrentContext(reinterpret_cast<ImGuiContext *>(context));
}
IggIO iggGetCurrentIO()
{
return reinterpret_cast<IggIO>(&ImGui::GetIO());
}
IggGuiStyle iggGetCurrentStyle()
{
return reinterpret_cast<IggGuiStyle>(&ImGui::GetStyle());
}
void iggNewFrame()
{
ImGui::NewFrame();
}
void iggRender()
{
ImGui::Render();
}
IggDrawData iggGetDrawData()
{
return reinterpret_cast<IggDrawData>(ImGui::GetDrawData());
}
void iggEndFrame()
{
ImGui::EndFrame();
}
char const *iggGetVersion()
{
return ImGui::GetVersion();
}
void iggShowDemoWindow(IggBool *open)
{
BoolWrapper openArg(open);
ImGui::ShowDemoWindow(openArg);
}
void iggShowUserGuide(void)
{
ImGui::ShowUserGuide();
}
IggBool iggBegin(char const *id, IggBool *open, int flags)
{
BoolWrapper openArg(open);
return ImGui::Begin(id, openArg, flags) ? 1 : 0;
}
void iggEnd(void)
{
ImGui::End();
}
IggBool iggBeginChild(char const *id, IggVec2 const *size, IggBool border, int flags)
{
Vec2Wrapper sizeArg(size);
return ImGui::BeginChild(id, *sizeArg, border, flags) ? 1 : 0;
}
void iggEndChild(void)
{
ImGui::EndChild();
}
void iggSetNextWindowPos(IggVec2 const *pos, int cond, IggVec2 const *pivot)
{
Vec2Wrapper posArg(pos);
Vec2Wrapper pivotArg(pivot);
ImGui::SetNextWindowPos(*posArg, cond, *pivotArg);
}
void iggSetNextWindowSize(IggVec2 const *size, int cond)
{
Vec2Wrapper sizeArg(size);
ImGui::SetNextWindowSize(*sizeArg, cond);
}
void iggSetNextWindowFocus(void)
{
ImGui::SetNextWindowFocus();
}
void iggSetNextWindowBgAlpha(float value)
{
ImGui::SetNextWindowBgAlpha(value);
}
void iggPushFont(IggFont handle)
{
ImFont *font = reinterpret_cast<ImFont *>(handle);
ImGui::PushFont(font);
}
void iggPopFont(void)
{
ImGui::PopFont();
}
void iggPushStyleColor(int index, IggVec4 const *col)
{
Vec4Wrapper colArg(col);
ImGui::PushStyleColor(index, *colArg);
}
void iggPopStyleColor(int count)
{
ImGui::PopStyleColor(count);
}
void iggPushStyleVarFloat(int index, float value)
{
ImGui::PushStyleVar(index, value);
}
void iggPushStyleVarVec2(int index, IggVec2 const *value)
{
Vec2Wrapper valueArg(value);
ImGui::PushStyleVar(index, *valueArg);
}
void iggPopStyleVar(int count)
{
ImGui::PopStyleVar(count);
}
void iggPushItemWidth(float width)
{
ImGui::PushItemWidth(width);
}
void iggPopItemWidth(void)
{
ImGui::PopItemWidth();
}
void iggPushTextWrapPos(float wrapPosX)
{
ImGui::PushTextWrapPos(wrapPosX);
}
void iggPopTextWrapPos(void)
{
ImGui::PopTextWrapPos();
}
void iggPushID(char const *id)
{
ImGui::PushID(id);
}
void iggPopID(void)
{
ImGui::PopID();
}
void iggTextUnformatted(char const *text)
{
ImGui::TextUnformatted(text);
}
void iggLabelText(char const *label, char const *text)
{
ImGui::LabelText(label, "%s", text);
}
IggBool iggButton(char const *label, IggVec2 const *size)
{
Vec2Wrapper sizeArg(size);
return ImGui::Button(label, *sizeArg) ? 1 : 0;
}
void iggImage(IggTextureID textureID,
IggVec2 const *size, IggVec2 const *uv0, IggVec2 const *uv1,
IggVec4 const *tintCol, IggVec4 const *borderCol)
{
Vec2Wrapper sizeArg(size);
Vec2Wrapper uv0Arg(uv0);
Vec2Wrapper uv1Arg(uv1);
Vec4Wrapper tintColArg(tintCol);
Vec4Wrapper borderColArg(borderCol);
ImGui::Image(static_cast<ImTextureID>(textureID), *sizeArg, *uv0Arg, *uv1Arg, *tintColArg, *borderColArg);
}
IggBool iggImageButton(IggTextureID textureID,
IggVec2 const *size, IggVec2 const *uv0, IggVec2 const *uv1,
int framePadding, IggVec4 const *bgCol,
IggVec4 const *tintCol)
{
Vec2Wrapper sizeArg(size);
Vec2Wrapper uv0Arg(uv0);
Vec2Wrapper uv1Arg(uv1);
Vec4Wrapper bgColArg(bgCol);
Vec4Wrapper tintColArg(tintCol);
return ImGui::ImageButton(static_cast<ImTextureID>(textureID), *sizeArg, *uv0Arg, *uv1Arg, framePadding, *bgColArg, *tintColArg) ? 1 : 0;
}
IggBool iggCheckbox(char const *label, IggBool *selected)
{
BoolWrapper selectedArg(selected);
return ImGui::Checkbox(label, selectedArg) ? 1 : 0;
}
void iggProgressBar(float fraction, IggVec2 const *size, char const *overlay)
{
Vec2Wrapper sizeArg(size);
ImGui::ProgressBar(fraction, *sizeArg, overlay);
}
IggBool iggBeginCombo(char const *label, char const *previewValue, int flags)
{
return ImGui::BeginCombo(label, previewValue, flags) ? 1 : 0;
}
void iggEndCombo(void)
{
ImGui::EndCombo();
}
IggBool iggDragFloat(char const *label, float *value, float speed, float min, float max, char const *format, float power)
{
return ImGui::DragFloat(label, value, speed, min, max, format, power) ? 1 : 0;
}
IggBool iggDragInt(char const *label, int *value, float speed, int min, int max, char const *format)
{
return ImGui::DragInt(label, value, speed, min, max, format) ? 1 : 0;
}
IggBool iggSliderFloat(char const *label, float *value, float minValue, float maxValue, char const *format, float power)
{
return ImGui::SliderFloat(label, value, minValue, maxValue, format, power) ? 1 : 0;
}
IggBool iggSliderFloatN(char const *label, float *value, int n, float minValue, float maxValue, char const *format, float power)
{
return ImGui::SliderScalarN(label, ImGuiDataType_Float, (void *)value, n, &minValue, &maxValue, format, power) ? 1 : 0;
}
IggBool iggSliderInt(char const *label, int *value, int minValue, int maxValue, char const *format)
{
return ImGui::SliderInt(label, value, minValue, maxValue, format) ? 1 : 0;
}
extern "C" int iggInputTextCallback(IggInputTextCallbackData data, int key);
static int iggInputTextCallbackWrapper(ImGuiInputTextCallbackData *data)
{
return iggInputTextCallback(reinterpret_cast<IggInputTextCallbackData>(data), static_cast<int>(reinterpret_cast<size_t>(data->UserData)));
}
IggBool iggInputText(char const* label, char* buf, unsigned int bufSize, int flags, int callbackKey)
{
return ImGui::InputText(label, buf, static_cast<size_t>(bufSize), flags,
iggInputTextCallbackWrapper, reinterpret_cast<void *>(callbackKey)) ? 1 : 0;
}
IggBool iggInputTextMultiline(char const* label, char* buf, unsigned int bufSize, IggVec2 const *size, int flags, int callbackKey)
{
Vec2Wrapper sizeArg(size);
return ImGui::InputTextMultiline(label, buf, static_cast<size_t>(bufSize), *sizeArg, flags,
iggInputTextCallbackWrapper, reinterpret_cast<void *>(callbackKey)) ? 1 : 0;
}
void iggSeparator(void)
{
ImGui::Separator();
}
void iggSameLine(float posX, float spacingW)
{
ImGui::SameLine(posX, spacingW);
}
void iggSpacing(void)
{
ImGui::Spacing();
}
void iggDummy(IggVec2 const *size)
{
Vec2Wrapper sizeArg(size);
ImGui::Dummy(*sizeArg);
}
void iggBeginGroup(void)
{
ImGui::BeginGroup();
}
void iggEndGroup(void)
{
ImGui::EndGroup();
}
void iggSetCursorPos(IggVec2 const *localPos)
{
Vec2Wrapper localPosArg(localPos);
ImGui::SetCursorPos(*localPosArg);
}
void iggAlignTextToFramePadding()
{
ImGui::AlignTextToFramePadding();
}
float iggGetTextLineHeight(void)
{
return ImGui::GetTextLineHeight();
}
float iggGetTextLineHeightWithSpacing(void)
{
return ImGui::GetTextLineHeightWithSpacing();
}
IggBool iggTreeNode(char const *label, int flags)
{
return ImGui::TreeNodeEx(label, flags) ? 1 : 0;
}
void iggTreePop(void)
{
ImGui::TreePop();
}
void iggSetNextTreeNodeOpen(IggBool open, int cond)
{
ImGui::SetNextTreeNodeOpen(open != 0, cond);
}
IggBool iggSelectable(char const *label, IggBool selected, int flags, IggVec2 const *size)
{
Vec2Wrapper sizeArg(size);
return ImGui::Selectable(label, selected != 0, flags, *sizeArg) ? 1 : 0;
}
IggBool iggListBoxV(char const *label, int *current_item, char const *const items[], int items_count, int height_items)
{
return ImGui::ListBox(label, current_item, items, items_count, height_items) ? 1 : 0;
}
void iggSetTooltip(char const *text)
{
ImGui::SetTooltip("%s", text);
}
void iggBeginTooltip(void)
{
ImGui::BeginTooltip();
}
void iggEndTooltip(void)
{
ImGui::EndTooltip();
}
IggBool iggBeginMainMenuBar(void)
{
return ImGui::BeginMainMenuBar() ? 1 : 0;
}
void iggEndMainMenuBar(void)
{
ImGui::EndMainMenuBar();
}
IggBool iggBeginMenuBar(void)
{
return ImGui::BeginMenuBar() ? 1 : 0;
}
void iggEndMenuBar(void)
{
ImGui::EndMenuBar();
}
IggBool iggBeginMenu(char const *label, IggBool enabled)
{
return ImGui::BeginMenu(label, enabled != 0) ? 1 : 0;
}
void iggEndMenu(void)
{
ImGui::EndMenu();
}
IggBool iggMenuItem(char const *label, char const *shortcut, IggBool selected, IggBool enabled)
{
return ImGui::MenuItem(label, shortcut, selected != 0, enabled != 0) ? 1 : 0;
}
void iggOpenPopup(char const *id)
{
ImGui::OpenPopup(id);
}
IggBool iggBeginPopupModal(char const *name, IggBool *open, int flags)
{
BoolWrapper openArg(open);
return ImGui::BeginPopupModal(name, openArg, flags) ? 1 : 0;
}
IggBool iggBeginPopupContextItem(char const *label, int mouseButton)
{
return ImGui::BeginPopupContextItem(label, mouseButton) ? 1 : 0;
}
void iggEndPopup(void)
{
ImGui::EndPopup();
}
void iggCloseCurrentPopup(void)
{
ImGui::CloseCurrentPopup();
}
IggBool iggIsItemHovered(int flags)
{
return ImGui::IsItemHovered(flags) ? 1 : 0;
}
IggBool iggIsKeyPressed(int key)
{
return ImGui::IsKeyPressed(key);
}
void iggBeginColumns(int count, char const *label, int flags)
{
ImGui::Columns(count, label, flags);
}
void iggNextColumn()
{
ImGui::NextColumn();
}
int iggGetColumnIndex()
{
return ImGui::GetColumnIndex();
}
int iggGetColumnWidth(int index)
{
return ImGui::GetColumnWidth(index);
}
void iggSetColumnWidth(int index, float width)
{
ImGui::SetColumnWidth(index, width);
}
float iggGetColumnOffset(int index)
{
return ImGui::GetColumnOffset(index);
}
void iggSetColumnOffset(int index, float offsetX)
{
ImGui::SetColumnOffset(index, offsetX);
}
int iggGetColumnsCount()
{
return ImGui::GetColumnsCount();
}
void iggSetScrollHereY(float center_y_ratio = 0.5f)
{
ImGui::SetScrollHereY(center_y_ratio);
}