Blender  V3.3
interface_ops.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2009 Blender Foundation. All rights reserved. */
3 
8 #include <string.h>
9 
10 #include "MEM_guardedalloc.h"
11 
12 #include "DNA_armature_types.h"
13 #include "DNA_material_types.h"
14 #include "DNA_modifier_types.h" /* for handling geometry nodes properties */
15 #include "DNA_object_types.h" /* for OB_DATA_SUPPORT_ID */
16 #include "DNA_screen_types.h"
17 #include "DNA_text_types.h"
18 
19 #include "BLI_blenlib.h"
20 #include "BLI_math_color.h"
21 
22 #include "BLF_api.h"
23 #include "BLT_lang.h"
24 #include "BLT_translation.h"
25 
26 #include "BKE_context.h"
27 #include "BKE_global.h"
28 #include "BKE_idprop.h"
29 #include "BKE_layer.h"
30 #include "BKE_lib_id.h"
31 #include "BKE_lib_override.h"
32 #include "BKE_lib_remap.h"
33 #include "BKE_material.h"
34 #include "BKE_node.h"
35 #include "BKE_report.h"
36 #include "BKE_screen.h"
37 #include "BKE_text.h"
38 
39 #include "IMB_colormanagement.h"
40 
41 #include "DEG_depsgraph.h"
42 
43 #include "RNA_access.h"
44 #include "RNA_define.h"
45 #include "RNA_path.h"
46 #include "RNA_prototypes.h"
47 #include "RNA_types.h"
48 
49 #include "UI_interface.h"
50 
51 #include "interface_intern.h"
52 
53 #include "WM_api.h"
54 #include "WM_types.h"
55 
56 #include "ED_object.h"
57 #include "ED_paint.h"
58 
59 /* for Copy As Driver */
60 #include "ED_keyframing.h"
61 
62 /* only for UI_OT_editsource */
63 #include "BKE_main.h"
64 #include "BLI_ghash.h"
65 #include "ED_screen.h"
66 #include "ED_text.h"
67 
68 /* -------------------------------------------------------------------- */
84 {
85  ED_region_do_layout(C, region);
87  ED_region_do_draw(C, region);
89  region->do_draw = false;
90 }
91 
94 /* -------------------------------------------------------------------- */
99 {
100  PointerRNA ptr;
101  PropertyRNA *prop;
102  char *path;
103  int index;
104 
105  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
106 
107  if (ptr.owner_id && ptr.data && prop) {
108  path = RNA_path_from_ID_to_property(&ptr, prop);
109 
110  if (path) {
111  MEM_freeN(path);
112  return true;
113  }
114  }
115 
116  return false;
117 }
118 
120 {
121  Main *bmain = CTX_data_main(C);
122  PointerRNA ptr;
123  PropertyRNA *prop;
124  char *path;
125  int index;
126  ID *id;
127 
128  const bool full_path = RNA_boolean_get(op->ptr, "full_path");
129 
130  /* try to create driver using property retrieved from UI */
131  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
132 
133  if (ptr.owner_id != NULL) {
134  if (full_path) {
135  if (prop) {
136  path = RNA_path_full_property_py_ex(bmain, &ptr, prop, index, true);
137  }
138  else {
139  path = RNA_path_full_struct_py(bmain, &ptr);
140  }
141  }
142  else {
143  path = RNA_path_from_real_ID_to_property_index(bmain, &ptr, prop, 0, -1, &id);
144 
145  if (!path) {
146  path = RNA_path_from_ID_to_property(&ptr, prop);
147  }
148  }
149 
150  if (path) {
151  WM_clipboard_text_set(path, false);
152  MEM_freeN(path);
153  return OPERATOR_FINISHED;
154  }
155  }
156 
157  return OPERATOR_CANCELLED;
158 }
159 
161 {
162  PropertyRNA *prop;
163 
164  /* identifiers */
165  ot->name = "Copy Data Path";
166  ot->idname = "UI_OT_copy_data_path_button";
167  ot->description = "Copy the RNA data path for this property to the clipboard";
168 
169  /* callbacks */
172 
173  /* flags */
175 
176  /* properties */
177  prop = RNA_def_boolean(ot->srna, "full_path", false, "full_path", "Copy full data path");
179 }
180 
183 /* -------------------------------------------------------------------- */
188 {
189  PointerRNA ptr;
190  PropertyRNA *prop;
191  char *path;
192  int index;
193 
194  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
195 
196  if (ptr.owner_id && ptr.data && prop &&
198  (index >= 0 || !RNA_property_array_check(prop))) {
199  path = RNA_path_from_ID_to_property(&ptr, prop);
200 
201  if (path) {
202  MEM_freeN(path);
203  return true;
204  }
205  }
206 
207  return false;
208 }
209 
211 {
212  Main *bmain = CTX_data_main(C);
213  PointerRNA ptr;
214  PropertyRNA *prop;
215  int index;
216 
217  /* try to create driver using property retrieved from UI */
218  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
219 
220  if (ptr.owner_id && ptr.data && prop) {
221  ID *id;
222  const int dim = RNA_property_array_dimension(&ptr, prop, NULL);
223  char *path = RNA_path_from_real_ID_to_property_index(bmain, &ptr, prop, dim, index, &id);
224 
225  if (path) {
227  MEM_freeN(path);
228  return OPERATOR_FINISHED;
229  }
230 
231  BKE_reportf(op->reports, RPT_ERROR, "Could not compute a valid data path");
232  return OPERATOR_CANCELLED;
233  }
234 
235  return OPERATOR_CANCELLED;
236 }
237 
239 {
240  /* identifiers */
241  ot->name = "Copy as New Driver";
242  ot->idname = "UI_OT_copy_as_driver_button";
243  ot->description =
244  "Create a new driver with this property as input, and copy it to the "
245  "clipboard. Use Paste Driver to add it to the target property, or Paste "
246  "Driver Variables to extend an existing driver";
247 
248  /* callbacks */
251 
252  /* flags */
254 }
255 
258 /* -------------------------------------------------------------------- */
263 {
265 
266  if (but && (but->optype != NULL)) {
267  return 1;
268  }
269 
270  return 0;
271 }
272 
274 {
276 
277  if (but && (but->optype != NULL)) {
278  PointerRNA *opptr;
279  char *str;
280  opptr = UI_but_operator_ptr_get(but); /* allocated when needed, the button owns it */
281 
282  str = WM_operator_pystring_ex(C, NULL, false, true, but->optype, opptr);
283 
285 
286  MEM_freeN(str);
287 
288  return OPERATOR_FINISHED;
289  }
290 
291  return OPERATOR_CANCELLED;
292 }
293 
295 {
296  /* identifiers */
297  ot->name = "Copy Python Command";
298  ot->idname = "UI_OT_copy_python_command_button";
299  ot->description = "Copy the Python command matching this button";
300 
301  /* callbacks */
304 
305  /* flags */
307 }
308 
311 /* -------------------------------------------------------------------- */
316 {
317  ID *id = ptr->owner_id;
318 
319  /* perform updates required for this property */
320  RNA_property_update(C, ptr, prop);
321 
322  /* as if we pressed the button */
324 
325  /* Since we don't want to undo _all_ edits to settings, eg window
326  * edits on the screen or on operator settings.
327  * it might be better to move undo's inline - campbell */
328  if (id && ID_CHECK_UNDO(id)) {
329  /* do nothing, go ahead with undo */
330  return OPERATOR_FINISHED;
331  }
332  return OPERATOR_CANCELLED;
333 }
334 
336  PointerRNA *ptr,
337  PropertyRNA *prop)
338 {
339  /* Perform updates required for this property. */
340  RNA_property_update(C, ptr, prop);
341 
342  /* As if we pressed the button. */
344 
345  return OPERATOR_FINISHED;
346 }
347 
349 {
350  PointerRNA ptr;
351  PropertyRNA *prop;
352  int index;
353 
354  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
355 
356  return (ptr.data && prop && RNA_property_editable(&ptr, prop));
357 }
358 
360 {
361  PointerRNA ptr;
362  PropertyRNA *prop;
363  int index;
364  const bool all = RNA_boolean_get(op->ptr, "all");
365 
366  /* try to reset the nominated setting to its default value */
367  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
368 
369  /* if there is a valid property that is editable... */
370  if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
371  if (RNA_property_reset(&ptr, prop, (all) ? -1 : index)) {
373  }
374  }
375 
376  return OPERATOR_CANCELLED;
377 }
378 
380 {
381  /* identifiers */
382  ot->name = "Reset to Default Value";
383  ot->idname = "UI_OT_reset_default_button";
384  ot->description = "Reset this property's value to its default value";
385 
386  /* callbacks */
389 
390  /* flags */
391  /* Don't set #OPTYPE_UNDO because #operator_button_property_finish_with_undo
392  * is responsible for the undo push. */
393  ot->flag = 0;
394 
395  /* properties */
396  RNA_def_boolean(ot->srna, "all", 1, "All", "Reset to default values all elements of the array");
397 }
398 
401 /* -------------------------------------------------------------------- */
406 {
407  PointerRNA ptr;
408  PropertyRNA *prop;
409  int index;
410 
411  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
412 
413  if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
414  const PropertyType type = RNA_property_type(prop);
415 
416  return RNA_property_is_idprop(prop) && !RNA_property_array_check(prop) &&
418  }
419 
420  return false;
421 }
422 
424 {
425  PointerRNA ptr;
426  PropertyRNA *prop;
427  int index;
428 
429  /* try to reset the nominated setting to its default value */
430  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
431 
432  /* if there is a valid property that is editable... */
433  if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
434  if (RNA_property_assign_default(&ptr, prop)) {
435  return operator_button_property_finish(C, &ptr, prop);
436  }
437  }
438 
439  return OPERATOR_CANCELLED;
440 }
441 
443 {
444  /* identifiers */
445  ot->name = "Assign Value as Default";
446  ot->idname = "UI_OT_assign_default_button";
447  ot->description = "Set this property's current value as the new default";
448 
449  /* callbacks */
452 
453  /* flags */
454  ot->flag = OPTYPE_UNDO;
455 }
456 
459 /* -------------------------------------------------------------------- */
464 {
465  PointerRNA ptr;
466  PropertyRNA *prop;
467  int index;
468 
469  /* try to unset the nominated property */
470  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
471 
472  /* if there is a valid property that is editable... */
473  if (ptr.data && prop && RNA_property_editable(&ptr, prop) &&
474  /* RNA_property_is_idprop(prop) && */
475  RNA_property_is_set(&ptr, prop)) {
476  RNA_property_unset(&ptr, prop);
477  return operator_button_property_finish(C, &ptr, prop);
478  }
479 
480  return OPERATOR_CANCELLED;
481 }
482 
484 {
485  /* identifiers */
486  ot->name = "Unset Property";
487  ot->idname = "UI_OT_unset_property_button";
488  ot->description = "Clear the property and use default or generated value in operators";
489 
490  /* callbacks */
493 
494  /* flags */
495  ot->flag = OPTYPE_UNDO;
496 }
497 
500 /* -------------------------------------------------------------------- */
504 /* Note that we use different values for UI/UX than 'real' override operations, user does not care
505  * whether it's added or removed for the differential operation e.g. */
506 enum {
509  UIOverride_Type_Difference = 2, /* Add/subtract */
510  UIOverride_Type_Factor = 3, /* Multiply */
511  /* TODO: should/can we expose insert/remove ones for collections? Doubt it... */
512 };
513 
516  "NOOP",
517  0,
518  "NoOp",
519  "'No-Operation', place holder preventing automatic override to ever affect the property"},
521  "REPLACE",
522  0,
523  "Replace",
524  "Completely replace value from linked data by local one"},
526  "DIFFERENCE",
527  0,
528  "Difference",
529  "Store difference to linked data value"},
531  "FACTOR",
532  0,
533  "Factor",
534  "Store factor to linked data value (useful e.g. for scale)"},
535  {0, NULL, 0, NULL, NULL},
536 };
537 
539 {
540  PointerRNA ptr;
541  PropertyRNA *prop;
542  int index;
543 
544  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
545 
546  const uint override_status = RNA_property_override_library_status(
547  CTX_data_main(C), &ptr, prop, index);
548 
549  return (ptr.data && prop && (override_status & RNA_OVERRIDE_STATUS_OVERRIDABLE));
550 }
551 
553 {
554  PointerRNA ptr;
555  PropertyRNA *prop;
556  int index;
557  bool created;
558  const bool all = RNA_boolean_get(op->ptr, "all");
559  const int op_type = RNA_enum_get(op->ptr, "type");
560 
561  short operation;
562 
563  switch (op_type) {
565  operation = IDOVERRIDE_LIBRARY_OP_NOOP;
566  break;
568  operation = IDOVERRIDE_LIBRARY_OP_REPLACE;
569  break;
571  /* override code will automatically switch to subtract if needed. */
572  operation = IDOVERRIDE_LIBRARY_OP_ADD;
573  break;
575  operation = IDOVERRIDE_LIBRARY_OP_MULTIPLY;
576  break;
577  default:
578  operation = IDOVERRIDE_LIBRARY_OP_REPLACE;
579  BLI_assert(0);
580  break;
581  }
582 
583  /* try to reset the nominated setting to its default value */
584  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
585 
587 
588  if (all) {
589  index = -1;
590  }
591 
593  CTX_data_main(C), &ptr, prop, operation, index, true, NULL, &created);
594 
595  if (opop == NULL) {
596  /* Sometimes e.g. RNA cannot generate a path to the given property. */
597  BKE_reportf(op->reports, RPT_WARNING, "Failed to create the override operation");
598  return OPERATOR_CANCELLED;
599  }
600 
601  if (!created) {
602  opop->operation = operation;
603  }
604 
605  /* Outliner e.g. has to be aware of this change. */
607 
608  return operator_button_property_finish(C, &ptr, prop);
609 }
610 
612  wmOperator *op,
613  const wmEvent *UNUSED(event))
614 {
615 #if 0 /* Disabled for now */
617 #else
619  return override_type_set_button_exec(C, op);
620 #endif
621 }
622 
624 {
625  /* identifiers */
626  ot->name = "Define Override Type";
627  ot->idname = "UI_OT_override_type_set_button";
628  ot->description = "Create an override operation, or set the type of an existing one";
629 
630  /* callbacks */
634 
635  /* flags */
636  ot->flag = OPTYPE_UNDO;
637 
638  /* properties */
639  RNA_def_boolean(ot->srna, "all", 1, "All", "Reset to default values all elements of the array");
640  ot->prop = RNA_def_enum(ot->srna,
641  "type",
644  "Type",
645  "Type of override operation");
646  /* TODO: add itemf callback, not all options are available for all data types... */
647 }
648 
650 {
651  PointerRNA ptr;
652  PropertyRNA *prop;
653  int index;
654 
655  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
656 
657  const uint override_status = RNA_property_override_library_status(
658  CTX_data_main(C), &ptr, prop, index);
659 
660  return (ptr.data && ptr.owner_id && prop && (override_status & RNA_OVERRIDE_STATUS_OVERRIDDEN));
661 }
662 
664 {
665  Main *bmain = CTX_data_main(C);
666  PointerRNA ptr, id_refptr, src;
667  PropertyRNA *prop;
668  int index;
669  const bool all = RNA_boolean_get(op->ptr, "all");
670 
671  /* try to reset the nominated setting to its default value */
672  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
673 
674  ID *id = ptr.owner_id;
676  BLI_assert(oprop != NULL);
677  BLI_assert(id != NULL && id->override_library != NULL);
678 
679  const bool is_template = ID_IS_OVERRIDE_LIBRARY_TEMPLATE(id);
680 
681  /* We need source (i.e. linked data) to restore values of deleted overrides...
682  * If this is an override template, we obviously do not need to restore anything. */
683  if (!is_template) {
684  PropertyRNA *src_prop;
686  if (!RNA_path_resolve_property(&id_refptr, oprop->rna_path, &src, &src_prop)) {
687  BLI_assert_msg(0, "Failed to create matching source (linked data) RNA pointer");
688  }
689  }
690 
691  if (!all && index != -1) {
692  bool is_strict_find;
693  /* Remove override operation for given item,
694  * add singular operations for the other items as needed. */
696  oprop, NULL, NULL, index, index, false, &is_strict_find);
697  BLI_assert(opop != NULL);
698  if (!is_strict_find) {
699  /* No specific override operation, we have to get generic one,
700  * and create item-specific override operations for all but given index,
701  * before removing generic one. */
702  for (int idx = RNA_property_array_length(&ptr, prop); idx--;) {
703  if (idx != index) {
705  oprop, opop->operation, NULL, NULL, idx, idx, true, NULL, NULL);
706  }
707  }
708  }
710  if (!is_template) {
711  RNA_property_copy(bmain, &ptr, &src, prop, index);
712  }
713  if (BLI_listbase_is_empty(&oprop->operations)) {
715  }
716  }
717  else {
718  /* Just remove whole generic override operation of this property. */
720  if (!is_template) {
721  RNA_property_copy(bmain, &ptr, &src, prop, -1);
722  }
723  }
724 
725  /* Outliner e.g. has to be aware of this change. */
727 
728  return operator_button_property_finish(C, &ptr, prop);
729 }
730 
732 {
733  /* identifiers */
734  ot->name = "Remove Override";
735  ot->idname = "UI_OT_override_remove_button";
736  ot->description = "Remove an override operation";
737 
738  /* callbacks */
741 
742  /* flags */
743  ot->flag = OPTYPE_UNDO;
744 
745  /* properties */
746  RNA_def_boolean(ot->srna, "all", 1, "All", "Reset to default values all elements of the array");
747 }
748 
750  bContext *C, ID **r_owner_id, ID **r_id, PointerRNA *r_owner_ptr, PropertyRNA **r_prop)
751 {
752  PointerRNA owner_ptr;
753  PropertyRNA *prop;
754  UI_context_active_but_prop_get_templateID(C, &owner_ptr, &prop);
755 
756  if (owner_ptr.data == NULL || prop == NULL) {
757  *r_owner_id = *r_id = NULL;
758  if (r_owner_ptr != NULL) {
759  *r_owner_ptr = PointerRNA_NULL;
760  }
761  if (r_prop != NULL) {
762  *r_prop = NULL;
763  }
764  return;
765  }
766 
767  *r_owner_id = owner_ptr.owner_id;
768  PointerRNA idptr = RNA_property_pointer_get(&owner_ptr, prop);
769  *r_id = idptr.data;
770  if (r_owner_ptr != NULL) {
771  *r_owner_ptr = owner_ptr;
772  }
773  if (r_prop != NULL) {
774  *r_prop = prop;
775  }
776 }
777 
778 static bool override_idtemplate_poll(bContext *C, const bool is_create_op)
779 {
780  ID *owner_id, *id;
781  override_idtemplate_ids_get(C, &owner_id, &id, NULL, NULL);
782 
783  if (owner_id == NULL || id == NULL) {
784  return false;
785  }
786 
787  if (is_create_op) {
788  if (!ID_IS_LINKED(id) && !ID_IS_OVERRIDE_LIBRARY_REAL(id)) {
789  return false;
790  }
791  return true;
792  }
793 
794  /* Reset/Clear operations. */
795  if (ID_IS_LINKED(id) || !ID_IS_OVERRIDE_LIBRARY_REAL(id)) {
796  return false;
797  }
798  return true;
799 }
800 
802 {
803  return override_idtemplate_poll(C, true);
804 }
805 
807 {
808  ID *owner_id, *id;
809  PointerRNA owner_ptr;
810  PropertyRNA *prop;
811  override_idtemplate_ids_get(C, &owner_id, &id, &owner_ptr, &prop);
812  if (ELEM(NULL, owner_id, id)) {
813  return OPERATOR_CANCELLED;
814  }
815 
817  C, CTX_data_main(C), owner_id, id, NULL);
818 
819  if (id_override == NULL) {
820  return OPERATOR_CANCELLED;
821  }
822 
823  PointerRNA idptr;
824  /* `idptr` is re-assigned to owner property to ensure proper updates etc. Here we also use it
825  * to ensure remapping of the owner property from the linked data to the newly created
826  * liboverride (note that in theory this remapping has already been done by code above), but
827  * only in case owner ID was already local ID (override or pure local data).
828  *
829  * Otherwise, owner ID will also have been overridden, and remapped already to use it's
830  * override of the data too. */
831  if (!ID_IS_LINKED(owner_id)) {
832  RNA_id_pointer_create(id_override, &idptr);
833  RNA_property_pointer_set(&owner_ptr, prop, idptr, NULL);
834  }
835  RNA_property_update(C, &owner_ptr, prop);
836 
837  /* 'Security' extra tagging, since this process may also affect the owner ID and not only the
838  * used ID, relying on the property update code only is not always enough. */
843 
844  return OPERATOR_FINISHED;
845 }
846 
848 {
849  /* identifiers */
850  ot->name = "Make Library Override";
851  ot->idname = "UI_OT_override_idtemplate_make";
852  ot->description =
853  "Create a local override of the selected linked data-block, and its hierarchy of "
854  "dependencies";
855 
856  /* callbacks */
859 
860  /* flags */
861  ot->flag = OPTYPE_UNDO;
862 }
863 
865 {
866  return override_idtemplate_poll(C, false);
867 }
868 
870 {
871  ID *owner_id, *id;
872  PointerRNA owner_ptr;
873  PropertyRNA *prop;
874  override_idtemplate_ids_get(C, &owner_id, &id, &owner_ptr, &prop);
875  if (ELEM(NULL, owner_id, id)) {
876  return OPERATOR_CANCELLED;
877  }
878 
879  if (ID_IS_LINKED(id) || !ID_IS_OVERRIDE_LIBRARY_REAL(id)) {
880  return OPERATOR_CANCELLED;
881  }
882 
884 
885  PointerRNA idptr;
886  /* `idptr` is re-assigned to owner property to ensure proper updates etc. */
887  RNA_id_pointer_create(id, &idptr);
888  RNA_property_pointer_set(&owner_ptr, prop, idptr, NULL);
889  RNA_property_update(C, &owner_ptr, prop);
890 
891  /* No need for 'security' extra tagging here, since this process will never affect the owner ID.
892  */
893 
894  return OPERATOR_FINISHED;
895 }
896 
898 {
899  /* identifiers */
900  ot->name = "Reset Library Override";
901  ot->idname = "UI_OT_override_idtemplate_reset";
902  ot->description = "Reset the selected local override to its linked reference values";
903 
904  /* callbacks */
907 
908  /* flags */
909  ot->flag = OPTYPE_UNDO;
910 }
911 
913 {
914  return override_idtemplate_poll(C, false);
915 }
916 
918 {
919  ID *owner_id, *id;
920  PointerRNA owner_ptr;
921  PropertyRNA *prop;
922  override_idtemplate_ids_get(C, &owner_id, &id, &owner_ptr, &prop);
923  if (ELEM(NULL, owner_id, id)) {
924  return OPERATOR_CANCELLED;
925  }
926 
927  if (ID_IS_LINKED(id)) {
928  return OPERATOR_CANCELLED;
929  }
930 
931  Main *bmain = CTX_data_main(C);
932  ViewLayer *view_layer = CTX_data_view_layer(C);
934  ID *id_new = id;
935 
937  id_new = id->override_library->reference;
938  bool do_remap_active = false;
939  if (OBACT(view_layer) == (Object *)id) {
940  BLI_assert(GS(id->name) == ID_OB);
941  BLI_assert(GS(id_new->name) == ID_OB);
942  do_remap_active = true;
943  }
945  if (do_remap_active) {
946  Object *ref_object = (Object *)id_new;
947  Base *basact = BKE_view_layer_base_find(view_layer, ref_object);
948  if (basact != NULL) {
949  view_layer->basact = basact;
950  }
952  }
953  BKE_id_delete(bmain, id);
954  }
955  else {
956  BKE_lib_override_library_id_reset(bmain, id, true);
957  }
958 
959  /* Here the affected ID may remain the same, or be replaced by its linked reference. In either
960  * case, the owner ID remains unchanged, and remapping is already handled by internal code, so
961  * calling `RNA_property_update` on it is enough to ensure proper notifiers are sent. */
962  RNA_property_update(C, &owner_ptr, prop);
963 
964  /* 'Security' extra tagging, since this process may also affect the owner ID and not only the
965  * used ID, relying on the property update code only is not always enough. */
970 
971  return OPERATOR_FINISHED;
972 }
973 
975 {
976  /* identifiers */
977  ot->name = "Clear Library Override";
978  ot->idname = "UI_OT_override_idtemplate_clear";
979  ot->description =
980  "Delete the selected local override and relink its usages to the linked data-block if "
981  "possible, else reset it and mark it as non editable";
982 
983  /* callbacks */
986 
987  /* flags */
988  ot->flag = OPTYPE_UNDO;
989 }
990 
991 static bool override_idtemplate_menu_poll(const bContext *C_const, MenuType *UNUSED(mt))
992 {
993  bContext *C = (bContext *)C_const;
994  ID *owner_id, *id;
995  override_idtemplate_ids_get(C, &owner_id, &id, NULL, NULL);
996 
997  if (owner_id == NULL || id == NULL) {
998  return false;
999  }
1000 
1001  if (!(ID_IS_LINKED(id) || ID_IS_OVERRIDE_LIBRARY_REAL(id))) {
1002  return false;
1003  }
1004  return true;
1005 }
1006 
1008 {
1009  uiLayout *layout = menu->layout;
1010  uiItemO(layout, IFACE_("Make"), ICON_NONE, "UI_OT_override_idtemplate_make");
1011  uiItemO(layout, IFACE_("Reset"), ICON_NONE, "UI_OT_override_idtemplate_reset");
1012  uiItemO(layout, IFACE_("Clear"), ICON_NONE, "UI_OT_override_idtemplate_clear");
1013 }
1014 
1015 static void override_idtemplate_menu(void)
1016 {
1017  MenuType *mt;
1018 
1019  mt = MEM_callocN(sizeof(MenuType), __func__);
1020  strcpy(mt->idname, "UI_MT_idtemplate_liboverride");
1021  strcpy(mt->label, N_("Library Override"));
1024  WM_menutype_add(mt);
1025 }
1026 
1029 /* -------------------------------------------------------------------- */
1033 #define NOT_NULL(assignment) ((assignment) != NULL)
1034 #define NOT_RNA_NULL(assignment) ((assignment).data != NULL)
1035 
1037 {
1038  ListBase lb;
1039  lb = CTX_data_collection_get(C, "selected_pose_bones");
1040 
1041  if (!BLI_listbase_is_empty(&lb)) {
1042  LISTBASE_FOREACH (CollectionPointerLink *, link, &lb) {
1043  bPoseChannel *pchan = link->ptr.data;
1044  RNA_pointer_create(link->ptr.owner_id, &RNA_Bone, pchan->bone, &link->ptr);
1045  }
1046  }
1047 
1048  *r_lb = lb;
1049 }
1050 
1052  PointerRNA *ptr,
1053  PropertyRNA *prop,
1054  ListBase *r_lb,
1055  bool *r_use_path_from_id,
1056  char **r_path)
1057 {
1058  *r_use_path_from_id = false;
1059  *r_path = NULL;
1060  /* special case for bone constraints */
1061  char *path_from_bone = NULL;
1062  /* Remove links from the collection list which don't contain 'prop'. */
1063  bool ensure_list_items_contain_prop = false;
1064 
1065  /* PropertyGroup objects don't have a reference to the struct that actually owns
1066  * them, so it is normally necessary to do a brute force search to find it. This
1067  * handles the search for non-ID owners by using the 'active' reference as a hint
1068  * to preserve efficiency. Only properties defined through RNA are handled, as
1069  * custom properties cannot be assumed to be valid for all instances.
1070  *
1071  * Properties owned by the ID are handled by the 'if (ptr->owner_id)' case below.
1072  */
1074  PointerRNA owner_ptr;
1075  char *idpath = NULL;
1076 
1077  /* First, check the active PoseBone and PoseBone->Bone. */
1078  if (NOT_RNA_NULL(
1079  owner_ptr = CTX_data_pointer_get_type(C, "active_pose_bone", &RNA_PoseBone))) {
1080  if (NOT_NULL(idpath = RNA_path_from_struct_to_idproperty(&owner_ptr, ptr->data))) {
1081  *r_lb = CTX_data_collection_get(C, "selected_pose_bones");
1082  }
1083  else {
1084  bPoseChannel *pchan = owner_ptr.data;
1085  RNA_pointer_create(owner_ptr.owner_id, &RNA_Bone, pchan->bone, &owner_ptr);
1086 
1087  if (NOT_NULL(idpath = RNA_path_from_struct_to_idproperty(&owner_ptr, ptr->data))) {
1089  }
1090  }
1091  }
1092 
1093  if (idpath == NULL) {
1094  /* Check the active EditBone if in edit mode. */
1095  if (NOT_RNA_NULL(
1096  owner_ptr = CTX_data_pointer_get_type_silent(C, "active_bone", &RNA_EditBone)) &&
1097  NOT_NULL(idpath = RNA_path_from_struct_to_idproperty(&owner_ptr, ptr->data))) {
1098  *r_lb = CTX_data_collection_get(C, "selected_editable_bones");
1099  }
1100 
1101  /* Add other simple cases here (Node, NodeSocket, Sequence, ViewLayer etc). */
1102  }
1103 
1104  if (idpath) {
1105  *r_path = BLI_sprintfN("%s.%s", idpath, RNA_property_identifier(prop));
1106  MEM_freeN(idpath);
1107  return true;
1108  }
1109  }
1110 
1111  if (RNA_struct_is_a(ptr->type, &RNA_EditBone)) {
1112  *r_lb = CTX_data_collection_get(C, "selected_editable_bones");
1113  }
1114  else if (RNA_struct_is_a(ptr->type, &RNA_PoseBone)) {
1115  *r_lb = CTX_data_collection_get(C, "selected_pose_bones");
1116  }
1117  else if (RNA_struct_is_a(ptr->type, &RNA_Bone)) {
1119  }
1120  else if (RNA_struct_is_a(ptr->type, &RNA_Sequence)) {
1121  /* Special case when we do this for 'Sequence.lock'.
1122  * (if the sequence is locked, it won't be in "selected_editable_sequences"). */
1123  const char *prop_id = RNA_property_identifier(prop);
1124  if (STREQ(prop_id, "lock")) {
1125  *r_lb = CTX_data_collection_get(C, "selected_sequences");
1126  }
1127  else {
1128  *r_lb = CTX_data_collection_get(C, "selected_editable_sequences");
1129  }
1130  /* Account for properties only being available for some sequence types. */
1131  ensure_list_items_contain_prop = true;
1132  }
1133  else if (RNA_struct_is_a(ptr->type, &RNA_FCurve)) {
1134  *r_lb = CTX_data_collection_get(C, "selected_editable_fcurves");
1135  }
1136  else if (RNA_struct_is_a(ptr->type, &RNA_Keyframe)) {
1137  *r_lb = CTX_data_collection_get(C, "selected_editable_keyframes");
1138  }
1139  else if (RNA_struct_is_a(ptr->type, &RNA_Action)) {
1140  *r_lb = CTX_data_collection_get(C, "selected_editable_actions");
1141  }
1142  else if (RNA_struct_is_a(ptr->type, &RNA_NlaStrip)) {
1143  *r_lb = CTX_data_collection_get(C, "selected_nla_strips");
1144  }
1145  else if (RNA_struct_is_a(ptr->type, &RNA_MovieTrackingTrack)) {
1146  *r_lb = CTX_data_collection_get(C, "selected_movieclip_tracks");
1147  }
1148  else if (RNA_struct_is_a(ptr->type, &RNA_Constraint) &&
1149  (path_from_bone = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_PoseBone)) !=
1150  NULL) {
1151  *r_lb = CTX_data_collection_get(C, "selected_pose_bones");
1152  *r_path = path_from_bone;
1153  }
1154  else if (RNA_struct_is_a(ptr->type, &RNA_Node) || RNA_struct_is_a(ptr->type, &RNA_NodeSocket)) {
1155  ListBase lb = {NULL, NULL};
1156  char *path = NULL;
1157  bNode *node = NULL;
1158 
1159  /* Get the node we're editing */
1160  if (RNA_struct_is_a(ptr->type, &RNA_NodeSocket)) {
1162  bNodeSocket *sock = ptr->data;
1163  if (nodeFindNode(ntree, sock, &node, NULL)) {
1164  if ((path = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_Node)) != NULL) {
1165  /* we're good! */
1166  }
1167  else {
1168  node = NULL;
1169  }
1170  }
1171  }
1172  else {
1173  node = ptr->data;
1174  }
1175 
1176  /* Now filter by type */
1177  if (node) {
1178  lb = CTX_data_collection_get(C, "selected_nodes");
1179 
1181  bNode *node_data = link->ptr.data;
1182 
1183  if (node_data->type != node->type) {
1184  BLI_remlink(&lb, link);
1185  MEM_freeN(link);
1186  }
1187  }
1188  }
1189 
1190  *r_lb = lb;
1191  *r_path = path;
1192  }
1193  else if (ptr->owner_id) {
1194  ID *id = ptr->owner_id;
1195 
1196  if (GS(id->name) == ID_OB) {
1197  *r_lb = CTX_data_collection_get(C, "selected_editable_objects");
1198  *r_use_path_from_id = true;
1199  *r_path = RNA_path_from_ID_to_property(ptr, prop);
1200  }
1201  else if (OB_DATA_SUPPORT_ID(GS(id->name))) {
1202  /* check we're using the active object */
1203  const short id_code = GS(id->name);
1204  ListBase lb = CTX_data_collection_get(C, "selected_editable_objects");
1205  char *path = RNA_path_from_ID_to_property(ptr, prop);
1206 
1207  /* de-duplicate obdata */
1208  if (!BLI_listbase_is_empty(&lb)) {
1209  LISTBASE_FOREACH (CollectionPointerLink *, link, &lb) {
1210  Object *ob = (Object *)link->ptr.owner_id;
1211  if (ob->data) {
1212  ID *id_data = ob->data;
1213  id_data->tag |= LIB_TAG_DOIT;
1214  }
1215  }
1216 
1218  Object *ob = (Object *)link->ptr.owner_id;
1219  ID *id_data = ob->data;
1220 
1221  if ((id_data == NULL) || (id_data->tag & LIB_TAG_DOIT) == 0 || ID_IS_LINKED(id_data) ||
1222  (GS(id_data->name) != id_code)) {
1223  BLI_remlink(&lb, link);
1224  MEM_freeN(link);
1225  }
1226  else {
1227  /* Avoid prepending 'data' to the path. */
1228  RNA_id_pointer_create(id_data, &link->ptr);
1229  }
1230 
1231  if (id_data) {
1232  id_data->tag &= ~LIB_TAG_DOIT;
1233  }
1234  }
1235  }
1236 
1237  *r_lb = lb;
1238  *r_path = path;
1239  }
1240  else if (GS(id->name) == ID_SCE) {
1241  /* Sequencer's ID is scene :/ */
1242  /* Try to recursively find an RNA_Sequence ancestor,
1243  * to handle situations like T41062... */
1244  if ((*r_path = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_Sequence)) != NULL) {
1245  /* Special case when we do this for 'Sequence.lock'.
1246  * (if the sequence is locked, it won't be in "selected_editable_sequences"). */
1247  const char *prop_id = RNA_property_identifier(prop);
1248  if (STREQ(prop_id, "lock")) {
1249  *r_lb = CTX_data_collection_get(C, "selected_sequences");
1250  }
1251  else {
1252  *r_lb = CTX_data_collection_get(C, "selected_editable_sequences");
1253  }
1254  /* Account for properties only being available for some sequence types. */
1255  ensure_list_items_contain_prop = true;
1256  }
1257  }
1258  return (*r_path != NULL);
1259  }
1260  else {
1261  return false;
1262  }
1263 
1264  if (ensure_list_items_contain_prop) {
1265  const char *prop_id = RNA_property_identifier(prop);
1267  if ((ptr->type != link->ptr.type) &&
1268  (RNA_struct_type_find_property(link->ptr.type, prop_id) != prop)) {
1269  BLI_remlink(r_lb, link);
1270  MEM_freeN(link);
1271  }
1272  }
1273  }
1274 
1275  return true;
1276 }
1277 
1279  PointerRNA *ptr_link,
1280  PropertyRNA *prop,
1281  const char *path,
1282  bool use_path_from_id,
1283  PointerRNA *r_ptr,
1284  PropertyRNA **r_prop)
1285 {
1286  PointerRNA idptr;
1287  PropertyRNA *lprop;
1288  PointerRNA lptr;
1289 
1290  if (ptr_link->data == ptr->data) {
1291  return false;
1292  }
1293 
1294  if (use_path_from_id) {
1295  /* Path relative to ID. */
1296  lprop = NULL;
1297  RNA_id_pointer_create(ptr_link->owner_id, &idptr);
1298  RNA_path_resolve_property(&idptr, path, &lptr, &lprop);
1299  }
1300  else if (path) {
1301  /* Path relative to elements from list. */
1302  lprop = NULL;
1303  RNA_path_resolve_property(ptr_link, path, &lptr, &lprop);
1304  }
1305  else {
1306  lptr = *ptr_link;
1307  lprop = prop;
1308  }
1309 
1310  if (lptr.data == ptr->data) {
1311  /* temp_ptr might not be the same as ptr_link! */
1312  return false;
1313  }
1314 
1315  /* Skip non-existing properties on link. This was previously covered with the `lprop != prop`
1316  * check but we are now more permissive when it comes to ID properties, see below. */
1317  if (lprop == NULL) {
1318  return false;
1319  }
1320 
1321  if (RNA_property_type(lprop) != RNA_property_type(prop)) {
1322  return false;
1323  }
1324 
1325  /* Check property pointers matching.
1326  * For ID properties, these pointers match:
1327  * - If the property is API defined on an existing class (and they are equally named).
1328  * - Never for ID properties on specific ID (even if they are equally named).
1329  * - Never for NodesModifierSettings properties (even if they are equally named).
1330  *
1331  * Be permissive on ID properties in the following cases:
1332  * - #NodesModifierSettings properties
1333  * - (special check: only if the node-group matches, since the 'Input_n' properties are name
1334  * based and similar on potentially very different node-groups).
1335  * - ID properties on specific ID
1336  * - (no special check, copying seems OK [even if type does not match -- does not do anything
1337  * then])
1338  */
1339  bool ignore_prop_eq = RNA_property_is_idprop(lprop) && RNA_property_is_idprop(prop);
1340  if (RNA_struct_is_a(lptr.type, &RNA_NodesModifier) &&
1341  RNA_struct_is_a(ptr->type, &RNA_NodesModifier)) {
1342  ignore_prop_eq = false;
1343 
1344  NodesModifierData *nmd_link = (NodesModifierData *)lptr.data;
1346  if (nmd_link->node_group == nmd_src->node_group) {
1347  ignore_prop_eq = true;
1348  }
1349  }
1350 
1351  if ((lprop != prop) && !ignore_prop_eq) {
1352  return false;
1353  }
1354 
1355  if (!RNA_property_editable(&lptr, lprop)) {
1356  return false;
1357  }
1358 
1359  if (r_ptr) {
1360  *r_ptr = lptr;
1361  }
1362  if (r_prop) {
1363  *r_prop = lprop;
1364  }
1365 
1366  return true;
1367 }
1368 
1376 static bool copy_to_selected_button(bContext *C, bool all, bool poll)
1377 {
1378  Main *bmain = CTX_data_main(C);
1379  PointerRNA ptr, lptr;
1380  PropertyRNA *prop, *lprop;
1381  bool success = false;
1382  int index;
1383 
1384  /* try to reset the nominated setting to its default value */
1385  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
1386 
1387  /* if there is a valid property that is editable... */
1388  if (ptr.data == NULL || prop == NULL) {
1389  return false;
1390  }
1391 
1392  char *path = NULL;
1393  bool use_path_from_id;
1394  ListBase lb = {NULL};
1395 
1396  if (!UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path)) {
1397  return false;
1398  }
1399  if (BLI_listbase_is_empty(&lb)) {
1400  MEM_SAFE_FREE(path);
1401  return false;
1402  }
1403 
1404  LISTBASE_FOREACH (CollectionPointerLink *, link, &lb) {
1405  if (link->ptr.data == ptr.data) {
1406  continue;
1407  }
1408 
1410  &ptr, &link->ptr, prop, path, use_path_from_id, &lptr, &lprop)) {
1411  continue;
1412  }
1413 
1414  if (poll) {
1415  success = true;
1416  break;
1417  }
1418  if (RNA_property_copy(bmain, &lptr, &ptr, prop, (all) ? -1 : index)) {
1419  RNA_property_update(C, &lptr, prop);
1420  success = true;
1421  }
1422  }
1423 
1424  MEM_SAFE_FREE(path);
1425  BLI_freelistN(&lb);
1426 
1427  return success;
1428 }
1429 
1431 {
1432  return copy_to_selected_button(C, false, true);
1433 }
1434 
1436 {
1437  bool success;
1438 
1439  const bool all = RNA_boolean_get(op->ptr, "all");
1440 
1441  success = copy_to_selected_button(C, all, false);
1442 
1443  return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
1444 }
1445 
1447 {
1448  /* identifiers */
1449  ot->name = "Copy to Selected";
1450  ot->idname = "UI_OT_copy_to_selected_button";
1451  ot->description =
1452  "Copy the property's value from the active item to the same property of all selected items "
1453  "if the same property exists";
1454 
1455  /* callbacks */
1458 
1459  /* flags */
1461 
1462  /* properties */
1463  RNA_def_boolean(ot->srna, "all", true, "All", "Copy to selected all elements of the array");
1464 }
1465 
1468 /* -------------------------------------------------------------------- */
1473 static bool jump_to_target_ptr(bContext *C, PointerRNA ptr, const bool poll)
1474 {
1475  if (RNA_pointer_is_null(&ptr)) {
1476  return false;
1477  }
1478 
1479  /* Verify pointer type. */
1480  char bone_name[MAXBONENAME];
1481  const StructRNA *target_type = NULL;
1482 
1483  if (ELEM(ptr.type, &RNA_EditBone, &RNA_PoseBone, &RNA_Bone)) {
1484  RNA_string_get(&ptr, "name", bone_name);
1485  if (bone_name[0] != '\0') {
1486  target_type = &RNA_Bone;
1487  }
1488  }
1489  else if (RNA_struct_is_a(ptr.type, &RNA_Object)) {
1490  target_type = &RNA_Object;
1491  }
1492 
1493  if (target_type == NULL) {
1494  return false;
1495  }
1496 
1497  /* Find the containing Object. */
1498  ViewLayer *view_layer = CTX_data_view_layer(C);
1499  Base *base = NULL;
1500  const short id_type = GS(ptr.owner_id->name);
1501  if (id_type == ID_OB) {
1502  base = BKE_view_layer_base_find(view_layer, (Object *)ptr.owner_id);
1503  }
1504  else if (OB_DATA_SUPPORT_ID(id_type)) {
1505  base = ED_object_find_first_by_data_id(view_layer, ptr.owner_id);
1506  }
1507 
1508  bool ok = false;
1509  if ((base == NULL) || ((target_type == &RNA_Bone) && (base->object->type != OB_ARMATURE))) {
1510  /* pass */
1511  }
1512  else if (poll) {
1513  ok = true;
1514  }
1515  else {
1516  /* Make optional. */
1517  const bool reveal_hidden = true;
1518  /* Select and activate the target. */
1519  if (target_type == &RNA_Bone) {
1520  ok = ED_object_jump_to_bone(C, base->object, bone_name, reveal_hidden);
1521  }
1522  else if (target_type == &RNA_Object) {
1523  ok = ED_object_jump_to_object(C, base->object, reveal_hidden);
1524  }
1525  else {
1526  BLI_assert(0);
1527  }
1528  }
1529  return ok;
1530 }
1531 
1539 static bool jump_to_target_button(bContext *C, bool poll)
1540 {
1541  PointerRNA ptr, target_ptr;
1542  PropertyRNA *prop;
1543  int index;
1544 
1545  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
1546 
1547  /* If there is a valid property... */
1548  if (ptr.data && prop) {
1549  const PropertyType type = RNA_property_type(prop);
1550 
1551  /* For pointer properties, use their value directly. */
1552  if (type == PROP_POINTER) {
1553  target_ptr = RNA_property_pointer_get(&ptr, prop);
1554 
1555  return jump_to_target_ptr(C, target_ptr, poll);
1556  }
1557  /* For string properties with prop_search, look up the search collection item. */
1558  if (type == PROP_STRING) {
1559  const uiBut *but = UI_context_active_but_get(C);
1560  const uiButSearch *search_but = (but->type == UI_BTYPE_SEARCH_MENU) ? (uiButSearch *)but :
1561  NULL;
1562 
1563  if (search_but && search_but->items_update_fn == ui_rna_collection_search_update_fn) {
1564  uiRNACollectionSearch *coll_search = search_but->arg;
1565 
1566  char str_buf[MAXBONENAME];
1567  char *str_ptr = RNA_property_string_get_alloc(&ptr, prop, str_buf, sizeof(str_buf), NULL);
1568 
1569  int found = 0;
1570  /* Jump to target only works with search properties currently, not search callbacks yet.
1571  * See ui_but_add_search. */
1572  if (coll_search->search_prop != NULL) {
1574  &coll_search->search_ptr, coll_search->search_prop, str_ptr, &target_ptr);
1575  }
1576 
1577  if (str_ptr != str_buf) {
1578  MEM_freeN(str_ptr);
1579  }
1580 
1581  if (found) {
1582  return jump_to_target_ptr(C, target_ptr, poll);
1583  }
1584  }
1585  }
1586  }
1587 
1588  return false;
1589 }
1590 
1592 {
1593  return jump_to_target_button(C, true);
1594 }
1595 
1597 {
1598  const bool success = jump_to_target_button(C, false);
1599 
1600  return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
1601 }
1602 
1604 {
1605  /* identifiers */
1606  ot->name = "Jump to Target";
1607  ot->idname = "UI_OT_jump_to_target_button";
1608  ot->description = "Switch to the target object or bone";
1609 
1610  /* callbacks */
1613 
1614  /* flags */
1616 }
1617 
1620 /* -------------------------------------------------------------------- */
1624 #ifdef WITH_PYTHON
1625 
1626 /* ------------------------------------------------------------------------- */
1627 /* EditSource Utility funcs and operator,
1628  * NOTE: this includes utility functions and button matching checks. */
1629 
1630 typedef struct uiEditSourceStore {
1631  uiBut but_orig;
1632  GHash *hash;
1633 } uiEditSourceStore;
1634 
1635 typedef struct uiEditSourceButStore {
1636  char py_dbg_fn[FILE_MAX];
1637  int py_dbg_line_number;
1638 } uiEditSourceButStore;
1639 
1640 /* should only ever be set while the edit source operator is running */
1641 static struct uiEditSourceStore *ui_editsource_info = NULL;
1642 
1643 bool UI_editsource_enable_check(void)
1644 {
1645  return (ui_editsource_info != NULL);
1646 }
1647 
1648 static void ui_editsource_active_but_set(uiBut *but)
1649 {
1650  BLI_assert(ui_editsource_info == NULL);
1651 
1652  ui_editsource_info = MEM_callocN(sizeof(uiEditSourceStore), __func__);
1653  memcpy(&ui_editsource_info->but_orig, but, sizeof(uiBut));
1654 
1655  ui_editsource_info->hash = BLI_ghash_ptr_new(__func__);
1656 }
1657 
1658 static void ui_editsource_active_but_clear(void)
1659 {
1660  BLI_ghash_free(ui_editsource_info->hash, NULL, MEM_freeN);
1661  MEM_freeN(ui_editsource_info);
1662  ui_editsource_info = NULL;
1663 }
1664 
1665 static bool ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b)
1666 {
1667 # if 0
1668  printf("matching buttons: '%s' == '%s'\n", but_a->drawstr, but_b->drawstr);
1669 # endif
1670 
1671  /* this just needs to be a 'good-enough' comparison so we can know beyond
1672  * reasonable doubt that these buttons are the same between redraws.
1673  * if this fails it only means edit-source fails - campbell */
1674  if (BLI_rctf_compare(&but_a->rect, &but_b->rect, FLT_EPSILON) && (but_a->type == but_b->type) &&
1675  (but_a->rnaprop == but_b->rnaprop) && (but_a->optype == but_b->optype) &&
1676  (but_a->unit_type == but_b->unit_type) &&
1677  STREQLEN(but_a->drawstr, but_b->drawstr, UI_MAX_DRAW_STR)) {
1678  return true;
1679  }
1680  return false;
1681 }
1682 
1684 {
1685  extern void PyC_FileAndNum_Safe(const char **r_filename, int *r_lineno);
1686 
1687  struct uiEditSourceButStore *but_store = MEM_callocN(sizeof(uiEditSourceButStore), __func__);
1688 
1689  const char *fn;
1690  int line_number = -1;
1691 
1692 # if 0
1693  printf("comparing buttons: '%s' == '%s'\n", but->drawstr, ui_editsource_info->but_orig.drawstr);
1694 # endif
1695 
1696  PyC_FileAndNum_Safe(&fn, &line_number);
1697 
1698  if (line_number != -1) {
1699  BLI_strncpy(but_store->py_dbg_fn, fn, sizeof(but_store->py_dbg_fn));
1700  but_store->py_dbg_line_number = line_number;
1701  }
1702  else {
1703  but_store->py_dbg_fn[0] = '\0';
1704  but_store->py_dbg_line_number = -1;
1705  }
1706 
1707  BLI_ghash_insert(ui_editsource_info->hash, but, but_store);
1708 }
1709 
1710 void UI_editsource_but_replace(const uiBut *old_but, uiBut *new_but)
1711 {
1712  uiEditSourceButStore *but_store = BLI_ghash_lookup(ui_editsource_info->hash, old_but);
1713  if (but_store) {
1714  BLI_ghash_remove(ui_editsource_info->hash, old_but, NULL, NULL);
1715  BLI_ghash_insert(ui_editsource_info->hash, new_but, but_store);
1716  }
1717 }
1718 
1719 static int editsource_text_edit(bContext *C,
1720  wmOperator *op,
1721  const char filepath[FILE_MAX],
1722  const int line)
1723 {
1724  struct Main *bmain = CTX_data_main(C);
1725  Text *text = NULL;
1726 
1727  /* Developers may wish to copy-paste to an external editor. */
1728  printf("%s:%d\n", filepath, line);
1729 
1730  LISTBASE_FOREACH (Text *, text_iter, &bmain->texts) {
1731  if (text_iter->filepath && BLI_path_cmp(text_iter->filepath, filepath) == 0) {
1732  text = text_iter;
1733  break;
1734  }
1735  }
1736 
1737  if (text == NULL) {
1738  text = BKE_text_load(bmain, filepath, BKE_main_blendfile_path(bmain));
1739  }
1740 
1741  if (text == NULL) {
1742  BKE_reportf(op->reports, RPT_WARNING, "File '%s' cannot be opened", filepath);
1743  return OPERATOR_CANCELLED;
1744  }
1745 
1746  txt_move_toline(text, line - 1, false);
1747 
1748  /* naughty!, find text area to set, not good behavior
1749  * but since this is a developer tool lets allow it - campbell */
1750  if (!ED_text_activate_in_screen(C, text)) {
1751  BKE_reportf(op->reports, RPT_INFO, "See '%s' in the text editor", text->id.name + 2);
1752  }
1753 
1755 
1756  return OPERATOR_FINISHED;
1757 }
1758 
1759 static int editsource_exec(bContext *C, wmOperator *op)
1760 {
1762 
1763  if (but) {
1764  GHashIterator ghi;
1765  struct uiEditSourceButStore *but_store = NULL;
1766 
1767  ARegion *region = CTX_wm_region(C);
1768  int ret;
1769 
1770  /* needed else the active button does not get tested */
1772 
1773  // printf("%s: begin\n", __func__);
1774 
1775  /* take care not to return before calling ui_editsource_active_but_clear */
1776  ui_editsource_active_but_set(but);
1777 
1778  /* redraw and get active button python info */
1780 
1781  for (BLI_ghashIterator_init(&ghi, ui_editsource_info->hash);
1782  BLI_ghashIterator_done(&ghi) == false;
1783  BLI_ghashIterator_step(&ghi)) {
1784  uiBut *but_key = BLI_ghashIterator_getKey(&ghi);
1785  if (but_key && ui_editsource_uibut_match(&ui_editsource_info->but_orig, but_key)) {
1786  but_store = BLI_ghashIterator_getValue(&ghi);
1787  break;
1788  }
1789  }
1790 
1791  if (but_store) {
1792  if (but_store->py_dbg_line_number != -1) {
1793  ret = editsource_text_edit(C, op, but_store->py_dbg_fn, but_store->py_dbg_line_number);
1794  }
1795  else {
1796  BKE_report(
1797  op->reports, RPT_ERROR, "Active button is not from a script, cannot edit source");
1799  }
1800  }
1801  else {
1802  BKE_report(op->reports, RPT_ERROR, "Active button match cannot be found");
1804  }
1805 
1806  ui_editsource_active_but_clear();
1807 
1808  // printf("%s: end\n", __func__);
1809 
1810  return ret;
1811  }
1812 
1813  BKE_report(op->reports, RPT_ERROR, "Active button not found");
1814  return OPERATOR_CANCELLED;
1815 }
1816 
1817 static void UI_OT_editsource(wmOperatorType *ot)
1818 {
1819  /* identifiers */
1820  ot->name = "Edit Source";
1821  ot->idname = "UI_OT_editsource";
1822  ot->description = "Edit UI source code of the active button";
1823 
1824  /* callbacks */
1825  ot->exec = editsource_exec;
1826 }
1827 
1830 /* -------------------------------------------------------------------- */
1840 static void edittranslation_find_po_file(const char *root,
1841  const char *uilng,
1842  char *path,
1843  const size_t maxlen)
1844 {
1845  char tstr[32]; /* Should be more than enough! */
1846 
1847  /* First, full lang code. */
1848  BLI_snprintf(tstr, sizeof(tstr), "%s.po", uilng);
1849  BLI_join_dirfile(path, maxlen, root, uilng);
1850  BLI_path_append(path, maxlen, tstr);
1851  if (BLI_is_file(path)) {
1852  return;
1853  }
1854 
1855  /* Now try without the second iso code part (_ES in es_ES). */
1856  {
1857  const char *tc = NULL;
1858  size_t szt = 0;
1859  tstr[0] = '\0';
1860 
1861  tc = strchr(uilng, '_');
1862  if (tc) {
1863  szt = tc - uilng;
1864  if (szt < sizeof(tstr)) { /* Paranoid, should always be true! */
1865  BLI_strncpy(tstr, uilng, szt + 1); /* +1 for '\0' char! */
1866  }
1867  }
1868  if (tstr[0]) {
1869  /* Because of some codes like sr_SR@latin... */
1870  tc = strchr(uilng, '@');
1871  if (tc) {
1872  BLI_strncpy(tstr + szt, tc, sizeof(tstr) - szt);
1873  }
1874 
1875  BLI_join_dirfile(path, maxlen, root, tstr);
1876  strcat(tstr, ".po");
1877  BLI_path_append(path, maxlen, tstr);
1878  if (BLI_is_file(path)) {
1879  return;
1880  }
1881  }
1882  }
1883 
1884  /* Else no po file! */
1885  path[0] = '\0';
1886 }
1887 
1888 static int edittranslation_exec(bContext *C, wmOperator *op)
1889 {
1891  if (but == NULL) {
1892  BKE_report(op->reports, RPT_ERROR, "Active button not found");
1893  return OPERATOR_CANCELLED;
1894  }
1895 
1896  wmOperatorType *ot;
1897  PointerRNA ptr;
1898  char popath[FILE_MAX];
1899  const char *root = U.i18ndir;
1900  const char *uilng = BLT_lang_get();
1901 
1902  uiStringInfo but_label = {BUT_GET_LABEL, NULL};
1903  uiStringInfo rna_label = {BUT_GET_RNA_LABEL, NULL};
1904  uiStringInfo enum_label = {BUT_GET_RNAENUM_LABEL, NULL};
1905  uiStringInfo but_tip = {BUT_GET_TIP, NULL};
1906  uiStringInfo rna_tip = {BUT_GET_RNA_TIP, NULL};
1907  uiStringInfo enum_tip = {BUT_GET_RNAENUM_TIP, NULL};
1912 
1913  if (!BLI_is_dir(root)) {
1914  BKE_report(op->reports,
1915  RPT_ERROR,
1916  "Please set your Preferences' 'Translation Branches "
1917  "Directory' path to a valid directory");
1918  return OPERATOR_CANCELLED;
1919  }
1921  if (ot == NULL) {
1922  BKE_reportf(op->reports,
1923  RPT_ERROR,
1924  "Could not find operator '%s'! Please enable ui_translate add-on "
1925  "in the User Preferences",
1927  return OPERATOR_CANCELLED;
1928  }
1929  /* Try to find a valid po file for current language... */
1930  edittranslation_find_po_file(root, uilng, popath, FILE_MAX);
1931  // printf("po path: %s\n", popath);
1932  if (popath[0] == '\0') {
1933  BKE_reportf(
1934  op->reports, RPT_ERROR, "No valid po found for language '%s' under %s", uilng, root);
1935  return OPERATOR_CANCELLED;
1936  }
1937 
1939  but,
1940  &but_label,
1941  &rna_label,
1942  &enum_label,
1943  &but_tip,
1944  &rna_tip,
1945  &enum_tip,
1946  &rna_struct,
1947  &rna_prop,
1948  &rna_enum,
1949  &rna_ctxt,
1950  NULL);
1951 
1953  RNA_string_set(&ptr, "lang", uilng);
1954  RNA_string_set(&ptr, "po_file", popath);
1955  RNA_string_set(&ptr, "but_label", but_label.strinfo);
1956  RNA_string_set(&ptr, "rna_label", rna_label.strinfo);
1957  RNA_string_set(&ptr, "enum_label", enum_label.strinfo);
1958  RNA_string_set(&ptr, "but_tip", but_tip.strinfo);
1959  RNA_string_set(&ptr, "rna_tip", rna_tip.strinfo);
1960  RNA_string_set(&ptr, "enum_tip", enum_tip.strinfo);
1961  RNA_string_set(&ptr, "rna_struct", rna_struct.strinfo);
1962  RNA_string_set(&ptr, "rna_prop", rna_prop.strinfo);
1963  RNA_string_set(&ptr, "rna_enum", rna_enum.strinfo);
1964  RNA_string_set(&ptr, "rna_ctxt", rna_ctxt.strinfo);
1966 
1967  /* Clean up */
1968  if (but_label.strinfo) {
1969  MEM_freeN(but_label.strinfo);
1970  }
1971  if (rna_label.strinfo) {
1972  MEM_freeN(rna_label.strinfo);
1973  }
1974  if (enum_label.strinfo) {
1975  MEM_freeN(enum_label.strinfo);
1976  }
1977  if (but_tip.strinfo) {
1978  MEM_freeN(but_tip.strinfo);
1979  }
1980  if (rna_tip.strinfo) {
1981  MEM_freeN(rna_tip.strinfo);
1982  }
1983  if (enum_tip.strinfo) {
1984  MEM_freeN(enum_tip.strinfo);
1985  }
1986  if (rna_struct.strinfo) {
1987  MEM_freeN(rna_struct.strinfo);
1988  }
1989  if (rna_prop.strinfo) {
1990  MEM_freeN(rna_prop.strinfo);
1991  }
1992  if (rna_enum.strinfo) {
1993  MEM_freeN(rna_enum.strinfo);
1994  }
1995  if (rna_ctxt.strinfo) {
1996  MEM_freeN(rna_ctxt.strinfo);
1997  }
1998 
1999  return ret;
2000 }
2001 
2002 static void UI_OT_edittranslation_init(wmOperatorType *ot)
2003 {
2004  /* identifiers */
2005  ot->name = "Edit Translation";
2006  ot->idname = "UI_OT_edittranslation_init";
2007  ot->description = "Edit i18n in current language for the active button";
2008 
2009  /* callbacks */
2010  ot->exec = edittranslation_exec;
2011 }
2012 
2013 #endif /* WITH_PYTHON */
2014 
2017 /* -------------------------------------------------------------------- */
2022 {
2023  BLT_lang_init();
2024  BLF_cache_clear();
2025  BLT_lang_set(NULL);
2026  UI_reinit_font();
2027  return OPERATOR_FINISHED;
2028 }
2029 
2031 {
2032  /* identifiers */
2033  ot->name = "Reload Translation";
2034  ot->idname = "UI_OT_reloadtranslation";
2035  ot->description = "Force a full reload of UI translation";
2036 
2037  /* callbacks */
2039 }
2040 
2043 /* -------------------------------------------------------------------- */
2047 static int ui_button_press_invoke(bContext *C, wmOperator *op, const wmEvent *event)
2048 {
2049  bScreen *screen = CTX_wm_screen(C);
2050  const bool skip_depressed = RNA_boolean_get(op->ptr, "skip_depressed");
2051  ARegion *region_prev = CTX_wm_region(C);
2052  ARegion *region = screen ? BKE_screen_find_region_xy(screen, RGN_TYPE_ANY, event->xy) : NULL;
2053 
2054  if (region == NULL) {
2055  region = region_prev;
2056  }
2057 
2058  if (region == NULL) {
2059  return OPERATOR_PASS_THROUGH;
2060  }
2061 
2062  CTX_wm_region_set(C, region);
2064  CTX_wm_region_set(C, region_prev);
2065 
2066  if (but == NULL) {
2067  return OPERATOR_PASS_THROUGH;
2068  }
2069  if (skip_depressed && (but->flag & (UI_SELECT | UI_SELECT_DRAW))) {
2070  return OPERATOR_PASS_THROUGH;
2071  }
2072 
2073  /* Weak, this is a workaround for 'UI_but_is_tool', which checks the operator type,
2074  * having this avoids a minor drawing glitch. */
2075  void *but_optype = but->optype;
2076 
2077  UI_but_execute(C, region, but);
2078 
2079  but->optype = but_optype;
2080 
2082 
2083  return OPERATOR_FINISHED;
2084 }
2085 
2087 {
2088  ot->name = "Press Button";
2089  ot->idname = "UI_OT_button_execute";
2090  ot->description = "Presses active button";
2091 
2093  ot->flag = OPTYPE_INTERNAL;
2094 
2095  RNA_def_boolean(ot->srna, "skip_depressed", 0, "Skip Depressed", "");
2096 }
2097 
2100 /* -------------------------------------------------------------------- */
2105 {
2107 
2108  if (but) {
2110  }
2111 
2112  return OPERATOR_FINISHED;
2113 }
2114 
2116 {
2117  ot->name = "Clear Button String";
2118  ot->idname = "UI_OT_button_string_clear";
2119  ot->description = "Unsets the text of the active button";
2120 
2124 }
2125 
2128 /* -------------------------------------------------------------------- */
2132 bool UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent *UNUSED(event))
2133 {
2134  /* should only return true for regions that include buttons, for now
2135  * return true always */
2136  if (drag->type == WM_DRAG_COLOR) {
2137  SpaceImage *sima = CTX_wm_space_image(C);
2138  ARegion *region = CTX_wm_region(C);
2139 
2140  if (UI_but_active_drop_color(C)) {
2141  return 1;
2142  }
2143 
2144  if (sima && (sima->mode == SI_MODE_PAINT) && sima->image &&
2145  (region && region->regiontype == RGN_TYPE_WINDOW)) {
2146  return 1;
2147  }
2148  }
2149 
2150  return 0;
2151 }
2152 
2154 {
2155  uiDragColorHandle *drag_info = drag->poin;
2156 
2157  RNA_float_set_array(drop->ptr, "color", drag_info->color);
2158  RNA_boolean_set(drop->ptr, "gamma", drag_info->gamma_corrected);
2159 }
2160 
2161 static int drop_color_invoke(bContext *C, wmOperator *op, const wmEvent *event)
2162 {
2163  ARegion *region = CTX_wm_region(C);
2164  uiBut *but = NULL;
2165  float color[4];
2166  bool gamma;
2167 
2168  RNA_float_get_array(op->ptr, "color", color);
2169  gamma = RNA_boolean_get(op->ptr, "gamma");
2170 
2171  /* find button under mouse, check if it has RNA color property and
2172  * if it does copy the data */
2173  but = ui_region_find_active_but(region);
2174 
2175  if (but && but->type == UI_BTYPE_COLOR && but->rnaprop) {
2176  const int color_len = RNA_property_array_length(&but->rnapoin, but->rnaprop);
2177  BLI_assert(color_len <= 4);
2178 
2179  /* keep alpha channel as-is */
2180  if (color_len == 4) {
2181  color[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3);
2182  }
2183 
2185  if (!gamma) {
2187  }
2189  RNA_property_update(C, &but->rnapoin, but->rnaprop);
2190  }
2191  else if (RNA_property_subtype(but->rnaprop) == PROP_COLOR) {
2192  if (gamma) {
2194  }
2196  RNA_property_update(C, &but->rnapoin, but->rnaprop);
2197  }
2198  }
2199  else {
2200  if (gamma) {
2202  }
2203 
2204  ED_imapaint_bucket_fill(C, color, op, event->mval);
2205  }
2206 
2207  ED_region_tag_redraw(region);
2208 
2209  return OPERATOR_FINISHED;
2210 }
2211 
2213 {
2214  ot->name = "Drop Color";
2215  ot->idname = "UI_OT_drop_color";
2216  ot->description = "Drop colors to buttons";
2217 
2219  ot->flag = OPTYPE_INTERNAL;
2220 
2221  RNA_def_float_color(ot->srna, "color", 3, NULL, 0.0, FLT_MAX, "Color", "Source color", 0.0, 1.0);
2222  RNA_def_boolean(ot->srna, "gamma", 0, "Gamma Corrected", "The source color is gamma corrected");
2223 }
2224 
2227 /* -------------------------------------------------------------------- */
2232 {
2233  if (!ED_operator_regionactive(C)) {
2234  return false;
2235  }
2236 
2237  const uiBut *but = UI_but_active_drop_name_button(C);
2238  if (!but) {
2239  return false;
2240  }
2241 
2242  if (but->flag & UI_BUT_DISABLED) {
2243  return false;
2244  }
2245 
2246  return true;
2247 }
2248 
2249 static int drop_name_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
2250 {
2252  char *str = RNA_string_get_alloc(op->ptr, "string", NULL, 0, NULL);
2253 
2254  if (str) {
2256  MEM_freeN(str);
2257  }
2258 
2259  return OPERATOR_FINISHED;
2260 }
2261 
2263 {
2264  ot->name = "Drop Name";
2265  ot->idname = "UI_OT_drop_name";
2266  ot->description = "Drop name to button";
2267 
2268  ot->poll = drop_name_poll;
2271 
2273  ot->srna, "string", NULL, 0, "String", "The string value to drop into the button");
2274 }
2275 
2278 /* -------------------------------------------------------------------- */
2283 {
2284  const ARegion *region = CTX_wm_region(C);
2285  if (!region) {
2286  return false;
2287  }
2288  const wmWindow *win = CTX_wm_window(C);
2289  const uiList *list = UI_list_find_mouse_over(region, win->eventstate);
2290 
2291  return list != NULL;
2292 }
2293 
2299 {
2300  if (list->filter_flag & UILST_FLT_SHOW) {
2301  /* Nothing to be done. */
2302  return false;
2303  }
2304 
2305  list->filter_flag |= UILST_FLT_SHOW;
2306  return true;
2307 }
2308 
2310 {
2311  ARegion *region = CTX_wm_region(C);
2312  uiList *list = UI_list_find_mouse_over(region, event);
2313  /* Poll should check. */
2314  BLI_assert(list != NULL);
2315 
2316  if (ui_list_unhide_filter_options(list)) {
2318  }
2319 
2320  if (!UI_textbutton_activate_rna(C, region, list, "filter_name")) {
2321  return OPERATOR_CANCELLED;
2322  }
2323 
2324  return OPERATOR_FINISHED;
2325 }
2326 
2328 {
2329  ot->name = "List Filter";
2330  ot->idname = "UI_OT_list_start_filter";
2331  ot->description = "Start entering filter text for the list in focus";
2332 
2335 }
2336 
2339 /* -------------------------------------------------------------------- */
2344 {
2345  const wmWindow *win = CTX_wm_window(C);
2346  const ARegion *region = CTX_wm_region(C);
2347  if (region == NULL) {
2348  return false;
2349  }
2350  const uiViewItemHandle *hovered_item = UI_region_views_find_item_at(region, win->eventstate->xy);
2351 
2352  return hovered_item != NULL;
2353 }
2354 
2355 static int ui_view_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
2356 {
2357  if (event->custom != EVT_DATA_DRAGDROP) {
2359  }
2360 
2361  const ARegion *region = CTX_wm_region(C);
2362  uiViewItemHandle *hovered_item = UI_region_views_find_item_at(region, event->xy);
2363 
2364  if (!UI_view_item_drop_handle(C, hovered_item, event->customdata)) {
2366  }
2367 
2368  return OPERATOR_FINISHED;
2369 }
2370 
2372 {
2373  ot->name = "View drop";
2374  ot->idname = "UI_OT_view_drop";
2375  ot->description = "Drag and drop items onto a data-set item";
2376 
2379 
2380  ot->flag = OPTYPE_INTERNAL;
2381 }
2382 
2385 /* -------------------------------------------------------------------- */
2395 {
2396  const ARegion *region = CTX_wm_region(C);
2397  if (region == NULL) {
2398  return false;
2399  }
2400  const uiViewItemHandle *active_item = UI_region_views_find_active_item(region);
2401  return active_item != NULL && UI_view_item_can_rename(active_item);
2402 }
2403 
2405 {
2406  ARegion *region = CTX_wm_region(C);
2407  uiViewItemHandle *active_item = UI_region_views_find_active_item(region);
2408 
2409  UI_view_item_begin_rename(active_item);
2410  ED_region_tag_redraw(region);
2411 
2412  return OPERATOR_FINISHED;
2413 }
2414 
2416 {
2417  ot->name = "Rename View Item";
2418  ot->idname = "UI_OT_view_item_rename";
2419  ot->description = "Rename the active item in the data-set view";
2420 
2423  /* Could get a custom tooltip via the `get_description()` callback and another overridable
2424  * function of the view. */
2425 
2426  ot->flag = OPTYPE_INTERNAL;
2427 }
2430 /* -------------------------------------------------------------------- */
2436 {
2437  PointerRNA ptr = CTX_data_pointer_get_type(C, "object", &RNA_Object);
2438  Object *ob = ptr.data;
2439  if (ob == NULL) {
2440  return false;
2441  }
2442 
2443  PointerRNA mat_slot = CTX_data_pointer_get_type(C, "material_slot", &RNA_MaterialSlot);
2444  if (RNA_pointer_is_null(&mat_slot)) {
2445  return false;
2446  }
2447 
2448  return true;
2449 }
2450 
2452 {
2453  Main *bmain = CTX_data_main(C);
2454 
2456  bmain, op->ptr, ID_MA);
2457  if (ma == NULL) {
2458  return OPERATOR_CANCELLED;
2459  }
2460 
2461  PointerRNA ptr = CTX_data_pointer_get_type(C, "object", &RNA_Object);
2462  Object *ob = ptr.data;
2463  BLI_assert(ob);
2464 
2465  PointerRNA mat_slot = CTX_data_pointer_get_type(C, "material_slot", &RNA_MaterialSlot);
2466  BLI_assert(mat_slot.data);
2467  const int target_slot = RNA_int_get(&mat_slot, "slot_index") + 1;
2468 
2469  /* only drop grease pencil material on grease pencil objects */
2470  if ((ma->gp_style != NULL) && (ob->type != OB_GPENCIL)) {
2471  return OPERATOR_CANCELLED;
2472  }
2473 
2474  BKE_object_material_assign(bmain, ob, ma, target_slot, BKE_MAT_ASSIGN_USERPREF);
2475 
2480 
2481  return OPERATOR_FINISHED;
2482 }
2483 
2485 {
2486  ot->name = "Drop Material in Material slots";
2487  ot->description = "Drag material to Material slots in Properties";
2488  ot->idname = "UI_OT_drop_material";
2489 
2493 
2495 }
2496 
2499 /* -------------------------------------------------------------------- */
2504 {
2516 #ifdef WITH_PYTHON
2517  WM_operatortype_append(UI_OT_editsource);
2518  WM_operatortype_append(UI_OT_edittranslation_init);
2519 #endif
2523 
2525 
2528 
2535 
2536  /* external */
2544 }
2545 
2547 {
2548  WM_keymap_ensure(keyconf, "User Interface", 0, 0);
2549 
2550  eyedropper_modal_keymap(keyconf);
2552 }
2553 
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
void CTX_wm_region_set(bContext *C, struct ARegion *region)
Definition: context.c:1009
PointerRNA CTX_data_pointer_get_type_silent(const bContext *C, const char *member, StructRNA *type)
Definition: context.c:492
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
Definition: context.c:473
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1100
struct bScreen * CTX_wm_screen(const bContext *C)
Definition: context.c:733
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:749
struct SpaceImage * CTX_wm_space_image(const bContext *C)
Definition: context.c:824
ListBase CTX_data_collection_get(const bContext *C, const char *member)
Definition: context.c:503
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1074
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:723
struct Base * BKE_view_layer_base_find(struct ViewLayer *view_layer, struct Object *ob)
Definition: layer.c:379
void BKE_id_delete(struct Main *bmain, void *idv) ATTR_NONNULL()
struct IDOverrideLibraryPropertyOperation * BKE_lib_override_library_property_operation_find(struct IDOverrideLibraryProperty *override_property, const char *subitem_refname, const char *subitem_locname, int subitem_refindex, int subitem_locindex, bool strict, bool *r_strict)
struct IDOverrideLibraryPropertyOperation * BKE_lib_override_library_property_operation_get(struct IDOverrideLibraryProperty *override_property, short operation, const char *subitem_refname, const char *subitem_locname, int subitem_refindex, int subitem_locindex, bool strict, bool *r_strict, bool *r_created)
bool BKE_lib_override_library_is_hierarchy_leaf(struct Main *bmain, struct ID *id)
void BKE_lib_override_library_property_operation_delete(struct IDOverrideLibraryProperty *override_property, struct IDOverrideLibraryPropertyOperation *override_property_operation)
void BKE_lib_override_library_id_reset(struct Main *bmain, struct ID *id_root, bool do_reset_system_override)
void BKE_lib_override_library_property_delete(struct IDOverrideLibrary *override, struct IDOverrideLibraryProperty *override_property)
@ ID_REMAP_SKIP_INDIRECT_USAGE
Definition: BKE_lib_remap.h:36
void void BKE_libblock_remap(struct Main *bmain, void *old_idv, void *new_idv, short remap_flags) ATTR_NONNULL(1
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
General operations, lookup, etc. for materials.
void BKE_object_material_assign(struct Main *bmain, struct Object *ob, struct Material *ma, short act, int assign_type)
Definition: material.c:1047
@ BKE_MAT_ASSIGN_USERPREF
Definition: BKE_material.h:80
bool nodeFindNode(struct bNodeTree *ntree, struct bNodeSocket *sock, struct bNode **r_node, int *r_sockindex)
Definition: node.cc:1997
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition: report.c:83
struct ARegion * BKE_screen_find_region_xy(struct bScreen *screen, int regiontype, const int xy[2]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
struct Text struct Text * BKE_text_load(struct Main *bmain, const char *filepath, const char *relbase) ATTR_NONNULL(1
void txt_move_toline(struct Text *text, unsigned int line, bool sel)
Definition: text.c:1091
void BLF_cache_clear(void)
Definition: blf.c:83
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
bool BLI_is_file(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: storage.c:402
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: storage.c:397
BLI_INLINE void * BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.h:298
void BLI_ghashIterator_step(GHashIterator *ghi)
Definition: BLI_ghash.c:914
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.h:302
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:734
bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:790
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition: BLI_ghash.c:710
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:863
GHash * BLI_ghash_ptr_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh)
Definition: BLI_ghash.c:898
BLI_INLINE bool BLI_ghashIterator_done(const GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.h:310
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:269
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
Definition: BLI_listbase.h:354
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:466
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:100
MINLINE void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
#define FILE_MAX
void BLI_path_append(char *__restrict dst, size_t maxlen, const char *__restrict file) ATTR_NONNULL()
Definition: path_util.c:1514
#define BLI_path_cmp
void BLI_join_dirfile(char *__restrict dst, size_t maxlen, const char *__restrict dir, const char *__restrict file) ATTR_NONNULL()
Definition: path_util.c:1531
bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, float limit)
size_t size_t char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
unsigned int uint
Definition: BLI_sys_types.h:67
#define STREQLEN(a, b, n)
#define UNUSED(x)
#define ELEM(...)
#define STREQ(a, b)
const char * BLT_lang_get(void)
Definition: blt_lang.c:269
void BLT_lang_init(void)
Definition: blt_lang.c:179
void BLT_lang_set(const char *)
Definition: blt_lang.c:238
#define IFACE_(msgid)
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_TRANSFORM
Definition: DNA_ID.h:771
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:834
@ ID_RECALC_SELECT
Definition: DNA_ID.h:818
@ ID_RECALC_BASE_FLAGS
Definition: DNA_ID.h:821
#define ID_IS_OVERRIDE_LIBRARY_REAL(_id)
Definition: DNA_ID.h:581
#define ID_CHECK_UNDO(id)
Definition: DNA_ID.h:556
#define ID_IS_LINKED(_id)
Definition: DNA_ID.h:566
@ IDOVERRIDE_LIBRARY_OP_MULTIPLY
Definition: DNA_ID.h:227
@ IDOVERRIDE_LIBRARY_OP_NOOP
Definition: DNA_ID.h:218
@ IDOVERRIDE_LIBRARY_OP_ADD
Definition: DNA_ID.h:223
@ IDOVERRIDE_LIBRARY_OP_REPLACE
Definition: DNA_ID.h:220
@ LIB_TAG_DOIT
Definition: DNA_ID.h:707
#define ID_IS_OVERRIDE_LIBRARY_TEMPLATE(_id)
Definition: DNA_ID.h:595
@ ID_SCE
Definition: DNA_ID_enums.h:45
@ ID_MA
Definition: DNA_ID_enums.h:51
@ ID_OB
Definition: DNA_ID_enums.h:47
#define MAXBONENAME
Object is a sort of wrapper for general info.
#define OB_DATA_SUPPORT_ID(_id_type)
@ OB_ARMATURE
@ OB_GPENCIL
#define OBACT(_view_layer)
@ RGN_TYPE_WINDOW
#define RGN_TYPE_ANY
@ UILST_FLT_SHOW
@ SI_MODE_PAINT
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_PASS_THROUGH
bool ED_object_jump_to_object(struct bContext *C, struct Object *ob, bool reveal_hidden)
struct Base * ED_object_find_first_by_data_id(struct ViewLayer *view_layer, struct ID *id)
bool ED_object_jump_to_bone(struct bContext *C, struct Object *ob, const char *bone_name, bool reveal_hidden)
void ED_imapaint_bucket_fill(struct bContext *C, float color[3], struct wmOperator *op, const int mouse[2])
Definition: paint_image.cc:961
void ED_region_do_layout(struct bContext *C, struct ARegion *region)
Definition: area.c:494
bool ED_operator_regionactive(struct bContext *C)
Definition: screen_ops.c:91
void ED_region_do_draw(struct bContext *C, struct ARegion *region)
Definition: area.c:517
void ED_region_tag_redraw(struct ARegion *region)
Definition: area.c:655
bool ED_text_activate_in_screen(struct bContext *C, struct Text *text)
_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
BLI_INLINE void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3])
BLI_INLINE void IMB_colormanagement_scene_linear_to_srgb_v3(float srgb[3], const float scene_linear[3])
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
@ RNA_OVERRIDE_STATUS_OVERRIDABLE
Definition: RNA_access.h:817
@ RNA_OVERRIDE_STATUS_OVERRIDDEN
Definition: RNA_access.h:819
PropertyType
Definition: RNA_types.h:58
@ PROP_FLOAT
Definition: RNA_types.h:61
@ PROP_BOOLEAN
Definition: RNA_types.h:59
@ PROP_ENUM
Definition: RNA_types.h:63
@ PROP_INT
Definition: RNA_types.h:60
@ PROP_STRING
Definition: RNA_types.h:62
@ PROP_POINTER
Definition: RNA_types.h:64
@ PROP_SKIP_SAVE
Definition: RNA_types.h:218
@ PROP_COLOR
Definition: RNA_types.h:153
@ PROP_COLOR_GAMMA
Definition: RNA_types.h:165
#define C
Definition: RandGen.cpp:25
bool UI_view_item_drop_handle(struct bContext *C, const uiViewItemHandle *item_, const struct ListBase *drags)
@ UI_BUT_DISABLED
Definition: UI_interface.h:196
struct PointerRNA * UI_but_operator_ptr_get(uiBut *but)
Definition: interface.cc:5908
uiBut * UI_context_active_but_get(const struct bContext *C)
uiViewItemHandle * UI_region_views_find_active_item(const struct ARegion *region)
uiViewItemHandle * UI_region_views_find_item_at(const struct ARegion *region, const int xy[2]) ATTR_NONNULL()
bool UI_but_active_drop_color(struct bContext *C)
void UI_context_active_but_prop_get_templateID(struct bContext *C, struct PointerRNA *r_ptr, struct PropertyRNA **r_prop)
void UI_editsource_but_replace(const uiBut *old_but, uiBut *new_but)
#define EDTSRC_I18N_OP_NAME
void UI_editsource_active_but_test(uiBut *but)
void UI_context_active_but_prop_handle(struct bContext *C, bool handle_undo)
#define UI_MAX_DRAW_STR
Definition: UI_interface.h:91
bool UI_editsource_enable_check(void)
@ BUT_GET_RNA_TIP
@ BUT_GET_RNA_LABEL
@ BUT_GET_LABEL
@ BUT_GET_TIP
@ BUT_GET_RNAENUM_TIP
@ BUT_GET_RNASTRUCT_IDENTIFIER
@ BUT_GET_RNAENUM_LABEL
@ BUT_GET_RNAPROP_IDENTIFIER
@ BUT_GET_RNA_LABEL_CONTEXT
@ BUT_GET_RNAENUM_IDENTIFIER
void UI_but_execute(const struct bContext *C, struct ARegion *region, uiBut *but)
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname)
bool UI_view_item_can_rename(const uiViewItemHandle *item_handle)
uiBut * UI_context_active_but_prop_get(const struct bContext *C, struct PointerRNA *r_ptr, struct PropertyRNA **r_prop, int *r_index)
bool UI_textbutton_activate_rna(const struct bContext *C, struct ARegion *region, const void *rna_poin_data, const char *rna_prop_id)
struct uiList * UI_list_find_mouse_over(const struct ARegion *region, const struct wmEvent *event)
void UI_view_item_begin_rename(uiViewItemHandle *item_handle)
void UI_reinit_font(void)
Definition: interface.cc:6782
struct uiViewItemHandle uiViewItemHandle
Definition: UI_interface.h:78
@ UI_BTYPE_SEARCH_MENU
Definition: UI_interface.h:372
@ UI_BTYPE_COLOR
Definition: UI_interface.h:349
uiBut * UI_context_active_but_get_respect_menu(const struct bContext *C)
uiBut * UI_but_active_drop_name_button(const struct bContext *C)
void UI_screen_free_active_but_highlight(const struct bContext *C, struct bScreen *screen)
void UI_but_string_info_get(struct bContext *C, uiBut *but,...) ATTR_SENTINEL(0)
Definition: interface.cc:6494
@ OPTYPE_INTERNAL
Definition: WM_types.h:168
@ OPTYPE_UNDO
Definition: WM_types.h:148
@ OPTYPE_REGISTER
Definition: WM_types.h:146
#define NC_WINDOW
Definition: WM_types.h:325
#define NC_WM
Definition: WM_types.h:324
#define ND_CURSOR
Definition: WM_types.h:438
#define ND_LIB_OVERRIDE_CHANGED
Definition: WM_types.h:367
#define NC_TEXT
Definition: WM_types.h:336
#define NC_MATERIAL
Definition: WM_types.h:330
@ WM_OP_INVOKE_DEFAULT
Definition: WM_types.h:201
#define ND_OB_SHADING
Definition: WM_types.h:406
#define ND_SPACE_VIEW3D
Definition: WM_types.h:471
#define NC_OBJECT
Definition: WM_types.h:329
#define ND_SHADING_LINKS
Definition: WM_types.h:427
#define NC_SPACE
Definition: WM_types.h:342
#define WM_DRAG_COLOR
Definition: WM_types.h:1053
__forceinline bool all(const avxb &b)
Definition: avxb.h:201
unsigned int U
Definition: btGjkEpa3.h:78
OperationNode * node
Scene scene
SyclQueue void void * src
void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const char *var_name)
Definition: drivers.c:792
bNodeTree * ntree
void UI_OT_eyedropper_color(wmOperatorType *ot)
void UI_OT_eyedropper_colorramp_point(wmOperatorType *ot)
void UI_OT_eyedropper_colorramp(wmOperatorType *ot)
void UI_OT_eyedropper_id(wmOperatorType *ot)
void UI_OT_eyedropper_depth(wmOperatorType *ot)
void UI_OT_eyedropper_driver(wmOperatorType *ot)
void UI_OT_eyedropper_gpencil_color(wmOperatorType *ot)
#define str(s)
wmKeyMap * eyedropper_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap * eyedropper_colorband_modal_keymap(wmKeyConfig *keyconf)
void ui_but_active_string_clear_and_exit(bContext *C, uiBut *but)
void ui_but_set_string_interactive(bContext *C, uiBut *but, const char *value)
void ui_rna_collection_search_update_fn(const struct bContext *C, void *arg, const char *str, uiSearchItems *items, bool is_first)
uiBut * ui_region_find_active_but(struct ARegion *region) ATTR_WARN_UNUSED_RESULT
struct ID * ui_template_id_liboverride_hierarchy_make(struct bContext *C, struct Main *bmain, struct ID *owner_id, struct ID *id, const char **r_undo_push_label)
@ UI_SELECT_DRAW
@ UI_SELECT
static bool ui_list_unhide_filter_options(uiList *list)
static int drop_name_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int unset_property_button_exec(bContext *C, wmOperator *UNUSED(op))
static void UI_OT_override_type_set_button(wmOperatorType *ot)
static int copy_to_selected_button_exec(bContext *C, wmOperator *op)
static bool override_type_set_button_poll(bContext *C)
static void UI_OT_override_idtemplate_reset(wmOperatorType *ot)
static void override_idtemplate_ids_get(bContext *C, ID **r_owner_id, ID **r_id, PointerRNA *r_owner_ptr, PropertyRNA **r_prop)
static void UI_OT_unset_property_button(wmOperatorType *ot)
static void override_idtemplate_menu(void)
static int ui_list_start_filter_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static bool ui_list_focused_poll(bContext *C)
static void UI_OT_button_execute(wmOperatorType *ot)
static bool override_remove_button_poll(bContext *C)
static bool ui_view_drop_poll(bContext *C)
static void ui_region_redraw_immediately(bContext *C, ARegion *region)
Definition: interface_ops.c:83
static int override_type_set_button_exec(bContext *C, wmOperator *op)
static bool reset_default_button_poll(bContext *C)
static int operator_button_property_finish(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
static int ui_button_press_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void UI_OT_copy_data_path_button(wmOperatorType *ot)
static int override_idtemplate_clear_exec(bContext *C, wmOperator *UNUSED(op))
static void UI_OT_reloadtranslation(wmOperatorType *ot)
static int reset_default_button_exec(bContext *C, wmOperator *op)
bool ui_jump_to_target_button_poll(bContext *C)
static bool copy_data_path_button_poll(bContext *C)
Definition: interface_ops.c:98
static void UI_OT_copy_python_command_button(wmOperatorType *ot)
static void UI_OT_assign_default_button(wmOperatorType *ot)
static void UI_OT_override_idtemplate_clear(wmOperatorType *ot)
static int copy_python_command_button_exec(bContext *C, wmOperator *UNUSED(op))
void ED_operatortypes_ui(void)
#define NOT_NULL(assignment)
static int override_type_set_button_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int reloadtranslation_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
static void UI_OT_list_start_filter(wmOperatorType *ot)
static int ui_view_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static bool copy_to_selected_button_poll(bContext *C)
static bool copy_to_selected_button(bContext *C, bool all, bool poll)
static void UI_OT_jump_to_target_button(wmOperatorType *ot)
static void UI_OT_drop_name(wmOperatorType *ot)
static void UI_OT_copy_to_selected_button(wmOperatorType *ot)
static int override_idtemplate_make_exec(bContext *C, wmOperator *UNUSED(op))
void UI_drop_color_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop)
static int override_remove_button_exec(bContext *C, wmOperator *op)
static void UI_OT_drop_material(wmOperatorType *ot)
static int ui_view_item_rename_exec(bContext *C, wmOperator *UNUSED(op))
static void override_idtemplate_menu_draw(const bContext *UNUSED(C), Menu *menu)
static bool override_idtemplate_reset_poll(bContext *C)
static int jump_to_target_button_exec(bContext *C, wmOperator *UNUSED(op))
bool UI_context_copy_to_selected_list(bContext *C, PointerRNA *ptr, PropertyRNA *prop, ListBase *r_lb, bool *r_use_path_from_id, char **r_path)
static bool jump_to_target_button(bContext *C, bool poll)
static void UI_OT_override_remove_button(wmOperatorType *ot)
static void UI_OT_button_string_clear(wmOperatorType *ot)
static int override_idtemplate_reset_exec(bContext *C, wmOperator *UNUSED(op))
static bool drop_name_poll(bContext *C)
#define NOT_RNA_NULL(assignment)
static bool copy_python_command_button_poll(bContext *C)
static int assign_default_button_exec(bContext *C, wmOperator *UNUSED(op))
static int copy_data_path_button_exec(bContext *C, wmOperator *op)
static void UI_OT_reset_default_button(wmOperatorType *ot)
void ED_keymap_ui(wmKeyConfig *keyconf)
User Interface Keymap.
static void UI_OT_override_idtemplate_make(wmOperatorType *ot)
static bool assign_default_button_poll(bContext *C)
static int ui_drop_material_exec(bContext *C, wmOperator *op)
static void UI_OT_view_drop(wmOperatorType *ot)
static void UI_OT_copy_as_driver_button(wmOperatorType *ot)
static int drop_color_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool jump_to_target_ptr(bContext *C, PointerRNA ptr, const bool poll)
static bool override_idtemplate_clear_poll(bContext *C)
static EnumPropertyItem override_type_items[]
static int copy_as_driver_button_exec(bContext *C, wmOperator *op)
bool UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent *UNUSED(event))
static bool ui_drop_material_poll(bContext *C)
static bool copy_as_driver_button_poll(bContext *C)
static int operator_button_property_finish_with_undo(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
static void UI_OT_drop_color(wmOperatorType *ot)
bool UI_context_copy_to_selected_check(PointerRNA *ptr, PointerRNA *ptr_link, PropertyRNA *prop, const char *path, bool use_path_from_id, PointerRNA *r_ptr, PropertyRNA **r_prop)
static bool ui_view_item_rename_poll(bContext *C)
static void UI_OT_view_item_rename(wmOperatorType *ot)
static void ui_context_selected_bones_via_pose(bContext *C, ListBase *r_lb)
static bool override_idtemplate_make_poll(bContext *C)
static bool override_idtemplate_menu_poll(const bContext *C_const, MenuType *UNUSED(mt))
static bool override_idtemplate_poll(bContext *C, const bool is_create_op)
@ UIOverride_Type_Replace
@ UIOverride_Type_Difference
@ UIOverride_Type_NOOP
@ UIOverride_Type_Factor
static int button_string_clear_exec(bContext *C, wmOperator *UNUSED(op))
#define GS(x)
Definition: iris.c:225
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
#define hash
Definition: noise.c:153
void PyC_FileAndNum_Safe(const char **r_filename, int *r_lineno)
return ret
bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:1966
bool RNA_property_array_check(PropertyRNA *prop)
Definition: rna_access.c:1080
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
Definition: rna_access.c:695
bool RNA_property_assign_default(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:6744
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:136
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
Definition: rna_access.c:5155
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
Definition: rna_access.c:112
const char * RNA_property_identifier(const PropertyRNA *prop)
Definition: rna_access.c:1000
bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
Definition: rna_access.c:6649
float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
Definition: rna_access.c:2954
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value, ReportList *reports)
Definition: rna_access.c:3532
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
Definition: rna_access.c:4874
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:5271
PropertyType RNA_property_type(PropertyRNA *prop)
Definition: rna_access.c:1010
const PointerRNA PointerRNA_NULL
Definition: rna_access.c:61
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3493
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
Definition: rna_access.c:4980
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2138
char * RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len)
Definition: rna_access.c:3178
int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, const char *key, PointerRNA *r_ptr)
Definition: rna_access.c:4184
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
Definition: rna_access.c:5116
int RNA_int_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4910
int RNA_property_array_dimension(const PointerRNA *ptr, PropertyRNA *prop, int length[])
Definition: rna_access.c:1085
PropertyRNA * RNA_struct_type_find_property(StructRNA *srna, const char *identifier)
Definition: rna_access.c:806
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen, int *r_len)
Definition: rna_access.c:5129
bool RNA_pointer_is_null(const PointerRNA *ptr)
Definition: rna_access.c:164
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:1075
bool RNA_property_is_idprop(const PropertyRNA *prop)
Definition: rna_access.c:5322
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
Definition: rna_access.c:2978
PropertySubType RNA_property_subtype(PropertyRNA *prop)
Definition: rna_access.c:1015
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4863
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
Definition: rna_access.c:5015
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
Definition: rna_access.c:4992
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
void RNA_property_unset(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:5281
IDOverrideLibraryPropertyOperation * RNA_property_override_property_operation_get(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, const short operation, const int index, const bool strict, bool *r_strict, bool *r_created)
IDOverrideLibraryProperty * RNA_property_override_property_find(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, ID **r_owner_id)
eRNAOverrideStatus RNA_property_override_library_status(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, const int index)
bool RNA_property_copy(Main *bmain, PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, int index)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
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:3687
PropertyRNA * RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3922
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1490
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:3783
StructRNA RNA_PropertyGroup
char * RNA_path_full_struct_py(Main *bmain, const PointerRNA *ptr)
Definition: rna_path.cc:1217
char * RNA_path_from_struct_to_idproperty(PointerRNA *ptr, IDProperty *needle)
Definition: rna_path.cc:893
char * RNA_path_resolve_from_type_to_property(const PointerRNA *ptr, PropertyRNA *prop, const StructRNA *type)
Definition: rna_path.cc:1146
char * RNA_path_from_ID_to_property(const PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_path.cc:1127
bool RNA_path_resolve_property(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
Definition: rna_path.cc:531
char * RNA_path_from_real_ID_to_property_index(Main *bmain, const PointerRNA *ptr, PropertyRNA *prop, int index_dim, int index, ID **r_real_id)
Definition: rna_path.cc:1132
char * RNA_path_full_property_py_ex(Main *bmain, const PointerRNA *ptr, PropertyRNA *prop, int index, bool use_fallback)
Definition: rna_path.cc:1245
short regiontype
struct Object * object
struct ID * reference
Definition: DNA_ID.h:294
Definition: DNA_ID.h:368
int tag
Definition: DNA_ID.h:387
IDOverrideLibrary * override_library
Definition: DNA_ID.h:412
char name[66]
Definition: DNA_ID.h:378
Definition: BKE_main.h:121
ListBase texts
Definition: BKE_main.h:185
char filepath[1024]
Definition: BKE_main.h:124
struct MaterialGPencilStyle * gp_style
char label[BKE_ST_MAXNAME]
Definition: BKE_screen.h:362
char idname[BKE_ST_MAXNAME]
Definition: BKE_screen.h:361
bool(* poll)(const struct bContext *C, struct MenuType *mt)
Definition: BKE_screen.h:368
void(* draw)(const struct bContext *C, struct Menu *menu)
Definition: BKE_screen.h:370
struct uiLayout * layout
Definition: BKE_screen.h:378
struct bNodeTree * node_group
void * data
struct StructRNA * type
Definition: RNA_types.h:37
void * data
Definition: RNA_types.h:38
struct ID * owner_id
Definition: RNA_types.h:36
struct Image * image
struct Base * basact
short type
struct Bone * bone
uiButSearchUpdateFn items_update_fn
eButType type
uchar unit_type
struct wmOperatorType * optype
char drawstr[UI_MAX_DRAW_STR]
struct PropertyRNA * rnaprop
struct PointerRNA rnapoin
void * poin
Definition: WM_types.h:1149
int type
Definition: WM_types.h:1148
struct PointerRNA * ptr
Definition: WM_types.h:1237
short custom
Definition: WM_types.h:712
int xy[2]
Definition: WM_types.h:682
int mval[2]
Definition: WM_types.h:684
void * customdata
Definition: WM_types.h:715
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:919
const char * name
Definition: WM_types.h:888
const char * idname
Definition: WM_types.h:890
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:943
struct StructRNA * srna
Definition: WM_types.h:969
const char * description
Definition: WM_types.h:893
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:903
PropertyRNA * prop
Definition: WM_types.h:981
struct ReportList * reports
struct PointerRNA * ptr
struct wmEvent * eventstate
#define N_(msgid)
void WM_draw_region_viewport_unbind(ARegion *region)
Definition: wm_draw.c:1416
void WM_draw_region_viewport_bind(ARegion *region)
Definition: wm_draw.c:1411
void WM_main_add_notifier(unsigned int type, void *reference)
int WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_event_add_mousemove(wmWindow *win)
@ EVT_DATA_DRAGDROP
PointerRNA * ptr
Definition: wm_files.c:3480
wmOperatorType * ot
Definition: wm_files.c:3479
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition: wm_keymap.c:852
bool WM_menutype_add(MenuType *mt)
Definition: wm_menu_type.c:51
ID * WM_operator_properties_id_lookup_from_name_or_session_uuid(Main *bmain, PointerRNA *ptr, const ID_Type type)
void WM_operator_properties_id_lookup(wmOperatorType *ot, const bool add_name_prop)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
int WM_menu_invoke_ex(bContext *C, wmOperator *op, wmOperatorCallContext opcontext)
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:192
void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot)
Definition: wm_operators.c:661
void WM_clipboard_text_set(const char *buf, bool selection)
Definition: wm_window.c:1780