UI: Add canvas picker to paint modes in 3D Viewport #111756
|
@ -883,12 +883,51 @@ class VIEW3D_HT_header(Header):
|
|||
text="",
|
||||
icon='MOD_MASK',
|
||||
)
|
||||
|
||||
elif object_mode == 'SCULPT':
|
||||
# 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 = 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",
|
||||
text="",
|
||||
icon='MOD_MASK',
|
||||
)
|
||||
|
||||
elif object_mode == 'VERTEX_PAINT':
|
||||
row = layout.row()
|
||||
row.ui_units_x = 6
|
||||
row.popover(panel="VIEW3D_PT_slots_color_attributes", icon="GROUP_VCOL")
|
||||
|
||||
elif object_mode == 'WEIGHT_PAINT':
|
||||
row = layout.row()
|
||||
row.ui_units_x = 6
|
||||
row.popover(panel="VIEW3D_PT_slots_vertex_groups", icon="GROUP_VERTEX")
|
||||
|
||||
elif object_mode == 'TEXTURE_PAINT':
|
||||
tool_mode = tool_settings.image_paint.mode
|
||||
icon = 'MATERIAL' if tool_mode == 'MATERIAL' else 'IMAGE_DATA'
|
||||
|
||||
row = layout.row()
|
||||
row.ui_units_x = 9
|
||||
row.popover(panel="VIEW3D_PT_slots_projectpaint", icon=icon)
|
||||
row.popover(panel="VIEW3D_PT_mask", icon="MOD_MASK", text="")
|
||||
else:
|
||||
# Transform settings depending on tool header visibility
|
||||
VIEW3D_HT_header.draw_xform_template(layout, context)
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
from bpy.types import Menu, Panel, UIList, WindowManager
|
||||
from bpy.app.translations import contexts as i18n_contexts
|
||||
from bpy.app.translations import (
|
||||
pgettext_iface as iface_,
|
||||
contexts as i18n_contexts,
|
||||
)
|
||||
|
||||
from bl_ui.properties_grease_pencil_common import (
|
||||
GreasePencilSculptAdvancedPanel,
|
||||
GreasePencilDisplayPanel,
|
||||
|
@ -456,7 +460,8 @@ class VIEW3D_MT_tools_projectpaint_uvlayer(Menu):
|
|||
|
||||
|
||||
class SelectPaintSlotHelper:
|
||||
bl_category = "Tool"
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'HEADER'
|
||||
|
||||
canvas_source_attr_name = "canvas_source"
|
||||
canvas_image_attr_name = "canvas_image"
|
||||
|
@ -550,8 +555,6 @@ class SelectPaintSlotHelper:
|
|||
|
||||
|
||||
class VIEW3D_PT_slots_projectpaint(SelectPaintSlotHelper, View3DPanel, Panel):
|
||||
bl_category = "Tool"
|
||||
bl_context = ".imagepaint" # dot on purpose (access from topbar)
|
||||
bl_label = "Texture Slots"
|
||||
|
||||
canvas_source_attr_name = "mode"
|
||||
|
@ -568,10 +571,23 @@ class VIEW3D_PT_slots_projectpaint(SelectPaintSlotHelper, View3DPanel, Panel):
|
|||
def draw_image_interpolation(self, layout, mode_settings):
|
||||
layout.prop(mode_settings, "interpolation", text="")
|
||||
|
||||
def draw_header(self, context):
|
||||
tool = context.tool_settings.image_paint
|
||||
ob = context.object
|
||||
mat = ob.active_material
|
||||
|
||||
label = iface_("Texture Slots")
|
||||
|
||||
if tool.mode == 'MATERIAL':
|
||||
if mat and mat.texture_paint_images and mat.texture_paint_slots:
|
||||
label = mat.texture_paint_slots[mat.paint_active_slot].name
|
||||
elif tool.canvas:
|
||||
label = tool.canvas.name
|
||||
|
||||
self.bl_label = label
|
||||
|
||||
|
||||
class VIEW3D_PT_slots_paint_canvas(SelectPaintSlotHelper, View3DPanel, Panel):
|
||||
bl_category = "Tool"
|
||||
bl_context = ".sculpt_mode" # dot on purpose (access from topbar)
|
||||
bl_label = "Canvas"
|
||||
|
||||
@classmethod
|
||||
|
@ -591,6 +607,108 @@ class VIEW3D_PT_slots_paint_canvas(SelectPaintSlotHelper, View3DPanel, Panel):
|
|||
def draw_image_interpolation(self, **kwargs):
|
||||
pass
|
||||
|
||||
def draw_header(self, context):
|
||||
paint = context.tool_settings.paint_mode
|
||||
ob = context.object
|
||||
me = context.object.data
|
||||
mat = ob.active_material
|
||||
|
||||
label = iface_("Canvas")
|
||||
|
||||
if paint.canvas_source == 'MATERIAL':
|
||||
if mat and mat.texture_paint_images and mat.texture_paint_slots:
|
||||
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 Attribute"))
|
||||
elif paint.canvas_image:
|
||||
label = paint.canvas_image.name
|
||||
|
||||
self.bl_label = label
|
||||
|
||||
|
||||
class VIEW3D_PT_slots_color_attributes(Panel):
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'HEADER'
|
||||
bl_label = "Color Attributes"
|
||||
bl_ui_units_x = 12
|
||||
|
||||
def draw_header(self, context):
|
||||
me = context.object.data
|
||||
self.bl_label = (
|
||||
iface_("%s") % (me.color_attributes.active_color.name) if me.color_attributes.active_color else
|
||||
iface_("Color Attributes")
|
||||
)
|
||||
|
||||
def draw(self, context):
|
||||
mesh = context.object.data
|
||||
|
||||
layout = self.layout
|
||||
row = layout.row()
|
||||
|
||||
col = row.column()
|
||||
col.template_list(
|
||||
"MESH_UL_color_attributes",
|
||||
"color_attributes",
|
||||
mesh,
|
||||
"color_attributes",
|
||||
mesh.color_attributes,
|
||||
"active_color_index",
|
||||
rows=3,
|
||||
)
|
||||
|
||||
col = row.column(align=True)
|
||||
col.operator("geometry.color_attribute_add", icon='ADD', text="")
|
||||
col.operator("geometry.color_attribute_remove", icon='REMOVE', text="")
|
||||
|
||||
col.separator()
|
||||
|
||||
col.menu("MESH_MT_color_attribute_context_menu", icon='DOWNARROW_HLT', text="")
|
||||
|
||||
|
||||
class VIEW3D_PT_slots_vertex_groups(Panel):
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'HEADER'
|
||||
bl_label = "Vertex Groups"
|
||||
bl_ui_units_x = 12
|
||||
|
||||
def draw_header(self, context):
|
||||
ob = context.object
|
||||
self.bl_label = (
|
||||
iface_("%s") % (ob.vertex_groups.active.name) if ob.vertex_groups else
|
||||
iface_("Vertex Groups")
|
||||
)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
row = layout.row()
|
||||
col = row.column()
|
||||
|
||||
ob = context.object
|
||||
group = ob.vertex_groups.active
|
||||
|
||||
rows = 3
|
||||
if group:
|
||||
rows = 5
|
||||
|
||||
row = layout.row()
|
||||
row.template_list("MESH_UL_vgroups", "", ob, "vertex_groups", ob.vertex_groups, "active_index", rows=rows)
|
||||
|
||||
col = row.column(align=True)
|
||||
|
||||
col.operator("object.vertex_group_add", icon='ADD', text="")
|
||||
props = col.operator("object.vertex_group_remove", icon='REMOVE', text="")
|
||||
props.all_unlocked = props.all = False
|
||||
|
||||
col.separator()
|
||||
|
||||
col.menu("MESH_MT_vertex_group_context_menu", icon='DOWNARROW_HLT', text="")
|
||||
|
||||
if group:
|
||||
col.separator()
|
||||
col.operator("object.vertex_group_move", icon='TRIA_UP', text="").direction = 'UP'
|
||||
col.operator("object.vertex_group_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
|
||||
|
||||
|
||||
class VIEW3D_PT_mask(View3DPanel, Panel):
|
||||
bl_category = "Tool"
|
||||
|
@ -2380,6 +2498,8 @@ classes = (
|
|||
|
||||
VIEW3D_PT_slots_projectpaint,
|
||||
VIEW3D_PT_slots_paint_canvas,
|
||||
VIEW3D_PT_slots_color_attributes,
|
||||
VIEW3D_PT_slots_vertex_groups,
|
||||
VIEW3D_PT_tools_brush_select,
|
||||
VIEW3D_PT_tools_brush_settings,
|
||||
VIEW3D_PT_tools_brush_color,
|
||||
|
|
Loading…
Reference in New Issue