diff options
Diffstat (limited to 'release/scripts/startup/bl_ui/space_view3d_toolbar.py')
-rw-r--r-- | release/scripts/startup/bl_ui/space_view3d_toolbar.py | 144 |
1 files changed, 100 insertions, 44 deletions
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 750e9b527f0..332933be68a 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -280,7 +280,7 @@ class TEXTURE_UL_texpaintslots(UIList): # mat = data if self.layout_type in {'DEFAULT', 'COMPACT'}: - layout.prop(item, "name", text="", emboss=False, icon_value=icon) + layout.prop(item, "name", text="", emboss=False, icon_value=item.icon_value) elif self.layout_type == 'GRID': layout.alignment = 'CENTER' layout.label(text="") @@ -459,15 +459,11 @@ class VIEW3D_MT_tools_projectpaint_uvlayer(Menu): props.value = i -class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel): +class SelectPaintSlotHelper: bl_category = "Tool" - bl_context = ".imagepaint" # dot on purpose (access from topbar) - bl_label = "Texture Slots" - @classmethod - def poll(cls, context): - brush = context.tool_settings.image_paint.brush - return (brush is not None and context.active_object is not None) + canvas_source_attr_name = "canvas_source" + canvas_image_attr_name = "canvas_image" def draw(self, context): layout = self.layout @@ -475,51 +471,66 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel): layout.use_property_decorate = False settings = context.tool_settings.image_paint + mode_settings = self.get_mode_settings(context) ob = context.active_object - layout.prop(settings, "mode", text="Mode") + layout.prop(mode_settings, self.canvas_source_attr_name, text="Mode") layout.separator() - if settings.mode == 'MATERIAL': - if len(ob.material_slots) > 1: - layout.template_list("MATERIAL_UL_matslots", "layers", - ob, "material_slots", - ob, "active_material_index", rows=2) - mat = ob.active_material - if mat and mat.texture_paint_images: - row = layout.row() - row.template_list("TEXTURE_UL_texpaintslots", "", - mat, "texture_paint_images", - mat, "paint_active_slot", rows=2) - - if mat.texture_paint_slots: - slot = mat.texture_paint_slots[mat.paint_active_slot] + have_image = False + + match getattr(mode_settings, self.canvas_source_attr_name): + case 'MATERIAL': + if len(ob.material_slots) > 1: + layout.template_list("MATERIAL_UL_matslots", "layers", + ob, "material_slots", + ob, "active_material_index", rows=2) + mat = ob.active_material + if mat and mat.texture_paint_images: + row = layout.row() + row.template_list("TEXTURE_UL_texpaintslots", "", + mat, "texture_paint_slots", + mat, "paint_active_slot", rows=2) + + if mat.texture_paint_slots: + slot = mat.texture_paint_slots[mat.paint_active_slot] + else: + slot = None + + have_image = slot is not None else: - slot = None + row = layout.row() - have_image = slot is not None - else: - row = layout.row() - - box = row.box() - box.label(text="No Textures") - have_image = False + box = row.box() + box.label(text="No Textures") - sub = row.column(align=True) - sub.operator_menu_enum("paint.add_texture_paint_slot", "type", icon='ADD', text="") + sub = row.column(align=True) + sub.operator_menu_enum("paint.add_texture_paint_slot", "type", icon='ADD', text="") - elif settings.mode == 'IMAGE': - mesh = ob.data - uv_text = mesh.uv_layers.active.name if mesh.uv_layers.active else "" - layout.template_ID(settings, "canvas", new="image.new", open="image.open") - if settings.missing_uvs: - layout.operator("paint.add_simple_uvs", icon='ADD', text="Add UVs") - else: - layout.menu("VIEW3D_MT_tools_projectpaint_uvlayer", text=uv_text, translate=False) - have_image = settings.canvas is not None - - layout.prop(settings, "interpolation", text="") + case 'IMAGE': + mesh = ob.data + uv_text = mesh.uv_layers.active.name if mesh.uv_layers.active else "" + layout.template_ID(mode_settings, self.canvas_image_attr_name, new="image.new", open="image.open") + if settings.missing_uvs: + layout.operator("paint.add_simple_uvs", icon='ADD', text="Add UVs") + else: + layout.menu("VIEW3D_MT_tools_projectpaint_uvlayer", text=uv_text, translate=False) + have_image = getattr(settings, self.canvas_image_attr_name) is not None + + self.draw_image_interpolation(layout=layout, mode_settings=mode_settings) + + case 'COLOR_ATTRIBUTE': + mesh = ob.data + layout.template_list( + "MESH_UL_color_attributes_selector", + "color_attributes", + mesh, + "color_attributes", + mesh.color_attributes, + "active_color_index", + rows=3, + ) if settings.missing_uvs: layout.separator() @@ -531,6 +542,50 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel): layout.operator("image.save_all_modified", text="Save All Images", icon='FILE_TICK') +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" + canvas_image_attr_name = "canvas" + + @classmethod + def poll(cls, context): + brush = context.tool_settings.image_paint.brush + return (brush is not None and context.active_object is not None) + + def get_mode_settings(self, context): + return context.tool_settings.image_paint + + def draw_image_interpolation(self, layout, mode_settings): + layout.prop(mode_settings, "interpolation", text="") + + + +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 + 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: + return False + return tool.use_paint_canvas + + def get_mode_settings(self, context): + return context.tool_settings.paint_mode + + def draw_image_interpolation(self, **kwargs): + pass + + class VIEW3D_PT_mask(View3DPanel, Panel): bl_category = "Tool" bl_context = ".imagepaint" # dot on purpose (access from topbar) @@ -2232,6 +2287,7 @@ classes = ( VIEW3D_PT_tools_posemode_options, VIEW3D_PT_slots_projectpaint, + VIEW3D_PT_slots_paint_canvas, VIEW3D_PT_tools_brush_select, VIEW3D_PT_tools_brush_settings, VIEW3D_PT_tools_brush_color, |