[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43479] trunk/blender/release/scripts/ startup/bl_ui/space_image.py: fix size slider not working for image space brushes ( uv sculpt and image paint).

Antony Riakiotakis kalast at gmail.com
Wed Jan 18 01:41:46 CET 2012


Revision: 43479
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43479
Author:   psy-fi
Date:     2012-01-18 00:41:39 +0000 (Wed, 18 Jan 2012)
Log Message:
-----------
fix size slider not working for image space brushes (uv sculpt and image paint). This is due to not checking if unified settings are active as per recent commit. Reused the space_view3D PaintPanel utility class slightly modified for the image space to do the checks. I am not very happy with the duplication but I decided to keep it as is since I change bl_space_type and bl_region_type from the original class. Reviewed by Nicholas Bishop.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_image.py

Modified: trunk/blender/release/scripts/startup/bl_ui/space_image.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_image.py	2012-01-18 00:03:09 UTC (rev 43478)
+++ trunk/blender/release/scripts/startup/bl_ui/space_image.py	2012-01-18 00:41:39 UTC (rev 43479)
@@ -20,7 +20,48 @@
 import bpy
 from bpy.types import Header, Menu, Panel
 
+class PaintPanel():
+    bl_space_type = 'IMAGE_EDITOR'
+    bl_region_type = 'UI'
 
+    @staticmethod
+    def paint_settings(context):
+        toolsettings = context.tool_settings
+
+        if context.sculpt_object:
+            return toolsettings.sculpt
+        elif context.vertex_paint_object:
+            return toolsettings.vertex_paint
+        elif context.weight_paint_object:
+            return toolsettings.weight_paint
+        elif context.image_paint_object:
+            return toolsettings.image_paint
+        elif context.particle_edit_object:
+            return toolsettings.particle_edit
+
+        return None
+
+    @staticmethod
+    def unified_paint_settings(parent, context):
+        ups = context.tool_settings.unified_paint_settings
+        parent.label(text="Unified Settings:")
+        parent.prop(ups, "use_unified_size", text="Size")
+        parent.prop(ups, "use_unified_strength", text="Strength")
+
+    @staticmethod
+    def prop_unified_size(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
+        ups = context.tool_settings.unified_paint_settings
+        ptr = ups if ups.use_unified_size else brush
+        parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
+
+    @staticmethod
+    def prop_unified_strength(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
+        ups = context.tool_settings.unified_paint_settings
+        ptr = ups if ups.use_unified_strength else brush
+        parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
+
+
+
 class BrushButtonsPanel():
     bl_space_type = 'IMAGE_EDITOR'
     bl_region_type = 'UI'
@@ -641,7 +682,7 @@
             sub.row().prop(uvedit, "draw_stretch_type", expand=True)
 
 
-class IMAGE_PT_paint(Panel):
+class IMAGE_PT_paint(Panel, PaintPanel):
     bl_space_type = 'IMAGE_EDITOR'
     bl_region_type = 'UI'
     bl_label = "Paint"
@@ -666,13 +707,13 @@
             col.prop(brush, "color", text="")
 
             row = col.row(align=True)
-            row.prop(brush, "size", slider=True)
-            row.prop(brush, "use_pressure_size", toggle=True, text="")
+            self.prop_unified_size(row, context, brush, "size", slider=True)
+            self.prop_unified_size(row, context, brush, "use_pressure_size")
 
             row = col.row(align=True)
-            row.prop(brush, "strength", slider=True)
-            row.prop(brush, "use_pressure_strength", toggle=True, text="")
-
+            self.prop_unified_strength(row, context, brush, "strength", slider=True)
+            self.prop_unified_strength(row, context, brush, "use_pressure_strength")
+            
             row = col.row(align=True)
             row.prop(brush, "jitter", slider=True)
             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
@@ -793,7 +834,7 @@
         row.operator("brush.curve_preset", icon="NOCURVE", text="").shape = 'MAX'
 
 
-class IMAGE_UV_sculpt(bpy.types.Panel):
+class IMAGE_UV_sculpt(bpy.types.Panel, PaintPanel):
     bl_space_type = 'IMAGE_EDITOR'
     bl_region_type = 'UI'
     bl_label = "UV Sculpt"
@@ -815,13 +856,13 @@
             col = layout.column()
 
             row = col.row(align=True)
-            row.prop(brush, "size", slider=True)
-            row.prop(brush, "use_pressure_size", toggle=True, text="")
+            self.prop_unified_size(row, context, brush, "size", slider=True)
+            self.prop_unified_size(row, context, brush, "use_pressure_size")
 
             row = col.row(align=True)
-            row.prop(brush, "strength", slider=True)
-            row.prop(brush, "use_pressure_strength", toggle=True, text="")
-
+            self.prop_unified_strength(row, context, brush, "strength", slider=True)
+            self.prop_unified_strength(row, context, brush, "use_pressure_strength")
+            
         split = layout.split()
         col = split.column()
 




More information about the Bf-blender-cvs mailing list