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.

This commit is contained in:
Antony Riakiotakis
2012-01-18 00:41:39 +00:00
parent b4df2658de
commit 6a218612be

View File

@@ -20,6 +20,47 @@
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'
@@ -641,7 +682,7 @@ class IMAGE_PT_view_properties(Panel):
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,12 +707,12 @@ class IMAGE_PT_paint(Panel):
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)
@@ -793,7 +834,7 @@ class IMAGE_UV_sculpt_curve(bpy.types.Panel):
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,12 +856,12 @@ class IMAGE_UV_sculpt(bpy.types.Panel):
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()