Cleanup: logical checks in UI scripts
authorCampbell Barton <ideasman42@gmail.com>
Fri, 19 Apr 2019 06:10:39 +0000 (08:10 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 19 Apr 2019 06:10:39 +0000 (08:10 +0200)
release/scripts/startup/bl_ui/properties_mask_common.py
release/scripts/startup/bl_ui/properties_object.py
release/scripts/startup/bl_ui/properties_paint_common.py
release/scripts/startup/bl_ui/properties_particle.py
release/scripts/startup/bl_ui/space_image.py
release/scripts/startup/bl_ui/space_sequencer.py
release/scripts/startup/bl_ui/space_view3d.py
release/scripts/startup/bl_ui/space_view3d_toolbar.py

index 6d22ad5..872b51d 100644 (file)
@@ -199,8 +199,8 @@ class MASK_PT_point:
             tracks_list = "tracks" if parent.type == 'POINT_TRACK' else "plane_tracks"
 
             if parent.parent in tracking.objects:
-                object = tracking.objects[parent.parent]
-                col.prop_search(parent, "sub_parent", object,
+                ob = tracking.objects[parent.parent]
+                col.prop_search(parent, "sub_parent", ob,
                                 tracks_list, icon='ANIM_DATA', text="Track")
             else:
                 col.prop_search(parent, "sub_parent", tracking,
index 323ab46..3265366 100644 (file)
@@ -309,7 +309,7 @@ class OBJECT_PT_instancing(ObjectButtonsPanel, Panel):
             col = layout.column()
             col.prop(ob, "instance_collection", text="Collection")
 
-        if ob.instance_type != 'NONE' or len(ob.particle_systems):
+        if ob.instance_type != 'NONE' or ob.particle_systems:
             col = flow.column(align=True)
             col.prop(ob, "show_instancer_for_viewport")
             col.prop(ob, "show_instancer_for_render")
index 6ceebff..4c7fb4d 100644 (file)
@@ -365,7 +365,7 @@ def brush_basic_sculpt_settings(layout, context, brush, *, compact=False):
         UnifiedPaintPanel.prop_unified_strength(row, context, brush, "use_pressure_strength", text="")
 
     # direction
-    if capabilities.has_direction == False:
+    if not capabilities.has_direction:
         layout.row().prop(brush, "direction", expand=True, **({"text": ""} if compact else {}))
 
 
index 6414c1c..7167be3 100644 (file)
@@ -488,7 +488,7 @@ class PARTICLE_PT_cache(ParticleButtonsPanel, Panel):
         if psys.settings.is_fluid:
             return False
         phystype = psys.settings.physics_type
-        if phystype == 'NO' or phystype == 'KEYED':
+        if phystype in {'NO', 'KEYED'}:
             return False
         return (
             psys.settings.type in {'EMITTER', 'REACTOR'} or (
@@ -691,10 +691,7 @@ class PARTICLE_PT_physics_fluid_advanced(ParticleButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         part = particle_get_settings(context)
-        if part.physics_type == 'FLUID':
-            return True
-        else:
-            return False
+        return part.physics_type == 'FLUID'
 
     def draw(self, context):
         layout = self.layout
@@ -740,10 +737,7 @@ class PARTICLE_PT_physics_fluid_springs(ParticleButtonsPanel, Panel):
     def poll(cls, context):
         part = particle_get_settings(context)
         fluid = part.fluid
-        if part.physics_type == 'FLUID' and fluid.solver == 'DDR':
-            return True
-        else:
-            return False
+        return part.physics_type == 'FLUID' and fluid.solver == 'DDR'
 
     def draw(self, context):
         layout = self.layout
@@ -767,10 +761,7 @@ class PARTICLE_PT_physics_fluid_springs_viscoelastic(ParticleButtonsPanel, Panel
     def poll(cls, context):
         part = particle_get_settings(context)
         fluid = part.fluid
-        if part.physics_type == 'FLUID' and fluid.solver == 'DDR':
-            return True
-        else:
-            return False
+        return part.physics_type == 'FLUID' and fluid.solver == 'DDR'
 
     def draw_header(self, context):
         part = particle_get_settings(context)
@@ -806,10 +797,7 @@ class PARTICLE_PT_physics_fluid_springs_advanced(ParticleButtonsPanel, Panel):
     def poll(cls, context):
         part = particle_get_settings(context)
         fluid = part.fluid
-        if part.physics_type == 'FLUID' and fluid.solver == 'DDR':
-            return True
-        else:
-            return False
+        return part.physics_type == 'FLUID' and fluid.solver == 'DDR'
 
     def draw(self, context):
         layout = self.layout
index dd6dd82..15a3f79 100644 (file)
@@ -975,7 +975,7 @@ class IMAGE_PT_paint_color(Panel, ImagePaintPanel):
         settings = context.tool_settings.image_paint
         brush = settings.brush
 
-        layout.active = brush.use_gradient == False
+        layout.active = not brush.use_gradient
 
         brush_texpaint_common_color(self, context, layout, brush, settings, True)
 
index f47213c..942656f 100644 (file)
@@ -658,7 +658,7 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel, Panel):
         row.label(text=iface_("Final Length: %s") % bpy.utils.smpte_from_frame(strip.frame_final_duration),
                   translate=False)
         row = col.row(align=True)
-        row.active = (frame_current >= strip.frame_start and frame_current <= strip.frame_start + strip.frame_duration)
+        row.active = strip.frame_start <= frame_current <= strip.frame_start + strip.frame_duration
         row.label(text=iface_("Playhead: %d") % (frame_current - strip.frame_start), translate=False)
 
         col.label(text=iface_("Frame Offset %d:%d") % (strip.frame_offset_start, strip.frame_offset_end),
index ba519cd..0b7a717 100644 (file)
@@ -43,7 +43,6 @@ class VIEW3D_HT_tool_header(Header):
 
         layout.row(align=True).template_header()
 
-        view = context.space_data
         # mode_string = context.mode
         obj = context.active_object
         tool_settings = context.tool_settings
index 9cea53a..2ec1e20 100644 (file)
@@ -404,7 +404,7 @@ class VIEW3D_PT_tools_brush_color(Panel, View3DPaintPanel):
         settings = self.paint_settings(context)
         brush = settings.brush
 
-        layout.active = brush.use_gradient == False
+        layout.active = not brush.use_gradient
 
         brush_texpaint_common_color(self, context, layout, brush, settings, True)