Blender  V2.93
wm_operators.c
Go to the documentation of this file.
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 
27 #include <ctype.h>
28 #include <errno.h>
29 #include <float.h>
30 #include <stddef.h>
31 #include <stdio.h>
32 #include <string.h>
33 
34 #ifdef WIN32
35 # include "GHOST_C-api.h"
36 #endif
37 
38 #include "MEM_guardedalloc.h"
39 
40 #include "CLG_log.h"
41 
42 #include "DNA_ID.h"
43 #include "DNA_brush_types.h"
44 #include "DNA_object_types.h"
45 #include "DNA_scene_types.h"
46 #include "DNA_screen_types.h"
47 #include "DNA_userdef_types.h"
49 
50 #include "BLT_translation.h"
51 
52 #include "PIL_time.h"
53 
54 #include "BLI_blenlib.h"
55 #include "BLI_dial_2d.h"
56 #include "BLI_dynstr.h" /*for WM_operator_pystring */
57 #include "BLI_math.h"
58 #include "BLI_utildefines.h"
59 
60 #include "BKE_brush.h"
61 #include "BKE_colortools.h"
62 #include "BKE_context.h"
63 #include "BKE_global.h"
64 #include "BKE_icons.h"
65 #include "BKE_idprop.h"
66 #include "BKE_image.h"
67 #include "BKE_lib_id.h"
68 #include "BKE_lib_query.h"
69 #include "BKE_main.h"
70 #include "BKE_material.h"
71 #include "BKE_report.h"
72 #include "BKE_scene.h"
73 #include "BKE_screen.h" /* BKE_ST_MAXNAME */
74 #include "BKE_unit.h"
75 
76 #include "BKE_idtype.h"
77 
78 #include "BLF_api.h"
79 
80 #include "GPU_immediate.h"
81 #include "GPU_immediate_util.h"
82 #include "GPU_matrix.h"
83 #include "GPU_state.h"
84 
85 #include "IMB_imbuf_types.h"
86 
87 #include "ED_fileselect.h"
88 #include "ED_numinput.h"
89 #include "ED_screen.h"
90 #include "ED_undo.h"
91 #include "ED_view3d.h"
92 
93 #include "RNA_access.h"
94 #include "RNA_define.h"
95 #include "RNA_enum_types.h"
96 
97 #include "UI_interface.h"
98 #include "UI_interface_icons.h"
99 #include "UI_resources.h"
100 
101 #include "WM_api.h"
102 #include "WM_types.h"
103 
104 #include "wm.h"
105 #include "wm_draw.h"
106 #include "wm_event_system.h"
107 #include "wm_event_types.h"
108 #include "wm_files.h"
109 #include "wm_window.h"
110 #ifdef WITH_XR_OPENXR
111 # include "wm_xr.h"
112 #endif
113 
114 #define UNDOCUMENTED_OPERATOR_TIP N_("(undocumented operator)")
115 
118 /* -------------------------------------------------------------------- */
122 /* SOME_OT_op -> some.op */
123 void WM_operator_py_idname(char *to, const char *from)
124 {
125  const char *sep = strstr(from, "_OT_");
126  if (sep) {
127  int ofs = (sep - from);
128 
129  /* note, we use ascii tolower instead of system tolower, because the
130  * latter depends on the locale, and can lead to idname mismatch */
131  memcpy(to, from, sizeof(char) * ofs);
132  BLI_str_tolower_ascii(to, ofs);
133 
134  to[ofs] = '.';
135  BLI_strncpy(to + (ofs + 1), sep + 4, OP_MAX_TYPENAME - (ofs + 1));
136  }
137  else {
138  /* should not happen but support just in case */
140  }
141 }
142 
143 /* some.op -> SOME_OT_op */
144 void WM_operator_bl_idname(char *to, const char *from)
145 {
146  if (from) {
147  const char *sep = strchr(from, '.');
148 
149  int from_len;
150  if (sep && (from_len = strlen(from)) < OP_MAX_TYPENAME - 3) {
151  const int ofs = (sep - from);
152  memcpy(to, from, sizeof(char) * ofs);
153  BLI_str_toupper_ascii(to, ofs);
154  memcpy(to + ofs, "_OT_", 4);
155  memcpy(to + (ofs + 4), sep + 1, (from_len - ofs));
156  }
157  else {
158  /* should not happen but support just in case */
160  }
161  }
162  else {
163  to[0] = 0;
164  }
165 }
166 
172  const char *classname,
173  const char *idname)
174 {
175  const char *ch = idname;
176  int dot = 0;
177  int i;
178  for (i = 0; *ch; i++, ch++) {
179  if ((*ch >= 'a' && *ch <= 'z') || (*ch >= '0' && *ch <= '9') || *ch == '_') {
180  /* pass */
181  }
182  else if (*ch == '.') {
183  dot++;
184  }
185  else {
186  BKE_reportf(reports,
187  RPT_ERROR,
188  "Registering operator class: '%s', invalid bl_idname '%s', at position %d",
189  classname,
190  idname,
191  i);
192  return false;
193  }
194  }
195 
196  if (i > (MAX_NAME - 3)) {
197  BKE_reportf(reports,
198  RPT_ERROR,
199  "Registering operator class: '%s', invalid bl_idname '%s', "
200  "is too long, maximum length is %d",
201  classname,
202  idname,
203  MAX_NAME - 3);
204  return false;
205  }
206 
207  if (dot != 1) {
208  BKE_reportf(
209  reports,
210  RPT_ERROR,
211  "Registering operator class: '%s', invalid bl_idname '%s', must contain 1 '.' character",
212  classname,
213  idname);
214  return false;
215  }
216  return true;
217 }
218 
229  wmOperator *op,
230  const bool all_args,
231  const bool macro_args,
233  PointerRNA *opptr)
234 {
235  char idname_py[OP_MAX_TYPENAME];
236 
237  /* for building the string */
238  DynStr *dynstr = BLI_dynstr_new();
239 
240  /* arbitrary, but can get huge string with stroke painting otherwise */
241  int max_prop_length = 10;
242 
243  WM_operator_py_idname(idname_py, ot->idname);
244  BLI_dynstr_appendf(dynstr, "bpy.ops.%s(", idname_py);
245 
246  if (op && op->macro.first) {
247  /* Special handling for macros, else we only get default values in this case... */
248  wmOperator *opm;
249  bool first_op = true;
250 
251  opm = macro_args ? op->macro.first : NULL;
252 
253  for (; opm; opm = opm->next) {
254  PointerRNA *opmptr = opm->ptr;
255  PointerRNA opmptr_default;
256  if (opmptr == NULL) {
257  WM_operator_properties_create_ptr(&opmptr_default, opm->type);
258  opmptr = &opmptr_default;
259  }
260 
261  char *cstring_args = RNA_pointer_as_string_id(C, opmptr);
262  if (first_op) {
263  BLI_dynstr_appendf(dynstr, "%s=%s", opm->type->idname, cstring_args);
264  first_op = false;
265  }
266  else {
267  BLI_dynstr_appendf(dynstr, ", %s=%s", opm->type->idname, cstring_args);
268  }
269  MEM_freeN(cstring_args);
270 
271  if (opmptr == &opmptr_default) {
272  WM_operator_properties_free(&opmptr_default);
273  }
274  }
275  }
276  else {
277  /* only to get the original props for comparisons */
278  PointerRNA opptr_default;
279  const bool macro_args_test = ot->macro.first ? macro_args : true;
280 
281  if (opptr == NULL) {
282  WM_operator_properties_create_ptr(&opptr_default, ot);
283  opptr = &opptr_default;
284  }
285 
286  char *cstring_args = RNA_pointer_as_string_keywords(
287  C, opptr, false, all_args, macro_args_test, max_prop_length);
288  BLI_dynstr_append(dynstr, cstring_args);
289  MEM_freeN(cstring_args);
290 
291  if (opptr == &opptr_default) {
292  WM_operator_properties_free(&opptr_default);
293  }
294  }
295 
296  BLI_dynstr_append(dynstr, ")");
297 
298  char *cstring = BLI_dynstr_get_cstring(dynstr);
299  BLI_dynstr_free(dynstr);
300  return cstring;
301 }
302 
303 char *WM_operator_pystring(bContext *C, wmOperator *op, const bool all_args, const bool macro_args)
304 {
305  return WM_operator_pystring_ex(C, op, all_args, macro_args, op->type, op->ptr);
306 }
307 
311 bool WM_operator_pystring_abbreviate(char *str, int str_len_max)
312 {
313  const int str_len = strlen(str);
314  const char *parens_start = strchr(str, '(');
315 
316  if (parens_start) {
317  const int parens_start_pos = parens_start - str;
318  const char *parens_end = strrchr(parens_start + 1, ')');
319 
320  if (parens_end) {
321  const int parens_len = parens_end - parens_start;
322 
323  if (parens_len > str_len_max) {
324  const char *comma_first = strchr(parens_start, ',');
325 
326  /* truncate after the first comma */
327  if (comma_first) {
328  const char end_str[] = " ... )";
329  const int end_str_len = sizeof(end_str) - 1;
330 
331  /* leave a place for the first argument*/
332  const int new_str_len = (comma_first - parens_start) + 1;
333 
334  if (str_len >= new_str_len + parens_start_pos + end_str_len + 1) {
335  /* append " ... )" to the string after the comma */
336  memcpy(str + new_str_len + parens_start_pos, end_str, end_str_len + 1);
337 
338  return true;
339  }
340  }
341  }
342  }
343  }
344 
345  return false;
346 }
347 
348 /* return NULL if no match is found */
349 #if 0
350 static const char *wm_context_member_from_ptr(bContext *C, const PointerRNA *ptr)
351 {
352  /* loop over all context items and do 2 checks
353  *
354  * - see if the pointer is in the context.
355  * - see if the pointers ID is in the context.
356  */
357 
358  /* Don't get from the context store since this is normally
359  * set only for the UI and not usable elsewhere. */
360  ListBase lb = CTX_data_dir_get_ex(C, false, true, true);
361  LinkData *link;
362 
363  const char *member_found = NULL;
364  const char *member_id = NULL;
365 
366  for (link = lb.first; link; link = link->next) {
367  const char *identifier = link->data;
368  PointerRNA ctx_item_ptr = {
369  {0}}; /* CTX_data_pointer_get(C, identifier); */ /* XXX, this isn't working. */
370 
371  if (ctx_item_ptr.type == NULL) {
372  continue;
373  }
374 
375  if (ptr->owner_id == ctx_item_ptr.owner_id) {
376  if ((ptr->data == ctx_item_ptr.data) && (ptr->type == ctx_item_ptr.type)) {
377  /* found! */
378  member_found = identifier;
379  break;
380  }
381  else if (RNA_struct_is_ID(ctx_item_ptr.type)) {
382  /* we found a reference to this ID,
383  * so fallback to it if there is no direct reference */
384  member_id = identifier;
385  }
386  }
387  }
388  BLI_freelistN(&lb);
389 
390  if (member_found) {
391  return member_found;
392  }
393  else if (member_id) {
394  return member_id;
395  }
396  else {
397  return NULL;
398  }
399 }
400 
401 #else
402 
403 /* use hard coded checks for now */
404 
405 static const char *wm_context_member_from_ptr(bContext *C, const PointerRNA *ptr)
406 {
407  const char *member_id = NULL;
408 
409  if (ptr->owner_id) {
410 
411 # define CTX_TEST_PTR_ID(C, member, idptr) \
412  { \
413  const char *ctx_member = member; \
414  PointerRNA ctx_item_ptr = CTX_data_pointer_get(C, ctx_member); \
415  if (ctx_item_ptr.owner_id == idptr) { \
416  member_id = ctx_member; \
417  break; \
418  } \
419  } \
420  (void)0
421 
422 # define CTX_TEST_PTR_ID_CAST(C, member, member_full, cast, idptr) \
423  { \
424  const char *ctx_member = member; \
425  const char *ctx_member_full = member_full; \
426  PointerRNA ctx_item_ptr = CTX_data_pointer_get(C, ctx_member); \
427  if (ctx_item_ptr.owner_id && (ID *)cast(ctx_item_ptr.owner_id) == idptr) { \
428  member_id = ctx_member_full; \
429  break; \
430  } \
431  } \
432  (void)0
433 
434 # define TEST_PTR_DATA_TYPE(member, rna_type, rna_ptr, dataptr_cmp) \
435  { \
436  const char *ctx_member = member; \
437  if (RNA_struct_is_a((rna_ptr)->type, &(rna_type)) && (rna_ptr)->data == (dataptr_cmp)) { \
438  member_id = ctx_member; \
439  break; \
440  } \
441  } \
442  (void)0
443 
444  switch (GS(ptr->owner_id->name)) {
445  case ID_SCE: {
446  CTX_TEST_PTR_ID(C, "scene", ptr->owner_id);
447  break;
448  }
449  case ID_OB: {
450  CTX_TEST_PTR_ID(C, "object", ptr->owner_id);
451  break;
452  }
453  /* from rna_Main_objects_new */
455 # define ID_CAST_OBDATA(id_pt) (((Object *)(id_pt))->data)
456  CTX_TEST_PTR_ID_CAST(C, "object", "object.data", ID_CAST_OBDATA, ptr->owner_id);
457  break;
458 # undef ID_CAST_OBDATA
459  }
460  case ID_MA: {
461 # define ID_CAST_OBMATACT(id_pt) \
462  (BKE_object_material_get(((Object *)id_pt), ((Object *)id_pt)->actcol))
464  C, "object", "object.active_material", ID_CAST_OBMATACT, ptr->owner_id);
465  break;
466 # undef ID_CAST_OBMATACT
467  }
468  case ID_WO: {
469 # define ID_CAST_SCENEWORLD(id_pt) (((Scene *)(id_pt))->world)
470  CTX_TEST_PTR_ID_CAST(C, "scene", "scene.world", ID_CAST_SCENEWORLD, ptr->owner_id);
471  break;
472 # undef ID_CAST_SCENEWORLD
473  }
474  case ID_SCR: {
475  CTX_TEST_PTR_ID(C, "screen", ptr->owner_id);
476 
477  SpaceLink *space_data = CTX_wm_space_data(C);
478 
479  TEST_PTR_DATA_TYPE("space_data", RNA_Space, ptr, space_data);
482 
483  switch (space_data->spacetype) {
484  case SPACE_VIEW3D: {
485  const View3D *v3d = (View3D *)space_data;
486  const View3DShading *shading = &v3d->shading;
487 
488  TEST_PTR_DATA_TYPE("space_data", RNA_View3DOverlay, ptr, v3d);
489  TEST_PTR_DATA_TYPE("space_data", RNA_View3DShading, ptr, shading);
490  break;
491  }
492  case SPACE_GRAPH: {
493  const SpaceGraph *sipo = (SpaceGraph *)space_data;
494  const bDopeSheet *ads = sipo->ads;
495  TEST_PTR_DATA_TYPE("space_data", RNA_DopeSheet, ptr, ads);
496  break;
497  }
498  case SPACE_FILE: {
499  const SpaceFile *sfile = (SpaceFile *)space_data;
502  break;
503  }
504  case SPACE_IMAGE: {
505  const SpaceImage *sima = (SpaceImage *)space_data;
506  TEST_PTR_DATA_TYPE("space_data", RNA_SpaceUVEditor, ptr, sima);
507  break;
508  }
509  case SPACE_NLA: {
510  const SpaceNla *snla = (SpaceNla *)space_data;
511  const bDopeSheet *ads = snla->ads;
512  TEST_PTR_DATA_TYPE("space_data", RNA_DopeSheet, ptr, ads);
513  break;
514  }
515  case SPACE_ACTION: {
516  const SpaceAction *sact = (SpaceAction *)space_data;
517  const bDopeSheet *ads = &sact->ads;
518  TEST_PTR_DATA_TYPE("space_data", RNA_DopeSheet, ptr, ads);
519  break;
520  }
521  }
522 
523  break;
524  }
525  default:
526  break;
527  }
528 # undef CTX_TEST_PTR_ID
529 # undef CTX_TEST_PTR_ID_CAST
530 # undef TEST_PTR_DATA_TYPE
531  }
532 
533  return member_id;
534 }
535 #endif
536 
538  PointerRNA *ptr,
539  PropertyRNA *prop,
540  int index)
541 {
542  const char *member_id = wm_context_member_from_ptr(C, ptr);
543  char *ret = NULL;
544  if (member_id != NULL) {
545  char *prop_str = RNA_path_struct_property_py(ptr, prop, index);
546  if (prop_str) {
547  ret = BLI_sprintfN("bpy.context.%s.%s", member_id, prop_str);
548  MEM_freeN(prop_str);
549  }
550  }
551  return ret;
552 }
553 
555 {
557 }
558 
560 {
561  char *lhs = C ? wm_prop_pystring_from_context(C, ptr, prop, index) : NULL;
562 
563  if (lhs == NULL) {
564  /* Fallback to `bpy.data.foo[id]` if we don't find in the context. */
565  lhs = RNA_path_full_property_py(CTX_data_main(C), ptr, prop, index);
566  }
567 
568  if (!lhs) {
569  return NULL;
570  }
571 
572  char *rhs = RNA_property_as_string(C, ptr, prop, index, INT_MAX);
573  if (!rhs) {
574  MEM_freeN(lhs);
575  return NULL;
576  }
577 
578  char *ret = BLI_sprintfN("%s = %s", lhs, rhs);
579  MEM_freeN(lhs);
580  MEM_freeN(rhs);
581  return ret;
582 }
583 
585 {
586  /* Set the ID so the context can be accessed: see #STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID. */
587  RNA_pointer_create(G_MAIN->wm.first, ot->srna, NULL, ptr);
588 }
589 
590 void WM_operator_properties_create(PointerRNA *ptr, const char *opstring)
591 {
592  wmOperatorType *ot = WM_operatortype_find(opstring, false);
593 
594  if (ot) {
596  }
597  else {
598  /* Set the ID so the context can be accessed: see #STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID. */
600  }
601 }
602 
603 /* similar to the function above except its uses ID properties
604  * used for keymaps and macros */
605 void WM_operator_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *opstring)
606 {
607  if (*properties == NULL) {
608  IDPropertyTemplate val = {0};
609  *properties = IDP_New(IDP_GROUP, &val, "wmOpItemProp");
610  }
611 
612  if (*ptr == NULL) {
613  *ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr");
615  }
616 
617  (*ptr)->data = *properties;
618 }
619 
620 void WM_operator_properties_sanitize(PointerRNA *ptr, const bool no_context)
621 {
622  RNA_STRUCT_BEGIN (ptr, prop) {
623  switch (RNA_property_type(prop)) {
624  case PROP_ENUM:
625  if (no_context) {
627  }
628  else {
630  }
631  break;
632  case PROP_POINTER: {
633  StructRNA *ptype = RNA_property_pointer_type(ptr, prop);
634 
635  /* recurse into operator properties */
637  PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
638  WM_operator_properties_sanitize(&opptr, no_context);
639  }
640  break;
641  }
642  default:
643  break;
644  }
645  }
647 }
648 
657 bool WM_operator_properties_default(PointerRNA *ptr, const bool do_update)
658 {
659  bool changed = false;
660  RNA_STRUCT_BEGIN (ptr, prop) {
661  switch (RNA_property_type(prop)) {
662  case PROP_POINTER: {
663  StructRNA *ptype = RNA_property_pointer_type(ptr, prop);
664  if (ptype != &RNA_Struct) {
665  PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
666  changed |= WM_operator_properties_default(&opptr, do_update);
667  }
668  break;
669  }
670  default:
671  if ((do_update == false) || (RNA_property_is_set(ptr, prop) == false)) {
672  if (RNA_property_reset(ptr, prop, -1)) {
673  changed = true;
674  }
675  }
676  break;
677  }
678  }
680 
681  return changed;
682 }
683 
684 /* remove all props without PROP_SKIP_SAVE */
686 {
687  if (op->ptr->data) {
689 
690  RNA_PROP_BEGIN (op->ptr, itemptr, iterprop) {
691  PropertyRNA *prop = itemptr.data;
692 
693  if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) {
694  const char *identifier = RNA_property_identifier(prop);
695  RNA_struct_idprops_unset(op->ptr, identifier);
696  }
697  }
698  RNA_PROP_END;
699  }
700 }
701 
703 {
704  IDProperty *properties = ptr->data;
705 
706  if (properties) {
707  IDP_ClearProperty(properties);
708  }
709 }
710 
712 {
713  IDProperty *properties = ptr->data;
714 
715  if (properties) {
716  IDP_FreeProperty(properties);
717  ptr->data = NULL; /* just in case */
718  }
719 }
720 
723 /* -------------------------------------------------------------------- */
727 #if 1 /* may want to disable operator remembering previous state for testing */
728 
729 static bool operator_last_properties_init_impl(wmOperator *op, IDProperty *last_properties)
730 {
731  bool changed = false;
732  IDPropertyTemplate val = {0};
733  IDProperty *replaceprops = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
734 
735  CLOG_INFO(WM_LOG_OPERATORS, 1, "loading previous properties for '%s'", op->type->idname);
736 
738 
739  RNA_PROP_BEGIN (op->ptr, itemptr, iterprop) {
740  PropertyRNA *prop = itemptr.data;
741  if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) {
742  if (!RNA_property_is_set(op->ptr, prop)) { /* don't override a setting already set */
743  const char *identifier = RNA_property_identifier(prop);
744  IDProperty *idp_src = IDP_GetPropertyFromGroup(last_properties, identifier);
745  if (idp_src) {
746  IDProperty *idp_dst = IDP_CopyProperty(idp_src);
747 
748  /* note - in the future this may need to be done recursively,
749  * but for now RNA doesn't access nested operators */
750  idp_dst->flag |= IDP_FLAG_GHOST;
751 
752  /* add to temporary group instead of immediate replace,
753  * because we are iterating over this group */
754  IDP_AddToGroup(replaceprops, idp_dst);
755  changed = true;
756  }
757  }
758  }
759  }
760  RNA_PROP_END;
761 
762  IDP_MergeGroup(op->properties, replaceprops, true);
763  IDP_FreeProperty(replaceprops);
764  return changed;
765 }
766 
768 {
769  bool changed = false;
770  if (op->type->last_properties) {
772  LISTBASE_FOREACH (wmOperator *, opm, &op->macro) {
773  IDProperty *idp_src = IDP_GetPropertyFromGroup(op->type->last_properties, opm->idname);
774  if (idp_src) {
775  changed |= operator_last_properties_init_impl(opm, idp_src);
776  }
777  }
778  }
779  return changed;
780 }
781 
783 {
784  if (op->type->last_properties) {
786  op->type->last_properties = NULL;
787  }
788 
789  if (op->properties) {
790  CLOG_INFO(WM_LOG_OPERATORS, 1, "storing properties for '%s'", op->type->idname);
792  }
793 
794  if (op->macro.first != NULL) {
795  LISTBASE_FOREACH (wmOperator *, opm, &op->macro) {
796  if (opm->properties) {
797  if (op->type->last_properties == NULL) {
799  IDP_GROUP, &(IDPropertyTemplate){0}, "wmOperatorProperties");
800  }
801  IDProperty *idp_macro = IDP_CopyProperty(opm->properties);
802  STRNCPY(idp_macro->name, opm->type->idname);
803  IDP_ReplaceInGroup(op->type->last_properties, idp_macro);
804  }
805  }
806  }
807 
808  return (op->type->last_properties != NULL);
809 }
810 
811 #else
812 
814 {
815  return false;
816 }
817 
819 {
820  return false;
821 }
822 
823 #endif
824 
827 /* -------------------------------------------------------------------- */
839 {
840  PropertyRNA *wait_to_deselect_prop = RNA_struct_find_property(op->ptr,
841  "wait_to_deselect_others");
842  const short init_event_type = (short)POINTER_AS_INT(op->customdata);
843  int ret_value = 0;
844 
845  /* get settings from RNA properties for operator */
846  const int mval[2] = {RNA_int_get(op->ptr, "mouse_x"), RNA_int_get(op->ptr, "mouse_y")};
847 
848  if (init_event_type == 0) {
849  if (event->val == KM_PRESS) {
850  RNA_property_boolean_set(op->ptr, wait_to_deselect_prop, true);
851 
852  ret_value = op->type->exec(C, op);
853  OPERATOR_RETVAL_CHECK(ret_value);
854 
855  op->customdata = POINTER_FROM_INT((int)event->type);
856  if (ret_value & OPERATOR_RUNNING_MODAL) {
858  }
859  return ret_value | OPERATOR_PASS_THROUGH;
860  }
861  /* If we are in init phase, and cannot validate init of modal operations,
862  * just fall back to basic exec.
863  */
864  RNA_property_boolean_set(op->ptr, wait_to_deselect_prop, false);
865 
866  ret_value = op->type->exec(C, op);
867  OPERATOR_RETVAL_CHECK(ret_value);
868 
869  return ret_value | OPERATOR_PASS_THROUGH;
870  }
871  if (event->type == init_event_type && event->val == KM_RELEASE) {
872  RNA_property_boolean_set(op->ptr, wait_to_deselect_prop, false);
873 
874  ret_value = op->type->exec(C, op);
875  OPERATOR_RETVAL_CHECK(ret_value);
876 
877  return ret_value | OPERATOR_PASS_THROUGH;
878  }
879  if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
880  const int drag_delta[2] = {
881  mval[0] - event->mval[0],
882  mval[1] - event->mval[1],
883  };
884  /* If user moves mouse more than defined threshold, we consider select operator as
885  * finished. Otherwise, it is still running until we get an 'release' event. In any
886  * case, we pass through event, but select op is not finished yet. */
887  if (WM_event_drag_test_with_delta(event, drag_delta)) {
889  }
890  /* Important not to return anything other than PASS_THROUGH here,
891  * otherwise it prevents underlying tweak detection code to work properly. */
892  return OPERATOR_PASS_THROUGH;
893  }
894 
896 }
897 
906 {
907  RNA_int_set(op->ptr, "mouse_x", event->mval[0]);
908  RNA_int_set(op->ptr, "mouse_y", event->mval[1]);
909 
910  op->customdata = POINTER_FROM_INT(0);
911 
912  return op->type->modal(C, op, event);
913 }
914 
916 {
917  if (op->flag & OP_IS_INVOKE) {
919  View3D *v3d = CTX_wm_view3d(C);
920 
921  const float dia = v3d ? ED_view3d_grid_scale(scene, v3d, NULL) :
923 
924  /* always run, so the values are initialized,
925  * otherwise we may get differ behavior when (dia != 1.0) */
926  RNA_STRUCT_BEGIN (op->ptr, prop) {
927  if (RNA_property_type(prop) == PROP_FLOAT) {
928  PropertySubType pstype = RNA_property_subtype(prop);
929  if (pstype == PROP_DISTANCE) {
930  /* we don't support arrays yet */
931  BLI_assert(RNA_property_array_check(prop) == false);
932  /* initialize */
933  if (!RNA_property_is_set_ex(op->ptr, prop, false)) {
934  const float value = RNA_property_float_get_default(op->ptr, prop) * dia;
935  RNA_property_float_set(op->ptr, prop, value);
936  }
937  }
938  }
939  }
941  }
942 }
943 
945 {
946  return (op->flag & OP_IS_INVOKE) ? U.smooth_viewtx : 0;
947 }
948 
949 /* invoke callback, uses enum property named "type" */
950 int WM_menu_invoke_ex(bContext *C, wmOperator *op, int opcontext)
951 {
952  PropertyRNA *prop = op->type->prop;
953 
954  if (prop == NULL) {
955  CLOG_ERROR(WM_LOG_OPERATORS, "'%s' has no enum property set", op->type->idname);
956  }
957  else if (RNA_property_type(prop) != PROP_ENUM) {
959  "'%s', '%s' is not an enum property",
960  op->type->idname,
962  }
963  else if (RNA_property_is_set(op->ptr, prop)) {
964  const int retval = op->type->exec(C, op);
965  OPERATOR_RETVAL_CHECK(retval);
966  return retval;
967  }
968  else {
969  uiPopupMenu *pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE);
970  uiLayout *layout = UI_popup_menu_layout(pup);
971  /* set this so the default execution context is the same as submenus */
972  uiLayoutSetOperatorContext(layout, opcontext);
974  layout, op->type->idname, RNA_property_identifier(prop), op->ptr->data, opcontext, 0);
975  UI_popup_menu_end(C, pup);
976  return OPERATOR_INTERFACE;
977  }
978 
979  return OPERATOR_CANCELLED;
980 }
981 
983 {
985 }
986 
988  wmOperator *op; /* the operator that will be executed when selecting an item */
989 
992 };
993 
995 static uiBlock *wm_enum_search_menu(bContext *C, ARegion *region, void *arg)
996 {
997  struct EnumSearchMenu *search_menu = arg;
998  wmWindow *win = CTX_wm_window(C);
999  wmOperator *op = search_menu->op;
1000  /* template_ID uses 4 * widget_unit for width,
1001  * we use a bit more, some items may have a suffix to show. */
1002  const int width = search_menu->use_previews ? 5 * U.widget_unit * search_menu->prv_cols :
1004  const int height = search_menu->use_previews ? 5 * U.widget_unit * search_menu->prv_rows :
1006  static char search[256] = "";
1007 
1008  uiBlock *block = UI_block_begin(C, region, "_popup", UI_EMBOSS);
1011 
1012  search[0] = '\0';
1013  BLI_assert(search_menu->use_previews ||
1014  (search_menu->prv_cols == 0 && search_menu->prv_rows == 0));
1015 #if 0 /* ok, this isn't so easy... */
1016  uiDefBut(block,
1018  0,
1020  10,
1021  10,
1023  UI_UNIT_Y,
1024  NULL,
1025  0.0,
1026  0.0,
1027  0,
1028  0,
1029  "");
1030 #endif
1031  uiBut *but = uiDefSearchButO_ptr(block,
1032  op->type,
1033  op->ptr->data,
1034  search,
1035  0,
1036  ICON_VIEWZOOM,
1037  sizeof(search),
1038  10,
1039  10,
1040  width,
1041  UI_UNIT_Y,
1042  search_menu->prv_rows,
1043  search_menu->prv_cols,
1044  "");
1045 
1046  /* fake button, it holds space for search items */
1047  uiDefBut(block,
1049  0,
1050  "",
1051  10,
1052  10 - UI_searchbox_size_y(),
1053  width,
1054  height,
1055  NULL,
1056  0,
1057  0,
1058  0,
1059  0,
1060  NULL);
1061 
1062  /* Move it downwards, mouse over button. */
1063  UI_block_bounds_set_popup(block, 0.3f * U.widget_unit, (const int[2]){0, -UI_UNIT_Y});
1064 
1065  UI_but_focus_on_enter_event(win, but);
1066 
1067  return block;
1068 }
1069 
1075 {
1076  static struct EnumSearchMenu search_menu;
1077 
1078  search_menu.op = op;
1079  search_menu.use_previews = true;
1080  search_menu.prv_cols = prv_cols;
1081  search_menu.prv_rows = prv_rows;
1082 
1084 
1085  return OPERATOR_INTERFACE;
1086 }
1087 
1089 {
1090  static struct EnumSearchMenu search_menu;
1091  search_menu.op = op;
1093  return OPERATOR_INTERFACE;
1094 }
1095 
1096 /* Can't be used as an invoke directly, needs message arg (can be NULL) */
1098  wmOperator *op,
1099  const char *title,
1100  const int icon,
1101  const char *message,
1102  const short opcontext)
1103 {
1104  IDProperty *properties = op->ptr->data;
1105 
1106  if (properties && properties->len) {
1107  properties = IDP_CopyProperty(op->ptr->data);
1108  }
1109  else {
1110  properties = NULL;
1111  }
1112 
1113  uiPopupMenu *pup = UI_popup_menu_begin(C, title, icon);
1114  uiLayout *layout = UI_popup_menu_layout(pup);
1115  uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, opcontext, 0, NULL);
1116  UI_popup_menu_end(C, pup);
1117 
1118  return OPERATOR_INTERFACE;
1119 }
1120 
1122 {
1124  C, op, IFACE_("OK?"), ICON_QUESTION, message, WM_OP_EXEC_REGION_WIN);
1125 }
1126 
1128 {
1130 }
1131 
1133 {
1134  const bool confirm = RNA_boolean_get(op->ptr, "confirm");
1135  if (confirm) {
1137  }
1138  return op->type->exec(C, op);
1139 }
1140 
1141 /* op->invoke, opens fileselect if path property not set, otherwise executes */
1143 {
1144  if (RNA_struct_property_is_set(op->ptr, "filepath")) {
1145  return WM_operator_call_notest(C, op); /* call exec direct */
1146  }
1148  return OPERATOR_RUNNING_MODAL;
1149 }
1150 
1152 {
1153  char filepath[FILE_MAX];
1154  /* Don't NULL check prop, this can only run on ops with a 'filepath'. */
1155  PropertyRNA *prop = RNA_struct_find_property(op->ptr, "filepath");
1156  RNA_property_string_get(op->ptr, prop, filepath);
1157  if (BKE_image_path_ensure_ext_from_imformat(filepath, im_format)) {
1158  RNA_property_string_set(op->ptr, prop, filepath);
1159  /* note, we could check for and update 'filename' here,
1160  * but so far nothing needs this. */
1161  return true;
1162  }
1163  return false;
1164 }
1165 
1166 /* op->poll */
1168 {
1169  if (CTX_wm_window(C) == NULL) {
1170  return 0;
1171  }
1172  return 1;
1173 }
1174 
1175 /* return false, if the UI should be disabled */
1176 bool WM_operator_check_ui_enabled(const bContext *C, const char *idname)
1177 {
1180 
1181  return !((ED_undo_is_valid(C, idname) == false) || WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY));
1182 }
1183 
1185 {
1187 
1188  /* only for operators that are registered and did an undo push */
1190  if ((op->type->flag & OPTYPE_REGISTER) && (op->type->flag & OPTYPE_UNDO)) {
1191  return op;
1192  }
1193  }
1194 
1195  return NULL;
1196 }
1197 
1199 {
1200  if (ot->last_properties == NULL) {
1201  IDPropertyTemplate val = {0};
1202  ot->last_properties = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
1203  }
1204  return ot->last_properties;
1205 }
1206 
1208 {
1210  RNA_pointer_create(G_MAIN->wm.first, ot->srna, props, ptr);
1211 }
1212 
1216 ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short idcode)
1217 {
1218  Main *bmain = CTX_data_main(C);
1219  ID *id = NULL;
1220  /* check input variables */
1221  if (RNA_struct_property_is_set(op->ptr, "filepath")) {
1222  const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path");
1223  char path[FILE_MAX];
1224  bool exists = false;
1225 
1226  RNA_string_get(op->ptr, "filepath", path);
1227 
1228  errno = 0;
1229 
1230  if (idcode == ID_IM) {
1231  id = (ID *)BKE_image_load_exists_ex(bmain, path, &exists);
1232  }
1233  else {
1235  }
1236 
1237  if (!id) {
1239  RPT_ERROR,
1240  "Cannot read %s '%s': %s",
1241  BKE_idtype_idcode_to_name(idcode),
1242  path,
1243  errno ? strerror(errno) : TIP_("unsupported format"));
1244  return NULL;
1245  }
1246 
1247  if (is_relative_path) {
1248  if (exists == false) {
1249  if (idcode == ID_IM) {
1250  BLI_path_rel(((Image *)id)->filepath, BKE_main_blendfile_path(bmain));
1251  }
1252  else {
1254  }
1255  }
1256  }
1257  }
1258  else if (RNA_struct_property_is_set(op->ptr, "name")) {
1259  char name[MAX_ID_NAME - 2];
1260  RNA_string_get(op->ptr, "name", name);
1261  id = BKE_libblock_find_name(bmain, idcode, name);
1262  if (!id) {
1263  BKE_reportf(
1264  op->reports, RPT_ERROR, "%s '%s' not found", BKE_idtype_idcode_to_name(idcode), name);
1265  return NULL;
1266  }
1267  id_us_plus(id);
1268  }
1269 
1270  return id;
1271 }
1272 
1273 static void wm_block_redo_cb(bContext *C, void *arg_op, int UNUSED(arg_event))
1274 {
1275  wmOperator *op = arg_op;
1276 
1277  if (op == WM_operator_last_redo(C)) {
1278  /* operator was already executed once? undo & repeat */
1280  }
1281  else {
1282  /* operator not executed yet, call it */
1283  ED_undo_push_op(C, op);
1285 
1287  }
1288 }
1289 
1290 static void wm_block_redo_cancel_cb(bContext *C, void *arg_op)
1291 {
1292  wmOperator *op = arg_op;
1293 
1294  /* if operator never got executed, free it */
1295  if (op != WM_operator_last_redo(C)) {
1297  }
1298 }
1299 
1300 static uiBlock *wm_block_create_redo(bContext *C, ARegion *region, void *arg_op)
1301 {
1302  wmOperator *op = arg_op;
1303  const uiStyle *style = UI_style_get_dpi();
1304  int width = 15 * UI_UNIT_X;
1305 
1306  uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
1309 
1310  /* UI_BLOCK_NUMSELECT for layer buttons */
1312 
1313  /* if register is not enabled, the operator gets freed on OPERATOR_FINISHED
1314  * ui_apply_but_funcs_after calls ED_undo_operator_repeate_cb and crashes */
1316 
1318  uiLayout *layout = UI_block_layout(
1319  block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, width, UI_UNIT_Y, 0, style);
1320 
1321  if (op == WM_operator_last_redo(C)) {
1323  uiLayoutSetEnabled(layout, false);
1324  }
1325  }
1326 
1327  uiLayout *col = uiLayoutColumn(layout, false);
1330 
1331  UI_block_bounds_set_popup(block, 6 * U.dpi_fac, NULL);
1332 
1333  return block;
1334 }
1335 
1336 typedef struct wmOpPopUp {
1338  int width;
1339  int height;
1340  int free_op;
1342 
1343 /* Only invoked by OK button in popups created with wm_block_dialog_create() */
1344 static void dialog_exec_cb(bContext *C, void *arg1, void *arg2)
1345 {
1346  wmOperator *op;
1347  {
1348  /* Execute will free the operator.
1349  * In this case, wm_operator_ui_popup_cancel wont run. */
1350  wmOpPopUp *data = arg1;
1351  op = data->op;
1352  MEM_freeN(data);
1353  }
1354 
1355  uiBlock *block = arg2;
1356  /* Explicitly set UI_RETURN_OK flag, otherwise the menu might be canceled
1357  * in case WM_operator_call_ex exits/reloads the current file (T49199). */
1358 
1359  UI_popup_menu_retval_set(block, UI_RETURN_OK, true);
1360 
1361  /* Get context data *after* WM_operator_call_ex
1362  * which might have closed the current file and changed context. */
1363  wmWindow *win = CTX_wm_window(C);
1364  UI_popup_block_close(C, win, block);
1365 
1366  WM_operator_call_ex(C, op, true);
1367 }
1368 
1369 /* Dialogs are popups that require user verification (click OK) before exec */
1370 static uiBlock *wm_block_dialog_create(bContext *C, ARegion *region, void *userData)
1371 {
1372  wmOpPopUp *data = userData;
1373  wmOperator *op = data->op;
1374  const uiStyle *style = UI_style_get_dpi();
1375 
1376  uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
1379 
1380  /* intentionally don't use 'UI_BLOCK_MOVEMOUSE_QUIT', some dialogues have many items
1381  * where quitting by accident is very annoying */
1383 
1384  uiLayout *layout = UI_block_layout(
1385  block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style);
1386 
1389 
1390  /* clear so the OK button is left alone */
1391  UI_block_func_set(block, NULL, NULL, NULL);
1392 
1393  /* new column so as not to interfere with custom layouts T26436. */
1394  {
1395  uiLayout *col = uiLayoutColumn(layout, false);
1396  uiBlock *col_block = uiLayoutGetBlock(col);
1397  /* Create OK button, the callback of which will execute op */
1398  uiBut *but = uiDefBut(
1399  col_block, UI_BTYPE_BUT, 0, IFACE_("OK"), 0, -30, 0, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
1401  UI_but_func_set(but, dialog_exec_cb, data, col_block);
1402  }
1403 
1404  /* center around the mouse */
1406  block, 6 * U.dpi_fac, (const int[2]){data->width / -2, data->height / 2});
1407 
1408  return block;
1409 }
1410 
1411 static uiBlock *wm_operator_ui_create(bContext *C, ARegion *region, void *userData)
1412 {
1413  wmOpPopUp *data = userData;
1414  wmOperator *op = data->op;
1415  const uiStyle *style = UI_style_get_dpi();
1416 
1417  uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
1421 
1422  uiLayout *layout = UI_block_layout(
1423  block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style);
1424 
1425  /* since ui is defined the auto-layout args are not used */
1427 
1428  UI_block_func_set(block, NULL, NULL, NULL);
1429 
1430  UI_block_bounds_set_popup(block, 6 * U.dpi_fac, NULL);
1431 
1432  return block;
1433 }
1434 
1435 static void wm_operator_ui_popup_cancel(struct bContext *C, void *userData)
1436 {
1437  wmOpPopUp *data = userData;
1438  wmOperator *op = data->op;
1439 
1440  if (op) {
1441  if (op->type->cancel) {
1442  op->type->cancel(C, op);
1443  }
1444 
1445  if (data->free_op) {
1446  WM_operator_free(op);
1447  }
1448  }
1449 
1450  MEM_freeN(data);
1451 }
1452 
1453 static void wm_operator_ui_popup_ok(struct bContext *C, void *arg, int retval)
1454 {
1455  wmOpPopUp *data = arg;
1456  wmOperator *op = data->op;
1457 
1458  if (op && retval > 0) {
1459  WM_operator_call_ex(C, op, true);
1460  }
1461 
1462  MEM_freeN(data);
1463 }
1464 
1466 {
1467  wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_ui_popup");
1468  data->op = op;
1469  data->width = width * U.dpi_fac;
1470  /* Actual used height depends on the content. */
1471  data->height = 0;
1472  data->free_op = true; /* if this runs and gets registered we may want not to free it */
1474  return OPERATOR_RUNNING_MODAL;
1475 }
1476 
1482  wmOperator *op,
1483  const bool do_call,
1484  const bool do_redo)
1485 {
1486  if ((op->type->flag & OPTYPE_REGISTER) == 0) {
1487  BKE_reportf(op->reports,
1488  RPT_ERROR,
1489  "Operator '%s' does not have register enabled, incorrect invoke function",
1490  op->type->idname);
1491  return OPERATOR_CANCELLED;
1492  }
1493 
1494  if (do_redo) {
1495  if ((op->type->flag & OPTYPE_UNDO) == 0) {
1496  BKE_reportf(op->reports,
1497  RPT_ERROR,
1498  "Operator '%s' does not have undo enabled, incorrect invoke function",
1499  op->type->idname);
1500  return OPERATOR_CANCELLED;
1501  }
1502  }
1503 
1504  /* if we don't have global undo, we can't do undo push for automatic redo,
1505  * so we require manual OK clicking in this popup */
1506  if (!do_redo || !(U.uiflag & USER_GLOBALUNDO)) {
1507  return WM_operator_props_dialog_popup(C, op, 300);
1508  }
1509 
1511 
1512  if (do_call) {
1513  wm_block_redo_cb(C, op, 0);
1514  }
1515 
1516  return OPERATOR_RUNNING_MODAL;
1517 }
1518 
1524 {
1525  return wm_operator_props_popup_ex(C, op, false, false);
1526 }
1527 
1534 {
1535  return wm_operator_props_popup_ex(C, op, true, true);
1536 }
1537 
1539 {
1540  return wm_operator_props_popup_ex(C, op, false, true);
1541 }
1542 
1544 {
1545  wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_props_dialog_popup");
1546 
1547  data->op = op;
1548  data->width = width * U.dpi_fac;
1549  /* Actual height depends on the content. */
1550  data->height = 0;
1551  data->free_op = true; /* if this runs and gets registered we may want not to free it */
1552 
1553  /* op is not executed until popup OK but is clicked */
1556 
1557  return OPERATOR_RUNNING_MODAL;
1558 }
1559 
1561 {
1562  /* CTX_wm_reports(C) because operator is on stack, not active in event system */
1563  if ((op->type->flag & OPTYPE_REGISTER) == 0) {
1565  RPT_ERROR,
1566  "Operator redo '%s' does not have register enabled, incorrect invoke function",
1567  op->type->idname);
1568  return OPERATOR_CANCELLED;
1569  }
1570  if (op->type->poll && op->type->poll(C) == 0) {
1571  BKE_reportf(
1572  CTX_wm_reports(C), RPT_ERROR, "Operator redo '%s': wrong context", op->type->idname);
1573  return OPERATOR_CANCELLED;
1574  }
1575 
1577 
1578  return OPERATOR_CANCELLED;
1579 }
1580 
1583 /* -------------------------------------------------------------------- */
1590 {
1591  G.debug_value = RNA_int_get(op->ptr, "debug_value");
1594 
1595  return OPERATOR_FINISHED;
1596 }
1597 
1598 static int wm_debug_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
1599 {
1600  RNA_int_set(op->ptr, "debug_value", G.debug_value);
1601  return WM_operator_props_dialog_popup(C, op, 250);
1602 }
1603 
1605 {
1606  ot->name = "Debug Menu";
1607  ot->idname = "WM_OT_debug_menu";
1608  ot->description = "Open a popup to set the debug level";
1609 
1613 
1614  RNA_def_int(ot->srna, "debug_value", 0, SHRT_MIN, SHRT_MAX, "Debug Value", "", -10000, 10000);
1615 }
1616 
1619 /* -------------------------------------------------------------------- */
1624 {
1625  PointerRNA ptr = CTX_data_pointer_get_type(C, "active_operator", &RNA_Operator);
1626 
1627  if (!ptr.data) {
1628  BKE_report(op->reports, RPT_ERROR, "No operator in context");
1629  return OPERATOR_CANCELLED;
1630  }
1631 
1633  return OPERATOR_FINISHED;
1634 }
1635 
1636 /* used by operator preset menu. pre-2.65 this was a 'Reset' button */
1638 {
1639  ot->name = "Restore Operator Defaults";
1640  ot->idname = "WM_OT_operator_defaults";
1641  ot->description = "Set the active operator to its default values";
1642 
1644 
1645  ot->flag = OPTYPE_INTERNAL;
1646 }
1647 
1650 /* -------------------------------------------------------------------- */
1655  enum {
1659 
1660  int size[2];
1661 };
1662 
1663 static uiBlock *wm_block_search_menu(bContext *C, ARegion *region, void *userdata)
1664 {
1665  const struct SearchPopupInit_Data *init_data = userdata;
1666  static char search[256] = "";
1667 
1668  uiBlock *block = UI_block_begin(C, region, "_popup", UI_EMBOSS);
1671 
1672  uiBut *but = uiDefSearchBut(block,
1673  search,
1674  0,
1675  ICON_VIEWZOOM,
1676  sizeof(search),
1677  10,
1678  10,
1679  init_data->size[0],
1680  UI_UNIT_Y,
1681  0,
1682  0,
1683  "");
1684 
1685  if (init_data->search_type == SEARCH_TYPE_OPERATOR) {
1687  }
1688  else if (init_data->search_type == SEARCH_TYPE_MENU) {
1690  }
1691  else {
1693  }
1694 
1696 
1697  /* fake button, it holds space for search items */
1698  uiDefBut(block,
1700  0,
1701  "",
1702  10,
1703  10 - init_data->size[1],
1704  init_data->size[0],
1705  init_data->size[1],
1706  NULL,
1707  0,
1708  0,
1709  0,
1710  0,
1711  NULL);
1712 
1713  /* Move it downwards, mouse over button. */
1714  UI_block_bounds_set_popup(block, 0.3f * U.widget_unit, (const int[2]){0, -UI_UNIT_Y});
1715 
1716  return block;
1717 }
1718 
1720 {
1721  return OPERATOR_FINISHED;
1722 }
1723 
1724 static int wm_search_menu_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1725 {
1726  /* Exception for launching via spacebar */
1727  if (event->type == EVT_SPACEKEY) {
1728  bool ok = true;
1729  ScrArea *area = CTX_wm_area(C);
1730  if (area) {
1731  if (area->spacetype == SPACE_CONSOLE) {
1732  /* So we can use the shortcut in the console. */
1733  ok = false;
1734  }
1735  else if (area->spacetype == SPACE_TEXT) {
1736  /* So we can use the spacebar in the text editor. */
1737  ok = false;
1738  }
1739  }
1740  else {
1741  Object *editob = CTX_data_edit_object(C);
1742  if (editob && editob->type == OB_FONT) {
1743  /* So we can use the spacebar for entering text. */
1744  ok = false;
1745  }
1746  }
1747  if (!ok) {
1748  return OPERATOR_PASS_THROUGH;
1749  }
1750  }
1751 
1752  int search_type;
1753  if (STREQ(op->type->idname, "WM_OT_search_menu")) {
1755  }
1756  else {
1758  }
1759 
1760  static struct SearchPopupInit_Data data;
1761  data = (struct SearchPopupInit_Data){
1762  .search_type = search_type,
1763  .size = {UI_searchbox_size_x() * 2, UI_searchbox_size_y()},
1764  };
1765 
1767 
1768  return OPERATOR_INTERFACE;
1769 }
1770 
1772 {
1773  ot->name = "Search Menu";
1774  ot->idname = "WM_OT_search_menu";
1775  ot->description = "Pop-up a search over all menus in the current context";
1776 
1780 }
1781 
1783 {
1784  ot->name = "Search Operator";
1785  ot->idname = "WM_OT_search_operator";
1786  ot->description = "Pop-up a search over all available operators in current context";
1787 
1791 }
1792 
1794 {
1795  char idname[BKE_ST_MAXNAME];
1796  RNA_string_get(op->ptr, "name", idname);
1797 
1798  return UI_popup_menu_invoke(C, idname, op->reports);
1799 }
1800 
1802 {
1803  char idname[BKE_ST_MAXNAME];
1804  RNA_string_get(ptr, "name", idname);
1805  MenuType *mt = WM_menutype_find(idname, true);
1806  return (mt) ? CTX_IFACE_(mt->translation_context, mt->label) :
1808 }
1809 
1811 {
1812  ot->name = "Call Menu";
1813  ot->idname = "WM_OT_call_menu";
1814  ot->description = "Open a predefined menu";
1815 
1819 
1820  ot->flag = OPTYPE_INTERNAL;
1821 
1822  RNA_def_string(ot->srna, "name", NULL, BKE_ST_MAXNAME, "Name", "Name of the menu");
1823 }
1824 
1825 static int wm_call_pie_menu_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1826 {
1827  char idname[BKE_ST_MAXNAME];
1828  RNA_string_get(op->ptr, "name", idname);
1829 
1830  return UI_pie_menu_invoke(C, idname, event);
1831 }
1832 
1834 {
1835  char idname[BKE_ST_MAXNAME];
1836  RNA_string_get(op->ptr, "name", idname);
1837 
1838  return UI_pie_menu_invoke(C, idname, CTX_wm_window(C)->eventstate);
1839 }
1840 
1842 {
1843  ot->name = "Call Pie Menu";
1844  ot->idname = "WM_OT_call_menu_pie";
1845  ot->description = "Open a predefined pie menu";
1846 
1851 
1852  ot->flag = OPTYPE_INTERNAL;
1853 
1854  RNA_def_string(ot->srna, "name", NULL, BKE_ST_MAXNAME, "Name", "Name of the pie menu");
1855 }
1856 
1858 {
1859  char idname[BKE_ST_MAXNAME];
1860  RNA_string_get(op->ptr, "name", idname);
1861  const bool keep_open = RNA_boolean_get(op->ptr, "keep_open");
1862 
1863  return UI_popover_panel_invoke(C, idname, keep_open, op->reports);
1864 }
1865 
1867 {
1868  char idname[BKE_ST_MAXNAME];
1869  RNA_string_get(ptr, "name", idname);
1870  PanelType *pt = WM_paneltype_find(idname, true);
1871  return (pt) ? CTX_IFACE_(pt->translation_context, pt->label) :
1873 }
1874 
1876 {
1877  ot->name = "Call Panel";
1878  ot->idname = "WM_OT_call_panel";
1879  ot->description = "Open a predefined panel";
1880 
1884 
1885  ot->flag = OPTYPE_INTERNAL;
1886 
1887  PropertyRNA *prop;
1888 
1889  prop = RNA_def_string(ot->srna, "name", NULL, BKE_ST_MAXNAME, "Name", "Name of the menu");
1891  prop = RNA_def_boolean(ot->srna, "keep_open", true, "Keep Open", "");
1893 }
1894 
1897 /* -------------------------------------------------------------------- */
1901 /* this poll functions is needed in place of WM_operator_winactive
1902  * while it crashes on full screen */
1904 {
1905  wmWindow *win = CTX_wm_window(C);
1906  bScreen *screen;
1907 
1908  if (win == NULL) {
1909  return 0;
1910  }
1911  if (!((screen = WM_window_get_active_screen(win)) && (screen->state == SCREENNORMAL))) {
1912  return 0;
1913  }
1914  if (G.background) {
1915  return 0;
1916  }
1917 
1918  return 1;
1919 }
1920 
1921 /* included for script-access */
1923 {
1924  ot->name = "Close Window";
1925  ot->idname = "WM_OT_window_close";
1926  ot->description = "Close the current window";
1927 
1930 }
1931 
1933 {
1934  ot->name = "New Window";
1935  ot->idname = "WM_OT_window_new";
1936  ot->description = "Create a new window";
1937 
1940 }
1941 
1943 {
1944  ot->name = "New Main Window";
1945  ot->idname = "WM_OT_window_new_main";
1946  ot->description = "Create a new main window with its own workspace and scene selection";
1947 
1950 }
1951 
1953 {
1954  ot->name = "Toggle Window Fullscreen";
1955  ot->idname = "WM_OT_window_fullscreen_toggle";
1956  ot->description = "Toggle the current window fullscreen";
1957 
1960 }
1961 
1963 {
1965  return OPERATOR_FINISHED;
1966 }
1967 
1969  wmOperator *UNUSED(op),
1970  const wmEvent *UNUSED(event))
1971 {
1972  if (U.uiflag & USER_SAVE_PROMPT) {
1974  }
1975  else {
1977  }
1978  return OPERATOR_FINISHED;
1979 }
1980 
1982 {
1983  ot->name = "Quit Blender";
1984  ot->idname = "WM_OT_quit_blender";
1985  ot->description = "Quit Blender";
1986 
1989 }
1990 
1993 /* -------------------------------------------------------------------- */
1997 #if defined(WIN32)
1998 
1999 static int wm_console_toggle_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
2000 {
2002  return OPERATOR_FINISHED;
2003 }
2004 
2005 static void WM_OT_console_toggle(wmOperatorType *ot)
2006 {
2007  /* XXX Have to mark these for xgettext, as under linux they do not exists... */
2008  ot->name = CTX_N_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Toggle System Console");
2009  ot->idname = "WM_OT_console_toggle";
2010  ot->description = N_("Toggle System Console");
2011 
2012  ot->exec = wm_console_toggle_exec;
2014 }
2015 
2016 #endif
2017 
2020 /* -------------------------------------------------------------------- */
2030  short region_type,
2031  bool (*poll)(bContext *C),
2032  wmPaintCursorDraw draw,
2033  void *customdata)
2034 {
2035  wmWindowManager *wm = G_MAIN->wm.first;
2036 
2037  wmPaintCursor *pc = MEM_callocN(sizeof(wmPaintCursor), "paint cursor");
2038 
2039  BLI_addtail(&wm->paintcursors, pc);
2040 
2041  pc->customdata = customdata;
2042  pc->poll = poll;
2043  pc->draw = draw;
2044 
2045  pc->space_type = space_type;
2046  pc->region_type = region_type;
2047 
2048  return pc;
2049 }
2050 
2052 {
2053  wmWindowManager *wm = G_MAIN->wm.first;
2055  if (pc == (wmPaintCursor *)handle) {
2056  BLI_remlink(&wm->paintcursors, pc);
2057  MEM_freeN(pc);
2058  return true;
2059  }
2060  }
2061  return false;
2062 }
2063 
2064 void WM_paint_cursor_remove_by_type(wmWindowManager *wm, void *draw_fn, void (*free)(void *))
2065 {
2067  if (pc->draw == draw_fn) {
2068  if (free) {
2069  free(pc->customdata);
2070  }
2071  BLI_remlink(&wm->paintcursors, pc);
2072  MEM_freeN(pc);
2073  }
2074  }
2075 }
2076 
2079 /* -------------------------------------------------------------------- */
2083 #define WM_RADIAL_CONTROL_DISPLAY_SIZE (200 * UI_DPI_FAC)
2084 #define WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE (35 * UI_DPI_FAC)
2085 #define WM_RADIAL_CONTROL_DISPLAY_WIDTH \
2086  (WM_RADIAL_CONTROL_DISPLAY_SIZE - WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE)
2087 #define WM_RADIAL_MAX_STR 10
2088 
2089 typedef struct {
2092  PointerRNA ptr, col_ptr, fill_col_ptr, rot_ptr, zoom_ptr, image_id_ptr;
2093  PointerRNA fill_col_override_ptr, fill_col_override_test_ptr;
2094  PropertyRNA *prop, *col_prop, *fill_col_prop, *rot_prop, *zoom_prop;
2095  PropertyRNA *fill_col_override_prop, *fill_col_override_test_prop;
2097  float initial_value, current_value, min_value, max_value;
2098  int initial_mouse[2];
2099  int initial_co[2];
2100  int slow_mouse[2];
2106  void *cursor;
2109 } RadialControl;
2110 
2112 {
2113  RadialControl *rc = op->customdata;
2114  char msg[UI_MAX_DRAW_STR];
2115  ScrArea *area = CTX_wm_area(C);
2117 
2118  if (hasNumInput(&rc->num_input)) {
2119  char num_str[NUM_STR_REP_LEN];
2120  outputNumInput(&rc->num_input, num_str, &scene->unit);
2121  BLI_snprintf(msg, sizeof(msg), "%s: %s", RNA_property_ui_name(rc->prop), num_str);
2122  }
2123  else {
2124  const char *ui_name = RNA_property_ui_name(rc->prop);
2125  switch (rc->subtype) {
2126  case PROP_NONE:
2127  case PROP_DISTANCE:
2128  BLI_snprintf(msg, sizeof(msg), "%s: %0.4f", ui_name, rc->current_value);
2129  break;
2130  case PROP_PIXEL:
2131  BLI_snprintf(msg,
2132  sizeof(msg),
2133  "%s: %d",
2134  ui_name,
2135  (int)rc->current_value); /* XXX: round to nearest? */
2136  break;
2137  case PROP_PERCENTAGE:
2138  BLI_snprintf(msg, sizeof(msg), "%s: %3.1f%%", ui_name, rc->current_value);
2139  break;
2140  case PROP_FACTOR:
2141  BLI_snprintf(msg, sizeof(msg), "%s: %1.3f", ui_name, rc->current_value);
2142  break;
2143  case PROP_ANGLE:
2144  BLI_snprintf(msg, sizeof(msg), "%s: %3.2f", ui_name, RAD2DEGF(rc->current_value));
2145  break;
2146  default:
2147  BLI_snprintf(msg, sizeof(msg), "%s", ui_name); /* XXX: No value? */
2148  break;
2149  }
2150  }
2151 
2152  ED_area_status_text(area, msg);
2153 }
2154 
2156 {
2157  float d[2] = {0, 0};
2158  float zoom[2] = {1, 1};
2159 
2160  rc->initial_mouse[0] = event->x;
2161  rc->initial_mouse[1] = event->y;
2162 
2163  rc->initial_co[0] = event->x;
2164  rc->initial_co[1] = event->y;
2165 
2166  switch (rc->subtype) {
2167  case PROP_NONE:
2168  case PROP_DISTANCE:
2169  case PROP_PIXEL:
2170  d[0] = rc->initial_value;
2171  break;
2172  case PROP_PERCENTAGE:
2173  d[0] = (rc->initial_value) / 100.0f * WM_RADIAL_CONTROL_DISPLAY_WIDTH +
2175  break;
2176  case PROP_FACTOR:
2179  break;
2180  case PROP_ANGLE:
2183  break;
2184  default:
2185  return;
2186  }
2187 
2188  if (rc->zoom_prop) {
2190  d[0] *= zoom[0];
2191  d[1] *= zoom[1];
2192  }
2193 
2194  rc->initial_mouse[0] -= d[0];
2195  rc->initial_mouse[1] -= d[1];
2196 }
2197 
2199 {
2200  ImBuf *ibuf;
2201 
2202  switch (RNA_type_to_ID_code(rc->image_id_ptr.type)) {
2203  case ID_BR:
2205  rc->image_id_ptr.data,
2206  rc->use_secondary_tex,
2208 
2210  "radial_control", ibuf->x, ibuf->y, 1, GPU_R8, ibuf->rect_float);
2211 
2212  GPU_texture_filter_mode(rc->texture, true);
2213  GPU_texture_swizzle_set(rc->texture, "111r");
2214 
2215  MEM_freeN(ibuf->rect_float);
2216  MEM_freeN(ibuf);
2217  }
2218  break;
2219  default:
2220  break;
2221  }
2222 }
2223 
2224 static void radial_control_paint_tex(RadialControl *rc, float radius, float alpha)
2225 {
2226 
2227  /* set fill color */
2228  float col[3] = {0, 0, 0};
2229  if (rc->fill_col_prop) {
2230  PointerRNA *fill_ptr;
2231  PropertyRNA *fill_prop;
2232 
2235  fill_ptr = &rc->fill_col_override_ptr;
2236  fill_prop = rc->fill_col_override_prop;
2237  }
2238  else {
2239  fill_ptr = &rc->fill_col_ptr;
2240  fill_prop = rc->fill_col_prop;
2241  }
2242 
2243  RNA_property_float_get_array(fill_ptr, fill_prop, col);
2244  }
2245 
2248 
2249  if (rc->texture) {
2250  uint texCoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
2251 
2252  /* set up rotation if available */
2253  if (rc->rot_prop) {
2254  float rot = RNA_property_float_get(&rc->rot_ptr, rc->rot_prop);
2255  GPU_matrix_push();
2257  }
2258 
2260 
2262  immBindTexture("image", rc->texture);
2263 
2264  /* draw textured quad */
2266 
2267  immAttr2f(texCoord, 0, 0);
2268  immVertex2f(pos, -radius, -radius);
2269 
2270  immAttr2f(texCoord, 1, 0);
2271  immVertex2f(pos, radius, -radius);
2272 
2273  immAttr2f(texCoord, 1, 1);
2274  immVertex2f(pos, radius, radius);
2275 
2276  immAttr2f(texCoord, 0, 1);
2277  immVertex2f(pos, -radius, radius);
2278 
2279  immEnd();
2280 
2282 
2283  /* undo rotation */
2284  if (rc->rot_prop) {
2285  GPU_matrix_pop();
2286  }
2287  }
2288  else {
2289  /* flat color if no texture available */
2292  imm_draw_circle_fill_2d(pos, 0.0f, 0.0f, radius, 40);
2293  }
2294 
2295  immUnbindProgram();
2296 }
2297 
2298 static void radial_control_paint_curve(uint pos, Brush *br, float radius, int line_segments)
2299 {
2300  GPU_line_width(2.0f);
2301  immUniformColor4f(0.8f, 0.8f, 0.8f, 0.85f);
2302  float step = (radius * 2.0f) / (float)line_segments;
2304  immBegin(GPU_PRIM_LINES, line_segments * 2);
2305  for (int i = 0; i < line_segments; i++) {
2306  float h1 = BKE_brush_curve_strength_clamped(br, fabsf((i * step) - radius), radius);
2307  immVertex2f(pos, -radius + (i * step), h1 * radius);
2308  float h2 = BKE_brush_curve_strength_clamped(br, fabsf(((i + 1) * step) - radius), radius);
2309  immVertex2f(pos, -radius + ((i + 1) * step), h2 * radius);
2310  }
2311  immEnd();
2312 }
2313 
2314 static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void *customdata)
2315 {
2316  RadialControl *rc = customdata;
2317  const uiStyle *style = UI_style_get();
2318  const uiFontStyle *fstyle = &style->widget;
2319  const int fontid = fstyle->uifont_id;
2320  short fstyle_points = fstyle->points;
2321  char str[WM_RADIAL_MAX_STR];
2322  short strdrawlen = 0;
2323  float strwidth, strheight;
2324  float r1 = 0.0f, r2 = 0.0f, rmin = 0.0, tex_radius, alpha;
2325  float zoom[2], col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
2326  float text_color[4];
2327 
2328  switch (rc->subtype) {
2329  case PROP_NONE:
2330  case PROP_DISTANCE:
2331  case PROP_PIXEL:
2332  r1 = rc->current_value;
2333  r2 = rc->initial_value;
2334  tex_radius = r1;
2335  alpha = 0.75;
2336  break;
2337  case PROP_PERCENTAGE:
2338  r1 = rc->current_value / 100.0f * WM_RADIAL_CONTROL_DISPLAY_WIDTH +
2340  r2 = tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE;
2342  BLI_snprintf(str, WM_RADIAL_MAX_STR, "%3.1f%%", rc->current_value);
2343  strdrawlen = BLI_strlen_utf8(str);
2344  tex_radius = r1;
2345  alpha = 0.75;
2346  break;
2347  case PROP_FACTOR:
2350  r2 = tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE;
2352  alpha = rc->current_value / 2.0f + 0.5f;
2354  strdrawlen = BLI_strlen_utf8(str);
2355  break;
2356  case PROP_ANGLE:
2357  r1 = r2 = tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE;
2358  alpha = 0.75;
2361  strdrawlen = BLI_strlen_utf8(str);
2362  break;
2363  default:
2364  tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE; /* note, this is a dummy value */
2365  alpha = 0.75;
2366  break;
2367  }
2368 
2369  if (rc->subtype == PROP_ANGLE) {
2370  /* Use the initial mouse position to draw the rotation preview. This avoids starting the
2371  * rotation in a random direction */
2372  x = rc->initial_mouse[0];
2373  y = rc->initial_mouse[1];
2374  }
2375  else {
2376  /* Keep cursor in the original place */
2377  x = rc->initial_co[0];
2378  y = rc->initial_co[1];
2379  }
2380  GPU_matrix_translate_2f((float)x, (float)y);
2381 
2383  GPU_line_smooth(true);
2384 
2385  /* apply zoom if available */
2386  if (rc->zoom_prop) {
2388  GPU_matrix_scale_2fv(zoom);
2389  }
2390 
2391  /* draw rotated texture */
2392  radial_control_paint_tex(rc, tex_radius, alpha);
2393 
2394  /* set line color */
2395  if (rc->col_prop) {
2397  }
2398 
2401 
2403 
2404  if (rc->subtype == PROP_ANGLE) {
2405  GPU_matrix_push();
2406 
2407  /* draw original angle line */
2408  GPU_matrix_rotate_3f(RAD2DEGF(rc->initial_value), 0.0f, 0.0f, 1.0f);
2412  immEnd();
2413 
2414  /* draw new angle line */
2415  GPU_matrix_rotate_3f(RAD2DEGF(rc->current_value - rc->initial_value), 0.0f, 0.0f, 1.0f);
2419  immEnd();
2420 
2421  GPU_matrix_pop();
2422  }
2423 
2424  /* draw circles on top */
2425  GPU_line_width(2.0f);
2427  imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, r1, 80);
2428 
2429  GPU_line_width(1.0f);
2431  imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, r2, 80);
2432  if (rmin > 0.0f) {
2433  /* Inner fill circle to increase the contrast of the value */
2434  const float black[3] = {0.0f};
2435  immUniformColor3fvAlpha(black, 0.2f);
2436  imm_draw_circle_fill_2d(pos, 0.0, 0.0f, rmin, 80);
2437 
2439  imm_draw_circle_wire_2d(pos, 0.0, 0.0f, rmin, 80);
2440  }
2441 
2442  /* draw curve falloff preview */
2444  Brush *br = rc->image_id_ptr.data;
2445  if (br) {
2446  radial_control_paint_curve(pos, br, r2, 120);
2447  }
2448  }
2449 
2450  immUnbindProgram();
2451 
2452  BLF_size(fontid, 1.75f * fstyle_points * U.pixelsize, U.dpi);
2453  UI_GetThemeColor4fv(TH_TEXT_HI, text_color);
2454  BLF_color4fv(fontid, text_color);
2455 
2456  /* draw value */
2457  BLF_width_and_height(fontid, str, strdrawlen, &strwidth, &strheight);
2458  BLF_position(fontid, -0.5f * strwidth, -0.5f * strheight, 0.0f);
2459  BLF_draw(fontid, str, strdrawlen);
2460 
2462  GPU_line_smooth(false);
2463 }
2464 
2465 typedef enum {
2469 } RCPropFlags;
2470 
2477  wmOperator *op,
2478  const char *name,
2479  PointerRNA *r_ptr,
2480  PropertyRNA **r_prop,
2481  int req_length,
2482  RCPropFlags flags)
2483 {
2484  PropertyRNA *unused_prop;
2485 
2486  /* check flags */
2487  if ((flags & RC_PROP_REQUIRE_BOOL) && (flags & RC_PROP_REQUIRE_FLOAT)) {
2488  BKE_report(op->reports, RPT_ERROR, "Property cannot be both boolean and float");
2489  return 0;
2490  }
2491 
2492  /* get an rna string path from the operator's properties */
2493  char *str;
2494  if (!(str = RNA_string_get_alloc(op->ptr, name, NULL, 0))) {
2495  return 1;
2496  }
2497 
2498  if (str[0] == '\0') {
2499  if (r_prop) {
2500  *r_prop = NULL;
2501  }
2502  MEM_freeN(str);
2503  return 1;
2504  }
2505 
2506  if (!r_prop) {
2507  r_prop = &unused_prop;
2508  }
2509 
2510  /* get rna from path */
2511  if (!RNA_path_resolve(ctx_ptr, str, r_ptr, r_prop)) {
2512  MEM_freeN(str);
2513  if (flags & RC_PROP_ALLOW_MISSING) {
2514  return 1;
2515  }
2516  BKE_reportf(op->reports, RPT_ERROR, "Could not resolve path '%s'", name);
2517  return 0;
2518  }
2519 
2520  /* check property type */
2521  if (flags & (RC_PROP_REQUIRE_BOOL | RC_PROP_REQUIRE_FLOAT)) {
2522  PropertyType prop_type = RNA_property_type(*r_prop);
2523 
2524  if (((flags & RC_PROP_REQUIRE_BOOL) && (prop_type != PROP_BOOLEAN)) ||
2525  ((flags & RC_PROP_REQUIRE_FLOAT) && (prop_type != PROP_FLOAT))) {
2526  MEM_freeN(str);
2527  BKE_reportf(op->reports, RPT_ERROR, "Property from path '%s' is not a float", name);
2528  return 0;
2529  }
2530  }
2531 
2532  /* check property's array length */
2533  int len;
2534  if (*r_prop && (len = RNA_property_array_length(r_ptr, *r_prop)) != req_length) {
2535  MEM_freeN(str);
2536  BKE_reportf(op->reports,
2537  RPT_ERROR,
2538  "Property from path '%s' has length %d instead of %d",
2539  name,
2540  len,
2541  req_length);
2542  return 0;
2543  }
2544 
2545  /* success */
2546  MEM_freeN(str);
2547  return 1;
2548 }
2549 
2550 /* initialize the rna pointers and properties using rna paths */
2552 {
2553  RadialControl *rc = op->customdata;
2554 
2555  PointerRNA ctx_ptr;
2556  RNA_pointer_create(NULL, &RNA_Context, C, &ctx_ptr);
2557 
2558  /* check if we use primary or secondary path */
2559  PointerRNA use_secondary_ptr;
2560  PropertyRNA *use_secondary_prop = NULL;
2561  if (!radial_control_get_path(&ctx_ptr,
2562  op,
2563  "use_secondary",
2564  &use_secondary_ptr,
2565  &use_secondary_prop,
2566  0,
2568  return 0;
2569  }
2570 
2571  const char *data_path;
2572  if (use_secondary_prop && RNA_property_boolean_get(&use_secondary_ptr, use_secondary_prop)) {
2573  data_path = "data_path_secondary";
2574  }
2575  else {
2576  data_path = "data_path_primary";
2577  }
2578 
2579  if (!radial_control_get_path(&ctx_ptr, op, data_path, &rc->ptr, &rc->prop, 0, 0)) {
2580  return 0;
2581  }
2582 
2583  /* data path is required */
2584  if (!rc->prop) {
2585  return 0;
2586  }
2587 
2589  &ctx_ptr, op, "rotation_path", &rc->rot_ptr, &rc->rot_prop, 0, RC_PROP_REQUIRE_FLOAT)) {
2590  return 0;
2591  }
2592 
2594  &ctx_ptr, op, "color_path", &rc->col_ptr, &rc->col_prop, 4, RC_PROP_REQUIRE_FLOAT)) {
2595  return 0;
2596  }
2597 
2598  if (!radial_control_get_path(&ctx_ptr,
2599  op,
2600  "fill_color_path",
2601  &rc->fill_col_ptr,
2602  &rc->fill_col_prop,
2603  3,
2605  return 0;
2606  }
2607 
2608  if (!radial_control_get_path(&ctx_ptr,
2609  op,
2610  "fill_color_override_path",
2611  &rc->fill_col_override_ptr,
2613  3,
2615  return 0;
2616  }
2617  if (!radial_control_get_path(&ctx_ptr,
2618  op,
2619  "fill_color_override_test_path",
2622  0,
2624  return 0;
2625  }
2626 
2627  /* slightly ugly; allow this property to not resolve
2628  * correctly. needed because 3d texture paint shares the same
2629  * keymap as 2d image paint */
2630  if (!radial_control_get_path(&ctx_ptr,
2631  op,
2632  "zoom_path",
2633  &rc->zoom_ptr,
2634  &rc->zoom_prop,
2635  2,
2637  return 0;
2638  }
2639 
2640  if (!radial_control_get_path(&ctx_ptr, op, "image_id", &rc->image_id_ptr, NULL, 0, 0)) {
2641  return 0;
2642  }
2643  if (rc->image_id_ptr.data) {
2644  /* extra check, pointer must be to an ID */
2645  if (!RNA_struct_is_ID(rc->image_id_ptr.type)) {
2646  BKE_report(op->reports, RPT_ERROR, "Pointer from path image_id is not an ID");
2647  return 0;
2648  }
2649  }
2650 
2651  rc->use_secondary_tex = RNA_boolean_get(op->ptr, "secondary_tex");
2652 
2653  return 1;
2654 }
2655 
2656 static int radial_control_invoke(bContext *C, wmOperator *op, const wmEvent *event)
2657 {
2658  wmWindowManager *wm;
2659  RadialControl *rc;
2660 
2661  if (!(op->customdata = rc = MEM_callocN(sizeof(RadialControl), "RadialControl"))) {
2662  return OPERATOR_CANCELLED;
2663  }
2664 
2665  if (!radial_control_get_properties(C, op)) {
2666  MEM_freeN(rc);
2667  return OPERATOR_CANCELLED;
2668  }
2669 
2670  /* get type, initial, min, and max values of the property */
2671  switch ((rc->type = RNA_property_type(rc->prop))) {
2672  case PROP_INT: {
2673  int value, min, max, step;
2674 
2675  value = RNA_property_int_get(&rc->ptr, rc->prop);
2676  RNA_property_int_ui_range(&rc->ptr, rc->prop, &min, &max, &step);
2677 
2678  rc->initial_value = value;
2679  rc->min_value = min_ii(value, min);
2680  rc->max_value = max_ii(value, max);
2681  break;
2682  }
2683  case PROP_FLOAT: {
2684  float value, min, max, step, precision;
2685 
2686  value = RNA_property_float_get(&rc->ptr, rc->prop);
2687  RNA_property_float_ui_range(&rc->ptr, rc->prop, &min, &max, &step, &precision);
2688 
2689  rc->initial_value = value;
2690  rc->min_value = min_ff(value, min);
2691  rc->max_value = max_ff(value, max);
2692  break;
2693  }
2694  default:
2695  BKE_report(op->reports, RPT_ERROR, "Property must be an integer or a float");
2696  MEM_freeN(rc);
2697  return OPERATOR_CANCELLED;
2698  }
2699 
2700  /* initialize numerical input */
2701  initNumInput(&rc->num_input);
2702  rc->num_input.idx_max = 0;
2706 
2707  /* get subtype of property */
2708  rc->subtype = RNA_property_subtype(rc->prop);
2709  if (!ELEM(rc->subtype,
2710  PROP_NONE,
2711  PROP_DISTANCE,
2712  PROP_FACTOR,
2714  PROP_ANGLE,
2715  PROP_PIXEL)) {
2716  BKE_report(op->reports,
2717  RPT_ERROR,
2718  "Property must be a none, distance, factor, percentage, angle, or pixel");
2719  MEM_freeN(rc);
2720  return OPERATOR_CANCELLED;
2721  }
2722 
2723  rc->current_value = rc->initial_value;
2726 
2728 
2729  /* temporarily disable other paint cursors */
2730  wm = CTX_wm_manager(C);
2731  rc->orig_paintcursors = wm->paintcursors;
2733 
2734  /* add radial control paint cursor */
2737 
2739 
2740  return OPERATOR_RUNNING_MODAL;
2741 }
2742 
2743 static void radial_control_set_value(RadialControl *rc, float val)
2744 {
2745  switch (rc->type) {
2746  case PROP_INT:
2747  RNA_property_int_set(&rc->ptr, rc->prop, val);
2748  break;
2749  case PROP_FLOAT:
2750  RNA_property_float_set(&rc->ptr, rc->prop, val);
2751  break;
2752  default:
2753  break;
2754  }
2755 }
2756 
2758 {
2759  RadialControl *rc = op->customdata;
2761  ScrArea *area = CTX_wm_area(C);
2762 
2763  if (rc->dial) {
2764  MEM_freeN(rc->dial);
2765  rc->dial = NULL;
2766  }
2767 
2769 
2771 
2772  /* restore original paint cursors */
2773  wm->paintcursors = rc->orig_paintcursors;
2774 
2775  /* not sure if this is a good notifier to use;
2776  * intended purpose is to update the UI so that the
2777  * new value is displayed in sliders/numfields */
2779 
2780  if (rc->texture != NULL) {
2782  }
2783 
2784  MEM_freeN(rc);
2785 }
2786 
2787 static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *event)
2788 {
2789  RadialControl *rc = op->customdata;
2790  float new_value, dist = 0.0f, zoom[2];
2791  float delta[2];
2793  float angle_precision = 0.0f;
2794  const bool has_numInput = hasNumInput(&rc->num_input);
2795  bool handled = false;
2796  float numValue;
2797  /* TODO: fix hardcoded events */
2798 
2799  bool snap = event->ctrl != 0;
2800 
2801  /* Modal numinput active, try to handle numeric inputs first... */
2802  if (event->val == KM_PRESS && has_numInput && handleNumInput(C, &rc->num_input, event)) {
2803  handled = true;
2804  applyNumInput(&rc->num_input, &numValue);
2805 
2806  if (rc->subtype == PROP_ANGLE) {
2807  numValue = fmod(numValue, 2.0f * (float)M_PI);
2808  if (numValue < 0.0f) {
2809  numValue += 2.0f * (float)M_PI;
2810  }
2811  }
2812 
2813  CLAMP(numValue, rc->min_value, rc->max_value);
2814  new_value = numValue;
2815 
2816  radial_control_set_value(rc, new_value);
2817  rc->current_value = new_value;
2819  return OPERATOR_RUNNING_MODAL;
2820  }
2821 
2822  handled = false;
2823  switch (event->type) {
2824  case EVT_ESCKEY:
2825  case RIGHTMOUSE:
2826  /* canceled; restore original value */
2829  break;
2830 
2831  case LEFTMOUSE:
2832  case EVT_PADENTER:
2833  case EVT_RETKEY:
2834  /* done; value already set */
2835  RNA_property_update(C, &rc->ptr, rc->prop);
2837  break;
2838 
2839  case MOUSEMOVE:
2840  if (!has_numInput) {
2841  if (rc->slow_mode) {
2842  if (rc->subtype == PROP_ANGLE) {
2843  const float position[2] = {event->x, event->y};
2844 
2845  /* calculate the initial angle here first */
2846  delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0];
2847  delta[1] = rc->initial_mouse[1] - rc->slow_mouse[1];
2848 
2849  /* precision angle gets calculated from dial and gets added later */
2850  angle_precision = -0.1f * BLI_dial_angle(rc->dial, position);
2851  }
2852  else {
2853  delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0];
2854  delta[1] = 0.0f;
2855 
2856  if (rc->zoom_prop) {
2858  delta[0] /= zoom[0];
2859  }
2860 
2861  dist = len_v2(delta);
2862 
2863  delta[0] = event->x - rc->slow_mouse[0];
2864 
2865  if (rc->zoom_prop) {
2866  delta[0] /= zoom[0];
2867  }
2868 
2869  dist = dist + 0.1f * (delta[0]);
2870  }
2871  }
2872  else {
2873  delta[0] = rc->initial_mouse[0] - event->x;
2874  delta[1] = rc->initial_mouse[1] - event->y;
2875  if (rc->zoom_prop) {
2877  delta[0] /= zoom[0];
2878  delta[1] /= zoom[1];
2879  }
2880  if (rc->subtype == PROP_ANGLE) {
2881  dist = len_v2(delta);
2882  }
2883  else {
2884  dist = clamp_f(-delta[0], 0.0f, FLT_MAX);
2885  }
2886  }
2887 
2888  /* calculate new value and apply snapping */
2889  switch (rc->subtype) {
2890  case PROP_NONE:
2891  case PROP_DISTANCE:
2892  case PROP_PIXEL:
2893  new_value = dist;
2894  if (snap) {
2895  new_value = ((int)new_value + 5) / 10 * 10;
2896  }
2897  break;
2898  case PROP_PERCENTAGE:
2899  new_value = ((dist - WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE) /
2901  100.0f;
2902  if (snap) {
2903  new_value = ((int)(new_value + 2.5f)) / 5 * 5;
2904  }
2905  break;
2906  case PROP_FACTOR:
2908  if (snap) {
2909  new_value = ((int)ceil(new_value * 10.0f) * 10.0f) / 100.0f;
2910  }
2911  /* Invert new value to increase the factor moving the mouse to the right */
2912  new_value = 1 - new_value;
2913  break;
2914  case PROP_ANGLE:
2915  new_value = atan2f(delta[1], delta[0]) + (float)M_PI + angle_precision;
2916  new_value = fmod(new_value, 2.0f * (float)M_PI);
2917  if (new_value < 0.0f) {
2918  new_value += 2.0f * (float)M_PI;
2919  }
2920  if (snap) {
2921  new_value = DEG2RADF(((int)RAD2DEGF(new_value) + 5) / 10 * 10);
2922  }
2923  break;
2924  default:
2925  new_value = dist; /* dummy value, should this ever happen? - campbell */
2926  break;
2927  }
2928 
2929  /* clamp and update */
2930  CLAMP(new_value, rc->min_value, rc->max_value);
2931  radial_control_set_value(rc, new_value);
2932  rc->current_value = new_value;
2933  handled = true;
2934  break;
2935  }
2936  break;
2937 
2938  case EVT_LEFTSHIFTKEY:
2939  case EVT_RIGHTSHIFTKEY: {
2940  if (event->val == KM_PRESS) {
2941  rc->slow_mouse[0] = event->x;
2942  rc->slow_mouse[1] = event->y;
2943  rc->slow_mode = true;
2944  if (rc->subtype == PROP_ANGLE) {
2945  const float initial_position[2] = {UNPACK2(rc->initial_mouse)};
2946  const float current_position[2] = {UNPACK2(rc->slow_mouse)};
2947  rc->dial = BLI_dial_init(initial_position, 0.0f);
2948  /* immediately set the position to get a an initial direction */
2949  BLI_dial_angle(rc->dial, current_position);
2950  }
2951  handled = true;
2952  }
2953  if (event->val == KM_RELEASE) {
2954  rc->slow_mode = false;
2955  handled = true;
2956  if (rc->dial) {
2957  MEM_freeN(rc->dial);
2958  rc->dial = NULL;
2959  }
2960  }
2961  break;
2962  }
2963  }
2964 
2965  /* Modal numinput inactive, try to handle numeric inputs last... */
2966  if (!handled && event->val == KM_PRESS && handleNumInput(C, &rc->num_input, event)) {
2967  applyNumInput(&rc->num_input, &numValue);
2968 
2969  if (rc->subtype == PROP_ANGLE) {
2970  numValue = fmod(numValue, 2.0f * (float)M_PI);
2971  if (numValue < 0.0f) {
2972  numValue += 2.0f * (float)M_PI;
2973  }
2974  }
2975 
2976  CLAMP(numValue, rc->min_value, rc->max_value);
2977  new_value = numValue;
2978 
2979  radial_control_set_value(rc, new_value);
2980 
2981  rc->current_value = new_value;
2983  return OPERATOR_RUNNING_MODAL;
2984  }
2985 
2986  if (!handled && (event->val == KM_RELEASE) && (rc->init_event == event->type) &&
2987  RNA_boolean_get(op->ptr, "release_confirm")) {
2989  }
2990 
2993 
2994  if (ret & OPERATOR_FINISHED) {
2996  if (wm->op_undo_depth == 0) {
2997  ID *id = rc->ptr.owner_id;
2999  ED_undo_push(C, op->type->name);
3000  }
3001  }
3002  }
3003 
3004  if (ret != OPERATOR_RUNNING_MODAL) {
3005  radial_control_cancel(C, op);
3006  }
3007 
3008  return ret;
3009 }
3010 
3012 {
3013  ot->name = "Radial Control";
3014  ot->idname = "WM_OT_radial_control";
3015  ot->description = "Set some size property (e.g. brush size) with mouse wheel";
3016 
3020 
3022 
3023  /* all paths relative to the context */
3024  PropertyRNA *prop;
3025  prop = RNA_def_string(ot->srna,
3026  "data_path_primary",
3027  NULL,
3028  0,
3029  "Primary Data Path",
3030  "Primary path of property to be set by the radial control");
3032 
3033  prop = RNA_def_string(ot->srna,
3034  "data_path_secondary",
3035  NULL,
3036  0,
3037  "Secondary Data Path",
3038  "Secondary path of property to be set by the radial control");
3040 
3041  prop = RNA_def_string(ot->srna,
3042  "use_secondary",
3043  NULL,
3044  0,
3045  "Use Secondary",
3046  "Path of property to select between the primary and secondary data paths");
3048 
3049  prop = RNA_def_string(ot->srna,
3050  "rotation_path",
3051  NULL,
3052  0,
3053  "Rotation Path",
3054  "Path of property used to rotate the texture display");
3056 
3057  prop = RNA_def_string(ot->srna,
3058  "color_path",
3059  NULL,
3060  0,
3061  "Color Path",
3062  "Path of property used to set the color of the control");
3064 
3065  prop = RNA_def_string(ot->srna,
3066  "fill_color_path",
3067  NULL,
3068  0,
3069  "Fill Color Path",
3070  "Path of property used to set the fill color of the control");
3072 
3073  prop = RNA_def_string(
3074  ot->srna, "fill_color_override_path", NULL, 0, "Fill Color Override Path", "");
3076  prop = RNA_def_string(
3077  ot->srna, "fill_color_override_test_path", NULL, 0, "Fill Color Override Test", "");
3079 
3080  prop = RNA_def_string(ot->srna,
3081  "zoom_path",
3082  NULL,
3083  0,
3084  "Zoom Path",
3085  "Path of property used to set the zoom level for the control");
3087 
3088  prop = RNA_def_string(ot->srna,
3089  "image_id",
3090  NULL,
3091  0,
3092  "Image ID",
3093  "Path of ID that is used to generate an image for the control");
3095 
3096  prop = RNA_def_boolean(
3097  ot->srna, "secondary_tex", false, "Secondary Texture", "Tweak brush secondary/mask texture");
3099 
3100  prop = RNA_def_boolean(
3101  ot->srna, "release_confirm", false, "Confirm On Release", "Finish operation on key release");
3103 }
3104 
3107 /* -------------------------------------------------------------------- */
3113 /* uses no type defines, fully local testing function anyway... ;) */
3114 
3116 {
3117  wmWindow *win = CTX_wm_window(C);
3118  bScreen *screen = CTX_wm_screen(C);
3119 
3121 
3122  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
3124  }
3125  wm_draw_update(C);
3126 
3127  CTX_wm_window_set(C, win); /* XXX context manipulation warning! */
3128 }
3129 
3130 enum {
3137  eRTUndo = 6,
3138 };
3139 
3141  {eRTDrawRegion, "DRAW", 0, "Draw Region", "Draw region"},
3142  {eRTDrawRegionSwap, "DRAW_SWAP", 0, "Draw Region & Swap", "Draw region and swap"},
3143  {eRTDrawWindow, "DRAW_WIN", 0, "Draw Window", "Draw window"},
3144  {eRTDrawWindowSwap, "DRAW_WIN_SWAP", 0, "Draw Window & Swap", "Draw window and swap"},
3145  {eRTAnimationStep, "ANIM_STEP", 0, "Animation Step", "Animation steps"},
3146  {eRTAnimationPlay, "ANIM_PLAY", 0, "Animation Play", "Animation playback"},
3147  {eRTUndo, "UNDO", 0, "Undo/Redo", "Undo and redo"},
3148  {0, NULL, 0, NULL, NULL},
3149 };
3150 
3152  Scene *scene,
3153  struct Depsgraph *depsgraph,
3154  wmWindow *win,
3155  ScrArea *area,
3156  ARegion *region,
3157  const int type,
3158  const int cfra)
3159 {
3160  if (type == eRTDrawRegion) {
3161  if (region) {
3162  wm_draw_region_test(C, area, region);
3163  }
3164  }
3165  else if (type == eRTDrawRegionSwap) {
3167 
3168  ED_region_tag_redraw(region);
3169  wm_draw_update(C);
3170 
3171  CTX_wm_window_set(C, win); /* XXX context manipulation warning! */
3172  }
3173  else if (type == eRTDrawWindow) {
3174  bScreen *screen = WM_window_get_active_screen(win);
3175 
3177 
3178  LISTBASE_FOREACH (ScrArea *, area_iter, &screen->areabase) {
3179  CTX_wm_area_set(C, area_iter);
3180  LISTBASE_FOREACH (ARegion *, region_iter, &area_iter->regionbase) {
3181  if (region_iter->visible) {
3182  CTX_wm_region_set(C, region_iter);
3183  wm_draw_region_test(C, area_iter, region_iter);
3184  }
3185  }
3186  }
3187 
3188  CTX_wm_window_set(C, win); /* XXX context manipulation warning! */
3189 
3191  CTX_wm_region_set(C, region);
3192  }
3193  else if (type == eRTDrawWindowSwap) {
3195  }
3196  else if (type == eRTAnimationStep) {
3197  scene->r.cfra += (cfra == scene->r.cfra) ? 1 : -1;
3199  }
3200  else if (type == eRTAnimationPlay) {
3201  /* play anim, return on same frame as started with */
3202  int tot = (scene->r.efra - scene->r.sfra) + 1;
3203 
3204  while (tot--) {
3205  /* todo, ability to escape! */
3206  scene->r.cfra++;
3207  if (scene->r.cfra > scene->r.efra) {
3208  scene->r.cfra = scene->r.sfra;
3209  }
3210 
3213  }
3214  }
3215  else { /* eRTUndo */
3216  /* Undo and redo, including depsgraph update since that can be a
3217  * significant part of the cost. */
3218  ED_undo_pop(C);
3220  ED_undo_redo(C);
3222  }
3223 }
3224 
3226 {
3228  wmWindow *win = CTX_wm_window(C);
3229  ScrArea *area = CTX_wm_area(C);
3230  ARegion *region = CTX_wm_region(C);
3232  const int type = RNA_enum_get(op->ptr, "type");
3233  const int iter = RNA_int_get(op->ptr, "iterations");
3234  const double time_limit = (double)RNA_float_get(op->ptr, "time_limit");
3235  const int cfra = scene->r.cfra;
3236  const char *infostr = "";
3237 
3238  /* NOTE: Depsgraph is used to update scene for a new state, so no need to ensure evaluation here.
3239  */
3241 
3242  WM_cursor_wait(true);
3243 
3244  double time_start = PIL_check_seconds_timer();
3245 
3246  wm_window_make_drawable(wm, win);
3247 
3248  int iter_steps = 0;
3249  for (int a = 0; a < iter; a++) {
3250  redraw_timer_step(C, scene, depsgraph, win, area, region, type, cfra);
3251  iter_steps += 1;
3252 
3253  if (time_limit != 0.0) {
3254  if ((PIL_check_seconds_timer() - time_start) > time_limit) {
3255  break;
3256  }
3257  a = 0;
3258  }
3259  }
3260 
3261  double time_delta = (PIL_check_seconds_timer() - time_start) * 1000;
3262 
3264 
3265  WM_cursor_wait(false);
3266 
3267  BKE_reportf(op->reports,
3268  RPT_WARNING,
3269  "%d x %s: %.4f ms, average: %.8f ms",
3270  iter_steps,
3271  infostr,
3272  time_delta,
3273  time_delta / iter_steps);
3274 
3275  return OPERATOR_FINISHED;
3276 }
3277 
3279 {
3280  ot->name = "Redraw Timer";
3281  ot->idname = "WM_OT_redraw_timer";
3282  ot->description = "Simple redraw timer to test the speed of updating the interface";
3283 
3287 
3288  ot->prop = RNA_def_enum(ot->srna, "type", redraw_timer_type_items, eRTDrawRegion, "Type", "");
3289  RNA_def_int(
3290  ot->srna, "iterations", 10, 1, INT_MAX, "Iterations", "Number of times to redraw", 1, 1000);
3292  "time_limit",
3293  0.0,
3294  0.0,
3295  FLT_MAX,
3296  "Time Limit",
3297  "Seconds to run the test for (override iterations)",
3298  0.0,
3299  60.0);
3300 }
3301 
3304 /* -------------------------------------------------------------------- */
3311 {
3313  return OPERATOR_FINISHED;
3314 }
3315 
3317 {
3318  ot->name = "Memory Statistics";
3319  ot->idname = "WM_OT_memory_statistics";
3320  ot->description = "Print memory statistics to the console";
3321 
3323 }
3324 
3327 /* -------------------------------------------------------------------- */
3333 typedef struct PreviewsIDEnsureData {
3337 
3339 {
3341 
3342  /* Only preview non-library datablocks, lib ones do not pertain to this .blend file!
3343  * Same goes for ID with no user. */
3344  if (!ID_IS_LINKED(id) && (id->us != 0)) {
3345  UI_icon_render_id(C, scene, id, ICON_SIZE_ICON, false);
3347  }
3348 }
3349 
3351 {
3352  const int cb_flag = cb_data->cb_flag;
3353 
3354  if (cb_flag & IDWALK_CB_EMBEDDED) {
3355  return IDWALK_RET_NOP;
3356  }
3357 
3358  PreviewsIDEnsureData *data = cb_data->user_data;
3359  ID *id = *cb_data->id_pointer;
3360 
3361  if (id && (id->tag & LIB_TAG_DOIT)) {
3363  previews_id_ensure(data->C, data->scene, id);
3364  id->tag &= ~LIB_TAG_DOIT;
3365  }
3366 
3367  return IDWALK_RET_NOP;
3368 }
3369 
3371 {
3372  Main *bmain = CTX_data_main(C);
3373  ListBase *lb[] = {
3374  &bmain->materials, &bmain->textures, &bmain->images, &bmain->worlds, &bmain->lights, NULL};
3375  PreviewsIDEnsureData preview_id_data;
3376 
3377  /* We use LIB_TAG_DOIT to check whether we have already handled a given ID or not. */
3378  BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
3379  for (int i = 0; lb[i]; i++) {
3380  BKE_main_id_tag_listbase(lb[i], LIB_TAG_DOIT, true);
3381  }
3382 
3383  preview_id_data.C = C;
3384  LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
3385  preview_id_data.scene = scene;
3386  ID *id = (ID *)scene;
3387 
3389  NULL, id, previews_id_ensure_callback, &preview_id_data, IDWALK_RECURSE);
3390  }
3391 
3392  /* Check a last time for ID not used (fake users only, in theory), and
3393  * do our best for those, using current scene... */
3394  for (int i = 0; lb[i]; i++) {
3395  LISTBASE_FOREACH (ID *, id, lb[i]) {
3396  if (id->tag & LIB_TAG_DOIT) {
3397  previews_id_ensure(C, NULL, id);
3398  id->tag &= ~LIB_TAG_DOIT;
3399  }
3400  }
3401  }
3402 
3403  return OPERATOR_FINISHED;
3404 }
3405 
3407 {
3408  ot->name = "Refresh Data-Block Previews";
3409  ot->idname = "WM_OT_previews_ensure";
3410  ot->description =
3411  "Ensure data-block previews are available and up-to-date "
3412  "(to be saved in .blend file, only for some types like materials, textures, etc.)";
3413 
3415 }
3416 
3419 /* -------------------------------------------------------------------- */
3423 typedef enum PreviewFilterID {
3436 
3437 /* Only types supporting previews currently. */
3439  {PREVIEW_FILTER_ALL, "ALL", 0, "All Types", ""},
3441  "GEOMETRY",
3442  0,
3443  "All Geometry Types",
3444  "Clear previews for scenes, collections and objects"},
3446  "SHADING",
3447  0,
3448  "All Shading Types",
3449  "Clear previews for materials, lights, worlds, textures and images"},
3450  {PREVIEW_FILTER_SCENE, "SCENE", 0, "Scenes", ""},
3451  {PREVIEW_FILTER_COLLECTION, "COLLECTION", 0, "Collections", ""},
3452  {PREVIEW_FILTER_OBJECT, "OBJECT", 0, "Objects", ""},
3453  {PREVIEW_FILTER_MATERIAL, "MATERIAL", 0, "Materials", ""},
3454  {PREVIEW_FILTER_LIGHT, "LIGHT", 0, "Lights", ""},
3455  {PREVIEW_FILTER_WORLD, "WORLD", 0, "Worlds", ""},
3456  {PREVIEW_FILTER_TEXTURE, "TEXTURE", 0, "Textures", ""},
3457  {PREVIEW_FILTER_IMAGE, "IMAGE", 0, "Images", ""},
3458 #if 0 /* XXX TODO */
3459  {PREVIEW_FILTER_BRUSH, "BRUSH", 0, "Brushes", ""},
3460 #endif
3461  {0, NULL, 0, NULL, NULL},
3462 };
3463 
3465 {
3466  switch (filter) {
3467  case PREVIEW_FILTER_ALL:
3474  case PREVIEW_FILTER_SCENE:
3475  return FILTER_ID_SCE;
3477  return FILTER_ID_GR;
3478  case PREVIEW_FILTER_OBJECT:
3479  return FILTER_ID_OB;
3481  return FILTER_ID_MA;
3482  case PREVIEW_FILTER_LIGHT:
3483  return FILTER_ID_LA;
3484  case PREVIEW_FILTER_WORLD:
3485  return FILTER_ID_WO;
3487  return FILTER_ID_TE;
3488  case PREVIEW_FILTER_IMAGE:
3489  return FILTER_ID_IM;
3490  }
3491 
3492  return 0;
3493 }
3494 
3496 {
3497  Main *bmain = CTX_data_main(C);
3498  ListBase *lb[] = {
3499  &bmain->objects,
3500  &bmain->collections,
3501  &bmain->materials,
3502  &bmain->worlds,
3503  &bmain->lights,
3504  &bmain->textures,
3505  &bmain->images,
3506  NULL,
3507  };
3508 
3509  const int id_filters = preview_filter_to_idfilter(RNA_enum_get(op->ptr, "id_type"));
3510 
3511  for (int i = 0; lb[i]; i++) {
3512  ID *id = lb[i]->first;
3513  if (!id) {
3514  continue;
3515  }
3516 
3517 #if 0
3518  printf("%s: %d, %d, %d -> %d\n",
3519  id->name,
3520  GS(id->name),
3522  id_filters,
3523  BKE_idtype_idcode_to_idfilter(GS(id->name)) & id_filters);
3524 #endif
3525 
3526  if (!(BKE_idtype_idcode_to_idfilter(GS(id->name)) & id_filters)) {
3527  continue;
3528  }
3529 
3530  for (; id; id = id->next) {
3531  PreviewImage *prv_img = BKE_previewimg_id_ensure(id);
3532 
3533  BKE_previewimg_clear(prv_img);
3534  }
3535  }
3536 
3537  return OPERATOR_FINISHED;
3538 }
3539 
3541 {
3542  ot->name = "Clear Data-Block Previews";
3543  ot->idname = "WM_OT_previews_clear";
3544  ot->description =
3545  "Clear data-block previews (only for some types like objects, materials, textures, etc.)";
3546 
3549 
3551  "id_type",
3554  "Data-Block Type",
3555  "Which data-block previews to clear");
3556 }
3557 
3560 /* -------------------------------------------------------------------- */
3565 {
3566  PointerRNA ptr_props;
3567  char buf[512];
3568  short retval = OPERATOR_CANCELLED;
3569 
3570  if (UI_but_online_manual_id_from_active(C, buf, sizeof(buf))) {
3571  WM_operator_properties_create(&ptr_props, "WM_OT_doc_view_manual");
3572  RNA_string_set(&ptr_props, "doc_id", buf);
3573 
3574  retval = WM_operator_name_call_ptr(
3575  C, WM_operatortype_find("WM_OT_doc_view_manual", false), WM_OP_EXEC_DEFAULT, &ptr_props);
3576 
3577  WM_operator_properties_free(&ptr_props);
3578  }
3579 
3580  return retval;
3581 }
3582 
3584 {
3585  /* identifiers */
3586  ot->name = "View Online Manual";
3587  ot->idname = "WM_OT_doc_view_manual_ui_context";
3588  ot->description = "View a context based online manual in a web browser";
3589 
3590  /* callbacks */
3593 }
3594 
3597 /* -------------------------------------------------------------------- */
3604 {
3605  PropertyRNA *prop;
3606 
3607  ot->name = "Set Stereo 3D";
3608  ot->idname = "WM_OT_set_stereo_3d";
3609  ot->description = "Toggle 3D stereo support for current window (or change the display mode)";
3610 
3617 
3618  prop = RNA_def_enum(ot->srna,
3619  "display_mode",
3622  "Display Mode",
3623  "");
3625  prop = RNA_def_enum(ot->srna,
3626  "anaglyph_type",
3629  "Anaglyph Type",
3630  "");
3632  prop = RNA_def_enum(ot->srna,
3633  "interlace_type",
3636  "Interlace Type",
3637  "");
3639  prop = RNA_def_boolean(ot->srna,
3640  "use_interlace_swap",
3641  false,
3642  "Swap Left/Right",
3643  "Swap left and right stereo channels");
3645  prop = RNA_def_boolean(ot->srna,
3646  "use_sidebyside_crosseyed",
3647  false,
3648  "Cross-Eyed",
3649  "Right eye should see left image and vice versa");
3651 }
3652 
3655 #ifdef WITH_XR_OPENXR
3656 
3657 static void wm_xr_session_update_screen(Main *bmain, const wmXrData *xr_data)
3658 {
3659  const bool session_exists = WM_xr_session_exists(xr_data);
3660 
3661  for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
3662  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
3663  LISTBASE_FOREACH (SpaceLink *, slink, &area->spacedata) {
3664  if (slink->spacetype == SPACE_VIEW3D) {
3665  View3D *v3d = (View3D *)slink;
3666 
3667  if (v3d->flag & V3D_XR_SESSION_MIRROR) {
3668  ED_view3d_xr_mirror_update(area, v3d, session_exists);
3669  }
3670 
3671  if (session_exists) {
3672  wmWindowManager *wm = bmain->wm.first;
3673  const Scene *scene = WM_windows_scene_get_from_screen(wm, screen);
3674 
3675  ED_view3d_xr_shading_update(wm, v3d, scene);
3676  }
3677  /* Ensure no 3D View is tagged as session root. */
3678  else {
3680  }
3681  }
3682  }
3683  }
3684  }
3685 
3687 }
3688 
3689 static void wm_xr_session_update_screen_on_exit_cb(const wmXrData *xr_data)
3690 {
3691  /* Just use G_MAIN here, storing main isn't reliable enough on file read or exit. */
3692  wm_xr_session_update_screen(G_MAIN, xr_data);
3693 }
3694 
3695 static int wm_xr_session_toggle_exec(bContext *C, wmOperator *UNUSED(op))
3696 {
3697  Main *bmain = CTX_data_main(C);
3699  wmWindow *win = CTX_wm_window(C);
3700  View3D *v3d = CTX_wm_view3d(C);
3701 
3702  /* Lazy-create xr context - tries to dynlink to the runtime, reading active_runtime.json. */
3703  if (wm_xr_init(wm) == false) {
3704  return OPERATOR_CANCELLED;
3705  }
3706 
3708  wm_xr_session_toggle(wm, win, wm_xr_session_update_screen_on_exit_cb);
3709  wm_xr_session_update_screen(bmain, &wm->xr);
3710 
3712 
3713  return OPERATOR_FINISHED;
3714 }
3715 
3716 static void WM_OT_xr_session_toggle(wmOperatorType *ot)
3717 {
3718  /* identifiers */
3719  ot->name = "Toggle VR Session";
3720  ot->idname = "WM_OT_xr_session_toggle";
3721  ot->description =
3722  "Open a view for use with virtual reality headsets, or close it if already "
3723  "opened";
3724 
3725  /* callbacks */
3726  ot->exec = wm_xr_session_toggle_exec;
3728 
3729  /* XXX INTERNAL just to hide it from the search menu by default, an Add-on will expose it in the
3730  * UI instead. Not meant as a permanent solution. */
3731  ot->flag = OPTYPE_INTERNAL;
3732 }
3733 
3734 #endif /* WITH_XR_OPENXR */
3735 
3736 /* -------------------------------------------------------------------- */
3741 {
3777 #ifdef WITH_XR_OPENXR
3778  WM_operatortype_append(WM_OT_xr_session_toggle);
3779 #endif
3780 #if defined(WIN32)
3781  WM_operatortype_append(WM_OT_console_toggle);
3782 #endif
3786 
3787  /* gizmos */
3790 }
3791 
3792 /* circleselect-like modal operators */
3794 {
3795  static const EnumPropertyItem modal_items[] = {
3796  {GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
3797  {GESTURE_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
3798  {GESTURE_MODAL_CIRCLE_ADD, "ADD", 0, "Add", ""},
3799  {GESTURE_MODAL_CIRCLE_SUB, "SUBTRACT", 0, "Subtract", ""},
3800  {GESTURE_MODAL_CIRCLE_SIZE, "SIZE", 0, "Size", ""},
3801 
3802  {GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""},
3803  {GESTURE_MODAL_DESELECT, "DESELECT", 0, "Deselect", ""},
3804  {GESTURE_MODAL_NOP, "NOP", 0, "No Operation", ""},
3805 
3806  {0, NULL, 0, NULL, NULL},
3807  };
3808 
3809  /* WARNING - name is incorrect, use for non-3d views */
3810  wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "View3D Gesture Circle");
3811 
3812  /* this function is called for each spacetype, only needs to add map once */
3813  if (keymap && keymap->modal_items) {
3814  return;
3815  }
3816 
3817  keymap = WM_modalkeymap_ensure(keyconf, "View3D Gesture Circle", modal_items);
3818 
3819  /* assign map to operators */
3820  WM_modalkeymap_assign(keymap, "VIEW3D_OT_select_circle");
3821  WM_modalkeymap_assign(keymap, "UV_OT_select_circle");
3822  WM_modalkeymap_assign(keymap, "CLIP_OT_select_circle");
3823  WM_modalkeymap_assign(keymap, "MASK_OT_select_circle");
3824  WM_modalkeymap_assign(keymap, "NODE_OT_select_circle");
3825  WM_modalkeymap_assign(keymap, "GPENCIL_OT_select_circle");
3826  WM_modalkeymap_assign(keymap, "GRAPH_OT_select_circle");
3827  WM_modalkeymap_assign(keymap, "ACTION_OT_select_circle");
3828 }
3829 
3830 /* straight line modal operators */
3832 {
3833  static const EnumPropertyItem modal_items[] = {
3834  {GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
3835  {GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""},
3836  {GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""},
3837  {GESTURE_MODAL_MOVE, "MOVE", 0, "Move", ""},
3838  {GESTURE_MODAL_SNAP, "SNAP", 0, "Snap", ""},
3839  {GESTURE_MODAL_FLIP, "FLIP", 0, "Flip", ""},
3840  {0, NULL, 0, NULL, NULL},
3841  };
3842 
3843  wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Gesture Straight Line");
3844 
3845  /* this function is called for each spacetype, only needs to add map once */
3846  if (keymap && keymap->modal_items) {
3847  return;
3848  }
3849 
3850  keymap = WM_modalkeymap_ensure(keyconf, "Gesture Straight Line", modal_items);
3851 
3852  /* assign map to operators */
3853  WM_modalkeymap_assign(keymap, "IMAGE_OT_sample_line");
3854  WM_modalkeymap_assign(keymap, "PAINT_OT_weight_gradient");
3855  WM_modalkeymap_assign(keymap, "MESH_OT_bisect");
3856  WM_modalkeymap_assign(keymap, "PAINT_OT_mask_line_gesture");
3857  WM_modalkeymap_assign(keymap, "SCULPT_OT_project_line_gesture");
3858 }
3859 
3860 /* box_select-like modal operators */
3862 {
3863  static const EnumPropertyItem modal_items[] = {
3864  {GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
3865  {GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""},
3866  {GESTURE_MODAL_DESELECT, "DESELECT", 0, "Deselect", ""},
3867  {GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""},
3868  {GESTURE_MODAL_MOVE, "MOVE", 0, "Move", ""},
3869  {0, NULL, 0, NULL, NULL},
3870  };
3871 
3872  wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Gesture Box");
3873 
3874  /* this function is called for each spacetype, only needs to add map once */
3875  if (keymap && keymap->modal_items) {
3876  return;
3877  }
3878 
3879  keymap = WM_modalkeymap_ensure(keyconf, "Gesture Box", modal_items);
3880 
3881  /* assign map to operators */
3882  WM_modalkeymap_assign(keymap, "ACTION_OT_select_box");
3883  WM_modalkeymap_assign(keymap, "ANIM_OT_channels_select_box");
3884  WM_modalkeymap_assign(keymap, "ANIM_OT_previewrange_set");
3885  WM_modalkeymap_assign(keymap, "INFO_OT_select_box");
3886  WM_modalkeymap_assign(keymap, "FILE_OT_select_box");
3887  WM_modalkeymap_assign(keymap, "GRAPH_OT_select_box");
3888  WM_modalkeymap_assign(keymap, "MARKER_OT_select_box");
3889  WM_modalkeymap_assign(keymap, "NLA_OT_select_box");
3890  WM_modalkeymap_assign(keymap, "NODE_OT_select_box");
3891  WM_modalkeymap_assign(keymap, "NODE_OT_viewer_border");
3892  WM_modalkeymap_assign(keymap, "PAINT_OT_hide_show");
3893  WM_modalkeymap_assign(keymap, "OUTLINER_OT_select_box");
3894 #if 0 /* Template. */
3895  WM_modalkeymap_assign(keymap, "SCREEN_OT_box_select");
3896 #endif
3897  WM_modalkeymap_assign(keymap, "SEQUENCER_OT_select_box");
3898  WM_modalkeymap_assign(keymap, "SEQUENCER_OT_view_ghost_border");
3899  WM_modalkeymap_assign(keymap, "UV_OT_select_box");
3900  WM_modalkeymap_assign(keymap, "CLIP_OT_select_box");
3901  WM_modalkeymap_assign(keymap, "CLIP_OT_graph_select_box");
3902  WM_modalkeymap_assign(keymap, "MASK_OT_select_box");
3903  WM_modalkeymap_assign(keymap, "PAINT_OT_mask_box_gesture");
3904  WM_modalkeymap_assign(keymap, "SCULPT_OT_face_set_box_gesture");
3905  WM_modalkeymap_assign(keymap, "SCULPT_OT_trim_box_gesture");
3906  WM_modalkeymap_assign(keymap, "VIEW2D_OT_zoom_border");
3907  WM_modalkeymap_assign(keymap, "VIEW3D_OT_clip_border");
3908  WM_modalkeymap_assign(keymap, "VIEW3D_OT_render_border");
3909  WM_modalkeymap_assign(keymap, "VIEW3D_OT_select_box");
3910  /* XXX TODO: zoom border should perhaps map rightmouse to zoom out instead of in+cancel */
3911  WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom_border");
3912  WM_modalkeymap_assign(keymap, "IMAGE_OT_render_border");
3913  WM_modalkeymap_assign(keymap, "IMAGE_OT_view_zoom_border");
3914  WM_modalkeymap_assign(keymap, "GPENCIL_OT_select_box");
3915 }
3916 
3917 /* lasso modal operators */
3919 {
3920  static const EnumPropertyItem modal_items[] = {
3921  {GESTURE_MODAL_MOVE, "MOVE", 0, "Move", ""},
3922  {0, NULL, 0, NULL, NULL},
3923  };
3924 
3925  wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Gesture Lasso");
3926 
3927  /* this function is called for each spacetype, only needs to add map once */
3928  if (keymap && keymap->modal_items) {
3929  return;
3930  }
3931 
3932  keymap = WM_modalkeymap_ensure(keyconf, "Gesture Lasso", modal_items);
3933 
3934  /* assign map to operators */
3935  WM_modalkeymap_assign(keymap, "VIEW3D_OT_select_lasso");
3936  WM_modalkeymap_assign(keymap, "GPENCIL_OT_stroke_cutter");
3937  WM_modalkeymap_assign(keymap, "GPENCIL_OT_select_lasso");
3938  WM_modalkeymap_assign(keymap, "MASK_OT_select_lasso");
3939  WM_modalkeymap_assign(keymap, "PAINT_OT_mask_lasso_gesture");
3940  WM_modalkeymap_assign(keymap, "SCULPT_OT_face_set_lasso_gesture");
3941  WM_modalkeymap_assign(keymap, "SCULPT_OT_trim_lasso_gesture");
3942  WM_modalkeymap_assign(keymap, "ACTION_OT_select_lasso");
3943  WM_modalkeymap_assign(keymap, "CLIP_OT_select_lasso");
3944  WM_modalkeymap_assign(keymap, "GRAPH_OT_select_lasso");
3945  WM_modalkeymap_assign(keymap, "NODE_OT_select_lasso");
3946  WM_modalkeymap_assign(keymap, "UV_OT_select_lasso");
3947 }
3948 
3949 /* zoom to border modal operators */
3951 {
3952  static const EnumPropertyItem modal_items[] = {
3953  {GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
3954  {GESTURE_MODAL_IN, "IN", 0, "In", ""},
3955  {GESTURE_MODAL_OUT, "OUT", 0, "Out", ""},
3956  {GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""},
3957  {0, NULL, 0, NULL, NULL},
3958  };
3959 
3960  wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Gesture Zoom Border");
3961 
3962  /* this function is called for each spacetype, only needs to add map once */
3963  if (keymap && keymap->modal_items) {
3964  return;
3965  }
3966 
3967  keymap = WM_modalkeymap_ensure(keyconf, "Gesture Zoom Border", modal_items);
3968 
3969  /* assign map to operators */
3970  WM_modalkeymap_assign(keymap, "VIEW2D_OT_zoom_border");
3971  WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom_border");
3972  WM_modalkeymap_assign(keymap, "IMAGE_OT_view_zoom_border");
3973 }
3974 
3975 /* default keymap for windows and screens, only call once per WM */
3977 {
3978  WM_keymap_ensure(keyconf, "Window", 0, 0);
3979 
3980  wm_gizmos_keymap(keyconf);
3981  gesture_circle_modal_keymap(keyconf);
3982  gesture_box_modal_keymap(keyconf);
3985  gesture_lasso_modal_keymap(keyconf);
3986 
3988 }
3989 
3992 /* -------------------------------------------------------------------- */
4000 static bool rna_id_enum_filter_single(const ID *id, void *user_data)
4001 {
4002  return (id != user_data);
4003 }
4004 
4005 /* Generic itemf's for operators that take library args */
4006 static const EnumPropertyItem *rna_id_itemf(bool *r_free,
4007  ID *id,
4008  bool local,
4009  bool (*filter_ids)(const ID *id, void *user_data),
4010  void *user_data)
4011 {
4012  EnumPropertyItem item_tmp = {0}, *item = NULL;
4013  int totitem = 0;
4014  int i = 0;
4015 
4016  if (id != NULL) {
4017  const short id_type = GS(id->name);
4018  for (; id; id = id->next) {
4019  if ((filter_ids != NULL) && filter_ids(id, user_data) == false) {
4020  i++;
4021  continue;
4022  }
4023  if (local == false || !ID_IS_LINKED(id)) {
4024  item_tmp.identifier = item_tmp.name = id->name + 2;
4025  item_tmp.value = i++;
4026 
4027  /* Show collection color tag icons in menus. */
4028  if (id_type == ID_GR) {
4029  item_tmp.icon = UI_icon_color_from_collection((struct Collection *)id);
4030  }
4031 
4032  RNA_enum_item_add(&item, &totitem, &item_tmp);
4033  }
4034  }
4035  }
4036 
4037  RNA_enum_item_end(&item, &totitem);
4038  *r_free = true;
4039 
4040  return item;
4041 }
4042 
4043 /* can add more as needed */
4045  PointerRNA *UNUSED(ptr),
4046  PropertyRNA *UNUSED(prop),
4047  bool *r_free)
4048 {
4049 
4050  return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->actions.first : NULL, false, NULL, NULL);
4051 }
4052 #if 0 /* UNUSED */
4053 const EnumPropertyItem *RNA_action_local_itemf(bContext *C,
4054  PointerRNA *UNUSED(ptr),
4055  PropertyRNA *UNUSED(prop),
4056  bool *r_free)
4057 {
4058  return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->action.first : NULL, true);
4059 }
4060 #endif
4061 
4063  PointerRNA *UNUSED(ptr),
4064  PropertyRNA *UNUSED(prop),
4065  bool *r_free)
4066 {
4067  return rna_id_itemf(
4068  r_free, C ? (ID *)CTX_data_main(C)->collections.first : NULL, false, NULL, NULL);
4069 }
4071  PointerRNA *UNUSED(ptr),
4072  PropertyRNA *UNUSED(prop),
4073  bool *r_free)
4074 {
4075  return rna_id_itemf(
4076  r_free, C ? (ID *)CTX_data_main(C)->collections.first : NULL, true, NULL, NULL);
4077 }
4078 
4080  PointerRNA *UNUSED(ptr),
4081  PropertyRNA *UNUSED(prop),
4082  bool *r_free)
4083 {
4084  return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->images.first : NULL, false, NULL, NULL);
4085 }
4087  PointerRNA *UNUSED(ptr),
4088  PropertyRNA *UNUSED(prop),
4089  bool *r_free)
4090 {
4091  return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->images.first : NULL, true, NULL, NULL);
4092 }
4093 
4095  PointerRNA *UNUSED(ptr),
4096  PropertyRNA *UNUSED(prop),
4097  bool *r_free)
4098 {
4099  return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->scenes.first : NULL, false, NULL, NULL);
4100 }
4102  PointerRNA *UNUSED(ptr),
4103  PropertyRNA *UNUSED(prop),
4104  bool *r_free)
4105 {
4106  return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->scenes.first : NULL, true, NULL, NULL);
4107 }
4109  PointerRNA *UNUSED(ptr),
4110  PropertyRNA *UNUSED(prop),
4111  bool *r_free)
4112 {
4113  Scene *scene_active = C ? CTX_data_scene(C) : NULL;
4114  return rna_id_itemf(r_free,
4115  C ? (ID *)CTX_data_main(C)->scenes.first : NULL,
4116  false,
4118  scene_active);
4119 }
4121  PointerRNA *UNUSED(ptr),
4122  PropertyRNA *UNUSED(prop),
4123  bool *r_free)
4124 {
4125  return rna_id_itemf(
4126  r_free, C ? (ID *)CTX_data_main(C)->movieclips.first : NULL, false, NULL, NULL);
4127 }
4129  PointerRNA *UNUSED(ptr),
4130  PropertyRNA *UNUSED(prop),
4131  bool *r_free)
4132 {
4133  return rna_id_itemf(
4134  r_free, C ? (ID *)CTX_data_main(C)->movieclips.first : NULL, true, NULL, NULL);
4135 }
4136 
4138  PointerRNA *UNUSED(ptr),
4139  PropertyRNA *UNUSED(prop),
4140  bool *r_free)
4141 {
4142  return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->masks.first : NULL, false, NULL, NULL);
4143 }
4145  PointerRNA *UNUSED(ptr),
4146  PropertyRNA *UNUSED(prop),
4147  bool *r_free)
4148 {
4149  return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->masks.first : NULL, true, NULL, NULL);
4150 }
4151 
typedef float(TangentPoint)[2]
struct ImBuf * BKE_brush_gen_radial_control_imbuf(struct Brush *br, bool secondary, bool display_gradient)
Definition: brush.c:2507
float BKE_brush_curve_strength_clamped(struct Brush *br, float p, const float len)
Definition: brush.c:2464
void BKE_curvemapping_init(struct CurveMapping *cumap)
Definition: colortools.c:1200
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:714
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
void CTX_wm_region_set(bContext *C, struct ARegion *region)
Definition: context.c:985
struct Object * CTX_data_edit_object(const bContext *C)
Definition: context.c:1296
void CTX_wm_menu_set(bContext *C, struct ARegion *menu)
Definition: context.c:996
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:689
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
Definition: context.c:456
struct View3D * CTX_wm_view3d(const bContext *C)
Definition: context.c:760
ListBase CTX_data_dir_get_ex(const bContext *C, const bool use_store, const bool use_rna, const bool use_all)
Definition: context.c:541
struct bScreen * CTX_wm_screen(const bContext *C)
Definition: context.c:709
void CTX_wm_window_set(bContext *C, struct wmWindow *win)
Definition: context.c:942
struct SpaceLink * CTX_wm_space_data(const bContext *C)
Definition: context.c:719
struct ReportList * CTX_wm_reports(const bContext *C)
Definition: context.c:751
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:725
struct Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Definition: context.c:1401
void CTX_wm_area_set(bContext *C, struct ScrArea *area)
Definition: context.c:973
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
#define G_MAIN
Definition: BKE_global.h:232
struct PreviewImage * BKE_previewimg_id_ensure(struct ID *id)
Definition: icons.cc:400
void BKE_previewimg_clear(struct PreviewImage *prv)
Definition: icons.cc:315
void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL()
Definition: idprop.c:572
void IDP_FreeProperty(struct IDProperty *prop)
Definition: idprop.c:1040
bool IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL()
Definition: idprop.c:643
struct IDProperty * IDP_GetPropertyFromGroup(const struct IDProperty *prop, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void IDP_MergeGroup(struct IDProperty *dest, const struct IDProperty *src, const bool do_overwrite) ATTR_NONNULL()
struct IDProperty * IDP_New(const char type, const IDPropertyTemplate *val, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: idprop.c:907
void IDP_ClearProperty(struct IDProperty *prop)
Definition: idprop.c:1046
struct IDProperty * IDP_CopyProperty(const struct IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
const char * BKE_idtype_idcode_to_name(const short idcode)
Definition: idtype.c:168
uint64_t BKE_idtype_idcode_to_idfilter(const short idcode)
Definition: idtype.c:242
int BKE_image_path_ensure_ext_from_imformat(char *string, const struct ImageFormatData *im_format)
struct Image * BKE_image_load_exists_ex(struct Main *bmain, const char *filepath, bool *r_exists)
Definition: image.c:843
void BKE_main_id_tag_all(struct Main *mainvar, const int tag, const bool value)
Definition: lib_id.c:923
void id_us_plus(struct ID *id)
Definition: lib_id.c:288
void BKE_main_id_tag_listbase(struct ListBase *lb, const int tag, const bool value)
Definition: lib_id.c:891
struct ID * BKE_libblock_find_name(struct Main *bmain, const short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: lib_id.c:1333
@ IDWALK_RECURSE
void BKE_library_foreach_ID_link(struct Main *bmain, struct ID *id, LibraryIDLinkCallback callback, void *user_data, int flag)
Definition: lib_query.c:322
@ IDWALK_RET_NOP
Definition: BKE_lib_query.h:97
@ IDWALK_CB_EMBEDDED
Definition: BKE_lib_query.h:62
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
General operations, lookup, etc. for materials.
void BKE_report(ReportList *reports, ReportType type, const char *message)
Definition: report.c:104
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_scene_graph_update_for_newframe(struct Depsgraph *depsgraph)
Definition: scene.c:2794
#define BKE_ST_MAXNAME
Definition: BKE_screen.h:68
void BLF_color4fv(int fontid, const float rgba[4])
Definition: blf.c:441
void BLF_width_and_height(int fontid, const char *str, size_t len, float *r_width, float *r_height) ATTR_NONNULL()
Definition: blf.c:698
void BLF_draw(int fontid, const char *str, size_t len) ATTR_NONNULL(2)
Definition: blf.c:542
void BLF_size(int fontid, int size, int dpi)
Definition: blf.c:367
void BLF_position(int fontid, float x, float y, float z)
Definition: blf.c:312
#define BLI_assert_unreachable()
Definition: BLI_assert.h:96
#define BLI_assert(a)
Definition: BLI_assert.h:58
Dial * BLI_dial_init(const float start_position[2], float threshold)
Definition: BLI_dial_2d.c:48
float BLI_dial_angle(Dial *dial, const float current_position[2])
Definition: BLI_dial_2d.c:58
A dynamically sized string ADT.
DynStr * BLI_dynstr_new(void) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition: BLI_dynstr.c:71
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
Definition: BLI_dynstr.c:358
void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format,...) ATTR_PRINTF_FORMAT(2
char * BLI_dynstr_get_cstring(DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: BLI_dynstr.c:323
void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr) ATTR_NONNULL()
Definition: BLI_dynstr.c:107
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:116
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
Definition: BLI_listbase.h:188
#define LISTBASE_FOREACH_BACKWARD(type, var, list)
Definition: BLI_listbase.h:184
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
Definition: BLI_listbase.h:128
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:547
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:110
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:133
MINLINE float max_ff(float a, float b)
MINLINE int min_ii(int a, int b)
MINLINE float clamp_f(float value, float min, float max)
MINLINE float min_ff(float a, float b)
MINLINE int max_ii(int a, int b)
#define M_PI
Definition: BLI_math_base.h:38
#define DEG2RADF(_deg)
#define RAD2DEGF(_rad)
MINLINE float len_v2(const float a[2]) ATTR_WARN_UNUSED_RESULT
#define FILE_MAX
void BLI_path_rel(char *file, const char *relfile) ATTR_NONNULL()
Definition: path_util.c:519
size_t size_t char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
#define STRNCPY(dst, src)
Definition: BLI_string.h:163
void BLI_str_tolower_ascii(char *str, const size_t len) ATTR_NONNULL()
Definition: string.c:890
void BLI_str_toupper_ascii(char *str, const size_t len) ATTR_NONNULL()
Definition: string.c:901
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string.c:108
size_t BLI_strlen_utf8(const char *strc) ATTR_NONNULL()
Definition: string_utf8.c:357
unsigned int uint
Definition: BLI_sys_types.h:83
#define UNPACK2(a)
#define POINTER_FROM_INT(i)
#define UNUSED(x)
#define POINTER_AS_INT(i)
#define ELEM(...)
#define STREQ(a, b)
#define CTX_N_(context, msgid)
#define TIP_(msgid)
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define IFACE_(msgid)
#define N_(msgid)
typedef double(DMatrix)[4][4]
#define CLOG_ERROR(clg_ref,...)
Definition: CLG_log.h:204
#define CLOG_INFO(clg_ref, level,...)
Definition: CLG_log.h:201
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
ID and Library types, which are fundamental for sdna.
#define FILTER_ID_OB
Definition: DNA_ID.h:722
#define FILTER_ID_MA
Definition: DNA_ID.h:716
@ LIB_TAG_DOIT
Definition: DNA_ID.h:554
#define ID_IS_LINKED(_id)
Definition: DNA_ID.h:426
#define MAX_ID_NAME
Definition: DNA_ID.h:269
#define FILTER_ID_LA
Definition: DNA_ID.h:713
@ IDP_GROUP
Definition: DNA_ID.h:101
#define FILTER_ID_GR
Definition: DNA_ID.h:711
#define FILTER_ID_TE
Definition: DNA_ID.h:728
@ IDP_FLAG_GHOST
Definition: DNA_ID.h:141
#define FILTER_ID_IM
Definition: DNA_ID.h:712
#define FILTER_ID_SCE
Definition: DNA_ID.h:725
#define FILTER_ID_WO
Definition: DNA_ID.h:731
@ ICON_SIZE_PREVIEW
Definition: DNA_ID_enums.h:30
@ ICON_SIZE_ICON
Definition: DNA_ID_enums.h:29
@ ID_TE
Definition: DNA_ID_enums.h:64
@ ID_IM
Definition: DNA_ID_enums.h:65
@ ID_LA
Definition: DNA_ID_enums.h:67
@ ID_SCE
Definition: DNA_ID_enums.h:57
@ ID_BR
Definition: DNA_ID_enums.h:81
@ ID_WO
Definition: DNA_ID_enums.h:71
@ ID_MA
Definition: DNA_ID_enums.h:63
@ ID_SCR
Definition: DNA_ID_enums.h:72
@ ID_GR
Definition: DNA_ID_enums.h:77
@ ID_OB
Definition: DNA_ID_enums.h:59
#define MAX_NAME
Definition: DNA_defs.h:62
Object is a sort of wrapper for general info.
#define OB_DATA_SUPPORT_ID_CASE
@ OB_FONT
#define USER_UNIT_NONE
@ S3D_ANAGLYPH_REDCYAN
@ S3D_DISPLAY_ANAGLYPH
@ S3D_INTERLACE_ROW
@ SCREENNORMAL
#define RGN_TYPE_ANY
@ SPACE_TEXT
@ SPACE_ACTION
@ SPACE_CONSOLE
@ SPACE_FILE
@ SPACE_NLA
@ SPACE_IMAGE
@ SPACE_GRAPH
@ SPACE_VIEW3D
#define SPACE_TYPE_ANY
@ USER_SAVE_PROMPT
@ USER_GLOBALUNDO
#define V3D_XR_SESSION_MIRROR
@ V3D_RUNTIME_XR_SESSION_ROOT
#define OP_MAX_TYPENAME
@ OPERATOR_CANCELLED
@ OPERATOR_INTERFACE
@ OPERATOR_FINISHED
@ OPERATOR_RUNNING_MODAL
@ OPERATOR_PASS_THROUGH
#define OPERATOR_RETVAL_CHECK(ret)
struct FileSelectParams * ED_fileselect_get_active_params(const struct SpaceFile *sfile)
void outputNumInput(NumInput *n, char *str, struct UnitSettings *unit_settings)
Definition: numinput.c:102
void initNumInput(NumInput *n)
Definition: numinput.c:83
#define NUM_STR_REP_LEN
Definition: ED_numinput.h:27
@ NUM_NO_NEGATIVE
Definition: ED_numinput.h:70
bool applyNumInput(NumInput *n, float *vec)
Definition: numinput.c:207
bool hasNumInput(const NumInput *n)
Definition: numinput.c:185
bool handleNumInput(struct bContext *C, NumInput *n, const struct wmEvent *event)
void ED_area_tag_redraw(ScrArea *area)
Definition: area.c:745
void ED_area_status_text(ScrArea *area, const char *str)
Definition: area.c:815
bool ED_operator_regionactive(struct bContext *C)
Definition: screen_ops.c:105
void ED_region_tag_redraw(struct ARegion *region)
Definition: area.c:667
void ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win)
Definition: screen_edit.c:496
bool ED_operator_view3d_active(struct bContext *C)
Definition: screen_ops.c:230
void ED_undo_redo(struct bContext *C)
Definition: ed_undo.c:411
void ED_undo_pop(struct bContext *C)
Definition: ed_undo.c:407
bool ED_undo_is_legacy_compatible_for_property(struct bContext *C, struct ID *id)
Definition: ed_undo.c:469
int ED_undo_operator_repeat(struct bContext *C, struct wmOperator *op)
Definition: ed_undo.c:678
void ED_undo_push(struct bContext *C, const char *str)
Definition: ed_undo.c:117
void ED_undo_push_op(struct bContext *C, struct wmOperator *op)
Definition: ed_undo.c:416
bool ED_undo_is_valid(const struct bContext *C, const char *undoname)
float ED_scene_grid_scale(const struct Scene *scene, const char **r_grid_unit)
float ED_view3d_grid_scale(const struct Scene *scene, struct View3D *v3d, const char **r_grid_unit)
GHOST C-API function and type declarations.
int GHOST_toggleConsole(int action)
void immUniformColor4f(float r, float g, float b, float a)
void immUnbindProgram(void)
void immVertex2f(uint attr_id, float x, float y)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immBindTexture(const char *name, GPUTexture *tex)
GPUVertFormat * immVertexFormat(void)
void immAttr2f(uint attr_id, float x, float y)
void immBegin(GPUPrimType, uint vertex_len)
void immUniformColor3fvAlpha(const float rgb[3], float a)
void immEnd(void)
void imm_draw_circle_fill_2d(uint shdr_pos, float x, float y, float radius, int nsegments)
void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float radius, int nsegments)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
void GPU_matrix_pop(void)
Definition: gpu_matrix.cc:142
void GPU_matrix_scale_2fv(const float vec[2])
Definition: gpu_matrix.cc:242
void GPU_matrix_push(void)
Definition: gpu_matrix.cc:135
void GPU_matrix_rotate_2d(float deg)
Definition: gpu_matrix.cc:269
void GPU_matrix_rotate_3f(float deg, float x, float y, float z)
Definition: gpu_matrix.cc:277
void GPU_matrix_translate_2f(float x, float y)
Definition: gpu_matrix.cc:190
@ GPU_PRIM_TRI_FAN
Definition: GPU_primitive.h:41
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:36
@ GPU_SHADER_2D_UNIFORM_COLOR
Definition: GPU_shader.h:171
@ GPU_SHADER_2D_IMAGE_COLOR
Definition: GPU_shader.h:187
@ GPU_BLEND_NONE
Definition: GPU_state.h:55
@ GPU_BLEND_ALPHA
Definition: GPU_state.h:57
void GPU_blend(eGPUBlend blend)
Definition: gpu_state.cc:55
void GPU_line_width(float width)
Definition: gpu_state.cc:173
void GPU_line_smooth(bool enable)
Definition: gpu_state.cc:85
void GPU_texture_swizzle_set(GPUTexture *tex, const char swizzle[4])
Definition: gpu_texture.cc:503
struct GPUTexture GPUTexture
Definition: GPU_texture.h:33
void GPU_texture_free(GPUTexture *tex)
Definition: gpu_texture.cc:508
void GPU_texture_filter_mode(GPUTexture *tex, bool use_filter)
Definition: gpu_texture.cc:468
void GPU_texture_unbind(GPUTexture *tex)
Definition: gpu_texture.cc:421
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:250
@ GPU_R8
Definition: GPU_texture.h:108
@ GPU_FETCH_FLOAT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
static void init_data(ModifierData *md)
Group RGB to Bright Vector Camera CLAMP
Platform independent time functions.
#define RNA_PROP_END
Definition: RNA_access.h:1268
StructRNA RNA_Region
#define RNA_STRUCT_BEGIN(sptr, prop)
Definition: RNA_access.h:1274
StructRNA RNA_Struct
StructRNA RNA_View3DShading
#define RNA_STRUCT_END
Definition: RNA_access.h:1294
StructRNA RNA_SpaceUVEditor
StructRNA RNA_Space
StructRNA RNA_View3DOverlay
short RNA_type_to_ID_code(const StructRNA *type)
StructRNA RNA_Context
StructRNA RNA_DopeSheet
#define RNA_PROP_BEGIN(sptr, itemptr, prop)
Definition: RNA_access.h:1261
StructRNA RNA_OperatorProperties
StructRNA RNA_FileSelectParams
StructRNA RNA_Operator
StructRNA RNA_Area
#define RNA_SUBTYPE_UNIT_VALUE(subtype)
Definition: RNA_types.h:100
PropertyType
Definition: RNA_types.h:72
@ PROP_FLOAT
Definition: RNA_types.h:75
@ PROP_BOOLEAN
Definition: RNA_types.h:73
@ PROP_ENUM
Definition: RNA_types.h:77
@ PROP_INT
Definition: RNA_types.h:74
@ PROP_POINTER
Definition: RNA_types.h:78
@ PROP_ENUM_NO_CONTEXT
Definition: RNA_types.h:277
@ PROP_SKIP_SAVE
Definition: RNA_types.h:204
PropertySubType
Definition: RNA_types.h:112
@ PROP_DISTANCE
Definition: RNA_types.h:135
@ PROP_PIXEL
Definition: RNA_types.h:128
@ PROP_ANGLE
Definition: RNA_types.h:132
@ PROP_NONE
Definition: RNA_types.h:113
@ PROP_PERCENTAGE
Definition: RNA_types.h:130
@ PROP_FACTOR
Definition: RNA_types.h:131
#define C
Definition: RandGen.cpp:39
#define UI_UNIT_Y
int UI_searchbox_size_x(void)
uiBlock * uiLayoutGetBlock(uiLayout *layout)
void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname, struct IDProperty *properties, int context, int flag)
void uiTemplateOperatorPropertyButs(const struct bContext *C, uiLayout *layout, struct wmOperator *op, eButLabelAlign label_align, short flag)
@ UI_EMBOSS
Definition: UI_interface.h:107
const struct uiStyle * UI_style_get_dpi(void)
void UI_block_theme_style_set(uiBlock *block, char theme_style)
Definition: interface.c:3547
int UI_searchbox_size_y(void)
void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext)
void uiLayoutSetEnabled(uiLayout *layout, bool enabled)
void UI_popup_block_close(struct bContext *C, struct wmWindow *win, uiBlock *block)
@ UI_BUT_ACTIVE_DEFAULT
Definition: UI_interface.h:215
@ UI_BUT_ACTIVATE_ON_INIT
Definition: UI_interface.h:222
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
@ UI_LAYOUT_PANEL
uiBut * uiDefBut(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip)
Definition: interface.c:4687
void UI_block_bounds_set_popup(uiBlock *block, int addval, const int bounds_offset[2])
Definition: interface.c:598
const struct uiStyle * UI_style_get(void)
void UI_block_flag_disable(uiBlock *block, int flag)
Definition: interface.c:6072
struct uiLayout * UI_popup_menu_layout(uiPopupMenu *pup)
void UI_block_func_handle_set(uiBlock *block, uiBlockHandleFunc func, void *arg)
Definition: interface.c:6247
void UI_but_func_menu_search(uiBut *but)
@ UI_BUT_LABEL_ALIGN_SPLIT_COLUMN
@ UI_BUT_LABEL_ALIGN_NONE
@ UI_BUT_LABEL_ALIGN_COLUMN
void uiItemFullO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, struct IDProperty *properties, int context, int flag, struct PointerRNA *r_opptr)
void UI_but_func_operator_search(uiBut *but)
void UI_popup_block_invoke(struct bContext *C, uiBlockCreateFunc func, void *arg, void(*arg_free)(void *arg))
void UI_popup_block_invoke_ex(struct bContext *C, uiBlockCreateFunc func, void *arg, void(*arg_free)(void *arg), bool can_refresh)
uiBut * uiDefSearchButO_ptr(uiBlock *block, struct wmOperatorType *ot, struct IDProperty *properties, void *arg, int retval, int icon, int maxlen, int x, int y, short width, short height, float a1, float a2, const char *tip)
Definition: interface.c:6783
#define UI_MAX_DRAW_STR
Definition: UI_interface.h:90
void UI_popup_block_ex(struct bContext *C, uiBlockCreateFunc func, uiBlockHandleFunc popup_func, uiBlockCancelFunc cancel_func, void *arg, struct wmOperator *op)
void UI_block_func_set(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2)
Definition: interface.c:6259
@ UI_BLOCK_SEARCH_MENU
Definition: UI_interface.h:152
@ UI_BLOCK_NUMSELECT
Definition: UI_interface.h:143
@ UI_BLOCK_LOOP
Definition: UI_interface.h:140
@ UI_BLOCK_MOVEMOUSE_QUIT
Definition: UI_interface.h:148
@ UI_BLOCK_KEEP_OPEN
Definition: UI_interface.h:149
uiLayout * UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, const struct uiStyle *style)
void UI_but_func_set(uiBut *but, uiButHandleFunc func, void *arg1, void *arg2)
Definition: interface.c:6294
@ UI_RETURN_OK
Definition: UI_interface.h:178
int void UI_popup_menu_retval_set(const uiBlock *block, const int retval, const bool enable)
uiBlock * UI_block_begin(const struct bContext *C, struct ARegion *region, const char *name, eUIEmbossType emboss)
void UI_popup_menu_end(struct bContext *C, struct uiPopupMenu *pup)
uiBut * uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x, int y, short width, short height, float a1, float a2, const char *tip)
Definition: interface.c:6573
void UI_but_focus_on_enter_event(struct wmWindow *win, uiBut *but)
Definition: interface.c:6850
@ UI_TEMPLATE_OP_PROPS_SHOW_TITLE
int UI_popover_panel_invoke(struct bContext *C, const char *idname, bool keep_open, struct ReportList *reports)
#define UI_UNIT_X
@ UI_LAYOUT_VERTICAL
void UI_block_flag_enable(uiBlock *block, int flag)
Definition: interface.c:6067
@ UI_BTYPE_BUT
Definition: UI_interface.h:334
@ UI_BTYPE_LABEL
Definition: UI_interface.h:358
@ UI_BLOCK_THEME_STYLE_REGULAR
Definition: UI_interface.h:670
@ UI_BLOCK_THEME_STYLE_POPUP
Definition: UI_interface.h:671
int UI_popup_menu_invoke(struct bContext *C, const char *idname, struct ReportList *reports) ATTR_NONNULL(1
void UI_but_flag_enable(uiBut *but, int flag)
Definition: interface.c:6077
uiPopupMenu * UI_popup_menu_begin(struct bContext *C, const char *title, int icon) ATTR_NONNULL()
int UI_pie_menu_invoke(struct bContext *C, const char *idname, const struct wmEvent *event)
bool UI_but_online_manual_id_from_active(const struct bContext *C, char *r_str, size_t maxlength) ATTR_WARN_UNUSED_RESULT
int UI_icon_color_from_collection(const struct Collection *collection)
void UI_icon_render_id(const struct bContext *C, struct Scene *scene, struct ID *id, const enum eIconSizes size, const bool use_job)
@ TH_TEXT_HI
Definition: UI_resources.h:59
void UI_GetThemeColor4fv(int colorid, float col[4])
Definition: resources.c:1199
@ WM_JOB_TYPE_ANY
Definition: WM_api.h:734
#define NC_WINDOW
Definition: WM_types.h:277
@ OPTYPE_INTERNAL
Definition: WM_types.h:175
@ OPTYPE_BLOCKING
Definition: WM_types.h:157
@ OPTYPE_UNDO
Definition: WM_types.h:155
@ OPTYPE_REGISTER
Definition: WM_types.h:153
#define NC_WM
Definition: WM_types.h:276
void(* wmPaintCursorDraw)(struct bContext *C, int, int, void *customdata)
Definition: WM_types.h:869
@ WM_OP_INVOKE_REGION_WIN
Definition: WM_types.h:198
@ WM_OP_EXEC_REGION_WIN
Definition: WM_types.h:205
@ WM_OP_EXEC_DEFAULT
Definition: WM_types.h:204
#define KM_PRESS
Definition: WM_types.h:242
#define ND_XR_DATA_CHANGED
Definition: WM_types.h:317
struct CLG_LogRef * WM_LOG_OPERATORS
#define KM_RELEASE
Definition: WM_types.h:243
unsigned int U
Definition: btGjkEpa3.h:78
StackEntry * from
Scene scene
const Depsgraph * depsgraph
void * user_data
static CCL_NAMESPACE_BEGIN const double alpha
#define rot(x, k)
#define str(s)
uint pos
uint col
DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
#define GS(x)
Definition: iris.c:241
#define sinf(x)
#define cosf(x)
#define atan2f(x, y)
#define fabsf(x)
format
Definition: logImageCore.h:47
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void(* MEM_printmemlist_stats)(void)
Definition: mallocn.c:55
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static unsigned a[3]
Definition: RandGen.cpp:92
static void area(int d1, int d2, int e1, int e2, float weights[2])
vector snap(vector a, vector b)
Definition: node_math.h:72
return ret
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2941
void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
Definition: rna_access.c:2627
void RNA_property_int_ui_range(PointerRNA *ptr, PropertyRNA *prop, int *softmin, int *softmax, int *step)
Definition: rna_access.c:1375
bool RNA_property_array_check(PropertyRNA *prop)
Definition: rna_access.c:1223
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
Definition: rna_access.c:844
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
Definition: rna_access.c:3033
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:146
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
Definition: rna_access.c:6550
char * RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index, int max_prop_length)
Definition: rna_access.c:6996
bool RNA_struct_is_ID(const StructRNA *type)
Definition: rna_access.c:797
const char * RNA_property_identifier(const PropertyRNA *prop)
Definition: rna_access.c:1145
void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *softmin, float *softmax, float *step, float *precision)
Definition: rna_access.c:1466
char * RNA_pointer_as_string_keywords(bContext *C, PointerRNA *ptr, const bool as_function, const bool all_args, const bool nested_args, const int max_prop_length)
Definition: rna_access.c:6866
PropertyUnit RNA_property_unit(PropertyRNA *prop)
Definition: rna_access.c:1187
bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
Definition: rna_access.c:8030
bool RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, bool use_ghost)
Definition: rna_access.c:6645
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:6655
PropertyType RNA_property_type(PropertyRNA *prop)
Definition: rna_access.c:1155
char * RNA_path_struct_property_py(PointerRNA *ptr, PropertyRNA *prop, int index)
Definition: rna_access.c:6204
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
Definition: rna_access.c:6319
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3641
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:866
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2317
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2331
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2607
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
Definition: rna_access.c:6514
int RNA_int_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6308
void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value)
Definition: rna_access.c:3310
StructRNA * RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:1567
int RNA_property_flag(PropertyRNA *prop)
Definition: rna_access.c:1192
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
Definition: rna_access.c:2358
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6355
char * RNA_path_full_property_py(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, int index)
Definition: rna_access.c:6195
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:1218
bool RNA_enum_description(const EnumPropertyItem *item, const int value, const char **r_description)
Definition: rna_access.c:1864
void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
Definition: rna_access.c:2964
char * RNA_pointer_as_string_id(bContext *C, PointerRNA *ptr)
Definition: rna_access.c:6724
PropertySubType RNA_property_subtype(PropertyRNA *prop)
Definition: rna_access.c:1160
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:6685
bool RNA_struct_idprops_unset(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:829
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6261
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6402
PropertyRNA * RNA_struct_iterator_property(StructRNA *type)
Definition: rna_access.c:771
bool RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
Definition: rna_access.c:5400
float RNA_property_float_get_default(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
Definition: rna_access.c:3216
const char * RNA_property_ui_name(const PropertyRNA *prop)
Definition: rna_access.c:2043
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
Definition: rna_access.c:3401
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen)
Definition: rna_access.c:6527
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3825
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3481
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3795
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
Definition: rna_define.c:4470
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1517
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
Definition: rna_define.c:4416
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3675
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1512
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3585
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3771
const EnumPropertyItem rna_enum_stereo3d_display_items[]
Definition: rna_scene.c:487
const EnumPropertyItem rna_enum_stereo3d_anaglyph_type_items[]
Definition: rna_scene.c:519
const EnumPropertyItem rna_enum_stereo3d_interlace_type_items[]
Definition: rna_scene.c:526
#define min(a, b)
Definition: sort.c:51
struct CurveMapping * curve
const char * identifier
Definition: RNA_types.h:446
const char * name
Definition: RNA_types.h:450
wmOperator * op
Definition: wm_operators.c:988
short flag
Definition: DNA_ID.h:72
int len
Definition: DNA_ID.h:84
char name[64]
Definition: DNA_ID.h:74
Definition: DNA_ID.h:273
int tag
Definition: DNA_ID.h:292
int us
Definition: DNA_ID.h:293
void * next
Definition: DNA_ID.h:274
char name[66]
Definition: DNA_ID.h:283
float * rect_float
void * data
Definition: DNA_listBase.h:42
struct LinkData * next
Definition: DNA_listBase.h:41
void * first
Definition: DNA_listBase.h:47
Definition: BKE_main.h:116
ListBase scenes
Definition: BKE_main.h:146
ListBase wm
Definition: BKE_main.h:175
ListBase textures
Definition: BKE_main.h:153
ListBase lights
Definition: BKE_main.h:156
ListBase materials
Definition: BKE_main.h:152
ListBase worlds
Definition: BKE_main.h:160
ListBase screens
Definition: BKE_main.h:161
ListBase collections
Definition: BKE_main.h:167
ListBase images
Definition: BKE_main.h:154
ListBase objects
Definition: BKE_main.h:148
char label[BKE_ST_MAXNAME]
Definition: BKE_screen.h:376
char translation_context[BKE_ST_MAXNAME]
Definition: BKE_screen.h:377
short idx_max
Definition: ED_numinput.h:34
short val_flag[NUM_MAX_ELEMENTS]
Definition: ED_numinput.h:43
int unit_sys
Definition: ED_numinput.h:35
int unit_type[NUM_MAX_ELEMENTS]
Definition: ED_numinput.h:37
char translation_context[BKE_ST_MAXNAME]
Definition: BKE_screen.h:244
char label[BKE_ST_MAXNAME]
Definition: BKE_screen.h:242
struct StructRNA * type
Definition: RNA_types.h:51
void * data
Definition: RNA_types.h:52
struct ID * owner_id
Definition: RNA_types.h:50
PropertySubType subtype
int initial_mouse[2]
GPUTexture * texture
PropertyRNA * prop
PointerRNA fill_col_override_test_ptr
PropertyRNA * zoom_prop
PointerRNA fill_col_ptr
NumInput num_input
ListBase orig_paintcursors
PropertyRNA * rot_prop
PointerRNA ptr
PointerRNA rot_ptr
PropertyRNA * col_prop
PropertyRNA * fill_col_override_test_prop
bool use_secondary_tex
PropertyRNA * fill_col_override_prop
PointerRNA fill_col_override_ptr
PointerRNA col_ptr
PropertyType type
PointerRNA zoom_ptr
PropertyRNA * fill_col_prop
StructRNA * image_id_srna
PointerRNA image_id_ptr
struct RenderData r
struct UnitSettings unit
enum SearchPopupInit_Data::@1162 search_type
bDopeSheet ads
struct bDopeSheet * ads
struct bDopeSheet * ads
View3D_Runtime runtime
View3DShading shading
ListBase areabase
uiFontStyle widget
short val
Definition: WM_types.h:579
int mval[2]
Definition: WM_types.h:583
short type
Definition: WM_types.h:577
const void * modal_items
wmOperator * op
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:752
const char * name
Definition: WM_types.h:721
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:768
struct IDProperty * last_properties
Definition: WM_types.h:805
const char * idname
Definition: WM_types.h:723
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:776
void(* cancel)(struct bContext *, struct wmOperator *)
Definition: WM_types.h:760
struct StructRNA * srna
Definition: WM_types.h:802
const char * translation_context
Definition: WM_types.h:724
const char * description
Definition: WM_types.h:726
void(* ui)(struct bContext *, struct wmOperator *)
Definition: WM_types.h:787
bool(* check)(struct bContext *, struct wmOperator *)
Definition: WM_types.h:744
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:736
PropertyRNA * prop
Definition: WM_types.h:814
const char *(* get_name)(struct wmOperatorType *, struct PointerRNA *)
Definition: WM_types.h:793
ListBase macro
Definition: WM_types.h:817
struct ReportList * reports
IDProperty * properties
struct wmOperator * next
struct wmOperatorType * type
struct PointerRNA * ptr
void(* draw)(bContext *C, int, int, void *customdata)
Definition: wm.h:40
void * customdata
Definition: wm.h:37
bool(* poll)(struct bContext *C)
Definition: wm.h:39
short region_type
Definition: wm.h:43
short space_type
Definition: wm.h:42
double PIL_check_seconds_timer(void)
Definition: time.c:80
float max
ccl_device_inline float3 ceil(const float3 &a)
#define G(x, y, z)
uint len
void wm_operator_register(bContext *C, wmOperator *op)
Definition: wm.c:376
void WM_operator_free(wmOperator *op)
Definition: wm.c:292
void WM_cursor_wait(bool val)
Definition: wm_cursors.c:226
void wm_draw_region_test(bContext *C, ScrArea *area, ARegion *region)
Definition: wm_draw.c:1094
void wm_draw_update(bContext *C)
Definition: wm_draw.c:1033
bool WM_event_drag_test_with_delta(const wmEvent *event, const int drag_delta[2])
int WM_userdef_event_type_from_keymap_type(int kmitype)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_main_add_notifier(unsigned int type, void *reference)
void WM_event_add_fileselect(bContext *C, wmOperator *op)
void wm_event_do_refresh_wm_and_depsgraph(bContext *C)
int WM_operator_repeat(bContext *C, wmOperator *op)
int WM_operator_call_notest(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
int WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, short context, PointerRNA *properties)
int WM_operator_call_ex(bContext *C, wmOperator *op, const bool store)
@ RIGHTMOUSE
@ EVT_PADENTER
@ EVT_SPACEKEY
@ MOUSEMOVE
@ LEFTMOUSE
@ EVT_ESCKEY
@ INBETWEEN_MOUSEMOVE
@ EVT_RIGHTSHIFTKEY
@ EVT_LEFTSHIFTKEY
@ EVT_RETKEY
@ GESTURE_MODAL_CIRCLE_SIZE
@ GESTURE_MODAL_OUT
@ GESTURE_MODAL_SNAP
@ GESTURE_MODAL_CIRCLE_ADD
@ GESTURE_MODAL_CANCEL
@ GESTURE_MODAL_CIRCLE_SUB
@ GESTURE_MODAL_MOVE
@ GESTURE_MODAL_NOP
@ GESTURE_MODAL_DESELECT
@ GESTURE_MODAL_CONFIRM
@ GESTURE_MODAL_IN
@ GESTURE_MODAL_FLIP
@ GESTURE_MODAL_BEGIN
@ GESTURE_MODAL_SELECT
void WM_OT_read_history(wmOperatorType *ot)
Definition: wm_files.c:2041
void WM_OT_save_as_mainfile(wmOperatorType *ot)
Definition: wm_files.c:2877
void WM_OT_open_mainfile(wmOperatorType *ot)
Definition: wm_files.c:2531
PointerRNA * ptr
Definition: wm_files.c:3157
void WM_OT_recover_last_session(wmOperatorType *ot)
Definition: wm_files.c:2648
void WM_OT_read_userpref(wmOperatorType *ot)
Definition: wm_files.c:2006
void WM_OT_save_homefile(wmOperatorType *ot)
Definition: wm_files.c:1855
void WM_OT_read_factory_userpref(wmOperatorType *ot)
Definition: wm_files.c:2016
void WM_OT_save_mainfile(wmOperatorType *ot)
Definition: wm_files.c:2950
void WM_OT_recover_auto_save(wmOperatorType *ot)
Definition: wm_files.c:2707
void WM_OT_read_factory_settings(wmOperatorType *ot)
Definition: wm_files.c:2225
wmOperatorType * ot
Definition: wm_files.c:3156
void WM_OT_read_homefile(wmOperatorType *ot)
Definition: wm_files.c:2191
void WM_OT_save_userpref(wmOperatorType *ot)
Definition: wm_files.c:1884
void WM_OT_revert_mainfile(wmOperatorType *ot)
Definition: wm_files.c:2594
void GIZMOGROUP_OT_gizmo_select(wmOperatorType *ot)
void GIZMOGROUP_OT_gizmo_tweak(wmOperatorType *ot)
void wm_gizmos_keymap(wmKeyConfig *keyconf)
void wm_exit_schedule_delayed(const bContext *C)
Definition: wm_init_exit.c:457
bool WM_jobs_test(wmWindowManager *wm, void *owner, int job_type)
Definition: wm_jobs.c:223
wmKeyMap * WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)
Definition: wm_keymap.c:914
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition: wm_keymap.c:852
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
Definition: wm_keymap.c:985
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
Definition: wm_keymap.c:888
void WM_keymap_fix_linking(void)
MenuType * WM_menutype_find(const char *idname, bool quiet)
Definition: wm_menu_type.c:44
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
const char * WM_operatortype_name(struct wmOperatorType *ot, struct PointerRNA *properties)
char * WM_prop_pystring_assign(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index)
Definition: wm_operators.c:559
static void WM_OT_call_menu_pie(wmOperatorType *ot)
static void gesture_box_modal_keymap(wmKeyConfig *keyconf)
static int wm_exit_blender_exec(bContext *C, wmOperator *UNUSED(op))
const EnumPropertyItem * RNA_mask_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
#define CTX_TEST_PTR_ID_CAST(C, member, member_full, cast, idptr)
static void WM_OT_search_menu(wmOperatorType *ot)
IDProperty * WM_operator_last_properties_ensure_idprops(wmOperatorType *ot)
@ eRTDrawWindowSwap
@ eRTAnimationStep
@ eRTDrawRegionSwap
@ eRTDrawWindow
@ eRTUndo
@ eRTDrawRegion
@ eRTAnimationPlay
#define ID_CAST_SCENEWORLD(id_pt)
static const EnumPropertyItem * rna_id_itemf(bool *r_free, ID *id, bool local, bool(*filter_ids)(const ID *id, void *user_data), void *user_data)
static void WM_OT_doc_view_manual_ui_context(wmOperatorType *ot)
bool WM_operator_pystring_abbreviate(char *str, int str_len_max)
Definition: wm_operators.c:311
static const char * wm_context_member_from_ptr(bContext *C, const PointerRNA *ptr)
Definition: wm_operators.c:405
static char * wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index)
Definition: wm_operators.c:537
static uiBlock * wm_block_search_menu(bContext *C, ARegion *region, void *userdata)
int WM_operator_confirm(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static void radial_control_paint_tex(RadialControl *rc, float radius, float alpha)
const EnumPropertyItem * RNA_collection_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
int WM_operator_redo_popup(bContext *C, wmOperator *op)
static void wm_block_redo_cancel_cb(bContext *C, void *arg_op)
int WM_operator_props_popup_call(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int wm_call_panel_exec(bContext *C, wmOperator *op)
static void gesture_straightline_modal_keymap(wmKeyConfig *keyconf)
static void radial_control_set_tex(RadialControl *rc)
static void gesture_zoom_border_modal_keymap(wmKeyConfig *keyconf)
static void wm_block_redo_cb(bContext *C, void *arg_op, int UNUSED(arg_event))
static void radial_control_cancel(bContext *C, wmOperator *op)
static void previews_id_ensure(bContext *C, Scene *scene, ID *id)
static int wm_debug_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
int WM_operator_ui_popup(bContext *C, wmOperator *op, int width)
static uiBlock * wm_block_dialog_create(bContext *C, ARegion *region, void *userData)
void wm_window_keymap(wmKeyConfig *keyconf)
static void redraw_timer_step(bContext *C, Scene *scene, struct Depsgraph *depsgraph, wmWindow *win, ScrArea *area, ARegion *region, const int type, const int cfra)
static int wm_operator_props_popup_ex(bContext *C, wmOperator *op, const bool do_call, const bool do_redo)
void WM_operator_last_properties_ensure(wmOperatorType *ot, PointerRNA *ptr)
static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op, const char *name, PointerRNA *r_ptr, PropertyRNA **r_prop, int req_length, RCPropFlags flags)
static void WM_OT_memory_statistics(wmOperatorType *ot)
#define CTX_TEST_PTR_ID(C, member, idptr)
static int radial_control_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int doc_view_manual_ui_context_exec(bContext *C, wmOperator *UNUSED(op))
#define ID_CAST_OBDATA(id_pt)
static int wm_call_pie_menu_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void radial_control_update_header(wmOperator *op, bContext *C)
static void wm_operator_ui_popup_cancel(struct bContext *C, void *userData)
int WM_operator_confirm_or_exec(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
const EnumPropertyItem * RNA_collection_local_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
static const char * wm_call_panel_get_name(wmOperatorType *ot, PointerRNA *ptr)
int WM_menu_invoke_ex(bContext *C, wmOperator *op, int opcontext)
Definition: wm_operators.c:950
void WM_operator_properties_reset(wmOperator *op)
Definition: wm_operators.c:685
static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void *customdata)
static void WM_OT_debug_menu(wmOperatorType *ot)
char * WM_operator_pystring(bContext *C, wmOperator *op, const bool all_args, const bool macro_args)
Definition: wm_operators.c:303
static int previews_clear_exec(bContext *C, wmOperator *op)
#define ID_CAST_OBMATACT(id_pt)
static void gesture_lasso_modal_keymap(wmKeyConfig *keyconf)
static void WM_OT_radial_control(wmOperatorType *ot)
int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message)
static bool rna_id_enum_filter_single(const ID *id, void *user_data)
bool WM_operator_last_properties_store(wmOperator *op)
Definition: wm_operators.c:782
void WM_operator_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *opstring)
Definition: wm_operators.c:605
static int wm_exit_blender_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
#define WM_RADIAL_CONTROL_DISPLAY_WIDTH
bool WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const struct ImageFormatData *im_format)
int WM_operator_props_popup_confirm(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
struct PreviewsIDEnsureData PreviewsIDEnsureData
static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *event)
static int radial_control_get_properties(bContext *C, wmOperator *op)
static int wm_call_pie_menu_exec(bContext *C, wmOperator *op)
void wm_operatortypes_register(void)
static void WM_OT_call_menu(wmOperatorType *ot)
static void wm_operator_ui_popup_ok(struct bContext *C, void *arg, int retval)
static int wm_call_menu_exec(bContext *C, wmOperator *op)
bool WM_operator_winactive(bContext *C)
const EnumPropertyItem * RNA_scene_without_active_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
int WM_operator_smooth_viewtx_get(const wmOperator *op)
Definition: wm_operators.c:944
bool WM_operator_check_ui_enabled(const bContext *C, const char *idname)
bool WM_paint_cursor_end(wmPaintCursor *handle)
static int previews_id_ensure_callback(LibraryIDLinkCallbackData *cb_data)
int WM_enum_search_invoke_previews(bContext *C, wmOperator *op, short prv_cols, short prv_rows)
void WM_paint_cursor_remove_by_type(wmWindowManager *wm, void *draw_fn, void(*free)(void *))
char * WM_operator_pystring_ex(bContext *C, wmOperator *op, const bool all_args, const bool macro_args, wmOperatorType *ot, PointerRNA *opptr)
Definition: wm_operators.c:228
static uiBlock * wm_block_create_redo(bContext *C, ARegion *region, void *arg_op)
int WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static void WM_OT_redraw_timer(wmOperatorType *ot)
const EnumPropertyItem * RNA_scene_local_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
static void WM_OT_search_operator(wmOperatorType *ot)
static void radial_control_set_initial_mouse(RadialControl *rc, const wmEvent *event)
static int wm_search_menu_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
const EnumPropertyItem * RNA_movieclip_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
void WM_operator_bl_idname(char *to, const char *from)
Definition: wm_operators.c:144
static void WM_OT_previews_clear(wmOperatorType *ot)
static uiBlock * wm_operator_ui_create(bContext *C, ARegion *region, void *userData)
static bool wm_operator_winactive_normal(bContext *C)
int WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
const EnumPropertyItem * RNA_mask_local_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
bool WM_operator_last_properties_init(wmOperator *op)
Definition: wm_operators.c:767
static void WM_OT_stereo3d_set(wmOperatorType *ot)
static void redraw_timer_window_swap(bContext *C)
int WM_generic_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: wm_operators.c:905
static void WM_OT_call_panel(wmOperatorType *ot)
void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot)
Definition: wm_operators.c:584
static void WM_OT_quit_blender(wmOperatorType *ot)
int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width)
bool WM_operator_properties_default(PointerRNA *ptr, const bool do_update)
Definition: wm_operators.c:657
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: wm_operators.c:982
static const EnumPropertyItem preview_id_type_items[]
static void WM_OT_window_new_main(wmOperatorType *ot)
static bool operator_last_properties_init_impl(wmOperator *op, IDProperty *last_properties)
Definition: wm_operators.c:729
static int wm_operator_defaults_exec(bContext *C, wmOperator *op)
int WM_operator_confirm_message_ex(bContext *C, wmOperator *op, const char *title, const int icon, const char *message, const short opcontext)
static int previews_ensure_exec(bContext *C, wmOperator *UNUSED(op))
static void WM_OT_window_new(wmOperatorType *ot)
static int redraw_timer_exec(bContext *C, wmOperator *op)
void WM_operator_properties_clear(PointerRNA *ptr)
Definition: wm_operators.c:702
RCPropFlags
@ RC_PROP_REQUIRE_FLOAT
@ RC_PROP_REQUIRE_BOOL
@ RC_PROP_ALLOW_MISSING
#define TEST_PTR_DATA_TYPE(member, rna_type, rna_ptr, dataptr_cmp)
static const char * wm_call_menu_get_name(wmOperatorType *ot, PointerRNA *ptr)
static int wm_debug_menu_exec(bContext *C, wmOperator *op)
static int memory_statistics_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
int WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
Definition: wm_operators.c:838
static void WM_OT_previews_ensure(wmOperatorType *ot)
ID * WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short idcode)
static uint preview_filter_to_idfilter(enum PreviewFilterID filter)
static const EnumPropertyItem redraw_timer_type_items[]
static void gesture_circle_modal_keymap(wmKeyConfig *keyconf)
void WM_operator_py_idname(char *to, const char *from)
Definition: wm_operators.c:123
static void radial_control_set_value(RadialControl *rc, float val)
void WM_operator_properties_create(PointerRNA *ptr, const char *opstring)
Definition: wm_operators.c:590
int WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot)
wmPaintCursor * WM_paint_cursor_activate(short space_type, short region_type, bool(*poll)(bContext *C), wmPaintCursorDraw draw, void *customdata)
static void dialog_exec_cb(bContext *C, void *arg1, void *arg2)
#define WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE
const EnumPropertyItem * RNA_action_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
static void radial_control_paint_curve(uint pos, Brush *br, float radius, int line_segments)
static void WM_OT_window_close(wmOperatorType *ot)
void WM_operator_properties_free(PointerRNA *ptr)
Definition: wm_operators.c:711
const EnumPropertyItem * RNA_scene_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
const char * WM_context_member_from_ptr(bContext *C, const PointerRNA *ptr)
Definition: wm_operators.c:554
const EnumPropertyItem * RNA_image_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
PreviewFilterID
@ PREVIEW_FILTER_WORLD
@ PREVIEW_FILTER_TEXTURE
@ PREVIEW_FILTER_GEOMETRY
@ PREVIEW_FILTER_LIGHT
@ PREVIEW_FILTER_MATERIAL
@ PREVIEW_FILTER_COLLECTION
@ PREVIEW_FILTER_ALL
@ PREVIEW_FILTER_IMAGE
@ PREVIEW_FILTER_OBJECT
@ PREVIEW_FILTER_SCENE
@ PREVIEW_FILTER_SHADING
void WM_operator_properties_sanitize(PointerRNA *ptr, const bool no_context)
Definition: wm_operators.c:620
bool WM_operator_py_idname_ok_or_report(ReportList *reports, const char *classname, const char *idname)
Definition: wm_operators.c:171
#define WM_RADIAL_MAX_STR
#define WM_RADIAL_CONTROL_DISPLAY_SIZE
void WM_operator_view3d_unit_defaults(struct bContext *C, struct wmOperator *op)
Definition: wm_operators.c:915
static int wm_search_menu_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmOperator * WM_operator_last_redo(const bContext *C)
static void WM_OT_operator_defaults(wmOperatorType *ot)
const EnumPropertyItem * RNA_movieclip_local_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
static uiBlock * wm_enum_search_menu(bContext *C, ARegion *region, void *arg)
Definition: wm_operators.c:995
struct wmOpPopUp wmOpPopUp
const EnumPropertyItem * RNA_image_local_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
PanelType * WM_paneltype_find(const char *idname, bool quiet)
Definition: wm_panel_type.c:42
void WM_OT_splash_about(wmOperatorType *ot)
void WM_OT_splash(wmOperatorType *ot)
int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
Definition: wm_stereo.c:274
bool wm_stereo3d_set_check(bContext *UNUSED(C), wmOperator *UNUSED(op))
Definition: wm_stereo.c:409
int wm_stereo3d_set_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: wm_stereo.c:362
void wm_stereo3d_set_draw(bContext *UNUSED(C), wmOperator *op)
Definition: wm_stereo.c:372
void wm_stereo3d_set_cancel(bContext *UNUSED(C), wmOperator *op)
Definition: wm_stereo.c:417
int wm_window_new_exec(bContext *C, wmOperator *UNUSED(op))
Definition: wm_window.c:914
int wm_window_close_exec(bContext *C, wmOperator *UNUSED(op))
Definition: wm_window.c:906
Scene * WM_windows_scene_get_from_screen(const wmWindowManager *wm, const bScreen *screen)
Definition: wm_window.c:2217
int wm_window_new_main_exec(bContext *C, wmOperator *UNUSED(op))
Definition: wm_window.c:933
void wm_quit_with_optional_confirmation_prompt(bContext *C, wmWindow *win)
Definition: wm_window.c:362
bScreen * WM_window_get_active_screen(const wmWindow *win)
Definition: wm_window.c:2372
void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win)
Definition: wm_window.c:1054
int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op))
Definition: wm_window.c:943
bool wm_xr_init(wmWindowManager *wm)
Definition: wm_xr.c:64
void wm_xr_session_toggle(wmWindowManager *wm, wmWindow *session_root_win, wmXrSessionExitFn session_exit_fn)
Definition: wm_xr_session.c:74
bool WM_xr_session_exists(const wmXrData *xr)
Definition: wm_xr_session.c:99