Commit: f4455faf4c15583a37f8ceb4913b844a03c06913
Author: Bastien Montagne
Date: Wed Jun 14 15:19:16 2017 +0200
Branches: id_override_static
https://developer.blender.org/rBf4455faf4c15583a37f8ceb4913b844a03c06913
Cleanup/expose template status in RNA utils API.
===================================================================
M source/blender/editors/interface/interface.c
M source/blender/editors/interface/interface_handlers.c
M source/blender/editors/interface/interface_ops.c
M source/blender/makesrna/RNA_access.h
M source/blender/makesrna/intern/rna_access.c
===================================================================
diff --git a/source/blender/editors/interface/interface.c
b/source/blender/editors/interface/interface.c
index bd7a589b24e..b5e288fe9a1 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1192,7 +1192,11 @@ static void ui_menu_block_set_keymaps(const bContext *C,
uiBlock *block)
void ui_but_override_flag(uiBut *but)
{
- if (RNA_property_overridden(&but->rnapoin, but->rnaprop,
but->rnaindex)) {
+ bool is_overridden;
+
+ RNA_property_override_status(&but->rnapoin, but->rnaprop,
but->rnaindex, NULL, &is_overridden, NULL, NULL);
+
+ if (is_overridden) {
but->flag |= UI_BUT_OVERRIDEN;
}
else {
diff --git a/source/blender/editors/interface/interface_handlers.c
b/source/blender/editors/interface/interface_handlers.c
index 4d4b0f19d7b..d6355c5fdd6 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -6788,10 +6788,12 @@ static bool ui_but_menu(bContext *C, uiBut *but)
const PropertySubType subtype = RNA_property_subtype(prop);
bool is_anim = RNA_property_animateable(ptr, prop);
bool is_editable = RNA_property_editable(ptr, prop);
- const bool is_overridable = RNA_property_overridable(ptr, prop);
+ bool is_overridable;
/*bool is_idprop = RNA_property_is_idprop(prop);*/ /* XXX does
not work as expected, not strictly needed */
bool is_set = RNA_property_is_set(ptr, prop);
+ RNA_property_override_status(ptr, prop, -1, &is_overridable,
NULL, NULL, NULL);
+
/* set the prop and pointer data for python access to the
hovered ui element; TODO, index could be supported as well*/
PointerRNA temp_ptr;
RNA_pointer_create(NULL, &RNA_Property, but->rnaprop,
&temp_ptr);
diff --git a/source/blender/editors/interface/interface_ops.c
b/source/blender/editors/interface/interface_ops.c
index e299db02a46..a389b7fb0cd 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -358,10 +358,13 @@ static int override_type_set_button_poll(bContext *C)
PointerRNA ptr;
PropertyRNA *prop;
int index;
+ bool is_overridable;
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
- return (ptr.data && prop && RNA_property_overridable(&ptr, prop));
+ RNA_property_override_status(&ptr, prop, index, &is_overridable, NULL,
NULL, NULL);
+
+ return (ptr.data && prop && is_overridable);
}
static int override_type_set_button_exec(bContext *C, wmOperator *op)
@@ -445,10 +448,13 @@ static int override_remove_button_poll(bContext *C)
PointerRNA ptr;
PropertyRNA *prop;
int index;
+ bool is_overridden;
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
- return (ptr.data && ptr.id.data && prop &&
RNA_property_overridden(&ptr, prop, index));
+ RNA_property_override_status(&ptr, prop, index, NULL, &is_overridden,
NULL, NULL);
+
+ return (ptr.data && ptr.id.data && prop && is_overridden);
}
static int override_remove_button_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/makesrna/RNA_access.h
b/source/blender/makesrna/RNA_access.h
index 1cc6c1ba26f..d2e5a5e8dbc 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -1248,8 +1248,9 @@ struct IDOverridePropertyOperation
*RNA_property_override_property_operation_get
PointerRNA *ptr, PropertyRNA *prop, const short operation, const int
index,
const bool strict, bool *r_strict, bool *r_created);
-bool RNA_property_overridable(PointerRNA *ptr, PropertyRNA *prop);
-bool RNA_property_overridden(PointerRNA *ptr, PropertyRNA *prop, const int
index);
+void RNA_property_override_status(
+ PointerRNA *ptr, PropertyRNA *prop, const int index,
+ bool *r_overridable, bool *r_overridden, bool *r_mandatory, bool
*r_locked);
#ifdef __cplusplus
}
diff --git a/source/blender/makesrna/intern/rna_access.c
b/source/blender/makesrna/intern/rna_access.c
index d8b3b03e72e..3bae51f11a6 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -8175,37 +8175,33 @@ IDOverridePropertyOperation
*RNA_property_override_property_operation_get(
return BKE_override_property_operation_get(op, operation, NULL, NULL,
index, index, strict, r_strict, r_created);
}
-bool RNA_property_overridable(PointerRNA *ptr, PropertyRNA *prop)
+void RNA_property_override_status(
+ PointerRNA *ptr, PropertyRNA *prop, const int index,
+ bool *r_overridable, bool *r_overridden, bool *r_mandatory, bool
*r_locked)
{
- if (!ptr || !prop || !ptr->id.data || !((ID *)ptr->id.data)->override) {
- return false;
- }
+#define SET_RET(_name, _val) if (_name != NULL) *_name = (_val)
- prop = rna_ensure_property(prop);
+ SET_RET(r_overridable, false);
+ SET_RET(r_overridden, false);
+ SET_RET(r_mandatory, false);
+ SET_RET(r_locked, false);
- if (!(prop->flag & PROP_OVERRIDABLE)) {
- return false;
+ if (!ptr || !prop || !ptr->id.data || !((ID *)ptr->id.data)->override) {
+ return;
}
- return (prop->flag & PROP_EDITABLE) != 0;
-}
+ SET_RET(r_overridable, (prop->flag & PROP_OVERRIDABLE) && (prop->flag &
PROP_EDITABLE));
-bool RNA_property_overridden(PointerRNA *ptr, PropertyRNA *prop, const int
index)
-{
- if (!ptr || !prop) {
- return false;
- }
-
- if (RNA_property_override_property_operation_find(ptr, prop, index,
false, NULL)) {
- return true;
+ if (r_overridden || r_mandatory || r_locked) {
+ IDOverridePropertyOperation *opop =
RNA_property_override_property_operation_find(ptr, prop, index, false, NULL);
+ SET_RET(r_overridden, opop != NULL);
+ SET_RET(r_mandatory, (opop->flag & IDOVERRIDE_FLAG_MANDATORY)
!= 0);
+ SET_RET(r_locked, (opop->flag & IDOVERRIDE_FLAG_LOCKED) != 0);
}
-
- return false;
}
-
bool RNA_path_resolved_create(
PointerRNA *ptr, struct PropertyRNA *prop,
const int prop_index,
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs