diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-08-14 19:17:52 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-08-14 19:18:13 +0300 |
commit | 16c28b5a6784dfdc22535cef14961a9a95136a44 (patch) | |
tree | fb604f91d4a849a906810e7be696fd275f501359 /source/blender/editors/interface/interface_context_menu.c | |
parent | 9ac3964be198a9bcbbcf2cda2ecd99047eae560f (diff) |
UI: suppress Copy/Paste/Edit Driver options on whole array property fields.
When a button represents the whole array (e.g. color picker buttons),
these context menu options were available, but didn't really work
correctly. Since it's not clear how they could reasonably work without
a valid index, it's better to hide them.
Diffstat (limited to 'source/blender/editors/interface/interface_context_menu.c')
-rw-r--r-- | source/blender/editors/interface/interface_context_menu.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c index 88fe8704082..22b75da4968 100644 --- a/source/blender/editors/interface/interface_context_menu.c +++ b/source/blender/editors/interface/interface_context_menu.c @@ -523,6 +523,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but) /* determine if we can key a single component of an array */ const bool is_array = RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0; const bool is_array_component = (is_array && but->rnaindex != -1); + const bool is_whole_array = (is_array && but->rnaindex == -1); const int override_status = RNA_property_override_library_status(ptr, prop, -1); const bool is_overridable = (override_status & RNA_OVERRIDE_STATUS_OVERRIDABLE) != 0; @@ -658,21 +659,23 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but) 1); } - uiItemO(layout, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Driver"), - ICON_NONE, - "ANIM_OT_copy_driver_button"); - if (ANIM_driver_can_paste()) { + if (!is_whole_array) { uiItemO(layout, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"), + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Driver"), ICON_NONE, - "ANIM_OT_paste_driver_button"); - } + "ANIM_OT_copy_driver_button"); + if (ANIM_driver_can_paste()) { + uiItemO(layout, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"), + ICON_NONE, + "ANIM_OT_paste_driver_button"); + } - uiItemO(layout, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Edit Driver"), - ICON_DRIVER, - "ANIM_OT_driver_button_edit"); + uiItemO(layout, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Edit Driver"), + ICON_DRIVER, + "ANIM_OT_driver_button_edit"); + } uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"), @@ -690,11 +693,13 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but) ICON_DRIVER, "ANIM_OT_driver_button_add"); - if (ANIM_driver_can_paste()) { - uiItemO(layout, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"), - ICON_NONE, - "ANIM_OT_paste_driver_button"); + if (!is_whole_array) { + if (ANIM_driver_can_paste()) { + uiItemO(layout, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Paste Driver"), + ICON_NONE, + "ANIM_OT_paste_driver_button"); + } } uiItemO(layout, @@ -862,7 +867,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but) "UI_OT_unset_property_button"); } - if (is_idprop && !is_array_component && ELEM(type, PROP_INT, PROP_FLOAT)) { + if (is_idprop && !is_array && ELEM(type, PROP_INT, PROP_FLOAT)) { uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Assign Value as Default"), ICON_NONE, @@ -899,7 +904,8 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but) ICON_NONE, "UI_OT_copy_data_path_button"); - if (ptr->id.data && ELEM(type, PROP_BOOLEAN, PROP_INT, PROP_FLOAT, PROP_ENUM)) { + if (ptr->id.data && !is_whole_array && + ELEM(type, PROP_BOOLEAN, PROP_INT, PROP_FLOAT, PROP_ENUM)) { uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy As New Driver"), ICON_NONE, |