Fix #133453: Canvas button cannot be enabled

This fixes an issue where the Canvas button is always disabled when
trying to use the experimental feature, Sculpt Texture Paint.

This bug was caused by the new Asset System since it changed how paint
tools work. Before, the UI would check the current tool being used and
determine if the Canvas button should be activated. With the new Asset
System, painting is done with modular brushes instead of tools, so
previous methods of checking tool properties have stopped working.

This is fixed by activating the Canvas button based on the properties
of the current brush. If the brush's type is either Paint or Smear,
then the Canvas button is activated.

Co-authored-by: T0MIS0N <50230774+T0MIS0N@users.noreply.github.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/133566
This commit is contained in:
T0MIS0N
2025-02-03 19:50:33 +01:00
committed by Sean Kim
parent 4e18ebee1b
commit a9c6889eb4
2 changed files with 17 additions and 1 deletions

View File

@@ -983,6 +983,9 @@ class VIEW3D_HT_header(Header):
canvas_source = tool_settings.paint_mode.canvas_source
icon = 'GROUP_VCOL' if canvas_source == 'COLOR_ATTRIBUTE' else canvas_source
row.popover(panel="VIEW3D_PT_slots_paint_canvas", icon=icon)
# TODO: Update this boolean condition so that the Canvas button is only active when
# the appropriate color types are selected in Solid mode, I.E. 'TEXTURE'
row.active = is_paint_tool
else:
row.popover(panel="VIEW3D_PT_slots_color_attributes", icon='GROUP_VCOL')

View File

@@ -607,7 +607,20 @@ class VIEW3D_PT_slots_paint_canvas(SelectPaintSlotHelper, View3DPanel, Panel):
tool = ToolSelectPanelHelper.tool_active_from_context(context)
if tool is None:
return False
return tool.use_paint_canvas
is_paint_tool = False
if tool.use_brushes:
brush = context.tool_settings.sculpt.brush
if brush:
is_paint_tool = brush.sculpt_tool in {'PAINT', 'SMEAR'}
else:
# TODO: The property use_paint_canvas doesn't work anymore since its associated
# C++ function 'rna_WorkSpaceTool_use_paint_canvas_get' passes in a nullptr for
# the bContext. This property should be fixed in the future, but will require
# some extensive refactoring. For now, use the workaround above.
is_paint_tool = tool.use_paint_canvas
return is_paint_tool
def get_mode_settings(self, context):
return context.tool_settings.paint_mode