From 94444aaadf238ab2de4226d6b1b66284d479a931 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 31 May 2022 14:07:12 +1000 Subject: PyDoc: de-duplicate enums for rna_rna.c & bpy_props.c Lists of items for bpy.props were duplicated 3 times, now all enums are defined once in rna_rna.c and referenced from bpy.props doc-strings. --- source/blender/makesrna/RNA_enum_items.h | 8 ++ source/blender/makesrna/intern/rna_rna.c | 186 +++++++++++++++++++++++-------- 2 files changed, 147 insertions(+), 47 deletions(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/RNA_enum_items.h b/source/blender/makesrna/RNA_enum_items.h index e1b093e7add..8c42bbe2ee6 100644 --- a/source/blender/makesrna/RNA_enum_items.h +++ b/source/blender/makesrna/RNA_enum_items.h @@ -150,7 +150,15 @@ DEF_ENUM(rna_enum_wm_report_items) DEF_ENUM(rna_enum_property_type_items) DEF_ENUM(rna_enum_property_subtype_items) +DEF_ENUM(rna_enum_property_subtype_string_items) +DEF_ENUM(rna_enum_property_subtype_number_items) +DEF_ENUM(rna_enum_property_subtype_number_array_items) DEF_ENUM(rna_enum_property_unit_items) +DEF_ENUM(rna_enum_property_flag_items) +DEF_ENUM(rna_enum_property_flag_enum_items) +DEF_ENUM(rna_enum_property_override_flag_items) +DEF_ENUM(rna_enum_property_override_flag_collection_items) +DEF_ENUM(rna_enum_property_string_search_flag_items) DEF_ENUM(rna_enum_shading_type_items) diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index b23c8cbba41..72ad695cd03 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -50,56 +50,85 @@ const EnumPropertyItem rna_enum_property_type_items[] = { {0, NULL, 0, NULL, NULL}, }; -/* Keep in sync with RNA_types.h PropertySubType and bpy_props.c's property_subtype_xxx_items */ +/* Wraps multiple enums onto a single line in a way that is difficult to read. + * NOTE: these enums are split up based on their use in `bpy.props` Python module. */ + +/* clang-format off */ +#define RNA_ENUM_PROPERTY_SUBTYPE_STRING_ITEMS \ + {PROP_FILEPATH, "FILE_PATH", 0, "File Path", ""}, \ + {PROP_DIRPATH, "DIR_PATH", 0, "Directory Path", ""}, \ + {PROP_FILENAME, "FILE_NAME", 0, "File Name", ""}, \ + {PROP_BYTESTRING, "BYTE_STRING", 0, "Byte String", ""}, \ + {PROP_PASSWORD, "PASSWORD", 0, "Password", "A string that is displayed hidden ('********')"} + +#define RNA_ENUM_PROPERTY_SUBTYPE_NUMBER_ITEMS \ + {PROP_PIXEL, "PIXEL", 0, "Pixel", ""}, \ + {PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned", ""}, \ + {PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""}, \ + {PROP_FACTOR, "FACTOR", 0, "Factor", ""}, \ + {PROP_ANGLE, "ANGLE", 0, "Angle", ""}, \ + {PROP_TIME, "TIME", 0, "Time (Scene Relative)", \ + "Time specified in frames, converted to seconds based on scene frame rate"}, \ + {PROP_TIME_ABSOLUTE, "TIME_ABSOLUTE", 0, "Time (Absolute)", \ + "Time specified in seconds, independent of the scene"}, \ + {PROP_DISTANCE, "DISTANCE", 0, "Distance", ""}, \ + {PROP_DISTANCE_CAMERA, "DISTANCE_CAMERA", 0, "Camera Distance", ""}, \ + {PROP_POWER, "POWER", 0, "Power", ""}, \ + {PROP_TEMPERATURE, "TEMPERATURE", 0, "Temperature", ""} + +#define RNA_ENUM_PROPERTY_SUBTYPE_NUMBER_ARRAY_ITEMS \ + {PROP_COLOR, "COLOR", 0, "Color", ""}, \ + {PROP_TRANSLATION, "TRANSLATION", 0, "Translation", ""}, \ + {PROP_DIRECTION, "DIRECTION", 0, "Direction", ""}, \ + {PROP_VELOCITY, "VELOCITY", 0, "Velocity", ""}, \ + {PROP_ACCELERATION, "ACCELERATION", 0, "Acceleration", ""}, \ + {PROP_MATRIX, "MATRIX", 0, "Matrix", ""}, \ + {PROP_EULER, "EULER", 0, "Euler Angles", ""}, \ + {PROP_QUATERNION, "QUATERNION", 0, "Quaternion", ""}, \ + {PROP_AXISANGLE, "AXISANGLE", 0, "Axis-Angle", ""}, \ + {PROP_XYZ, "XYZ", 0, "XYZ", ""}, \ + {PROP_XYZ_LENGTH, "XYZ_LENGTH", 0, "XYZ Length", ""}, \ + {PROP_COLOR_GAMMA, "COLOR_GAMMA", 0, "Color", ""}, \ + {PROP_COORDS, "COORDS", 0, "Coordinates", ""}, \ + /* Boolean. */ \ + {PROP_LAYER, "LAYER", 0, "Layer", ""}, \ + {PROP_LAYER_MEMBER, "LAYER_MEMBER", 0, "Layer Member", ""} + +/* clang-format on */ + +const EnumPropertyItem rna_enum_property_subtype_string_items[] = { + RNA_ENUM_PROPERTY_SUBTYPE_STRING_ITEMS, + + {PROP_NONE, "NONE", 0, "None", ""}, + {0, NULL, 0, NULL, NULL}, +}; + +const EnumPropertyItem rna_enum_property_subtype_number_items[] = { + RNA_ENUM_PROPERTY_SUBTYPE_NUMBER_ITEMS, + + {PROP_NONE, "NONE", 0, "None", ""}, + {0, NULL, 0, NULL, NULL}, +}; + +const EnumPropertyItem rna_enum_property_subtype_number_array_items[] = { + RNA_ENUM_PROPERTY_SUBTYPE_NUMBER_ARRAY_ITEMS, + + {PROP_NONE, "NONE", 0, "None", ""}, + {0, NULL, 0, NULL, NULL}, +}; + const EnumPropertyItem rna_enum_property_subtype_items[] = { {PROP_NONE, "NONE", 0, "None", ""}, - /* strings */ - {PROP_FILEPATH, "FILEPATH", 0, "File Path", ""}, - {PROP_DIRPATH, "DIRPATH", 0, "Directory Path", ""}, - {PROP_FILENAME, "FILENAME", 0, "File Name", ""}, - {PROP_BYTESTRING, "BYTESTRING", 0, "Byte String", ""}, - {PROP_PASSWORD, "PASSWORD", 0, "Password", "A string that is displayed hidden ('********')"}, - - /* numbers */ - {PROP_PIXEL, "PIXEL", 0, "Pixel", ""}, - {PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned", ""}, - {PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""}, - {PROP_FACTOR, "FACTOR", 0, "Factor", ""}, - {PROP_ANGLE, "ANGLE", 0, "Angle", ""}, - {PROP_TIME, - "TIME", - 0, - "Time (Scene Relative)", - "Time specified in frames, converted to seconds based on scene frame rate"}, - {PROP_TIME_ABSOLUTE, - "TIME_ABSOLUTE", - 0, - "Time (Absolute)", - "Time specified in seconds, independent of the scene"}, - {PROP_DISTANCE, "DISTANCE", 0, "Distance", ""}, - {PROP_DISTANCE_CAMERA, "DISTANCE_CAMERA", 0, "Camera Distance", ""}, - {PROP_POWER, "POWER", 0, "Power", ""}, - {PROP_TEMPERATURE, "TEMPERATURE", 0, "Temperature", ""}, - - /* number arrays */ - {PROP_COLOR, "COLOR", 0, "Color", ""}, - {PROP_TRANSLATION, "TRANSLATION", 0, "Translation", ""}, - {PROP_DIRECTION, "DIRECTION", 0, "Direction", ""}, - {PROP_VELOCITY, "VELOCITY", 0, "Velocity", ""}, - {PROP_ACCELERATION, "ACCELERATION", 0, "Acceleration", ""}, - {PROP_MATRIX, "MATRIX", 0, "Matrix", ""}, - {PROP_EULER, "EULER", 0, "Euler Angles", ""}, - {PROP_QUATERNION, "QUATERNION", 0, "Quaternion", ""}, - {PROP_AXISANGLE, "AXISANGLE", 0, "Axis-Angle", ""}, - {PROP_XYZ, "XYZ", 0, "XYZ", ""}, - {PROP_XYZ_LENGTH, "XYZ_LENGTH", 0, "XYZ Length", ""}, - {PROP_COLOR_GAMMA, "COLOR_GAMMA", 0, "Color", ""}, - {PROP_COORDS, "COORDS", 0, "Coordinates", ""}, - - /* booleans */ - {PROP_LAYER, "LAYER", 0, "Layer", ""}, - {PROP_LAYER_MEMBER, "LAYER_MEMBER", 0, "Layer Member", ""}, + /* String. */ + RNA_ENUM_PROPERTY_SUBTYPE_STRING_ITEMS, + + /* Number. */ + RNA_ENUM_PROPERTY_SUBTYPE_NUMBER_ITEMS, + + /* Number array. */ + RNA_ENUM_PROPERTY_SUBTYPE_NUMBER_ARRAY_ITEMS, + {0, NULL, 0, NULL, NULL}, }; @@ -120,6 +149,69 @@ const EnumPropertyItem rna_enum_property_unit_items[] = { {0, NULL, 0, NULL, NULL}, }; +const EnumPropertyItem rna_enum_property_flag_items[] = { + {PROP_HIDDEN, "HIDDEN", 0, "Hidden", ""}, + {PROP_SKIP_SAVE, "SKIP_SAVE", 0, "Skip Save", ""}, + {PROP_ANIMATABLE, "ANIMATABLE", 0, "Animatable", ""}, + {PROP_LIB_EXCEPTION, "LIBRARY_EDITABLE", 0, "Library Editable", ""}, + {PROP_PROPORTIONAL, "PROPORTIONAL", 0, "Adjust values proportionally to eachother", ""}, + {PROP_TEXTEDIT_UPDATE, + "TEXTEDIT_UPDATE", + 0, + "Update on every keystroke in textedit 'mode'", + ""}, + {0, NULL, 0, NULL, NULL}, +}; + +/** Only for enum type properties. */ +const EnumPropertyItem rna_enum_property_flag_enum_items[] = { + {PROP_HIDDEN, "HIDDEN", 0, "Hidden", ""}, + {PROP_SKIP_SAVE, "SKIP_SAVE", 0, "Skip Save", ""}, + {PROP_ANIMATABLE, "ANIMATABLE", 0, "Animatable", ""}, + {PROP_LIB_EXCEPTION, "LIBRARY_EDITABLE", 0, "Library Editable", ""}, + {PROP_ENUM_FLAG, "ENUM_FLAG", 0, "Enum Flag", ""}, + {0, NULL, 0, NULL, NULL}, +}; + +const EnumPropertyItem rna_enum_property_override_flag_items[] = { + {PROPOVERRIDE_OVERRIDABLE_LIBRARY, + "LIBRARY_OVERRIDABLE", + 0, + "Library Overridable", + "Make that property editable in library overrides of linked data-blocks"}, + {0, NULL, 0, NULL, NULL}, +}; + +const EnumPropertyItem rna_enum_property_override_flag_collection_items[] = { + {PROPOVERRIDE_OVERRIDABLE_LIBRARY, + "LIBRARY_OVERRIDABLE", + 0, + "Library Overridable", + "Make that property editable in library overrides of linked data-blocks"}, + {PROPOVERRIDE_NO_PROP_NAME, + "NO_PROPERTY_NAME", + 0, + "No Name", + "Do not use the names of the items, only their indices in the collection"}, + {PROPOVERRIDE_LIBRARY_INSERTION, + "USE_INSERTION", + 0, + "Use Insertion", + "Allow users to add new items in that collection in library overrides"}, + {0, NULL, 0, NULL, NULL}, +}; + +const EnumPropertyItem rna_enum_property_string_search_flag_items[] = { + {PROP_STRING_SEARCH_SORT, "SORT", 0, "Sort Search Results", ""}, + {PROP_STRING_SEARCH_SUGGESTION, + "SUGGESTION", + 0, + "Suggestion", + "Search results are suggestions (other values may be entered)"}, + + {0, NULL, 0, NULL, NULL}, +}; + /** \} */ #ifdef RNA_RUNTIME -- cgit v1.2.3