[Bf-blender-cvs] [1a1e8f363dd] greasepencil-object: GPencil: Make Random Curve panels more compact

Antonio Vazquez noreply at git.blender.org
Wed Apr 22 11:47:14 CEST 2020


Commit: 1a1e8f363ddfeedfb1cdec4f4d13cc16b5ab95d1
Author: Antonio Vazquez
Date:   Wed Apr 22 11:46:45 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rB1a1e8f363ddfeedfb1cdec4f4d13cc16b5ab95d1

GPencil: Make Random Curve panels more compact

Instead to use a panel by curve, use tabs.

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

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesrna/intern/rna_brush.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 681e47e4102..154613f8c71 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1682,7 +1682,6 @@ class VIEW3D_PT_tools_grease_pencil_brushcurves_sensitivity(View3DPanel, Panel):
     bl_label = "Sensitivity"
     bl_category = "Tool"
     bl_parent_id = "VIEW3D_PT_tools_grease_pencil_brushcurves"
-    bl_options = {'DEFAULT_CLOSED'}
 
     def draw(self, context):
         layout = self.layout
@@ -1700,7 +1699,6 @@ class VIEW3D_PT_tools_grease_pencil_brushcurves_strength(View3DPanel, Panel):
     bl_label = "Strength"
     bl_category = "Tool"
     bl_parent_id = "VIEW3D_PT_tools_grease_pencil_brushcurves"
-    bl_options = {'DEFAULT_CLOSED'}
 
     def draw(self, context):
         layout = self.layout
@@ -1718,7 +1716,6 @@ class VIEW3D_PT_tools_grease_pencil_brushcurves_jitter(View3DPanel, Panel):
     bl_label = "Jitter"
     bl_category = "Tool"
     bl_parent_id = "VIEW3D_PT_tools_grease_pencil_brushcurves"
-    bl_options = {'DEFAULT_CLOSED'}
 
     def draw(self, context):
         layout = self.layout
@@ -1731,75 +1728,9 @@ class VIEW3D_PT_tools_grease_pencil_brushcurves_jitter(View3DPanel, Panel):
                                       use_negative_slope=True)
 
 
-class VIEW3D_PT_tools_grease_pencil_brushcurves_rand_pressure(View3DPanel, Panel):
-    bl_context = ".greasepencil_paint"
-    bl_label = "Random Pressure"
-    bl_category = "Tool"
-    bl_parent_id = "VIEW3D_PT_tools_grease_pencil_brushcurves"
-    bl_options = {'DEFAULT_CLOSED'}
-
-    @classmethod
-    def poll(cls, context):
-        return (context.region.type != 'TOOL_HEADER')
-
-    def draw(self, context):
-        layout = self.layout
-        layout.use_property_split = True
-
-        brush = context.tool_settings.gpencil_paint.brush
-        gp_settings = brush.gpencil_settings
-
-        layout.template_curve_mapping(gp_settings, "curve_random_pressure", brush=True,
-                                      use_negative_slope=True)
-
-
-class VIEW3D_PT_tools_grease_pencil_brushcurves_rand_strength(View3DPanel, Panel):
-    bl_context = ".greasepencil_paint"
-    bl_label = "Random Strength"
-    bl_category = "Tool"
-    bl_parent_id = "VIEW3D_PT_tools_grease_pencil_brushcurves"
-    bl_options = {'DEFAULT_CLOSED'}
-
-    @classmethod
-    def poll(cls, context):
-        return (context.region.type != 'TOOL_HEADER')
-
-    def draw(self, context):
-        layout = self.layout
-        layout.use_property_split = True
-
-        brush = context.tool_settings.gpencil_paint.brush
-        gp_settings = brush.gpencil_settings
-
-        layout.template_curve_mapping(gp_settings, "curve_random_strength", brush=True,
-                                      use_negative_slope=True)
-
-
-class VIEW3D_PT_tools_grease_pencil_brushcurves_rand_uv(View3DPanel, Panel):
-    bl_context = ".greasepencil_paint"
-    bl_label = "Random UV"
-    bl_category = "Tool"
-    bl_parent_id = "VIEW3D_PT_tools_grease_pencil_brushcurves"
-    bl_options = {'DEFAULT_CLOSED'}
-
-    @classmethod
-    def poll(cls, context):
-        return (context.region.type != 'TOOL_HEADER')
-
-    def draw(self, context):
-        layout = self.layout
-        layout.use_property_split = True
-
-        brush = context.tool_settings.gpencil_paint.brush
-        gp_settings = brush.gpencil_settings
-
-        layout.template_curve_mapping(gp_settings, "curve_random_uv", brush=True,
-                                      use_negative_slope=True)
-
-
-class VIEW3D_PT_tools_grease_pencil_brushcurves_rand_hue(View3DPanel, Panel):
+class VIEW3D_PT_tools_grease_pencil_brushcurves_random(View3DPanel, Panel):
     bl_context = ".greasepencil_paint"
-    bl_label = "Random Hue"
+    bl_label = "Random"
     bl_category = "Tool"
     bl_parent_id = "VIEW3D_PT_tools_grease_pencil_brushcurves"
     bl_options = {'DEFAULT_CLOSED'}
@@ -1815,51 +1746,25 @@ class VIEW3D_PT_tools_grease_pencil_brushcurves_rand_hue(View3DPanel, Panel):
         brush = context.tool_settings.gpencil_paint.brush
         gp_settings = brush.gpencil_settings
 
-        layout.template_curve_mapping(gp_settings, "curve_random_hue", brush=True,
-                                      use_negative_slope=True)
-
-
-class VIEW3D_PT_tools_grease_pencil_brushcurves_rand_saturation(View3DPanel, Panel):
-    bl_context = ".greasepencil_paint"
-    bl_label = "Random Saturation"
-    bl_category = "Tool"
-    bl_parent_id = "VIEW3D_PT_tools_grease_pencil_brushcurves"
-    bl_options = {'DEFAULT_CLOSED'}
-
-    @classmethod
-    def poll(cls, context):
-        return (context.region.type != 'TOOL_HEADER')
-
-    def draw(self, context):
-        layout = self.layout
-        layout.use_property_split = True
-
-        brush = context.tool_settings.gpencil_paint.brush
-        gp_settings = brush.gpencil_settings
-
-        layout.template_curve_mapping(gp_settings, "curve_random_saturation", brush=True,
-                                      use_negative_slope=True)
-
-
-class VIEW3D_PT_tools_grease_pencil_brushcurves_rand_value(View3DPanel, Panel):
-    bl_context = ".greasepencil_paint"
-    bl_label = "Random Value"
-    bl_category = "Tool"
-    bl_parent_id = "VIEW3D_PT_tools_grease_pencil_brushcurves"
-    bl_options = {'DEFAULT_CLOSED'}
-
-    @classmethod
-    def poll(cls, context):
-        return (context.region.type != 'TOOL_HEADER')
-
-    def draw(self, context):
-        layout = self.layout
-        layout.use_property_split = True
-
-        brush = context.tool_settings.gpencil_paint.brush
-        gp_settings = brush.gpencil_settings
+        row=layout.row(align=True)
+        row.prop(gp_settings, "curve_random_tab", expand=True)
+
+        if gp_settings.curve_random_tab == 'PRESSURE':
+            curve = "curve_random_pressure"
+        elif gp_settings.curve_random_tab == 'STRENGTH':
+            curve = "curve_random_strength"
+        elif gp_settings.curve_random_tab == 'UV':
+            curve = "curve_random_uv"
+        elif gp_settings.curve_random_tab == 'HUE':
+            curve = "curve_random_hue"
+        elif gp_settings.curve_random_tab == 'SATURATION':
+            curve = "curve_random_saturation"
+        elif gp_settings.curve_random_tab == 'VALUE':
+            curve = "curve_random_value"
+        else:
+            curve = "curve_random_strength"
 
-        layout.template_curve_mapping(gp_settings, "curve_random_value", brush=True,
+        layout.template_curve_mapping(gp_settings, curve, brush=True,
                                       use_negative_slope=True)
 
 
@@ -2442,12 +2347,7 @@ classes = (
     VIEW3D_PT_tools_grease_pencil_brushcurves_sensitivity,
     VIEW3D_PT_tools_grease_pencil_brushcurves_strength,
     VIEW3D_PT_tools_grease_pencil_brushcurves_jitter,
-    VIEW3D_PT_tools_grease_pencil_brushcurves_rand_pressure,
-    VIEW3D_PT_tools_grease_pencil_brushcurves_rand_strength,
-    VIEW3D_PT_tools_grease_pencil_brushcurves_rand_uv,
-    VIEW3D_PT_tools_grease_pencil_brushcurves_rand_hue,
-    VIEW3D_PT_tools_grease_pencil_brushcurves_rand_saturation,
-    VIEW3D_PT_tools_grease_pencil_brushcurves_rand_value,
+    VIEW3D_PT_tools_grease_pencil_brushcurves_random,
     VIEW3D_PT_tools_grease_pencil_paint_appearance,
     VIEW3D_PT_tools_grease_pencil_sculpt_select,
     VIEW3D_PT_tools_grease_pencil_sculpt_settings,
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 5c5cd3a905b..c967ecadf2f 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -118,7 +118,8 @@ typedef struct BrushGpencilSettings {
   int sculpt_mode_flag;
   /** Preset type (used to reset brushes - internal). */
   short preset_type;
-  char _pad3[2];
+  /** Curve type active tab for random curves. */
+  short curve_random_tab;
 
   /** Randomness for Hue. */
   float random_hue;
@@ -185,6 +186,17 @@ typedef enum eGPBrush_Presets {
   GP_BRUSH_PRESET_DRAW_WEIGHT = 300,
 } eGPBrush_Presets;
 
+/* BrushGpencilSettings->curve_tab_type */
+
+typedef enum eGPBrush_TabType {
+  GP_BRUSH_CURVETAB_PRESSURE = 0,
+  GP_BRUSH_CURVETAB_STRENGTH = 1,
+  GP_BRUSH_CURVETAB_UV = 2,
+  GP_BRUSH_CURVETAB_HUE = 3,
+  GP_BRUSH_CURVETAB_SATURATION = 4,
+  GP_BRUSH_CURVETAB_VALUE = 5,
+} eGPBrush_TabType;
+
 /* BrushGpencilSettings->gp_flag */
 typedef enum eGPDbrush_Flag {
   /* brush use pressure */
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 8d83d2a9134..4b25e849834 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -282,6 +282,17 @@ static EnumPropertyItem rna_enum_gpencil_brush_vertex_icons_items[] = {
     {GP_BRUSH_ICON_VERTEX_REPLACE, "REPLACE", ICON_BRUSH_MIX, "Replace", ""},
     {0, NULL, 0, NULL, NULL},
 };
+
+static EnumPropertyItem rna_enum_brush_curvetab_types_items[] = {
+    {GP_BRUSH_CURVETAB_PRESSURE, "PRESSURE", 0, "PS", "Pressure"},
+    {GP_BRUSH_CURVETAB_STRENGTH, "STRENGTH", 0, "ST", "Strength"},
+    {GP_BRUSH_CURVETAB_UV, "UV", 0, "UV", "UV"},
+    {GP_BRUSH_CURVETAB_HUE, "HUE", 0, "H", "Hue"},
+    {GP_BRUSH_CURVETAB_SATURATION, "SATURATION", 0, "S", "Saturation"},
+    {GP_BRUSH_CURVETAB_VALUE, "VALUE", 0, "V", "Value"},
+    {0, NULL, 0, NULL, NULL},
+};
+
 #endif
 
 #ifdef RNA_RUNTIME
@@ -1296,6 +1307,13 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
   RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
 
+  prop = RNA_def_property(srna, "curve_random_tab", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "curve_random_tab");
+  RNA_def_property_enum_items(prop, rna_enum_brush_curvetab_types_items);
+  RNA_def_property_ui_text(prop, "Curve", "Curve Tab");
+  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
   prop = RNA_def_property(srna, "curve_random_pressure", PROP_POINTER, PROP_NONE);
   RNA_def_property_pointer_sdna(prop, NULL, "curve_ra

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list