diff options
Diffstat (limited to 'source/blender/editors/interface/interface_layout.c')
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index edd568e4fea..922b5779c9f 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -370,7 +370,7 @@ static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index) uiBut *but = arg_but, *cbut; PointerRNA *ptr = &but->rnapoin; PropertyRNA *prop = but->rnaprop; - int i, index = GET_INT_FROM_POINTER(arg_index); + int i, index = POINTER_AS_INT(arg_index); int shift = win->eventstate->shift; int len = RNA_property_array_length(ptr, prop); @@ -463,7 +463,7 @@ static void ui_item_array( but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, butw, buth); if (subtype == PROP_LAYER_MEMBER) - UI_but_func_set(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num)); + UI_but_func_set(but, ui_layer_but_cb, but, POINTER_FROM_INT(layer_num)); } for (a = 0; a < colbuts; a++) { const int layer_num = a + len / 2 + b * colbuts; @@ -481,7 +481,7 @@ static void ui_item_array( but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, buth); if (subtype == PROP_LAYER_MEMBER) - UI_but_func_set(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num)); + UI_but_func_set(but, ui_layer_but_cb, but, POINTER_FROM_INT(layer_num)); } UI_block_align_end(block); @@ -567,7 +567,7 @@ static void ui_item_enum_expand_handle(bContext *C, void *arg1, void *arg2) if (!win->eventstate->shift) { uiBut *but = (uiBut *)arg1; - int enum_value = GET_INT_FROM_POINTER(arg2); + int enum_value = POINTER_AS_INT(arg2); int current_value = RNA_property_enum_get(&but->rnapoin, but->rnaprop); if (!(current_value & enum_value)) { @@ -645,7 +645,7 @@ static void ui_item_enum_expand( but = uiDefButR_prop(block, UI_BTYPE_ROW, 0, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); if (RNA_property_flag(prop) & PROP_ENUM_FLAG) { - UI_but_func_set(but, ui_item_enum_expand_handle, but, SET_INT_IN_POINTER(value)); + UI_but_func_set(but, ui_item_enum_expand_handle, but, POINTER_FROM_INT(value)); } if (ui_layout_local_dir(layout) != UI_LAYOUT_HORIZONTAL) @@ -1099,7 +1099,7 @@ void uiItemsFullEnumO_items( uiItemS(target); } else { - /* XXX bug here, colums draw bottom item badly */ + /* XXX bug here, columns draw bottom item badly */ uiItemS(target); } } @@ -1741,7 +1741,7 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s /* add search items from temporary list */ for (cis = items_list->first; cis; cis = cis->next) { - if (false == UI_search_item_add(items, cis->name, SET_INT_IN_POINTER(cis->index), cis->iconid)) { + if (false == UI_search_item_add(items, cis->name, POINTER_FROM_INT(cis->index), cis->iconid)) { break; } } @@ -1941,8 +1941,11 @@ static uiBut *ui_item_menu( else but = uiDefMenuBut(block, func, arg, name, 0, 0, w, h, tip); - if (argN) { /* ugly .. */ - but->poin = (char *)but; + if (argN) { + /* ugly .. */ + if (arg != argN) { + but->poin = (char *)but; + } but->func_argN = argN; } @@ -1976,7 +1979,9 @@ void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon) if (layout->root->type == UI_LAYOUT_MENU && !icon) icon = ICON_BLANK1; - ui_item_menu(layout, name, icon, ui_item_menutype_func, mt, NULL, TIP_(mt->description), false); + ui_item_menu( + layout, name, icon, ui_item_menutype_func, mt, NULL, + mt->description ? TIP_(mt->description) : "", false); } /* label item */ @@ -2078,6 +2083,18 @@ void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc ui_item_menu(layout, name, icon, func, arg, NULL, "", false); } +/** + * Version of #uiItemMenuF that free's `argN`. + */ +void uiItemMenuFN(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *argN) +{ + if (!func) + return; + + /* Second 'argN' only ensures it gets freed. */ + ui_item_menu(layout, name, icon, func, argN, argN, "", false); +} + typedef struct MenuItemLevel { int opcontext; /* don't use pointers to the strings because python can dynamically |