Sculpt:
[blender.git] / release / scripts / ui / properties_physics_softbody.py
index f43d903..4cecb7e 100644 (file)
 # <pep8 compliant>
 import bpy
 
+narrowui = 180
+
 
 from properties_physics_common import point_cache_ui
 from properties_physics_common import effector_weights_ui
 
 
 def softbody_panel_enabled(md):
-    return md.point_cache.baked == False
+    return (md.point_cache.baked is False)
 
 
 class PhysicButtonsPanel(bpy.types.Panel):
@@ -47,22 +49,24 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel):
 
         md = context.soft_body
         ob = context.object
+        wide_ui = context.region.width > narrowui
 
         split = layout.split()
-        split.operator_context = "EXEC_DEFAULT"
+        split.operator_context = 'EXEC_DEFAULT'
 
         if md:
             # remove modifier + settings
             split.set_context_pointer("modifier", md)
-            split.itemO("object.modifier_remove", text="Remove")
+            split.operator("object.modifier_remove", text="Remove")
 
             row = split.row(align=True)
-            row.itemR(md, "render", text="")
-            row.itemR(md, "realtime", text="")
+            row.prop(md, "render", text="")
+            row.prop(md, "realtime", text="")
         else:
             # add modifier
-            split.item_enumO("object.modifier_add", "type", 'SOFT_BODY', text="Add")
-            split.itemL("")
+            split.operator("object.modifier_add", text="Add").type = 'SOFT_BODY'
+            if wide_ui:
+                split.column()
 
         if md:
             softbody = md.settings
@@ -72,14 +76,15 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel):
             split.enabled = softbody_panel_enabled(md)
 
             col = split.column()
-            col.itemL(text="Object:")
-            col.itemR(softbody, "friction")
-            col.itemR(softbody, "mass")
-            col.item_pointerR(softbody, "mass_vertex_group", ob, "vertex_groups", text="Mass:")
+            col.label(text="Object:")
+            col.prop(softbody, "friction")
+            col.prop(softbody, "mass")
+            col.prop_object(softbody, "mass_vertex_group", ob, "vertex_groups", text="Mass:")
 
-            col = split.column()
-            col.itemL(text="Simulation:")
-            col.itemR(softbody, "speed")
+            if wide_ui:
+                col = split.column()
+            col.label(text="Simulation:")
+            col.prop(softbody, "speed")
 
 
 class PHYSICS_PT_softbody_cache(PhysicButtonsPanel):
@@ -91,7 +96,7 @@ class PHYSICS_PT_softbody_cache(PhysicButtonsPanel):
 
     def draw(self, context):
         md = context.soft_body
-        point_cache_ui(self, md.point_cache, softbody_panel_enabled(md), 0, 0)
+        point_cache_ui(self, context, md.point_cache, softbody_panel_enabled(md), 0, 0)
 
 
 class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
@@ -105,7 +110,7 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
         softbody = context.soft_body.settings
 
         self.layout.active = softbody_panel_enabled(context.soft_body)
-        self.layout.itemR(softbody, "use_goal", text="")
+        self.layout.prop(softbody, "use_goal", text="")
 
     def draw(self, context):
         layout = self.layout
@@ -113,6 +118,7 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
         md = context.soft_body
         softbody = md.settings
         ob = context.object
+        wide_ui = context.region.width > narrowui
 
         layout.active = softbody.use_goal and softbody_panel_enabled(md)
 
@@ -122,18 +128,19 @@ class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
         split = layout.split()
 
         col = split.column()
-        col.itemL(text="Goal Strengths:")
-        col.itemR(softbody, "goal_default", text="Default")
+        col.label(text="Goal Strengths:")
+        col.prop(softbody, "goal_default", text="Default")
         sub = col.column(align=True)
-        sub.itemR(softbody, "goal_min", text="Minimum")
-        sub.itemR(softbody, "goal_max", text="Maximum")
+        sub.prop(softbody, "goal_min", text="Minimum")
+        sub.prop(softbody, "goal_max", text="Maximum")
 
-        col = split.column()
-        col.itemL(text="Goal Settings:")
-        col.itemR(softbody, "goal_spring", text="Stiffness")
-        col.itemR(softbody, "goal_friction", text="Damping")
+        if wide_ui:
+            col = split.column()
+        col.label(text="Goal Settings:")
+        col.prop(softbody, "goal_spring", text="Stiffness")
+        col.prop(softbody, "goal_friction", text="Damping")
 
-        layout.item_pointerR(softbody, "goal_vertex_group", ob, "vertex_groups", text="Vertex Group")
+        layout.prop_object(softbody, "goal_vertex_group", ob, "vertex_groups", text="Vertex Group")
 
 
 class PHYSICS_PT_softbody_edge(PhysicButtonsPanel):
@@ -147,7 +154,7 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel):
         softbody = context.soft_body.settings
 
         self.layout.active = softbody_panel_enabled(context.soft_body)
-        self.layout.itemR(softbody, "use_edges", text="")
+        self.layout.prop(softbody, "use_edges", text="")
 
     def draw(self, context):
         layout = self.layout
@@ -155,35 +162,38 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel):
         md = context.soft_body
         softbody = md.settings
         ob = context.object
+        wide_ui = context.region.width > narrowui
 
         layout.active = softbody.use_edges and softbody_panel_enabled(md)
 
         split = layout.split()
 
         col = split.column()
-        col.itemL(text="Springs:")
-        col.itemR(softbody, "pull")
-        col.itemR(softbody, "push")
-        col.itemR(softbody, "damp")
-        col.itemR(softbody, "plastic")
-        col.itemR(softbody, "bending")
-        col.itemR(softbody, "spring_length", text="Length")
+        col.label(text="Springs:")
+        col.prop(softbody, "pull")
+        col.prop(softbody, "push")
+        col.prop(softbody, "damp")
+        col.prop(softbody, "plastic")
+        col.prop(softbody, "bending")
+        col.prop(softbody, "spring_length", text="Length")
+        col.prop_object(softbody, "spring_vertex_group", ob, "vertex_groups", text="Springs:")
         col.item_pointerR(softbody, "spring_vertex_group", ob, "vertex_groups", text="Springs:")
 
-        col = split.column()
-        col.itemR(softbody, "stiff_quads")
+        if wide_ui:
+            col = split.column()
+        col.prop(softbody, "stiff_quads")
         sub = col.column()
         sub.active = softbody.stiff_quads
-        sub.itemR(softbody, "shear")
+        sub.prop(softbody, "shear")
 
-        col.itemR(softbody, "new_aero", text="Aero")
+        col.prop(softbody, "new_aero", text="Aero")
         sub = col.column()
         sub.enabled = softbody.new_aero
-        sub.itemR(softbody, "aero", text="Factor")
+        sub.prop(softbody, "aero", text="Factor")
 
-        col.itemL(text="Collision:")
-        col.itemR(softbody, "edge_collision", text="Edge")
-        col.itemR(softbody, "face_collision", text="Face")
+        col.label(text="Collision:")
+        col.prop(softbody, "edge_collision", text="Edge")
+        col.prop(softbody, "face_collision", text="Face")
 
 
 class PHYSICS_PT_softbody_collision(PhysicButtonsPanel):
@@ -197,25 +207,28 @@ class PHYSICS_PT_softbody_collision(PhysicButtonsPanel):
         softbody = context.soft_body.settings
 
         self.layout.active = softbody_panel_enabled(context.soft_body)
-        self.layout.itemR(softbody, "self_collision", text="")
+        self.layout.prop(softbody, "self_collision", text="")
 
     def draw(self, context):
         layout = self.layout
 
         md = context.soft_body
         softbody = md.settings
-        ob = context.object
+        wide_ui = context.region.width > narrowui
 
         layout.active = softbody.self_collision and softbody_panel_enabled(md)
 
-        layout.itemL(text="Collision Type:")
-        layout.itemR(softbody, "collision_type", expand=True)
+        layout.label(text="Collision Type:")
+        if wide_ui:
+            layout.prop(softbody, "collision_type", expand=True)
+        else:
+            layout.prop(softbody, "collision_type", text="")
 
         col = layout.column(align=True)
-        col.itemL(text="Ball:")
-        col.itemR(softbody, "ball_size", text="Size")
-        col.itemR(softbody, "ball_stiff", text="Stiffness")
-        col.itemR(softbody, "ball_damp", text="Dampening")
+        col.label(text="Ball:")
+        col.prop(softbody, "ball_size", text="Size")
+        col.prop(softbody, "ball_stiff", text="Stiffness")
+        col.prop(softbody, "ball_damp", text="Dampening")
 
 
 class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
@@ -230,7 +243,7 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
 
         md = context.soft_body
         softbody = md.settings
-        ob = context.object
+        wide_ui = context.region.width > narrowui
 
         layout.active = softbody_panel_enabled(md)
 
@@ -238,19 +251,20 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
         split = layout.split()
 
         col = split.column(align=True)
-        col.itemL(text="Step Size:")
-        col.itemR(softbody, "minstep")
-        col.itemR(softbody, "maxstep")
-        col.itemR(softbody, "auto_step", text="Auto-Step")
+        col.label(text="Step Size:")
+        col.prop(softbody, "minstep")
+        col.prop(softbody, "maxstep")
+        col.prop(softbody, "auto_step", text="Auto-Step")
 
-        col = split.column()
-        col.itemR(softbody, "error_limit")
-        col.itemL(text="Helpers:")
-        col.itemR(softbody, "choke")
-        col.itemR(softbody, "fuzzy")
+        if wide_ui:
+            col = split.column()
+        col.prop(softbody, "error_limit")
+        col.label(text="Helpers:")
+        col.prop(softbody, "choke")
+        col.prop(softbody, "fuzzy")
 
-        layout.itemL(text="Diagnostics:")
-        layout.itemR(softbody, "diagnose")
+        layout.label(text="Diagnostics:")
+        layout.prop(softbody, "diagnose")
 
 
 class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel):
@@ -263,7 +277,8 @@ class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel):
     def draw(self, context):
         md = context.soft_body
         softbody = md.settings
-        effector_weights_ui(self, softbody.effector_weights)
+
+        effector_weights_ui(self, context, softbody.effector_weights)
 
 bpy.types.register(PHYSICS_PT_softbody)
 bpy.types.register(PHYSICS_PT_softbody_cache)