forked from inkyblackness/imgui-go
-
Notifications
You must be signed in to change notification settings - Fork 15
/
IOWrapper.cpp
218 lines (181 loc) · 5.6 KB
/
IOWrapper.cpp
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
#include "imguiWrappedHeader.h"
#include "IOWrapper.h"
#include "WrapperConverter.h"
#include <string>
IggBool iggWantCaptureMouse(IggIO handle)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
return io->WantCaptureMouse ? 1 : 0;
}
IggBool iggWantCaptureKeyboard(IggIO handle)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
return io->WantCaptureKeyboard ? 1 : 0;
}
IggBool iggWantTextInput(IggIO handle)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
return io->WantTextInput ? 1 : 0;
}
IggFontAtlas iggIoGetFonts(IggIO handle)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
return reinterpret_cast<IggFontAtlas>(io->Fonts);
}
void iggIoSetDisplaySize(IggIO handle, IggVec2 const *value)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
importValue(io->DisplaySize, *value);
}
void iggIoSetMousePosition(IggIO handle, IggVec2 const *value)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
importValue(io->MousePos, *value);
}
void iggIoSetMouseButtonDown(IggIO handle, int index, IggBool value)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
io->MouseDown[index] = value != 0;
}
void iggIoAddMouseWheelDelta(IggIO handle, float horizontal, float vertical)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
io->MouseWheelH += horizontal;
io->MouseWheel += vertical;
}
void iggIoGetMouseWheelDelta(IggIO handle, IggFloat *value)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
exportValue(*value, io->MouseWheel);
}
void iggIoGetMouseWheelHDelta(IggIO handle, IggFloat *value)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
exportValue(*value, io->MouseWheelH);
}
void iggIoGetMouseDelta(IggIO handle, IggVec2 *value)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
exportValue(*value, io->MouseDelta);
}
void iggIoSetDeltaTime(IggIO handle, float value)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
io->DeltaTime = value;
}
void iggIoSetFontGlobalScale(IggIO handle, float value)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
io->FontGlobalScale = value;
}
IggBool iggIoGetMouseDrawCursor(IggIO handle)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
return io->MouseDrawCursor ? 1 : 0;
}
void iggIoSetMouseDrawCursor(IggIO handle, IggBool value)
{
ImGuiIO *io = reinterpret_cast<ImGuiIO *>(handle);
io->MouseDrawCursor = value != 0;
}
void iggIoKeyPress(IggIO handle, int key)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.KeysDown[key] = true;
}
void iggIoKeyRelease(IggIO handle, int key)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.KeysDown[key] = false;
}
void iggIoKeyMap(IggIO handle, int imguiKey, int nativeKey)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.KeyMap[imguiKey] = nativeKey;
}
void iggIoKeyCtrl(IggIO handle, int leftCtrl, int rightCtrl)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.KeyCtrl = io.KeysDown[leftCtrl] || io.KeysDown[rightCtrl];
}
void iggIoKeyShift(IggIO handle, int leftShift, int rightShift)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.KeyShift = io.KeysDown[leftShift] || io.KeysDown[rightShift];
}
void iggIoKeyAlt(IggIO handle, int leftAlt, int rightAlt)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.KeyAlt = io.KeysDown[leftAlt] || io.KeysDown[rightAlt];
}
void iggIoKeySuper(IggIO handle, int leftSuper, int rightSuper)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.KeySuper = io.KeysDown[leftSuper] || io.KeysDown[rightSuper];
}
void iggIoAddInputCharactersUTF8(IggIO handle, char const *utf8Chars)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.AddInputCharactersUTF8(utf8Chars);
}
void iggIoSetIniFilename(IggIO handle, char const *value)
{
static std::string bufferValue;
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
bufferValue = (value != nullptr) ? value : "";
io.IniFilename = bufferValue.empty() ? nullptr : bufferValue.c_str();
}
void iggIoSetConfigFlags(IggIO handle, int flags)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.ConfigFlags = flags;
}
int iggIoGetConfigFlags(IggIO handle)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
return io.ConfigFlags;
}
void iggIoSetBackendFlags(IggIO handle, int flags)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.BackendFlags = flags;
}
extern "C" void iggIoSetClipboardText(IggIO handle, char *text);
extern "C" char *iggIoGetClipboardText(IggIO handle);
static void iggIoSetClipboardTextWrapper(void *userData, char const *text)
{
iggIoSetClipboardText(userData, const_cast<char *>(text));
}
static char const *iggIoGetClipboardTextWrapper(void *userData)
{
return iggIoGetClipboardText(userData);
}
void iggIoRegisterClipboardFunctions(IggIO handle)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.ClipboardUserData = handle;
io.GetClipboardTextFn = iggIoGetClipboardTextWrapper;
io.SetClipboardTextFn = iggIoSetClipboardTextWrapper;
}
void iggIoClearClipboardFunctions(IggIO handle)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.GetClipboardTextFn = nullptr;
io.SetClipboardTextFn = nullptr;
io.ClipboardUserData = nullptr;
}
int iggGetFrameCountSinceLastInput(IggIO handle)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
return io.FrameCountSinceLastInput;
}
void iggSetFrameCountSinceLastInput(IggIO handle, int count)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.FrameCountSinceLastInput = count;
}
void iggIoAddFocusEvent(IggIO handle, IggBool focused)
{
ImGuiIO &io = *reinterpret_cast<ImGuiIO *>(handle);
io.AddFocusEvent(focused);
}