diff options
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 48 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_animation.c | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_curve.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_fcurve.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_gpencil.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal_types.h | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_lattice.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_material.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_meta.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_nla.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_pose.c | 9 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sequencer.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_vfont.c | 2 |
18 files changed, 72 insertions, 26 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 2893fabd145..44d1a6bfaaf 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -856,6 +856,7 @@ StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop); int RNA_property_pointer_poll(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *value); bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop); +bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char **r_info); bool RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index); bool RNA_property_editable_flag(PointerRNA *ptr, PropertyRNA *prop); /* without lib check, only checks the flag */ bool RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop); diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 7e6bdf970f6..280ad4aa9b1 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -122,7 +122,7 @@ void rna_ID_name_set(PointerRNA *ptr, const char *value) BLI_libblock_ensure_unique_name(G.main, id->name); } -static int rna_ID_name_editable(PointerRNA *ptr) +static int rna_ID_name_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { ID *id = (ID *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 6879a0534e9..6f054e586ec 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1619,20 +1619,56 @@ bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop) { ID *id = ptr->id.data; int flag; + const char *dummy_info; prop = rna_ensure_property(prop); - flag = prop->editable ? prop->editable(ptr) : prop->flag; + flag = prop->editable ? prop->editable(ptr, &dummy_info) : prop->flag; + return ((flag & PROP_EDITABLE) && (flag & PROP_REGISTER) == 0 && (!id || !ID_IS_LINKED_DATABLOCK(id) || (prop->flag & PROP_LIB_EXCEPTION))); } +/** + * Version of #RNA_property_editable that tries to return additional info in \a r_info that can be exposed in UI. + */ +bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char **r_info) +{ + ID *id = ptr->id.data; + int flag; + + prop = rna_ensure_property(prop); + *r_info = ""; + + /* get flag */ + if (prop->editable) { + flag = prop->editable(ptr, r_info); + } + else { + flag = prop->flag; + if ((flag & PROP_EDITABLE) == 0 || (flag & PROP_REGISTER)) { + *r_info = "This property is for internal use only and can't be edited."; + } + } + + /* property from linked data-block */ + if (id && ID_IS_LINKED_DATABLOCK(id) && (prop->flag & PROP_LIB_EXCEPTION) == 0) { + if (!(*r_info)[0]) { + *r_info = "Can't edit this property from a linked data-block."; + } + return false; + } + + return ((flag & PROP_EDITABLE) && (flag & PROP_REGISTER) == 0); +} + bool RNA_property_editable_flag(PointerRNA *ptr, PropertyRNA *prop) { int flag; + const char *dummy_info; prop = rna_ensure_property(prop); - flag = prop->editable ? prop->editable(ptr) : prop->flag; + flag = prop->editable ? prop->editable(ptr, &dummy_info) : prop->flag; return (flag & PROP_EDITABLE) != 0; } @@ -1647,9 +1683,11 @@ bool RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index) prop = rna_ensure_property(prop); flag = prop->flag; - - if (prop->editable) - flag &= prop->editable(ptr); + + if (prop->editable) { + const char *dummy_info; + flag &= prop->editable(ptr, &dummy_info); + } if (prop->itemeditable) flag &= prop->itemeditable(ptr, index); diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index e37affcf5a3..cdbf7582fa7 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -89,7 +89,7 @@ static void rna_AnimData_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Point DAG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA); } -static int rna_AnimData_action_editable(PointerRNA *ptr) +static int rna_AnimData_action_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { AnimData *adt = (AnimData *)ptr->data; @@ -305,7 +305,7 @@ static StructRNA *rna_ksPath_id_typef(PointerRNA *ptr) return ID_code_to_RNA_type(ksp->idtype); } -static int rna_ksPath_id_editable(PointerRNA *ptr) +static int rna_ksPath_id_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { KS_Path *ksp = (KS_Path *)ptr->data; return (ksp->idtype) ? PROP_EDITABLE : 0; @@ -393,7 +393,7 @@ static void rna_KeyingSet_name_set(PointerRNA *ptr, const char *value) } -static int rna_KeyingSet_active_ksPath_editable(PointerRNA *ptr) +static int rna_KeyingSet_active_ksPath_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { KeyingSet *ks = (KeyingSet *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index f4fb30e0793..22e45964742 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -221,7 +221,7 @@ static void rna_Curve_texspace_set(Main *UNUSED(bmain), Scene *UNUSED(scene), Po BKE_curve_texspace_calc(cu); } -static int rna_Curve_texspace_editable(PointerRNA *ptr) +static int rna_Curve_texspace_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { Curve *cu = (Curve *)ptr->data; return (cu->texflag & CU_AUTOSPACE) ? 0 : PROP_EDITABLE; diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index c521e93d33e..1d3b65bb7ba 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -199,13 +199,13 @@ static StructRNA *rna_DriverTarget_id_typef(PointerRNA *ptr) return ID_code_to_RNA_type(dtar->idtype); } -static int rna_DriverTarget_id_editable(PointerRNA *ptr) +static int rna_DriverTarget_id_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { DriverTarget *dtar = (DriverTarget *)ptr->data; return (dtar->idtype) ? PROP_EDITABLE : 0; } -static int rna_DriverTarget_id_type_editable(PointerRNA *ptr) +static int rna_DriverTarget_id_type_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { DriverTarget *dtar = (DriverTarget *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 7eaf8b65902..9b881c13347 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -120,7 +120,7 @@ static char *rna_GPencilLayer_path(PointerRNA *ptr) return BLI_sprintfN("layers[\"%s\"]", name_esc); } -static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr) +static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { bGPDlayer *gpl = (bGPDlayer *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index ba0705b5caa..04b85b8997e 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -62,7 +62,7 @@ struct Scene; typedef void (*UpdateFunc)(struct Main *main, struct Scene *scene, struct PointerRNA *ptr); typedef void (*ContextPropUpdateFunc)(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop); typedef void (*ContextUpdateFunc)(struct bContext *C, struct PointerRNA *ptr); -typedef int (*EditableFunc)(struct PointerRNA *ptr); +typedef int (*EditableFunc)(struct PointerRNA *ptr, const char **r_info); typedef int (*ItemEditableFunc)(struct PointerRNA *ptr, int index); typedef struct IDProperty *(*IDPropertiesFunc)(struct PointerRNA *ptr, bool create); typedef struct StructRNA *(*StructRefineFunc)(struct PointerRNA *ptr); @@ -188,7 +188,9 @@ struct PropertyRNA { UpdateFunc update; int noteflag; - /* callback for testing if editable */ + /* Callback for testing if editable. Its r_info parameter can be used to + * return info on editable state that might be shown to user. E.g. tooltips + * of disabled buttons can show reason why button is disabled using this. */ EditableFunc editable; /* callback for testing if array-item editable (if applicable) */ ItemEditableFunc itemeditable; diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index 6bc9cc38a7d..9424ddf7d0e 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -171,7 +171,7 @@ static void rna_Lattice_use_outside_set(PointerRNA *ptr, int value) } } -static int rna_Lattice_size_editable(PointerRNA *ptr) +static int rna_Lattice_size_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { Lattice *lt = (Lattice *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 2a8cc073e22..752f406264a 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -233,7 +233,7 @@ static void rna_Material_active_texture_set(PointerRNA *ptr, PointerRNA value) set_current_material_texture(ma, value.data); } -static int rna_Material_active_texture_editable(PointerRNA *ptr) +static int rna_Material_active_texture_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { Material *ma = (Material *)ptr->id.data; diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 1d734864833..df034ed85d8 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -662,7 +662,7 @@ static void rna_MeshLoopColor_color_set(PointerRNA *ptr, const float *values) (&mcol->r)[2] = (char)(CLAMPIS(values[2] * 255.0f, 0, 255)); } -static int rna_Mesh_texspace_editable(PointerRNA *ptr) +static int rna_Mesh_texspace_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { Mesh *me = (Mesh *)ptr->data; return (me->texflag & ME_AUTOSPACE) ? 0 : PROP_EDITABLE; diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index d3b66e4c3b4..9d13bc90e72 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -53,7 +53,7 @@ #include "WM_types.h" #include "WM_api.h" -static int rna_Meta_texspace_editable(PointerRNA *ptr) +static int rna_Meta_texspace_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { MetaBall *mb = (MetaBall *)ptr->data; return (mb->texflag & MB_AUTOSPACE) ? 0 : PROP_EDITABLE; diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index eb87eafe16c..55bc40f573c 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -282,7 +282,7 @@ static void rna_NlaStrip_use_auto_blend_set(PointerRNA *ptr, int value) } } -static int rna_NlaStrip_action_editable(PointerRNA *ptr) +static int rna_NlaStrip_action_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { NlaStrip *strip = (NlaStrip *)ptr->data; diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 2cbf23973c2..0e735350e05 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -712,7 +712,7 @@ static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value) assign_material(ob, value.data, ob->actcol, BKE_MAT_ASSIGN_EXISTING); } -static int rna_Object_active_material_editable(PointerRNA *ptr) +static int rna_Object_active_material_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { Object *ob = (Object *)ptr->id.data; bool is_editable; diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 1f34d8f23d4..0591e877634 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -556,13 +556,18 @@ static void rna_PoseChannel_constraints_remove(ID *id, bPoseChannel *pchan, Repo } } -static int rna_PoseChannel_proxy_editable(PointerRNA *ptr) +static int rna_PoseChannel_proxy_editable(PointerRNA *ptr, const char **r_info) { Object *ob = (Object *)ptr->id.data; bArmature *arm = ob->data; bPoseChannel *pchan = (bPoseChannel *)ptr->data; - return (ob->proxy && pchan->bone && (pchan->bone->layer & arm->layer_protected)) ? 0 : PROP_EDITABLE; + if (ob->proxy && pchan->bone && (pchan->bone->layer & arm->layer_protected)) { + *r_info = "Can't edit property of a proxy on a protected layer"; + return 0; + } + + return PROP_EDITABLE; } static int rna_PoseChannel_location_editable(PointerRNA *ptr, int index) diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index c3a66058888..bb9c2a6c2fd 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -292,7 +292,7 @@ static int rna_Sequence_frame_length_get(PointerRNA *ptr) return BKE_sequence_tx_get_final_right(seq, false) - BKE_sequence_tx_get_final_left(seq, false); } -static int rna_Sequence_frame_editable(PointerRNA *ptr) +static int rna_Sequence_frame_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { Sequence *seq = (Sequence *)ptr->data; /* Effect sequences' start frame and length must be readonly! */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index a7dab0f56f8..375d370097e 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1645,7 +1645,7 @@ static void rna_FileBrowser_FSMenuEntry_name_set(PointerRNA *ptr, const char *va ED_fsmenu_entry_set_name(fsm, value); } -static int rna_FileBrowser_FSMenuEntry_name_get_editable(PointerRNA *ptr) +static int rna_FileBrowser_FSMenuEntry_name_get_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { FSMenuEntry *fsm = ptr->data; diff --git a/source/blender/makesrna/intern/rna_vfont.c b/source/blender/makesrna/intern/rna_vfont.c index e9ba0c78439..c743751649c 100644 --- a/source/blender/makesrna/intern/rna_vfont.c +++ b/source/blender/makesrna/intern/rna_vfont.c @@ -44,7 +44,7 @@ #include "WM_api.h" /* matching fnction in rna_ID.c */ -static int rna_VectorFont_filepath_editable(PointerRNA *ptr) +static int rna_VectorFont_filepath_editable(PointerRNA *ptr, const char **UNUSED(r_info)) { VFont *vfont = ptr->id.data; if (BKE_vfont_is_builtin(vfont)) { |