imgui-bindings 0.1.16 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1129 @@
1
+ require 'ffi'
2
+ require 'sdl3'
3
+ require_relative 'imgui'
4
+
5
+ module ImGui
6
+
7
+ ImGui_ImplDockingSDL3_MouseCaptureMode_Disabled = 0
8
+ ImGui_ImplDockingSDL3_MouseCaptureMode_Enabled = 1
9
+ ImGui_ImplDockingSDL3_MouseCaptureMode_EnabledAfterDrag = 2
10
+
11
+ ImGui_ImplDockingSDL3_GamepadMode_AutoFirst = 0
12
+ ImGui_ImplDockingSDL3_GamepadMode_AutoAll = 1
13
+ ImGui_ImplDockingSDL3_GamepadMode_Manual = 2
14
+
15
+ @@g_DockingSDL3BackendPlatformName = FFI::MemoryPointer.from_string('imgui_impl_docking_sdl3')
16
+ @@g_DockingSDL3BackendData = {}
17
+ @@g_DockingSDL3PlatformFunctions = nil
18
+
19
+ class ImGui_ImplDockingSDL3_Data
20
+ attr_accessor :window, :window_id, :renderer, :time, :clipboard_text_data,
21
+ :use_vulkan, :want_update_monitors, :ime_window, :ime_data,
22
+ :ime_dirty, :mouse_window_id, :mouse_buttons_down, :mouse_cursors,
23
+ :mouse_last_cursor, :mouse_pending_leave_frame,
24
+ :mouse_can_use_global_state, :mouse_can_report_hovered_viewport,
25
+ :mouse_capture_mode, :gamepads, :gamepad_mode,
26
+ :want_update_gamepads_list, :monitor_memory, :viewport_data
27
+
28
+ def initialize
29
+ @window = nil
30
+ @window_id = 0
31
+ @renderer = nil
32
+ @time = 0
33
+ @clipboard_text_data = nil
34
+ @use_vulkan = false
35
+ @want_update_monitors = false
36
+ @ime_window = nil
37
+ @ime_data = ImGuiPlatformImeData.new
38
+ @ime_data[:WantVisible] = false
39
+ @ime_data[:WantTextInput] = false
40
+ @ime_data[:InputPos][:x] = 0.0
41
+ @ime_data[:InputPos][:y] = 0.0
42
+ @ime_data[:InputLineHeight] = 0.0
43
+ @ime_data[:ViewportId] = 0
44
+ @ime_dirty = false
45
+ @mouse_window_id = 0
46
+ @mouse_buttons_down = 0
47
+ @mouse_cursors = Array.new(ImGuiMouseCursor_COUNT) { nil }
48
+ @mouse_last_cursor = nil
49
+ @mouse_pending_leave_frame = 0
50
+ @mouse_can_use_global_state = false
51
+ @mouse_can_report_hovered_viewport = false
52
+ @mouse_capture_mode = ImGui_ImplDockingSDL3_MouseCaptureMode_Disabled
53
+ @gamepads = []
54
+ @gamepad_mode = ImGui_ImplDockingSDL3_GamepadMode_AutoFirst
55
+ @want_update_gamepads_list = true
56
+ @monitor_memory = nil
57
+ @viewport_data = {}
58
+ end
59
+ end
60
+
61
+ class ImGui_ImplDockingSDL3_ViewportData
62
+ attr_accessor :window, :parent_window, :window_id, :window_owned, :gl_context
63
+
64
+ def initialize
65
+ @window = nil
66
+ @parent_window = nil
67
+ @window_id = 0
68
+ @window_owned = false
69
+ @gl_context = nil
70
+ end
71
+ end
72
+
73
+ def self.ImGui_ImplDockingSDL3_GetBackendData
74
+ context = ImGui::GetCurrentContext()
75
+ return nil if context == nil
76
+
77
+ @@g_DockingSDL3BackendData[context.address]
78
+ end
79
+
80
+ def self.ImGui_ImplDockingSDL3_GetViewportToken(viewport)
81
+ FFI::Pointer.new(viewport.pointer)
82
+ end
83
+
84
+ def self.ImGui_ImplDockingSDL3_GetViewportData(viewport_raw)
85
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
86
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
87
+ return nil if bd == nil
88
+
89
+ bd.viewport_data[viewport.pointer.address]
90
+ end
91
+
92
+ def self.ImGui_ImplDockingSDL3_SetViewportData(viewport_raw, data)
93
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
94
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
95
+ return if bd == nil
96
+
97
+ if data == nil
98
+ bd.viewport_data.delete(viewport.pointer.address)
99
+ viewport[:PlatformUserData] = nil
100
+ else
101
+ bd.viewport_data[viewport.pointer.address] = data
102
+ viewport[:PlatformUserData] = ImGui_ImplDockingSDL3_GetViewportToken(viewport)
103
+ end
104
+ end
105
+
106
+ def self.ImGui_ImplDockingSDL3_IsTouchMouse(which_id)
107
+ which_id == SDL::TOUCH_MOUSEID || which_id == 0xffffffff
108
+ end
109
+
110
+ def self.ImGui_ImplDockingSDL3_GetViewportForWindowID(window_id)
111
+ return nil if window_id == 0
112
+
113
+ viewport_ptr = ImGui::FindViewportByPlatformHandle(FFI::Pointer.new(window_id))
114
+ return nil if viewport_ptr == nil || viewport_ptr.address == 0
115
+
116
+ ImGuiViewport.new(viewport_ptr)
117
+ end
118
+
119
+ def self.ImGui_ImplDockingSDL3_GetSDLWindowFromViewport(viewport_raw)
120
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
121
+ handle = viewport[:PlatformHandle]
122
+ return nil if handle == nil || handle.address == 0
123
+
124
+ SDL.GetWindowFromID(handle.address)
125
+ end
126
+
127
+ def self.ImGui_ImplDockingSDL3_KeyEventToImGuiKey(keycode, scancode)
128
+ case scancode
129
+ when SDL::SCANCODE_KP_0 then ImGuiKey_Keypad0
130
+ when SDL::SCANCODE_KP_1 then ImGuiKey_Keypad1
131
+ when SDL::SCANCODE_KP_2 then ImGuiKey_Keypad2
132
+ when SDL::SCANCODE_KP_3 then ImGuiKey_Keypad3
133
+ when SDL::SCANCODE_KP_4 then ImGuiKey_Keypad4
134
+ when SDL::SCANCODE_KP_5 then ImGuiKey_Keypad5
135
+ when SDL::SCANCODE_KP_6 then ImGuiKey_Keypad6
136
+ when SDL::SCANCODE_KP_7 then ImGuiKey_Keypad7
137
+ when SDL::SCANCODE_KP_8 then ImGuiKey_Keypad8
138
+ when SDL::SCANCODE_KP_9 then ImGuiKey_Keypad9
139
+ when SDL::SCANCODE_KP_PERIOD then ImGuiKey_KeypadDecimal
140
+ when SDL::SCANCODE_KP_DIVIDE then ImGuiKey_KeypadDivide
141
+ when SDL::SCANCODE_KP_MULTIPLY then ImGuiKey_KeypadMultiply
142
+ when SDL::SCANCODE_KP_MINUS then ImGuiKey_KeypadSubtract
143
+ when SDL::SCANCODE_KP_PLUS then ImGuiKey_KeypadAdd
144
+ when SDL::SCANCODE_KP_ENTER then ImGuiKey_KeypadEnter
145
+ when SDL::SCANCODE_KP_EQUALS then ImGuiKey_KeypadEqual
146
+ end
147
+
148
+ case keycode
149
+ when SDL::SDLK_TAB then ImGuiKey_Tab
150
+ when SDL::SDLK_LEFT then ImGuiKey_LeftArrow
151
+ when SDL::SDLK_RIGHT then ImGuiKey_RightArrow
152
+ when SDL::SDLK_UP then ImGuiKey_UpArrow
153
+ when SDL::SDLK_DOWN then ImGuiKey_DownArrow
154
+ when SDL::SDLK_PAGEUP then ImGuiKey_PageUp
155
+ when SDL::SDLK_PAGEDOWN then ImGuiKey_PageDown
156
+ when SDL::SDLK_HOME then ImGuiKey_Home
157
+ when SDL::SDLK_END then ImGuiKey_End
158
+ when SDL::SDLK_INSERT then ImGuiKey_Insert
159
+ when SDL::SDLK_DELETE then ImGuiKey_Delete
160
+ when SDL::SDLK_BACKSPACE then ImGuiKey_Backspace
161
+ when SDL::SDLK_SPACE then ImGuiKey_Space
162
+ when SDL::SDLK_RETURN then ImGuiKey_Enter
163
+ when SDL::SDLK_ESCAPE then ImGuiKey_Escape
164
+ when SDL::SDLK_COMMA then ImGuiKey_Comma
165
+ when SDL::SDLK_PERIOD then ImGuiKey_Period
166
+ when SDL::SDLK_SEMICOLON then ImGuiKey_Semicolon
167
+ when SDL::SDLK_CAPSLOCK then ImGuiKey_CapsLock
168
+ when SDL::SDLK_SCROLLLOCK then ImGuiKey_ScrollLock
169
+ when SDL::SDLK_NUMLOCKCLEAR then ImGuiKey_NumLock
170
+ when SDL::SDLK_PRINTSCREEN then ImGuiKey_PrintScreen
171
+ when SDL::SDLK_PAUSE then ImGuiKey_Pause
172
+ when SDL::SDLK_LCTRL then ImGuiKey_LeftCtrl
173
+ when SDL::SDLK_LSHIFT then ImGuiKey_LeftShift
174
+ when SDL::SDLK_LALT then ImGuiKey_LeftAlt
175
+ when SDL::SDLK_LGUI then ImGuiKey_LeftSuper
176
+ when SDL::SDLK_RCTRL then ImGuiKey_RightCtrl
177
+ when SDL::SDLK_RSHIFT then ImGuiKey_RightShift
178
+ when SDL::SDLK_RALT then ImGuiKey_RightAlt
179
+ when SDL::SDLK_RGUI then ImGuiKey_RightSuper
180
+ when SDL::SDLK_APPLICATION then ImGuiKey_Menu
181
+ when SDL::SDLK_0 then ImGuiKey_0
182
+ when SDL::SDLK_1 then ImGuiKey_1
183
+ when SDL::SDLK_2 then ImGuiKey_2
184
+ when SDL::SDLK_3 then ImGuiKey_3
185
+ when SDL::SDLK_4 then ImGuiKey_4
186
+ when SDL::SDLK_5 then ImGuiKey_5
187
+ when SDL::SDLK_6 then ImGuiKey_6
188
+ when SDL::SDLK_7 then ImGuiKey_7
189
+ when SDL::SDLK_8 then ImGuiKey_8
190
+ when SDL::SDLK_9 then ImGuiKey_9
191
+ when SDL::SDLK_A then ImGuiKey_A
192
+ when SDL::SDLK_B then ImGuiKey_B
193
+ when SDL::SDLK_C then ImGuiKey_C
194
+ when SDL::SDLK_D then ImGuiKey_D
195
+ when SDL::SDLK_E then ImGuiKey_E
196
+ when SDL::SDLK_F then ImGuiKey_F
197
+ when SDL::SDLK_G then ImGuiKey_G
198
+ when SDL::SDLK_H then ImGuiKey_H
199
+ when SDL::SDLK_I then ImGuiKey_I
200
+ when SDL::SDLK_J then ImGuiKey_J
201
+ when SDL::SDLK_K then ImGuiKey_K
202
+ when SDL::SDLK_L then ImGuiKey_L
203
+ when SDL::SDLK_M then ImGuiKey_M
204
+ when SDL::SDLK_N then ImGuiKey_N
205
+ when SDL::SDLK_O then ImGuiKey_O
206
+ when SDL::SDLK_P then ImGuiKey_P
207
+ when SDL::SDLK_Q then ImGuiKey_Q
208
+ when SDL::SDLK_R then ImGuiKey_R
209
+ when SDL::SDLK_S then ImGuiKey_S
210
+ when SDL::SDLK_T then ImGuiKey_T
211
+ when SDL::SDLK_U then ImGuiKey_U
212
+ when SDL::SDLK_V then ImGuiKey_V
213
+ when SDL::SDLK_W then ImGuiKey_W
214
+ when SDL::SDLK_X then ImGuiKey_X
215
+ when SDL::SDLK_Y then ImGuiKey_Y
216
+ when SDL::SDLK_Z then ImGuiKey_Z
217
+ when SDL::SDLK_F1 then ImGuiKey_F1
218
+ when SDL::SDLK_F2 then ImGuiKey_F2
219
+ when SDL::SDLK_F3 then ImGuiKey_F3
220
+ when SDL::SDLK_F4 then ImGuiKey_F4
221
+ when SDL::SDLK_F5 then ImGuiKey_F5
222
+ when SDL::SDLK_F6 then ImGuiKey_F6
223
+ when SDL::SDLK_F7 then ImGuiKey_F7
224
+ when SDL::SDLK_F8 then ImGuiKey_F8
225
+ when SDL::SDLK_F9 then ImGuiKey_F9
226
+ when SDL::SDLK_F10 then ImGuiKey_F10
227
+ when SDL::SDLK_F11 then ImGuiKey_F11
228
+ when SDL::SDLK_F12 then ImGuiKey_F12
229
+ when SDL::SDLK_F13 then ImGuiKey_F13
230
+ when SDL::SDLK_F14 then ImGuiKey_F14
231
+ when SDL::SDLK_F15 then ImGuiKey_F15
232
+ when SDL::SDLK_F16 then ImGuiKey_F16
233
+ when SDL::SDLK_F17 then ImGuiKey_F17
234
+ when SDL::SDLK_F18 then ImGuiKey_F18
235
+ when SDL::SDLK_F19 then ImGuiKey_F19
236
+ when SDL::SDLK_F20 then ImGuiKey_F20
237
+ when SDL::SDLK_F21 then ImGuiKey_F21
238
+ when SDL::SDLK_F22 then ImGuiKey_F22
239
+ when SDL::SDLK_F23 then ImGuiKey_F23
240
+ when SDL::SDLK_F24 then ImGuiKey_F24
241
+ when SDL::SDLK_AC_BACK then ImGuiKey_AppBack
242
+ when SDL::SDLK_AC_FORWARD then ImGuiKey_AppForward
243
+ else
244
+ case scancode
245
+ when SDL::SCANCODE_GRAVE then ImGuiKey_GraveAccent
246
+ when SDL::SCANCODE_MINUS then ImGuiKey_Minus
247
+ when SDL::SCANCODE_EQUALS then ImGuiKey_Equal
248
+ when SDL::SCANCODE_LEFTBRACKET then ImGuiKey_LeftBracket
249
+ when SDL::SCANCODE_RIGHTBRACKET then ImGuiKey_RightBracket
250
+ when SDL::SCANCODE_NONUSBACKSLASH then ImGuiKey_Oem102
251
+ when SDL::SCANCODE_BACKSLASH then ImGuiKey_Backslash
252
+ when SDL::SCANCODE_SEMICOLON then ImGuiKey_Semicolon
253
+ when SDL::SCANCODE_APOSTROPHE then ImGuiKey_Apostrophe
254
+ when SDL::SCANCODE_COMMA then ImGuiKey_Comma
255
+ when SDL::SCANCODE_PERIOD then ImGuiKey_Period
256
+ when SDL::SCANCODE_SLASH then ImGuiKey_Slash
257
+ else ImGuiKey_None
258
+ end
259
+ end
260
+ end
261
+
262
+ def self.ImGui_ImplDockingSDL3_UpdateKeyModifiers(sdl_key_mods)
263
+ io = ImGuiIO.new(ImGui::GetIO())
264
+ io.AddKeyEvent(ImGuiMod_Ctrl, (sdl_key_mods & SDL::KMOD_CTRL) != 0)
265
+ io.AddKeyEvent(ImGuiMod_Shift, (sdl_key_mods & SDL::KMOD_SHIFT) != 0)
266
+ io.AddKeyEvent(ImGuiMod_Alt, (sdl_key_mods & SDL::KMOD_ALT) != 0)
267
+ io.AddKeyEvent(ImGuiMod_Super, (sdl_key_mods & SDL::KMOD_GUI) != 0)
268
+ end
269
+
270
+ def self.ImGui_ImplDockingSDL3_CopyImeData(dst, src)
271
+ dst[:WantVisible] = src[:WantVisible]
272
+ dst[:WantTextInput] = src[:WantTextInput]
273
+ dst[:InputPos][:x] = src[:InputPos][:x]
274
+ dst[:InputPos][:y] = src[:InputPos][:y]
275
+ dst[:InputLineHeight] = src[:InputLineHeight]
276
+ dst[:ViewportId] = src[:ViewportId]
277
+ end
278
+
279
+ def self.ImGui_ImplDockingSDL3_GetClipboardText(_context)
280
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
281
+ return nil if bd == nil
282
+
283
+ SDL.free(bd.clipboard_text_data) if bd.clipboard_text_data != nil
284
+ bd.clipboard_text_data = SDL.HasClipboardText() ? SDL.GetClipboardText() : nil
285
+ bd.clipboard_text_data
286
+ end
287
+
288
+ def self.ImGui_ImplDockingSDL3_SetClipboardText(_context, text)
289
+ SDL.SetClipboardText(text)
290
+ end
291
+
292
+ def self.ImGui_ImplDockingSDL3_PlatformSetImeData(_context, _viewport, data_raw)
293
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
294
+ return if bd == nil
295
+
296
+ data = data_raw.kind_of?(ImGuiPlatformImeData) ? data_raw : ImGuiPlatformImeData.new(data_raw)
297
+ ImGui_ImplDockingSDL3_CopyImeData(bd.ime_data, data)
298
+ bd.ime_dirty = true
299
+ ImGui_ImplDockingSDL3_UpdateIme
300
+ end
301
+
302
+ def self.ImGui_ImplDockingSDL3_UpdateIme
303
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
304
+ return if bd == nil
305
+
306
+ data = bd.ime_data
307
+ window = SDL.GetKeyboardFocus()
308
+
309
+ if (!(data[:WantVisible] || data[:WantTextInput]) || bd.ime_window != window) && bd.ime_window != nil
310
+ SDL.StopTextInput(bd.ime_window)
311
+ bd.ime_window = nil
312
+ end
313
+ return if (!bd.ime_dirty && bd.ime_window == window) || window == nil
314
+
315
+ bd.ime_dirty = false
316
+ if data[:WantVisible]
317
+ viewport_pos = ImVec2.create(0.0, 0.0)
318
+ viewport = ImGui_ImplDockingSDL3_GetViewportForWindowID(SDL.GetWindowID(window))
319
+ if viewport != nil
320
+ viewport_pos[:x] = viewport[:Pos][:x]
321
+ viewport_pos[:y] = viewport[:Pos][:y]
322
+ end
323
+ rect = SDL::Rect.new
324
+ rect[:x] = (data[:InputPos][:x] - viewport_pos[:x]).to_i
325
+ rect[:y] = (data[:InputPos][:y] - viewport_pos[:y]).to_i
326
+ rect[:w] = 1
327
+ rect[:h] = data[:InputLineHeight].to_i
328
+ SDL.SetTextInputArea(window, rect, 0)
329
+ bd.ime_window = window
330
+ end
331
+ SDL.StartTextInput(window) if !SDL.TextInputActive(window) && (data[:WantVisible] || data[:WantTextInput])
332
+ end
333
+
334
+ def self.ImGui_ImplDockingSDL3_SetupPlatformHandles(viewport_raw, window)
335
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
336
+ viewport[:PlatformHandle] = FFI::Pointer.new(SDL.GetWindowID(window))
337
+ viewport[:PlatformHandleRaw] = nil
338
+ if FFI::Platform.windows?
339
+ props = SDL.GetWindowProperties(window)
340
+ viewport[:PlatformHandleRaw] = SDL.GetPointerProperty(props, SDL::PROP_WINDOW_WIN32_HWND_POINTER, nil)
341
+ elsif FFI::Platform.mac?
342
+ props = SDL.GetWindowProperties(window)
343
+ viewport[:PlatformHandleRaw] = SDL.GetPointerProperty(props, SDL::PROP_WINDOW_COCOA_WINDOW_POINTER, nil)
344
+ end
345
+ end
346
+
347
+ def self.ImGui_ImplDockingSDL3_UpdateMonitors
348
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
349
+ return if bd == nil
350
+
351
+ platform_io = ImGuiPlatformIO.new(ImGui::GetPlatformIO())
352
+ monitors = platform_io[:Monitors]
353
+ monitors[:Size] = 0
354
+ bd.want_update_monitors = false
355
+
356
+ count_ptr = FFI::MemoryPointer.new(:int)
357
+ displays_ptr = SDL.GetDisplays(count_ptr)
358
+ display_count = count_ptr.read_int
359
+
360
+ if displays_ptr == nil || displays_ptr.address == 0 || display_count <= 0
361
+ bd.monitor_memory = nil
362
+ monitors[:Capacity] = 0
363
+ monitors[:Data] = nil
364
+ return
365
+ end
366
+
367
+ bd.monitor_memory = FFI::MemoryPointer.new(ImGuiPlatformMonitor, display_count)
368
+ monitors[:Capacity] = display_count
369
+ monitors[:Data] = bd.monitor_memory
370
+
371
+ valid_count = 0
372
+ display_count.times do |index|
373
+ display_id = (displays_ptr + index * FFI.type_size(:uint)).read_uint
374
+ monitor = ImGuiPlatformMonitor.new(bd.monitor_memory + valid_count * ImGuiPlatformMonitor.size)
375
+ rect = SDL::Rect.new
376
+ SDL.GetDisplayBounds(display_id, rect)
377
+ monitor[:MainPos][:x] = rect[:x].to_f
378
+ monitor[:MainPos][:y] = rect[:y].to_f
379
+ monitor[:WorkPos][:x] = rect[:x].to_f
380
+ monitor[:WorkPos][:y] = rect[:y].to_f
381
+ monitor[:MainSize][:x] = rect[:w].to_f
382
+ monitor[:MainSize][:y] = rect[:h].to_f
383
+ monitor[:WorkSize][:x] = rect[:w].to_f
384
+ monitor[:WorkSize][:y] = rect[:h].to_f
385
+ if SDL.GetDisplayUsableBounds(display_id, rect) && rect[:w] > 0 && rect[:h] > 0
386
+ monitor[:WorkPos][:x] = rect[:x].to_f
387
+ monitor[:WorkPos][:y] = rect[:y].to_f
388
+ monitor[:WorkSize][:x] = rect[:w].to_f
389
+ monitor[:WorkSize][:y] = rect[:h].to_f
390
+ end
391
+ monitor[:DpiScale] = SDL.GetDisplayContentScale(display_id)
392
+ next if monitor[:DpiScale] <= 0.0
393
+
394
+ monitor[:PlatformHandle] = FFI::Pointer.new(index)
395
+ valid_count += 1
396
+ end
397
+
398
+ monitors[:Size] = valid_count
399
+
400
+ SDL.free(displays_ptr)
401
+ end
402
+
403
+ def self.ImGui_ImplDockingSDL3_GetWindowSizeAndFramebufferScale(window)
404
+ w_ptr = FFI::MemoryPointer.new(:int)
405
+ h_ptr = FFI::MemoryPointer.new(:int)
406
+ SDL.GetWindowSize(window, w_ptr, h_ptr)
407
+ w = w_ptr.read_int
408
+ h = h_ptr.read_int
409
+ if (SDL.GetWindowFlags(window) & SDL::WINDOW_MINIMIZED) != 0
410
+ w = 0
411
+ h = 0
412
+ end
413
+
414
+ if FFI::Platform.mac?
415
+ scale_x = SDL.GetWindowDisplayScale(window)
416
+ scale_y = scale_x
417
+ else
418
+ display_w_ptr = FFI::MemoryPointer.new(:int)
419
+ display_h_ptr = FFI::MemoryPointer.new(:int)
420
+ SDL.GetWindowSizeInPixels(window, display_w_ptr, display_h_ptr)
421
+ display_w = display_w_ptr.read_int
422
+ display_h = display_h_ptr.read_int
423
+ scale_x = w > 0 ? display_w.to_f / w.to_f : 1.0
424
+ scale_y = h > 0 ? display_h.to_f / h.to_f : 1.0
425
+ end
426
+
427
+ [w, h, scale_x, scale_y]
428
+ end
429
+
430
+ def self.ImGui_ImplDockingSDL3_EnsureCallbacks
431
+ return @@g_DockingSDL3PlatformFunctions if @@g_DockingSDL3PlatformFunctions != nil
432
+
433
+ @@g_DockingSDL3PlatformFunctions = {
434
+ get_clipboard_text: FFI::Function.new(:pointer, [:pointer]) { |context| ImGui_ImplDockingSDL3_GetClipboardText(context) },
435
+ set_clipboard_text: FFI::Function.new(:void, [:pointer, :pointer]) { |context, text| ImGui_ImplDockingSDL3_SetClipboardText(context, text) },
436
+ set_ime_data: FFI::Function.new(:void, [:pointer, :pointer, :pointer]) { |context, viewport, data| ImGui_ImplDockingSDL3_PlatformSetImeData(context, viewport, data) },
437
+ open_in_shell: FFI::Function.new(:bool, [:pointer, :pointer]) { |_context, url| SDL.OpenURL(url) },
438
+ create_window: FFI::Function.new(:void, [:pointer]) { |viewport| ImGui_ImplDockingSDL3_CreateWindow(ImGuiViewport.new(viewport)) },
439
+ destroy_window: FFI::Function.new(:void, [:pointer]) { |viewport| ImGui_ImplDockingSDL3_DestroyWindow(ImGuiViewport.new(viewport)) },
440
+ show_window: FFI::Function.new(:void, [:pointer]) { |viewport| ImGui_ImplDockingSDL3_ShowWindow(ImGuiViewport.new(viewport)) },
441
+ update_window: FFI::Function.new(:void, [:pointer]) { |viewport| ImGui_ImplDockingSDL3_UpdateWindow(ImGuiViewport.new(viewport)) },
442
+ set_window_pos: FFI::Function.new(:void, [:pointer, ImVec2.by_value]) { |viewport, pos| ImGui_ImplDockingSDL3_SetWindowPos(ImGuiViewport.new(viewport), pos) },
443
+ get_window_pos: FFI::Function.new(ImVec2.by_value, [:pointer]) { |viewport| ImGui_ImplDockingSDL3_GetWindowPos(ImGuiViewport.new(viewport)) },
444
+ set_window_size: FFI::Function.new(:void, [:pointer, ImVec2.by_value]) { |viewport, size| ImGui_ImplDockingSDL3_SetWindowSize(ImGuiViewport.new(viewport), size) },
445
+ get_window_size: FFI::Function.new(ImVec2.by_value, [:pointer]) { |viewport| ImGui_ImplDockingSDL3_GetWindowSize(ImGuiViewport.new(viewport)) },
446
+ get_window_framebuffer_scale: FFI::Function.new(ImVec2.by_value, [:pointer]) { |viewport| ImGui_ImplDockingSDL3_GetWindowFramebufferScale(ImGuiViewport.new(viewport)) },
447
+ set_window_focus: FFI::Function.new(:void, [:pointer]) { |viewport| ImGui_ImplDockingSDL3_SetWindowFocus(ImGuiViewport.new(viewport)) },
448
+ get_window_focus: FFI::Function.new(:bool, [:pointer]) { |viewport| ImGui_ImplDockingSDL3_GetWindowFocus(ImGuiViewport.new(viewport)) },
449
+ get_window_minimized: FFI::Function.new(:bool, [:pointer]) { |viewport| ImGui_ImplDockingSDL3_GetWindowMinimized(ImGuiViewport.new(viewport)) },
450
+ set_window_title: FFI::Function.new(:void, [:pointer, :pointer]) { |viewport, title| ImGui_ImplDockingSDL3_SetWindowTitle(ImGuiViewport.new(viewport), title) },
451
+ render_window: FFI::Function.new(:void, [:pointer, :pointer]) { |viewport, arg| ImGui_ImplDockingSDL3_RenderWindow(ImGuiViewport.new(viewport), arg) },
452
+ swap_buffers: FFI::Function.new(:void, [:pointer, :pointer]) { |viewport, arg| ImGui_ImplDockingSDL3_SwapBuffers(ImGuiViewport.new(viewport), arg) },
453
+ set_window_alpha: FFI::Function.new(:void, [:pointer, :float]) { |viewport, alpha| ImGui_ImplDockingSDL3_SetWindowAlpha(ImGuiViewport.new(viewport), alpha) },
454
+ create_vk_surface: FFI::Function.new(:int, [:pointer, :uint64, :pointer, :pointer]) { |viewport, instance, allocator, out_surface| ImGui_ImplDockingSDL3_CreateVkSurface(ImGuiViewport.new(viewport), instance, allocator, out_surface) }
455
+ }
456
+ end
457
+
458
+ def self.ImplDockingSDL3_ProcessEvent(event)
459
+ io = ImGuiIO.new(ImGui::GetIO())
460
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
461
+ return false if bd == nil
462
+
463
+ event_type = event[:type]
464
+
465
+ case event_type
466
+ when SDL::EVENT_MOUSE_MOTION
467
+ return false if ImGui_ImplDockingSDL3_GetViewportForWindowID(event[:motion][:windowID]) == nil
468
+ mouse_x = event[:motion][:x].to_f
469
+ mouse_y = event[:motion][:y].to_f
470
+ if (io[:ConfigFlags] & ImGuiConfigFlags_ViewportsEnable) != 0
471
+ window = SDL.GetWindowFromID(event[:motion][:windowID])
472
+ if window != nil
473
+ wx = FFI::MemoryPointer.new(:int)
474
+ wy = FFI::MemoryPointer.new(:int)
475
+ SDL.GetWindowPosition(window, wx, wy)
476
+ mouse_x += wx.read_int
477
+ mouse_y += wy.read_int
478
+ end
479
+ end
480
+ io.AddMouseSourceEvent(ImGui_ImplDockingSDL3_IsTouchMouse(event[:motion][:which]) ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse)
481
+ io.AddMousePosEvent(mouse_x, mouse_y)
482
+ true
483
+
484
+ when SDL::EVENT_MOUSE_WHEEL
485
+ return false if ImGui_ImplDockingSDL3_GetViewportForWindowID(event[:wheel][:windowID]) == nil
486
+ io.AddMouseSourceEvent(ImGui_ImplDockingSDL3_IsTouchMouse(event[:wheel][:which]) ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse)
487
+ io.AddMouseWheelEvent(-event[:wheel][:x].to_f, event[:wheel][:y].to_f)
488
+ true
489
+
490
+ when SDL::EVENT_MOUSE_BUTTON_DOWN, SDL::EVENT_MOUSE_BUTTON_UP
491
+ return false if ImGui_ImplDockingSDL3_GetViewportForWindowID(event[:button][:windowID]) == nil
492
+ mouse_button = -1
493
+ mouse_button = 0 if event[:button][:button] == SDL::BUTTON_LEFT
494
+ mouse_button = 1 if event[:button][:button] == SDL::BUTTON_RIGHT
495
+ mouse_button = 2 if event[:button][:button] == SDL::BUTTON_MIDDLE
496
+ mouse_button = 3 if event[:button][:button] == SDL::BUTTON_X1
497
+ mouse_button = 4 if event[:button][:button] == SDL::BUTTON_X2
498
+ return false if mouse_button == -1
499
+
500
+ is_down = event_type == SDL::EVENT_MOUSE_BUTTON_DOWN
501
+ io.AddMouseSourceEvent(ImGui_ImplDockingSDL3_IsTouchMouse(event[:button][:which]) ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse)
502
+ io.AddMouseButtonEvent(mouse_button, is_down)
503
+ bd.mouse_buttons_down = is_down ? (bd.mouse_buttons_down | (1 << mouse_button)) : (bd.mouse_buttons_down & ~(1 << mouse_button))
504
+ true
505
+
506
+ when SDL::EVENT_TEXT_INPUT
507
+ return false if ImGui_ImplDockingSDL3_GetViewportForWindowID(event[:text][:windowID]) == nil
508
+ io.AddInputCharactersUTF8(event[:text][:text].read_string)
509
+ true
510
+
511
+ when SDL::EVENT_KEY_DOWN, SDL::EVENT_KEY_UP
512
+ viewport = ImGui_ImplDockingSDL3_GetViewportForWindowID(event[:key][:windowID])
513
+ return false if viewport == nil
514
+ ImGui_ImplDockingSDL3_UpdateKeyModifiers(event[:key][:mod])
515
+ key = ImGui_ImplDockingSDL3_KeyEventToImGuiKey(event[:key][:key], event[:key][:scancode])
516
+ io.AddKeyEvent(key, event_type == SDL::EVENT_KEY_DOWN)
517
+ io.SetKeyEventNativeDataEx(key, event[:key][:key], event[:key][:scancode], event[:key][:scancode])
518
+ true
519
+
520
+ when SDL::EVENT_DISPLAY_ORIENTATION, SDL::EVENT_DISPLAY_ADDED, SDL::EVENT_DISPLAY_REMOVED,
521
+ SDL::EVENT_DISPLAY_MOVED, SDL::EVENT_DISPLAY_CONTENT_SCALE_CHANGED
522
+ bd.want_update_monitors = true
523
+ true
524
+
525
+ when SDL::EVENT_WINDOW_MOUSE_ENTER
526
+ return false if ImGui_ImplDockingSDL3_GetViewportForWindowID(event[:window][:windowID]) == nil
527
+ bd.mouse_window_id = event[:window][:windowID]
528
+ bd.mouse_pending_leave_frame = 0
529
+ true
530
+
531
+ when SDL::EVENT_WINDOW_MOUSE_LEAVE
532
+ return false if ImGui_ImplDockingSDL3_GetViewportForWindowID(event[:window][:windowID]) == nil
533
+ bd.mouse_pending_leave_frame = ImGui::GetFrameCount() + 1
534
+ true
535
+
536
+ when SDL::EVENT_WINDOW_FOCUS_GAINED, SDL::EVENT_WINDOW_FOCUS_LOST
537
+ return false if ImGui_ImplDockingSDL3_GetViewportForWindowID(event[:window][:windowID]) == nil
538
+ io.AddFocusEvent(event_type == SDL::EVENT_WINDOW_FOCUS_GAINED)
539
+ true
540
+
541
+ when SDL::EVENT_WINDOW_CLOSE_REQUESTED, SDL::EVENT_WINDOW_MOVED, SDL::EVENT_WINDOW_RESIZED
542
+ viewport = ImGui_ImplDockingSDL3_GetViewportForWindowID(event[:window][:windowID])
543
+ return false if viewport == nil
544
+ viewport[:PlatformRequestClose] = true if event_type == SDL::EVENT_WINDOW_CLOSE_REQUESTED
545
+ viewport[:PlatformRequestMove] = true if event_type == SDL::EVENT_WINDOW_MOVED
546
+ viewport[:PlatformRequestResize] = true if event_type == SDL::EVENT_WINDOW_RESIZED
547
+ true
548
+
549
+ when SDL::EVENT_GAMEPAD_ADDED, SDL::EVENT_GAMEPAD_REMOVED
550
+ bd.want_update_gamepads_list = true
551
+ true
552
+
553
+ else
554
+ if defined?(SDL::EVENT_DISPLAY_USABLE_BOUNDS_CHANGED) && event_type == SDL::EVENT_DISPLAY_USABLE_BOUNDS_CHANGED
555
+ bd.want_update_monitors = true
556
+ true
557
+ else
558
+ false
559
+ end
560
+ end
561
+ end
562
+
563
+ def self.ImplDockingSDL3_Init(window, renderer = nil, sdl_gl_context = nil)
564
+ io = ImGuiIO.new(ImGui::GetIO())
565
+ raise 'Already initialized a platform backend!' if io[:BackendPlatformUserData] != nil && io[:BackendPlatformUserData].address != 0
566
+
567
+ bd = ImGui_ImplDockingSDL3_Data.new
568
+ bd.window = window
569
+ bd.window_id = SDL.GetWindowID(window)
570
+ bd.renderer = renderer
571
+
572
+ sdl_backend = SDL.GetCurrentVideoDriver()
573
+ sdl_backend_name = sdl_backend == nil ? '' : sdl_backend.read_string
574
+ %w[windows cocoa x11 DIVE VMAN].each do |platform|
575
+ next unless sdl_backend_name.start_with?(platform)
576
+
577
+ bd.mouse_can_use_global_state = true
578
+ bd.mouse_capture_mode = platform == 'x11' ? ImGui_ImplDockingSDL3_MouseCaptureMode_EnabledAfterDrag : ImGui_ImplDockingSDL3_MouseCaptureMode_Enabled
579
+ break
580
+ end
581
+ bd.mouse_can_report_hovered_viewport = !FFI::Platform.mac? && bd.mouse_can_use_global_state
582
+
583
+ @@g_DockingSDL3BackendData[ImGui::GetCurrentContext().address] = bd
584
+
585
+ io[:BackendPlatformUserData] = FFI::Pointer.new(ImGui::GetCurrentContext().address)
586
+ io[:BackendPlatformName] = @@g_DockingSDL3BackendPlatformName
587
+ io[:BackendFlags] |= ImGuiBackendFlags_HasMouseCursors
588
+ io[:BackendFlags] |= ImGuiBackendFlags_HasSetMousePos
589
+ if bd.mouse_can_use_global_state
590
+ io[:BackendFlags] |= ImGuiBackendFlags_PlatformHasViewports
591
+ io[:BackendFlags] |= ImGuiBackendFlags_HasParentViewport
592
+ end
593
+
594
+ callbacks = ImGui_ImplDockingSDL3_EnsureCallbacks()
595
+ platform_io = ImGuiPlatformIO.new(ImGui::GetPlatformIO())
596
+ platform_io[:Platform_SetClipboardTextFn] = callbacks[:set_clipboard_text]
597
+ platform_io[:Platform_GetClipboardTextFn] = callbacks[:get_clipboard_text]
598
+ platform_io[:Platform_SetImeDataFn] = callbacks[:set_ime_data]
599
+ platform_io[:Platform_OpenInShellFn] = callbacks[:open_in_shell]
600
+
601
+ bd.want_update_monitors = true
602
+ ImGui_ImplDockingSDL3_UpdateMonitors()
603
+
604
+ bd.mouse_cursors[ImGuiMouseCursor_Arrow] = SDL.CreateSystemCursor(SDL::SYSTEM_CURSOR_DEFAULT)
605
+ bd.mouse_cursors[ImGuiMouseCursor_TextInput] = SDL.CreateSystemCursor(SDL::SYSTEM_CURSOR_TEXT)
606
+ bd.mouse_cursors[ImGuiMouseCursor_ResizeAll] = SDL.CreateSystemCursor(SDL::SYSTEM_CURSOR_MOVE)
607
+ bd.mouse_cursors[ImGuiMouseCursor_ResizeNS] = SDL.CreateSystemCursor(SDL::SYSTEM_CURSOR_NS_RESIZE)
608
+ bd.mouse_cursors[ImGuiMouseCursor_ResizeEW] = SDL.CreateSystemCursor(SDL::SYSTEM_CURSOR_EW_RESIZE)
609
+ bd.mouse_cursors[ImGuiMouseCursor_ResizeNESW] = SDL.CreateSystemCursor(SDL::SYSTEM_CURSOR_NESW_RESIZE)
610
+ bd.mouse_cursors[ImGuiMouseCursor_ResizeNWSE] = SDL.CreateSystemCursor(SDL::SYSTEM_CURSOR_NWSE_RESIZE)
611
+ bd.mouse_cursors[ImGuiMouseCursor_Hand] = SDL.CreateSystemCursor(SDL::SYSTEM_CURSOR_POINTER)
612
+ bd.mouse_cursors[ImGuiMouseCursor_Wait] = SDL.CreateSystemCursor(SDL::SYSTEM_CURSOR_WAIT)
613
+ bd.mouse_cursors[ImGuiMouseCursor_Progress] = SDL.CreateSystemCursor(SDL::SYSTEM_CURSOR_PROGRESS)
614
+ bd.mouse_cursors[ImGuiMouseCursor_NotAllowed] = SDL.CreateSystemCursor(SDL::SYSTEM_CURSOR_NOT_ALLOWED)
615
+
616
+ main_viewport = ImGuiViewport.new(ImGui::GetMainViewport())
617
+ ImGui_ImplDockingSDL3_SetupPlatformHandles(main_viewport, window)
618
+
619
+ SDL.SetHint(SDL::HINT_MOUSE_FOCUS_CLICKTHROUGH, '1') if defined?(SDL::HINT_MOUSE_FOCUS_CLICKTHROUGH)
620
+ SDL.SetHint(SDL::HINT_MOUSE_AUTO_CAPTURE, '0') if defined?(SDL::HINT_MOUSE_AUTO_CAPTURE)
621
+ SDL.SetHint('SDL_BORDERLESS_WINDOWED_STYLE', '0')
622
+
623
+ ImGui_ImplDockingSDL3_InitMultiViewportSupport(window, sdl_gl_context) if (io[:BackendFlags] & ImGuiBackendFlags_PlatformHasViewports) != 0
624
+ true
625
+ end
626
+
627
+ def self.ImplDockingSDL3_InitForOpenGL(window, sdl_gl_context = nil)
628
+ ImplDockingSDL3_Init(window, nil, sdl_gl_context)
629
+ end
630
+
631
+ def self.ImplDockingSDL3_InitForVulkan(window)
632
+ result = ImplDockingSDL3_Init(window, nil, nil)
633
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
634
+ bd.use_vulkan = true if result && bd != nil
635
+ result
636
+ end
637
+
638
+ def self.ImplDockingSDL3_InitForD3D(window)
639
+ ImplDockingSDL3_Init(window, nil, nil)
640
+ end
641
+
642
+ def self.ImplDockingSDL3_InitForMetal(window)
643
+ ImplDockingSDL3_Init(window, nil, nil)
644
+ end
645
+
646
+ def self.ImplDockingSDL3_InitForSDLRenderer(window, renderer)
647
+ ImplDockingSDL3_Init(window, renderer, nil)
648
+ end
649
+
650
+ def self.ImplDockingSDL3_InitForSDLGPU(window)
651
+ ImplDockingSDL3_Init(window, nil, nil)
652
+ end
653
+
654
+ def self.ImplDockingSDL3_InitForOther(window)
655
+ ImplDockingSDL3_Init(window, nil, nil)
656
+ end
657
+
658
+ def self.ImplDockingSDL3_CloseGamepads
659
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
660
+ return if bd == nil
661
+
662
+ if bd.gamepad_mode != ImGui_ImplDockingSDL3_GamepadMode_Manual
663
+ bd.gamepads.each { |gamepad| SDL.CloseGamepad(gamepad) if gamepad != nil }
664
+ end
665
+ bd.gamepads = []
666
+ end
667
+
668
+ def self.ImplDockingSDL3_SetGamepadMode(mode, manual_gamepads_array = nil)
669
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
670
+ return if bd == nil
671
+
672
+ ImplDockingSDL3_CloseGamepads()
673
+ if mode == ImGui_ImplDockingSDL3_GamepadMode_Manual()
674
+ bd.gamepads = manual_gamepads_array ? manual_gamepads_array.compact : []
675
+ else
676
+ bd.want_update_gamepads_list = true
677
+ end
678
+ bd.gamepad_mode = mode
679
+ end
680
+
681
+ def self.ImplDockingSDL3_Shutdown
682
+ io = ImGuiIO.new(ImGui::GetIO())
683
+ platform_io = ImGuiPlatformIO.new(ImGui::GetPlatformIO())
684
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
685
+ return if bd == nil
686
+
687
+ ImGui_ImplDockingSDL3_ShutdownMultiViewportSupport()
688
+ SDL.free(bd.clipboard_text_data) if bd.clipboard_text_data != nil
689
+ bd.mouse_cursors.each { |cursor| SDL.DestroyCursor(cursor) if cursor != nil }
690
+ ImplDockingSDL3_CloseGamepads()
691
+
692
+ io[:BackendPlatformName] = nil
693
+ io[:BackendPlatformUserData] = nil
694
+ io[:BackendFlags] &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport | ImGuiBackendFlags_HasParentViewport)
695
+ platform_io.ClearPlatformHandlers
696
+ @@g_DockingSDL3BackendData.delete(ImGui::GetCurrentContext().address)
697
+ end
698
+
699
+ def self.ImplDockingSDL3_SetMouseCaptureMode(mode)
700
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
701
+ return if bd == nil
702
+
703
+ SDL.CaptureMouse(false) if mode == ImGui_ImplDockingSDL3_MouseCaptureMode_Disabled && bd.mouse_capture_mode != ImGui_ImplDockingSDL3_MouseCaptureMode_Disabled
704
+ bd.mouse_capture_mode = mode
705
+ end
706
+
707
+ def self.ImplDockingSDL3_UpdateMouseData
708
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
709
+ io = ImGuiIO.new(ImGui::GetIO())
710
+ return if bd == nil
711
+
712
+ if bd.mouse_capture_mode == ImGui_ImplDockingSDL3_MouseCaptureMode_Enabled
713
+ SDL.CaptureMouse(bd.mouse_buttons_down != 0)
714
+ elsif bd.mouse_capture_mode == ImGui_ImplDockingSDL3_MouseCaptureMode_EnabledAfterDrag
715
+ want_capture = false
716
+ ImGuiMouseButton_COUNT.times do |button_n|
717
+ if ImGui::IsMouseDragging(button_n, 1.0)
718
+ want_capture = true
719
+ break
720
+ end
721
+ end
722
+ SDL.CaptureMouse(want_capture)
723
+ end
724
+
725
+ focused_window = SDL.GetKeyboardFocus()
726
+ is_app_focused = focused_window != nil && (bd.window == focused_window || ImGui_ImplDockingSDL3_GetViewportForWindowID(SDL.GetWindowID(focused_window)) != nil)
727
+ return unless is_app_focused
728
+
729
+ if io[:WantSetMousePos]
730
+ if (io[:ConfigFlags] & ImGuiConfigFlags_ViewportsEnable) != 0
731
+ SDL.WarpMouseGlobal(io[:MousePos][:x], io[:MousePos][:y])
732
+ else
733
+ SDL.WarpMouseInWindow(bd.window, io[:MousePos][:x], io[:MousePos][:y])
734
+ end
735
+ end
736
+
737
+ hovered_window = SDL.GetMouseFocus()
738
+ is_relative_mouse_mode = SDL.GetWindowRelativeMouseMode(bd.window)
739
+ if hovered_window == nil && bd.mouse_can_use_global_state && bd.mouse_buttons_down == 0 && !is_relative_mouse_mode
740
+ mx = FFI::MemoryPointer.new(:float)
741
+ my = FFI::MemoryPointer.new(:float)
742
+ SDL.GetGlobalMouseState(mx, my)
743
+ mouse_x = mx.read_float
744
+ mouse_y = my.read_float
745
+ if (io[:ConfigFlags] & ImGuiConfigFlags_ViewportsEnable) == 0
746
+ wx = FFI::MemoryPointer.new(:int)
747
+ wy = FFI::MemoryPointer.new(:int)
748
+ SDL.GetWindowPosition(focused_window, wx, wy)
749
+ mouse_x -= wx.read_int
750
+ mouse_y -= wy.read_int
751
+ end
752
+ io.AddMousePosEvent(mouse_x, mouse_y)
753
+ end
754
+
755
+ if (io[:BackendFlags] & ImGuiBackendFlags_HasMouseHoveredViewport) != 0
756
+ mouse_viewport_id = 0
757
+ mouse_viewport = ImGui_ImplDockingSDL3_GetViewportForWindowID(bd.mouse_window_id)
758
+ mouse_viewport_id = mouse_viewport[:ID] if mouse_viewport != nil
759
+ io.AddMouseViewportEvent(mouse_viewport_id)
760
+ end
761
+ end
762
+
763
+ def self.ImplDockingSDL3_UpdateMouseCursor
764
+ io = ImGuiIO.new(ImGui::GetIO())
765
+ return if (io[:ConfigFlags] & ImGuiConfigFlags_NoMouseCursorChange) != 0
766
+
767
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
768
+ return if bd == nil
769
+
770
+ imgui_cursor = ImGui::GetMouseCursor()
771
+ if io[:MouseDrawCursor] || imgui_cursor == ImGuiMouseCursor_None
772
+ SDL.HideCursor
773
+ else
774
+ expected_cursor = bd.mouse_cursors[imgui_cursor] || bd.mouse_cursors[ImGuiMouseCursor_Arrow]
775
+ if bd.mouse_last_cursor != expected_cursor
776
+ SDL.SetCursor(expected_cursor)
777
+ bd.mouse_last_cursor = expected_cursor
778
+ end
779
+ SDL.ShowCursor
780
+ end
781
+ end
782
+
783
+ def self.ImplDockingSDL3_Saturate(v)
784
+ return 0.0 if v < 0.0
785
+ return 1.0 if v > 1.0
786
+
787
+ v
788
+ end
789
+
790
+ def self.ImplDockingSDL3_UpdateGamepadButton(bd, io, key, button_no)
791
+ merged_value = false
792
+ bd.gamepads.each do |gamepad|
793
+ merged_value ||= SDL.GetGamepadButton(gamepad, button_no)
794
+ end
795
+ io.AddKeyEvent(key, merged_value)
796
+ end
797
+
798
+ def self.ImplDockingSDL3_UpdateGamepadAnalog(bd, io, key, axis_no, v0, v1)
799
+ merged_value = 0.0
800
+ bd.gamepads.each do |gamepad|
801
+ vn = ImplDockingSDL3_Saturate((SDL.GetGamepadAxis(gamepad, axis_no) - v0).to_f / (v1 - v0).to_f)
802
+ merged_value = vn if merged_value < vn
803
+ end
804
+ io.AddKeyAnalogEvent(key, merged_value > 0.1, merged_value)
805
+ end
806
+
807
+ def self.ImplDockingSDL3_UpdateGamepads
808
+ io = ImGuiIO.new(ImGui::GetIO())
809
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
810
+ return if bd == nil
811
+
812
+ if bd.want_update_gamepads_list && bd.gamepad_mode != ImGui_ImplDockingSDL3_GamepadMode_Manual
813
+ ImplDockingSDL3_CloseGamepads()
814
+ count_ptr = FFI::MemoryPointer.new(:int)
815
+ gamepads_ptr = SDL.GetGamepads(count_ptr)
816
+ count = count_ptr.read_int
817
+ count.times do |n|
818
+ joystick_id = (gamepads_ptr + n * FFI.type_size(:uint)).read_uint
819
+ gamepad = SDL.OpenGamepad(joystick_id)
820
+ next if gamepad == nil
821
+
822
+ bd.gamepads << gamepad
823
+ break if bd.gamepad_mode == ImGui_ImplDockingSDL3_GamepadMode_AutoFirst
824
+ end
825
+ bd.want_update_gamepads_list = false
826
+ SDL.free(gamepads_ptr) if gamepads_ptr != nil
827
+ end
828
+
829
+ io[:BackendFlags] &= ~ImGuiBackendFlags_HasGamepad
830
+ return if bd.gamepads.empty?
831
+
832
+ io[:BackendFlags] |= ImGuiBackendFlags_HasGamepad
833
+ dead_zone = 8000
834
+ ImplDockingSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadStart, SDL::GAMEPAD_BUTTON_START)
835
+ ImplDockingSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadBack, SDL::GAMEPAD_BUTTON_BACK)
836
+ ImplDockingSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceLeft, SDL::GAMEPAD_BUTTON_WEST)
837
+ ImplDockingSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceRight, SDL::GAMEPAD_BUTTON_EAST)
838
+ ImplDockingSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceUp, SDL::GAMEPAD_BUTTON_NORTH)
839
+ ImplDockingSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceDown, SDL::GAMEPAD_BUTTON_SOUTH)
840
+ ImplDockingSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadLeft, SDL::GAMEPAD_BUTTON_DPAD_LEFT)
841
+ ImplDockingSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadRight, SDL::GAMEPAD_BUTTON_DPAD_RIGHT)
842
+ ImplDockingSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadUp, SDL::GAMEPAD_BUTTON_DPAD_UP)
843
+ ImplDockingSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadDown, SDL::GAMEPAD_BUTTON_DPAD_DOWN)
844
+ ImplDockingSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadL1, SDL::GAMEPAD_BUTTON_LEFT_SHOULDER)
845
+ ImplDockingSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadR1, SDL::GAMEPAD_BUTTON_RIGHT_SHOULDER)
846
+ ImplDockingSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadL2, SDL::GAMEPAD_AXIS_LEFT_TRIGGER, 0.0, 32767.0)
847
+ ImplDockingSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadR2, SDL::GAMEPAD_AXIS_RIGHT_TRIGGER, 0.0, 32767.0)
848
+ ImplDockingSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadL3, SDL::GAMEPAD_BUTTON_LEFT_STICK)
849
+ ImplDockingSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadR3, SDL::GAMEPAD_BUTTON_RIGHT_STICK)
850
+ ImplDockingSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickLeft, SDL::GAMEPAD_AXIS_LEFTX, -dead_zone, -32768.0)
851
+ ImplDockingSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickRight, SDL::GAMEPAD_AXIS_LEFTX, dead_zone, 32767.0)
852
+ ImplDockingSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickUp, SDL::GAMEPAD_AXIS_LEFTY, -dead_zone, -32768.0)
853
+ ImplDockingSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickDown, SDL::GAMEPAD_AXIS_LEFTY, dead_zone, 32767.0)
854
+ ImplDockingSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickLeft, SDL::GAMEPAD_AXIS_RIGHTX, -dead_zone, -32768.0)
855
+ ImplDockingSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickRight, SDL::GAMEPAD_AXIS_RIGHTX, dead_zone, 32767.0)
856
+ ImplDockingSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickUp, SDL::GAMEPAD_AXIS_RIGHTY, -dead_zone, -32768.0)
857
+ ImplDockingSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickDown, SDL::GAMEPAD_AXIS_RIGHTY, dead_zone, 32767.0)
858
+ end
859
+
860
+ def self.ImplDockingSDL3_NewFrame
861
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
862
+ raise 'Context or backend not initialized! Did you call ImGui::ImplDockingSDL3_Init()?' if bd == nil
863
+
864
+ io = ImGuiIO.new(ImGui::GetIO())
865
+
866
+ w, h, scale_x, scale_y = ImGui_ImplDockingSDL3_GetWindowSizeAndFramebufferScale(bd.window)
867
+ io[:DisplaySize] = ImVec2.create(w.to_f, h.to_f)
868
+ io[:DisplayFramebufferScale][:x] = scale_x
869
+ io[:DisplayFramebufferScale][:y] = scale_y
870
+
871
+ bd.want_update_monitors = true if FFI::Platform.windows?
872
+ ImGui_ImplDockingSDL3_UpdateMonitors() if bd.want_update_monitors
873
+
874
+ frequency = SDL.GetPerformanceFrequency()
875
+ current_time = SDL.GetPerformanceCounter()
876
+ current_time = bd.time + 1 if current_time <= bd.time
877
+ io[:DeltaTime] = bd.time > 0 ? (current_time - bd.time).to_f / frequency.to_f : (1.0 / 60.0)
878
+ bd.time = current_time
879
+
880
+ if bd.mouse_pending_leave_frame != 0 && bd.mouse_pending_leave_frame >= ImGui::GetFrameCount() && bd.mouse_buttons_down == 0
881
+ bd.mouse_window_id = 0
882
+ bd.mouse_pending_leave_frame = 0
883
+ io.AddMousePosEvent(-Float::MAX, -Float::MAX)
884
+ end
885
+
886
+ payload = ImGui::GetDragDropPayload()
887
+ if bd.mouse_can_report_hovered_viewport && (payload == nil || payload.address == 0)
888
+ io[:BackendFlags] |= ImGuiBackendFlags_HasMouseHoveredViewport
889
+ else
890
+ io[:BackendFlags] &= ~ImGuiBackendFlags_HasMouseHoveredViewport
891
+ end
892
+
893
+ ImplDockingSDL3_UpdateMouseData()
894
+ ImplDockingSDL3_UpdateMouseCursor()
895
+ ImGui_ImplDockingSDL3_UpdateIme()
896
+ ImplDockingSDL3_UpdateGamepads()
897
+ end
898
+
899
+ def self.ImGui_ImplDockingSDL3_CreateWindow(viewport_raw)
900
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
901
+ bd = ImGui_ImplDockingSDL3_GetBackendData()
902
+ return if bd == nil
903
+
904
+ vd = ImGui_ImplDockingSDL3_ViewportData.new
905
+ ImGui_ImplDockingSDL3_SetViewportData(viewport, vd)
906
+ vd.parent_window = ImGui_ImplDockingSDL3_GetSDLWindowFromViewport(viewport[:ParentViewport]) if viewport[:ParentViewport] != nil && viewport[:ParentViewport].address != 0
907
+
908
+ main_viewport = ImGuiViewport.new(ImGui::GetMainViewport())
909
+ main_viewport_data = ImGui_ImplDockingSDL3_GetViewportData(main_viewport)
910
+
911
+ use_opengl = main_viewport_data != nil && main_viewport_data.gl_context != nil
912
+ backup_context = nil
913
+ if use_opengl
914
+ backup_context = SDL.GL_GetCurrentContext()
915
+ SDL.GL_SetAttribute(SDL::GL_SHARE_WITH_CURRENT_CONTEXT, 1)
916
+ SDL.GL_MakeCurrent(main_viewport_data.window, main_viewport_data.gl_context)
917
+ end
918
+
919
+ sdl_flags = 0
920
+ sdl_flags |= SDL::WINDOW_HIDDEN
921
+ sdl_flags |= use_opengl ? SDL::WINDOW_OPENGL : (bd.use_vulkan ? SDL::WINDOW_VULKAN : 0)
922
+ sdl_flags |= SDL.GetWindowFlags(bd.window) & SDL::WINDOW_HIGH_PIXEL_DENSITY
923
+ sdl_flags |= (viewport[:Flags] & ImGuiViewportFlags_NoDecoration) != 0 ? SDL::WINDOW_BORDERLESS : 0
924
+ sdl_flags |= (viewport[:Flags] & ImGuiViewportFlags_NoDecoration) == 0 ? SDL::WINDOW_RESIZABLE : 0
925
+ sdl_flags |= (viewport[:Flags] & ImGuiViewportFlags_NoTaskBarIcon) != 0 ? SDL::WINDOW_UTILITY : 0 if defined?(SDL::WINDOW_UTILITY)
926
+ sdl_flags |= (viewport[:Flags] & ImGuiViewportFlags_TopMost) != 0 ? SDL::WINDOW_ALWAYS_ON_TOP : 0 if defined?(SDL::WINDOW_ALWAYS_ON_TOP)
927
+
928
+ vd.window = SDL.CreateWindow('No Title Yet', viewport[:Size][:x].to_i, viewport[:Size][:y].to_i, sdl_flags)
929
+ if !FFI::Platform.mac? && vd.parent_window != nil
930
+ SDL.SetWindowParent(vd.window, vd.parent_window)
931
+ end
932
+ SDL.SetWindowPosition(vd.window, viewport[:Pos][:x].to_i, viewport[:Pos][:y].to_i)
933
+ vd.window_owned = true
934
+ vd.window_id = SDL.GetWindowID(vd.window)
935
+ if use_opengl
936
+ vd.gl_context = SDL.GL_CreateContext(vd.window)
937
+ SDL.GL_SetSwapInterval(0)
938
+ end
939
+ SDL.GL_MakeCurrent(vd.window, backup_context) if use_opengl && backup_context != nil
940
+
941
+ ImGui_ImplDockingSDL3_SetupPlatformHandles(viewport, vd.window)
942
+ end
943
+
944
+ def self.ImGui_ImplDockingSDL3_DestroyWindow(viewport_raw)
945
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
946
+ vd = ImGui_ImplDockingSDL3_GetViewportData(viewport)
947
+ return if vd == nil
948
+
949
+ SDL.GL_DestroyContext(vd.gl_context) if vd.gl_context != nil && vd.window_owned
950
+ SDL.DestroyWindow(vd.window) if vd.window != nil && vd.window_owned
951
+ ImGui_ImplDockingSDL3_SetViewportData(viewport, nil)
952
+ viewport[:PlatformHandle] = nil
953
+ end
954
+
955
+ def self.ImGui_ImplDockingSDL3_ShowWindow(viewport_raw)
956
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
957
+ vd = ImGui_ImplDockingSDL3_GetViewportData(viewport)
958
+ return if vd == nil || vd.window == nil
959
+
960
+ hint = if FFI::Platform.mac?
961
+ '1'
962
+ else
963
+ (viewport[:Flags] & ImGuiViewportFlags_NoFocusOnAppearing) != 0 ? '0' : '1'
964
+ end
965
+ SDL.SetHint(SDL::HINT_WINDOW_ACTIVATE_WHEN_SHOWN, hint) if defined?(SDL::HINT_WINDOW_ACTIVATE_WHEN_SHOWN)
966
+ SDL.ShowWindow(vd.window)
967
+ end
968
+
969
+ def self.ImGui_ImplDockingSDL3_UpdateWindow(viewport_raw)
970
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
971
+ vd = ImGui_ImplDockingSDL3_GetViewportData(viewport)
972
+ return if vd == nil || vd.window == nil || FFI::Platform.mac?
973
+
974
+ new_parent = nil
975
+ new_parent = ImGui_ImplDockingSDL3_GetSDLWindowFromViewport(viewport[:ParentViewport]) if viewport[:ParentViewport] != nil && viewport[:ParentViewport].address != 0
976
+ if new_parent != vd.parent_window
977
+ vd.parent_window = new_parent
978
+ SDL.SetWindowParent(vd.window, vd.parent_window)
979
+ end
980
+ end
981
+
982
+ def self.ImGui_ImplDockingSDL3_GetWindowPos(viewport_raw)
983
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
984
+ vd = ImGui_ImplDockingSDL3_GetViewportData(viewport)
985
+ return ImVec2.create(0.0, 0.0) if vd == nil || vd.window == nil
986
+
987
+ x_ptr = FFI::MemoryPointer.new(:int)
988
+ y_ptr = FFI::MemoryPointer.new(:int)
989
+ SDL.GetWindowPosition(vd.window, x_ptr, y_ptr)
990
+ ImVec2.create(x_ptr.read_int.to_f, y_ptr.read_int.to_f)
991
+ end
992
+
993
+ def self.ImGui_ImplDockingSDL3_SetWindowPos(viewport_raw, pos)
994
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
995
+ vd = ImGui_ImplDockingSDL3_GetViewportData(viewport)
996
+ return if vd == nil || vd.window == nil
997
+
998
+ SDL.SetWindowPosition(vd.window, pos[:x].to_i, pos[:y].to_i)
999
+ end
1000
+
1001
+ def self.ImGui_ImplDockingSDL3_GetWindowSize(viewport_raw)
1002
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
1003
+ vd = ImGui_ImplDockingSDL3_GetViewportData(viewport)
1004
+ return ImVec2.create(0.0, 0.0) if vd == nil || vd.window == nil
1005
+
1006
+ w_ptr = FFI::MemoryPointer.new(:int)
1007
+ h_ptr = FFI::MemoryPointer.new(:int)
1008
+ SDL.GetWindowSize(vd.window, w_ptr, h_ptr)
1009
+ ImVec2.create(w_ptr.read_int.to_f, h_ptr.read_int.to_f)
1010
+ end
1011
+
1012
+ def self.ImGui_ImplDockingSDL3_SetWindowSize(viewport_raw, size)
1013
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
1014
+ vd = ImGui_ImplDockingSDL3_GetViewportData(viewport)
1015
+ return if vd == nil || vd.window == nil
1016
+
1017
+ SDL.SetWindowSize(vd.window, size[:x].to_i, size[:y].to_i)
1018
+ end
1019
+
1020
+ def self.ImGui_ImplDockingSDL3_GetWindowFramebufferScale(viewport_raw)
1021
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
1022
+ vd = ImGui_ImplDockingSDL3_GetViewportData(viewport)
1023
+ return ImVec2.create(1.0, 1.0) if vd == nil || vd.window == nil
1024
+
1025
+ _w, _h, scale_x, scale_y = ImGui_ImplDockingSDL3_GetWindowSizeAndFramebufferScale(vd.window)
1026
+ ImVec2.create(scale_x, scale_y)
1027
+ end
1028
+
1029
+ def self.ImGui_ImplDockingSDL3_SetWindowTitle(viewport_raw, title)
1030
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
1031
+ vd = ImGui_ImplDockingSDL3_GetViewportData(viewport)
1032
+ return if vd == nil || vd.window == nil
1033
+
1034
+ SDL.SetWindowTitle(vd.window, title)
1035
+ end
1036
+
1037
+ def self.ImGui_ImplDockingSDL3_SetWindowAlpha(viewport_raw, alpha)
1038
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
1039
+ vd = ImGui_ImplDockingSDL3_GetViewportData(viewport)
1040
+ return if vd == nil || vd.window == nil
1041
+
1042
+ SDL.SetWindowOpacity(vd.window, alpha)
1043
+ end
1044
+
1045
+ def self.ImGui_ImplDockingSDL3_SetWindowFocus(viewport_raw)
1046
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
1047
+ vd = ImGui_ImplDockingSDL3_GetViewportData(viewport)
1048
+ return if vd == nil || vd.window == nil
1049
+
1050
+ SDL.RaiseWindow(vd.window)
1051
+ end
1052
+
1053
+ def self.ImGui_ImplDockingSDL3_GetWindowFocus(viewport_raw)
1054
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
1055
+ vd = ImGui_ImplDockingSDL3_GetViewportData(viewport)
1056
+ return false if vd == nil || vd.window == nil
1057
+
1058
+ (SDL.GetWindowFlags(vd.window) & SDL::WINDOW_INPUT_FOCUS) != 0
1059
+ end
1060
+
1061
+ def self.ImGui_ImplDockingSDL3_GetWindowMinimized(viewport_raw)
1062
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
1063
+ vd = ImGui_ImplDockingSDL3_GetViewportData(viewport)
1064
+ return false if vd == nil || vd.window == nil
1065
+
1066
+ (SDL.GetWindowFlags(vd.window) & SDL::WINDOW_MINIMIZED) != 0
1067
+ end
1068
+
1069
+ def self.ImGui_ImplDockingSDL3_RenderWindow(viewport_raw, _render_arg)
1070
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
1071
+ vd = ImGui_ImplDockingSDL3_GetViewportData(viewport)
1072
+ return if vd == nil || vd.window == nil || vd.gl_context == nil
1073
+
1074
+ SDL.GL_MakeCurrent(vd.window, vd.gl_context)
1075
+ end
1076
+
1077
+ def self.ImGui_ImplDockingSDL3_SwapBuffers(viewport_raw, _render_arg)
1078
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
1079
+ vd = ImGui_ImplDockingSDL3_GetViewportData(viewport)
1080
+ return if vd == nil || vd.window == nil || vd.gl_context == nil
1081
+
1082
+ SDL.GL_MakeCurrent(vd.window, vd.gl_context)
1083
+ SDL.GL_SwapWindow(vd.window)
1084
+ end
1085
+
1086
+ def self.ImGui_ImplDockingSDL3_CreateVkSurface(viewport_raw, vk_instance, vk_allocator, out_vk_surface)
1087
+ viewport = viewport_raw.kind_of?(ImGuiViewport) ? viewport_raw : ImGuiViewport.new(viewport_raw)
1088
+ vd = ImGui_ImplDockingSDL3_GetViewportData(viewport)
1089
+ return 1 if vd == nil || vd.window == nil
1090
+
1091
+ SDL.Vulkan_CreateSurface(vd.window, FFI::Pointer.new(vk_instance), vk_allocator, out_vk_surface) ? 0 : 1
1092
+ end
1093
+
1094
+ def self.ImGui_ImplDockingSDL3_InitMultiViewportSupport(window, sdl_gl_context)
1095
+ callbacks = ImGui_ImplDockingSDL3_EnsureCallbacks()
1096
+ platform_io = ImGuiPlatformIO.new(ImGui::GetPlatformIO())
1097
+ platform_io[:Platform_CreateWindow] = callbacks[:create_window]
1098
+ platform_io[:Platform_DestroyWindow] = callbacks[:destroy_window]
1099
+ platform_io[:Platform_ShowWindow] = callbacks[:show_window]
1100
+ platform_io[:Platform_UpdateWindow] = callbacks[:update_window]
1101
+ platform_io[:Platform_SetWindowPos] = callbacks[:set_window_pos]
1102
+ platform_io[:Platform_GetWindowPos] = callbacks[:get_window_pos]
1103
+ platform_io[:Platform_SetWindowSize] = callbacks[:set_window_size]
1104
+ platform_io[:Platform_GetWindowSize] = callbacks[:get_window_size]
1105
+ platform_io[:Platform_GetWindowFramebufferScale] = callbacks[:get_window_framebuffer_scale]
1106
+ platform_io[:Platform_SetWindowFocus] = callbacks[:set_window_focus]
1107
+ platform_io[:Platform_GetWindowFocus] = callbacks[:get_window_focus]
1108
+ platform_io[:Platform_GetWindowMinimized] = callbacks[:get_window_minimized]
1109
+ platform_io[:Platform_SetWindowTitle] = callbacks[:set_window_title]
1110
+ platform_io[:Platform_RenderWindow] = callbacks[:render_window]
1111
+ platform_io[:Platform_SwapBuffers] = callbacks[:swap_buffers]
1112
+ platform_io[:Platform_SetWindowAlpha] = callbacks[:set_window_alpha]
1113
+ platform_io[:Platform_CreateVkSurface] = callbacks[:create_vk_surface]
1114
+
1115
+ main_viewport = ImGuiViewport.new(ImGui::GetMainViewport())
1116
+ vd = ImGui_ImplDockingSDL3_ViewportData.new
1117
+ vd.window = window
1118
+ vd.window_id = SDL.GetWindowID(window)
1119
+ vd.window_owned = false
1120
+ vd.gl_context = sdl_gl_context
1121
+ ImGui_ImplDockingSDL3_SetViewportData(main_viewport, vd)
1122
+ main_viewport[:PlatformHandle] = FFI::Pointer.new(vd.window_id)
1123
+ end
1124
+
1125
+ def self.ImGui_ImplDockingSDL3_ShutdownMultiViewportSupport
1126
+ ImGui::DestroyPlatformWindows()
1127
+ end
1128
+
1129
+ end