diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-05-03 01:27:19 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-05-03 01:27:19 +0400 |
commit | 91ba6c9ced2a95105fab8616ba6c41a55e1b4b1f (patch) | |
tree | 70b601cbb79092079c4376ebdb211d0d114e8655 | |
parent | fe208a895a39c398e114779ca4c8c2a01adf676d (diff) |
adjustment to own commit r56463.
when strings use 'PROP_NEVER_NULL' we still want them to show an unlink button.
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 6 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 12 |
4 files changed, 15 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index f781da1b810..c66ca75412f 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1411,11 +1411,7 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN /* turn button into search button */ if (searchprop) { - if (RNA_property_flag(prop) & (PROP_NEVER_UNLINK | PROP_NEVER_NULL)) - but->type = SEARCH_MENU; - else - but->type = SEARCH_MENU_UNLINK; - + but->type = RNA_property_is_unlink(prop) ? SEARCH_MENU_UNLINK : SEARCH_MENU; but->hardmax = MAX2(but->hardmax, 256.0f); but->rnasearchpoin = *searchptr; but->rnasearchprop = searchprop; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index eae06bbf5fc..84f30ecca76 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -577,9 +577,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str } /* delete button */ - if (id && (flag & UI_ID_DELETE) && - (RNA_property_flag(template->prop) & (PROP_NEVER_UNLINK | PROP_NEVER_NULL)) == 0) - { + if (id && (flag & UI_ID_DELETE) && RNA_property_is_unlink(template->prop)) { if (unlinkop) { but = uiDefIconButO(block, BUT, unlinkop, WM_OP_INVOKE_REGION_WIN, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); /* so we can access the template from operators, font unlinking needs this */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index a61a9b3da85..816a5b0bdc3 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -1026,6 +1026,7 @@ void RNA_property_unset(PointerRNA *ptr, PropertyRNA *prop); bool RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, bool use_ghost); bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier); bool RNA_property_is_idprop(PropertyRNA *prop); +bool RNA_property_is_unlink(PropertyRNA *prop); void RNA_struct_property_unset(PointerRNA *ptr, const char *identifier); /* python compatible string representation of this property, (must be freed!) */ diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 7a0a91cc6e3..a7e81416b80 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -4924,6 +4924,18 @@ bool RNA_property_is_idprop(PropertyRNA *prop) return (prop->magic != RNA_MAGIC); } +/* mainly for the UI */ +bool RNA_property_is_unlink(PropertyRNA *prop) +{ + const int flag = RNA_property_flag(prop); + if (RNA_property_type(prop) == PROP_STRING) { + return (flag & PROP_NEVER_UNLINK) == 0; + } + else { + return (flag & (PROP_NEVER_UNLINK | PROP_NEVER_NULL)) == 0; + } +} + /* string representation of a property, python * compatible but can be used for display too, * context may be NULL */ |