Cleanup: simplify use of tool_settings in space_view3d.py
Assign early in and reuse, access directly from context.
This commit is contained in:
@@ -368,7 +368,8 @@ class _draw_tool_settings_context_mode:
|
||||
elif not tool.has_datablock:
|
||||
return False
|
||||
|
||||
paint = context.tool_settings.gpencil_paint
|
||||
tool_settings = context.tool_settings
|
||||
paint = tool_settings.gpencil_paint
|
||||
brush = paint.brush
|
||||
if brush is None:
|
||||
return False
|
||||
@@ -376,7 +377,6 @@ class _draw_tool_settings_context_mode:
|
||||
gp_settings = brush.gpencil_settings
|
||||
|
||||
row = layout.row(align=True)
|
||||
tool_settings = context.scene.tool_settings
|
||||
settings = tool_settings.gpencil_paint
|
||||
row.template_ID_preview(settings, "brush", rows=3, cols=8, hide_buttons=True)
|
||||
|
||||
@@ -401,7 +401,9 @@ class _draw_tool_settings_context_mode:
|
||||
def SCULPT_GPENCIL(context, layout, tool):
|
||||
if (tool is None) or (not tool.has_datablock):
|
||||
return False
|
||||
paint = context.tool_settings.gpencil_sculpt_paint
|
||||
|
||||
tool_settings = context.tool_settings
|
||||
paint = tool_settings.gpencil_sculpt_paint
|
||||
brush = paint.brush
|
||||
|
||||
from bl_ui.properties_paint_common import (
|
||||
@@ -415,7 +417,9 @@ class _draw_tool_settings_context_mode:
|
||||
def WEIGHT_GPENCIL(context, layout, tool):
|
||||
if (tool is None) or (not tool.has_datablock):
|
||||
return False
|
||||
paint = context.tool_settings.gpencil_weight_paint
|
||||
|
||||
tool_settings = context.tool_settings
|
||||
paint = tool_settings.gpencil_weight_paint
|
||||
brush = paint.brush
|
||||
|
||||
layout.template_ID_preview(paint, "brush", rows=3, cols=8, hide_buttons=True)
|
||||
@@ -432,11 +436,11 @@ class _draw_tool_settings_context_mode:
|
||||
if (tool is None) or (not tool.has_datablock):
|
||||
return False
|
||||
|
||||
paint = context.tool_settings.gpencil_vertex_paint
|
||||
tool_settings = context.tool_settings
|
||||
paint = tool_settings.gpencil_vertex_paint
|
||||
brush = paint.brush
|
||||
|
||||
row = layout.row(align=True)
|
||||
tool_settings = context.scene.tool_settings
|
||||
settings = tool_settings.gpencil_vertex_paint
|
||||
row.template_ID_preview(settings, "brush", rows=3, cols=8, hide_buttons=True)
|
||||
|
||||
@@ -458,7 +462,8 @@ class _draw_tool_settings_context_mode:
|
||||
return False
|
||||
|
||||
# See: 'VIEW3D_PT_tools_brush', basically a duplicate
|
||||
settings = context.tool_settings.particle_edit
|
||||
tool_settings = context.tool_settings
|
||||
settings = tool_settings.particle_edit
|
||||
brush = settings.brush
|
||||
tool = settings.tool
|
||||
if tool == 'NONE':
|
||||
@@ -1022,7 +1027,7 @@ class VIEW3D_MT_editor_menus(Menu):
|
||||
edit_object = context.edit_object
|
||||
gp_edit = obj and obj.mode in {'EDIT_GPENCIL', 'PAINT_GPENCIL', 'SCULPT_GPENCIL',
|
||||
'WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}
|
||||
tool_settings = context.scene.tool_settings
|
||||
tool_settings = context.tool_settings
|
||||
|
||||
layout.menu("VIEW3D_MT_view")
|
||||
|
||||
@@ -5519,7 +5524,9 @@ class VIEW3D_MT_edit_gpencil_stroke(Menu):
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
settings = context.tool_settings.gpencil_sculpt
|
||||
|
||||
tool_settings = context.tool_settings
|
||||
settings = tool_settings.gpencil_sculpt
|
||||
|
||||
layout.operator("gpencil.stroke_subdivide", text="Subdivide").only_selected = False
|
||||
layout.menu("VIEW3D_MT_gpencil_simplify")
|
||||
@@ -5796,18 +5803,20 @@ class VIEW3D_MT_pivot_pie(Menu):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
pie = layout.menu_pie()
|
||||
|
||||
tool_settings = context.tool_settings
|
||||
obj = context.active_object
|
||||
mode = context.mode
|
||||
|
||||
pie.prop_enum(context.scene.tool_settings, "transform_pivot_point", value='BOUNDING_BOX_CENTER')
|
||||
pie.prop_enum(context.scene.tool_settings, "transform_pivot_point", value='CURSOR')
|
||||
pie.prop_enum(context.scene.tool_settings, "transform_pivot_point", value='INDIVIDUAL_ORIGINS')
|
||||
pie.prop_enum(context.scene.tool_settings, "transform_pivot_point", value='MEDIAN_POINT')
|
||||
pie.prop_enum(context.scene.tool_settings, "transform_pivot_point", value='ACTIVE_ELEMENT')
|
||||
pie.prop_enum(tool_settings, "transform_pivot_point", value='BOUNDING_BOX_CENTER')
|
||||
pie.prop_enum(tool_settings, "transform_pivot_point", value='CURSOR')
|
||||
pie.prop_enum(tool_settings, "transform_pivot_point", value='INDIVIDUAL_ORIGINS')
|
||||
pie.prop_enum(tool_settings, "transform_pivot_point", value='MEDIAN_POINT')
|
||||
pie.prop_enum(tool_settings, "transform_pivot_point", value='ACTIVE_ELEMENT')
|
||||
if (obj is None) or (mode in {'OBJECT', 'POSE', 'WEIGHT_PAINT'}):
|
||||
pie.prop(context.scene.tool_settings, "use_transform_pivot_point_align")
|
||||
pie.prop(tool_settings, "use_transform_pivot_point_align")
|
||||
if mode == 'EDIT_GPENCIL':
|
||||
pie.prop(context.scene.tool_settings.gpencil_sculpt, "use_scale_thickness")
|
||||
pie.prop(tool_settings.gpencil_sculpt, "use_scale_thickness")
|
||||
|
||||
|
||||
class VIEW3D_MT_orientations_pie(Menu):
|
||||
@@ -5852,6 +5861,7 @@ class VIEW3D_MT_proportional_editing_falloff_pie(Menu):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
pie = layout.menu_pie()
|
||||
|
||||
tool_settings = context.scene.tool_settings
|
||||
|
||||
pie.prop(tool_settings, "proportional_edit_falloff", expand=True)
|
||||
|
||||
Reference in New Issue
Block a user