UI: Add canvas picker to paint modes in 3D Viewport #111756

Merged
Pablo Vazquez merged 7 commits from pablovazquez/blender:ui-viewport-canvas-selector into main 2023-09-06 16:21:19 +02:00
2 changed files with 20 additions and 5 deletions
Showing only changes of commit 4b0d3c475b - Show all commits

View File

@ -885,12 +885,24 @@ class VIEW3D_HT_header(Header):
)
elif object_mode == 'SCULPT':
canvas_source = tool_settings.paint_mode.canvas_source
icon = 'GROUP_VCOL' if canvas_source == 'COLOR_ATTRIBUTE' else canvas_source
# If the active tool supports it, show the canvas selector popover.
from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
tool = ToolSelectPanelHelper.tool_active_from_context(context)
is_paint_tool = tool and tool.use_paint_canvas
shading = VIEW3D_PT_shading.get_shading(context)
color_type = shading.color_type
row = layout.row()
row.ui_units_x = 7
row.popover(panel="VIEW3D_PT_slots_paint_canvas", icon=icon)
row.ui_units_x = 6
row.active = is_paint_tool and color_type == 'VERTEX'
if context.preferences.experimental.use_sculpt_texture_paint:
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)
else:
row.popover(panel="VIEW3D_PT_slots_color_attributes", icon="GROUP_VCOL")
layout.popover(
panel="VIEW3D_PT_sculpt_automasking",

View File

@ -592,6 +592,9 @@ class VIEW3D_PT_slots_paint_canvas(SelectPaintSlotHelper, View3DPanel, Panel):
@classmethod
def poll(cls, context):
if not context.preferences.experimental.use_sculpt_texture_paint:
return False
from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
tool = ToolSelectPanelHelper.tool_active_from_context(context)
if tool is None:
@ -617,7 +620,7 @@ class VIEW3D_PT_slots_paint_canvas(SelectPaintSlotHelper, View3DPanel, Panel):
label = mat.texture_paint_slots[mat.paint_active_slot].name
elif paint.canvas_source == 'COLOR_ATTRIBUTE':
label = (me.color_attributes.active_color.name if me.color_attributes.active_color
else iface_("Color Attributes"))
else iface_("Color Attribute"))
elif paint.canvas_image:
label = paint.canvas_image.name