revert part of Tons commit r33884.
- rather then use unlink="None", just don't pass unlink as a keyword. This is more pythonic. - added an RNA flag for properties which cant be unlinked by setting to None.
This commit is contained in:
@@ -43,9 +43,9 @@ class DATA_PT_context_arm(ArmatureButtonsPanel, bpy.types.Panel):
|
||||
space = context.space_data
|
||||
|
||||
if ob:
|
||||
layout.template_ID(ob, "data", unlink="None")
|
||||
layout.template_ID(ob, "data")
|
||||
elif arm:
|
||||
layout.template_ID(space, "pin_id", unlink="None")
|
||||
layout.template_ID(space, "pin_id")
|
||||
|
||||
|
||||
class DATA_PT_skeleton(ArmatureButtonsPanel, bpy.types.Panel):
|
||||
|
||||
@@ -60,9 +60,9 @@ class DATA_PT_context_curve(CurveButtonsPanel, bpy.types.Panel):
|
||||
space = context.space_data
|
||||
|
||||
if ob:
|
||||
layout.template_ID(ob, "data", unlink="None")
|
||||
layout.template_ID(ob, "data")
|
||||
elif curve:
|
||||
layout.template_ID(space, "pin_id", unlink="None") # XXX: broken
|
||||
layout.template_ID(space, "pin_id") # XXX: broken
|
||||
|
||||
|
||||
class DATA_PT_shape_curve(CurveButtonsPanel, bpy.types.Panel):
|
||||
|
||||
@@ -71,9 +71,9 @@ class DATA_PT_context_mesh(MeshButtonsPanel, bpy.types.Panel):
|
||||
space = context.space_data
|
||||
|
||||
if ob:
|
||||
layout.template_ID(ob, "data", unlink="None")
|
||||
layout.template_ID(ob, "data")
|
||||
elif mesh:
|
||||
layout.template_ID(space, "pin_id", unlink="None")
|
||||
layout.template_ID(space, "pin_id")
|
||||
|
||||
|
||||
class DATA_PT_normals(MeshButtonsPanel, bpy.types.Panel):
|
||||
|
||||
@@ -43,9 +43,9 @@ class DATA_PT_context_metaball(DataButtonsPanel, bpy.types.Panel):
|
||||
space = context.space_data
|
||||
|
||||
if ob:
|
||||
layout.template_ID(ob, "data", unlink="None")
|
||||
layout.template_ID(ob, "data")
|
||||
elif mball:
|
||||
layout.template_ID(space, "pin_id", unlink="None")
|
||||
layout.template_ID(space, "pin_id")
|
||||
|
||||
|
||||
class DATA_PT_metaball(DataButtonsPanel, bpy.types.Panel):
|
||||
|
||||
@@ -37,7 +37,7 @@ class OBJECT_PT_context_object(ObjectButtonsPanel, bpy.types.Panel):
|
||||
ob = context.object
|
||||
|
||||
if space.use_pin_id:
|
||||
layout.template_ID(space, "pin_id", unlink="None")
|
||||
layout.template_ID(space, "pin_id")
|
||||
else:
|
||||
row = layout.row()
|
||||
row.label(text="", icon='OBJECT_DATA')
|
||||
|
||||
@@ -212,7 +212,7 @@ short ANIM_add_driver (ReportList *reports, ID *id, const char rna_path[], int a
|
||||
/* Main Driver Management API calls:
|
||||
* Remove the driver for the specified property on the given ID block (if available)
|
||||
*/
|
||||
short ANIM_remove_driver (ReportList *reports, ID *id, const char rna_path[], int array_index, short UNUSED(flag))
|
||||
short ANIM_remove_driver (ReportList *UNUSED(reports), ID *id, const char rna_path[], int array_index, short UNUSED(flag))
|
||||
{
|
||||
AnimData *adt;
|
||||
FCurve *fcu;
|
||||
|
||||
@@ -450,7 +450,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
|
||||
}
|
||||
|
||||
/* delete button */
|
||||
if(id && (flag & UI_ID_DELETE)) {
|
||||
if(id && (flag & UI_ID_DELETE) && (RNA_property_flag(template->prop) & PROP_NEVER_UNLINK)==0) {
|
||||
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 */
|
||||
@@ -494,8 +494,6 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const
|
||||
flag |= UI_ID_ADD_NEW;
|
||||
if(openop)
|
||||
flag |= UI_ID_OPEN;
|
||||
if(unlinkop && strcmp(unlinkop, "None") == 0)
|
||||
flag &= ~UI_ID_DELETE;
|
||||
|
||||
type= RNA_property_pointer_type(ptr, prop);
|
||||
template->idlb= which_libbase(CTX_data_main(C), RNA_type_to_ID_code(type));
|
||||
|
||||
@@ -167,6 +167,10 @@ typedef enum PropertyFlag {
|
||||
* only apply this to types that are derived from an ID ()*/
|
||||
PROP_ID_SELF_CHECK = 1<<20,
|
||||
PROP_NEVER_NULL = 1<<18,
|
||||
/* currently only used for UI, this is similar to PROP_NEVER_NULL
|
||||
* except that the value may be NULL at times, used for ObData, where an Empty's will be NULL
|
||||
* but setting NULL on a mesh object is not possible. So, if its not NULL, setting NULL cant be done! */
|
||||
PROP_NEVER_UNLINK = 1<<25,
|
||||
|
||||
/* flag contains multiple enums.
|
||||
* note: not to be confused with prop->enumbitflags
|
||||
|
||||
@@ -1680,7 +1680,7 @@ static void rna_def_object(BlenderRNA *brna)
|
||||
RNA_def_property_struct_type(prop, "ID");
|
||||
RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_data_set", "rna_Object_data_typef", NULL);
|
||||
RNA_def_property_editable_func(prop, "rna_Object_data_editable");
|
||||
RNA_def_property_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK);
|
||||
RNA_def_property_ui_text(prop, "Data", "Object data");
|
||||
RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user