UI: add weight paint brushes to toolbar

This commit is contained in:
Campbell Barton 2018-04-30 16:06:51 +02:00
parent cbe57acddf
commit 9aef2d961d
3 changed files with 78 additions and 42 deletions

View File

@ -203,33 +203,6 @@ class _defs_view3d_select:
# -----------------------------------------------------------------------------
# Object Modes (named based on context.mode)
class _defs_weight_paint:
@ToolDef.from_fn
def gradient_linear():
return dict(
text="Linear Gradient",
icon=None,
widget=None,
keymap=(
("paint.weight_gradient", dict(type='LINEAR'),
dict(type='EVT_TWEAK_A', value='ANY')),
),
)
@ToolDef.from_fn
def gradient_radial():
return dict(
text="Radial Gradient",
icon=None,
widget=None,
keymap=(
("paint.weight_gradient",
dict(type='RADIAL'),
dict(type='EVT_TWEAK_A', value='ANY')),
),
)
class _defs_edit_armature:
@ToolDef.from_fn
@ -571,13 +544,14 @@ class _defs_sculpt:
)
)
class _defs_vertexpaint:
class _defs_vertex_paint:
@staticmethod
def generate_from_brushes(context):
return generate_from_brushes_ex(
context,
icon_prefix="brush.vertexpaint.",
icon_prefix="brush.paint_vertex.",
brush_test_attr="use_paint_vertex",
brush_category_attr="vertex_tool",
brush_category_layout=(
@ -594,6 +568,54 @@ class _defs_vertexpaint:
)
class _defs_weight_paint:
@staticmethod
def generate_from_brushes(context):
return generate_from_brushes_ex(
context,
icon_prefix="brush.paint_weight.",
brush_test_attr="use_paint_weight",
brush_category_attr="vertex_tool",
brush_category_layout=(
('MIX',),
('BLUR', 'AVERAGE'),
('SMEAR',),
(
'ADD', 'SUB', 'MUL', 'LIGHTEN', 'DARKEN',
'COLORDODGE', 'DIFFERENCE', 'SCREEN', 'HARDLIGHT',
'OVERLAY', 'SOFTLIGHT', 'EXCLUSION', 'LUMINOCITY',
'SATURATION', 'HUE',
),
)
)
@ToolDef.from_fn
def gradient_linear():
return dict(
text="Linear Gradient",
icon=None,
widget=None,
keymap=(
("paint.weight_gradient", dict(type='LINEAR'),
dict(type='EVT_TWEAK_A', value='ANY')),
),
)
@ToolDef.from_fn
def gradient_radial():
return dict(
text="Radial Gradient",
icon=None,
widget=None,
keymap=(
("paint.weight_gradient",
dict(type='RADIAL'),
dict(type='EVT_TWEAK_A', value='ANY')),
),
)
class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
@ -653,15 +675,6 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
*_tools_select,
*_tools_transform,
],
'PAINT_WEIGHT': [
*_tools_select,
# TODO, override brush events
(
_defs_weight_paint.gradient_linear,
_defs_weight_paint.gradient_radial,
),
],
'EDIT_ARMATURE': [
*_tools_select,
None,
@ -735,7 +748,17 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
_defs_sculpt.generate_from_brushes,
],
'PAINT_VERTEX': [
_defs_vertexpaint.generate_from_brushes,
_defs_vertex_paint.generate_from_brushes,
],
'PAINT_WEIGHT': [
*_tools_select,
# TODO, override brush events
_defs_weight_paint.generate_from_brushes,
(
_defs_weight_paint.gradient_linear,
_defs_weight_paint.gradient_radial,
),
],
}

View File

@ -150,7 +150,8 @@ class TOPBAR_HT_lower_bar(Header):
layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".dummy", category="")
layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".vertexpaint", category="")
elif mode == 'PAINT_WEIGHT':
layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".dummy", category="")
layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context="", category="")
layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context=".weightpaint", category="")
elif mode == 'PAINT_TEXTURE':
layout.popover_group(space_type='VIEW_3D', region_type='TOOLS', context="", category="")
@ -203,6 +204,18 @@ class _draw_left_context_mode:
UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", slider=True, text="Radius")
UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True, text="Strength")
def PAINT_WEIGHT(context, layout):
brush = context.tool_settings.weight_paint.brush
if brush is None:
return
from .properties_paint_common import UnifiedPaintPanel
layout.prop(brush, "weight")
UnifiedPaintPanel.prop_unified_size(layout, context, brush, "size", slider=True, text="Radius")
UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True, text="Strength")
class TOPBAR_PT_redo(Panel):
bl_label = "Redo"
bl_space_type = 'TOPBAR'

View File

@ -1050,7 +1050,7 @@ class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
class VIEW3D_PT_tools_weightpaint_symmetry(Panel, View3DPaintPanel):
bl_category = "Tools"
bl_context = "weightpaint"
bl_context = ".weightpaint"
bl_options = {'DEFAULT_CLOSED'}
bl_label = "Symmetry"
@ -1063,7 +1063,7 @@ class VIEW3D_PT_tools_weightpaint_symmetry(Panel, View3DPaintPanel):
class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
bl_category = "Options"
bl_context = "weightpaint"
bl_context = ".weightpaint"
bl_label = "Options"
def draw(self, context):