goome 0.4.0__py3-none-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.
goome/__init__.py ADDED
@@ -0,0 +1,38 @@
1
+ from .core import (
2
+ ALT, AUTO, BACKENDS, CAP_CAPTURE, CAP_CLIPBOARD, CAP_CURSOR, CAP_GLOBAL_POINTER, CAP_GRAB, CAP_HIDE_SELF, CAP_HOTKEYS,
3
+ CAP_KEYBOARD, CAP_WINDOW, CLOSE, CONTROL, CTRL, CURSOR_ARROW, CURSOR_HAND, CURSOR_HIDDEN, CURSOR_IBEAM, CURSOR_MOVE,
4
+ CURSOR_NAMES, CURSOR_NO, CURSOR_RESIZE_EW, CURSOR_RESIZE_NESW, CURSOR_RESIZE_NS, CURSOR_RESIZE_NWSE, CURSOR_WAIT, DOWN,
5
+ DROP, EAGAIN, FMT_BGRA, FMT_BGRA_PREMUL, FMT_RGBA, FMT_RGBA_PREMUL, EARG, EDENIED, EDGE_BOTTOM, EDGE_LEFT, EDGE_RIGHT, EDGE_TOP, EGONE, ENODISPLAY, ENOMEM, ENOTSUP, FOCUS,
6
+ GNOME, HOTKEY, K_BACKSPACE, K_DELETE, K_DOWN, K_END, K_ENTER, K_ESC, K_F1, K_F12, K_HOME, K_INSERT, K_LEFT, K_PGDN,
7
+ K_PGUP, K_RIGHT, K_SPACE, K_TAB, K_UP, KEY, MACOS, MODE_OFFSCREEN, MODE_OVERLAY, MODE_WINDOW, MODES, MONITORS, MOTION,
8
+ NONE, OFFSCREEN, OK, PORTAL, QUIT, SCROLL, SHIFT, STATE_FULLSCREEN, STATE_MAXIMIZED, STATE_MINIMIZED, STATE_NORMAL,
9
+ SUPER, TEST, UP, VERSION, WANT_KEYBOARD, WANT_MOUSE, WAYLAND, WIN32, WINDOW_BORDERLESS, WINDOW_CENTER, WINDOW_HIDDEN,
10
+ WINDOW_ON_TOP, WINDOW_RESIZABLE, WINDOW_TRANSPARENT, X11, Again, BadArg, Denied, Event, Frame, Goome, GoomeError, Gone, Image, Monitor,
11
+ NoDisplay, NoMemory, NotSupported, Pacer, Pointer, Rect, now_ms, open, open_app, open_offscreen, parse_combo, save_ppm,
12
+ send, strerror,
13
+ )
14
+ from .draw import Bitmap, Canvas, Font, Radii, font_count, line_height, measure, radius, set_font
15
+ from .ui import (
16
+ APP_MENUBAR, APP_NO_PAD, APP_STATUSBAR, APP_TITLEBAR, EDIT_LINE_NUMBERS, EDIT_MONO, EDIT_READONLY, EDIT_WRAP,
17
+ ITEM_DRAG_X, ITEM_DRAG_Y, ITEM_FOCUSABLE, ITEM_NO_HIT, ITEM_REPEAT, S_ACCENT, S_ACCENT_TEXT, S_ACTIVE, S_ANIM_MS, S_BG,
18
+ S_BORDER, S_BORDER_WIDTH, S_COUNT, S_FONT_SIZE, S_GAP, S_HOVER, S_INPUT_BG, S_PAD, S_PANEL, S_RADIUS, S_SHADOW,
19
+ S_SHADOW_BLUR, S_TEXT, S_TEXT_DIM, SKIN_BUTTON, SKIN_CHECKBOX, SKIN_COUNT, SKIN_INPUT, SKIN_MENU, SKIN_PANEL, SKIN_POPUP,
20
+ SKIN_RADIO, SKIN_SCROLLBAR, SKIN_SLIDER_FILL, SKIN_SLIDER_TRACK, SKIN_TAB, SKIN_TITLEBAR, SKIN_TOGGLE, SKIN_TOOLTIP,
21
+ ICON_ARROW_DOWN, ICON_ARROW_LEFT, ICON_ARROW_RIGHT, ICON_ARROW_UP, ICON_CHECK, ICON_CLOSE, ICON_COLLAPSE, ICON_COUNT,
22
+ ICON_DRAG_HANDLE, ICON_EXPAND, ICON_MAXIMIZE, ICON_MINIMIZE, ICON_MINUS, ICON_NAMES, ICON_PICKER, ICON_PLUS, ICON_RADIO_DOT,
23
+ ICON_RESIZE, ICON_RESTORE, ICON_SLIDER_KNOB, ICON_SORT_DOWN, ICON_SORT_UP, ICON_TOAST, ICON_TOGGLE_KNOB, Icons, Item,
24
+ TABLE_BORDERS, TABLE_RESIZABLE, TABLE_SORTABLE, TABLE_STRIPES, WIN_CLOSE, WIN_COLLAPSE, WIN_MOVE, WIN_NO_TITLE,
25
+ WIN_RESIZE, ACT_NAMES, ALIGN_NAMES, CUR_NAMES, EASE_NAMES, PRESET_NAMES, STYLE_NAMES, Config, Cursors, Flag, Skin, Sort,
26
+ Split, Theme, Ui, Window,
27
+ )
28
+ from . import ui as _ui
29
+
30
+ for _n in dir(_ui):
31
+ if _n.split("_")[0] in ("S", "INPUT", "ALIGN", "EASE", "PRESET", "ACT", "CUR") and _n.isupper():
32
+ globals()[_n] = getattr(_ui, _n)
33
+ from .app import App
34
+ from ._lib import path as lib_path
35
+
36
+ __version__ = VERSION
37
+
38
+ __all__ = [n for n in dir() if not n.startswith("_") and n not in ("open", "core", "draw", "ui", "app")]
goome/_lib.py ADDED
@@ -0,0 +1,453 @@
1
+ import ctypes
2
+ import os
3
+ import sys
4
+ from ctypes import (
5
+ CFUNCTYPE,
6
+ POINTER,
7
+ Structure,
8
+ c_char,
9
+ c_char_p,
10
+ c_double,
11
+ c_float,
12
+ c_int,
13
+ c_long,
14
+ c_size_t,
15
+ c_uint32,
16
+ c_void_p,
17
+ )
18
+
19
+ HERE = os.path.dirname(os.path.abspath(__file__))
20
+
21
+
22
+ def lib_name():
23
+ if sys.platform == "win32":
24
+ return "goome.dll"
25
+ if sys.platform == "darwin":
26
+ return "libgoome.dylib"
27
+ return "libgoome.so"
28
+
29
+
30
+ class Opts(Structure):
31
+ _fields_ = [
32
+ ("title", c_char_p),
33
+ ("backend", c_int),
34
+ ("state_dir", c_char_p),
35
+ ("no_capture", c_int),
36
+ ("capture_fps", c_int),
37
+ ("hide_self", c_int),
38
+ ("test_frames", c_char_p),
39
+ ("test_script", c_char_p),
40
+ ("test_shots", c_char_p),
41
+ ("mode", c_int),
42
+ ("width", c_int),
43
+ ("height", c_int),
44
+ ("min_width", c_int),
45
+ ("min_height", c_int),
46
+ ("window_flags", c_int),
47
+ ("scale", c_double),
48
+ ]
49
+
50
+
51
+ class RectS(Structure):
52
+ _fields_ = [("x", c_int), ("y", c_int), ("w", c_int), ("h", c_int)]
53
+
54
+
55
+ class MonitorS(Structure):
56
+ _fields_ = [
57
+ ("id", c_int),
58
+ ("name", c_char * 64),
59
+ ("area", RectS),
60
+ ("scale", c_double),
61
+ ("pw", c_int),
62
+ ("ph", c_int),
63
+ ("rotation", c_int),
64
+ ]
65
+
66
+
67
+ class ImageS(Structure):
68
+ _fields_ = [
69
+ ("px", POINTER(c_uint32)),
70
+ ("w", c_int),
71
+ ("h", c_int),
72
+ ("stride", c_int),
73
+ ("area", RectS),
74
+ ("mon", c_int),
75
+ ("has_self", c_int),
76
+ ("has_cursor", c_int),
77
+ ("cursor", RectS),
78
+ ]
79
+
80
+
81
+ class CanvasS(Structure):
82
+ _fields_ = [
83
+ ("px", POINTER(c_uint32)),
84
+ ("w", c_int),
85
+ ("h", c_int),
86
+ ("stride", c_int),
87
+ ("ox", c_double),
88
+ ("oy", c_double),
89
+ ("scale", c_double),
90
+ ("mon", c_int),
91
+ ("dx0", c_int),
92
+ ("dy0", c_int),
93
+ ("dx1", c_int),
94
+ ("dy1", c_int),
95
+ ("cx0", c_int),
96
+ ("cy0", c_int),
97
+ ("cx1", c_int),
98
+ ("cy1", c_int),
99
+ ("kx0", c_int),
100
+ ("ky0", c_int),
101
+ ("kx1", c_int),
102
+ ("ky1", c_int),
103
+ ("nclip", c_int),
104
+ ("clips", (c_int * 4) * 16),
105
+ ]
106
+
107
+
108
+ class EventS(Structure):
109
+ _fields_ = [
110
+ ("type", c_int),
111
+ ("x", c_double),
112
+ ("y", c_double),
113
+ ("mon", c_int),
114
+ ("button", c_int),
115
+ ("dy", c_int),
116
+ ("key", c_int),
117
+ ("mods", c_int),
118
+ ("text", c_char * 8),
119
+ ("id", c_int),
120
+ ("msg", c_char * 64),
121
+ ]
122
+
123
+
124
+ class PacerS(Structure):
125
+ _fields_ = [("next", c_long), ("fps", c_int)]
126
+
127
+
128
+ class RadiiS(Structure):
129
+ _fields_ = [("tl", c_double), ("tr", c_double), ("br", c_double), ("bl", c_double)]
130
+
131
+
132
+ class BitmapS(Structure):
133
+ _fields_ = [
134
+ ("px", POINTER(c_uint32)),
135
+ ("w", c_int),
136
+ ("h", c_int),
137
+ ("stride", c_int),
138
+ ("owned", c_int),
139
+ ]
140
+
141
+
142
+ class SkinS(Structure):
143
+ _fields_ = [("bm", POINTER(BitmapS)), ("l", c_double), ("t", c_double), ("r", c_double), ("b", c_double)]
144
+
145
+
146
+ THEME_SKINS = ("skin_button", "skin_panel", "skin_input", "skin_checkbox", "skin_radio", "skin_toggle", "skin_slider", "skin_slider_fill",
147
+ "skin_scrollbar", "skin_tab", "skin_titlebar", "skin_tooltip", "skin_menu", "skin_popup")
148
+ ICON_COUNT = 22
149
+ BASE_COLORS = ("bg", "panel", "border", "text", "text_dim", "accent", "accent_text", "hover", "active", "input_bg", "shadow")
150
+ BASE_SIZES = ("radius", "pad", "gap", "border_width", "font_size", "shadow_blur", "anim_ms")
151
+ MORE_COLORS = ("focus", "select", "caret", "link", "badge", "toast", "tooltip", "danger", "knob", "dim")
152
+ MORE_SIZES = ("check_size", "check_radius", "toggle_w", "toggle_h", "slider_h", "slider_track", "knob_size",
153
+ "scroll_w", "scroll_min", "item_h", "menu_item_h", "tab_h", "win_title_h", "app_title_h", "menubar_h", "statusbar_h",
154
+ "focus_w", "focus_gap", "sep_w", "grip", "indent", "plot_w", "spinner", "caret_w",
155
+ "win_min_w", "win_min_h", "pop_gap", "menu_gap", "tip_pad_x", "tip_pad_y", "tip_x", "tip_y", "tip_radius",
156
+ "shadow_x", "shadow_y", "align", "heading_size", "small_size", "ease",
157
+ "hover_ms", "press_ms", "popup_ms", "collapse_ms", "toast_fade_ms")
158
+ THEME_COLORS = BASE_COLORS + MORE_COLORS
159
+ THEME_SIZES = BASE_SIZES + MORE_SIZES
160
+ STYLE_NAMES = BASE_COLORS + BASE_SIZES + MORE_COLORS + MORE_SIZES
161
+ THEME_FONTS = ("font", "font_heading", "font_mono", "font_small")
162
+
163
+
164
+ class ThemeS(Structure):
165
+ _fields_ = [(n, c_uint32) for n in BASE_COLORS] + [(n, c_double) for n in BASE_SIZES] + [("font", c_void_p)] + [(n, SkinS) for n in THEME_SKINS[:3]] + [
166
+ ("icon", POINTER(BitmapS) * ICON_COUNT), ("icon_tint", c_uint32)] + [(n, SkinS) for n in THEME_SKINS[3:]] + [
167
+ (n, c_uint32) for n in MORE_COLORS] + [(n, c_double) for n in MORE_SIZES] + [(n, c_void_p) for n in THEME_FONTS[1:]]
168
+
169
+
170
+ ACT_COUNT = 12
171
+ CUR_COUNT = 12
172
+ EASE_FN = CFUNCTYPE(c_double, c_double, c_void_p)
173
+ CONFIG_INTS = ("tip_delay_ms", "dbl_click_ms", "dbl_click_px", "drag_px", "repeat_delay_ms", "repeat_ms", "blink_ms", "menu_delay_ms", "toast_ms")
174
+ CONFIG_TOGGLES = ("raise_on_click", "esc_closes", "tab_nav", "focus_on_mouse")
175
+
176
+
177
+ class ComboS(Structure):
178
+ _fields_ = [("key", c_int), ("mods", c_int)]
179
+
180
+
181
+ class ConfigS(Structure):
182
+ _fields_ = [(n, c_int) for n in CONFIG_INTS] + [("scroll_lines", c_double)] + [(n, c_int) for n in CONFIG_TOGGLES] + [
183
+ ("cursor", c_int * CUR_COUNT), ("keys", (ComboS * 4) * ACT_COUNT), ("ease", EASE_FN), ("ease_user", c_void_p), ("mask", c_char_p)]
184
+
185
+
186
+ class ItemS(Structure):
187
+ _fields_ = [(n, c_double) for n in ("x", "y", "w", "h")] + [
188
+ (n, c_int) for n in ("hovered", "pressed", "held", "released", "clicked", "double_clicked", "right_clicked", "focused")
189
+ ] + [(n, c_double) for n in ("mx", "my", "dx", "dy", "drag_x", "drag_y")] + [("key", c_int)]
190
+
191
+
192
+ STRUCTS = {
193
+ "goome_opts": Opts,
194
+ "goome_rect": RectS,
195
+ "goome_monitor": MonitorS,
196
+ "goome_image": ImageS,
197
+ "goome_canvas": CanvasS,
198
+ "goome_event": EventS,
199
+ "goome_pacer": PacerS,
200
+ "goome_radii": RadiiS,
201
+ "goome_bitmap": BitmapS,
202
+ "goome_skin": SkinS,
203
+ "goome_theme": ThemeS,
204
+ "goome_ui_item": ItemS,
205
+ "goome_combo": ComboS,
206
+ "goome_ui_config": ConfigS,
207
+ }
208
+
209
+ P = c_void_p
210
+ CP = POINTER(CanvasS)
211
+ D = c_double
212
+ I = c_int
213
+ S = c_char_p
214
+ U = c_uint32
215
+ PD = POINTER(c_double)
216
+ PI = POINTER(c_int)
217
+ PU = POINTER(c_uint32)
218
+ PF = POINTER(c_float)
219
+
220
+ PROTOS = {
221
+ "goome_open": (P, [POINTER(Opts), PI]),
222
+ "goome_open_app": (P, [S, I, I, PI]),
223
+ "goome_close": (None, [P]),
224
+ "goome_error": (S, [P]),
225
+ "goome_strerror": (S, [I]),
226
+ "goome_backend_name": (S, [P]),
227
+ "goome_caps": (I, [P]),
228
+ "goome_monitors": (I, [P, POINTER(MonitorS), I]),
229
+ "goome_capture": (I, [P, I, POINTER(RectS), POINTER(ImageS)]),
230
+ "goome_alpha_at": (I, [P, D, D]),
231
+ "goome_begin": (CP, [P, I]),
232
+ "goome_end": (I, [P, CP, POINTER(RectS), I]),
233
+ "goome_damage": (None, [CP, POINTER(RectS)]),
234
+ "goome_poll": (I, [P, POINTER(EventS), I]),
235
+ "goome_pointer": (I, [P, PD, PD, PI]),
236
+ "goome_keyboard": (I, [P, I]),
237
+ "goome_grab": (I, [P, I]),
238
+ "goome_grabbed": (I, [P]),
239
+ "goome_hotkey": (I, [P, S, I]),
240
+ "goome_parse_combo": (I, [S, PI, PI]),
241
+ "goome_control_path": (S, [P]),
242
+ "goome_send": (I, [S, S]),
243
+ "goome_pace": (I, [POINTER(PacerS), I]),
244
+ "goome_now_ms": (c_long, []),
245
+ "goome_mode": (I, [P]),
246
+ "goome_window_title": (I, [P, S]),
247
+ "goome_window_size": (I, [P, I, I]),
248
+ "goome_window_pos": (I, [P, PI, PI, I]),
249
+ "goome_window_state": (I, [P, I]),
250
+ "goome_window_get_state": (I, [P]),
251
+ "goome_window_drag": (I, [P, I]),
252
+ "goome_window_show": (I, [P, I]),
253
+ "goome_cursor": (I, [P, I]),
254
+ "goome_cursor_shape": (I, [P]),
255
+ "goome_clipboard_set": (I, [P, S]),
256
+ "goome_clipboard_get": (I, [P, c_void_p, I]),
257
+ "goome_drop_path": (S, [P]),
258
+ "goome_push": (I, [P, POINTER(EventS)]),
259
+ "goome_resize": (I, [P, I, I, D]),
260
+ "goome_frame": (I, [P, POINTER(ImageS)]),
261
+ "goome_hit": (I, [P, D, D]),
262
+ "goome_frame_dirty": (I, [P, POINTER(RectS)]),
263
+ "goome_frame_copy": (I, [P, c_void_p, I, I, POINTER(RectS)]),
264
+ "goome_save_ppm": (I, [S, PU, I, I, I]),
265
+ "goome_clear": (None, [CP]),
266
+ "goome_draw_rect": (None, [CP, D, D, D, D, U]),
267
+ "goome_draw_round_rect": (None, [CP, D, D, D, D, D, U]),
268
+ "goome_draw_frame": (None, [CP, D, D, D, D, D, U]),
269
+ "goome_draw_line": (None, [CP, D, D, D, D, D, U]),
270
+ "goome_draw_triangle": (None, [CP, D, D, D, D, D, D, U]),
271
+ "goome_draw_image": (None, [CP, D, D, D, D, PU, I, I]),
272
+ "goome_erase": (None, [CP, D, D, D, D]),
273
+ "goome_draw_text": (D, [CP, D, D, S, I, U]),
274
+ "goome_text_width": (D, [CP, S, I]),
275
+ "goome_set_font": (None, [I]),
276
+ "goome_font_count": (I, []),
277
+ "goome_canvas_blit": (None, [CP, CP, D, D, D]),
278
+ "goome_radius": (RadiiS, [D]),
279
+ "goome_clip_push": (None, [CP, D, D, D, D]),
280
+ "goome_clip_pop": (None, [CP]),
281
+ "goome_draw_rrect": (None, [CP, D, D, D, D, RadiiS, U]),
282
+ "goome_draw_rrect_line": (None, [CP, D, D, D, D, RadiiS, D, U]),
283
+ "goome_draw_rrect_grad": (None, [CP, D, D, D, D, RadiiS, U, U, I]),
284
+ "goome_draw_shadow": (None, [CP, D, D, D, D, D, D, U]),
285
+ "goome_draw_circle": (None, [CP, D, D, D, U]),
286
+ "goome_draw_ring": (None, [CP, D, D, D, D, U]),
287
+ "goome_draw_arc": (None, [CP, D, D, D, D, D, D, U]),
288
+ "goome_draw_poly": (None, [CP, PD, I, U]),
289
+ "goome_bitmap_load": (I, [S, POINTER(BitmapS)]),
290
+ "goome_bitmap_load_mem": (I, [c_void_p, c_size_t, POINTER(BitmapS)]),
291
+ "goome_bitmap_error": (S, []),
292
+ "goome_bitmap_from_argb": (I, [PU, I, I, POINTER(BitmapS)]),
293
+ "goome_bitmap_free": (None, [POINTER(BitmapS)]),
294
+ "goome_draw_bitmap": (None, [CP, POINTER(BitmapS), D, D, D, D, RadiiS, U]),
295
+ "goome_draw_bitmap_part": (None, [CP, POINTER(BitmapS), I, I, I, I, D, D, D, D, U]),
296
+ "goome_draw_bitmap_nine": (None, [CP, POINTER(BitmapS), D, D, D, D, D, D, D, D]),
297
+ "goome_font_load": (P, [S]),
298
+ "goome_font_load_index": (P, [S, I]),
299
+ "goome_font_load_mem": (P, [c_void_p, c_size_t, I]),
300
+ "goome_font_system": (P, [S]),
301
+ "goome_font_free": (None, [P]),
302
+ "goome_text": (D, [CP, P, D, D, D, S, U]),
303
+ "goome_text_measure": (D, [P, D, S, PD]),
304
+ "goome_text_line_height": (D, [P, D]),
305
+ "goome_ui_new": (P, [P]),
306
+ "goome_ui_free": (None, [P]),
307
+ "goome_ui_theme": (POINTER(ThemeS), [P]),
308
+ "goome_ui_theme_dark": (None, [POINTER(ThemeS)]),
309
+ "goome_ui_theme_light": (None, [POINTER(ThemeS)]),
310
+ "goome_ui_feed": (I, [P, POINTER(EventS)]),
311
+ "goome_ui_begin": (CP, [P, I]),
312
+ "goome_ui_end": (None, [P]),
313
+ "goome_ui_hit": (None, [P, D, D, D, D]),
314
+ "goome_ui_animating": (I, [P]),
315
+ "goome_ui_window": (I, [P, S, PD, PD, PD, PD, I, PI]),
316
+ "goome_ui_window_end": (None, [P]),
317
+ "goome_ui_row": (None, [P, I]),
318
+ "goome_ui_same_line": (None, [P]),
319
+ "goome_ui_space": (None, [P, D]),
320
+ "goome_ui_separator": (None, [P]),
321
+ "goome_ui_width": (None, [P, D]),
322
+ "goome_ui_label": (None, [P, S]),
323
+ "goome_ui_heading": (None, [P, S]),
324
+ "goome_ui_wrapped": (None, [P, S]),
325
+ "goome_ui_button": (I, [P, S]),
326
+ "goome_ui_image_button": (I, [P, S, POINTER(BitmapS), D, D]),
327
+ "goome_ui_image": (None, [P, POINTER(BitmapS), D, D, D]),
328
+ "goome_ui_checkbox": (I, [P, S, PI]),
329
+ "goome_ui_toggle": (I, [P, S, PI]),
330
+ "goome_ui_radio": (I, [P, S, PI, I]),
331
+ "goome_ui_slider": (I, [P, S, PD, D, D, S]),
332
+ "goome_ui_slider_int": (I, [P, S, PI, I, I]),
333
+ "goome_ui_input": (I, [P, S, c_char_p, I]),
334
+ "goome_ui_combo": (I, [P, S, PI, POINTER(c_char_p), I]),
335
+ "goome_ui_selectable": (I, [P, S, I]),
336
+ "goome_ui_tabs": (I, [P, S, POINTER(c_char_p), I, PI]),
337
+ "goome_ui_collapsing": (I, [P, S, PI]),
338
+ "goome_ui_progress": (None, [P, D, S]),
339
+ "goome_ui_color": (I, [P, S, PU]),
340
+ "goome_ui_tooltip": (None, [P, S]),
341
+ "goome_ui_hovered": (I, [P]),
342
+ "goome_ui_scroll_begin": (I, [P, S, D]),
343
+ "goome_ui_scroll_end": (None, [P]),
344
+ "goome_ui_push_id": (None, [P, S]),
345
+ "goome_ui_pop_id": (None, [P]),
346
+ "goome_ui_app": (I, [P, S, I]),
347
+ "goome_ui_app_end": (None, [P]),
348
+ "goome_ui_menubar_begin": (I, [P]),
349
+ "goome_ui_menubar_end": (None, [P]),
350
+ "goome_ui_menu_begin": (I, [P, S]),
351
+ "goome_ui_menu_end": (None, [P]),
352
+ "goome_ui_menu_item": (I, [P, S, S, PI]),
353
+ "goome_ui_menu_separator": (None, [P]),
354
+ "goome_ui_context_begin": (I, [P, S]),
355
+ "goome_ui_context_end": (None, [P]),
356
+ "goome_ui_popup_open": (None, [P, S]),
357
+ "goome_ui_popup_begin": (I, [P, S]),
358
+ "goome_ui_popup_end": (None, [P]),
359
+ "goome_ui_popup_close": (None, [P]),
360
+ "goome_ui_modal_begin": (I, [P, S, PI]),
361
+ "goome_ui_modal_end": (None, [P]),
362
+ "goome_ui_toast": (None, [P, S, I]),
363
+ "goome_ui_statusbar": (None, [P, S]),
364
+ "goome_ui_focused": (I, [P]),
365
+ "goome_ui_set_focus": (None, [P]),
366
+ "goome_ui_wants": (I, [P]),
367
+ "goome_ui_auto_grab": (None, [P, I]),
368
+ "goome_ui_text_edit": (I, [P, S, c_char_p, I, D, I]),
369
+ "goome_ui_table_begin": (I, [P, S, I, D, I]),
370
+ "goome_ui_table_column": (None, [P, S, D]),
371
+ "goome_ui_table_sort": (I, [P, PI, PI]),
372
+ "goome_ui_table_row": (None, [P]),
373
+ "goome_ui_table_next": (None, [P]),
374
+ "goome_ui_table_end": (None, [P]),
375
+ "goome_ui_tree": (I, [P, S, PI]),
376
+ "goome_ui_tree_end": (None, [P]),
377
+ "goome_ui_list_clip": (I, [P, I, D, PI, PI]),
378
+ "goome_ui_drag_float": (I, [P, S, PD, D, D, D, S]),
379
+ "goome_ui_drag_int": (I, [P, S, PI, D, I, I]),
380
+ "goome_ui_number": (I, [P, S, PD, D, S]),
381
+ "goome_ui_plot_lines": (None, [P, S, PF, I, D, D, D]),
382
+ "goome_ui_plot_bars": (None, [P, S, PF, I, D, D, D]),
383
+ "goome_ui_split_begin": (I, [P, S, I, PD]),
384
+ "goome_ui_split_next": (None, [P]),
385
+ "goome_ui_split_end": (None, [P]),
386
+ "goome_ui_drag_source": (I, [P, S, c_void_p, I]),
387
+ "goome_ui_drop_target": (I, [P, S, c_void_p, I]),
388
+ "goome_ui_spinner": (None, [P, D]),
389
+ "goome_ui_link": (I, [P, S]),
390
+ "goome_ui_badge": (None, [P, S, U]),
391
+ "goome_ui_pos": (None, [P, D, D]),
392
+ "goome_ui_size": (None, [P, D, D]),
393
+ "goome_ui_push_color": (None, [P, I, U]),
394
+ "goome_ui_push_num": (None, [P, I, D]),
395
+ "goome_ui_push_radii": (None, [P, RadiiS]),
396
+ "goome_ui_push_font": (None, [P, P]),
397
+ "goome_ui_push_skin": (None, [P, I, POINTER(SkinS)]),
398
+ "goome_ui_push_theme": (None, [P, POINTER(ThemeS)]),
399
+ "goome_ui_push_icon": (None, [P, I, POINTER(BitmapS)]),
400
+ "goome_ui_pop": (None, [P, I]),
401
+ "goome_ui_custom": (I, [P, S, D, D, I, POINTER(ItemS)]),
402
+ "goome_ui_canvas": (CP, [P]),
403
+ "goome_ui_store": (PD, [P, S, I]),
404
+ "goome_ui_input_ex": (I, [P, S, c_char_p, I, I, S]),
405
+ "goome_ui_theme_make": (None, [POINTER(ThemeS), U, I, D]),
406
+ "goome_ui_theme_preset": (I, [POINTER(ThemeS), I]),
407
+ "goome_ui_scale": (None, [P, D]),
408
+ "goome_ui_cfg": (POINTER(ConfigS), [P]),
409
+ "goome_ui_config_default": (None, [POINTER(ConfigS)]),
410
+ "goome_ui_bind": (I, [P, I, S]),
411
+ }
412
+
413
+
414
+ def candidates():
415
+ env = os.environ.get("GOOME_LIB")
416
+ if env:
417
+ return [env]
418
+ return [os.path.join(HERE, "_native", lib_name())]
419
+
420
+
421
+ def load():
422
+ tried = []
423
+ for path in candidates():
424
+ if not os.path.isfile(path):
425
+ tried.append(path + " (not there)")
426
+ continue
427
+ try:
428
+ return ctypes.CDLL(path), path
429
+ except OSError as e:
430
+ tried.append("%s (%s)" % (path, e))
431
+ raise OSError(
432
+ "cant find the goome native library, tried: %s. reinstall the package so it builds one, "
433
+ "run ./build.sh in the repo, or point GOOME_LIB at a libgoome you built" % "; ".join(tried)
434
+ )
435
+
436
+
437
+ def bind(lib):
438
+ missing = []
439
+ for name, (res, args) in PROTOS.items():
440
+ try:
441
+ f = getattr(lib, name)
442
+ except AttributeError:
443
+ missing.append(name)
444
+ continue
445
+ f.restype = res
446
+ f.argtypes = args
447
+ if missing:
448
+ raise OSError("this goome library is missing %s, its probably too old" % ", ".join(missing))
449
+ return lib
450
+
451
+
452
+ lib, path = load()
453
+ bind(lib)
Binary file
goome/app.py ADDED
@@ -0,0 +1,116 @@
1
+ from .core import CLOSE, QUIT, Pacer, open_app
2
+
3
+
4
+ class App(object):
5
+ _dirty = 0
6
+
7
+ def __init__(self, title="goome", width=960, height=640, flags=0, fps=60, idle_ms=500, light=False, **opts):
8
+ self.title = title
9
+ self.width = width
10
+ self.height = height
11
+ self.flags = flags
12
+ self.fps = fps
13
+ self.idle_ms = idle_ms
14
+ self.light = light
15
+ self.opts = opts
16
+ self.animate = False
17
+ self.running = False
18
+ self.frames = 0
19
+ self.g = None
20
+ self.ui = None
21
+ self._draw = None
22
+ self._handlers = []
23
+ self._close = None
24
+ self._start = None
25
+
26
+ def frame(self, fn):
27
+ self._draw = fn
28
+ return fn
29
+
30
+ def event(self, fn):
31
+ self._handlers.append(fn)
32
+ return fn
33
+
34
+ def on_close(self, fn):
35
+ self._close = fn
36
+ return fn
37
+
38
+ def on_start(self, fn):
39
+ self._start = fn
40
+ return fn
41
+
42
+ def redraw(self):
43
+ self._dirty = max(self._dirty, 1)
44
+
45
+ def quit(self):
46
+ self.running = False
47
+
48
+ def _handle(self, ev):
49
+ for h in self._handlers:
50
+ if h(ev):
51
+ return
52
+ self.ui.feed(ev)
53
+ if ev.type == QUIT:
54
+ self.running = False
55
+ elif ev.type == CLOSE and (self._close is None or self._close() is not False):
56
+ self.running = False
57
+
58
+ def _paint(self):
59
+ ui = self.ui
60
+ if ui.begin(0) is None:
61
+ return
62
+ try:
63
+ with ui.app(self.title, self.flags):
64
+ if self._draw is not None:
65
+ self._draw(ui)
66
+ finally:
67
+ ui.end()
68
+ self.frames += 1
69
+
70
+ def start(self):
71
+ g = open_app(self.title, self.width, self.height, **self.opts)
72
+ ui = g.ui()
73
+ self.g, self.ui = g, ui
74
+ if self.light:
75
+ ui.theme.light()
76
+ self._every = g.backend_name.split()[0] == "test"
77
+ self._pace = Pacer(self.fps)
78
+ self._dirty = 2
79
+ self.running = True
80
+ if self._start is not None:
81
+ self._start()
82
+ return self
83
+
84
+ def step(self, wait=True):
85
+ ui = self.ui
86
+ busy = self._every or self.animate or self._dirty > 0 or ui.animating
87
+ if self._dirty > 0:
88
+ self._dirty -= 1
89
+ timeout = (self._pace.wait() if busy else self.idle_ms) if wait else 0
90
+ for ev in self.g.events(timeout):
91
+ self._handle(ev)
92
+ self._dirty = max(self._dirty, 1)
93
+ if not self.running:
94
+ return False
95
+ if self.running and (busy or self._dirty > 0):
96
+ self._paint()
97
+ return self.running
98
+
99
+ def stop(self):
100
+ self.running = False
101
+ g, ui = self.g, self.ui
102
+ self.g, self.ui = None, None
103
+ if ui is not None:
104
+ ui.close()
105
+ if g is not None:
106
+ g.close()
107
+
108
+ def run(self, draw=None):
109
+ if draw is not None:
110
+ self._draw = draw
111
+ self.start()
112
+ try:
113
+ while self.step():
114
+ pass
115
+ finally:
116
+ self.stop()