Blender  V2.93
interface_context_menu.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 
23 #include <string.h>
24 
25 #include "MEM_guardedalloc.h"
26 
27 #include "DNA_scene_types.h"
28 #include "DNA_screen_types.h"
29 
30 #include "BLI_path_util.h"
31 #include "BLI_string.h"
32 #include "BLI_utildefines.h"
33 
34 #include "BLT_translation.h"
35 
36 #include "BKE_addon.h"
37 #include "BKE_context.h"
38 #include "BKE_idprop.h"
39 #include "BKE_screen.h"
40 
41 #include "ED_asset.h"
42 #include "ED_keyframing.h"
43 #include "ED_screen.h"
44 
45 #include "UI_interface.h"
46 
47 #include "interface_intern.h"
48 
49 #include "RNA_access.h"
50 
51 #ifdef WITH_PYTHON
52 # include "BPY_extern.h"
53 # include "BPY_extern_run.h"
54 #endif
55 
56 #include "WM_api.h"
57 #include "WM_types.h"
58 
59 /* This hack is needed because we don't have a good way to
60  * re-reference keymap items once added: T42944 */
61 #define USE_KEYMAP_ADD_HACK
62 
63 /* -------------------------------------------------------------------- */
68 {
69  /* Compute data path from context to property. */
70 
71  /* If this returns null, we won't be able to bind shortcuts to these RNA properties.
72  * Support can be added at #wm_context_member_from_ptr. */
73  const char *member_id = WM_context_member_from_ptr(C, &but->rnapoin);
74  if (member_id == NULL) {
75  return NULL;
76  }
77 
78  const char *data_path = RNA_path_from_ID_to_struct(&but->rnapoin);
79  const char *member_id_data_path = member_id;
80 
81  if (data_path) {
82  member_id_data_path = BLI_sprintfN("%s.%s", member_id, data_path);
83  MEM_freeN((void *)data_path);
84  }
85 
86  const char *prop_id = RNA_property_identifier(but->rnaprop);
87  const char *final_data_path = BLI_sprintfN("%s.%s", member_id_data_path, prop_id);
88 
89  if (member_id != member_id_data_path) {
90  MEM_freeN((void *)member_id_data_path);
91  }
92 
93  /* Create ID property of data path, to pass to the operator. */
94  const IDPropertyTemplate val = {0};
95  IDProperty *prop = IDP_New(IDP_GROUP, &val, __func__);
96  IDP_AddToGroup(prop, IDP_NewString(final_data_path, "data_path", strlen(final_data_path) + 1));
97 
98  MEM_freeN((void *)final_data_path);
99 
100  return prop;
101 }
102 
103 static const char *shortcut_get_operator_property(bContext *C, uiBut *but, IDProperty **r_prop)
104 {
105  if (but->optype) {
106  /* Operator */
107  *r_prop = (but->opptr && but->opptr->data) ? IDP_CopyProperty(but->opptr->data) : NULL;
108  return but->optype->idname;
109  }
110 
111  if (but->rnaprop) {
112  const PropertyType rnaprop_type = RNA_property_type(but->rnaprop);
113 
114  if (rnaprop_type == PROP_BOOLEAN) {
115  /* Boolean */
116  *r_prop = shortcut_property_from_rna(C, but);
117  if (*r_prop == NULL) {
118  return NULL;
119  }
120  return "WM_OT_context_toggle";
121  }
122  if (rnaprop_type == PROP_ENUM) {
123  /* Enum */
124  *r_prop = shortcut_property_from_rna(C, but);
125  if (*r_prop == NULL) {
126  return NULL;
127  }
128  return "WM_OT_context_menu_enum";
129  }
130  }
131 
132  *r_prop = NULL;
133  return NULL;
134 }
135 
137 {
138  if (prop) {
139  IDP_FreeProperty(prop);
140  }
141 }
142 
143 static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
144 {
145  uiBut *but = (uiBut *)arg1;
146  char shortcut_str[128];
147 
148  IDProperty *prop;
149  const char *idname = shortcut_get_operator_property(C, but, &prop);
150  if (idname == NULL) {
151  return;
152  }
153 
154  /* complex code to change name of button */
156  C, idname, but->opcontext, prop, true, shortcut_str, sizeof(shortcut_str))) {
157  ui_but_add_shortcut(but, shortcut_str, true);
158  }
159  else {
160  /* simply strip the shortcut */
161  ui_but_add_shortcut(but, NULL, true);
162  }
163 
165 }
166 
167 static uiBlock *menu_change_shortcut(bContext *C, ARegion *region, void *arg)
168 {
170  uiBut *but = (uiBut *)arg;
171  PointerRNA ptr;
172  const uiStyle *style = UI_style_get_dpi();
173  IDProperty *prop;
174  const char *idname = shortcut_get_operator_property(C, but, &prop);
175 
176  wmKeyMap *km;
178  idname,
179  but->opcontext,
180  prop,
183  &km);
184  U.runtime.is_dirty = true;
185 
186  BLI_assert(kmi != NULL);
187 
188  RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr);
189 
190  uiBlock *block = UI_block_begin(C, region, "_popup", UI_EMBOSS);
194 
195  uiLayout *layout = UI_block_layout(block,
198  0,
199  0,
200  U.widget_unit * 10,
201  U.widget_unit * 2,
202  0,
203  style);
204 
205  uiItemL(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Change Shortcut"), ICON_HAND);
206  uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
207 
209  block, 6 * U.dpi_fac, (const int[2]){-100 * U.dpi_fac, 36 * U.dpi_fac});
210 
212 
213  return block;
214 }
215 
216 #ifdef USE_KEYMAP_ADD_HACK
217 static int g_kmi_id_hack;
218 #endif
219 
220 static uiBlock *menu_add_shortcut(bContext *C, ARegion *region, void *arg)
221 {
223  uiBut *but = (uiBut *)arg;
224  PointerRNA ptr;
225  const uiStyle *style = UI_style_get_dpi();
226  IDProperty *prop;
227  const char *idname = shortcut_get_operator_property(C, but, &prop);
228 
229  /* XXX this guess_opname can potentially return a different keymap
230  * than being found on adding later... */
231  wmKeyMap *km = WM_keymap_guess_opname(C, idname);
232  wmKeyMapItem *kmi = WM_keymap_add_item(km, idname, EVT_AKEY, KM_PRESS, 0, 0);
233  const int kmi_id = kmi->id;
234 
235  /* This takes ownership of prop, or prop can be NULL for reset. */
237 
238  /* update and get pointers again */
240  U.runtime.is_dirty = true;
241 
242  km = WM_keymap_guess_opname(C, idname);
243  kmi = WM_keymap_item_find_id(km, kmi_id);
244 
245  RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr);
246 
247  uiBlock *block = UI_block_begin(C, region, "_popup", UI_EMBOSS);
250 
251  uiLayout *layout = UI_block_layout(block,
254  0,
255  0,
256  U.widget_unit * 10,
257  U.widget_unit * 2,
258  0,
259  style);
260 
261  uiItemL(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Assign Shortcut"), ICON_HAND);
262  uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
263 
265  block, 6 * U.dpi_fac, (const int[2]){-100 * U.dpi_fac, 36 * U.dpi_fac});
266 
267 #ifdef USE_KEYMAP_ADD_HACK
268  g_kmi_id_hack = kmi_id;
269 #endif
270 
271  return block;
272 }
273 
274 static void menu_add_shortcut_cancel(struct bContext *C, void *arg1)
275 {
276  uiBut *but = (uiBut *)arg1;
277 
278  IDProperty *prop;
279  const char *idname = shortcut_get_operator_property(C, but, &prop);
280 
281 #ifdef USE_KEYMAP_ADD_HACK
282  wmKeyMap *km = WM_keymap_guess_opname(C, idname);
283  const int kmi_id = g_kmi_id_hack;
284  UNUSED_VARS(but);
285 #else
286  int kmi_id = WM_key_event_operator_id(C, idname, but->opcontext, prop, true, &km);
287 #endif
288 
290 
291  wmKeyMapItem *kmi = WM_keymap_item_find_id(km, kmi_id);
292  WM_keymap_remove_item(km, kmi);
293 }
294 
295 static void popup_change_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
296 {
297  uiBut *but = (uiBut *)arg1;
299 }
300 
301 static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
302 {
303  uiBut *but = (uiBut *)arg1;
304  IDProperty *prop;
305  const char *idname = shortcut_get_operator_property(C, but, &prop);
306 
307  wmKeyMap *km;
309  idname,
310  but->opcontext,
311  prop,
314  &km);
315  BLI_assert(kmi != NULL);
316 
317  WM_keymap_remove_item(km, kmi);
318  U.runtime.is_dirty = true;
319 
321  but_shortcut_name_func(C, but, 0);
322 }
323 
324 static void popup_add_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
325 {
326  uiBut *but = (uiBut *)arg1;
328 }
329 
331 {
332  return (but->optype ||
333  (but->rnaprop && (RNA_property_type(but->rnaprop) == PROP_BOOLEAN) &&
334  (WM_context_member_from_ptr(C, &but->rnapoin) != NULL)) ||
335  UI_but_menutype_get(but));
336 }
337 
339 {
340  if (but->optype) {
341  IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
343  &um->items, but->optype, prop, but->opcontext);
344  }
345  if (but->rnaprop) {
346  const char *member_id = WM_context_member_from_ptr(C, &but->rnapoin);
347  const char *data_path = RNA_path_from_ID_to_struct(&but->rnapoin);
348  const char *member_id_data_path = member_id;
349  if (data_path) {
350  member_id_data_path = BLI_sprintfN("%s.%s", member_id, data_path);
351  }
352  const char *prop_id = RNA_property_identifier(but->rnaprop);
354  &um->items, member_id_data_path, prop_id, but->rnaindex);
355  if (data_path) {
356  MEM_freeN((void *)data_path);
357  }
358  if (member_id != member_id_data_path) {
359  MEM_freeN((void *)member_id_data_path);
360  }
361  return umi;
362  }
363 
364  MenuType *mt = UI_but_menutype_get(but);
365  if (mt != NULL) {
367  }
368  return NULL;
369 }
370 
372 {
374 
375  char drawstr[sizeof(but->drawstr)];
376  STRNCPY(drawstr, but->drawstr);
377  if (but->flag & UI_BUT_HAS_SEP_CHAR) {
378  char *sep = strrchr(drawstr, UI_SEP_CHAR);
379  if (sep) {
380  *sep = '\0';
381  }
382  }
383 
384  MenuType *mt = NULL;
385  if (but->optype) {
386  if (drawstr[0] == '\0') {
387  /* Hard code overrides for generic operators. */
388  if (UI_but_is_tool(but)) {
389  char idname[64];
390  RNA_string_get(but->opptr, "name", idname);
391 #ifdef WITH_PYTHON
392  {
393  const char *expr_imports[] = {"bpy", "bl_ui", NULL};
394  char expr[256];
395  SNPRINTF(expr,
396  "bl_ui.space_toolsystem_common.item_from_id("
397  "bpy.context, "
398  "bpy.context.space_data.type, "
399  "'%s').label",
400  idname);
401  char *expr_result = NULL;
402  if (BPY_run_string_as_string(C, expr_imports, expr, NULL, &expr_result)) {
403  STRNCPY(drawstr, expr_result);
404  MEM_freeN(expr_result);
405  }
406  else {
407  BLI_assert(0);
408  STRNCPY(drawstr, idname);
409  }
410  }
411 #else
412  STRNCPY(drawstr, idname);
413 #endif
414  }
415  }
417  &um->items, drawstr, but->optype, but->opptr ? but->opptr->data : NULL, but->opcontext);
418  }
419  else if (but->rnaprop) {
420  /* Note: 'member_id' may be a path. */
421  const char *member_id = WM_context_member_from_ptr(C, &but->rnapoin);
422  const char *data_path = RNA_path_from_ID_to_struct(&but->rnapoin);
423  const char *member_id_data_path = member_id;
424  if (data_path) {
425  member_id_data_path = BLI_sprintfN("%s.%s", member_id, data_path);
426  }
427  const char *prop_id = RNA_property_identifier(but->rnaprop);
428  /* Note, ignore 'drawstr', use property idname always. */
429  ED_screen_user_menu_item_add_prop(&um->items, "", member_id_data_path, prop_id, but->rnaindex);
430  if (data_path) {
431  MEM_freeN((void *)data_path);
432  }
433  if (member_id != member_id_data_path) {
434  MEM_freeN((void *)member_id_data_path);
435  }
436  }
437  else if ((mt = UI_but_menutype_get(but))) {
438  ED_screen_user_menu_item_add_menu(&um->items, drawstr, mt);
439  }
440 }
441 
442 static void popup_user_menu_add_or_replace_func(bContext *C, void *arg1, void *UNUSED(arg2))
443 {
444  uiBut *but = arg1;
446  U.runtime.is_dirty = true;
447  ui_but_user_menu_add(C, but, um);
448 }
449 
450 static void popup_user_menu_remove_func(bContext *UNUSED(C), void *arg1, void *arg2)
451 {
452  bUserMenu *um = arg1;
453  bUserMenuItem *umi = arg2;
454  U.runtime.is_dirty = true;
456 }
457 
459 {
460  const PropertySubType subtype = RNA_property_subtype(prop);
461  wmOperatorType *ot = WM_operatortype_find("WM_OT_path_open", true);
462  char filepath[FILE_MAX];
463  char dir[FILE_MAXDIR];
464  char file[FILE_MAXFILE];
465  PointerRNA props_ptr;
466 
468  UNUSED_VARS_NDEBUG(subtype);
469 
470  RNA_property_string_get(ptr, prop, filepath);
471  BLI_split_dirfile(filepath, dir, file, sizeof(dir), sizeof(file));
472 
473  if (file[0]) {
474  BLI_assert(subtype == PROP_FILEPATH);
475  uiItemFullO_ptr(layout,
476  ot,
477  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open File Externally"),
478  ICON_NONE,
479  NULL,
481  0,
482  &props_ptr);
483  RNA_string_set(&props_ptr, "filepath", filepath);
484  }
485 
486  uiItemFullO_ptr(layout,
487  ot,
488  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Location Externally"),
489  ICON_NONE,
490  NULL,
492  0,
493  &props_ptr);
494  RNA_string_set(&props_ptr, "filepath", dir);
495 }
496 
498 {
499  /* ui_but_is_interactive() may let some buttons through that should not get a context menu - it
500  * doesn't make sense for them. */
501  if (ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_IMAGE)) {
502  return false;
503  }
504 
505  uiPopupMenu *pup;
506  uiLayout *layout;
507  bContextStore *previous_ctx = CTX_store_get(C);
508  {
510 
511  /* highly unlikely getting the label ever fails */
513 
514  pup = UI_popup_menu_begin(C, label.strinfo ? label.strinfo : "", ICON_NONE);
515  layout = UI_popup_menu_layout(pup);
516  if (label.strinfo) {
517  MEM_freeN(label.strinfo);
518  }
519 
520  if (but->context) {
521  uiLayoutContextCopy(layout, but->context);
523  }
525  }
526 
527  const bool is_disabled = but->flag & UI_BUT_DISABLED;
528 
529  if (is_disabled) {
530  /* Suppress editing commands. */
531  }
532  else if (but->type == UI_BTYPE_TAB) {
533  uiButTab *tab = (uiButTab *)but;
534  if (tab->menu) {
535  UI_menutype_draw(C, tab->menu, layout);
536  uiItemS(layout);
537  }
538  }
539  else if (but->rnapoin.data && but->rnaprop) {
540  PointerRNA *ptr = &but->rnapoin;
541  PropertyRNA *prop = but->rnaprop;
542  const PropertyType type = RNA_property_type(prop);
543  const PropertySubType subtype = RNA_property_subtype(prop);
544  bool is_anim = RNA_property_animateable(ptr, prop);
545  const bool is_idprop = RNA_property_is_idprop(prop);
546 
547  /* second slower test,
548  * saved people finding keyframe items in menus when its not possible */
549  if (is_anim) {
550  is_anim = RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop);
551  }
552 
553  /* determine if we can key a single component of an array */
554  const bool is_array = RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0;
555  const bool is_array_component = (is_array && but->rnaindex != -1);
556  const bool is_whole_array = (is_array && but->rnaindex == -1);
557 
558  const uint override_status = RNA_property_override_library_status(
559  CTX_data_main(C), ptr, prop, -1);
560  const bool is_overridable = (override_status & RNA_OVERRIDE_STATUS_OVERRIDABLE) != 0;
561 
562  /* Set the (button_pointer, button_prop)
563  * and pointer data for Python access to the hovered ui element. */
564  uiLayoutSetContextFromBut(layout, but);
565 
566  /* Keyframes */
567  if (but->flag & UI_BUT_ANIMATED_KEY) {
568  /* Replace/delete keyframes. */
569  if (is_array_component) {
570  uiItemBooleanO(layout,
571  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Keyframes"),
572  ICON_KEY_HLT,
573  "ANIM_OT_keyframe_insert_button",
574  "all",
575  1);
576  uiItemBooleanO(layout,
577  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Single Keyframe"),
578  ICON_NONE,
579  "ANIM_OT_keyframe_insert_button",
580  "all",
581  0);
582  uiItemBooleanO(layout,
583  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Keyframes"),
584  ICON_NONE,
585  "ANIM_OT_keyframe_delete_button",
586  "all",
587  1);
588  uiItemBooleanO(layout,
589  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Single Keyframe"),
590  ICON_NONE,
591  "ANIM_OT_keyframe_delete_button",
592  "all",
593  0);
594  }
595  else {
596  uiItemBooleanO(layout,
597  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Keyframe"),
598  ICON_KEY_HLT,
599  "ANIM_OT_keyframe_insert_button",
600  "all",
601  1);
602  uiItemBooleanO(layout,
603  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Keyframe"),
604  ICON_NONE,
605  "ANIM_OT_keyframe_delete_button",
606  "all",
607  1);
608  }
609 
610  /* keyframe settings */
611  uiItemS(layout);
612  }
613  else if (but->flag & UI_BUT_DRIVEN) {
614  /* pass */
615  }
616  else if (is_anim) {
617  if (is_array_component) {
618  uiItemBooleanO(layout,
619  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframes"),
620  ICON_KEY_HLT,
621  "ANIM_OT_keyframe_insert_button",
622  "all",
623  1);
624  uiItemBooleanO(layout,
625  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Single Keyframe"),
626  ICON_NONE,
627  "ANIM_OT_keyframe_insert_button",
628  "all",
629  0);
630  }
631  else {
632  uiItemBooleanO(layout,
633  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframe"),
634  ICON_KEY_HLT,
635  "ANIM_OT_keyframe_insert_button",
636  "all",
637  1);
638  }
639  }
640 
641  if ((but->flag & UI_BUT_ANIMATED) && (but->rnapoin.type != &RNA_NlaStrip)) {
642  if (is_array_component) {
643  uiItemBooleanO(layout,
644  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"),
645  ICON_KEY_DEHLT,
646  "ANIM_OT_keyframe_clear_button",
647  "all",
648  1);
649  uiItemBooleanO(layout,
650  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Single Keyframes"),
651  ICON_NONE,
652  "ANIM_OT_keyframe_clear_button",
653  "all",
654  0);
655  }
656  else {
657  uiItemBooleanO(layout,
658  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"),
659  ICON_KEY_DEHLT,
660  "ANIM_OT_keyframe_clear_button",
661  "all",
662  1);
663  }
664  }
665 
666  /* Drivers */
667  if (but->flag & UI_BUT_DRIVEN) {
668  uiItemS(layout);
669 
670  if (is_array_component) {
671  uiItemBooleanO(layout,
672  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Drivers"),
673  ICON_X,
674  "ANIM_OT_driver_button_remove",
675  "all",
676  1);
677  uiItemBooleanO(layout,
678  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Single Driver"),
679  ICON_NONE,
680  "ANIM_OT_driver_button_remove",
681  "all",
682  0);
683  }
684  else {
685  uiItemBooleanO(layout,
687  ICON_X,
688  "ANIM_OT_driver_button_remove",
689  "all",
690  1);
691  }
692 
693  if (!is_whole_array) {
694  uiItemO(layout,
696  ICON_NONE,
697  "ANIM_OT_copy_driver_button");
698  if (ANIM_driver_can_paste()) {
699  uiItemO(layout,
701  ICON_NONE,
702  "ANIM_OT_paste_driver_button");
703  }
704 
705  uiItemO(layout,
707  ICON_DRIVER,
708  "ANIM_OT_driver_button_edit");
709  }
710 
711  uiItemO(layout,
712  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"),
713  ICON_NONE,
714  "SCREEN_OT_drivers_editor_show");
715  }
716  else if (but->flag & (UI_BUT_ANIMATED_KEY | UI_BUT_ANIMATED)) {
717  /* pass */
718  }
719  else if (is_anim) {
720  uiItemS(layout);
721 
722  uiItemO(layout,
724  ICON_DRIVER,
725  "ANIM_OT_driver_button_add");
726 
727  if (!is_whole_array) {
728  if (ANIM_driver_can_paste()) {
729  uiItemO(layout,
731  ICON_NONE,
732  "ANIM_OT_paste_driver_button");
733  }
734  }
735 
736  uiItemO(layout,
737  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"),
738  ICON_NONE,
739  "SCREEN_OT_drivers_editor_show");
740  }
741 
742  /* Keying Sets */
743  /* TODO: check on modifyability of Keying Set when doing this */
744  if (is_anim) {
745  uiItemS(layout);
746 
747  if (is_array_component) {
748  uiItemBooleanO(layout,
749  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add All to Keying Set"),
750  ICON_KEYINGSET,
751  "ANIM_OT_keyingset_button_add",
752  "all",
753  1);
754  uiItemBooleanO(layout,
755  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add Single to Keying Set"),
756  ICON_NONE,
757  "ANIM_OT_keyingset_button_add",
758  "all",
759  0);
760  uiItemO(layout,
761  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Keying Set"),
762  ICON_NONE,
763  "ANIM_OT_keyingset_button_remove");
764  }
765  else {
766  uiItemBooleanO(layout,
767  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Keying Set"),
768  ICON_KEYINGSET,
769  "ANIM_OT_keyingset_button_add",
770  "all",
771  1);
772  uiItemO(layout,
773  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Keying Set"),
774  ICON_NONE,
775  "ANIM_OT_keyingset_button_remove");
776  }
777  }
778 
779  if (is_overridable) {
781  PointerRNA op_ptr;
782  /* Override Operators */
783  uiItemS(layout);
784 
785  if (but->flag & UI_BUT_OVERRIDDEN) {
786  if (is_array_component) {
787 #if 0 /* Disabled for now. */
788  ot = WM_operatortype_find("UI_OT_override_type_set_button", false);
790  layout, ot, "Overrides Type", ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr);
791  RNA_boolean_set(&op_ptr, "all", true);
792  uiItemFullO_ptr(layout,
793  ot,
794  "Single Override Type",
795  ICON_NONE,
796  NULL,
798  0,
799  &op_ptr);
800  RNA_boolean_set(&op_ptr, "all", false);
801 #endif
802  uiItemBooleanO(layout,
803  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Overrides"),
804  ICON_X,
805  "UI_OT_override_remove_button",
806  "all",
807  true);
808  uiItemBooleanO(layout,
809  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Single Override"),
810  ICON_X,
811  "UI_OT_override_remove_button",
812  "all",
813  false);
814  }
815  else {
816 #if 0 /* Disabled for now. */
817  uiItemFullO(layout,
818  "UI_OT_override_type_set_button",
819  "Override Type",
820  ICON_NONE,
821  NULL,
823  0,
824  &op_ptr);
825  RNA_boolean_set(&op_ptr, "all", false);
826 #endif
827  uiItemBooleanO(layout,
828  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Override"),
829  ICON_X,
830  "UI_OT_override_remove_button",
831  "all",
832  true);
833  }
834  }
835  else {
836  if (is_array_component) {
837  ot = WM_operatortype_find("UI_OT_override_type_set_button", false);
839  layout, ot, "Define Overrides", ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr);
840  RNA_boolean_set(&op_ptr, "all", true);
841  uiItemFullO_ptr(layout,
842  ot,
843  "Define Single Override",
844  ICON_NONE,
845  NULL,
847  0,
848  &op_ptr);
849  RNA_boolean_set(&op_ptr, "all", false);
850  }
851  else {
852  uiItemFullO(layout,
853  "UI_OT_override_type_set_button",
854  "Define Override",
855  ICON_NONE,
856  NULL,
858  0,
859  &op_ptr);
860  RNA_boolean_set(&op_ptr, "all", false);
861  }
862  }
863  }
864 
865  uiItemS(layout);
866 
867  /* Property Operators */
868 
869  /* Copy Property Value
870  * Paste Property Value */
871 
872  if (is_array_component) {
873  uiItemBooleanO(layout,
874  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset All to Default Values"),
875  ICON_LOOP_BACK,
876  "UI_OT_reset_default_button",
877  "all",
878  1);
879  uiItemBooleanO(layout,
880  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset Single to Default Value"),
881  ICON_NONE,
882  "UI_OT_reset_default_button",
883  "all",
884  0);
885  }
886  else {
887  uiItemBooleanO(layout,
888  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Reset to Default Value"),
889  ICON_LOOP_BACK,
890  "UI_OT_reset_default_button",
891  "all",
892  1);
893  }
894 
895  if (is_idprop && !is_array && ELEM(type, PROP_INT, PROP_FLOAT)) {
896  uiItemO(layout,
897  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Assign Value as Default"),
898  ICON_NONE,
899  "UI_OT_assign_default_button");
900 
901  uiItemS(layout);
902  }
903 
904  if (is_array_component) {
905  uiItemBooleanO(layout,
906  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy All to Selected"),
907  ICON_NONE,
908  "UI_OT_copy_to_selected_button",
909  "all",
910  true);
911  uiItemBooleanO(layout,
912  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Single to Selected"),
913  ICON_NONE,
914  "UI_OT_copy_to_selected_button",
915  "all",
916  false);
917  }
918  else {
919  uiItemBooleanO(layout,
920  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy to Selected"),
921  ICON_NONE,
922  "UI_OT_copy_to_selected_button",
923  "all",
924  true);
925  }
926 
927  uiItemO(layout,
928  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Data Path"),
929  ICON_NONE,
930  "UI_OT_copy_data_path_button");
931  uiItemBooleanO(layout,
932  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Full Data Path"),
933  ICON_NONE,
934  "UI_OT_copy_data_path_button",
935  "full_path",
936  true);
937 
938  if (ptr->owner_id && !is_whole_array &&
940  uiItemO(layout,
941  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy as New Driver"),
942  ICON_NONE,
943  "UI_OT_copy_as_driver_button");
944  }
945 
946  uiItemS(layout);
947 
948  if (type == PROP_STRING && ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH)) {
949  ui_but_menu_add_path_operators(layout, ptr, prop);
950  uiItemS(layout);
951  }
952  }
953 
954  /* If the button represents an id, it can set the "id" context pointer. */
955  if (U.experimental.use_asset_browser && ED_asset_can_make_single_from_context(C)) {
956  ID *id = CTX_data_pointer_get_type(C, "id", &RNA_ID).data;
957 
958  /* Gray out items depending on if data-block is an asset. Preferably this could be done via
959  * operator poll, but that doesn't work since the operator also works with "selected_ids",
960  * which isn't cheap to check. */
961  uiLayout *sub = uiLayoutColumn(layout, true);
963  uiItemO(sub, NULL, ICON_NONE, "ASSET_OT_mark");
964  sub = uiLayoutColumn(layout, true);
966  uiItemO(sub, NULL, ICON_NONE, "ASSET_OT_clear");
967  uiItemS(layout);
968  }
969 
970  /* Pointer properties and string properties with
971  * prop_search support jumping to target object/bone. */
972  if (but->rnapoin.data && but->rnaprop) {
973  const PropertyType prop_type = RNA_property_type(but->rnaprop);
974  if (((prop_type == PROP_POINTER) ||
975  (prop_type == PROP_STRING && but->type == UI_BTYPE_SEARCH_MENU &&
976  ((uiButSearch *)but)->items_update_fn == ui_rna_collection_search_update_fn)) &&
978  uiItemO(layout,
979  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Jump to Target"),
980  ICON_NONE,
981  "UI_OT_jump_to_target_button");
982  uiItemS(layout);
983  }
984  }
985 
986  /* Favorites Menu */
987  if (ui_but_is_user_menu_compatible(C, but)) {
988  uiBlock *block = uiLayoutGetBlock(layout);
989  const int w = uiLayoutGetWidth(layout);
990  bool item_found = false;
991 
992  uint um_array_len;
993  bUserMenu **um_array = ED_screen_user_menus_find(C, &um_array_len);
994  for (int um_index = 0; um_index < um_array_len; um_index++) {
995  bUserMenu *um = um_array[um_index];
996  if (um == NULL) {
997  continue;
998  }
999  bUserMenuItem *umi = ui_but_user_menu_find(C, but, um);
1000  if (umi != NULL) {
1001  uiBut *but2 = uiDefIconTextBut(
1002  block,
1003  UI_BTYPE_BUT,
1004  0,
1005  ICON_MENU_PANEL,
1006  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Quick Favorites"),
1007  0,
1008  0,
1009  w,
1010  UI_UNIT_Y,
1011  NULL,
1012  0,
1013  0,
1014  0,
1015  0,
1016  "");
1018  item_found = true;
1019  }
1020  }
1021  if (um_array) {
1022  MEM_freeN(um_array);
1023  }
1024 
1025  if (!item_found) {
1026  uiBut *but2 = uiDefIconTextBut(
1027  block,
1028  UI_BTYPE_BUT,
1029  0,
1030  ICON_MENU_PANEL,
1031  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Quick Favorites"),
1032  0,
1033  0,
1034  w,
1035  UI_UNIT_Y,
1036  NULL,
1037  0,
1038  0,
1039  0,
1040  0,
1041  "Add to a user defined context menu (stored in the user preferences)");
1043  }
1044 
1045  uiItemS(layout);
1046  }
1047 
1048  /* Shortcut menu */
1049  IDProperty *prop;
1050  const char *idname = shortcut_get_operator_property(C, but, &prop);
1051  if (idname != NULL) {
1052  uiBlock *block = uiLayoutGetBlock(layout);
1053  const int w = uiLayoutGetWidth(layout);
1054 
1055  /* We want to know if this op has a shortcut, be it hotkey or not. */
1056  wmKeyMap *km;
1058  C, idname, but->opcontext, prop, EVT_TYPE_MASK_ALL, 0, &km);
1059 
1060  /* We do have a shortcut, but only keyboard ones are editable that way... */
1061  if (kmi) {
1062  if (ISKEYBOARD(kmi->type)) {
1063 #if 0 /* would rather use a block but, but gets weirdly positioned... */
1064  uiDefBlockBut(block,
1066  but,
1067  "Change Shortcut",
1068  0,
1069  0,
1070  uiLayoutGetWidth(layout),
1071  UI_UNIT_Y,
1072  "");
1073 #endif
1074 
1075  uiBut *but2 = uiDefIconTextBut(
1076  block,
1077  UI_BTYPE_BUT,
1078  0,
1079  ICON_HAND,
1080  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Change Shortcut"),
1081  0,
1082  0,
1083  w,
1084  UI_UNIT_Y,
1085  NULL,
1086  0,
1087  0,
1088  0,
1089  0,
1090  "");
1092  }
1093  else {
1094  uiBut *but2 = uiDefIconTextBut(block,
1095  UI_BTYPE_BUT,
1096  0,
1097  ICON_HAND,
1098  IFACE_("Non-Keyboard Shortcut"),
1099  0,
1100  0,
1101  w,
1102  UI_UNIT_Y,
1103  NULL,
1104  0,
1105  0,
1106  0,
1107  0,
1108  TIP_("Only keyboard shortcuts can be edited that way, "
1109  "please use User Preferences otherwise"));
1111  }
1112 
1113  uiBut *but2 = uiDefIconTextBut(
1114  block,
1115  UI_BTYPE_BUT,
1116  0,
1117  ICON_BLANK1,
1118  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove Shortcut"),
1119  0,
1120  0,
1121  w,
1122  UI_UNIT_Y,
1123  NULL,
1124  0,
1125  0,
1126  0,
1127  0,
1128  "");
1130  }
1131  /* only show 'assign' if there's a suitable key map for it to go in */
1132  else if (WM_keymap_guess_opname(C, idname)) {
1133  uiBut *but2 = uiDefIconTextBut(
1134  block,
1135  UI_BTYPE_BUT,
1136  0,
1137  ICON_HAND,
1138  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Assign Shortcut"),
1139  0,
1140  0,
1141  w,
1142  UI_UNIT_Y,
1143  NULL,
1144  0,
1145  0,
1146  0,
1147  0,
1148  "");
1150  }
1151 
1153 
1154  /* Set the operator pointer for python access */
1155  uiLayoutSetContextFromBut(layout, but);
1156 
1157  uiItemS(layout);
1158  }
1159 
1160  { /* Docs */
1161  char buf[512];
1162 
1163  if (UI_but_online_manual_id(but, buf, sizeof(buf))) {
1164  PointerRNA ptr_props;
1165  uiItemO(layout,
1166  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Manual"),
1167  ICON_URL,
1168  "WM_OT_doc_view_manual_ui_context");
1169 
1170  if (U.flag & USER_DEVELOPER_UI) {
1171  uiItemFullO(layout,
1172  "WM_OT_doc_view",
1173  CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Python Reference"),
1174  ICON_NONE,
1175  NULL,
1177  0,
1178  &ptr_props);
1179  RNA_string_set(&ptr_props, "doc_id", buf);
1180  }
1181  }
1182  }
1183 
1184  if (but->optype && U.flag & USER_DEVELOPER_UI) {
1185  uiItemO(layout, NULL, ICON_NONE, "UI_OT_copy_python_command_button");
1186  }
1187 
1188  /* perhaps we should move this into (G.debug & G_DEBUG) - campbell */
1189  if (U.flag & USER_DEVELOPER_UI) {
1190  if (ui_block_is_menu(but->block) == false) {
1191  uiItemFullO(
1192  layout, "UI_OT_editsource", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL);
1193  }
1194  }
1195 
1196  if (BKE_addon_find(&U.addons, "ui_translate")) {
1197  uiItemFullO(layout,
1198  "UI_OT_edittranslation_init",
1199  NULL,
1200  ICON_NONE,
1201  NULL,
1203  0,
1204  NULL);
1205  }
1206 
1207  /* Show header tools for header buttons. */
1208  if (ui_block_is_popup_any(but->block) == false) {
1209  const ARegion *region = CTX_wm_region(C);
1210 
1211  if (!region) {
1212  /* skip */
1213  }
1214  else if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
1215  uiItemMenuF(layout, IFACE_("Header"), ICON_NONE, ED_screens_header_tools_menu_create, NULL);
1216  }
1217  else if (region->regiontype == RGN_TYPE_NAV_BAR) {
1218  uiItemMenuF(layout,
1219  IFACE_("Navigation Bar"),
1220  ICON_NONE,
1222  NULL);
1223  }
1224  else if (region->regiontype == RGN_TYPE_FOOTER) {
1225  uiItemMenuF(layout, IFACE_("Footer"), ICON_NONE, ED_screens_footer_tools_menu_create, NULL);
1226  }
1227  }
1228 
1229  MenuType *mt = WM_menutype_find("WM_MT_button_context", true);
1230  if (mt) {
1231  UI_menutype_draw(C, mt, uiLayoutColumn(layout, false));
1232  }
1233 
1234  if (but->context) {
1235  CTX_store_set(C, previous_ctx);
1236  }
1237 
1238  return UI_popup_menu_end_or_cancel(C, pup);
1239 }
1240 
1243 /* -------------------------------------------------------------------- */
1251 {
1252  bScreen *screen = CTX_wm_screen(C);
1253  const bool has_panel_category = UI_panel_category_is_visible(region);
1254  const bool any_item_visible = has_panel_category;
1255 
1256  if (!any_item_visible) {
1257  return;
1258  }
1259  if (panel->type->parent != NULL) {
1260  return;
1261  }
1262 
1263  PointerRNA ptr;
1264  RNA_pointer_create(&screen->id, &RNA_Panel, panel, &ptr);
1265 
1266  uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Panel"), ICON_NONE);
1267  uiLayout *layout = UI_popup_menu_layout(pup);
1268 
1269  if (has_panel_category) {
1270  char tmpstr[80];
1271  BLI_snprintf(tmpstr,
1272  sizeof(tmpstr),
1273  "%s" UI_SEP_CHAR_S "%s",
1274  IFACE_("Pin"),
1275  IFACE_("Shift Left Mouse"));
1276  uiItemR(layout, &ptr, "use_pin", 0, tmpstr, ICON_NONE);
1277 
1278  /* evil, force shortcut flag */
1279  {
1280  uiBlock *block = uiLayoutGetBlock(layout);
1281  uiBut *but = block->buttons.last;
1282  but->flag |= UI_BUT_HAS_SEP_CHAR;
1283  but->drawflag |= UI_BUT_HAS_SHORTCUT;
1284  }
1285  }
1286  UI_popup_menu_end(C, pup);
1287 }
1288 
struct bAddon * BKE_addon_find(struct ListBase *addon_list, const char *module)
Definition: addon.c:53
void CTX_store_set(bContext *C, bContextStore *store)
Definition: context.c:186
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:689
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
Definition: context.c:456
struct bScreen * CTX_wm_screen(const bContext *C)
Definition: context.c:709
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:725
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
bContextStore * CTX_store_get(bContext *C)
Definition: context.c:181
struct IDProperty * IDP_NewString(const char *st, const char *name, int maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
Definition: idprop.c:325
void IDP_FreeProperty(struct IDProperty *prop)
Definition: idprop.c:1040
bool IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL()
Definition: idprop.c:643
struct IDProperty * IDP_New(const char type, const IDPropertyTemplate *val, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: idprop.c:907
struct IDProperty * IDP_CopyProperty(const struct IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define FILE_MAXFILE
#define FILE_MAX
void BLI_split_dirfile(const char *string, char *dir, char *file, const size_t dirlen, const size_t filelen)
Definition: path_util.c:1654
#define FILE_MAXDIR
size_t size_t char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
#define STRNCPY(dst, src)
Definition: BLI_string.h:163
#define SNPRINTF(dst, format,...)
Definition: BLI_string.h:165
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:83
#define UNUSED_VARS(...)
#define UNUSED_VARS_NDEBUG(...)
#define UNUSED(x)
#define ELEM(...)
#define TIP_(msgid)
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define IFACE_(msgid)
bool BPY_run_string_as_string(struct bContext *C, const char *imports[], const char *expr, struct BPy_RunErrInfo *err_info, char **r_value)
@ IDP_GROUP
Definition: DNA_ID.h:101
@ RGN_TYPE_TOOL_HEADER
@ RGN_TYPE_NAV_BAR
@ RGN_TYPE_FOOTER
@ RGN_TYPE_HEADER
@ USER_DEVELOPER_UI
struct bUserMenu * ED_screen_user_menu_ensure(struct bContext *C)
bUserMenu ** ED_screen_user_menus_find(const struct bContext *C, uint *r_len)
void ED_screen_user_menu_item_add_operator(struct ListBase *lb, const char *ui_name, const struct wmOperatorType *ot, const struct IDProperty *prop, short opcontext)
struct bUserMenuItem_Prop * ED_screen_user_menu_item_find_prop(struct ListBase *lb, const char *context_data_path, const char *prop_id, int prop_index)
void ED_screens_footer_tools_menu_create(struct bContext *C, struct uiLayout *layout, void *arg)
struct bUserMenuItem_Menu * ED_screen_user_menu_item_find_menu(struct ListBase *lb, const struct MenuType *mt)
void ED_screens_header_tools_menu_create(struct bContext *C, struct uiLayout *layout, void *arg)
void ED_screen_user_menu_item_remove(struct ListBase *lb, struct bUserMenuItem *umi)
struct bUserMenuItem_Op * ED_screen_user_menu_item_find_operator(struct ListBase *lb, const struct wmOperatorType *ot, struct IDProperty *prop, short opcontext)
void ED_screens_navigation_bar_tools_menu_create(struct bContext *C, struct uiLayout *layout, void *arg)
void ED_screen_user_menu_item_add_prop(ListBase *lb, const char *ui_name, const char *context_data_path, const char *prop_id, int prop_index)
void ED_screen_user_menu_item_add_menu(struct ListBase *lb, const char *ui_name, const struct MenuType *mt)
_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
static bool is_disabled
Read Guarded memory(de)allocation.
@ RNA_OVERRIDE_STATUS_OVERRIDABLE
Definition: RNA_access.h:1497
StructRNA RNA_Panel
StructRNA RNA_ID
StructRNA RNA_KeyMapItem
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
PropertySubType
Definition: RNA_types.h:112
@ PROP_DIRPATH
Definition: RNA_types.h:117
@ PROP_FILEPATH
Definition: RNA_types.h:116
#define C
Definition: RandGen.cpp:39
void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value)
bool UI_but_online_manual_id(const uiBut *but, char *r_str, size_t maxlength) ATTR_WARN_UNUSED_RESULT
uiBut * uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip)
Definition: interface.c:5603
#define UI_UNIT_Y
@ UI_ITEM_R_IMMEDIATE
@ UI_ITEM_R_FULL_EVENT
#define UI_SEP_CHAR_S
Definition: UI_interface.h:87
struct bContextStore * uiLayoutGetContextStore(uiLayout *layout)
uiBlock * uiLayoutGetBlock(uiLayout *layout)
@ UI_BUT_HAS_SHORTCUT
Definition: UI_interface.h:295
@ UI_EMBOSS
Definition: UI_interface.h:107
const struct uiStyle * UI_style_get_dpi(void)
void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext)
void uiLayoutSetEnabled(uiLayout *layout, bool enabled)
@ UI_BUT_ANIMATED
Definition: UI_interface.h:201
@ UI_BUT_DISABLED
Definition: UI_interface.h:199
@ UI_BUT_OVERRIDDEN
Definition: UI_interface.h:234
@ UI_BUT_HAS_SEP_CHAR
Definition: UI_interface.h:225
@ UI_BUT_DRIVEN
Definition: UI_interface.h:203
@ UI_BUT_ANIMATED_KEY
Definition: UI_interface.h:202
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
@ UI_LAYOUT_PANEL
void uiItemFullO(uiLayout *layout, const char *opname, const char *name, int icon, struct IDProperty *properties, int context, int flag, struct PointerRNA *r_opptr)
void UI_menutype_draw(struct bContext *C, struct MenuType *mt, struct uiLayout *layout)
#define UI_SEP_CHAR
Definition: UI_interface.h:86
void UI_block_bounds_set_popup(uiBlock *block, int addval, const int bounds_offset[2])
Definition: interface.c:598
void uiItemL(uiLayout *layout, const char *name, int icon)
struct uiLayout * UI_popup_menu_layout(uiPopupMenu *pup)
void uiLayoutContextCopy(uiLayout *layout, struct bContextStore *context)
void UI_block_func_handle_set(uiBlock *block, uiBlockHandleFunc func, void *arg)
Definition: interface.c:6247
void uiItemS(uiLayout *layout)
void uiItemFullO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, struct IDProperty *properties, int context, int flag, struct PointerRNA *r_opptr)
void UI_popup_block_invoke(struct bContext *C, uiBlockCreateFunc func, void *arg, void(*arg_free)(void *arg))
void UI_popup_block_ex(struct bContext *C, uiBlockCreateFunc func, uiBlockHandleFunc popup_func, uiBlockCancelFunc cancel_func, void *arg, struct wmOperator *op)
@ UI_BLOCK_MOVEMOUSE_QUIT
Definition: UI_interface.h:148
uiLayout * UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, const struct uiStyle *style)
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
void UI_but_func_set(uiBut *but, uiButHandleFunc func, void *arg1, void *arg2)
Definition: interface.c:6294
struct MenuType * UI_but_menutype_get(uiBut *but)
bool UI_panel_category_is_visible(const struct ARegion *region)
uiBut * uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x, int y, short width, short height, const char *tip)
Definition: interface.c:6338
@ BUT_GET_LABEL
int uiLayoutGetWidth(uiLayout *layout)
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname)
uiBlock * UI_block_begin(const struct bContext *C, struct ARegion *region, const char *name, eUIEmbossType emboss)
void uiLayoutSetContextFromBut(uiLayout *layout, uiBut *but)
void UI_popup_menu_end(struct bContext *C, struct uiPopupMenu *pup)
void UI_block_direction_set(uiBlock *block, char direction)
Definition: interface.c:6028
void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg)
@ UI_DIR_CENTER_Y
Definition: UI_interface.h:127
@ UI_LAYOUT_VERTICAL
void UI_block_flag_enable(uiBlock *block, int flag)
Definition: interface.c:6067
@ UI_BTYPE_BUT
Definition: UI_interface.h:334
@ UI_BTYPE_TAB
Definition: UI_interface.h:354
@ UI_BTYPE_LABEL
Definition: UI_interface.h:358
@ UI_BTYPE_SEARCH_MENU
Definition: UI_interface.h:376
@ UI_BTYPE_IMAGE
Definition: UI_interface.h:380
bool UI_but_is_tool(const uiBut *but)
void UI_but_flag_enable(uiBut *but, int flag)
Definition: interface.c:6077
void UI_but_string_info_get(struct bContext *C, uiBut *but,...) ATTR_SENTINEL(0)
Definition: interface.c:6870
bool UI_popup_menu_end_or_cancel(struct bContext *C, struct uiPopupMenu *head)
uiPopupMenu * UI_popup_menu_begin(struct bContext *C, const char *title, int icon) ATTR_NONNULL()
@ WM_OP_INVOKE_DEFAULT
Definition: WM_types.h:197
@ WM_OP_EXEC_DEFAULT
Definition: WM_types.h:204
#define KM_PRESS
Definition: WM_types.h:242
bool ED_asset_can_make_single_from_context(const bContext *C)
Definition: asset_edit.cc:63
return(oflags[bm->toolflag_index].f &oflag) !=0
unsigned int U
Definition: btGjkEpa3.h:78
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
FILE * file
const char * label
bool ANIM_driver_can_paste(void)
Definition: drivers.c:617
void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_strip)
Definition: interface.c:1136
static bool ui_but_is_user_menu_compatible(bContext *C, uiBut *but)
static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
void ui_popup_context_menu_for_panel(bContext *C, ARegion *region, Panel *panel)
static void popup_user_menu_add_or_replace_func(bContext *C, void *arg1, void *UNUSED(arg2))
static uiBlock * menu_add_shortcut(bContext *C, ARegion *region, void *arg)
static void popup_add_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
static uiBlock * menu_change_shortcut(bContext *C, ARegion *region, void *arg)
static const char * shortcut_get_operator_property(bContext *C, uiBut *but, IDProperty **r_prop)
bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um)
static void popup_user_menu_remove_func(bContext *UNUSED(C), void *arg1, void *arg2)
static void shortcut_free_operator_property(IDProperty *prop)
static void menu_add_shortcut_cancel(struct bContext *C, void *arg1)
static void popup_change_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
static IDProperty * shortcut_property_from_rna(bContext *C, uiBut *but)
static void ui_but_menu_add_path_operators(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop)
static bUserMenuItem * ui_but_user_menu_find(bContext *C, uiBut *but, bUserMenu *um)
static int g_kmi_id_hack
bool ui_block_is_popup_any(const uiBlock *block) ATTR_WARN_UNUSED_RESULT
bool ui_block_is_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT
bool ui_jump_to_target_button_poll(struct bContext *C)
void ui_rna_collection_search_update_fn(const struct bContext *C, void *arg, const char *str, uiSearchItems *items, const bool is_first)
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
bool RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2168
bool RNA_property_path_from_ID_check(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2207
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
const char * RNA_property_identifier(const PropertyRNA *prop)
Definition: rna_access.c:1145
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
Definition: rna_access.c:6272
PropertyType RNA_property_type(PropertyRNA *prop)
Definition: rna_access.c:1155
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
Definition: rna_access.c:6514
void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value)
Definition: rna_access.c:3310
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
PropertySubType RNA_property_subtype(PropertyRNA *prop)
Definition: rna_access.c:1160
char * RNA_path_from_ID_to_struct(PointerRNA *ptr)
Definition: rna_access.c:5876
eRNAOverrideStatus RNA_property_override_library_status(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, const int index)
short regiontype
Definition: DNA_ID.h:273
struct AssetMetaData * asset_data
Definition: DNA_ID.h:280
void * last
Definition: DNA_listBase.h:47
struct PanelType * parent
Definition: BKE_screen.h:288
struct PanelType * type
struct StructRNA * type
Definition: RNA_types.h:51
void * data
Definition: RNA_types.h:52
struct ID * owner_id
Definition: RNA_types.h:50
ListBase items
ListBase buttons
struct MenuType * menu
struct bContextStore * context
eButType type
uiBlock * block
struct PointerRNA * opptr
struct wmOperatorType * optype
short opcontext
char drawstr[UI_MAX_DRAW_STR]
struct PropertyRNA * rnaprop
struct PointerRNA rnapoin
const char * idname
Definition: WM_types.h:723
#define EVT_TYPE_MASK_HOTKEY_INCLUDE
@ EVT_AKEY
#define ISKEYBOARD(event_type)
#define EVT_TYPE_MASK_HOTKEY_EXCLUDE
#define EVT_TYPE_MASK_ALL
PointerRNA * ptr
Definition: wm_files.c:3157
wmOperatorType * ot
Definition: wm_files.c:3156
wmKeyMapItem * WM_keymap_item_find_id(wmKeyMap *keymap, int id)
Definition: wm_keymap.c:1992
void WM_keyconfig_update(wmWindowManager *wm)
Definition: wm_keymap.c:1781
wmKeyMapItem * WM_keymap_add_item(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier)
Definition: wm_keymap.c:506
bool WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi)
Definition: wm_keymap.c:537
char * WM_key_event_operator_string(const bContext *C, const char *opname, int opcontext, IDProperty *properties, const bool is_strict, char *result, const int result_len)
Definition: wm_keymap.c:1587
void WM_keymap_item_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties)
Definition: wm_keymap.c:193
wmKeyMapItem * WM_key_event_operator(const bContext *C, const char *opname, int opcontext, IDProperty *properties, const short include_mask, const short exclude_mask, wmKeyMap **r_keymap)
Definition: wm_keymap.c:1627
wmKeyMap * WM_keymap_guess_opname(const bContext *C, const char *opname)
MenuType * WM_menutype_find(const char *idname, bool quiet)
Definition: wm_menu_type.c:44
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
const char * WM_context_member_from_ptr(bContext *C, const PointerRNA *ptr)
Definition: wm_operators.c:554