Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-05-03 01:27:19 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-05-03 01:27:19 +0400
commit91ba6c9ced2a95105fab8616ba6c41a55e1b4b1f (patch)
tree70b601cbb79092079c4376ebdb211d0d114e8655
parentfe208a895a39c398e114779ca4c8c2a01adf676d (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.c6
-rw-r--r--source/blender/editors/interface/interface_templates.c4
-rw-r--r--source/blender/makesrna/RNA_access.h1
-rw-r--r--source/blender/makesrna/intern/rna_access.c12
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 */