Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormeta-androcto <meta.androcto1@gmail.com>2017-07-20 09:25:36 +0300
committermeta-androcto <meta.androcto1@gmail.com>2017-07-20 09:25:36 +0300
commite70b309dac3f6aae5cb42a7a90ce0f407350060f (patch)
tree7bdbebb5f7f0137425a5c025eb162ccdcece9504 /space_view3d_brush_menus/texture_menu.py
parent766887ce0c1f46dfcf0ca47df27b9f638bb0952e (diff)
brush menus: bug fixes/update by imaginer T52124
Diffstat (limited to 'space_view3d_brush_menus/texture_menu.py')
-rw-r--r--space_view3d_brush_menus/texture_menu.py259
1 files changed, 150 insertions, 109 deletions
diff --git a/space_view3d_brush_menus/texture_menu.py b/space_view3d_brush_menus/texture_menu.py
index d961410b..31125bbb 100644
--- a/space_view3d_brush_menus/texture_menu.py
+++ b/space_view3d_brush_menus/texture_menu.py
@@ -12,142 +12,161 @@ class TextureMenu(Menu):
@classmethod
def poll(self, context):
return utils_core.get_mode() in (
- utils_core.sculpt,
- utils_core.vertex_paint,
- utils_core.texture_paint
+ 'SCULPT',
+ 'VERTEX_PAINT',
+ 'TEXTURE_PAINT'
)
def draw(self, context):
- menu = utils_core.Menu(self)
+ layout = self.layout
- if utils_core.get_mode() == utils_core.sculpt:
- self.sculpt(menu, context)
+ if utils_core.get_mode() == 'SCULPT':
+ self.sculpt(layout, context)
- elif utils_core.get_mode() == utils_core.vertex_paint:
- self.vertpaint(menu, context)
+ elif utils_core.get_mode() == 'VERTEX_PAINT':
+ self.vertpaint(layout, context)
else:
- self.texpaint(menu, context)
+ self.texpaint(layout, context)
- def sculpt(self, menu, context):
+ def sculpt(self, layout, context):
has_brush = utils_core.get_brush_link(context, types="brush")
tex_slot = has_brush.texture_slot if has_brush else None
# Menus
- menu.add_item().menu(Textures.bl_idname)
- menu.add_item().menu(TextureMapMode.bl_idname)
- menu.add_item().separator()
+ layout.row().menu(Textures.bl_idname)
+ layout.row().menu(TextureMapMode.bl_idname)
+ layout.row().separator()
# Checkboxes
if tex_slot:
if tex_slot.map_mode != '3D':
- if tex_slot.map_mode in ['RANDOM', 'VIEW_PLANE', 'AREA_PLANE']:
- menu.add_item().prop(tex_slot, "use_rake", toggle=True)
- menu.add_item().prop(tex_slot, "use_random", toggle=True)
+ if tex_slot.map_mode in ('RANDOM', 'VIEW_PLANE', 'AREA_PLANE'):
+ layout.row().prop(tex_slot, "use_rake", toggle=True)
+ layout.row().prop(tex_slot, "use_random", toggle=True)
# Sliders
- menu.add_item().prop(tex_slot, "angle",
- text=utils_core.PIW + "Angle", slider=True)
+ layout.row().prop(tex_slot, "angle",
+ text=utils_core.PIW + "Angle", slider=True)
- if tex_slot.tex_paint_map_mode in ['RANDOM', 'VIEW_PLANE'] and tex_slot.use_random:
- menu.add_item().prop(tex_slot, "random_angle",
- text=utils_core.PIW + "Random Angle", slider=True)
+ if tex_slot.tex_paint_map_mode in ('RANDOM', 'VIEW_PLANE') and tex_slot.use_random:
+ layout.row().prop(tex_slot, "random_angle",
+ text=utils_core.PIW + "Random Angle", slider=True)
# Operator
if tex_slot.tex_paint_map_mode == 'STENCIL':
- menu.add_item().operator("brush.stencil_reset_transform")
+ if has_brush.texture and has_brush.texture.type == 'IMAGE':
+ layout.row().operator("brush.stencil_fit_image_aspect")
+
+ layout.row().operator("brush.stencil_reset_transform")
+
else:
- menu.add_item().label("No Texture Slot available", icon="INFO")
+ layout.row().label("No Texture Slot available", icon="INFO")
- def vertpaint(self, menu, context):
+ def vertpaint(self, layout, context):
has_brush = utils_core.get_brush_link(context, types="brush")
tex_slot = has_brush.texture_slot if has_brush else None
# Menus
- menu.add_item().menu(Textures.bl_idname)
- menu.add_item().menu(TextureMapMode.bl_idname)
+ layout.row().menu(Textures.bl_idname)
+ layout.row().menu(TextureMapMode.bl_idname)
# Checkboxes
- if tex_slot and tex_slot.tex_paint_map_mode != '3D':
+ if tex_slot:
+ if tex_slot.tex_paint_map_mode != '3D':
+ if tex_slot.tex_paint_map_mode in ('RANDOM', 'VIEW_PLANE'):
+ layout.row().prop(tex_slot, "use_rake", toggle=True)
+ layout.row().prop(tex_slot, "use_random", toggle=True)
- if tex_slot.tex_paint_map_mode in ['RANDOM', 'VIEW_PLANE']:
- menu.add_item().prop(tex_slot, "use_rake", toggle=True)
- menu.add_item().prop(tex_slot, "use_random", toggle=True)
+ # Sliders
+ layout.row().prop(tex_slot, "angle",
+ text=utils_core.PIW + "Angle", slider=True)
- # Sliders
- menu.add_item().prop(tex_slot, "angle",
- text=utils_core.PIW + "Angle", slider=True)
+ if tex_slot.tex_paint_map_mode in ('RANDOM', 'VIEW_PLANE') and tex_slot.use_random:
+ layout.row().prop(tex_slot, "random_angle",
+ text=utils_core.PIW + "Random Angle", slider=True)
- if tex_slot.tex_paint_map_mode in ['RANDOM', 'VIEW_PLANE'] and tex_slot.use_random:
- menu.add_item().prop(tex_slot, "random_angle",
- text=utils_core.PIW + "Random Angle", slider=True)
+ # Operator
+ if tex_slot.tex_paint_map_mode == 'STENCIL':
+ if has_brush.texture and has_brush.texture.type == 'IMAGE':
+ layout.row().operator("brush.stencil_fit_image_aspect")
+
+ layout.row().operator("brush.stencil_reset_transform")
- # Operator
- if tex_slot.tex_paint_map_mode == 'STENCIL':
- menu.add_item().operator("brush.stencil_reset_transform")
else:
- menu.add_item().label("No Texture Slot available", icon="INFO")
+ layout.row().label("No Texture Slot available", icon="INFO")
- def texpaint(self, menu, context):
+ def texpaint(self, layout, context):
has_brush = utils_core.get_brush_link(context, types="brush")
tex_slot = has_brush.texture_slot if has_brush else None
mask_tex_slot = has_brush.mask_texture_slot if has_brush else None
# Texture Section
- menu.add_item().label(text="Texture", icon='TEXTURE')
+ layout.row().label(text="Texture", icon='TEXTURE')
# Menus
- menu.add_item().menu(Textures.bl_idname)
- menu.add_item().menu(TextureMapMode.bl_idname)
+ layout.row().menu(Textures.bl_idname)
+ layout.row().menu(TextureMapMode.bl_idname)
# Checkboxes
- if tex_slot and tex_slot.tex_paint_map_mode != '3D':
- if tex_slot.tex_paint_map_mode in ['RANDOM', 'VIEW_PLANE']:
- menu.add_item().prop(tex_slot, "use_rake", toggle=True)
- menu.add_item().prop(tex_slot, "use_random", toggle=True)
+ if tex_slot:
+ if tex_slot.tex_paint_map_mode != '3D':
+ if tex_slot.tex_paint_map_mode in ('RANDOM', 'VIEW_PLANE'):
+ layout.row().prop(tex_slot, "use_rake", toggle=True)
+ layout.row().prop(tex_slot, "use_random", toggle=True)
- # Sliders
- menu.add_item().prop(tex_slot, "angle",
- text=utils_core.PIW + "Angle", slider=True)
+ # Sliders
+ layout.row().prop(tex_slot, "angle",
+ text=utils_core.PIW + "Angle", slider=True)
- if tex_slot.tex_paint_map_mode in ['RANDOM', 'VIEW_PLANE'] and tex_slot.use_random:
- menu.add_item().prop(tex_slot, "random_angle",
- text=utils_core.PIW + "Random Angle", slider=True)
+ if tex_slot.tex_paint_map_mode in ('RANDOM', 'VIEW_PLANE') and tex_slot.use_random:
+ layout.row().prop(tex_slot, "random_angle",
+ text=utils_core.PIW + "Random Angle", slider=True)
- # Operator
- if tex_slot.tex_paint_map_mode == 'STENCIL':
- menu.add_item().operator("brush.stencil_reset_transform")
+ # Operator
+ if tex_slot.tex_paint_map_mode == 'STENCIL':
+ if has_brush.texture and has_brush.texture.type == 'IMAGE':
+ layout.row().operator("brush.stencil_fit_image_aspect")
- menu.add_item().separator()
+ layout.row().operator("brush.stencil_reset_transform")
+
+ else:
+ layout.row().label("No Texture Slot available", icon="INFO")
+
+ layout.row().separator()
# Texture Mask Section
- menu.add_item().label(text="Texture Mask", icon='MOD_MASK')
+ layout.row().label(text="Texture Mask", icon='MOD_MASK')
# Menus
- menu.add_item().menu(MaskTextures.bl_idname)
- menu.add_item().menu(MaskMapMode.bl_idname)
+ layout.row().menu(MaskTextures.bl_idname)
+ layout.row().menu(MaskMapMode.bl_idname)
+ layout.row().menu(MaskPressureModeMenu.bl_idname)
# Checkboxes
if mask_tex_slot:
- if mask_tex_slot.mask_map_mode in ['RANDOM', 'VIEW_PLANE']:
- menu.add_item().prop(mask_tex_slot, "use_rake", toggle=True)
- menu.add_item().prop(mask_tex_slot, "use_random", toggle=True)
+ if mask_tex_slot.mask_map_mode in ('RANDOM', 'VIEW_PLANE'):
+ layout.row().prop(mask_tex_slot, "use_rake", toggle=True)
+ layout.row().prop(mask_tex_slot, "use_random", toggle=True)
# Sliders
- menu.add_item().prop(mask_tex_slot, "angle",
- text=utils_core.PIW + "Angle", icon_value=5, slider=True)
+ layout.row().prop(mask_tex_slot, "angle",
+ text=utils_core.PIW + "Angle", icon_value=5, slider=True)
- if mask_tex_slot.mask_map_mode in ['RANDOM', 'VIEW_PLANE'] and \
- mask_tex_slot.use_random:
- menu.add_item().prop(mask_tex_slot, "random_angle",
- text=utils_core.PIW + "Random Angle", slider=True)
+ if mask_tex_slot.mask_map_mode in ('RANDOM', 'VIEW_PLANE') and mask_tex_slot.use_random:
+ layout.row().prop(mask_tex_slot, "random_angle",
+ text=utils_core.PIW + "Random Angle", slider=True)
# Operator
if mask_tex_slot.mask_map_mode == 'STENCIL':
- prop = menu.add_item().operator("brush.stencil_reset_transform")
+ if has_brush.mask_texture and has_brush.mask_texture.type == 'IMAGE':
+ layout.row().operator("brush.stencil_fit_image_aspect")
+
+ prop = layout.row().operator("brush.stencil_reset_transform")
prop.mask = True
+
else:
- menu.add_item().label("Mask Texture not available", icon="INFO")
+ layout.row().label("Mask Texture not available", icon="INFO")
class Textures(Menu):
@@ -155,13 +174,13 @@ class Textures(Menu):
bl_idname = "VIEW3D_MT_sv3_texture_list"
def init(self):
- if utils_core.get_mode() == utils_core.sculpt:
+ if utils_core.get_mode() == 'SCULPT':
datapath = "tool_settings.sculpt.brush.texture"
- elif utils_core.get_mode() == utils_core.vertex_paint:
+ elif utils_core.get_mode() == 'VERTEX_PAINT':
datapath = "tool_settings.vertex_paint.brush.texture"
- elif utils_core.get_mode() == utils_core.texture_paint:
+ elif utils_core.get_mode() == 'TEXTURE_PAINT':
datapath = "tool_settings.image_paint.brush.texture"
else:
@@ -174,30 +193,30 @@ class Textures(Menu):
has_brush = utils_core.get_brush_link(context, types="brush")
current_texture = eval("bpy.context.{}".format(datapath)) if \
has_brush else None
- menu = utils_core.Menu(self)
+ layout = self.layout
# get the current texture's name
if current_texture:
current_texture = current_texture.name
- menu.add_item().label(text="Brush Texture")
- menu.add_item().separator()
+ layout.row().label(text="Brush Texture")
+ layout.row().separator()
# add an item to set the texture to None
- utils_core.menuprop(menu.add_item(), "None", "None",
+ utils_core.menuprop(layout.row(), "None", "None",
datapath, icon='RADIOBUT_OFF', disable=True,
disable_icon='RADIOBUT_ON',
- custom_disable_exp=[None, current_texture],
+ custom_disable_exp=(None, current_texture),
path=True)
# add the menu items
for item in bpy.data.textures:
- utils_core.menuprop(menu.add_item(), item.name,
+ utils_core.menuprop(layout.row(), item.name,
'bpy.data.textures["%s"]' % item.name,
datapath, icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON',
- custom_disable_exp=[item.name, current_texture],
+ custom_disable_exp=(item.name, current_texture),
path=True)
@@ -206,33 +225,33 @@ class TextureMapMode(Menu):
bl_idname = "VIEW3D_MT_sv3_texture_map_mode"
def draw(self, context):
- menu = utils_core.Menu(self)
+ layout = self.layout
has_brush = utils_core.get_brush_link(context, types="brush")
- menu.add_item().label(text="Brush Mapping")
- menu.add_item().separator()
+ layout.row().label(text="Brush Mapping")
+ layout.row().separator()
if has_brush:
- if utils_core.get_mode() == utils_core.sculpt:
+ if utils_core.get_mode() == 'SCULPT':
path = "tool_settings.sculpt.brush.texture_slot.map_mode"
# add the menu items
for item in has_brush. \
texture_slot.bl_rna.properties['map_mode'].enum_items:
utils_core.menuprop(
- menu.add_item(), item.name, item.identifier, path,
+ layout.row(), item.name, item.identifier, path,
icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON'
)
- elif utils_core.get_mode() == utils_core.vertex_paint:
+ elif utils_core.get_mode() == 'VERTEX_PAINT':
path = "tool_settings.vertex_paint.brush.texture_slot.tex_paint_map_mode"
# add the menu items
for item in has_brush. \
texture_slot.bl_rna.properties['tex_paint_map_mode'].enum_items:
utils_core.menuprop(
- menu.add_item(), item.name, item.identifier, path,
+ layout.row(), item.name, item.identifier, path,
icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON'
@@ -244,13 +263,13 @@ class TextureMapMode(Menu):
for item in has_brush. \
texture_slot.bl_rna.properties['tex_paint_map_mode'].enum_items:
utils_core.menuprop(
- menu.add_item(), item.name, item.identifier, path,
+ layout.row(), item.name, item.identifier, path,
icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON'
)
else:
- menu.add_item().label("No brushes available", icon="INFO")
+ layout.row().label("No brushes available", icon="INFO")
class MaskTextures(Menu):
@@ -258,14 +277,14 @@ class MaskTextures(Menu):
bl_idname = "VIEW3D_MT_sv3_mask_texture_list"
def draw(self, context):
- menu = utils_core.Menu(self)
+ layout = self.layout
datapath = "tool_settings.image_paint.brush.mask_texture"
has_brush = utils_core.get_brush_link(context, types="brush")
current_texture = eval("bpy.context.{}".format(datapath)) if \
has_brush else None
- menu.add_item().label(text="Mask Texture")
- menu.add_item().separator()
+ layout.row().label(text="Mask Texture")
+ layout.row().separator()
if has_brush:
# get the current texture's name
@@ -274,24 +293,24 @@ class MaskTextures(Menu):
# add an item to set the texture to None
utils_core.menuprop(
- menu.add_item(), "None", "None",
+ layout.row(), "None", "None",
datapath, icon='RADIOBUT_OFF', disable=True,
disable_icon='RADIOBUT_ON',
- custom_disable_exp=[None, current_texture],
+ custom_disable_exp=(None, current_texture),
path=True
)
# add the menu items
for item in bpy.data.textures:
utils_core.menuprop(
- menu.add_item(), item.name, 'bpy.data.textures["%s"]' % item.name,
+ layout.row(), item.name, 'bpy.data.textures["%s"]' % item.name,
datapath, icon='RADIOBUT_OFF', disable=True,
disable_icon='RADIOBUT_ON',
- custom_disable_exp=[item.name, current_texture],
+ custom_disable_exp=(item.name, current_texture),
path=True
)
else:
- menu.add_item().label("No brushes available", icon="INFO")
+ layout.row().label("No brushes available", icon="INFO")
class MaskMapMode(Menu):
@@ -299,25 +318,25 @@ class MaskMapMode(Menu):
bl_idname = "VIEW3D_MT_sv3_mask_map_mode"
def draw(self, context):
- menu = utils_core.Menu(self)
+ layout = self.layout
path = "tool_settings.image_paint.brush.mask_texture_slot.mask_map_mode"
has_brush = utils_core.get_brush_link(context, types="brush")
- menu.add_item().label(text="Mask Mapping")
- menu.add_item().separator()
+ layout.row().label(text="Mask Mapping")
+ layout.row().separator()
if has_brush:
items = has_brush. \
mask_texture_slot.bl_rna.properties['mask_map_mode'].enum_items
# add the menu items
for item in items:
utils_core.menuprop(
- menu.add_item(), item.name, item.identifier, path,
+ layout.row(), item.name, item.identifier, path,
icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON'
)
else:
- menu.add_item().label("No brushes available", icon="INFO")
+ layout.row().label("No brushes available", icon="INFO")
class TextureAngleSource(Menu):
@@ -325,16 +344,16 @@ class TextureAngleSource(Menu):
bl_idname = "VIEW3D_MT_sv3_texture_angle_source"
def draw(self, context):
- menu = utils_core.Menu(self)
+ layout = self.layout
has_brush = utils_core.get_brush_link(context, types="brush")
if has_brush:
- if utils_core.get_mode() == utils_core.sculpt:
+ if utils_core.get_mode() == 'SCULPT':
items = has_brush. \
bl_rna.properties['texture_angle_source_random'].enum_items
path = "tool_settings.sculpt.brush.texture_angle_source_random"
- elif utils_core.get_mode() == utils_core.vertex_paint:
+ elif utils_core.get_mode() == 'VERTEX_PAINT':
items = has_brush. \
bl_rna.properties['texture_angle_source_random'].enum_items
path = "tool_settings.vertex_paint.brush.texture_angle_source_random"
@@ -347,10 +366,32 @@ class TextureAngleSource(Menu):
# add the menu items
for item in items:
utils_core.menuprop(
- menu.add_item(), item[0], item[1], path,
+ layout.row(), item[0], item[1], path,
icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON'
)
else:
- menu.add_item().label("No brushes available", icon="INFO")
+ layout.row().label("No brushes available", icon="INFO")
+
+class MaskPressureModeMenu(Menu):
+ bl_label = "Mask Pressure Mode"
+ bl_idname = "VIEW3D_MT_sv3_mask_pressure_mode_menu"
+
+ def draw(self, context):
+ layout = self.layout
+ path = "tool_settings.image_paint.brush.use_pressure_masking"
+
+ layout.row().label(text="Mask Pressure Mode")
+ layout.row().separator()
+
+ # add the menu items
+ for item in context.tool_settings.image_paint.brush. \
+ bl_rna.properties['use_pressure_masking'].enum_items:
+ utils_core.menuprop(
+ layout.row(), item.name, item.identifier, path,
+ icon='RADIOBUT_OFF',
+ disable=True,
+ disable_icon='RADIOBUT_ON'
+ )
+