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 /source/blender/windowmanager | |
parent | e388cd8bb4b5dd309de0e603e529ee99348e3b19 (diff) |
Fix status bar and keymap editor showing Call Menu instead of menu name
Diffstat (limited to 'source/blender/windowmanager')
-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 |
6 files changed, 40 insertions, 4 deletions
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; |