From a8e9d5533f51455febc40d386c8c2ce0cc561b7a Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Tue, 15 May 2012 04:50:47 +0000 Subject: Code/UI cleanup: improvements for sculpt brush texture settings. Settings are shown in both the View3D toolbar and texture properties panel; code is now in shared sculpt_brush_texture_settings() function in properties_paint_common.py. Also added a few new properties to the SculptCapabilities RNA to replace "X in {Y, Z}" tests in the Python code. --- .../startup/bl_ui/properties_paint_common.py | 34 ++++++++++++++++++ .../scripts/startup/bl_ui/properties_texture.py | 15 ++++---- .../scripts/startup/bl_ui/space_view3d_toolbar.py | 42 +++------------------- 3 files changed, 44 insertions(+), 47 deletions(-) (limited to 'release/scripts') diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py index 94df1ed6cf5..53cf640beb9 100644 --- a/release/scripts/startup/bl_ui/properties_paint_common.py +++ b/release/scripts/startup/bl_ui/properties_paint_common.py @@ -67,3 +67,37 @@ class UnifiedPaintPanel(): ups = context.tool_settings.unified_paint_settings ptr = ups if ups.use_unified_weight else brush parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider) + + +# Used in both the View3D toolbar and texture properties +def sculpt_brush_texture_settings(layout, brush): + tex_slot = brush.texture_slot + + layout.label(text="Brush Mapping:") + + # map_mode + layout.row().prop(tex_slot, "map_mode", text="") + layout.separator() + + # angle and texture_angle_source + col = layout.column() + col.active = brush.sculpt_capabilities.has_texture_angle_source + col.label(text="Angle:") + if brush.sculpt_capabilities.has_random_texture_angle: + col.prop(brush, "texture_angle_source_random", text="") + else: + col.prop(brush, "texture_angle_source_no_random", text="") + + col = layout.column() + col.active = brush.sculpt_capabilities.has_texture_angle + col.prop(tex_slot, "angle", text="") + + # scale and offset + split = layout.split() + split.prop(tex_slot, "offset") + split.prop(tex_slot, "scale") + + # texture_sample_bias + col = layout.column(align=True) + col.label(text="Sample Bias:") + col.prop(brush, "texture_sample_bias", slider=True, text="") diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index 32047581550..1d5e96cf701 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -29,6 +29,8 @@ from bpy.types import (Brush, from rna_prop_ui import PropertyPanel +from bl_ui.properties_paint_common import sculpt_brush_texture_settings + class TEXTURE_MT_specials(Menu): bl_label = "Texture Specials" @@ -856,12 +858,7 @@ class TEXTURE_PT_mapping(TextureSlotPanel, Panel): if isinstance(idblock, Brush): if context.sculpt_object: - layout.label(text="Brush Mapping:") - layout.prop(tex, "map_mode", expand=True) - - row = layout.row() - row.active = tex.map_mode in {'FIXED', 'TILED'} - row.prop(tex, "angle") + sculpt_brush_texture_settings(layout, idblock) else: if isinstance(idblock, Material): split = layout.split(percentage=0.3) @@ -884,9 +881,9 @@ class TEXTURE_PT_mapping(TextureSlotPanel, Panel): row.prop(tex, "mapping_y", text="") row.prop(tex, "mapping_z", text="") - row = layout.row() - row.column().prop(tex, "offset") - row.column().prop(tex, "scale") + row = layout.row() + row.column().prop(tex, "offset") + row.column().prop(tex, "scale") class TEXTURE_PT_influence(TextureSlotPanel, Panel): diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index f3fa1585d56..d3a8427aa16 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -20,6 +20,7 @@ import bpy from bpy.types import Menu, Panel from bl_ui.properties_paint_common import UnifiedPaintPanel +from bl_ui.properties_paint_common import sculpt_brush_texture_settings class View3DPanel(): @@ -719,45 +720,11 @@ class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel): col.prop(brush, "use_fixed_texture") if context.sculpt_object: - #XXX duplicated from properties_texture.py - - col.label(text="Brush Mapping:") - col.row().prop(tex_slot, "map_mode", expand=True) - - col.separator() - - col = layout.column() - col.active = tex_slot.map_mode in {'FIXED'} - col.label(text="Angle:") - if brush.sculpt_capabilities.has_random_texture_angle: - col.prop(brush, "texture_angle_source_random", text="") - else: - col.prop(brush, "texture_angle_source_no_random", text="") - - #row = col.row(align=True) - #row.label(text="Angle:") - #row.active = tex_slot.map_mode in {'FIXED', 'TILED'} - - #row = col.row(align=True) - - #col = row.column() - #col.active = tex_slot.map_mode in {'FIXED'} - #col.prop(brush, "use_rake", toggle=True, icon='PARTICLEMODE', text="") - - col = layout.column() - col.active = tex_slot.map_mode in {'FIXED', 'TILED'} - col.prop(tex_slot, "angle", text="") - - split = layout.split() - split.prop(tex_slot, "offset") - split.prop(tex_slot, "scale") - - col = layout.column(align=True) - col.label(text="Sample Bias:") - col.prop(brush, "texture_sample_bias", slider=True, text="") + sculpt_brush_texture_settings(col, brush) + # use_texture_overlay and texture_overlay_alpha col = layout.column(align=True) - col.active = tex_slot.map_mode in {'FIXED', 'TILED'} + col.active = brush.sculpt_capabilities.has_overlay col.label(text="Overlay:") row = col.row() @@ -766,7 +733,6 @@ class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel): else: row.prop(brush, "use_texture_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON') sub = row.row() - sub.active = tex_slot.map_mode in {'FIXED', 'TILED'} and brush.use_texture_overlay sub.prop(brush, "texture_overlay_alpha", text="Alpha") -- cgit v1.2.3