Blender  V2.93
interface_ops.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2009 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include <string.h>
25 
26 #include "MEM_guardedalloc.h"
27 
28 #include "DNA_armature_types.h"
29 #include "DNA_object_types.h" /* for OB_DATA_SUPPORT_ID */
30 #include "DNA_screen_types.h"
31 #include "DNA_text_types.h"
32 
33 #include "BLI_blenlib.h"
34 #include "BLI_math_color.h"
35 
36 #include "BLF_api.h"
37 #include "BLT_lang.h"
38 
39 #include "BKE_context.h"
40 #include "BKE_global.h"
41 #include "BKE_idprop.h"
42 #include "BKE_layer.h"
43 #include "BKE_lib_id.h"
44 #include "BKE_lib_override.h"
45 #include "BKE_node.h"
46 #include "BKE_report.h"
47 #include "BKE_screen.h"
48 #include "BKE_text.h"
49 
50 #include "IMB_colormanagement.h"
51 
52 #include "DEG_depsgraph.h"
53 
54 #include "RNA_access.h"
55 #include "RNA_define.h"
56 #include "RNA_types.h"
57 
58 #include "UI_interface.h"
59 
60 #include "interface_intern.h"
61 
62 #include "WM_api.h"
63 #include "WM_types.h"
64 
65 #include "ED_object.h"
66 #include "ED_paint.h"
67 
68 /* for Copy As Driver */
69 #include "ED_keyframing.h"
70 
71 /* only for UI_OT_editsource */
72 #include "BKE_main.h"
73 #include "BLI_ghash.h"
74 #include "ED_screen.h"
75 #include "ED_text.h"
76 
77 /* -------------------------------------------------------------------- */
82 {
84  PropertyRNA *prop;
85  char *path;
86  int index;
87 
88  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
89 
90  if (ptr.owner_id && ptr.data && prop) {
91  path = RNA_path_from_ID_to_property(&ptr, prop);
92 
93  if (path) {
94  MEM_freeN(path);
95  return true;
96  }
97  }
98 
99  return false;
100 }
101 
103 {
104  Main *bmain = CTX_data_main(C);
105  PointerRNA ptr;
106  PropertyRNA *prop;
107  char *path;
108  int index;
109  ID *id;
110 
111  const bool full_path = RNA_boolean_get(op->ptr, "full_path");
112 
113  /* try to create driver using property retrieved from UI */
114  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
115 
116  if (ptr.owner_id != NULL) {
117  if (full_path) {
118  if (prop) {
119  path = RNA_path_full_property_py_ex(bmain, &ptr, prop, index, true);
120  }
121  else {
122  path = RNA_path_full_struct_py(bmain, &ptr);
123  }
124  }
125  else {
126  path = RNA_path_from_real_ID_to_property_index(bmain, &ptr, prop, 0, -1, &id);
127 
128  if (!path) {
129  path = RNA_path_from_ID_to_property(&ptr, prop);
130  }
131  }
132 
133  if (path) {
134  WM_clipboard_text_set(path, false);
135  MEM_freeN(path);
136  return OPERATOR_FINISHED;
137  }
138  }
139 
140  return OPERATOR_CANCELLED;
141 }
142 
144 {
145  PropertyRNA *prop;
146 
147  /* identifiers */
148  ot->name = "Copy Data Path";
149  ot->idname = "UI_OT_copy_data_path_button";
150  ot->description = "Copy the RNA data path for this property to the clipboard";
151 
152  /* callbacks */
155 
156  /* flags */
158 
159  /* properties */
160  prop = RNA_def_boolean(ot->srna, "full_path", false, "full_path", "Copy full data path");
162 }
163 
166 /* -------------------------------------------------------------------- */
171 {
172  PointerRNA ptr;
173  PropertyRNA *prop;
174  char *path;
175  int index;
176 
177  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
178 
179  if (ptr.owner_id && ptr.data && prop &&
181  (index >= 0 || !RNA_property_array_check(prop))) {
182  path = RNA_path_from_ID_to_property(&ptr, prop);
183 
184  if (path) {
185  MEM_freeN(path);
186  return true;
187  }
188  }
189 
190  return false;
191 }
192 
194 {
195  Main *bmain = CTX_data_main(C);
196  PointerRNA ptr;
197  PropertyRNA *prop;
198  int index;
199 
200  /* try to create driver using property retrieved from UI */
201  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
202 
203  if (ptr.owner_id && ptr.data && prop) {
204  ID *id;
205  const int dim = RNA_property_array_dimension(&ptr, prop, NULL);
206  char *path = RNA_path_from_real_ID_to_property_index(bmain, &ptr, prop, dim, index, &id);
207 
208  if (path) {
210  MEM_freeN(path);
211  return OPERATOR_FINISHED;
212  }
213 
214  BKE_reportf(op->reports, RPT_ERROR, "Could not compute a valid data path");
215  return OPERATOR_CANCELLED;
216  }
217 
218  return OPERATOR_CANCELLED;
219 }
220 
222 {
223  /* identifiers */
224  ot->name = "Copy as New Driver";
225  ot->idname = "UI_OT_copy_as_driver_button";
226  ot->description =
227  "Create a new driver with this property as input, and copy it to the "
228  "clipboard. Use Paste Driver to add it to the target property, or Paste "
229  "Driver Variables to extend an existing driver";
230 
231  /* callbacks */
234 
235  /* flags */
237 }
238 
241 /* -------------------------------------------------------------------- */
246 {
248 
249  if (but && (but->optype != NULL)) {
250  return 1;
251  }
252 
253  return 0;
254 }
255 
257 {
259 
260  if (but && (but->optype != NULL)) {
261  PointerRNA *opptr;
262  char *str;
263  opptr = UI_but_operator_ptr_get(but); /* allocated when needed, the button owns it */
264 
265  str = WM_operator_pystring_ex(C, NULL, false, true, but->optype, opptr);
266 
268 
269  MEM_freeN(str);
270 
271  return OPERATOR_FINISHED;
272  }
273 
274  return OPERATOR_CANCELLED;
275 }
276 
278 {
279  /* identifiers */
280  ot->name = "Copy Python Command";
281  ot->idname = "UI_OT_copy_python_command_button";
282  ot->description = "Copy the Python command matching this button";
283 
284  /* callbacks */
287 
288  /* flags */
290 }
291 
294 /* -------------------------------------------------------------------- */
299 {
300  ID *id = ptr->owner_id;
301 
302  /* perform updates required for this property */
303  RNA_property_update(C, ptr, prop);
304 
305  /* as if we pressed the button */
307 
308  /* Since we don't want to undo _all_ edits to settings, eg window
309  * edits on the screen or on operator settings.
310  * it might be better to move undo's inline - campbell */
311  if (id && ID_CHECK_UNDO(id)) {
312  /* do nothing, go ahead with undo */
313  return OPERATOR_FINISHED;
314  }
315  return OPERATOR_CANCELLED;
316 }
317 
319 {
320  PointerRNA ptr;
321  PropertyRNA *prop;
322  int index;
323 
324  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
325 
326  return (ptr.data && prop && RNA_property_editable(&ptr, prop));
327 }
328 
330 {
331  PointerRNA ptr;
332  PropertyRNA *prop;
333  int index;
334  const bool all = RNA_boolean_get(op->ptr, "all");
335 
336  /* try to reset the nominated setting to its default value */
337  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
338 
339  /* if there is a valid property that is editable... */
340  if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
341  if (RNA_property_reset(&ptr, prop, (all) ? -1 : index)) {
342  return operator_button_property_finish(C, &ptr, prop);
343  }
344  }
345 
346  return OPERATOR_CANCELLED;
347 }
348 
350 {
351  /* identifiers */
352  ot->name = "Reset to Default Value";
353  ot->idname = "UI_OT_reset_default_button";
354  ot->description = "Reset this property's value to its default value";
355 
356  /* callbacks */
359 
360  /* flags */
361  ot->flag = OPTYPE_UNDO;
362 
363  /* properties */
364  RNA_def_boolean(ot->srna, "all", 1, "All", "Reset to default values all elements of the array");
365 }
366 
369 /* -------------------------------------------------------------------- */
374 {
375  PointerRNA ptr;
376  PropertyRNA *prop;
377  int index;
378 
379  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
380 
381  if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
382  const PropertyType type = RNA_property_type(prop);
383 
384  return RNA_property_is_idprop(prop) && !RNA_property_array_check(prop) &&
386  }
387 
388  return false;
389 }
390 
392 {
393  PointerRNA ptr;
394  PropertyRNA *prop;
395  int index;
396 
397  /* try to reset the nominated setting to its default value */
398  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
399 
400  /* if there is a valid property that is editable... */
401  if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
402  if (RNA_property_assign_default(&ptr, prop)) {
403  return operator_button_property_finish(C, &ptr, prop);
404  }
405  }
406 
407  return OPERATOR_CANCELLED;
408 }
409 
411 {
412  /* identifiers */
413  ot->name = "Assign Value as Default";
414  ot->idname = "UI_OT_assign_default_button";
415  ot->description = "Set this property's current value as the new default";
416 
417  /* callbacks */
420 
421  /* flags */
422  ot->flag = OPTYPE_UNDO;
423 }
424 
427 /* -------------------------------------------------------------------- */
432 {
433  PointerRNA ptr;
434  PropertyRNA *prop;
435  int index;
436 
437  /* try to unset the nominated property */
438  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
439 
440  /* if there is a valid property that is editable... */
441  if (ptr.data && prop && RNA_property_editable(&ptr, prop) &&
442  /* RNA_property_is_idprop(prop) && */
443  RNA_property_is_set(&ptr, prop)) {
444  RNA_property_unset(&ptr, prop);
445  return operator_button_property_finish(C, &ptr, prop);
446  }
447 
448  return OPERATOR_CANCELLED;
449 }
450 
452 {
453  /* identifiers */
454  ot->name = "Unset Property";
455  ot->idname = "UI_OT_unset_property_button";
456  ot->description = "Clear the property and use default or generated value in operators";
457 
458  /* callbacks */
461 
462  /* flags */
463  ot->flag = OPTYPE_UNDO;
464 }
465 
468 /* -------------------------------------------------------------------- */
472 /* Note that we use different values for UI/UX than 'real' override operations, user does not care
473  * whether it's added or removed for the differential operation e.g. */
474 enum {
477  UIOverride_Type_Difference = 2, /* Add/subtract */
478  UIOverride_Type_Factor = 3, /* Multiply */
479  /* TODO: should/can we expose insert/remove ones for collections? Doubt it... */
480 };
481 
484  "NOOP",
485  0,
486  "NoOp",
487  "'No-Operation', place holder preventing automatic override to ever affect the property"},
489  "REPLACE",
490  0,
491  "Replace",
492  "Completely replace value from linked data by local one"},
494  "DIFFERENCE",
495  0,
496  "Difference",
497  "Store difference to linked data value"},
499  "FACTOR",
500  0,
501  "Factor",
502  "Store factor to linked data value (useful e.g. for scale)"},
503  {0, NULL, 0, NULL, NULL},
504 };
505 
507 {
508  PointerRNA ptr;
509  PropertyRNA *prop;
510  int index;
511 
512  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
513 
514  const uint override_status = RNA_property_override_library_status(
515  CTX_data_main(C), &ptr, prop, index);
516 
517  return (ptr.data && prop && (override_status & RNA_OVERRIDE_STATUS_OVERRIDABLE));
518 }
519 
521 {
522  PointerRNA ptr;
523  PropertyRNA *prop;
524  int index;
525  bool created;
526  const bool all = RNA_boolean_get(op->ptr, "all");
527  const int op_type = RNA_enum_get(op->ptr, "type");
528 
529  short operation;
530 
531  switch (op_type) {
533  operation = IDOVERRIDE_LIBRARY_OP_NOOP;
534  break;
536  operation = IDOVERRIDE_LIBRARY_OP_REPLACE;
537  break;
539  /* override code will automatically switch to subtract if needed. */
540  operation = IDOVERRIDE_LIBRARY_OP_ADD;
541  break;
543  operation = IDOVERRIDE_LIBRARY_OP_MULTIPLY;
544  break;
545  default:
546  operation = IDOVERRIDE_LIBRARY_OP_REPLACE;
547  BLI_assert(0);
548  break;
549  }
550 
551  /* try to reset the nominated setting to its default value */
552  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
553 
555 
556  if (all) {
557  index = -1;
558  }
559 
561  CTX_data_main(C), &ptr, prop, operation, index, true, NULL, &created);
562 
563  if (opop == NULL) {
564  /* Sometimes e.g. RNA cannot generate a path to the given property. */
565  BKE_reportf(op->reports, RPT_WARNING, "Failed to create the override operation");
566  return OPERATOR_CANCELLED;
567  }
568 
569  if (!created) {
570  opop->operation = operation;
571  }
572 
573  return operator_button_property_finish(C, &ptr, prop);
574 }
575 
577  wmOperator *op,
578  const wmEvent *UNUSED(event))
579 {
580 #if 0 /* Disabled for now */
582 #else
584  return override_type_set_button_exec(C, op);
585 #endif
586 }
587 
589 {
590  /* identifiers */
591  ot->name = "Define Override Type";
592  ot->idname = "UI_OT_override_type_set_button";
593  ot->description = "Create an override operation, or set the type of an existing one";
594 
595  /* callbacks */
599 
600  /* flags */
601  ot->flag = OPTYPE_UNDO;
602 
603  /* properties */
604  RNA_def_boolean(ot->srna, "all", 1, "All", "Reset to default values all elements of the array");
605  ot->prop = RNA_def_enum(ot->srna,
606  "type",
609  "Type",
610  "Type of override operation");
611  /* TODO: add itemf callback, not all options are available for all data types... */
612 }
613 
615 {
616  PointerRNA ptr;
617  PropertyRNA *prop;
618  int index;
619 
620  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
621 
622  const uint override_status = RNA_property_override_library_status(
623  CTX_data_main(C), &ptr, prop, index);
624 
625  return (ptr.data && ptr.owner_id && prop && (override_status & RNA_OVERRIDE_STATUS_OVERRIDDEN));
626 }
627 
629 {
630  Main *bmain = CTX_data_main(C);
631  PointerRNA ptr, id_refptr, src;
632  PropertyRNA *prop;
633  int index;
634  const bool all = RNA_boolean_get(op->ptr, "all");
635 
636  /* try to reset the nominated setting to its default value */
637  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
638 
639  ID *id = ptr.owner_id;
641  BLI_assert(oprop != NULL);
642  BLI_assert(id != NULL && id->override_library != NULL);
643 
644  const bool is_template = ID_IS_OVERRIDE_LIBRARY_TEMPLATE(id);
645 
646  /* We need source (i.e. linked data) to restore values of deleted overrides...
647  * If this is an override template, we obviously do not need to restore anything. */
648  if (!is_template) {
649  PropertyRNA *src_prop;
651  if (!RNA_path_resolve_property(&id_refptr, oprop->rna_path, &src, &src_prop)) {
652  BLI_assert(0 && "Failed to create matching source (linked data) RNA pointer");
653  }
654  }
655 
656  if (!all && index != -1) {
657  bool is_strict_find;
658  /* Remove override operation for given item,
659  * add singular operations for the other items as needed. */
661  oprop, NULL, NULL, index, index, false, &is_strict_find);
662  BLI_assert(opop != NULL);
663  if (!is_strict_find) {
664  /* No specific override operation, we have to get generic one,
665  * and create item-specific override operations for all but given index,
666  * before removing generic one. */
667  for (int idx = RNA_property_array_length(&ptr, prop); idx--;) {
668  if (idx != index) {
670  oprop, opop->operation, NULL, NULL, idx, idx, true, NULL, NULL);
671  }
672  }
673  }
675  if (!is_template) {
676  RNA_property_copy(bmain, &ptr, &src, prop, index);
677  }
678  if (BLI_listbase_is_empty(&oprop->operations)) {
680  }
681  }
682  else {
683  /* Just remove whole generic override operation of this property. */
685  if (!is_template) {
686  RNA_property_copy(bmain, &ptr, &src, prop, -1);
687  }
688  }
689 
690  return operator_button_property_finish(C, &ptr, prop);
691 }
692 
694 {
695  /* identifiers */
696  ot->name = "Remove Override";
697  ot->idname = "UI_OT_override_remove_button";
698  ot->description = "Remove an override operation";
699 
700  /* callbacks */
703 
704  /* flags */
705  ot->flag = OPTYPE_UNDO;
706 
707  /* properties */
708  RNA_def_boolean(ot->srna, "all", 1, "All", "Reset to default values all elements of the array");
709 }
710 
713 /* -------------------------------------------------------------------- */
717 #define NOT_NULL(assignment) ((assignment) != NULL)
718 #define NOT_RNA_NULL(assignment) ((assignment).data != NULL)
719 
721 {
722  ListBase lb;
723  lb = CTX_data_collection_get(C, "selected_pose_bones");
724 
725  if (!BLI_listbase_is_empty(&lb)) {
726  LISTBASE_FOREACH (CollectionPointerLink *, link, &lb) {
727  bPoseChannel *pchan = link->ptr.data;
728  RNA_pointer_create(link->ptr.owner_id, &RNA_Bone, pchan->bone, &link->ptr);
729  }
730  }
731 
732  *r_lb = lb;
733 }
734 
736  PointerRNA *ptr,
737  PropertyRNA *prop,
738  ListBase *r_lb,
739  bool *r_use_path_from_id,
740  char **r_path)
741 {
742  *r_use_path_from_id = false;
743  *r_path = NULL;
744  /* special case for bone constraints */
745  char *path_from_bone = NULL;
746  /* Remove links from the collection list which don't contain 'prop'. */
747  bool ensure_list_items_contain_prop = false;
748 
749  /* PropertyGroup objects don't have a reference to the struct that actually owns
750  * them, so it is normally necessary to do a brute force search to find it. This
751  * handles the search for non-ID owners by using the 'active' reference as a hint
752  * to preserve efficiency. Only properties defined through RNA are handled, as
753  * custom properties cannot be assumed to be valid for all instances.
754  *
755  * Properties owned by the ID are handled by the 'if (ptr->owner_id)' case below.
756  */
758  PointerRNA owner_ptr;
759  char *idpath = NULL;
760 
761  /* First, check the active PoseBone and PoseBone->Bone. */
762  if (NOT_RNA_NULL(
763  owner_ptr = CTX_data_pointer_get_type(C, "active_pose_bone", &RNA_PoseBone))) {
764  if (NOT_NULL(idpath = RNA_path_from_struct_to_idproperty(&owner_ptr, ptr->data))) {
765  *r_lb = CTX_data_collection_get(C, "selected_pose_bones");
766  }
767  else {
768  bPoseChannel *pchan = owner_ptr.data;
769  RNA_pointer_create(owner_ptr.owner_id, &RNA_Bone, pchan->bone, &owner_ptr);
770 
771  if (NOT_NULL(idpath = RNA_path_from_struct_to_idproperty(&owner_ptr, ptr->data))) {
773  }
774  }
775  }
776 
777  if (idpath == NULL) {
778  /* Check the active EditBone if in edit mode. */
779  if (NOT_RNA_NULL(
780  owner_ptr = CTX_data_pointer_get_type_silent(C, "active_bone", &RNA_EditBone)) &&
781  NOT_NULL(idpath = RNA_path_from_struct_to_idproperty(&owner_ptr, ptr->data))) {
782  *r_lb = CTX_data_collection_get(C, "selected_editable_bones");
783  }
784 
785  /* Add other simple cases here (Node, NodeSocket, Sequence, ViewLayer etc). */
786  }
787 
788  if (idpath) {
789  *r_path = BLI_sprintfN("%s.%s", idpath, RNA_property_identifier(prop));
790  MEM_freeN(idpath);
791  return true;
792  }
793  }
794 
796  *r_lb = CTX_data_collection_get(C, "selected_editable_bones");
797  }
798  else if (RNA_struct_is_a(ptr->type, &RNA_PoseBone)) {
799  *r_lb = CTX_data_collection_get(C, "selected_pose_bones");
800  }
801  else if (RNA_struct_is_a(ptr->type, &RNA_Bone)) {
803  }
804  else if (RNA_struct_is_a(ptr->type, &RNA_Sequence)) {
805  /* Special case when we do this for 'Sequence.lock'.
806  * (if the sequence is locked, it wont be in "selected_editable_sequences"). */
807  const char *prop_id = RNA_property_identifier(prop);
808  if (STREQ(prop_id, "lock")) {
809  *r_lb = CTX_data_collection_get(C, "selected_sequences");
810  }
811  else {
812  *r_lb = CTX_data_collection_get(C, "selected_editable_sequences");
813  }
814  /* Account for properties only being available for some sequence types. */
815  ensure_list_items_contain_prop = true;
816  }
817  else if (RNA_struct_is_a(ptr->type, &RNA_FCurve)) {
818  *r_lb = CTX_data_collection_get(C, "selected_editable_fcurves");
819  }
820  else if (RNA_struct_is_a(ptr->type, &RNA_Keyframe)) {
821  *r_lb = CTX_data_collection_get(C, "selected_editable_keyframes");
822  }
823  else if (RNA_struct_is_a(ptr->type, &RNA_NlaStrip)) {
824  *r_lb = CTX_data_collection_get(C, "selected_nla_strips");
825  }
826  else if (RNA_struct_is_a(ptr->type, &RNA_Constraint) &&
827  (path_from_bone = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_PoseBone)) !=
828  NULL) {
829  *r_lb = CTX_data_collection_get(C, "selected_pose_bones");
830  *r_path = path_from_bone;
831  }
833  ListBase lb = {NULL, NULL};
834  char *path = NULL;
835  bNode *node = NULL;
836 
837  /* Get the node we're editing */
840  bNodeSocket *sock = ptr->data;
841  if (nodeFindNode(ntree, sock, &node, NULL)) {
842  if ((path = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_Node)) != NULL) {
843  /* we're good! */
844  }
845  else {
846  node = NULL;
847  }
848  }
849  }
850  else {
851  node = ptr->data;
852  }
853 
854  /* Now filter by type */
855  if (node) {
856  lb = CTX_data_collection_get(C, "selected_nodes");
857 
859  bNode *node_data = link->ptr.data;
860 
861  if (node_data->type != node->type) {
862  BLI_remlink(&lb, link);
863  MEM_freeN(link);
864  }
865  }
866  }
867 
868  *r_lb = lb;
869  *r_path = path;
870  }
871  else if (ptr->owner_id) {
872  ID *id = ptr->owner_id;
873 
874  if (GS(id->name) == ID_OB) {
875  *r_lb = CTX_data_collection_get(C, "selected_editable_objects");
876  *r_use_path_from_id = true;
877  *r_path = RNA_path_from_ID_to_property(ptr, prop);
878  }
879  else if (OB_DATA_SUPPORT_ID(GS(id->name))) {
880  /* check we're using the active object */
881  const short id_code = GS(id->name);
882  ListBase lb = CTX_data_collection_get(C, "selected_editable_objects");
883  char *path = RNA_path_from_ID_to_property(ptr, prop);
884 
885  /* de-duplicate obdata */
886  if (!BLI_listbase_is_empty(&lb)) {
887  LISTBASE_FOREACH (CollectionPointerLink *, link, &lb) {
888  Object *ob = (Object *)link->ptr.owner_id;
889  if (ob->data) {
890  ID *id_data = ob->data;
891  id_data->tag |= LIB_TAG_DOIT;
892  }
893  }
894 
896  Object *ob = (Object *)link->ptr.owner_id;
897  ID *id_data = ob->data;
898 
899  if ((id_data == NULL) || (id_data->tag & LIB_TAG_DOIT) == 0 || ID_IS_LINKED(id_data) ||
900  (GS(id_data->name) != id_code)) {
901  BLI_remlink(&lb, link);
902  MEM_freeN(link);
903  }
904  else {
905  /* Avoid prepending 'data' to the path. */
906  RNA_id_pointer_create(id_data, &link->ptr);
907  }
908 
909  if (id_data) {
910  id_data->tag &= ~LIB_TAG_DOIT;
911  }
912  }
913  }
914 
915  *r_lb = lb;
916  *r_path = path;
917  }
918  else if (GS(id->name) == ID_SCE) {
919  /* Sequencer's ID is scene :/ */
920  /* Try to recursively find an RNA_Sequence ancestor,
921  * to handle situations like T41062... */
922  if ((*r_path = RNA_path_resolve_from_type_to_property(ptr, prop, &RNA_Sequence)) != NULL) {
923  /* Special case when we do this for 'Sequence.lock'.
924  * (if the sequence is locked, it wont be in "selected_editable_sequences"). */
925  const char *prop_id = RNA_property_identifier(prop);
926  if (STREQ(prop_id, "lock")) {
927  *r_lb = CTX_data_collection_get(C, "selected_sequences");
928  }
929  else {
930  *r_lb = CTX_data_collection_get(C, "selected_editable_sequences");
931  }
932  /* Account for properties only being available for some sequence types. */
933  ensure_list_items_contain_prop = true;
934  }
935  }
936  return (*r_path != NULL);
937  }
938  else {
939  return false;
940  }
941 
942  if (ensure_list_items_contain_prop) {
943  const char *prop_id = RNA_property_identifier(prop);
945  if ((ptr->type != link->ptr.type) &&
946  (RNA_struct_type_find_property(link->ptr.type, prop_id) != prop)) {
947  BLI_remlink(r_lb, link);
948  MEM_freeN(link);
949  }
950  }
951  }
952 
953  return true;
954 }
955 
963 static bool copy_to_selected_button(bContext *C, bool all, bool poll)
964 {
965  Main *bmain = CTX_data_main(C);
966  PointerRNA ptr, lptr, idptr;
967  PropertyRNA *prop, *lprop;
968  bool success = false;
969  int index;
970 
971  /* try to reset the nominated setting to its default value */
972  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
973 
974  /* if there is a valid property that is editable... */
975  if (ptr.data && prop) {
976  char *path = NULL;
977  bool use_path_from_id;
978  ListBase lb = {NULL};
979 
980  if (UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path) &&
981  !BLI_listbase_is_empty(&lb)) {
982  LISTBASE_FOREACH (CollectionPointerLink *, link, &lb) {
983  if (link->ptr.data != ptr.data) {
984  if (use_path_from_id) {
985  /* Path relative to ID. */
986  lprop = NULL;
987  RNA_id_pointer_create(link->ptr.owner_id, &idptr);
988  RNA_path_resolve_property(&idptr, path, &lptr, &lprop);
989  }
990  else if (path) {
991  /* Path relative to elements from list. */
992  lprop = NULL;
993  RNA_path_resolve_property(&link->ptr, path, &lptr, &lprop);
994  }
995  else {
996  lptr = link->ptr;
997  lprop = prop;
998  }
999 
1000  if (lptr.data == ptr.data) {
1001  /* lptr might not be the same as link->ptr! */
1002  continue;
1003  }
1004 
1005  if (lprop == prop) {
1006  if (RNA_property_editable(&lptr, lprop)) {
1007  if (poll) {
1008  success = true;
1009  break;
1010  }
1011  if (RNA_property_copy(bmain, &lptr, &ptr, prop, (all) ? -1 : index)) {
1012  RNA_property_update(C, &lptr, prop);
1013  success = true;
1014  }
1015  }
1016  }
1017  }
1018  }
1019  }
1020  MEM_SAFE_FREE(path);
1021  BLI_freelistN(&lb);
1022  }
1023 
1024  return success;
1025 }
1026 
1028 {
1029  return copy_to_selected_button(C, false, true);
1030 }
1031 
1033 {
1034  bool success;
1035 
1036  const bool all = RNA_boolean_get(op->ptr, "all");
1037 
1038  success = copy_to_selected_button(C, all, false);
1039 
1040  return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
1041 }
1042 
1044 {
1045  /* identifiers */
1046  ot->name = "Copy to Selected";
1047  ot->idname = "UI_OT_copy_to_selected_button";
1048  ot->description = "Copy property from this object to selected objects or bones";
1049 
1050  /* callbacks */
1053 
1054  /* flags */
1056 
1057  /* properties */
1058  RNA_def_boolean(ot->srna, "all", true, "All", "Copy to selected all elements of the array");
1059 }
1060 
1063 /* -------------------------------------------------------------------- */
1068 static bool jump_to_target_ptr(bContext *C, PointerRNA ptr, const bool poll)
1069 {
1070  if (RNA_pointer_is_null(&ptr)) {
1071  return false;
1072  }
1073 
1074  /* Verify pointer type. */
1075  char bone_name[MAXBONENAME];
1076  const StructRNA *target_type = NULL;
1077 
1079  RNA_string_get(&ptr, "name", bone_name);
1080  if (bone_name[0] != '\0') {
1081  target_type = &RNA_Bone;
1082  }
1083  }
1084  else if (RNA_struct_is_a(ptr.type, &RNA_Object)) {
1085  target_type = &RNA_Object;
1086  }
1087 
1088  if (target_type == NULL) {
1089  return false;
1090  }
1091 
1092  /* Find the containing Object. */
1093  ViewLayer *view_layer = CTX_data_view_layer(C);
1094  Base *base = NULL;
1095  const short id_type = GS(ptr.owner_id->name);
1096  if (id_type == ID_OB) {
1097  base = BKE_view_layer_base_find(view_layer, (Object *)ptr.owner_id);
1098  }
1099  else if (OB_DATA_SUPPORT_ID(id_type)) {
1100  base = ED_object_find_first_by_data_id(view_layer, ptr.owner_id);
1101  }
1102 
1103  bool ok = false;
1104  if ((base == NULL) || ((target_type == &RNA_Bone) && (base->object->type != OB_ARMATURE))) {
1105  /* pass */
1106  }
1107  else if (poll) {
1108  ok = true;
1109  }
1110  else {
1111  /* Make optional. */
1112  const bool reveal_hidden = true;
1113  /* Select and activate the target. */
1114  if (target_type == &RNA_Bone) {
1115  ok = ED_object_jump_to_bone(C, base->object, bone_name, reveal_hidden);
1116  }
1117  else if (target_type == &RNA_Object) {
1118  ok = ED_object_jump_to_object(C, base->object, reveal_hidden);
1119  }
1120  else {
1121  BLI_assert(0);
1122  }
1123  }
1124  return ok;
1125 }
1126 
1134 static bool jump_to_target_button(bContext *C, bool poll)
1135 {
1136  PointerRNA ptr, target_ptr;
1137  PropertyRNA *prop;
1138  int index;
1139 
1140  UI_context_active_but_prop_get(C, &ptr, &prop, &index);
1141 
1142  /* If there is a valid property... */
1143  if (ptr.data && prop) {
1144  const PropertyType type = RNA_property_type(prop);
1145 
1146  /* For pointer properties, use their value directly. */
1147  if (type == PROP_POINTER) {
1148  target_ptr = RNA_property_pointer_get(&ptr, prop);
1149 
1150  return jump_to_target_ptr(C, target_ptr, poll);
1151  }
1152  /* For string properties with prop_search, look up the search collection item. */
1153  if (type == PROP_STRING) {
1154  const uiBut *but = UI_context_active_but_get(C);
1155  const uiButSearch *search_but = (but->type == UI_BTYPE_SEARCH_MENU) ? (uiButSearch *)but :
1156  NULL;
1157 
1158  if (search_but && search_but->items_update_fn == ui_rna_collection_search_update_fn) {
1159  uiRNACollectionSearch *coll_search = search_but->arg;
1160 
1161  char str_buf[MAXBONENAME];
1162  char *str_ptr = RNA_property_string_get_alloc(&ptr, prop, str_buf, sizeof(str_buf), NULL);
1163 
1165  &coll_search->search_ptr, coll_search->search_prop, str_ptr, &target_ptr);
1166 
1167  if (str_ptr != str_buf) {
1168  MEM_freeN(str_ptr);
1169  }
1170 
1171  if (found) {
1172  return jump_to_target_ptr(C, target_ptr, poll);
1173  }
1174  }
1175  }
1176  }
1177 
1178  return false;
1179 }
1180 
1182 {
1183  return jump_to_target_button(C, true);
1184 }
1185 
1187 {
1188  const bool success = jump_to_target_button(C, false);
1189 
1190  return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
1191 }
1192 
1194 {
1195  /* identifiers */
1196  ot->name = "Jump to Target";
1197  ot->idname = "UI_OT_jump_to_target_button";
1198  ot->description = "Switch to the target object or bone";
1199 
1200  /* callbacks */
1203 
1204  /* flags */
1206 }
1207 
1210 /* -------------------------------------------------------------------- */
1214 #ifdef WITH_PYTHON
1215 
1216 /* ------------------------------------------------------------------------- */
1217 /* EditSource Utility funcs and operator,
1218  * note, this includes utility functions and button matching checks */
1219 
1220 typedef struct uiEditSourceStore {
1221  uiBut but_orig;
1222  GHash *hash;
1223 } uiEditSourceStore;
1224 
1225 typedef struct uiEditSourceButStore {
1226  char py_dbg_fn[FILE_MAX];
1227  int py_dbg_line_number;
1228 } uiEditSourceButStore;
1229 
1230 /* should only ever be set while the edit source operator is running */
1231 static struct uiEditSourceStore *ui_editsource_info = NULL;
1232 
1233 bool UI_editsource_enable_check(void)
1234 {
1235  return (ui_editsource_info != NULL);
1236 }
1237 
1238 static void ui_editsource_active_but_set(uiBut *but)
1239 {
1240  BLI_assert(ui_editsource_info == NULL);
1241 
1242  ui_editsource_info = MEM_callocN(sizeof(uiEditSourceStore), __func__);
1243  memcpy(&ui_editsource_info->but_orig, but, sizeof(uiBut));
1244 
1245  ui_editsource_info->hash = BLI_ghash_ptr_new(__func__);
1246 }
1247 
1248 static void ui_editsource_active_but_clear(void)
1249 {
1250  BLI_ghash_free(ui_editsource_info->hash, NULL, MEM_freeN);
1251  MEM_freeN(ui_editsource_info);
1252  ui_editsource_info = NULL;
1253 }
1254 
1255 static bool ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b)
1256 {
1257 # if 0
1258  printf("matching buttons: '%s' == '%s'\n", but_a->drawstr, but_b->drawstr);
1259 # endif
1260 
1261  /* this just needs to be a 'good-enough' comparison so we can know beyond
1262  * reasonable doubt that these buttons are the same between redraws.
1263  * if this fails it only means edit-source fails - campbell */
1264  if (BLI_rctf_compare(&but_a->rect, &but_b->rect, FLT_EPSILON) && (but_a->type == but_b->type) &&
1265  (but_a->rnaprop == but_b->rnaprop) && (but_a->optype == but_b->optype) &&
1266  (but_a->unit_type == but_b->unit_type) &&
1267  STREQLEN(but_a->drawstr, but_b->drawstr, UI_MAX_DRAW_STR)) {
1268  return true;
1269  }
1270  return false;
1271 }
1272 
1274 {
1275  extern void PyC_FileAndNum_Safe(const char **r_filename, int *r_lineno);
1276 
1277  struct uiEditSourceButStore *but_store = MEM_callocN(sizeof(uiEditSourceButStore), __func__);
1278 
1279  const char *fn;
1280  int line_number = -1;
1281 
1282 # if 0
1283  printf("comparing buttons: '%s' == '%s'\n", but->drawstr, ui_editsource_info->but_orig.drawstr);
1284 # endif
1285 
1286  PyC_FileAndNum_Safe(&fn, &line_number);
1287 
1288  if (line_number != -1) {
1289  BLI_strncpy(but_store->py_dbg_fn, fn, sizeof(but_store->py_dbg_fn));
1290  but_store->py_dbg_line_number = line_number;
1291  }
1292  else {
1293  but_store->py_dbg_fn[0] = '\0';
1294  but_store->py_dbg_line_number = -1;
1295  }
1296 
1297  BLI_ghash_insert(ui_editsource_info->hash, but, but_store);
1298 }
1299 
1304 void UI_editsource_but_replace(const uiBut *old_but, uiBut *new_but)
1305 {
1306  uiEditSourceButStore *but_store = BLI_ghash_lookup(ui_editsource_info->hash, old_but);
1307  if (but_store) {
1308  BLI_ghash_remove(ui_editsource_info->hash, old_but, NULL, NULL);
1309  BLI_ghash_insert(ui_editsource_info->hash, new_but, but_store);
1310  }
1311 }
1312 
1313 static int editsource_text_edit(bContext *C,
1314  wmOperator *op,
1315  const char filepath[FILE_MAX],
1316  const int line)
1317 {
1318  struct Main *bmain = CTX_data_main(C);
1319  Text *text = NULL;
1320 
1321  /* Developers may wish to copy-paste to an external editor. */
1322  printf("%s:%d\n", filepath, line);
1323 
1324  LISTBASE_FOREACH (Text *, text_iter, &bmain->texts) {
1325  if (text_iter->filepath && BLI_path_cmp(text_iter->filepath, filepath) == 0) {
1326  text = text_iter;
1327  break;
1328  }
1329  }
1330 
1331  if (text == NULL) {
1332  text = BKE_text_load(bmain, filepath, BKE_main_blendfile_path(bmain));
1333  }
1334 
1335  if (text == NULL) {
1336  BKE_reportf(op->reports, RPT_WARNING, "File '%s' cannot be opened", filepath);
1337  return OPERATOR_CANCELLED;
1338  }
1339 
1340  txt_move_toline(text, line - 1, false);
1341 
1342  /* naughty!, find text area to set, not good behavior
1343  * but since this is a dev tool lets allow it - campbell */
1345  if (area) {
1346  SpaceText *st = area->spacedata.first;
1348  st->text = text;
1349  if (region) {
1350  ED_text_scroll_to_cursor(st, region, true);
1351  }
1352  }
1353  else {
1354  BKE_reportf(op->reports, RPT_INFO, "See '%s' in the text editor", text->id.name + 2);
1355  }
1356 
1358 
1359  return OPERATOR_FINISHED;
1360 }
1361 
1362 static int editsource_exec(bContext *C, wmOperator *op)
1363 {
1365 
1366  if (but) {
1367  GHashIterator ghi;
1368  struct uiEditSourceButStore *but_store = NULL;
1369 
1370  ARegion *region = CTX_wm_region(C);
1371  int ret;
1372 
1373  /* needed else the active button does not get tested */
1375 
1376  // printf("%s: begin\n", __func__);
1377 
1378  /* take care not to return before calling ui_editsource_active_but_clear */
1379  ui_editsource_active_but_set(but);
1380 
1381  /* redraw and get active button python info */
1382  ED_region_do_layout(C, region);
1384  ED_region_do_draw(C, region);
1386  region->do_draw = false;
1387 
1388  for (BLI_ghashIterator_init(&ghi, ui_editsource_info->hash);
1389  BLI_ghashIterator_done(&ghi) == false;
1390  BLI_ghashIterator_step(&ghi)) {
1391  uiBut *but_key = BLI_ghashIterator_getKey(&ghi);
1392  if (but_key && ui_editsource_uibut_match(&ui_editsource_info->but_orig, but_key)) {
1393  but_store = BLI_ghashIterator_getValue(&ghi);
1394  break;
1395  }
1396  }
1397 
1398  if (but_store) {
1399  if (but_store->py_dbg_line_number != -1) {
1400  ret = editsource_text_edit(C, op, but_store->py_dbg_fn, but_store->py_dbg_line_number);
1401  }
1402  else {
1403  BKE_report(
1404  op->reports, RPT_ERROR, "Active button is not from a script, cannot edit source");
1406  }
1407  }
1408  else {
1409  BKE_report(op->reports, RPT_ERROR, "Active button match cannot be found");
1411  }
1412 
1413  ui_editsource_active_but_clear();
1414 
1415  // printf("%s: end\n", __func__);
1416 
1417  return ret;
1418  }
1419 
1420  BKE_report(op->reports, RPT_ERROR, "Active button not found");
1421  return OPERATOR_CANCELLED;
1422 }
1423 
1424 static void UI_OT_editsource(wmOperatorType *ot)
1425 {
1426  /* identifiers */
1427  ot->name = "Edit Source";
1428  ot->idname = "UI_OT_editsource";
1429  ot->description = "Edit UI source code of the active button";
1430 
1431  /* callbacks */
1432  ot->exec = editsource_exec;
1433 }
1434 
1437 /* -------------------------------------------------------------------- */
1447 static void edittranslation_find_po_file(const char *root,
1448  const char *uilng,
1449  char *path,
1450  const size_t maxlen)
1451 {
1452  char tstr[32]; /* Should be more than enough! */
1453 
1454  /* First, full lang code. */
1455  BLI_snprintf(tstr, sizeof(tstr), "%s.po", uilng);
1456  BLI_join_dirfile(path, maxlen, root, uilng);
1457  BLI_path_append(path, maxlen, tstr);
1458  if (BLI_is_file(path)) {
1459  return;
1460  }
1461 
1462  /* Now try without the second iso code part (_ES in es_ES). */
1463  {
1464  const char *tc = NULL;
1465  size_t szt = 0;
1466  tstr[0] = '\0';
1467 
1468  tc = strchr(uilng, '_');
1469  if (tc) {
1470  szt = tc - uilng;
1471  if (szt < sizeof(tstr)) { /* Paranoid, should always be true! */
1472  BLI_strncpy(tstr, uilng, szt + 1); /* +1 for '\0' char! */
1473  }
1474  }
1475  if (tstr[0]) {
1476  /* Because of some codes like sr_SR@latin... */
1477  tc = strchr(uilng, '@');
1478  if (tc) {
1479  BLI_strncpy(tstr + szt, tc, sizeof(tstr) - szt);
1480  }
1481 
1482  BLI_join_dirfile(path, maxlen, root, tstr);
1483  strcat(tstr, ".po");
1484  BLI_path_append(path, maxlen, tstr);
1485  if (BLI_is_file(path)) {
1486  return;
1487  }
1488  }
1489  }
1490 
1491  /* Else no po file! */
1492  path[0] = '\0';
1493 }
1494 
1495 static int edittranslation_exec(bContext *C, wmOperator *op)
1496 {
1498  int ret = OPERATOR_CANCELLED;
1499 
1500  if (but) {
1501  wmOperatorType *ot;
1502  PointerRNA ptr;
1503  char popath[FILE_MAX];
1504  const char *root = U.i18ndir;
1505  const char *uilng = BLT_lang_get();
1506 
1507  uiStringInfo but_label = {BUT_GET_LABEL, NULL};
1508  uiStringInfo rna_label = {BUT_GET_RNA_LABEL, NULL};
1509  uiStringInfo enum_label = {BUT_GET_RNAENUM_LABEL, NULL};
1510  uiStringInfo but_tip = {BUT_GET_TIP, NULL};
1511  uiStringInfo rna_tip = {BUT_GET_RNA_TIP, NULL};
1512  uiStringInfo enum_tip = {BUT_GET_RNAENUM_TIP, NULL};
1517 
1518  if (!BLI_is_dir(root)) {
1519  BKE_report(op->reports,
1520  RPT_ERROR,
1521  "Please set your Preferences' 'Translation Branches "
1522  "Directory' path to a valid directory");
1523  return OPERATOR_CANCELLED;
1524  }
1526  if (ot == NULL) {
1527  BKE_reportf(op->reports,
1528  RPT_ERROR,
1529  "Could not find operator '%s'! Please enable ui_translate add-on "
1530  "in the User Preferences",
1532  return OPERATOR_CANCELLED;
1533  }
1534  /* Try to find a valid po file for current language... */
1535  edittranslation_find_po_file(root, uilng, popath, FILE_MAX);
1536  /* printf("po path: %s\n", popath); */
1537  if (popath[0] == '\0') {
1538  BKE_reportf(
1539  op->reports, RPT_ERROR, "No valid po found for language '%s' under %s", uilng, root);
1540  return OPERATOR_CANCELLED;
1541  }
1542 
1544  but,
1545  &but_label,
1546  &rna_label,
1547  &enum_label,
1548  &but_tip,
1549  &rna_tip,
1550  &enum_tip,
1551  &rna_struct,
1552  &rna_prop,
1553  &rna_enum,
1554  &rna_ctxt,
1555  NULL);
1556 
1558  RNA_string_set(&ptr, "lang", uilng);
1559  RNA_string_set(&ptr, "po_file", popath);
1560  RNA_string_set(&ptr, "but_label", but_label.strinfo);
1561  RNA_string_set(&ptr, "rna_label", rna_label.strinfo);
1562  RNA_string_set(&ptr, "enum_label", enum_label.strinfo);
1563  RNA_string_set(&ptr, "but_tip", but_tip.strinfo);
1564  RNA_string_set(&ptr, "rna_tip", rna_tip.strinfo);
1565  RNA_string_set(&ptr, "enum_tip", enum_tip.strinfo);
1566  RNA_string_set(&ptr, "rna_struct", rna_struct.strinfo);
1567  RNA_string_set(&ptr, "rna_prop", rna_prop.strinfo);
1568  RNA_string_set(&ptr, "rna_enum", rna_enum.strinfo);
1569  RNA_string_set(&ptr, "rna_ctxt", rna_ctxt.strinfo);
1571 
1572  /* Clean up */
1573  if (but_label.strinfo) {
1574  MEM_freeN(but_label.strinfo);
1575  }
1576  if (rna_label.strinfo) {
1577  MEM_freeN(rna_label.strinfo);
1578  }
1579  if (enum_label.strinfo) {
1580  MEM_freeN(enum_label.strinfo);
1581  }
1582  if (but_tip.strinfo) {
1583  MEM_freeN(but_tip.strinfo);
1584  }
1585  if (rna_tip.strinfo) {
1586  MEM_freeN(rna_tip.strinfo);
1587  }
1588  if (enum_tip.strinfo) {
1589  MEM_freeN(enum_tip.strinfo);
1590  }
1591  if (rna_struct.strinfo) {
1592  MEM_freeN(rna_struct.strinfo);
1593  }
1594  if (rna_prop.strinfo) {
1595  MEM_freeN(rna_prop.strinfo);
1596  }
1597  if (rna_enum.strinfo) {
1598  MEM_freeN(rna_enum.strinfo);
1599  }
1600  if (rna_ctxt.strinfo) {
1601  MEM_freeN(rna_ctxt.strinfo);
1602  }
1603 
1604  return ret;
1605  }
1606 
1607  BKE_report(op->reports, RPT_ERROR, "Active button not found");
1608  return OPERATOR_CANCELLED;
1609 }
1610 
1611 static void UI_OT_edittranslation_init(wmOperatorType *ot)
1612 {
1613  /* identifiers */
1614  ot->name = "Edit Translation";
1615  ot->idname = "UI_OT_edittranslation_init";
1616  ot->description = "Edit i18n in current language for the active button";
1617 
1618  /* callbacks */
1619  ot->exec = edittranslation_exec;
1620 }
1621 
1622 #endif /* WITH_PYTHON */
1623 
1626 /* -------------------------------------------------------------------- */
1631 {
1632  BLT_lang_init();
1633  BLF_cache_clear();
1634  BLT_lang_set(NULL);
1635  UI_reinit_font();
1636  return OPERATOR_FINISHED;
1637 }
1638 
1640 {
1641  /* identifiers */
1642  ot->name = "Reload Translation";
1643  ot->idname = "UI_OT_reloadtranslation";
1644  ot->description = "Force a full reload of UI translation";
1645 
1646  /* callbacks */
1648 }
1649 
1652 /* -------------------------------------------------------------------- */
1656 static int ui_button_press_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1657 {
1658  bScreen *screen = CTX_wm_screen(C);
1659  const bool skip_depressed = RNA_boolean_get(op->ptr, "skip_depressed");
1660  ARegion *region_prev = CTX_wm_region(C);
1661  ARegion *region = screen ? BKE_screen_find_region_xy(screen, RGN_TYPE_ANY, event->x, event->y) :
1662  NULL;
1663 
1664  if (region == NULL) {
1665  region = region_prev;
1666  }
1667 
1668  if (region == NULL) {
1669  return OPERATOR_PASS_THROUGH;
1670  }
1671 
1672  CTX_wm_region_set(C, region);
1674  CTX_wm_region_set(C, region_prev);
1675 
1676  if (but == NULL) {
1677  return OPERATOR_PASS_THROUGH;
1678  }
1679  if (skip_depressed && (but->flag & (UI_SELECT | UI_SELECT_DRAW))) {
1680  return OPERATOR_PASS_THROUGH;
1681  }
1682 
1683  /* Weak, this is a workaround for 'UI_but_is_tool', which checks the operator type,
1684  * having this avoids a minor drawing glitch. */
1685  void *but_optype = but->optype;
1686 
1687  UI_but_execute(C, region, but);
1688 
1689  but->optype = but_optype;
1690 
1692 
1693  return OPERATOR_FINISHED;
1694 }
1695 
1697 {
1698  ot->name = "Press Button";
1699  ot->idname = "UI_OT_button_execute";
1700  ot->description = "Presses active button";
1701 
1703  ot->flag = OPTYPE_INTERNAL;
1704 
1705  RNA_def_boolean(ot->srna, "skip_depressed", 0, "Skip Depressed", "");
1706 }
1707 
1710 /* -------------------------------------------------------------------- */
1715 {
1717 
1718  if (but) {
1720  }
1721 
1722  return OPERATOR_FINISHED;
1723 }
1724 
1726 {
1727  ot->name = "Clear Button String";
1728  ot->idname = "UI_OT_button_string_clear";
1729  ot->description = "Unsets the text of the active button";
1730 
1734 }
1735 
1738 /* -------------------------------------------------------------------- */
1743  wmDrag *drag,
1744  const wmEvent *UNUSED(event),
1745  const char **UNUSED(r_tooltip))
1746 {
1747  /* should only return true for regions that include buttons, for now
1748  * return true always */
1749  if (drag->type == WM_DRAG_COLOR) {
1750  SpaceImage *sima = CTX_wm_space_image(C);
1751  ARegion *region = CTX_wm_region(C);
1752 
1753  if (UI_but_active_drop_color(C)) {
1754  return 1;
1755  }
1756 
1757  if (sima && (sima->mode == SI_MODE_PAINT) && sima->image &&
1758  (region && region->regiontype == RGN_TYPE_WINDOW)) {
1759  return 1;
1760  }
1761  }
1762 
1763  return 0;
1764 }
1765 
1767 {
1768  uiDragColorHandle *drag_info = drag->poin;
1769 
1770  RNA_float_set_array(drop->ptr, "color", drag_info->color);
1771  RNA_boolean_set(drop->ptr, "gamma", drag_info->gamma_corrected);
1772 }
1773 
1774 static int drop_color_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1775 {
1776  ARegion *region = CTX_wm_region(C);
1777  uiBut *but = NULL;
1778  float color[4];
1779  bool gamma;
1780 
1781  RNA_float_get_array(op->ptr, "color", color);
1782  gamma = RNA_boolean_get(op->ptr, "gamma");
1783 
1784  /* find button under mouse, check if it has RNA color property and
1785  * if it does copy the data */
1786  but = ui_region_find_active_but(region);
1787 
1788  if (but && but->type == UI_BTYPE_COLOR && but->rnaprop) {
1789  const int color_len = RNA_property_array_length(&but->rnapoin, but->rnaprop);
1790  BLI_assert(color_len <= 4);
1791 
1792  /* keep alpha channel as-is */
1793  if (color_len == 4) {
1794  color[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3);
1795  }
1796 
1798  if (!gamma) {
1800  }
1801  RNA_property_float_set_array(&but->rnapoin, but->rnaprop, color);
1802  RNA_property_update(C, &but->rnapoin, but->rnaprop);
1803  }
1804  else if (RNA_property_subtype(but->rnaprop) == PROP_COLOR) {
1805  if (gamma) {
1807  }
1808  RNA_property_float_set_array(&but->rnapoin, but->rnaprop, color);
1809  RNA_property_update(C, &but->rnapoin, but->rnaprop);
1810  }
1811  }
1812  else {
1813  if (gamma) {
1814  srgb_to_linearrgb_v3_v3(color, color);
1815  }
1816 
1817  ED_imapaint_bucket_fill(C, color, op, event->mval);
1818  }
1819 
1820  ED_region_tag_redraw(region);
1821 
1822  return OPERATOR_FINISHED;
1823 }
1824 
1826 {
1827  ot->name = "Drop Color";
1828  ot->idname = "UI_OT_drop_color";
1829  ot->description = "Drop colors to buttons";
1830 
1832  ot->flag = OPTYPE_INTERNAL;
1833 
1834  RNA_def_float_color(ot->srna, "color", 3, NULL, 0.0, FLT_MAX, "Color", "Source color", 0.0, 1.0);
1835  RNA_def_boolean(ot->srna, "gamma", 0, "Gamma Corrected", "The source color is gamma corrected");
1836 }
1837 
1840 /* -------------------------------------------------------------------- */
1845 {
1857 #ifdef WITH_PYTHON
1858  WM_operatortype_append(UI_OT_editsource);
1859  WM_operatortype_append(UI_OT_edittranslation_init);
1860 #endif
1864 
1865  /* external */
1873 }
1874 
1879 {
1880  WM_keymap_ensure(keyconf, "User Interface", 0, 0);
1881 
1882  eyedropper_modal_keymap(keyconf);
1884 }
1885 
void CTX_wm_region_set(bContext *C, struct ARegion *region)
Definition: context.c:985
PointerRNA CTX_data_pointer_get_type_silent(const bContext *C, const char *member, StructRNA *type)
Definition: context.c:475
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
Definition: context.c:456
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1044
struct bScreen * CTX_wm_screen(const bContext *C)
Definition: context.c:709
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:725
struct SpaceImage * CTX_wm_space_image(const bContext *C)
Definition: context.c:800
ListBase CTX_data_collection_get(const bContext *C, const char *member)
Definition: context.c:486
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
struct Base * BKE_view_layer_base_find(struct ViewLayer *view_layer, struct Object *ob)
Definition: layer.c:394
struct IDOverrideLibraryPropertyOperation * BKE_lib_override_library_property_operation_get(struct IDOverrideLibraryProperty *override_property, const short operation, const char *subitem_refname, const char *subitem_locname, const int subitem_refindex, const int subitem_locindex, const bool strict, bool *r_strict, bool *r_created)
struct IDOverrideLibraryPropertyOperation * BKE_lib_override_library_property_operation_find(struct IDOverrideLibraryProperty *override_property, const char *subitem_refname, const char *subitem_locname, const int subitem_refindex, const int subitem_locindex, const bool strict, bool *r_strict)
void BKE_lib_override_library_property_operation_delete(struct IDOverrideLibraryProperty *override_property, struct IDOverrideLibraryPropertyOperation *override_property_operation)
void BKE_lib_override_library_property_delete(struct IDOverrideLibrary *override, struct IDOverrideLibraryProperty *override_property)
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
bool nodeFindNode(struct bNodeTree *ntree, struct bNodeSocket *sock, struct bNode **r_node, int *r_sockindex)
Definition: node.cc:1823
void BKE_report(ReportList *reports, ReportType type, const char *message)
Definition: report.c:104
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
struct ARegion * BKE_area_find_region_type(const struct ScrArea *area, int type)
struct ScrArea struct ScrArea * BKE_screen_find_big_area(struct bScreen *screen, const int spacetype, const short min)
Definition: screen.c:983
struct ARegion * BKE_screen_find_region_xy(struct bScreen *screen, const int regiontype, int x, int y) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition: screen.c:952
struct Text * BKE_text_load(struct Main *bmain, const char *file, const char *relpath)
Definition: text.c:533
void txt_move_toline(struct Text *text, unsigned int line, const bool sel)
Definition: text.c:1131
void BLF_cache_clear(void)
Definition: blf.c:105
#define BLI_assert(a)
Definition: BLI_assert.h:58
bool BLI_is_file(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: storage.c:444
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: storage.c:436
BLI_INLINE void * BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.h:146
void BLI_ghashIterator_step(GHashIterator *ghi)
Definition: BLI_ghash.c:1086
BLI_INLINE bool BLI_ghashIterator_done(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.h:158
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.h:150
bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:900
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition: BLI_ghash.c:756
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:1008
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:1065
void * BLI_ghash_lookup(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:803
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:124
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
Definition: BLI_listbase.h:188
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:547
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:133
MINLINE void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
#define FILE_MAX
void BLI_path_append(char *__restrict dst, const size_t maxlen, const char *__restrict file) ATTR_NONNULL()
Definition: path_util.c:1716
void BLI_join_dirfile(char *__restrict dst, const size_t maxlen, const char *__restrict dir, const char *__restrict file) ATTR_NONNULL()
Definition: path_util.c:1737
#define BLI_path_cmp
bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, const 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
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string.c:108
unsigned int uint
Definition: BLI_sys_types.h:83
#define STREQLEN(a, b, n)
#define UNUSED(x)
#define ELEM(...)
#define STREQ(a, b)
const char * BLT_lang_get(void)
Definition: blt_lang.c:289
void BLT_lang_init(void)
Definition: blt_lang.c:198
void BLT_lang_set(const char *)
Definition: blt_lang.c:257
#define ID_CHECK_UNDO(id)
Definition: DNA_ID.h:416
@ LIB_TAG_DOIT
Definition: DNA_ID.h:554
#define ID_IS_LINKED(_id)
Definition: DNA_ID.h:426
#define ID_IS_OVERRIDE_LIBRARY_TEMPLATE(_id)
Definition: DNA_ID.h:448
@ IDOVERRIDE_LIBRARY_OP_MULTIPLY
Definition: DNA_ID.h:183
@ IDOVERRIDE_LIBRARY_OP_NOOP
Definition: DNA_ID.h:174
@ IDOVERRIDE_LIBRARY_OP_ADD
Definition: DNA_ID.h:179
@ IDOVERRIDE_LIBRARY_OP_REPLACE
Definition: DNA_ID.h:176
@ ID_SCE
Definition: DNA_ID_enums.h:57
@ ID_OB
Definition: DNA_ID_enums.h:59
#define MAXBONENAME
Object is a sort of wrapper for general info.
#define OB_DATA_SUPPORT_ID(_id_type)
@ OB_ARMATURE
#define RGN_TYPE_ANY
@ RGN_TYPE_WINDOW
@ SPACE_TEXT
@ SI_MODE_PAINT
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_PASS_THROUGH
bool ED_object_jump_to_object(struct bContext *C, struct Object *ob, const bool reveal_hidden)
bool ED_object_jump_to_bone(struct bContext *C, struct Object *ob, const char *bone_name, const bool reveal_hidden)
struct Base * ED_object_find_first_by_data_id(struct ViewLayer *view_layer, struct ID *id)
void ED_imapaint_bucket_fill(struct bContext *C, float color[3], struct wmOperator *op, const int mouse[2])
Definition: paint_image.c:1328
void ED_region_do_layout(struct bContext *C, struct ARegion *region)
Definition: area.c:505
bool ED_operator_regionactive(struct bContext *C)
Definition: screen_ops.c:105
void ED_region_do_draw(struct bContext *C, struct ARegion *region)
Definition: area.c:529
void ED_region_tag_redraw(struct ARegion *region)
Definition: area.c:667
void ED_text_scroll_to_cursor(struct SpaceText *st, struct ARegion *region, bool center)
_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
void IMB_colormanagement_scene_linear_to_srgb_v3(float pixel[3])
void IMB_colormanagement_srgb_to_scene_linear_v3(float pixel[3])
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
StructRNA RNA_Bone
StructRNA RNA_Node
@ RNA_OVERRIDE_STATUS_OVERRIDABLE
Definition: RNA_access.h:1497
@ RNA_OVERRIDE_STATUS_OVERRIDDEN
Definition: RNA_access.h:1499
StructRNA RNA_Constraint
StructRNA RNA_EditBone
StructRNA RNA_NodeSocket
StructRNA RNA_FCurve
StructRNA RNA_Keyframe
StructRNA RNA_PoseBone
StructRNA RNA_Object
StructRNA RNA_Sequence
StructRNA RNA_NlaStrip
PropertyType
Definition: RNA_types.h:72
@ PROP_FLOAT
Definition: RNA_types.h:75
@ PROP_BOOLEAN
Definition: RNA_types.h:73
@ PROP_ENUM
Definition: RNA_types.h:77
@ PROP_INT
Definition: RNA_types.h:74
@ PROP_STRING
Definition: RNA_types.h:76
@ PROP_POINTER
Definition: RNA_types.h:78
@ PROP_SKIP_SAVE
Definition: RNA_types.h:204
@ PROP_COLOR
Definition: RNA_types.h:139
@ PROP_COLOR_GAMMA
Definition: RNA_types.h:151
#define C
Definition: RandGen.cpp:39
struct PointerRNA * UI_but_operator_ptr_get(uiBut *but)
Definition: interface.c:6218
void UI_screen_free_active_but(const struct bContext *C, struct bScreen *screen)
uiBut * UI_context_active_but_get(const struct bContext *C)
bool UI_but_active_drop_color(struct bContext *C)
void UI_context_active_but_prop_handle(struct bContext *C)
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)
#define UI_MAX_DRAW_STR
Definition: UI_interface.h:90
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)
uiBut * UI_context_active_but_prop_get(const struct bContext *C, struct PointerRNA *r_ptr, struct PropertyRNA **r_prop, int *r_index)
void UI_reinit_font(void)
Definition: interface.c:7123
@ UI_BTYPE_SEARCH_MENU
Definition: UI_interface.h:376
@ UI_BTYPE_COLOR
Definition: UI_interface.h:353
uiBut * UI_context_active_but_get_respect_menu(const struct bContext *C)
void UI_but_string_info_get(struct bContext *C, uiBut *but,...) ATTR_SENTINEL(0)
Definition: interface.c:6870
@ OPTYPE_INTERNAL
Definition: WM_types.h:175
@ OPTYPE_UNDO
Definition: WM_types.h:155
@ OPTYPE_REGISTER
Definition: WM_types.h:153
#define ND_CURSOR
Definition: WM_types.h:390
@ WM_OP_INVOKE_DEFAULT
Definition: WM_types.h:197
#define NC_TEXT
Definition: WM_types.h:287
#define WM_DRAG_COLOR
Definition: WM_types.h:879
unsigned int U
Definition: btGjkEpa3.h:78
OperationNode * node
void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const char *var_name)
Definition: drivers.c:842
bNodeTree * ntree
#define str(s)
wmKeyMap * eyedropper_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap * eyedropper_colorband_modal_keymap(wmKeyConfig *keyconf)
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)
void ui_but_active_string_clear_and_exit(bContext *C, uiBut *but)
uiBut * ui_region_find_active_but(struct ARegion *region) ATTR_WARN_UNUSED_RESULT
void ui_rna_collection_search_update_fn(const struct bContext *C, void *arg, const char *str, uiSearchItems *items, const bool is_first)
@ UI_SELECT_DRAW
@ UI_SELECT
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_unset_property_button(wmOperatorType *ot)
static void UI_OT_button_execute(wmOperatorType *ot)
static bool override_remove_button_poll(bContext *C)
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 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:81
static void UI_OT_copy_python_command_button(wmOperatorType *ot)
static void UI_OT_assign_default_button(wmOperatorType *ot)
@ UIOverride_Type_Replace
@ UIOverride_Type_Difference
@ UIOverride_Type_NOOP
@ UIOverride_Type_Factor
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 bool copy_to_selected_button_poll(bContext *C)
static bool copy_to_selected_button(bContext *C, bool all, bool poll)
bool UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(r_tooltip))
static void UI_OT_jump_to_target_button(wmOperatorType *ot)
static void UI_OT_copy_to_selected_button(wmOperatorType *ot)
static int override_remove_button_exec(bContext *C, wmOperator *op)
void UI_drop_color_copy(wmDrag *drag, wmDropBox *drop)
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)
#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 bool assign_default_button_poll(bContext *C)
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 EnumPropertyItem override_type_items[]
static int copy_as_driver_button_exec(bContext *C, wmOperator *op)
static bool copy_as_driver_button_poll(bContext *C)
static void UI_OT_drop_color(wmOperatorType *ot)
static void ui_context_selected_bones_via_pose(bContext *C, ListBase *r_lb)
static int button_string_clear_exec(bContext *C, wmOperator *UNUSED(op))
#define GS(x)
Definition: iris.c:241
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static void area(int d1, int d2, int e1, int e2, float weights[2])
#define hash
Definition: noise.c:169
void PyC_FileAndNum_Safe(const char **r_filename, int *r_lineno)
return ret
char * RNA_path_resolve_from_type_to_property(PointerRNA *ptr, PropertyRNA *prop, const StructRNA *type)
Definition: rna_access.c:6046
bool RNA_property_array_check(PropertyRNA *prop)
Definition: rna_access.c:1223
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
Definition: rna_access.c:844
bool RNA_property_assign_default(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:8125
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:146
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
Definition: rna_access.c:6550
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
Definition: rna_access.c:122
const char * RNA_property_identifier(const PropertyRNA *prop)
Definition: rna_access.c:1145
bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
Definition: rna_access.c:8030
int RNA_property_array_dimension(PointerRNA *ptr, PropertyRNA *prop, int length[])
Definition: rna_access.c:1229
float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
Definition: rna_access.c:3108
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
Definition: rna_access.c:6272
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:6655
PropertyType RNA_property_type(PropertyRNA *prop)
Definition: rna_access.c:1155
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3641
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
Definition: rna_access.c:6378
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2317
char * RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:6027
char * RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len)
Definition: rna_access.c:3339
char * RNA_path_from_struct_to_idproperty(PointerRNA *ptr, IDProperty *needle)
Definition: rna_access.c:5781
int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, const char *key, PointerRNA *r_ptr)
Definition: rna_access.c:4299
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
Definition: rna_access.c:6514
PropertyRNA * RNA_struct_type_find_property(StructRNA *srna, const char *identifier)
Definition: rna_access.c:953
char * RNA_path_full_property_py_ex(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, int index, bool use_fallback)
Definition: rna_access.c:6147
char * RNA_path_from_real_ID_to_property_index(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, int index_dim, int index, ID **r_real_id)
Definition: rna_access.c:6032
bool RNA_pointer_is_null(const PointerRNA *ptr)
Definition: rna_access.c:174
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:1218
bool RNA_property_is_idprop(const PropertyRNA *prop)
Definition: rna_access.c:6706
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
Definition: rna_access.c:3132
PropertySubType RNA_property_subtype(PropertyRNA *prop)
Definition: rna_access.c:1160
bool RNA_path_resolve_property(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
Definition: rna_access.c:5434
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6261
char * RNA_path_full_struct_py(Main *bmain, struct PointerRNA *ptr)
Definition: rna_access.c:6115
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
Definition: rna_access.c:6413
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
Definition: rna_access.c:6390
bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop_orig)
Definition: rna_access.c:2073
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6402
void RNA_property_unset(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:6665
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:3481
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:3911
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1512
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3771
StructRNA RNA_PropertyGroup
short regiontype
struct Object * object
struct ID * reference
Definition: DNA_ID.h:250
Definition: DNA_ID.h:273
int tag
Definition: DNA_ID.h:292
IDOverrideLibrary * override_library
Definition: DNA_ID.h:317
char name[66]
Definition: DNA_ID.h:283
Definition: BKE_main.h:116
ListBase texts
Definition: BKE_main.h:163
void * data
struct StructRNA * type
Definition: RNA_types.h:51
void * data
Definition: RNA_types.h:52
struct ID * owner_id
Definition: RNA_types.h:50
struct Image * image
struct Text * text
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:908
int type
Definition: WM_types.h:907
struct PointerRNA * ptr
Definition: WM_types.h:953
int y
Definition: WM_types.h:581
int mval[2]
Definition: WM_types.h:583
int x
Definition: WM_types.h:581
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:752
const char * name
Definition: WM_types.h:721
const char * idname
Definition: WM_types.h:723
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:776
struct StructRNA * srna
Definition: WM_types.h:802
const char * description
Definition: WM_types.h:726
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:736
PropertyRNA * prop
Definition: WM_types.h:814
struct ReportList * reports
struct PointerRNA * ptr
__forceinline bool all(const avxb &b)
Definition: util_avxb.h:214
void WM_draw_region_viewport_unbind(ARegion *region)
Definition: wm_draw.c:1141
void WM_draw_region_viewport_bind(ARegion *region)
Definition: wm_draw.c:1136
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
int WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, short context, PointerRNA *properties)
void WM_event_add_mousemove(wmWindow *win)
PointerRNA * ptr
Definition: wm_files.c:3157
wmOperatorType * ot
Definition: wm_files.c:3156
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition: wm_keymap.c:852
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, int opcontext)
Definition: wm_operators.c:950
char * WM_operator_pystring_ex(bContext *C, wmOperator *op, const bool all_args, const bool macro_args, wmOperatorType *ot, PointerRNA *opptr)
Definition: wm_operators.c:228
void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot)
Definition: wm_operators.c:584
void WM_clipboard_text_set(const char *buf, bool selection)
Definition: wm_window.c:1778