Skip to content
Snippets Groups Projects
Commit 4d53ec76 authored by Ryan Inch's avatar Ryan Inch
Browse files

space_view3d_brush_menus: Improve brush icon support.

- Brushes menu: print terminal warning and use fallback icon
  if tool/mode isn't supported yet.
- Add icons for new sculpt mode tools to brushes menu.
parent c9fba919
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ bl_info = { ...@@ -6,7 +6,7 @@ bl_info = {
"name": "Dynamic Brush Menus", "name": "Dynamic Brush Menus",
"description": "Fast access to brushes & tools in Sculpt and Paint Modes", "description": "Fast access to brushes & tools in Sculpt and Paint Modes",
"author": "Ryan Inch (Imaginer)", "author": "Ryan Inch (Imaginer)",
"version": (1, 1, 9), "version": (1, 1, 10),
"blender": (2, 80, 0), "blender": (2, 80, 0),
"location": "Spacebar in Sculpt/Paint Modes", "location": "Spacebar in Sculpt/Paint Modes",
"warning": '', "warning": '',
......
...@@ -51,7 +51,7 @@ class BrushOptionsMenu(Menu): ...@@ -51,7 +51,7 @@ class BrushOptionsMenu(Menu):
def sculpt(self, mode, layout, context): def sculpt(self, mode, layout, context):
has_brush = utils_core.get_brush_link(context, types="brush") has_brush = utils_core.get_brush_link(context, types="brush")
icons = brushes.brush_icon[mode][has_brush.sculpt_tool] if \ icons = brushes.get_brush_icon(mode, has_brush.sculpt_tool) if \
has_brush else "BRUSH_DATA" has_brush else "BRUSH_DATA"
layout.row().menu("VIEW3D_MT_sv3_brushes_menu", layout.row().menu("VIEW3D_MT_sv3_brushes_menu",
...@@ -73,7 +73,7 @@ class BrushOptionsMenu(Menu): ...@@ -73,7 +73,7 @@ class BrushOptionsMenu(Menu):
def vw_paint(self, mode, layout, context): def vw_paint(self, mode, layout, context):
has_brush = utils_core.get_brush_link(context, types="brush") has_brush = utils_core.get_brush_link(context, types="brush")
icons = brushes.brush_icon[mode][has_brush.vertex_tool] if \ icons = brushes.get_brush_icon(mode, has_brush.vertex_tool) if \
has_brush else "BRUSH_DATA" has_brush else "BRUSH_DATA"
if mode == 'VERTEX_PAINT': if mode == 'VERTEX_PAINT':
...@@ -111,7 +111,7 @@ class BrushOptionsMenu(Menu): ...@@ -111,7 +111,7 @@ class BrushOptionsMenu(Menu):
toolsettings = context.tool_settings.image_paint toolsettings = context.tool_settings.image_paint
has_brush = utils_core.get_brush_link(context, types="brush") has_brush = utils_core.get_brush_link(context, types="brush")
icons = brushes.brush_icon[mode][has_brush.image_tool] if \ icons = brushes.get_brush_icon(mode, has_brush.image_tool) if \
has_brush else "BRUSH_DATA" has_brush else "BRUSH_DATA"
if context.image_paint_object and not toolsettings.detect_data(): if context.image_paint_object and not toolsettings.detect_data():
......
...@@ -32,10 +32,16 @@ brush_datapath = { ...@@ -32,10 +32,16 @@ brush_datapath = {
brush_icon = { brush_icon = {
'SCULPT': { 'SCULPT': {
"BLOB": 'BRUSH_BLOB', "BLOB": 'BRUSH_BLOB',
"BOUNDARY": 'BRUSH_GRAB',
"CLAY": 'BRUSH_CLAY', "CLAY": 'BRUSH_CLAY',
"CLAY_STRIPS": 'BRUSH_CLAY_STRIPS', "CLAY_STRIPS": 'BRUSH_CLAY_STRIPS',
"CLAY_THUMB": 'BRUSH_CLAY_STRIPS',
"CLOTH": 'BRUSH_SCULPT_DRAW',
"CREASE": 'BRUSH_CREASE', "CREASE": 'BRUSH_CREASE',
"DISPLACEMENT_ERASER": 'BRUSH_SCULPT_DRAW',
"DISPLACEMENT_SMEAR": 'BRUSH_SCULPT_DRAW',
"DRAW": 'BRUSH_SCULPT_DRAW', "DRAW": 'BRUSH_SCULPT_DRAW',
"DRAW_FACE_SETS": 'BRUSH_MASK',
"DRAW_SHARP": 'BRUSH_SCULPT_DRAW', "DRAW_SHARP": 'BRUSH_SCULPT_DRAW',
"ELASTIC_DEFORM": 'BRUSH_GRAB', "ELASTIC_DEFORM": 'BRUSH_GRAB',
"FILL": 'BRUSH_FILL', "FILL": 'BRUSH_FILL',
...@@ -44,7 +50,9 @@ brush_icon = { ...@@ -44,7 +50,9 @@ brush_icon = {
"INFLATE": 'BRUSH_INFLATE', "INFLATE": 'BRUSH_INFLATE',
"LAYER": 'BRUSH_LAYER', "LAYER": 'BRUSH_LAYER',
"MASK": 'BRUSH_MASK', "MASK": 'BRUSH_MASK',
"MULTIPLANE_SCRAPE": 'BRUSH_SCRAPE',
"NUDGE": 'BRUSH_NUDGE', "NUDGE": 'BRUSH_NUDGE',
"PAINT": 'BRUSH_SCULPT_DRAW',
"PINCH": 'BRUSH_PINCH', "PINCH": 'BRUSH_PINCH',
"POSE": 'BRUSH_GRAB', "POSE": 'BRUSH_GRAB',
"ROTATE": 'BRUSH_ROTATE', "ROTATE": 'BRUSH_ROTATE',
...@@ -52,21 +60,22 @@ brush_icon = { ...@@ -52,21 +60,22 @@ brush_icon = {
"SIMPLIFY": 'BRUSH_DATA', "SIMPLIFY": 'BRUSH_DATA',
"SMOOTH": 'BRUSH_SMOOTH', "SMOOTH": 'BRUSH_SMOOTH',
"SNAKE_HOOK": 'BRUSH_SNAKE_HOOK', "SNAKE_HOOK": 'BRUSH_SNAKE_HOOK',
"THUMB": 'BRUSH_THUMB' "THUMB": 'BRUSH_THUMB',
"TOPOLOGY": 'BRUSH_GRAB',
}, },
'VERTEX_PAINT': { 'VERTEX_PAINT': {
"AVERAGE": 'BRUSH_BLUR', "AVERAGE": 'BRUSH_BLUR',
"BLUR": 'BRUSH_BLUR', "BLUR": 'BRUSH_BLUR',
"DRAW": 'BRUSH_MIX', "DRAW": 'BRUSH_MIX',
"SMEAR": 'BRUSH_BLUR' "SMEAR": 'BRUSH_BLUR',
}, },
'WEIGHT_PAINT': { 'WEIGHT_PAINT': {
"AVERAGE": 'BRUSH_BLUR', "AVERAGE": 'BRUSH_BLUR',
"BLUR": 'BRUSH_BLUR', "BLUR": 'BRUSH_BLUR',
"DRAW": 'BRUSH_MIX', "DRAW": 'BRUSH_MIX',
"SMEAR": 'BRUSH_BLUR' "SMEAR": 'BRUSH_BLUR',
}, },
'TEXTURE_PAINT': { 'TEXTURE_PAINT': {
...@@ -75,10 +84,26 @@ brush_icon = { ...@@ -75,10 +84,26 @@ brush_icon = {
"FILL": 'BRUSH_TEXFILL', "FILL": 'BRUSH_TEXFILL',
"MASK": 'BRUSH_TEXMASK', "MASK": 'BRUSH_TEXMASK',
"SMEAR": 'BRUSH_SMEAR', "SMEAR": 'BRUSH_SMEAR',
"SOFTEN": 'BRUSH_SOFTEN' "SOFTEN": 'BRUSH_SOFTEN',
} },
} }
def get_brush_icon(mode, tool):
mode_icons = brush_icon.get(mode, None)
if mode_icons == None:
print(f"Warning: icons for mode {mode} aren't supported")
return 'BRUSH_DATA'
icon = mode_icons.get(tool, None)
if icon == None:
print(f"Warning: Could not find icon for tool {tool} in mode {mode}")
return 'BRUSH_DATA'
return icon
class BrushesMenu(Menu): class BrushesMenu(Menu):
bl_label = "Brush" bl_label = "Brush"
...@@ -120,7 +145,7 @@ class BrushesMenu(Menu): ...@@ -120,7 +145,7 @@ class BrushesMenu(Menu):
utils_core.menuprop( utils_core.menuprop(
column_flow.row(), item.name, column_flow.row(), item.name,
'bpy.data.brushes["%s"]' % item.name, 'bpy.data.brushes["%s"]' % item.name,
brush_datapath[mode], icon=brush_icon[mode][item.sculpt_tool], brush_datapath[mode], icon=get_brush_icon(mode, item.sculpt_tool),
disable=True, custom_disable_exp=(item.name, current_brush), disable=True, custom_disable_exp=(item.name, current_brush),
path=True path=True
) )
...@@ -131,7 +156,7 @@ class BrushesMenu(Menu): ...@@ -131,7 +156,7 @@ class BrushesMenu(Menu):
utils_core.menuprop( utils_core.menuprop(
column_flow.row(), item.name, column_flow.row(), item.name,
'bpy.data.brushes["%s"]' % item.name, 'bpy.data.brushes["%s"]' % item.name,
brush_datapath[mode], icon=brush_icon[mode][item.vertex_tool], brush_datapath[mode], icon=get_brush_icon(mode, item.vertex_tool),
disable=True, custom_disable_exp=(item.name, current_brush), disable=True, custom_disable_exp=(item.name, current_brush),
path=True path=True
) )
...@@ -142,7 +167,7 @@ class BrushesMenu(Menu): ...@@ -142,7 +167,7 @@ class BrushesMenu(Menu):
utils_core.menuprop( utils_core.menuprop(
column_flow.row(), item.name, column_flow.row(), item.name,
'bpy.data.brushes["%s"]' % item.name, 'bpy.data.brushes["%s"]' % item.name,
brush_datapath[mode], icon=brush_icon[mode][item.vertex_tool], brush_datapath[mode], icon=get_brush_icon(mode, item.weight_tool),
disable=True, custom_disable_exp=(item.name, current_brush), disable=True, custom_disable_exp=(item.name, current_brush),
path=True path=True
) )
...@@ -153,7 +178,7 @@ class BrushesMenu(Menu): ...@@ -153,7 +178,7 @@ class BrushesMenu(Menu):
utils_core.menuprop( utils_core.menuprop(
column_flow.row(), item.name, column_flow.row(), item.name,
'bpy.data.brushes["%s"]' % item.name, 'bpy.data.brushes["%s"]' % item.name,
brush_datapath[mode], icon=brush_icon[mode][item.image_tool], brush_datapath[mode], icon=get_brush_icon(mode, item.image_tool),
disable=True, custom_disable_exp=(item.name, current_brush), disable=True, custom_disable_exp=(item.name, current_brush),
path=True path=True
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment