Cleanup: use staticmethod where appropriate

This commit is contained in:
2019-04-19 07:51:14 +02:00
parent ba44602b23
commit 082d7e8d5f
10 changed files with 23 additions and 7 deletions

View File

@@ -62,10 +62,12 @@ class PhysicButtonsPanel:
bl_region_type = 'WINDOW'
bl_context = "physics"
@staticmethod
def poll_dyn_paint(context):
ob = context.object
return (ob and ob.type == 'MESH') and context.dynamic_paint
@staticmethod
def poll_dyn_canvas(context):
if not PhysicButtonsPanel.poll_dyn_paint(context):
return False
@@ -73,6 +75,7 @@ class PhysicButtonsPanel:
md = context.dynamic_paint
return (md and md.ui_type == 'CANVAS' and md.canvas_settings and md.canvas_settings.canvas_surfaces.active)
@staticmethod
def poll_dyn_canvas_paint(context):
if not PhysicButtonsPanel.poll_dyn_canvas(context):
return False
@@ -80,6 +83,7 @@ class PhysicButtonsPanel:
surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
return (surface.surface_type == 'PAINT')
@staticmethod
def poll_dyn_canvas_brush(context):
if not PhysicButtonsPanel.poll_dyn_paint(context):
return False
@@ -87,6 +91,7 @@ class PhysicButtonsPanel:
md = context.dynamic_paint
return (md and md.ui_type == 'BRUSH' and md.brush_settings)
@staticmethod
def poll_dyn_output(context):
if not PhysicButtonsPanel.poll_dyn_canvas(context):
return False
@@ -94,6 +99,7 @@ class PhysicButtonsPanel:
surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
return (not (surface.surface_format == 'VERTEX' and (surface.surface_type in {'DISPLACE', 'WAVE'})))
@staticmethod
def poll_dyn_output_maps(context):
if not PhysicButtonsPanel.poll_dyn_output(context):
return False

View File

@@ -32,10 +32,12 @@ class PhysicButtonsPanel:
bl_region_type = 'WINDOW'
bl_context = "physics"
@staticmethod
def poll_force_field(context):
ob = context.object
return (ob and (ob.field) and (ob.field.type != 'NONE'))
@staticmethod
def poll_collision(context):
ob = context.object
return (ob and ob.type == 'MESH') and (context.collision)

View File

@@ -38,6 +38,7 @@ class PhysicButtonsPanel:
bl_region_type = 'WINDOW'
bl_context = "physics"
@staticmethod
def poll_fluid(context):
ob = context.object
if not ((ob and ob.type == 'MESH') and (context.fluid)):
@@ -45,6 +46,7 @@ class PhysicButtonsPanel:
return (bpy.app.build_options.mod_fluid)
@staticmethod
def poll_fluid_settings(context):
if not (PhysicButtonsPanel.poll_fluid(context)):
return False
@@ -52,6 +54,7 @@ class PhysicButtonsPanel:
md = context.fluid
return md and md.settings and (md.settings.type != 'NONE')
@staticmethod
def poll_fluid_domain(context):
if not PhysicButtonsPanel.poll_fluid(context):
return False

View File

@@ -33,6 +33,7 @@ class PhysicButtonsPanel:
bl_region_type = 'WINDOW'
bl_context = "physics"
@staticmethod
def poll_smoke(context):
ob = context.object
if not ((ob and ob.type == 'MESH') and (context.smoke)):
@@ -41,6 +42,7 @@ class PhysicButtonsPanel:
md = context.smoke
return md and (context.smoke.smoke_type != 'NONE') and (bpy.app.build_options.mod_smoke)
@staticmethod
def poll_smoke_domain(context):
if not PhysicButtonsPanel.poll_smoke(context):
return False

View File

@@ -236,6 +236,7 @@ class DOPESHEET_HT_editor_buttons(Header):
def draw(self, context):
pass
@staticmethod
def draw_header(context, layout):
st = context.space_data
tool_settings = context.tool_settings

View File

@@ -28,7 +28,6 @@ class INFO_HT_header(Header):
layout.template_header()
# Empty for now until info editor gets turned into log editor
pass
# Not really info, just add to re-usable location.

View File

@@ -30,6 +30,7 @@ class TIME_HT_editor_buttons(Header):
def draw(self, context):
pass
@staticmethod
def draw_header(context, layout):
scene = context.scene
tool_settings = context.tool_settings

View File

@@ -260,6 +260,7 @@ class TOPBAR_MT_file_new(Menu):
return sorted(app_templates)
@staticmethod
def draw_ex(layout, _context, *, use_splash=False, use_more=False):
layout.operator_context = 'EXEC_DEFAULT'
@@ -639,7 +640,6 @@ class TOPBAR_PT_gpencil_fill(Panel):
bl_region_type = 'HEADER'
bl_label = "Advanced"
@staticmethod
def draw(self, context):
paint = context.tool_settings.gpencil_paint
brush = paint.brush

View File

@@ -697,6 +697,7 @@ class USERPREF_MT_interface_theme_presets(Menu):
)
draw = Menu.draw_preset
@staticmethod
def reset_cb(context):
bpy.ops.preferences.reset_default_theme()

View File

@@ -3482,15 +3482,15 @@ class VIEW3D_MT_edit_mesh_extrude(Menu):
_extrude_funcs = {
'VERT': lambda layout:
layout.operator("mesh.extrude_vertices_move", text="Extrude Vertices"),
layout.operator("mesh.extrude_vertices_move", text="Extrude Vertices"),
'EDGE': lambda layout:
layout.operator("mesh.extrude_edges_move", text="Extrude Edges"),
layout.operator("mesh.extrude_edges_move", text="Extrude Edges"),
'REGION': lambda layout:
layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Faces"),
layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Faces"),
'REGION_VERT_NORMAL': lambda layout:
layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Extrude Faces Along Normals"),
layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Extrude Faces Along Normals"),
'FACE': lambda layout:
layout.operator("mesh.extrude_faces_move", text="Extrude Individual Faces"),
layout.operator("mesh.extrude_faces_move", text="Extrude Individual Faces"),
}
@staticmethod
@@ -5991,6 +5991,7 @@ class VIEW3D_PT_context_properties(Panel):
bl_label = "Properties"
bl_options = {'DEFAULT_CLOSED'}
@staticmethod
def _active_context_member(context):
obj = context.object
if obj: