CMake: add WITH_LINKER_LLD option for unix platforms
[blender-staging.git] / source / blender / windowmanager / WM_api.h
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2007 Blender Foundation.
17  * All rights reserved.
18  */
19 #ifndef __WM_API_H__
20 #define __WM_API_H__
21
22 /** \file
23  * \ingroup wm
24  *
25  * \page wmpage windowmanager
26  * \section wmabout About windowmanager
27  * \ref wm handles events received from \ref GHOST and manages
28  * the screens, areas and input for Blender
29  * \section wmnote NOTE
30  * \todo document
31  */
32
33 /* dna-savable wmStructs here */
34 #include "BLI_compiler_attrs.h"
35 #include "DNA_windowmanager_types.h"
36 #include "WM_keymap.h"
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 struct ARegion;
43 struct GHashIterator;
44 struct GPUViewport;
45 struct ID;
46 struct IDProperty;
47 struct ImBuf;
48 struct ImageFormatData;
49 struct Main;
50 struct MenuType;
51 struct PointerRNA;
52 struct PropertyRNA;
53 struct ScrArea;
54 struct View3D;
55 struct ViewLayer;
56 struct bContext;
57 struct rcti;
58 struct wmDrag;
59 struct wmDropBox;
60 struct wmEvent;
61 struct wmEventHandler_Keymap;
62 struct wmEventHandler_UI;
63 struct wmGenericUserData;
64 struct wmGesture;
65 struct wmJob;
66 struct wmOperator;
67 struct wmOperatorType;
68 struct wmPaintCursor;
69
70 #ifdef WITH_INPUT_NDOF
71 struct wmNDOFMotionData;
72 #endif
73
74 typedef struct wmGizmo wmGizmo;
75 typedef struct wmGizmoMap wmGizmoMap;
76 typedef struct wmGizmoMapType wmGizmoMapType;
77 typedef struct wmJob wmJob;
78
79 /* general API */
80 void WM_init_state_app_template_set(const char *app_template);
81 const char *WM_init_state_app_template_get(void);
82
83 void WM_init_state_size_set(int stax, int stay, int sizx, int sizy);
84 void WM_init_state_fullscreen_set(void);
85 void WM_init_state_normal_set(void);
86 void WM_init_state_maximized_set(void);
87 void WM_init_state_start_with_console_set(bool value);
88 void WM_init_window_focus_set(bool do_it);
89 void WM_init_native_pixels(bool do_it);
90 void WM_init_tablet_api(void);
91
92 void WM_init(struct bContext *C, int argc, const char **argv);
93 void WM_exit_ex(struct bContext *C, const bool do_python);
94
95 void WM_exit(struct bContext *C) ATTR_NORETURN;
96
97 void WM_main(struct bContext *C) ATTR_NORETURN;
98
99 void WM_init_splash(struct bContext *C);
100
101 void WM_init_opengl(struct Main *bmain);
102
103 void WM_check(struct bContext *C);
104 void WM_reinit_gizmomap_all(struct Main *bmain);
105
106 void WM_script_tag_reload(void);
107
108 uint *WM_window_pixels_read(struct wmWindowManager *wm, struct wmWindow *win, int r_size[2]);
109
110 int WM_window_pixels_x(const struct wmWindow *win);
111 int WM_window_pixels_y(const struct wmWindow *win);
112 void WM_window_rect_calc(const struct wmWindow *win, struct rcti *r_rect);
113 void WM_window_screen_rect_calc(const struct wmWindow *win, struct rcti *r_rect);
114 bool WM_window_is_fullscreen(const struct wmWindow *win);
115 bool WM_window_is_maximized(const struct wmWindow *win);
116
117 void WM_windows_scene_data_sync(const ListBase *win_lb, struct Scene *scene) ATTR_NONNULL();
118 struct Scene *WM_windows_scene_get_from_screen(const struct wmWindowManager *wm,
119                                                const struct bScreen *screen)
120     ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
121 struct WorkSpace *WM_windows_workspace_get_from_screen(const wmWindowManager *wm,
122                                                        const struct bScreen *screen)
123     ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
124
125 struct Scene *WM_window_get_active_scene(const struct wmWindow *win)
126     ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
127 void WM_window_set_active_scene(struct Main *bmain,
128                                 struct bContext *C,
129                                 struct wmWindow *win,
130                                 struct Scene *scene_new) ATTR_NONNULL();
131 struct WorkSpace *WM_window_get_active_workspace(const struct wmWindow *win)
132     ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
133 void WM_window_set_active_workspace(struct bContext *C,
134                                     struct wmWindow *win,
135                                     struct WorkSpace *workspace) ATTR_NONNULL(1);
136 struct WorkSpaceLayout *WM_window_get_active_layout(const struct wmWindow *win)
137     ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
138 void WM_window_set_active_layout(struct wmWindow *win,
139                                  struct WorkSpace *workspace,
140                                  struct WorkSpaceLayout *layout) ATTR_NONNULL(1);
141 struct bScreen *WM_window_get_active_screen(const struct wmWindow *win)
142     ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
143 void WM_window_set_active_screen(struct wmWindow *win,
144                                  struct WorkSpace *workspace,
145                                  struct bScreen *screen) ATTR_NONNULL(1);
146
147 struct ViewLayer *WM_window_get_active_view_layer(const struct wmWindow *win)
148     ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT;
149 void WM_window_set_active_view_layer(struct wmWindow *win, struct ViewLayer *view_layer)
150     ATTR_NONNULL(1);
151 void WM_window_ensure_active_view_layer(struct wmWindow *win) ATTR_NONNULL(1);
152
153 bool WM_window_is_temp_screen(const struct wmWindow *win) ATTR_WARN_UNUSED_RESULT;
154
155 void *WM_opengl_context_create(void);
156 void WM_opengl_context_dispose(void *context);
157 void WM_opengl_context_activate(void *context);
158 void WM_opengl_context_release(void *context);
159
160 struct wmWindow *WM_window_open(struct bContext *C, const struct rcti *rect);
161 struct wmWindow *WM_window_open_temp(struct bContext *C,
162                                      const char *title,
163                                      int x,
164                                      int y,
165                                      int sizex,
166                                      int sizey,
167                                      int space_type,
168                                      bool dialog);
169 void WM_window_set_dpi(const wmWindow *win);
170
171 bool WM_stereo3d_enabled(struct wmWindow *win, bool only_fullscreen_test);
172
173 /* files */
174 void WM_file_autoexec_init(const char *filepath);
175 bool WM_file_read(struct bContext *C, const char *filepath, struct ReportList *reports);
176 void WM_autosave_init(struct wmWindowManager *wm);
177 void WM_recover_last_session(struct bContext *C, struct ReportList *reports);
178 void WM_file_tag_modified(void);
179
180 struct ID *WM_file_append_datablock(struct Main *bmain,
181                                     struct Scene *scene,
182                                     struct ViewLayer *view_layer,
183                                     struct View3D *v3d,
184                                     const char *filepath,
185                                     const short id_code,
186                                     const char *id_name);
187 void WM_lib_reload(struct Library *lib, struct bContext *C, struct ReportList *reports);
188
189 /* mouse cursors */
190 void WM_cursor_set(struct wmWindow *win, int curs);
191 bool WM_cursor_set_from_tool(struct wmWindow *win, const ScrArea *area, const ARegion *region);
192 void WM_cursor_modal_set(struct wmWindow *win, int curs);
193 void WM_cursor_modal_restore(struct wmWindow *win);
194 void WM_cursor_wait(bool val);
195 void WM_cursor_grab_enable(struct wmWindow *win, int wrap, bool hide, int bounds[4]);
196 void WM_cursor_grab_disable(struct wmWindow *win, const int mouse_ungrab_xy[2]);
197 void WM_cursor_time(struct wmWindow *win, int nr);
198
199 struct wmPaintCursor *WM_paint_cursor_activate(
200     struct wmWindowManager *wm,
201     short space_type,
202     short region_type,
203     bool (*poll)(struct bContext *C),
204     void (*draw)(struct bContext *C, int, int, void *customdata),
205     void *customdata);
206
207 bool WM_paint_cursor_end(struct wmWindowManager *wm, struct wmPaintCursor *handle);
208 void WM_paint_cursor_tag_redraw(struct wmWindow *win, struct ARegion *region);
209
210 void WM_cursor_warp(struct wmWindow *win, int x, int y);
211 void WM_cursor_compatible_xy(wmWindow *win, int *x, int *y);
212
213 /* handlers */
214
215 typedef bool (*EventHandlerPoll)(const ARegion *region, const struct wmEvent *event);
216 struct wmEventHandler_Keymap *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap);
217 struct wmEventHandler_Keymap *WM_event_add_keymap_handler_poll(ListBase *handlers,
218                                                                wmKeyMap *keymap,
219                                                                EventHandlerPoll poll);
220 struct wmEventHandler_Keymap *WM_event_add_keymap_handler_v2d_mask(ListBase *handlers,
221                                                                    wmKeyMap *keymap);
222 /* priority not implemented, it adds in begin */
223 struct wmEventHandler_Keymap *WM_event_add_keymap_handler_priority(ListBase *handlers,
224                                                                    wmKeyMap *keymap,
225                                                                    int priority);
226
227 typedef struct wmKeyMap *(wmEventHandler_KeymapDynamicFn)(
228     wmWindowManager *wm, struct wmEventHandler_Keymap *handler)ATTR_WARN_UNUSED_RESULT;
229
230 struct wmKeyMap *WM_event_get_keymap_from_toolsystem_fallback(
231     struct wmWindowManager *wm, struct wmEventHandler_Keymap *handler);
232 struct wmKeyMap *WM_event_get_keymap_from_toolsystem(struct wmWindowManager *wm,
233                                                      struct wmEventHandler_Keymap *handler);
234
235 struct wmEventHandler_Keymap *WM_event_add_keymap_handler_dynamic(
236     ListBase *handlers, wmEventHandler_KeymapDynamicFn *keymap_fn, void *user_data);
237
238 void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap);
239
240 void WM_event_set_keymap_handler_post_callback(struct wmEventHandler_Keymap *handler,
241                                                void(keymap_tag)(wmKeyMap *keymap,
242                                                                 wmKeyMapItem *kmi,
243                                                                 void *user_data),
244                                                void *user_data);
245 wmKeyMap *WM_event_get_keymap_from_handler(wmWindowManager *wm,
246                                            struct wmEventHandler_Keymap *handler);
247
248 wmKeyMapItem *WM_event_match_keymap_item(struct bContext *C,
249                                          wmKeyMap *keymap,
250                                          const struct wmEvent *event);
251
252 wmKeyMapItem *WM_event_match_keymap_item_from_handlers(struct bContext *C,
253                                                        struct wmWindowManager *wm,
254                                                        struct ListBase *handlers,
255                                                        const struct wmEvent *event);
256
257 typedef int (*wmUIHandlerFunc)(struct bContext *C, const struct wmEvent *event, void *userdata);
258 typedef void (*wmUIHandlerRemoveFunc)(struct bContext *C, void *userdata);
259
260 struct wmEventHandler_UI *WM_event_add_ui_handler(const struct bContext *C,
261                                                   ListBase *handlers,
262                                                   wmUIHandlerFunc ui_handle,
263                                                   wmUIHandlerRemoveFunc ui_remove,
264                                                   void *userdata,
265                                                   const char flag);
266 void WM_event_remove_ui_handler(ListBase *handlers,
267                                 wmUIHandlerFunc ui_handle,
268                                 wmUIHandlerRemoveFunc ui_remove,
269                                 void *userdata,
270                                 const bool postpone);
271 void WM_event_remove_area_handler(struct ListBase *handlers, void *area);
272 void WM_event_free_ui_handler_all(struct bContext *C,
273                                   ListBase *handlers,
274                                   wmUIHandlerFunc ui_handle,
275                                   wmUIHandlerRemoveFunc ui_remove);
276
277 struct wmEventHandler_Op *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op);
278 void WM_event_modal_handler_area_replace(wmWindow *win,
279                                          const struct ScrArea *old_area,
280                                          struct ScrArea *new_area);
281 void WM_event_modal_handler_region_replace(wmWindow *win,
282                                            const struct ARegion *old_region,
283                                            struct ARegion *new_region);
284
285 void WM_event_remove_handlers(struct bContext *C, ListBase *handlers);
286
287 /* handler flag */
288 enum {
289   WM_HANDLER_BLOCKING = (1 << 0),         /* after this handler all others are ignored */
290   WM_HANDLER_ACCEPT_DBL_CLICK = (1 << 1), /* handler accepts double key press events */
291
292   /* internal */
293   WM_HANDLER_DO_FREE = (1 << 7), /* handler tagged to be freed in wm_handlers_do() */
294 };
295
296 struct wmEventHandler_Dropbox *WM_event_add_dropbox_handler(ListBase *handlers,
297                                                             ListBase *dropboxes);
298
299 /* mouse */
300 void WM_event_add_mousemove(wmWindow *win);
301
302 #ifdef WITH_INPUT_NDOF
303 /* 3D mouse */
304 void WM_ndof_deadzone_set(float deadzone);
305 #endif
306 /* notifiers */
307 void WM_event_add_notifier_ex(struct wmWindowManager *wm,
308                               const struct wmWindow *win,
309                               unsigned int type,
310                               void *reference);
311 void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference);
312 void WM_main_add_notifier(unsigned int type, void *reference);
313 void WM_main_remove_notifier_reference(const void *reference);
314 void WM_main_remap_editor_id_reference(struct ID *old_id, struct ID *new_id);
315
316 /* reports */
317 void WM_report_banner_show(void);
318 void WM_report_banners_cancel(struct Main *bmain);
319 void WM_report(ReportType type, const char *message);
320 void WM_reportf(ReportType type, const char *format, ...) ATTR_PRINTF_FORMAT(2, 3);
321
322 struct wmEvent *wm_event_add_ex(struct wmWindow *win,
323                                 const struct wmEvent *event_to_add,
324                                 const struct wmEvent *event_to_add_after) ATTR_NONNULL(1, 2);
325 struct wmEvent *wm_event_add(struct wmWindow *win, const struct wmEvent *event_to_add)
326     ATTR_NONNULL(1, 2);
327
328 void wm_event_init_from_window(struct wmWindow *win, struct wmEvent *event);
329
330 /* at maximum, every timestep seconds it triggers event_type events */
331 struct wmTimer *WM_event_add_timer(struct wmWindowManager *wm,
332                                    struct wmWindow *win,
333                                    int event_type,
334                                    double timestep);
335 struct wmTimer *WM_event_add_timer_notifier(struct wmWindowManager *wm,
336                                             struct wmWindow *win,
337                                             unsigned int type,
338                                             double timestep);
339 void WM_event_remove_timer(struct wmWindowManager *wm,
340                            struct wmWindow *win,
341                            struct wmTimer *timer);
342 void WM_event_remove_timer_notifier(struct wmWindowManager *wm,
343                                     struct wmWindow *win,
344                                     struct wmTimer *timer);
345 void WM_event_timer_sleep(struct wmWindowManager *wm,
346                           struct wmWindow *win,
347                           struct wmTimer *timer,
348                           bool do_sleep);
349
350 /* operator api, default callbacks */
351 /* invoke callback, uses enum property named "type" */
352 int WM_generic_select_modal(struct bContext *C,
353                             struct wmOperator *op,
354                             const struct wmEvent *event);
355 int WM_generic_select_invoke(struct bContext *C,
356                              struct wmOperator *op,
357                              const struct wmEvent *event);
358 void WM_operator_view3d_unit_defaults(struct bContext *C, struct wmOperator *op);
359 int WM_operator_smooth_viewtx_get(const struct wmOperator *op);
360 int WM_menu_invoke_ex(struct bContext *C, struct wmOperator *op, int opcontext);
361 int WM_menu_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
362 void WM_menu_name_call(struct bContext *C, const char *menu_name, short context);
363 int WM_enum_search_invoke_previews(struct bContext *C,
364                                    struct wmOperator *op,
365                                    short prv_cols,
366                                    short prv_rows);
367 int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
368 /* invoke callback, confirm menu + exec */
369 int WM_operator_confirm(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
370 int WM_operator_confirm_or_exec(struct bContext *C,
371                                 struct wmOperator *op,
372                                 const struct wmEvent *event);
373 /* invoke callback, file selector "filepath" unset + exec */
374 int WM_operator_filesel(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
375 bool WM_operator_filesel_ensure_ext_imtype(wmOperator *op,
376                                            const struct ImageFormatData *im_format);
377 /* poll callback, context checks */
378 bool WM_operator_winactive(struct bContext *C);
379 /* invoke callback, exec + redo popup */
380 int WM_operator_props_popup_confirm(struct bContext *C,
381                                     struct wmOperator *op,
382                                     const struct wmEvent *event);
383 int WM_operator_props_popup_call(struct bContext *C,
384                                  struct wmOperator *op,
385                                  const struct wmEvent *event);
386 int WM_operator_props_popup(struct bContext *C,
387                             struct wmOperator *op,
388                             const struct wmEvent *event);
389 int WM_operator_props_dialog_popup(struct bContext *C, struct wmOperator *op, int width);
390 int WM_operator_redo_popup(struct bContext *C, struct wmOperator *op);
391 int WM_operator_ui_popup(struct bContext *C, struct wmOperator *op, int width);
392
393 int WM_operator_confirm_message_ex(struct bContext *C,
394                                    struct wmOperator *op,
395                                    const char *title,
396                                    const int icon,
397                                    const char *message,
398                                    const short opcontext);
399 int WM_operator_confirm_message(struct bContext *C, struct wmOperator *op, const char *message);
400
401 /* operator api */
402 void WM_operator_free(struct wmOperator *op);
403 void WM_operator_free_all_after(wmWindowManager *wm, struct wmOperator *op);
404 void WM_operator_type_set(struct wmOperator *op, struct wmOperatorType *ot);
405 void WM_operator_stack_clear(struct wmWindowManager *wm);
406 void WM_operator_handlers_clear(wmWindowManager *wm, struct wmOperatorType *ot);
407
408 bool WM_operator_poll(struct bContext *C, struct wmOperatorType *ot);
409 bool WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, short context);
410 int WM_operator_call_ex(struct bContext *C, struct wmOperator *op, const bool store);
411 int WM_operator_call(struct bContext *C, struct wmOperator *op);
412 int WM_operator_call_notest(struct bContext *C, struct wmOperator *op);
413 int WM_operator_repeat(struct bContext *C, struct wmOperator *op);
414 int WM_operator_repeat_last(struct bContext *C, struct wmOperator *op);
415 bool WM_operator_repeat_check(const struct bContext *C, struct wmOperator *op);
416 bool WM_operator_is_repeat(const struct bContext *C, const struct wmOperator *op);
417 int WM_operator_name_call_ptr(struct bContext *C,
418                               struct wmOperatorType *ot,
419                               short context,
420                               struct PointerRNA *properties);
421 int WM_operator_name_call(struct bContext *C,
422                           const char *opstring,
423                           short context,
424                           struct PointerRNA *properties);
425 int WM_operator_name_call_with_properties(struct bContext *C,
426                                           const char *opstring,
427                                           short context,
428                                           struct IDProperty *properties);
429 int WM_operator_call_py(struct bContext *C,
430                         struct wmOperatorType *ot,
431                         short context,
432                         struct PointerRNA *properties,
433                         struct ReportList *reports,
434                         const bool is_undo);
435
436 /* Used for keymap and macro items. */
437 void WM_operator_properties_alloc(struct PointerRNA **ptr,
438                                   struct IDProperty **properties,
439                                   const char *opstring);
440
441 /* Make props context sensitive or not. */
442 void WM_operator_properties_sanitize(struct PointerRNA *ptr, const bool no_context);
443
444 bool WM_operator_properties_default(struct PointerRNA *ptr, const bool do_update);
445 void WM_operator_properties_reset(struct wmOperator *op);
446 void WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring);
447 void WM_operator_properties_create_ptr(struct PointerRNA *ptr, struct wmOperatorType *ot);
448 void WM_operator_properties_clear(struct PointerRNA *ptr);
449 void WM_operator_properties_free(struct PointerRNA *ptr);
450
451 bool WM_operator_check_ui_empty(struct wmOperatorType *ot);
452 bool WM_operator_check_ui_enabled(const struct bContext *C, const char *idname);
453
454 IDProperty *WM_operator_last_properties_ensure_idprops(struct wmOperatorType *ot);
455 void WM_operator_last_properties_ensure(struct wmOperatorType *ot, struct PointerRNA *ptr);
456 wmOperator *WM_operator_last_redo(const struct bContext *C);
457 ID *WM_operator_drop_load_path(struct bContext *C, struct wmOperator *op, const short idcode);
458
459 bool WM_operator_last_properties_init(struct wmOperator *op);
460 bool WM_operator_last_properties_store(struct wmOperator *op);
461
462 /* wm_operator_props.c */
463 void WM_operator_properties_confirm_or_exec(struct wmOperatorType *ot);
464 void WM_operator_properties_filesel(struct wmOperatorType *ot,
465                                     int filter,
466                                     short type,
467                                     short action,
468                                     short flag,
469                                     short display,
470                                     short sort);
471 void WM_operator_properties_use_cursor_init(struct wmOperatorType *ot);
472 void WM_operator_properties_border(struct wmOperatorType *ot);
473 void WM_operator_properties_border_to_rcti(struct wmOperator *op, struct rcti *rect);
474 void WM_operator_properties_border_to_rctf(struct wmOperator *op, rctf *rect);
475 void WM_operator_properties_gesture_box_ex(struct wmOperatorType *ot, bool deselect, bool extend);
476 void WM_operator_properties_gesture_box(struct wmOperatorType *ot);
477 void WM_operator_properties_gesture_box_select(struct wmOperatorType *ot);
478 void WM_operator_properties_gesture_box_zoom(struct wmOperatorType *ot);
479 void WM_operator_properties_gesture_lasso(struct wmOperatorType *ot);
480 void WM_operator_properties_gesture_straightline(struct wmOperatorType *ot, int cursor);
481 void WM_operator_properties_gesture_circle(struct wmOperatorType *ot);
482 void WM_operator_properties_mouse_select(struct wmOperatorType *ot);
483 void WM_operator_properties_select_all(struct wmOperatorType *ot);
484 void WM_operator_properties_select_action(struct wmOperatorType *ot,
485                                           int default_action,
486                                           bool hide_gui);
487 void WM_operator_properties_select_action_simple(struct wmOperatorType *ot,
488                                                  int default_action,
489                                                  bool hide_gui);
490 void WM_operator_properties_select_random(struct wmOperatorType *ot);
491 int WM_operator_properties_select_random_seed_increment_get(wmOperator *op);
492 void WM_operator_properties_select_operation(struct wmOperatorType *ot);
493 void WM_operator_properties_select_operation_simple(struct wmOperatorType *ot);
494 void WM_operator_properties_select_walk_direction(struct wmOperatorType *ot);
495 void WM_operator_properties_generic_select(struct wmOperatorType *ot);
496 struct CheckerIntervalParams {
497   int nth; /* bypass when set to zero */
498   int skip;
499   int offset;
500 };
501 void WM_operator_properties_checker_interval(struct wmOperatorType *ot, bool nth_can_disable);
502 void WM_operator_properties_checker_interval_from_op(struct wmOperator *op,
503                                                      struct CheckerIntervalParams *op_params);
504 bool WM_operator_properties_checker_interval_test(const struct CheckerIntervalParams *op_params,
505                                                   int depth);
506
507 /* flags for WM_operator_properties_filesel */
508 #define WM_FILESEL_RELPATH (1 << 0)
509
510 #define WM_FILESEL_DIRECTORY (1 << 1)
511 #define WM_FILESEL_FILENAME (1 << 2)
512 #define WM_FILESEL_FILEPATH (1 << 3)
513 #define WM_FILESEL_FILES (1 << 4)
514 /* Show the properties sidebar by default. */
515 #define WM_FILESEL_SHOW_PROPS (1 << 5)
516
517 /* operator as a python command (resultuing string must be freed) */
518 char *WM_operator_pystring_ex(struct bContext *C,
519                               struct wmOperator *op,
520                               const bool all_args,
521                               const bool macro_args,
522                               struct wmOperatorType *ot,
523                               struct PointerRNA *opptr);
524 char *WM_operator_pystring(struct bContext *C,
525                            struct wmOperator *op,
526                            const bool all_args,
527                            const bool macro_args);
528 bool WM_operator_pystring_abbreviate(char *str, int str_len_max);
529 char *WM_prop_pystring_assign(struct bContext *C,
530                               struct PointerRNA *ptr,
531                               struct PropertyRNA *prop,
532                               int index);
533 void WM_operator_bl_idname(char *to, const char *from);
534 void WM_operator_py_idname(char *to, const char *from);
535 bool WM_operator_py_idname_ok_or_report(struct ReportList *reports,
536                                         const char *classname,
537                                         const char *idname);
538 const char *WM_context_member_from_ptr(struct bContext *C, const struct PointerRNA *ptr);
539
540 /* wm_operator_type.c */
541 struct wmOperatorType *WM_operatortype_find(const char *idname, bool quiet);
542 void WM_operatortype_iter(struct GHashIterator *ghi);
543 void WM_operatortype_append(void (*opfunc)(struct wmOperatorType *));
544 void WM_operatortype_append_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata);
545 void WM_operatortype_append_macro_ptr(void (*opfunc)(struct wmOperatorType *, void *),
546                                       void *userdata);
547 void WM_operatortype_remove_ptr(struct wmOperatorType *ot);
548 bool WM_operatortype_remove(const char *idname);
549 void WM_operatortype_last_properties_clear_all(void);
550 void WM_operatortype_props_advanced_begin(struct wmOperatorType *ot);
551 void WM_operatortype_props_advanced_end(struct wmOperatorType *ot);
552
553 #define WM_operatortype_prop_tag(property, tags) \
554   { \
555     CHECK_TYPE(tags, eOperatorPropTags); \
556     RNA_def_property_tags(prop, tags); \
557   } \
558   (void)0
559
560 struct wmOperatorType *WM_operatortype_append_macro(const char *idname,
561                                                     const char *name,
562                                                     const char *description,
563                                                     int flag);
564 struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot,
565                                                          const char *idname);
566
567 const char *WM_operatortype_name(struct wmOperatorType *ot, struct PointerRNA *properties);
568 char *WM_operatortype_description(struct bContext *C,
569                                   struct wmOperatorType *ot,
570                                   struct PointerRNA *properties);
571
572 /* wm_operator_utils.c */
573 void WM_operator_type_modal_from_exec_for_object_edit_coords(struct wmOperatorType *ot);
574
575 /* wm_uilist_type.c */
576 void WM_uilisttype_init(void);
577 struct uiListType *WM_uilisttype_find(const char *idname, bool quiet);
578 bool WM_uilisttype_add(struct uiListType *ult);
579 void WM_uilisttype_freelink(struct uiListType *ult);
580 void WM_uilisttype_free(void);
581
582 /* wm_menu_type.c */
583 void WM_menutype_init(void);
584 struct MenuType *WM_menutype_find(const char *idname, bool quiet);
585 bool WM_menutype_add(struct MenuType *mt);
586 void WM_menutype_freelink(struct MenuType *mt);
587 void WM_menutype_free(void);
588 bool WM_menutype_poll(struct bContext *C, struct MenuType *mt);
589
590 /* wm_panel_type.c */
591 void WM_paneltype_init(void);
592 void WM_paneltype_clear(void);
593 struct PanelType *WM_paneltype_find(const char *idname, bool quiet);
594 bool WM_paneltype_add(struct PanelType *pt);
595 void WM_paneltype_remove(struct PanelType *pt);
596
597 /* wm_gesture_ops.c */
598 int WM_gesture_box_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
599 int WM_gesture_box_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
600 void WM_gesture_box_cancel(struct bContext *C, struct wmOperator *op);
601 int WM_gesture_circle_invoke(struct bContext *C,
602                              struct wmOperator *op,
603                              const struct wmEvent *event);
604 int WM_gesture_circle_modal(struct bContext *C,
605                             struct wmOperator *op,
606                             const struct wmEvent *event);
607 void WM_gesture_circle_cancel(struct bContext *C, struct wmOperator *op);
608 int WM_gesture_lines_invoke(struct bContext *C,
609                             struct wmOperator *op,
610                             const struct wmEvent *event);
611 int WM_gesture_lines_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
612 void WM_gesture_lines_cancel(struct bContext *C, struct wmOperator *op);
613 int WM_gesture_lasso_invoke(struct bContext *C,
614                             struct wmOperator *op,
615                             const struct wmEvent *event);
616 int WM_gesture_lasso_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
617 void WM_gesture_lasso_cancel(struct bContext *C, struct wmOperator *op);
618 const int (*WM_gesture_lasso_path_to_array(struct bContext *C,
619                                            struct wmOperator *op,
620                                            int *mcords_tot))[2];
621 int WM_gesture_straightline_invoke(struct bContext *C,
622                                    struct wmOperator *op,
623                                    const struct wmEvent *event);
624 int WM_gesture_straightline_modal(struct bContext *C,
625                                   struct wmOperator *op,
626                                   const struct wmEvent *event);
627 void WM_gesture_straightline_cancel(struct bContext *C, struct wmOperator *op);
628
629 /* Gesture manager API */
630 struct wmGesture *WM_gesture_new(struct wmWindow *window,
631                                  const struct ARegion *region,
632                                  const struct wmEvent *event,
633                                  int type);
634 void WM_gesture_end(struct wmWindow *win, struct wmGesture *gesture);
635 void WM_gestures_remove(struct wmWindow *win);
636 void WM_gestures_free_all(struct wmWindow *win);
637 bool WM_gesture_is_modal_first(const struct wmGesture *gesture);
638
639 /* fileselecting support */
640 void WM_event_add_fileselect(struct bContext *C, struct wmOperator *op);
641 void WM_event_fileselect_event(struct wmWindowManager *wm, void *ophandle, int eventval);
642
643 void WM_operator_region_active_win_set(struct bContext *C);
644
645 /* drag and drop */
646 struct wmDrag *WM_event_start_drag(
647     struct bContext *C, int icon, int type, void *poin, double value, unsigned int flags);
648 void WM_event_drag_image(struct wmDrag *, struct ImBuf *, float scale, int sx, int sy);
649 void WM_drag_free(struct wmDrag *drag);
650 void WM_drag_free_list(struct ListBase *lb);
651
652 struct wmDropBox *WM_dropbox_add(
653     ListBase *lb,
654     const char *idname,
655     bool (*poll)(struct bContext *, struct wmDrag *, const struct wmEvent *event, const char **),
656     void (*copy)(struct wmDrag *, struct wmDropBox *));
657 ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid);
658
659 /* ID drag and drop */
660 void WM_drag_add_ID(struct wmDrag *drag, struct ID *id, struct ID *from_parent);
661 struct ID *WM_drag_ID(const struct wmDrag *drag, short idcode);
662 struct ID *WM_drag_ID_from_event(const struct wmEvent *event, short idcode);
663
664 /* Set OpenGL viewport and scissor */
665 void wmViewport(const struct rcti *rect);
666 void wmPartialViewport(rcti *drawrct, const rcti *winrct, const rcti *partialrct);
667 void wmWindowViewport(struct wmWindow *win);
668
669 /* OpenGL utilities with safety check */
670 void wmOrtho2(float x1, float x2, float y1, float y2);
671 /* use for conventions (avoid hard-coded offsets all over) */
672 void wmOrtho2_region_pixelspace(const struct ARegion *region);
673 void wmOrtho2_pixelspace(const float x, const float y);
674 void wmGetProjectionMatrix(float mat[4][4], const struct rcti *winrct);
675
676 /* threaded Jobs Manager */
677 enum {
678   WM_JOB_PRIORITY = (1 << 0),
679   WM_JOB_EXCL_RENDER = (1 << 1),
680   WM_JOB_PROGRESS = (1 << 2),
681 };
682
683 /**
684  * Identifying jobs by owner alone is unreliable, this isnt saved,
685  * order can change (keep 0 for 'any').
686  */
687 enum {
688   WM_JOB_TYPE_ANY = 0,
689   WM_JOB_TYPE_COMPOSITE,
690   WM_JOB_TYPE_RENDER,
691   WM_JOB_TYPE_RENDER_PREVIEW, /* UI preview */
692   WM_JOB_TYPE_OBJECT_SIM_OCEAN,
693   WM_JOB_TYPE_OBJECT_SIM_FLUID,
694   WM_JOB_TYPE_OBJECT_BAKE_TEXTURE,
695   WM_JOB_TYPE_OBJECT_BAKE,
696   WM_JOB_TYPE_FILESEL_READDIR,
697   WM_JOB_TYPE_CLIP_BUILD_PROXY,
698   WM_JOB_TYPE_CLIP_TRACK_MARKERS,
699   WM_JOB_TYPE_CLIP_SOLVE_CAMERA,
700   WM_JOB_TYPE_CLIP_PREFETCH,
701   WM_JOB_TYPE_SEQ_BUILD_PROXY,
702   WM_JOB_TYPE_SEQ_BUILD_PREVIEW,
703   WM_JOB_TYPE_POINTCACHE,
704   WM_JOB_TYPE_DPAINT_BAKE,
705   WM_JOB_TYPE_ALEMBIC,
706   WM_JOB_TYPE_SHADER_COMPILATION,
707   WM_JOB_TYPE_STUDIOLIGHT,
708   WM_JOB_TYPE_LIGHT_BAKE,
709   WM_JOB_TYPE_FSMENU_BOOKMARK_VALIDATE,
710   WM_JOB_TYPE_QUADRIFLOW_REMESH,
711   /* add as needed, bake, seq proxy build
712    * if having hard coded values is a problem */
713 };
714
715 struct wmJob *WM_jobs_get(struct wmWindowManager *wm,
716                           struct wmWindow *win,
717                           void *owner,
718                           const char *name,
719                           int flag,
720                           int job_type);
721
722 bool WM_jobs_test(struct wmWindowManager *wm, void *owner, int job_type);
723 float WM_jobs_progress(struct wmWindowManager *wm, void *owner);
724 char *WM_jobs_name(struct wmWindowManager *wm, void *owner);
725 double WM_jobs_starttime(struct wmWindowManager *wm, void *owner);
726 void *WM_jobs_customdata(struct wmWindowManager *wm, void *owner);
727 void *WM_jobs_customdata_from_type(struct wmWindowManager *wm, int job_type);
728
729 bool WM_jobs_is_running(struct wmJob *);
730 bool WM_jobs_is_stopped(wmWindowManager *wm, void *owner);
731 void *WM_jobs_customdata_get(struct wmJob *);
732 void WM_jobs_customdata_set(struct wmJob *, void *customdata, void (*free)(void *));
733 void WM_jobs_timer(struct wmJob *, double timestep, unsigned int note, unsigned int endnote);
734 void WM_jobs_delay_start(struct wmJob *, double delay_time);
735 void WM_jobs_callbacks(struct wmJob *,
736                        void (*startjob)(void *, short *, short *, float *),
737                        void (*initjob)(void *),
738                        void (*update)(void *),
739                        void (*endjob)(void *));
740
741 void WM_jobs_start(struct wmWindowManager *wm, struct wmJob *);
742 void WM_jobs_stop(struct wmWindowManager *wm, void *owner, void *startjob);
743 void WM_jobs_kill(struct wmWindowManager *wm,
744                   void *owner,
745                   void (*)(void *, short int *, short int *, float *));
746 void WM_jobs_kill_all(struct wmWindowManager *wm);
747 void WM_jobs_kill_all_except(struct wmWindowManager *wm, void *owner);
748 void WM_jobs_kill_type(struct wmWindowManager *wm, void *owner, int job_type);
749
750 bool WM_jobs_has_running(struct wmWindowManager *wm);
751
752 void WM_job_main_thread_lock_acquire(struct wmJob *job);
753 void WM_job_main_thread_lock_release(struct wmJob *job);
754
755 /* clipboard */
756 char *WM_clipboard_text_get(bool selection, int *r_len);
757 char *WM_clipboard_text_get_firstline(bool selection, int *r_len);
758 void WM_clipboard_text_set(const char *buf, bool selection);
759
760 /* progress */
761 void WM_progress_set(struct wmWindow *win, float progress);
762 void WM_progress_clear(struct wmWindow *win);
763
764 /* Draw (for screenshot) */
765 void *WM_draw_cb_activate(struct wmWindow *win,
766                           void (*draw)(const struct wmWindow *, void *),
767                           void *customdata);
768 void WM_draw_cb_exit(struct wmWindow *win, void *handle);
769 void WM_redraw_windows(struct bContext *C);
770
771 void WM_draw_region_viewport_ensure(struct ARegion *region, short space_type);
772 void WM_draw_region_viewport_bind(struct ARegion *region);
773 void WM_draw_region_viewport_unbind(struct ARegion *region);
774
775 /* Region drawing */
776 void WM_draw_region_free(struct ARegion *region);
777 struct GPUViewport *WM_draw_region_get_viewport(struct ARegion *region);
778 struct GPUViewport *WM_draw_region_get_bound_viewport(struct ARegion *region);
779
780 void WM_main_playanim(int argc, const char **argv);
781
782 /* debugging only, convenience function to write on crash */
783 bool write_crash_blend(void);
784
785 /* Lock the interface for any communication */
786 void WM_set_locked_interface(struct wmWindowManager *wm, bool lock);
787
788 /* For testing only 'G_FLAG_EVENT_SIMULATE' */
789 struct wmEvent *WM_event_add_simulate(struct wmWindow *win, const struct wmEvent *event_to_add);
790
791 const char *WM_window_cursor_keymap_status_get(const struct wmWindow *win,
792                                                int button_index,
793                                                int type_index);
794 void WM_window_cursor_keymap_status_refresh(struct bContext *C, struct wmWindow *win);
795
796 void WM_window_status_area_tag_redraw(struct wmWindow *win);
797 struct ScrArea *WM_window_status_area_find(struct wmWindow *win, struct bScreen *screen);
798 bool WM_window_modal_keymap_status_draw(struct bContext *C,
799                                         struct wmWindow *win,
800                                         struct uiLayout *layout);
801
802 /* wm_event_query.c */
803 void WM_event_print(const struct wmEvent *event);
804
805 int WM_event_modifier_flag(const struct wmEvent *event);
806
807 bool WM_event_is_modal_tweak_exit(const struct wmEvent *event, int tweak_event);
808 bool WM_event_is_last_mousemove(const struct wmEvent *event);
809
810 int WM_event_drag_threshold(const struct wmEvent *event);
811 bool WM_event_drag_test(const struct wmEvent *event, const int prev_xy[2]);
812 bool WM_event_drag_test_with_delta(const struct wmEvent *event, const int delta[2]);
813
814 /* event map */
815 int WM_userdef_event_map(int kmitype);
816 int WM_userdef_event_type_from_keymap_type(int kmitype);
817
818 #ifdef WITH_INPUT_NDOF
819 void WM_event_ndof_pan_get(const struct wmNDOFMotionData *ndof,
820                            float r_pan[3],
821                            const bool use_zoom);
822 void WM_event_ndof_rotate_get(const struct wmNDOFMotionData *ndof, float r_rot[3]);
823
824 float WM_event_ndof_to_axis_angle(const struct wmNDOFMotionData *ndof, float axis[3]);
825 void WM_event_ndof_to_quat(const struct wmNDOFMotionData *ndof, float q[4]);
826 #endif /* WITH_INPUT_NDOF */
827
828 float WM_event_tablet_data(const struct wmEvent *event, int *pen_flip, float tilt[2]);
829 bool WM_event_is_tablet(const struct wmEvent *event);
830
831 #ifdef WITH_INPUT_IME
832 bool WM_event_is_ime_switch(const struct wmEvent *event);
833 #endif
834
835 /* wm_tooltip.c */
836 typedef struct ARegion *(*wmTooltipInitFn)(struct bContext *C,
837                                            struct ARegion *region,
838                                            int *pass,
839                                            double *r_pass_delay,
840                                            bool *r_exit_on_event);
841
842 void WM_tooltip_immediate_init(struct bContext *C,
843                                struct wmWindow *win,
844                                struct ScrArea *area,
845                                struct ARegion *region,
846                                wmTooltipInitFn init);
847 void WM_tooltip_timer_init_ex(struct bContext *C,
848                               struct wmWindow *win,
849                               struct ScrArea *area,
850                               struct ARegion *region,
851                               wmTooltipInitFn init,
852                               double delay);
853 void WM_tooltip_timer_init(struct bContext *C,
854                            struct wmWindow *win,
855                            struct ScrArea *area,
856                            struct ARegion *region,
857                            wmTooltipInitFn init);
858 void WM_tooltip_timer_clear(struct bContext *C, struct wmWindow *win);
859 void WM_tooltip_clear(struct bContext *C, struct wmWindow *win);
860 void WM_tooltip_init(struct bContext *C, struct wmWindow *win);
861 void WM_tooltip_refresh(struct bContext *C, struct wmWindow *win);
862 double WM_tooltip_time_closed(void);
863
864 /* wm_utils.c */
865 struct wmGenericCallback *WM_generic_callback_steal(struct wmGenericCallback *callback);
866 void WM_generic_callback_free(struct wmGenericCallback *callback);
867
868 void WM_generic_user_data_free(struct wmGenericUserData *user_data);
869
870 #ifdef WITH_XR_OPENXR
871 /* wm_xr.c */
872 bool WM_xr_session_exists(const wmXrData *xr);
873 bool WM_xr_session_is_ready(const wmXrData *xr);
874 struct wmXrSessionState *WM_xr_session_state_handle_get(const wmXrData *xr);
875 bool WM_xr_session_state_viewer_pose_location_get(const wmXrData *xr, float r_location[3]);
876 bool WM_xr_session_state_viewer_pose_rotation_get(const wmXrData *xr, float r_rotation[4]);
877 bool WM_xr_session_state_viewer_pose_matrix_info_get(const wmXrData *xr,
878                                                      float r_viewmat[4][4],
879                                                      float *r_focal_len);
880 #endif
881
882 #ifdef __cplusplus
883 }
884 #endif
885
886 #endif /* __WM_API_H__ */