[Bf-blender-cvs] [c8058e51ee7] master: RNA: add macros for EnumPropertyItem layout elements

Campbell Barton noreply at git.blender.org
Tue May 31 06:19:38 CEST 2022


Commit: c8058e51ee7b355320e20a068ba00f6628567e98
Author: Campbell Barton
Date:   Tue May 31 14:07:15 2022 +1000
Branches: master
https://developer.blender.org/rBc8058e51ee7b355320e20a068ba00f6628567e98

RNA: add macros for EnumPropertyItem layout elements

Add the following macros for enums as support for these features wasn't
all that obvious and there were some inconsistencies in their use.

- RNA_ENUM_ITEM_HEADING(name, description)
- RNA_ENUM_ITEM_SEPR
- RNA_ENUM_ITEM_SEPR_COLUMN

===================================================================

M	source/blender/editors/armature/armature_edit.c
M	source/blender/editors/gpencil/gpencil_interpolate.c
M	source/blender/editors/object/object_data_transfer.c
M	source/blender/editors/object/object_relations.c
M	source/blender/editors/space_outliner/outliner_tools.cc
M	source/blender/makesrna/RNA_types.h
M	source/blender/makesrna/intern/rna_brush.c
M	source/blender/makesrna/intern/rna_constraint.c
M	source/blender/makesrna/intern/rna_curve.c
M	source/blender/makesrna/intern/rna_define.c
M	source/blender/makesrna/intern/rna_fcurve.c
M	source/blender/makesrna/intern/rna_gpencil_modifier.c
M	source/blender/makesrna/intern/rna_material.c
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/makesrna/intern/rna_nla.c
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/makesrna/intern/rna_object.c
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_sequencer.c
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/makesrna/intern/rna_texture.c
M	source/blender/makesrna/intern/rna_userdef.c
M	source/blender/makesrna/intern/rna_wm.c

===================================================================

diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index 963d7ea1149..3c445f46902 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -229,7 +229,7 @@ typedef enum eCalcRollTypes {
 } eCalcRollTypes;
 
 static const EnumPropertyItem prop_calc_roll_types[] = {
-    {0, "", 0, N_("Positive"), ""},
+    RNA_ENUM_ITEM_HEADING(N_("Positive"), NULL),
     {CALC_ROLL_TAN_POS_X, "POS_X", 0, "Local +X Tangent", ""},
     {CALC_ROLL_TAN_POS_Z, "POS_Z", 0, "Local +Z Tangent", ""},
 
@@ -237,8 +237,7 @@ static const EnumPropertyItem prop_calc_roll_types[] = {
     {CALC_ROLL_POS_Y, "GLOBAL_POS_Y", 0, "Global +Y Axis", ""},
     {CALC_ROLL_POS_Z, "GLOBAL_POS_Z", 0, "Global +Z Axis", ""},
 
-    {0, "", 0, N_("Negative"), ""},
-
+    RNA_ENUM_ITEM_HEADING(N_("Negative"), NULL),
     {CALC_ROLL_TAN_NEG_X, "NEG_X", 0, "Local -X Tangent", ""},
     {CALC_ROLL_TAN_NEG_Z, "NEG_Z", 0, "Local -Z Tangent", ""},
 
@@ -246,7 +245,7 @@ static const EnumPropertyItem prop_calc_roll_types[] = {
     {CALC_ROLL_NEG_Y, "GLOBAL_NEG_Y", 0, "Global -Y Axis", ""},
     {CALC_ROLL_NEG_Z, "GLOBAL_NEG_Z", 0, "Global -Z Axis", ""},
 
-    {0, "", 0, N_("Other"), ""},
+    RNA_ENUM_ITEM_HEADING(N_("Other"), NULL),
     {CALC_ROLL_ACTIVE, "ACTIVE", 0, "Active Bone", ""},
     {CALC_ROLL_VIEW, "VIEW", 0, "View Axis", ""},
     {CALC_ROLL_CURSOR, "CURSOR", 0, "Cursor", ""},
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index 8630b7f23d4..0039dbae674 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -1482,8 +1482,8 @@ void GPENCIL_OT_interpolate_sequence(wmOperatorType *ot)
    * Changes here will likely apply there too.
    */
   static const EnumPropertyItem gpencil_interpolation_type_items[] = {
-      /* interpolation */
-      {0, "", 0, N_("Interpolation"), "Standard transitions between keyframes"},
+      /* Interpolation. */
+      RNA_ENUM_ITEM_HEADING(N_("Interpolation"), "Standard transitions between keyframes"),
       {GP_IPO_LINEAR,
        "LINEAR",
        ICON_IPO_LINEAR,
@@ -1495,13 +1495,10 @@ void GPENCIL_OT_interpolate_sequence(wmOperatorType *ot)
        "Custom",
        "Custom interpolation defined using a curve map"},
 
-      /* easing */
-      {0,
-       "",
-       0,
-       N_("Easing (by strength)"),
-       "Predefined inertial transitions, useful for motion graphics (from least to most "
-       "''dramatic'')"},
+      /* Easing. */
+      RNA_ENUM_ITEM_HEADING(N_("Easing (by strength)"),
+                            "Predefined inertial transitions, useful for motion graphics "
+                            "(from least to most \"dramatic\")"),
       {GP_IPO_SINE,
        "SINE",
        ICON_IPO_SINE,
@@ -1518,7 +1515,7 @@ void GPENCIL_OT_interpolate_sequence(wmOperatorType *ot)
        "Circular",
        "Circular easing (strongest and most dynamic)"},
 
-      {0, "", 0, N_("Dynamic Effects"), "Simple physics-inspired easing effects"},
+      RNA_ENUM_ITEM_HEADING(N_("Dynamic Effects"), "Simple physics-inspired easing effects"),
       {GP_IPO_BACK, "BACK", ICON_IPO_BACK, "Back", "Cubic easing with overshoot and settle"},
       {GP_IPO_BOUNCE,
        "BOUNCE",
diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c
index dfe858e5bd9..b9a4c79ac03 100644
--- a/source/blender/editors/object/object_data_transfer.c
+++ b/source/blender/editors/object/object_data_transfer.c
@@ -45,7 +45,7 @@
  * Note some are 'fake' ones, i.e. they are not hold by real CDLayers. */
 /* Not shared with modifier, since we use a usual enum here, not a multi-choice one. */
 static const EnumPropertyItem DT_layer_items[] = {
-    {0, "", 0, "Vertex Data", ""},
+    RNA_ENUM_ITEM_HEADING("Vertex Data", NULL),
     {DT_TYPE_MDEFORMVERT,
      "VGROUP_WEIGHTS",
      0,
@@ -60,7 +60,8 @@ static const EnumPropertyItem DT_layer_items[] = {
     {DT_TYPE_SKIN, "SKIN", 0, "Skin Weight", "Transfer skin weights"},
 #endif
     {DT_TYPE_BWEIGHT_VERT, "BEVEL_WEIGHT_VERT", 0, "Bevel Weight", "Transfer bevel weights"},
-    {0, "", 0, "Edge Data", ""},
+
+    RNA_ENUM_ITEM_HEADING("Edge Data", NULL),
     {DT_TYPE_SHARP_EDGE, "SHARP_EDGE", 0, "Sharp", "Transfer sharp mark"},
     {DT_TYPE_SEAM, "SEAM", 0, "UV Seam", "Transfer UV seam mark"},
     {DT_TYPE_CREASE, "CREASE", 0, "Subdivision Crease", "Transfer crease values"},
@@ -70,11 +71,13 @@ static const EnumPropertyItem DT_layer_items[] = {
      0,
      "Freestyle Mark",
      "Transfer Freestyle edge mark"},
-    {0, "", 0, "Face Corner Data", ""},
+
+    RNA_ENUM_ITEM_HEADING("Face Corner Data", NULL),
     {DT_TYPE_LNOR, "CUSTOM_NORMAL", 0, "Custom Normals", "Transfer custom normals"},
     {DT_TYPE_MPROPCOL_LOOP | DT_TYPE_MLOOPCOL_LOOP, "VCOL", 0, "Colors", "Color Attributes"},
     {DT_TYPE_UV, "UV", 0, "UVs", "Transfer UV layers"},
-    {0, "", 0, "Face Data", ""},
+
+    RNA_ENUM_ITEM_HEADING("Face Data", NULL),
     {DT_TYPE_SHARP_FACE, "SMOOTH", 0, "Smooth", "Transfer flat/smooth mark"},
     {DT_TYPE_FREESTYLE_FACE,
      "FREESTYLE_FACE",
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index abbde3b5b3a..6cfd322b2e2 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -1653,7 +1653,7 @@ void OBJECT_OT_make_links_data(wmOperatorType *ot)
        "Link Instance Collection",
        "Replace assigned Collection Instance"},
       {MAKE_LINKS_FONTS, "FONTS", 0, "Link Fonts to Text", "Replace Text object Fonts"},
-      {0, "", 0, NULL, NULL},
+      RNA_ENUM_ITEM_SEPR,
       {MAKE_LINKS_MODIFIERS, "MODIFIERS", 0, "Copy Modifiers", "Replace Modifiers"},
       {MAKE_LINKS_SHADERFX,
        "EFFECTS",
diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc
index 3b018d59881..bfb4c7251a8 100644
--- a/source/blender/editors/space_outliner/outliner_tools.cc
+++ b/source/blender/editors/space_outliner/outliner_tools.cc
@@ -2008,7 +2008,7 @@ static const EnumPropertyItem prop_id_op_types[] = {
      0,
      "Remap Users",
      "Make all users of selected data-blocks to use instead current (clicked) one"},
-    {0, "", 0, nullptr, nullptr},
+    RNA_ENUM_ITEM_SEPR,
     {OUTLINER_IDOP_OVERRIDE_LIBRARY_CREATE,
      "OVERRIDE_LIBRARY_CREATE",
      0,
@@ -2067,10 +2067,10 @@ static const EnumPropertyItem prop_id_op_types[] = {
      "Clear Library Override Hierarchy",
      "Delete this local override (including its hierarchy of override dependencies) and relink "
      "its usages to the linked data-blocks"},
-    {0, "", 0, nullptr, nullptr},
+    RNA_ENUM_ITEM_SEPR,
     {OUTLINER_IDOP_COPY, "COPY", ICON_COPYDOWN, "Copy", ""},
     {OUTLINER_IDOP_PASTE, "PASTE", ICON_PASTEDOWN, "Paste", ""},
-    {0, "", 0, nullptr, nullptr},
+    RNA_ENUM_ITEM_SEPR,
     {OUTLINER_IDOP_FAKE_ADD,
      "ADD_FAKE",
      0,
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 75b514cdb13..5346228050a 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -467,6 +467,27 @@ typedef struct EnumPropertyItem {
   const char *description;
 } EnumPropertyItem;
 
+/**
+ * Heading for RNA enum items (shown in the UI).
+ *
+ * The description is currently only shown in the Python documentation.
+ * By convention the value should be a non-empty string or NULL when there is no description
+ * (never an empty string).
+ */
+#define RNA_ENUM_ITEM_HEADING(name, description) \
+  { \
+    0, "", 0, name, description \
+  }
+
+/** Separator for RNA enum items (shown in the UI). */
+#define RNA_ENUM_ITEM_SEPR \
+  { \
+    0, "", 0, NULL, NULL \
+  }
+
+/** Separator for RNA enum that begins a new column in menus (shown in the UI). */
+#define RNA_ENUM_ITEM_SEPR_COLUMN RNA_ENUM_ITEM_HEADING("", NULL)
+
 /* extended versions with PropertyRNA argument */
 typedef bool (*BooleanPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop);
 typedef void (*BooleanPropertySetFunc)(struct PointerRNA *ptr,
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 72f5bd1923c..2735a00ee75 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -98,14 +98,14 @@ const EnumPropertyItem rna_enum_brush_sculpt_tool_items[] = {
     {SCULPT_TOOL_INFLATE, "INFLATE", ICON_BRUSH_INFLATE, "Inflate", ""},
     {SCULPT_TOOL_BLOB, "BLOB", ICON_BRUSH_BLOB, "Blob", ""},
     {SCULPT_TOOL_CREASE, "CREASE", ICON_BRUSH_CREASE, "Crease", ""},
-    {0, "", 0, NULL, NULL},
+    RNA_ENUM_ITEM_SEPR,
     {SCULPT_TOOL_SMOOTH, "SMOOTH", ICON_BRUSH_SMOOTH, "Smooth", ""},
     {SCULPT_TOOL_FLATTEN, "FLATTEN", ICON_BRUSH_FLATTEN, "Flatten", ""},
     {SCULPT_TOOL_FILL, "FILL", ICON_BRUSH_FILL, "Fill", ""},
     {SCULPT_TOOL_SCRAPE, "SCRAPE", ICON_BRUSH_SCRAPE, "Scrape", ""},
     {SCULPT_TOOL_MULTIPLANE_SCRAPE, "MULTIPLANE_SCRAPE", ICON_BRUSH_SCRAPE, "Multi-plane Scrape", ""},
     {SCULPT_TOOL_PINCH, "PINCH", ICON_BRUSH_PINCH, "Pinch", ""},
-    {0, "", 0, NULL, NULL},
+    RNA_ENUM_ITEM_SEPR,
     {SCULPT_TOOL_GRAB, "GRAB", ICON_BRUSH_GRAB, "Grab", ""},
     {SCULPT_TOOL_ELASTIC_DEFORM, "ELASTIC_DEFORM", ICON_BRUSH_GRAB, "Elastic Deform", ""},
     {SCULPT_TOOL_SNAKE_HOOK, "SNAKE_HOOK", ICON_BRUSH_SNAKE_HOOK, "Snake Hook", ""},
@@ -115,7 +115,7 @@ const EnumPropertyItem rna_enum_brush_sculpt_tool_items[] = {
     {SCULPT_TOOL_ROTATE, "ROTATE", ICON_BRUSH_ROTATE, "Rotate", ""},
     {SCULPT_TOOL_SLIDE_RELAX, "TOPOLOGY", ICON_BRUSH_GRAB, "Slide Relax", ""},
     {SCULPT_TOOL_BOUNDARY, "BOUNDARY", ICON_BRUSH_GRAB, "Boundary", ""},
-    {0, "", 0, NULL, NULL},
+    RNA_ENUM_ITEM_SEPR,
     {SCULPT_TOOL_CLOTH, "CLOTH", ICON_BRUSH_SCULPT_DRAW, "Cloth", ""},
     {SCULPT_TOOL_SIMPLIFY, "SIMPLIFY", ICON_BRUSH_DATA, "Simplify", ""},
     {SCULPT_TOOL_MASK, "MASK", ICON_BRUSH_MASK, "Mas

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list