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