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:
authorlijenstina <lijenstina@gmail.com>2017-04-22 04:54:45 +0300
committerlijenstina <lijenstina@gmail.com>2017-04-22 04:54:45 +0300
commit29f2b2f34a8255828cf1621edd5c725167338f9f (patch)
treed478f0eb44d078137d62ad5b76d7320bbaf4f494 /space_view3d_brush_menus/stroke_menu.py
parent3fe42bb946bd780e7732afc4c1d100d13830d7e3 (diff)
Sculpt Paint Brush Menus: cleanup, refactor, various fixes
Bumped version to 1.1.4 Remove the Utils folder and move it to file utils_core Remove star imports and replace them with namespace Remove unused imports Use importlib for reloading files Add customization to the brushes (column size, 3 types of menus) Remove the VIEW3D_MT_Brush_Selection1 menu Remove versioning code Add some helper functions in utils_core Fix crash with poll functions get_mode if no active object Fix several crashes with unlinked missing active brush (hope i got it all) Move the shortcut register to the init Update wiki link NOTE: Remove unused operators and functions Part of it is something to do with properties creation Haven't seen the code used anywhere so it was removed If it is needed for something it could be restored later
Diffstat (limited to 'space_view3d_brush_menus/stroke_menu.py')
-rw-r--r--space_view3d_brush_menus/stroke_menu.py128
1 files changed, 69 insertions, 59 deletions
diff --git a/space_view3d_brush_menus/stroke_menu.py b/space_view3d_brush_menus/stroke_menu.py
index ff0708e7..c2163999 100644
--- a/space_view3d_brush_menus/stroke_menu.py
+++ b/space_view3d_brush_menus/stroke_menu.py
@@ -1,5 +1,8 @@
-from bpy.props import *
-from .Utils.core import *
+# gpl author: Ryan Inch (Imaginer)
+
+import bpy
+from bpy.types import Menu
+from . import utils_core
airbrush = 'AIRBRUSH'
anchored = 'ANCHORED'
@@ -10,108 +13,115 @@ line = 'LINE'
curve = 'CURVE'
-class StrokeOptionsMenu(bpy.types.Menu):
+class StrokeOptionsMenu(Menu):
bl_label = "Stroke Options"
bl_idname = "VIEW3D_MT_sv3_stroke_options"
@classmethod
def poll(self, context):
- if get_mode() in [sculpt, vertex_paint, weight_paint, texture_paint, particle_edit]:
- return True
- else:
- return False
+ return utils_core.get_mode() in (
+ utils_core.sculpt, utils_core.vertex_paint,
+ utils_core.weight_paint, utils_core.texture_paint,
+ utils_core.particle_edit
+ )
def init(self):
- if get_mode() == sculpt:
+ has_brush = utils_core.get_brush_link(bpy.context, types="brush")
+ if utils_core.get_mode() == utils_core.sculpt:
settings = bpy.context.tool_settings.sculpt
- brush = settings.brush
-
- if bpy.app.version > (2, 71):
- stroke_method = brush.stroke_method
-
- else:
- stroke_method = brush.sculpt_stroke_method
- elif get_mode() == texture_paint:
+ elif utils_core.get_mode() == utils_core.texture_paint:
settings = bpy.context.tool_settings.image_paint
- brush = settings.brush
- stroke_method = brush.stroke_method
else:
settings = bpy.context.tool_settings.vertex_paint
- brush = settings.brush
- stroke_method = brush.stroke_method
- return settings, brush, stroke_method
+ stroke_method = has_brush.stroke_method if has_brush else None
+
+ return settings, has_brush, stroke_method
def draw(self, context):
settings, brush, stroke_method = self.init()
- menu = Menu(self)
+ menu = utils_core.Menu(self)
menu.add_item().menu(StrokeMethodMenu.bl_idname)
-
menu.add_item().separator()
- if stroke_method == space:
- menu.add_item().prop(brush, "spacing", text=PIW+"Spacing", slider=True)
+ if stroke_method:
+ if stroke_method == space and brush:
+ menu.add_item().prop(brush, "spacing",
+ text=utils_core.PIW + "Spacing", slider=True)
- elif stroke_method == airbrush:
- menu.add_item().prop(brush, "rate", text=PIW+"Rate", slider=True)
+ elif stroke_method == airbrush and brush:
+ menu.add_item().prop(brush, "rate",
+ text=utils_core.PIW + "Rate", slider=True)
- elif stroke_method == anchored:
+ elif stroke_method == anchored and brush:
menu.add_item().prop(brush, "use_edge_to_edge")
-
- else:
- pass
- if get_mode() == sculpt and stroke_method in [drag_dot, anchored]:
- pass
- else:
- menu.add_item().prop(brush, "jitter", text=PIW+"Jitter", slider=True)
+ else:
+ pass
- menu.add_item().prop(settings, "input_samples", text=PIW+"Input Samples", slider=True)
-
- if stroke_method in [dots, space, airbrush]:
- menu.add_item().separator()
+ if utils_core.get_mode() == utils_core.sculpt and stroke_method in (drag_dot, anchored):
+ pass
+ else:
+ if brush:
+ menu.add_item().prop(brush, "jitter",
+ text=utils_core.PIW + "Jitter", slider=True)
- menu.add_item().prop(brush, "use_smooth_stroke", toggle=True)
+ menu.add_item().prop(settings, "input_samples",
+ text=utils_core.PIW + "Input Samples", slider=True)
- if brush.use_smooth_stroke:
- menu.add_item().prop(brush, "smooth_stroke_radius", text=PIW+"Radius", slider=True)
- menu.add_item().prop(brush, "smooth_stroke_factor", text=PIW+"Factor", slider=True)
+ if stroke_method in [dots, space, airbrush] and brush:
+ menu.add_item().separator()
+ menu.add_item().prop(brush, "use_smooth_stroke", toggle=True)
-class StrokeMethodMenu(bpy.types.Menu):
+ if brush.use_smooth_stroke:
+ menu.add_item().prop(brush, "smooth_stroke_radius",
+ text=utils_core.PIW + "Radius", slider=True)
+ menu.add_item().prop(brush, "smooth_stroke_factor",
+ text=utils_core.PIW + "Factor", slider=True)
+ else:
+ menu.add_item().label("No Stroke Options available", icon="INFO")
+
+
+class StrokeMethodMenu(Menu):
bl_label = "Stroke Method"
bl_idname = "VIEW3D_MT_sv3_stroke_method"
def init(self):
- if get_mode() == sculpt:
- brush = bpy.context.tool_settings.sculpt.brush
+ has_brush = utils_core.get_brush_link(bpy.context, types="brush")
+ if utils_core.get_mode() == utils_core.sculpt:
path = "tool_settings.sculpt.brush.stroke_method"
- elif get_mode() == texture_paint:
- brush = bpy.context.tool_settings.image_paint.brush
+ elif utils_core.get_mode() == utils_core.texture_paint:
path = "tool_settings.image_paint.brush.stroke_method"
else:
- brush = bpy.context.tool_settings.vertex_paint.brush
path = "tool_settings.vertex_paint.brush.stroke_method"
- return brush, path
+ return has_brush, path
def draw(self, context):
brush, path = self.init()
- menu = Menu(self)
+ menu = utils_core.Menu(self)
menu.add_item().label(text="Stroke Method")
menu.add_item().separator()
- # add the menu items dynamicaly based on values in enum property
- for tool in brush.bl_rna.properties['stroke_method'].enum_items:
- if tool.identifier in [anchored, drag_dot] and get_mode() in [vertex_paint, weight_paint]:
- continue
-
- menuprop(menu.add_item(), tool.name, tool.identifier, path,
- icon='RADIOBUT_OFF', disable=True,
- disable_icon='RADIOBUT_ON')
+ if brush:
+ # add the menu items dynamicaly based on values in enum property
+ for tool in brush.bl_rna.properties['stroke_method'].enum_items:
+ if tool.identifier in [anchored, drag_dot] and \
+ utils_core.get_mode() in [utils_core.vertex_paint,
+ utils_core.weight_paint]:
+ continue
+
+ utils_core.menuprop(
+ menu.add_item(), tool.name, tool.identifier, path,
+ icon='RADIOBUT_OFF', disable=True,
+ disable_icon='RADIOBUT_ON'
+ )
+ else:
+ menu.add_item().label("No Stroke Method available", icon="INFO")