de-duplicate paint parent class, added new py module for common paint UI classes/funcs --- since we'll likely have more of these.
This commit is contained in:
61
release/scripts/startup/bl_ui/properties_paint_common.py
Normal file
61
release/scripts/startup/bl_ui/properties_paint_common.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
#
|
||||||
|
# ##### END GPL LICENSE BLOCK #####
|
||||||
|
|
||||||
|
# <pep8 compliant>
|
||||||
|
|
||||||
|
|
||||||
|
class UnifiedPaintPanel():
|
||||||
|
# subclass must set
|
||||||
|
# bl_space_type = 'IMAGE_EDITOR'
|
||||||
|
# bl_region_type = 'UI'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def paint_settings(context):
|
||||||
|
toolsettings = context.tool_settings
|
||||||
|
|
||||||
|
if context.sculpt_object:
|
||||||
|
return toolsettings.sculpt
|
||||||
|
elif context.vertex_paint_object:
|
||||||
|
return toolsettings.vertex_paint
|
||||||
|
elif context.weight_paint_object:
|
||||||
|
return toolsettings.weight_paint
|
||||||
|
elif context.image_paint_object:
|
||||||
|
return toolsettings.image_paint
|
||||||
|
elif context.particle_edit_object:
|
||||||
|
return toolsettings.particle_edit
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def unified_paint_settings(parent, context):
|
||||||
|
ups = context.tool_settings.unified_paint_settings
|
||||||
|
parent.label(text="Unified Settings:")
|
||||||
|
parent.prop(ups, "use_unified_size", text="Size")
|
||||||
|
parent.prop(ups, "use_unified_strength", text="Strength")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def prop_unified_size(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
|
||||||
|
ups = context.tool_settings.unified_paint_settings
|
||||||
|
ptr = ups if ups.use_unified_size else brush
|
||||||
|
parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def prop_unified_strength(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
|
||||||
|
ups = context.tool_settings.unified_paint_settings
|
||||||
|
ptr = ups if ups.use_unified_strength else brush
|
||||||
|
parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
|
@@ -19,48 +19,12 @@
|
|||||||
# <pep8 compliant>
|
# <pep8 compliant>
|
||||||
import bpy
|
import bpy
|
||||||
from bpy.types import Header, Menu, Panel
|
from bpy.types import Header, Menu, Panel
|
||||||
|
from .properties_paint_common import UnifiedPaintPanel
|
||||||
|
|
||||||
class PaintPanel():
|
class ImagePaintPanel(UnifiedPaintPanel):
|
||||||
bl_space_type = 'IMAGE_EDITOR'
|
bl_space_type = 'IMAGE_EDITOR'
|
||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def paint_settings(context):
|
|
||||||
toolsettings = context.tool_settings
|
|
||||||
|
|
||||||
if context.sculpt_object:
|
|
||||||
return toolsettings.sculpt
|
|
||||||
elif context.vertex_paint_object:
|
|
||||||
return toolsettings.vertex_paint
|
|
||||||
elif context.weight_paint_object:
|
|
||||||
return toolsettings.weight_paint
|
|
||||||
elif context.image_paint_object:
|
|
||||||
return toolsettings.image_paint
|
|
||||||
elif context.particle_edit_object:
|
|
||||||
return toolsettings.particle_edit
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def unified_paint_settings(parent, context):
|
|
||||||
ups = context.tool_settings.unified_paint_settings
|
|
||||||
parent.label(text="Unified Settings:")
|
|
||||||
parent.prop(ups, "use_unified_size", text="Size")
|
|
||||||
parent.prop(ups, "use_unified_strength", text="Strength")
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def prop_unified_size(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
|
|
||||||
ups = context.tool_settings.unified_paint_settings
|
|
||||||
ptr = ups if ups.use_unified_size else brush
|
|
||||||
parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def prop_unified_strength(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
|
|
||||||
ups = context.tool_settings.unified_paint_settings
|
|
||||||
ptr = ups if ups.use_unified_strength else brush
|
|
||||||
parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BrushButtonsPanel():
|
class BrushButtonsPanel():
|
||||||
bl_space_type = 'IMAGE_EDITOR'
|
bl_space_type = 'IMAGE_EDITOR'
|
||||||
@@ -682,7 +646,7 @@ class IMAGE_PT_view_properties(Panel):
|
|||||||
sub.row().prop(uvedit, "draw_stretch_type", expand=True)
|
sub.row().prop(uvedit, "draw_stretch_type", expand=True)
|
||||||
|
|
||||||
|
|
||||||
class IMAGE_PT_paint(Panel, PaintPanel):
|
class IMAGE_PT_paint(Panel, ImagePaintPanel):
|
||||||
bl_space_type = 'IMAGE_EDITOR'
|
bl_space_type = 'IMAGE_EDITOR'
|
||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
bl_label = "Paint"
|
bl_label = "Paint"
|
||||||
@@ -834,7 +798,7 @@ class IMAGE_UV_sculpt_curve(bpy.types.Panel):
|
|||||||
row.operator("brush.curve_preset", icon="NOCURVE", text="").shape = 'MAX'
|
row.operator("brush.curve_preset", icon="NOCURVE", text="").shape = 'MAX'
|
||||||
|
|
||||||
|
|
||||||
class IMAGE_UV_sculpt(bpy.types.Panel, PaintPanel):
|
class IMAGE_UV_sculpt(Panel, ImagePaintPanel):
|
||||||
bl_space_type = 'IMAGE_EDITOR'
|
bl_space_type = 'IMAGE_EDITOR'
|
||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
bl_label = "UV Sculpt"
|
bl_label = "UV Sculpt"
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
# <pep8 compliant>
|
# <pep8 compliant>
|
||||||
import bpy
|
import bpy
|
||||||
from bpy.types import Menu, Panel
|
from bpy.types import Menu, Panel
|
||||||
|
from .properties_paint_common import UnifiedPaintPanel
|
||||||
|
|
||||||
|
|
||||||
class View3DPanel():
|
class View3DPanel():
|
||||||
@@ -447,48 +448,12 @@ class VIEW3D_PT_tools_posemode_options(View3DPanel, Panel):
|
|||||||
# ********** default tools for paint modes ****************
|
# ********** default tools for paint modes ****************
|
||||||
|
|
||||||
|
|
||||||
class PaintPanel():
|
class View3DPaintPanel(UnifiedPaintPanel):
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
bl_region_type = 'TOOLS'
|
bl_region_type = 'TOOLS'
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def paint_settings(context):
|
|
||||||
toolsettings = context.tool_settings
|
|
||||||
|
|
||||||
if context.sculpt_object:
|
class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
|
||||||
return toolsettings.sculpt
|
|
||||||
elif context.vertex_paint_object:
|
|
||||||
return toolsettings.vertex_paint
|
|
||||||
elif context.weight_paint_object:
|
|
||||||
return toolsettings.weight_paint
|
|
||||||
elif context.image_paint_object:
|
|
||||||
return toolsettings.image_paint
|
|
||||||
elif context.particle_edit_object:
|
|
||||||
return toolsettings.particle_edit
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def unified_paint_settings(parent, context):
|
|
||||||
ups = context.tool_settings.unified_paint_settings
|
|
||||||
parent.label(text="Unified Settings:")
|
|
||||||
parent.prop(ups, "use_unified_size", text="Size")
|
|
||||||
parent.prop(ups, "use_unified_strength", text="Strength")
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def prop_unified_size(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
|
|
||||||
ups = context.tool_settings.unified_paint_settings
|
|
||||||
ptr = ups if ups.use_unified_size else brush
|
|
||||||
parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def prop_unified_strength(parent, context, brush, prop_name, icon='NONE', text="", slider=False):
|
|
||||||
ups = context.tool_settings.unified_paint_settings
|
|
||||||
ptr = ups if ups.use_unified_strength else brush
|
|
||||||
parent.prop(ptr, prop_name, icon=icon, text=text, slider=slider)
|
|
||||||
|
|
||||||
|
|
||||||
class VIEW3D_PT_tools_brush(PaintPanel, Panel):
|
|
||||||
bl_label = "Brush"
|
bl_label = "Brush"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -715,7 +680,7 @@ class VIEW3D_PT_tools_brush(PaintPanel, Panel):
|
|||||||
#row.prop(brush, "use_pressure_jitter", toggle=True, text="")
|
#row.prop(brush, "use_pressure_jitter", toggle=True, text="")
|
||||||
|
|
||||||
|
|
||||||
class VIEW3D_PT_tools_brush_texture(PaintPanel, Panel):
|
class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
|
||||||
bl_label = "Texture"
|
bl_label = "Texture"
|
||||||
bl_options = {'DEFAULT_CLOSED'}
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
@@ -794,7 +759,7 @@ class VIEW3D_PT_tools_brush_texture(PaintPanel, Panel):
|
|||||||
sub.prop(brush, "texture_overlay_alpha", text="Alpha")
|
sub.prop(brush, "texture_overlay_alpha", text="Alpha")
|
||||||
|
|
||||||
|
|
||||||
class VIEW3D_PT_tools_brush_tool(PaintPanel, Panel):
|
class VIEW3D_PT_tools_brush_tool(Panel, View3DPaintPanel):
|
||||||
bl_label = "Tool"
|
bl_label = "Tool"
|
||||||
bl_options = {'DEFAULT_CLOSED'}
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
@@ -828,7 +793,7 @@ class VIEW3D_PT_tools_brush_tool(PaintPanel, Panel):
|
|||||||
row.prop(brush, "use_paint_image", text="", icon='TPAINT_HLT')
|
row.prop(brush, "use_paint_image", text="", icon='TPAINT_HLT')
|
||||||
|
|
||||||
|
|
||||||
class VIEW3D_PT_tools_brush_stroke(PaintPanel, Panel):
|
class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
|
||||||
bl_label = "Stroke"
|
bl_label = "Stroke"
|
||||||
bl_options = {'DEFAULT_CLOSED'}
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
@@ -920,7 +885,7 @@ class VIEW3D_PT_tools_brush_stroke(PaintPanel, Panel):
|
|||||||
# row.prop(brush, "use_pressure_spacing", toggle=True, text="")
|
# row.prop(brush, "use_pressure_spacing", toggle=True, text="")
|
||||||
|
|
||||||
|
|
||||||
class VIEW3D_PT_tools_brush_curve(PaintPanel, Panel):
|
class VIEW3D_PT_tools_brush_curve(Panel, View3DPaintPanel):
|
||||||
bl_label = "Curve"
|
bl_label = "Curve"
|
||||||
bl_options = {'DEFAULT_CLOSED'}
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
@@ -947,7 +912,7 @@ class VIEW3D_PT_tools_brush_curve(PaintPanel, Panel):
|
|||||||
row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
|
row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
|
||||||
|
|
||||||
|
|
||||||
class VIEW3D_PT_sculpt_options(PaintPanel, Panel):
|
class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
|
||||||
bl_label = "Options"
|
bl_label = "Options"
|
||||||
bl_options = {'DEFAULT_CLOSED'}
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
@@ -975,7 +940,7 @@ class VIEW3D_PT_sculpt_options(PaintPanel, Panel):
|
|||||||
self.unified_paint_settings(layout, context)
|
self.unified_paint_settings(layout, context)
|
||||||
|
|
||||||
|
|
||||||
class VIEW3D_PT_sculpt_symmetry(PaintPanel, Panel):
|
class VIEW3D_PT_sculpt_symmetry(Panel, View3DPaintPanel):
|
||||||
bl_label = "Symmetry"
|
bl_label = "Symmetry"
|
||||||
bl_options = {'DEFAULT_CLOSED'}
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
@@ -999,7 +964,7 @@ class VIEW3D_PT_sculpt_symmetry(PaintPanel, Panel):
|
|||||||
layout.prop(sculpt, "use_symmetry_feather", text="Feather")
|
layout.prop(sculpt, "use_symmetry_feather", text="Feather")
|
||||||
|
|
||||||
|
|
||||||
class VIEW3D_PT_tools_brush_appearance(PaintPanel, Panel):
|
class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
|
||||||
bl_label = "Appearance"
|
bl_label = "Appearance"
|
||||||
bl_options = {'DEFAULT_CLOSED'}
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
@@ -1061,7 +1026,7 @@ class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
|
|||||||
col.operator("object.vertex_group_fix", text="Fix Deforms")
|
col.operator("object.vertex_group_fix", text="Fix Deforms")
|
||||||
|
|
||||||
|
|
||||||
class VIEW3D_PT_tools_weightpaint_options(PaintPanel, Panel):
|
class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
|
||||||
bl_context = "weightpaint"
|
bl_context = "weightpaint"
|
||||||
bl_label = "Options"
|
bl_label = "Options"
|
||||||
|
|
||||||
@@ -1097,7 +1062,7 @@ class VIEW3D_PT_tools_weightpaint_options(PaintPanel, Panel):
|
|||||||
# ********** default tools for vertex-paint ****************
|
# ********** default tools for vertex-paint ****************
|
||||||
|
|
||||||
|
|
||||||
class VIEW3D_PT_tools_vertexpaint(PaintPanel, Panel):
|
class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
|
||||||
bl_context = "vertexpaint"
|
bl_context = "vertexpaint"
|
||||||
bl_label = "Options"
|
bl_label = "Options"
|
||||||
|
|
||||||
@@ -1191,7 +1156,7 @@ class VIEW3D_PT_tools_projectpaint(View3DPanel, Panel):
|
|||||||
col.operator("image.save_dirty", text="Save All Edited")
|
col.operator("image.save_dirty", text="Save All Edited")
|
||||||
|
|
||||||
|
|
||||||
class VIEW3D_PT_imagepaint_options(PaintPanel):
|
class VIEW3D_PT_imagepaint_options(View3DPaintPanel):
|
||||||
bl_label = "Options"
|
bl_label = "Options"
|
||||||
bl_options = {'DEFAULT_CLOSED'}
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user