diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-06-04 16:50:15 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-06-04 19:26:02 +0300 |
commit | 0dbbc5aac7125475b0c0b2523892e7d3bae34b05 (patch) | |
tree | eb76897c88b1f5830c17f25abf13093e3cc693b1 | |
parent | e388cd8bb4b5dd309de0e603e529ee99348e3b19 (diff) |
Fix status bar and keymap editor showing Call Menu instead of menu name
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_region_hud.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 4 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_panels.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_tools.c | 2 | ||||
-rw-r--r-- | source/blender/editors/undo/ed_undo.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_dragdrop.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operator_type.c | 10 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 23 |
17 files changed, 57 insertions, 21 deletions
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 2dc17c5c397..89d85388981 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1956,7 +1956,7 @@ static int insert_key_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UN uiLayout *layout; /* call the menu, which will call this operator again, hence the canceled */ - pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); + pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE); layout = UI_popup_menu_layout(pup); uiItemsEnumO(layout, "ANIM_OT_keyframe_insert_menu", "type"); UI_popup_menu_end(C, pup); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 931a4faa1c0..2154ac4a7f6 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -4241,7 +4241,7 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, if (!str) { if (ot && ot->srna) { - str = RNA_struct_ui_name(ot->srna); + str = WM_operatortype_name(ot, NULL); } else { str = ""; @@ -6392,7 +6392,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) } else if (but->optype) { if (type == BUT_GET_RNA_LABEL) { - tmp = BLI_strdup(RNA_struct_ui_name(but->optype->srna)); + tmp = BLI_strdup(WM_operatortype_name(but->optype, NULL)); } else { const char *t = RNA_struct_ui_description(but->optype->srna); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index b89767171ab..d4d7af3a374 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1143,7 +1143,7 @@ static uiBut *uiItemFullO_ptr_ex(uiLayout *layout, if (!name) { if (ot && ot->srna && (flag & UI_ITEM_R_ICON_ONLY) == 0) { - name = RNA_struct_ui_name(ot->srna); + name = WM_operatortype_name(ot, NULL); } else { name = ""; @@ -3126,7 +3126,7 @@ void uiItemMenuEnumO_ptr(uiLayout *layout, BLI_assert(ot->srna != NULL); if (name == NULL) { - name = RNA_struct_ui_name(ot->srna); + name = WM_operatortype_name(ot, NULL); } if (layout->root->type == UI_LAYOUT_MENU && !icon) { diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c index 362a1c8a22c..6d1b2baeff9 100644 --- a/source/blender/editors/interface/interface_region_hud.c +++ b/source/blender/editors/interface/interface_region_hud.c @@ -92,7 +92,7 @@ static bool hud_panel_operator_redo_poll(const bContext *C, PanelType *UNUSED(pt static void hud_panel_operator_redo_draw_header(const bContext *C, Panel *pa) { wmOperator *op = WM_operator_last_redo(C); - BLI_strncpy(pa->drawname, RNA_struct_ui_name(op->type->srna), sizeof(pa->drawname)); + BLI_strncpy(pa->drawname, WM_operatortype_name(op->type, op->ptr), sizeof(pa->drawname)); } static void hud_panel_operator_redo_draw(const bContext *C, Panel *pa) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index b1d404e8ab4..5d25c778de1 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2355,7 +2355,7 @@ void uiTemplateOperatorRedoProperties(uiLayout *layout, const bContext *C) /* Repeat button with operator name as text. */ uiItemFullO(layout, "SCREEN_OT_repeat_last", - RNA_struct_ui_name(op->type->srna), + WM_operatortype_name(op->type, op->ptr), ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, @@ -5916,7 +5916,7 @@ eAutoPropButsReturn uiTemplateOperatorPropertyButs(const bContext *C, } if (flag & UI_TEMPLATE_OP_PROPS_SHOW_TITLE) { - uiItemL(layout, RNA_struct_ui_name(op->type->srna), ICON_NONE); + uiItemL(layout, WM_operatortype_name(op->type, op->ptr), ICON_NONE); } /* menu */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 773f596ec79..7c03ba889a7 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3457,7 +3457,7 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent return OPERATOR_CANCELLED; } - pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); + pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE); layout = UI_popup_menu_layout(pup); uiItemFullO( @@ -3596,13 +3596,13 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNU return OPERATOR_CANCELLED; } - pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); + pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE); layout = UI_popup_menu_layout(pup); for (i = items - 1, lastop = wm->operators.last; lastop; lastop = lastop->prev, i--) { if ((lastop->type->flag & OPTYPE_REGISTER) && WM_operator_repeat_check(C, lastop)) { uiItemIntO( - layout, RNA_struct_ui_name(lastop->type->srna), ICON_NONE, op->type->idname, "index", i); + layout, WM_operatortype_name(lastop->type, lastop->ptr), ICON_NONE, op->type->idname, "index", i); } } diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index 023dff704c7..d9a6e70121f 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -62,7 +62,7 @@ static void file_panel_operator_header(const bContext *C, Panel *pa) SpaceFile *sfile = CTX_wm_space_file(C); wmOperator *op = sfile->op; - BLI_strncpy(pa->drawname, RNA_struct_ui_name(op->type->srna), sizeof(pa->drawname)); + BLI_strncpy(pa->drawname, WM_operatortype_name(op->type, op->ptr), sizeof(pa->drawname)); } static void file_panel_operator(const bContext *C, Panel *pa) diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index e5f19f0164d..c82e140e1fe 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -112,7 +112,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) const bool is_directory = (RNA_struct_find_property(op->ptr, "directory") != NULL); const bool is_relative_path = (RNA_struct_find_property(op->ptr, "relative_path") != NULL); - BLI_strncpy_utf8(params->title, RNA_struct_ui_name(op->type->srna), sizeof(params->title)); + BLI_strncpy_utf8(params->title, WM_operatortype_name(op->type, op->ptr), sizeof(params->title)); if ((prop = RNA_struct_find_property(op->ptr, "filemode"))) { params->type = RNA_property_int_get(op->ptr, prop); diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 0f9efb0d2e1..7e5638e48ea 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -2144,7 +2144,7 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot) static int outliner_operator_menu(bContext *C, const char *opname) { wmOperatorType *ot = WM_operatortype_find(opname, false); - uiPopupMenu *pup = UI_popup_menu_begin(C, RNA_struct_ui_name(ot->srna), ICON_NONE); + uiPopupMenu *pup = UI_popup_menu_begin(C, WM_operatortype_name(ot, NULL), ICON_NONE); uiLayout *layout = UI_popup_menu_layout(pup); /* set this so the default execution context is the same as submenus */ diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index ccbe12b4a93..734cdc424d9 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -591,7 +591,7 @@ static int undo_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE const EnumPropertyItem *item = rna_undo_itemf(C, &totitem); if (totitem > 0) { - uiPopupMenu *pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); + uiPopupMenu *pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE); uiLayout *layout = UI_popup_menu_layout(pup); uiLayout *split = uiLayoutSplit(layout, 0.0f, false); uiLayout *column = NULL; diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 3c707142951..72c23f29b31 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -1203,14 +1203,14 @@ static void rna_wmKeyMapItem_name_get(PointerRNA *ptr, char *value) { wmKeyMapItem *kmi = ptr->data; wmOperatorType *ot = WM_operatortype_find(kmi->idname, 1); - strcpy(value, ot ? RNA_struct_ui_name(ot->srna) : kmi->idname); + strcpy(value, ot ? WM_operatortype_name(ot, kmi->ptr) : kmi->idname); } static int rna_wmKeyMapItem_name_length(PointerRNA *ptr) { wmKeyMapItem *kmi = ptr->data; wmOperatorType *ot = WM_operatortype_find(kmi->idname, 1); - return strlen(ot ? RNA_struct_ui_name(ot->srna) : kmi->idname); + return strlen(ot ? WM_operatortype_name(ot, kmi->ptr) : kmi->idname); } static bool rna_KeyMapItem_userdefined_get(PointerRNA *ptr) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 558eb97c54b..dfea0cf25fa 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -537,6 +537,8 @@ struct wmOperatorType *WM_operatortype_append_macro(const char *idname, struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname); +const char *WM_operatortype_name(struct wmOperatorType *ot, struct PointerRNA *properties); + /* wm_uilist_type.c */ void WM_uilisttype_init(void); struct uiListType *WM_uilisttype_find(const char *idname, bool quiet); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 20bb5935c8e..c725b9f51c9 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -648,6 +648,10 @@ typedef struct wmOperatorType { /* optional panel for redo and repeat, autogenerated if not set */ void (*ui)(struct bContext *, struct wmOperator *); + /* Return a different name to use in the user interface, based on property values. + * The returned string does not need to be freed. */ + const char *(*get_name)(struct wmOperatorType *, struct PointerRNA *); + /* rna for properties */ struct StructRNA *srna; diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index e4ecf7e6e94..6b3bd1ea24e 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -208,7 +208,7 @@ static const char *dropbox_active(bContext *C, if (drop->poll(C, drag, event, &tooltip)) { /* XXX Doing translation here might not be ideal, but later we have no more * access to ot (and hence op context)... */ - return (tooltip) ? tooltip : RNA_struct_ui_name(drop->ot->srna); + return (tooltip) ? tooltip : WM_operatortype_name(drop->ot, drop->ptr); } } } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 987c71398ee..f688f520572 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -5099,7 +5099,8 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) } if (kmi) { wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); - STRNCPY(cd->text[button_index][type_index], ot ? ot->name : kmi->idname); + const char *name = (ot) ? WM_operatortype_name(ot, kmi->ptr) : kmi->idname; + STRNCPY(cd->text[button_index][type_index], name); } } diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c index 69f09162c74..1cec9848104 100644 --- a/source/blender/windowmanager/intern/wm_operator_type.c +++ b/source/blender/windowmanager/intern/wm_operator_type.c @@ -584,4 +584,14 @@ static void wm_operatortype_free_macro(wmOperatorType *ot) BLI_freelistN(&ot->macro); } +const char *WM_operatortype_name(struct wmOperatorType *ot, struct PointerRNA *properties) +{ + if (ot->get_name && properties) { + return ot->get_name(ot, properties); + } + else { + return RNA_struct_ui_name(ot->srna); + } +} + /** \} */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 4a99c2de6e7..31205ab11f4 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -753,7 +753,7 @@ int WM_menu_invoke_ex(bContext *C, wmOperator *op, int opcontext) return retval; } else { - pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); + pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE); layout = UI_popup_menu_layout(pup); /* set this so the default execution context is the same as submenus */ uiLayoutSetOperatorContext(layout, opcontext); @@ -805,7 +805,7 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg) uiDefBut(block, UI_BTYPE_LABEL, 0, - RNA_struct_ui_name(op->type->srna), + WM_operatortype_name(op->type, op->ptr), 10, 10, UI_searchbox_size_x(), @@ -1843,6 +1843,14 @@ static int wm_call_menu_exec(bContext *C, wmOperator *op) return UI_popup_menu_invoke(C, idname, op->reports); } +static const char *wm_call_menu_get_name(wmOperatorType *ot, PointerRNA *ptr) +{ + char idname[BKE_ST_MAXNAME]; + RNA_string_get(ptr, "name", idname); + MenuType *mt = WM_menutype_find(idname, true); + return (mt) ? mt->label : ot->name; +} + static void WM_OT_call_menu(wmOperatorType *ot) { ot->name = "Call Menu"; @@ -1851,6 +1859,7 @@ static void WM_OT_call_menu(wmOperatorType *ot) ot->exec = wm_call_menu_exec; ot->poll = WM_operator_winactive; + ot->get_name = wm_call_menu_get_name; ot->flag = OPTYPE_INTERNAL; @@ -1882,6 +1891,7 @@ static void WM_OT_call_menu_pie(wmOperatorType *ot) ot->invoke = wm_call_pie_menu_invoke; ot->exec = wm_call_pie_menu_exec; ot->poll = WM_operator_winactive; + ot->get_name = wm_call_menu_get_name; ot->flag = OPTYPE_INTERNAL; @@ -1897,6 +1907,14 @@ static int wm_call_panel_exec(bContext *C, wmOperator *op) return UI_popover_panel_invoke(C, idname, keep_open, op->reports); } +static const char *wm_call_panel_get_name(wmOperatorType *ot, PointerRNA *ptr) +{ + char idname[BKE_ST_MAXNAME]; + RNA_string_get(ptr, "name", idname); + PanelType *pt = WM_paneltype_find(idname, true); + return (pt) ? pt->label : ot->name; +} + static void WM_OT_call_panel(wmOperatorType *ot) { ot->name = "Call Panel"; @@ -1905,6 +1923,7 @@ static void WM_OT_call_panel(wmOperatorType *ot) ot->exec = wm_call_panel_exec; ot->poll = WM_operator_winactive; + ot->get_name = wm_call_panel_get_name; ot->flag = OPTYPE_INTERNAL; |