[Bf-blender-cvs] [1717403] soc-2013-paint: Address review points:

Antony Riakiotakis noreply at git.blender.org
Tue Jun 24 18:06:42 CEST 2014


Commit: 171740318577a4bf6603952efa964583f9818b24
Author: Antony Riakiotakis
Date:   Tue Jun 24 19:06:24 2014 +0300
https://developer.blender.org/rB171740318577a4bf6603952efa964583f9818b24

Address review points:

* Deduplicate panel for texture paint brushes
* Use compare_len_v3v3_squared for color comparison in 2d fill tool
* NULL check when adding texture.

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	release/scripts/startup/bl_ui/space_image.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenlib/BLI_math_vector.h
M	source/blender/blenlib/intern/math_vector_inline.c
M	source/blender/editors/sculpt_paint/paint_image_2d.c
M	source/blender/editors/space_image/image_ops.c

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

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index a17efc7..521fa99 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -85,6 +85,93 @@ class UnifiedPaintPanel():
         ptr = ups if ups.use_unified_color else brush
         parent.template_color_picker(ptr, prop_name, value_slider=value_slider)
 
+
+def brush_texpaint_common(panel, context, layout, brush, settings):
+    capabilities = brush.imapaint_capabilities
+
+    col = layout.column()
+
+    if brush.image_tool in {'DRAW', 'FILL'}:
+        if brush.blend not in {'ERASE_ALPHA', 'ADD_ALPHA'}:
+            if not brush.use_gradient:
+                panel.prop_unified_color_picker(col, context, brush, "color", value_slider=True)
+
+            if settings.palette:
+                col.template_palette(settings, "palette", color=True)
+						
+            if brush.use_gradient:
+                col.label("Gradient Colors")
+                col.template_color_ramp(brush, "gradient", expand=True)
+
+                if brush.image_tool != 'FILL':
+                    col.label("Background Color")
+                    row = col.row(align=True)
+                    panel.prop_unified_color(row, context, brush, "secondary_color", text="")
+
+                if brush.image_tool == 'DRAW':
+                    col.prop(brush, "gradient_stroke_mode", text="Mode")
+                    if brush.gradient_stroke_mode in {'SPACING_REPEAT', 'SPACING_CLAMP'}:
+                        col.prop(brush, "grad_spacing")
+                elif brush.image_tool == 'FILL':
+                    col.prop(brush, "gradient_fill_mode")
+            else:
+                row = col.row(align=True)
+                panel.prop_unified_color(row, context, brush, "color", text="")
+                if brush.image_tool == 'FILL':
+                    col.prop(brush, "fill_threshold")
+                else:
+                    panel.prop_unified_color(row, context, brush, "secondary_color", text="")
+                    row.separator()
+                    row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="")
+
+    elif brush.image_tool == 'SOFTEN':
+        col = layout.column(align=True)
+        col.row().prop(brush, "direction", expand=True)
+        col.separator()
+        col.prop(brush, "sharp_threshold")
+        col.prop(brush, "blur_kernel_radius")
+        col.separator()
+        col.prop(brush, "blur_mode")
+    elif brush.image_tool == 'MASK':
+        col.prop(brush, "weight", text="Mask Value", slider=True)
+
+    elif brush.image_tool == 'CLONE':
+        col.separator()
+        col.prop(brush, "clone_image", text="Image")
+        col.prop(brush, "clone_alpha", text="Alpha")
+                
+    col.separator()
+
+    if capabilities.has_radius:
+        row = col.row(align=True)
+        panel.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
+        panel.prop_unified_size(row, context, brush, "use_pressure_size")
+
+        row = col.row(align=True)
+
+    if capabilities.has_space_attenuation:
+        row.prop(brush, "use_space_attenuation", toggle=True, icon_only=True)
+
+    panel.prop_unified_strength(row, context, brush, "strength", text="Strength")
+    panel.prop_unified_strength(row, context, brush, "use_pressure_strength")
+
+    if brush.image_tool in {'DRAW', 'FILL'}:
+        col.separator()
+        col.prop(brush, "blend", text="Blend")
+
+    col = layout.column()
+
+    # use_accumulate
+    if capabilities.has_accumulate:
+        col = layout.column(align=True)
+        col.prop(brush, "use_accumulate")
+
+    col.prop(brush, "use_alpha")
+    col.prop(brush, "use_gradient")
+
+    col.separator()
+    col.template_ID(settings, "palette", new="palette.new")
+
 # Used in both the View3D toolbar and texture properties
 def brush_texture_settings(layout, brush, sculpt):
     tex_slot = brush.texture_slot
@@ -161,3 +248,5 @@ def brush_mask_texture_settings(layout, brush):
     split = layout.split()
     split.prop(mask_tex_slot, "offset")
     split.prop(mask_tex_slot, "scale")
+
+
diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index 16a7aca..77747f0 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -22,6 +22,7 @@ from bpy.types import Header, Menu, Panel
 from bl_ui.properties_paint_common import (
         UnifiedPaintPanel,
         brush_texture_settings,
+        brush_texpaint_common,
         brush_mask_texture_settings,
         )
 from bl_ui.properties_grease_pencil_common import GreasePencilPanel
@@ -691,92 +692,7 @@ class IMAGE_PT_paint(Panel, BrushButtonsPanel):
         col.template_ID_preview(settings, "brush", new="brush.add", rows=2, cols=6)
 
         if brush:
-            capabilities = brush.imapaint_capabilities
-
-            col = layout.column()
-
-            if brush.image_tool in {'DRAW', 'FILL'}:
-                if brush.blend not in {'ERASE_ALPHA', 'ADD_ALPHA'}:
-                    if not brush.use_gradient:
-                        self.prop_unified_color_picker(col, context, brush, "color", value_slider=True)
-
-                    if settings.palette:
-                        col.template_palette(settings, "palette", color=True)
-						
-                    if brush.use_gradient:
-                        col.label("Gradient Colors")
-                        col.template_color_ramp(brush, "gradient", expand=True)
-
-                        if brush.image_tool != 'FILL':
-                            col.label("Background Color")
-                            row = col.row(align=True)
-                            self.prop_unified_color(row, context, brush, "secondary_color", text="")
-
-                        if brush.image_tool == 'DRAW':
-                            col.prop(brush, "gradient_stroke_mode", text="Mode")
-                            if brush.gradient_stroke_mode in {'SPACING_REPEAT', 'SPACING_CLAMP'}:
-                                col.prop(brush, "grad_spacing")
-                        elif brush.image_tool == 'FILL':
-                            col.prop(brush, "gradient_fill_mode")
-                    else:
-                        row = col.row(align=True)
-                        self.prop_unified_color(row, context, brush, "color", text="")
-                        if brush.image_tool == 'FILL':
-                            col.prop(brush, "fill_threshold")
-                        else:
-                            self.prop_unified_color(row, context, brush, "secondary_color", text="")
-                            row.separator()
-                            row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="")
-
-            elif brush.image_tool == 'SOFTEN':
-                col = layout.column(align=True)
-                col.row().prop(brush, "direction", expand=True)
-                col.separator()
-                col.prop(brush, "sharp_threshold")
-                col.prop(brush, "blur_kernel_radius")
-                col.separator()
-                col.prop(brush, "blur_mode")
-
-            elif brush.image_tool == 'MASK':
-                col.prop(brush, "weight", text="Mask Value", slider=True)
-
-            elif brush.image_tool == 'CLONE':
-                col.separator()
-                col.prop(brush, "clone_image", text="Image")
-                col.prop(brush, "clone_alpha", text="Alpha")
-                
-            col.separator()
-			
-            if capabilities.has_radius:
-                row = col.row(align=True)
-                self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
-                self.prop_unified_size(row, context, brush, "use_pressure_size")
-
-            row = col.row(align=True)
-
-            if capabilities.has_space_attenuation:
-                row.prop(brush, "use_space_attenuation", toggle=True, icon_only=True)
-
-            self.prop_unified_strength(row, context, brush, "strength", text="Strength")
-            self.prop_unified_strength(row, context, brush, "use_pressure_strength")
-
-            if brush.image_tool in {'DRAW', 'FILL'}:
-                col.separator()
-                col.prop(brush, "blend", text="Blend")
-
-            col = layout.column()
-
-            # use_accumulate
-            if capabilities.has_accumulate:
-                col = layout.column(align=True)
-                col.prop(brush, "use_accumulate")
-
-            col.prop(brush, "use_alpha")
-            col.prop(brush, "use_gradient")
-
-            col.separator()
-            col.template_ID(settings, "palette", new="palette.new")
-
+            brush_texpaint_common(self, context, layout, brush, settings)
 
 class IMAGE_PT_tools_brush_overlay(BrushButtonsPanel, Panel):
     bl_label = "Overlay"
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 9c3e798..36f0a60 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -23,6 +23,7 @@ from bl_ui.properties_grease_pencil_common import GreasePencilPanel
 from bl_ui.properties_paint_common import (
         UnifiedPaintPanel,
         brush_texture_settings,
+        brush_texpaint_common,
         brush_mask_texture_settings,
         )
 
@@ -979,84 +980,7 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
         # Texture Paint Mode #
 
         elif context.image_paint_object and brush:
-            capabilities = brush.imapaint_capabilities
-
-            col = layout.column()
-
-            if brush.image_tool in {'DRAW', 'FILL'}:
-                if brush.blend not in {'ERASE_ALPHA', 'ADD_ALPHA'}:
-                    if not brush.use_gradient:
-                        self.prop_unified_color_picker(col, context, brush, "color", value_slider=True)
-
-                    if settings.palette:
-                        col.template_palette(settings, "palette", color=True)
-						
-                    if 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list