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