meltygui-imgui 2.0.0.post3__cp313-cp313-win_amd64.whl

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.
Files changed (38) hide show
  1. meltygui_imgui/__init__.py +879 -0
  2. meltygui_imgui/_compat.py +16 -0
  3. meltygui_imgui/ansifeed.pxd +20 -0
  4. meltygui_imgui/cimgui.pxd +2242 -0
  5. meltygui_imgui/common.pyx +75 -0
  6. meltygui_imgui/core.cp313-win_amd64.pyd +0 -0
  7. meltygui_imgui/core.cpp +189914 -0
  8. meltygui_imgui/core.h +51 -0
  9. meltygui_imgui/core.pxd +12 -0
  10. meltygui_imgui/core.pyx +12812 -0
  11. meltygui_imgui/enums.pxd +561 -0
  12. meltygui_imgui/enums_internal.pxd +200 -0
  13. meltygui_imgui/extra.py +36 -0
  14. meltygui_imgui/integrations/__init__.py +13 -0
  15. meltygui_imgui/integrations/base.py +33 -0
  16. meltygui_imgui/integrations/cocos2d.py +27 -0
  17. meltygui_imgui/integrations/glfw.py +133 -0
  18. meltygui_imgui/integrations/glumpy.py +369 -0
  19. meltygui_imgui/integrations/opengl.py +422 -0
  20. meltygui_imgui/integrations/pygame.py +152 -0
  21. meltygui_imgui/integrations/pyglet.py +245 -0
  22. meltygui_imgui/integrations/sdl2.py +136 -0
  23. meltygui_imgui/internal.cp313-win_amd64.pyd +0 -0
  24. meltygui_imgui/internal.cpp +13336 -0
  25. meltygui_imgui/internal.h +51 -0
  26. meltygui_imgui/internal.pxd +686 -0
  27. meltygui_imgui/internal.pyx +207 -0
  28. meltygui_imgui-2.0.0.post3.dist-info/DELVEWHEEL +2 -0
  29. meltygui_imgui-2.0.0.post3.dist-info/METADATA +146 -0
  30. meltygui_imgui-2.0.0.post3.dist-info/RECORD +38 -0
  31. meltygui_imgui-2.0.0.post3.dist-info/WHEEL +5 -0
  32. meltygui_imgui-2.0.0.post3.dist-info/licenses/LICENSE +28 -0
  33. meltygui_imgui-2.0.0.post3.dist-info/licenses/LICENSES/imgui-MIT.txt +21 -0
  34. meltygui_imgui-2.0.0.post3.dist-info/licenses/LICENSES/imstb_rectpack.h.license.txt +37 -0
  35. meltygui_imgui-2.0.0.post3.dist-info/licenses/LICENSES/imstb_textedit.h.license.txt +37 -0
  36. meltygui_imgui-2.0.0.post3.dist-info/licenses/LICENSES/imstb_truetype.h.license.txt +37 -0
  37. meltygui_imgui-2.0.0.post3.dist-info/top_level.txt +1 -0
  38. meltygui_imgui.libs/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
@@ -0,0 +1,200 @@
1
+ cdef extern from "imgui_internal.h":
2
+
3
+ ctypedef enum ImGuiItemFlags_:
4
+ ImGuiItemFlags_None #
5
+ ImGuiItemFlags_NoTabStop # false
6
+ ImGuiItemFlags_ButtonRepeat # false # Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
7
+ ImGuiItemFlags_Disabled # false # [BETA] Disable interactions but doesn't affect visuals yet. See github.com/ocornut/meltygui_imgui/issues/211
8
+ ImGuiItemFlags_NoNav # false
9
+ ImGuiItemFlags_NoNavDefaultFocus # false
10
+ ImGuiItemFlags_SelectableDontClosePopup # false # MenuItem/Selectable() automatically closes current Popup window
11
+ ImGuiItemFlags_MixedValue # false # [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets)
12
+ ImGuiItemFlags_ReadOnly # false # [ALPHA] Allow hovering interactions but underlying value is not changed.
13
+ ImGuiItemFlags_Default_ #
14
+
15
+
16
+ ctypedef enum ImGuiItemStatusFlags_:
17
+ ImGuiItemStatusFlags_None #
18
+ ImGuiItemStatusFlags_HoveredRect #
19
+ ImGuiItemStatusFlags_HasDisplayRect #
20
+ ImGuiItemStatusFlags_Edited # Value exposed by item was edited in the current frame (should match the bool return value of most widgets)
21
+ ImGuiItemStatusFlags_ToggledSelection # Set when Selectable(), TreeNode() reports toggling a selection. We can't report "Selected" because reporting the change allows us to handle clipping with less issues.
22
+ ImGuiItemStatusFlags_ToggledOpen # Set when TreeNode() reports toggling their open state.
23
+ ImGuiItemStatusFlags_HasDeactivated # Set if the widget/group is able to provide data for the ImGuiItemStatusFlags_Deactivated flag.
24
+ ImGuiItemStatusFlags_Deactivated # Only valid if ImGuiItemStatusFlags_HasDeactivated is set.
25
+
26
+ ctypedef enum ImGuiButtonFlagsPrivate_:
27
+ ImGuiButtonFlags_PressedOnClick # return true on click (mouse down event)
28
+ ImGuiButtonFlags_PressedOnClickRelease # [Default] return true on click + release on same item <-- this is what the majority of Button are using
29
+ ImGuiButtonFlags_PressedOnClickReleaseAnywhere # return true on click + release even if the release event is not done while hovering the item
30
+ ImGuiButtonFlags_PressedOnRelease # return true on release (default requires click+release)
31
+ ImGuiButtonFlags_PressedOnDoubleClick # return true on double-click (default requires click+release)
32
+ ImGuiButtonFlags_PressedOnDragDropHold # return true when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
33
+ ImGuiButtonFlags_Repeat # hold to repeat
34
+ ImGuiButtonFlags_FlattenChildren # allow interactions even if a child window is overlapping
35
+ ImGuiButtonFlags_AllowItemOverlap # require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap()
36
+ ImGuiButtonFlags_DontClosePopups # disable automatically closing parent popup on press // [UNUSED]
37
+ ImGuiButtonFlags_Disabled # disable interactions
38
+ ImGuiButtonFlags_AlignTextBaseLine # vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
39
+ ImGuiButtonFlags_NoKeyModifiers # disable mouse interaction if a key modifier is held
40
+ ImGuiButtonFlags_NoHoldingActiveId # don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
41
+ ImGuiButtonFlags_NoNavFocus # don't override navigation focus when activated
42
+ ImGuiButtonFlags_NoHoveredOnFocus # don't report as hovered when nav focus is on this item
43
+ ImGuiButtonFlags_PressedOnMask_ = ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_PressedOnDragDropHold
44
+ ImGuiButtonFlags_PressedOnDefault_ = ImGuiButtonFlags_PressedOnClickRelease
45
+
46
+ ctypedef enum ImGuiSliderFlagsPrivate_:
47
+ ImGuiSliderFlags_Vertical # Should this slider be orientated vertically?
48
+ ImGuiSliderFlags_ReadOnly #
49
+
50
+ ctypedef enum ImGuiSelectableFlagsPrivate_:
51
+ # NB: need to be in sync with last value of ImGuiSelectableFlags_
52
+ ImGuiSelectableFlags_NoHoldingActiveID #
53
+ ImGuiSelectableFlags_SelectOnClick # Override button behavior to react on Click (default is Click+Release)
54
+ ImGuiSelectableFlags_SelectOnRelease # Override button behavior to react on Release (default is Click+Release)
55
+ ImGuiSelectableFlags_SpanAvailWidth # Span all avail width even if we declared less for layout purpose. FIXME: We may be able to remove this (added in 6251d379, 2bcafc86 for menus)
56
+ ImGuiSelectableFlags_DrawHoveredWhenHeld # Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow.
57
+ ImGuiSelectableFlags_SetNavIdOnHover # Set Nav/Focus ID on mouse hover (used by MenuItem)
58
+ ImGuiSelectableFlags_NoPadWithHalfSpacing # Disable padding each side with ItemSpacing * 0.5f
59
+
60
+ ctypedef enum ImGuiTreeNodeFlagsPrivate_:
61
+ ImGuiTreeNodeFlags_ClipLabelForTrailingButton
62
+
63
+ ctypedef enum ImGuiSeparatorFlags_:
64
+ ImGuiSeparatorFlags_None #
65
+ ImGuiSeparatorFlags_Horizontal # Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
66
+ ImGuiSeparatorFlags_Vertical #
67
+ ImGuiSeparatorFlags_SpanAllColumns #
68
+
69
+ ctypedef enum ImGuiTextFlags_:
70
+ ImGuiTextFlags_None
71
+ ImGuiTextFlags_NoWidthForLargeClippedText
72
+
73
+ ctypedef enum ImGuiTooltipFlags_:
74
+ ImGuiTooltipFlags_None
75
+ ImGuiTooltipFlags_OverridePreviousTooltip # Override will clear/ignore previously submitted tooltip (defaults to append)
76
+
77
+ # FIXME: this is in development, not exposed/functional as a generic feature yet.
78
+ # Horizontal/Vertical enums are fixed to 0/1 so they may be used to index ImVec2
79
+ ctypedef enum ImGuiLayoutType_:
80
+ ImGuiLayoutType_Horizontal
81
+ ImGuiLayoutType_Vertical
82
+
83
+ ctypedef enum ImGuiLogType:
84
+ ImGuiLogType_None
85
+ ImGuiLogType_TTY
86
+ ImGuiLogType_File
87
+ ImGuiLogType_Buffer
88
+ ImGuiLogType_Clipboard
89
+
90
+ # X/Y enums are fixed to 0/1 so they may be used to index ImVec2
91
+ ctypedef enum ImGuiAxis:
92
+ ImGuiAxis_None
93
+ ImGuiAxis_X
94
+ ImGuiAxis_Y
95
+
96
+ ctypedef enum ImGuiPlotType:
97
+ ImGuiPlotType_Lines
98
+ ImGuiPlotType_Histogram
99
+
100
+ ctypedef enum ImGuiInputSource:
101
+ ImGuiInputSource_None
102
+ ImGuiInputSource_Mouse
103
+ ImGuiInputSource_Keyboard
104
+ ImGuiInputSource_Gamepad
105
+ ImGuiInputSource_Nav # Stored in g.ActiveIdSource only
106
+ ImGuiInputSource_COUNT
107
+
108
+ # FIXME-NAV: Clarify/expose various repeat delay/rate
109
+ ctypedef enum ImGuiInputReadMode:
110
+ ImGuiInputReadMode_Down
111
+ ImGuiInputReadMode_Pressed
112
+ ImGuiInputReadMode_Released
113
+ ImGuiInputReadMode_Repeat
114
+ ImGuiInputReadMode_RepeatSlow
115
+ ImGuiInputReadMode_RepeatFast
116
+
117
+ ctypedef enum ImGuiNavHighlightFlags_:
118
+ ImGuiNavHighlightFlags_None
119
+ ImGuiNavHighlightFlags_TypeDefault
120
+ ImGuiNavHighlightFlags_TypeThin
121
+ ImGuiNavHighlightFlags_AlwaysDraw # Draw rectangular highlight if (g.NavId == id) _even_ when using the mouse.
122
+ ImGuiNavHighlightFlags_NoRounding
123
+
124
+ ctypedef enum ImGuiNavDirSourceFlags_:
125
+ ImGuiNavDirSourceFlags_None
126
+ ImGuiNavDirSourceFlags_Keyboard
127
+ ImGuiNavDirSourceFlags_PadDPad
128
+ ImGuiNavDirSourceFlags_PadLStick
129
+
130
+ ctypedef enum ImGuiNavMoveFlags_:
131
+ ImGuiNavMoveFlags_None #
132
+ ImGuiNavMoveFlags_LoopX # On failed request, restart from opposite side
133
+ ImGuiNavMoveFlags_LoopY #
134
+ ImGuiNavMoveFlags_WrapX # On failed request, request from opposite side one line down (when NavDir==right) or one line up (when NavDir==left)
135
+ ImGuiNavMoveFlags_WrapY # This is not super useful for provided for completeness
136
+ ImGuiNavMoveFlags_AllowCurrentNavId # Allow scoring and considering the current NavId as a move target candidate. This is used when the move source is offset (e.g. pressing PageDown actually needs to send a Up move request, if we are pressing PageDown from the bottom-most item we need to stay in place)
137
+ ImGuiNavMoveFlags_AlsoScoreVisibleSet # Store alternate result in NavMoveResultLocalVisibleSet that only comprise elements that are already fully visible.
138
+ ImGuiNavMoveFlags_ScrollToEdge #
139
+
140
+ ctypedef enum ImGuiNavForward:
141
+ ImGuiNavForward_None
142
+ ImGuiNavForward_ForwardQueued
143
+ ImGuiNavForward_ForwardActive
144
+
145
+ ctypedef enum ImGuiNavLayer:
146
+ ImGuiNavLayer_Main # Main scrolling layer
147
+ ImGuiNavLayer_Menu # Menu layer (access with Alt/ImGuiNavInput_Menu)
148
+ ImGuiNavLayer_COUNT
149
+
150
+ ctypedef enum ImGuiPopupPositionPolicy:
151
+ ImGuiPopupPositionPolicy_Default
152
+ ImGuiPopupPositionPolicy_ComboBox
153
+ ImGuiPopupPositionPolicy_Tooltip
154
+
155
+ ctypedef enum ImGuiNextWindowDataFlags_:
156
+ ImGuiNextWindowDataFlags_None
157
+ ImGuiNextWindowDataFlags_HasPos
158
+ ImGuiNextWindowDataFlags_HasSize
159
+ ImGuiNextWindowDataFlags_HasContentSize
160
+ ImGuiNextWindowDataFlags_HasCollapsed
161
+ ImGuiNextWindowDataFlags_HasSizeConstraint
162
+ ImGuiNextWindowDataFlags_HasFocus
163
+ ImGuiNextWindowDataFlags_HasBgAlpha
164
+ ImGuiNextWindowDataFlags_HasScroll
165
+
166
+ ctypedef enum ImGuiNextItemDataFlags_:
167
+ ImGuiNextItemDataFlags_None
168
+ ImGuiNextItemDataFlags_HasWidth
169
+ ImGuiNextItemDataFlags_HasOpen
170
+
171
+ ctypedef enum ImGuiOldColumnFlags_:
172
+ # Default: 0
173
+ ImGuiOldColumnFlags_None #
174
+ ImGuiOldColumnFlags_NoBorder # Disable column dividers
175
+ ImGuiOldColumnFlags_NoResize # Disable resizing columns when clicking on the dividers
176
+ ImGuiOldColumnFlags_NoPreserveWidths # Disable column width preservation when adjusting columns
177
+ ImGuiOldColumnFlags_NoForceWithinWindow # Disable forcing columns to fit within window
178
+ ImGuiOldColumnFlags_GrowParentContentsSize # (WIP) Restore pre-1.51 behavior of extending the parent window contents size but _without affecting the columns width at all_. Will eventually remove.
179
+
180
+ ctypedef enum ImGuiContextHookType:
181
+ ImGuiContextHookType_NewFramePre
182
+ ImGuiContextHookType_NewFramePost
183
+ ImGuiContextHookType_EndFramePre
184
+ ImGuiContextHookType_EndFramePost
185
+ ImGuiContextHookType_RenderPre
186
+ ImGuiContextHookType_RenderPost
187
+ ImGuiContextHookType_Shutdown
188
+
189
+
190
+ ctypedef enum ImGuiTabBarFlagsPrivate_:
191
+ ImGuiTabBarFlags_DockNode # Part of a dock node [we don't use this in the master branch but it facilitate branch syncing to keep this around]
192
+ ImGuiTabBarFlags_IsFocused #
193
+ ImGuiTabBarFlags_SaveSettings # FIXME: Settings are handled by the docking system, this only request the tab bar to mark settings dirty when reordering tabs
194
+
195
+ ctypedef enum ImGuiTabItemFlagsPrivate_:
196
+ ImGuiTabItemFlags_NoCloseButton # Track whether p_open was set or not (we'll need this info on the next frame to recompute ContentWidth during layout)
197
+ ImGuiTabItemFlags_Button # Used by TabItemButton, change the tab item behavior to mimic a button
198
+
199
+
200
+
@@ -0,0 +1,36 @@
1
+ """
2
+ This module provides extra utilities that are not part of core ImGui C++ API
3
+ but are useful in Python application.
4
+
5
+ """
6
+ from . import core
7
+
8
+ __all__ = (
9
+ "text_ansi",
10
+ "text_ansi_colored",
11
+ "font",
12
+ "styled",
13
+ "istyled",
14
+ "colored",
15
+ "vertex_buffer_vertex_pos_offset",
16
+ "vertex_buffer_vertex_uv_offset",
17
+ "vertex_buffer_vertex_col_offset",
18
+ "vertex_buffer_vertex_size",
19
+ "index_buffer_index_size",
20
+ )
21
+
22
+ text_ansi = core._ansifeed_text_ansi
23
+ text_ansi_colored = core._ansifeed_text_ansi_colored
24
+
25
+ font = core._py_font
26
+ styled = core._py_styled
27
+ #: istyled
28
+ istyled = core._py_istyled
29
+ colored = core._py_colored
30
+ scoped = core._py_scoped
31
+
32
+ vertex_buffer_vertex_pos_offset = core._py_vertex_buffer_vertex_pos_offset
33
+ vertex_buffer_vertex_uv_offset = core._py_vertex_buffer_vertex_uv_offset
34
+ vertex_buffer_vertex_col_offset = core._py_vertex_buffer_vertex_col_offset
35
+ vertex_buffer_vertex_size = core._py_vertex_buffer_vertex_size
36
+ index_buffer_index_size = core._py_index_buffer_index_size
@@ -0,0 +1,13 @@
1
+ # -*- coding: utf-8 -*-
2
+ from __future__ import absolute_import
3
+
4
+
5
+ def compute_fb_scale(window_size, frame_buffer_size):
6
+ win_width, win_height = window_size
7
+ fb_width, fb_height = frame_buffer_size
8
+
9
+ # future: remove floats after dropping py27 support
10
+ if win_width != 0 and win_height != 0:
11
+ return float(fb_width) / win_width, float(fb_height) / win_height
12
+
13
+ return 1., 1.
@@ -0,0 +1,33 @@
1
+ import meltygui_imgui
2
+
3
+
4
+ class BaseOpenGLRenderer(object):
5
+ def __init__(self):
6
+ if not meltygui_imgui.get_current_context():
7
+ raise RuntimeError(
8
+ "No valid ImGui context. Use meltygui_imgui.create_context() first and/or "
9
+ "meltygui_imgui.set_current_context()."
10
+ )
11
+ self.io = meltygui_imgui.get_io()
12
+
13
+ self._font_texture = None
14
+
15
+ self.io.delta_time = 1.0 / 60.0
16
+
17
+ self._create_device_objects()
18
+ self.refresh_font_texture()
19
+
20
+ def render(self, draw_data):
21
+ raise NotImplementedError
22
+
23
+ def refresh_font_texture(self):
24
+ raise NotImplementedError
25
+
26
+ def _create_device_objects(self):
27
+ raise NotImplementedError
28
+
29
+ def _invalidate_device_objects(self):
30
+ raise NotImplementedError
31
+
32
+ def shutdown(self):
33
+ self._invalidate_device_objects()
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+ from __future__ import absolute_import
3
+
4
+ import cocos
5
+
6
+ import meltygui_imgui
7
+
8
+ from .import compute_fb_scale
9
+ from .pyglet import PygletMixin
10
+ from .opengl import FixedPipelineRenderer
11
+
12
+
13
+ class ImguiLayer(PygletMixin, cocos.layer.Layer):
14
+ is_event_handler = True
15
+
16
+ def __init__(self):
17
+ super(ImguiLayer, self).__init__()
18
+
19
+ window_size = cocos.director.director.window.get_size()
20
+ viewport_size = cocos.director.director.window.get_viewport_size()
21
+
22
+ self.io = meltygui_imgui.get_io()
23
+ self.io.display_size = window_size
24
+ self.io.display_fb_scale = compute_fb_scale(window_size, viewport_size)
25
+
26
+ self.renderer = FixedPipelineRenderer()
27
+ self._map_keys()
@@ -0,0 +1,133 @@
1
+ # -*- coding: utf-8 -*-
2
+ from __future__ import absolute_import
3
+
4
+ import glfw
5
+ import meltygui_imgui
6
+
7
+ from . import compute_fb_scale
8
+ from .opengl import ProgrammablePipelineRenderer
9
+
10
+ class GlfwRenderer(ProgrammablePipelineRenderer):
11
+ def __init__(self, window, attach_callbacks:bool=True):
12
+ super(GlfwRenderer, self).__init__()
13
+ self.window = window
14
+
15
+ if attach_callbacks:
16
+ glfw.set_key_callback(self.window, self.keyboard_callback)
17
+ glfw.set_cursor_pos_callback(self.window, self.mouse_callback)
18
+ glfw.set_window_size_callback(self.window, self.resize_callback)
19
+ glfw.set_char_callback(self.window, self.char_callback)
20
+ glfw.set_scroll_callback(self.window, self.scroll_callback)
21
+
22
+ self.io.display_size = glfw.get_framebuffer_size(self.window)
23
+ self.io.get_clipboard_text_fn = self._get_clipboard_text
24
+ self.io.set_clipboard_text_fn = self._set_clipboard_text
25
+
26
+ self._map_keys()
27
+ self._gui_time = None
28
+
29
+ def _get_clipboard_text(self):
30
+ return glfw.get_clipboard_string(self.window)
31
+
32
+ def _set_clipboard_text(self, text):
33
+ glfw.set_clipboard_string(self.window, text)
34
+
35
+ def _map_keys(self):
36
+ key_map = self.io.key_map
37
+
38
+ key_map[meltygui_imgui.KEY_TAB] = glfw.KEY_TAB
39
+ key_map[meltygui_imgui.KEY_LEFT_ARROW] = glfw.KEY_LEFT
40
+ key_map[meltygui_imgui.KEY_RIGHT_ARROW] = glfw.KEY_RIGHT
41
+ key_map[meltygui_imgui.KEY_UP_ARROW] = glfw.KEY_UP
42
+ key_map[meltygui_imgui.KEY_DOWN_ARROW] = glfw.KEY_DOWN
43
+ key_map[meltygui_imgui.KEY_PAGE_UP] = glfw.KEY_PAGE_UP
44
+ key_map[meltygui_imgui.KEY_PAGE_DOWN] = glfw.KEY_PAGE_DOWN
45
+ key_map[meltygui_imgui.KEY_HOME] = glfw.KEY_HOME
46
+ key_map[meltygui_imgui.KEY_END] = glfw.KEY_END
47
+ key_map[meltygui_imgui.KEY_INSERT] = glfw.KEY_INSERT
48
+ key_map[meltygui_imgui.KEY_DELETE] = glfw.KEY_DELETE
49
+ key_map[meltygui_imgui.KEY_BACKSPACE] = glfw.KEY_BACKSPACE
50
+ key_map[meltygui_imgui.KEY_SPACE] = glfw.KEY_SPACE
51
+ key_map[meltygui_imgui.KEY_ENTER] = glfw.KEY_ENTER
52
+ key_map[meltygui_imgui.KEY_ESCAPE] = glfw.KEY_ESCAPE
53
+ key_map[meltygui_imgui.KEY_PAD_ENTER] = glfw.KEY_KP_ENTER
54
+ key_map[meltygui_imgui.KEY_A] = glfw.KEY_A
55
+ key_map[meltygui_imgui.KEY_C] = glfw.KEY_C
56
+ key_map[meltygui_imgui.KEY_V] = glfw.KEY_V
57
+ key_map[meltygui_imgui.KEY_X] = glfw.KEY_X
58
+ key_map[meltygui_imgui.KEY_Y] = glfw.KEY_Y
59
+ key_map[meltygui_imgui.KEY_Z] = glfw.KEY_Z
60
+
61
+ def keyboard_callback(self, window, key, scancode, action, mods):
62
+ # perf: local for faster access
63
+ io = self.io
64
+
65
+ if action == glfw.PRESS:
66
+ io.keys_down[key] = True
67
+ elif action == glfw.RELEASE:
68
+ io.keys_down[key] = False
69
+
70
+ io.key_ctrl = (
71
+ io.keys_down[glfw.KEY_LEFT_CONTROL] or
72
+ io.keys_down[glfw.KEY_RIGHT_CONTROL]
73
+ )
74
+
75
+ io.key_alt = (
76
+ io.keys_down[glfw.KEY_LEFT_ALT] or
77
+ io.keys_down[glfw.KEY_RIGHT_ALT]
78
+ )
79
+
80
+ io.key_shift = (
81
+ io.keys_down[glfw.KEY_LEFT_SHIFT] or
82
+ io.keys_down[glfw.KEY_RIGHT_SHIFT]
83
+ )
84
+
85
+ io.key_super = (
86
+ io.keys_down[glfw.KEY_LEFT_SUPER] or
87
+ io.keys_down[glfw.KEY_RIGHT_SUPER]
88
+ )
89
+
90
+ def char_callback(self, window, char):
91
+ io = meltygui_imgui.get_io()
92
+
93
+ if 0 < char < 0x10000:
94
+ io.add_input_character(char)
95
+
96
+ def resize_callback(self, window, width, height):
97
+ self.io.display_size = width, height
98
+
99
+ def mouse_callback(self, *args, **kwargs):
100
+ pass
101
+
102
+ def scroll_callback(self, window, x_offset, y_offset):
103
+ self.io.mouse_wheel_horizontal = x_offset
104
+ self.io.mouse_wheel = y_offset
105
+
106
+ def process_inputs(self):
107
+ io = meltygui_imgui.get_io()
108
+
109
+ window_size = glfw.get_window_size(self.window)
110
+ fb_size = glfw.get_framebuffer_size(self.window)
111
+
112
+ io.display_size = window_size
113
+ io.display_fb_scale = compute_fb_scale(window_size, fb_size)
114
+ io.delta_time = 1.0/60
115
+
116
+ if glfw.get_window_attrib(self.window, glfw.FOCUSED):
117
+ io.mouse_pos = glfw.get_cursor_pos(self.window)
118
+ else:
119
+ io.mouse_pos = -1, -1
120
+
121
+ io.mouse_down[0] = glfw.get_mouse_button(self.window, 0)
122
+ io.mouse_down[1] = glfw.get_mouse_button(self.window, 1)
123
+ io.mouse_down[2] = glfw.get_mouse_button(self.window, 2)
124
+
125
+ current_time = glfw.get_time()
126
+
127
+ if self._gui_time:
128
+ self.io.delta_time = current_time - self._gui_time
129
+ else:
130
+ self.io.delta_time = 1. / 60.
131
+ if(io.delta_time <= 0.0): io.delta_time = 1./ 1000.
132
+
133
+ self._gui_time = current_time