[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22045] branches/blender2.5/blender/ release/ui: 2.5 Part 3 of Layout Code Cleanup:

Thomas Dinges dingto at gmx.de
Thu Jul 30 12:11:19 CEST 2009


Revision: 22045
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22045
Author:   dingto
Date:     2009-07-30 12:11:19 +0200 (Thu, 30 Jul 2009)

Log Message:
-----------
2.5 Part 3 of Layout Code Cleanup:

* More cleanup to match new coding guidelines.
http://wiki.blender.org/index.php/Dev:Py/Blender2.5/Layouts/Guidelines

* Replaced some if's with proper elif's.
* Removed some unnecessary code.
Note: Please don't use inconsistent assign names like colsub, subcol1 etc. anymore!

 

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/buttons_data_lamp.py
    branches/blender2.5/blender/release/ui/buttons_data_metaball.py
    branches/blender2.5/blender/release/ui/buttons_game.py
    branches/blender2.5/blender/release/ui/buttons_material.py
    branches/blender2.5/blender/release/ui/buttons_object.py
    branches/blender2.5/blender/release/ui/buttons_object_constraint.py
    branches/blender2.5/blender/release/ui/buttons_physics_field.py
    branches/blender2.5/blender/release/ui/buttons_physics_fluid.py
    branches/blender2.5/blender/release/ui/buttons_physics_softbody.py
    branches/blender2.5/blender/release/ui/buttons_scene.py

Modified: branches/blender2.5/blender/release/ui/buttons_data_lamp.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_data_lamp.py	2009-07-30 08:30:57 UTC (rev 22044)
+++ branches/blender2.5/blender/release/ui/buttons_data_lamp.py	2009-07-30 10:11:19 UTC (rev 22045)
@@ -52,41 +52,24 @@
 		sub = col.column()
 		sub.itemR(lamp, "color", text="")
 		sub.itemR(lamp, "energy")
-		
-	
-		
-		
-		#split = layout.split()
-		
+
 		if lamp.type in ('POINT', 'SPOT'):
-			#col = split.column()
-			#col.itemL(text="Falloff:")
-			sub = col.column()
 			sub.itemR(lamp, "falloff_type", text="Falloff")
 			sub.itemR(lamp, "distance")
-			
-			
+
 			if lamp.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED':
-				#col = split.column()
 				col.itemL(text="Attenuation Factors:")
 				sub = col.column(align=True)
 				sub.itemR(lamp, "linear_attenuation", slider=True, text="Linear")
 				sub.itemR(lamp, "quadratic_attenuation", slider=True, text="Quadratic")
-			#else:
-				# 
-				# split.column()
 			
 			col.itemR(lamp, "sphere")
 			
 		if lamp.type == 'AREA':
-			#col = split.column()
 			col.itemR(lamp, "distance")
 			col.itemR(lamp, "gamma")
-
-			#col = split.column()
-			
-			
 			col.itemR(lamp, "shape")
+			
 			sub = col.column(align=True)
 			if (lamp.shape == 'SQUARE'):
 				sub.itemR(lamp, "size")
@@ -99,7 +82,6 @@
 		col.itemR(lamp, "layer", text="This Layer Only")
 		col.itemR(lamp, "specular")
 		col.itemR(lamp, "diffuse")	
-			
 
 class DATA_PT_sunsky(DataButtonsPanel):
 	__label__ = "Sun/Sky"

Modified: branches/blender2.5/blender/release/ui/buttons_data_metaball.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_data_metaball.py	2009-07-30 08:30:57 UTC (rev 22044)
+++ branches/blender2.5/blender/release/ui/buttons_data_metaball.py	2009-07-30 10:11:19 UTC (rev 22045)
@@ -76,8 +76,7 @@
 		col.itemR(metaelem, "stiffness", text="Stiffness")
 		col.itemR(metaelem, "negative", text="Negative")
 		col.itemR(metaelem, "hide", text="Hide")
-		
-	
+
 bpy.types.register(DATA_PT_context_metaball)
 bpy.types.register(DATA_PT_metaball)
 bpy.types.register(DATA_PT_metaball_element)
\ No newline at end of file

Modified: branches/blender2.5/blender/release/ui/buttons_game.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_game.py	2009-07-30 08:30:57 UTC (rev 22044)
+++ branches/blender2.5/blender/release/ui/buttons_game.py	2009-07-30 10:11:19 UTC (rev 22045)
@@ -16,70 +16,78 @@
 
 	def draw(self, context):
 		layout = self.layout
+		
 		ob = context.active_object
-		
 		game = ob.game
 
 		layout.itemR(game, "physics_type")
 		layout.itemS()
 		
 		split = layout.split()
+		
 		col = split.column()
-		
 		col.itemR(game, "actor")
-		
 		col.itemR(game, "ghost")
 		col.itemR(ob, "restrict_render", text="Invisible") # out of place but useful
+		
 		col = split.column()
 		col.itemR(game, "do_fh", text="Use Material Physics")
 		col.itemR(game, "rotation_fh", text="Rotate From Normal")
 		col.itemR(game, "no_sleeping")
 		
 		layout.itemS()
+		
 		split = layout.split()
+		
 		col = split.column()
 		col.itemL(text="Attributes:")
-		colsub = col.column(align=True)
-		colsub.itemR(game, "mass")
-		colsub.itemR(game, "radius")
-		colsub.itemR(game, "form_factor")
+		sub = col.column(align=True)
+		sub.itemR(game, "mass")
+		sub.itemR(game, "radius")
+		sub.itemR(game, "form_factor")
+		
 		col.itemS()
+		
 		col.itemL(text="Damping:")
-		colsub = col.column(align=True)
-		colsub.itemR(game, "damping", text="Translation", slider=True)
-		colsub.itemR(game, "rotation_damping", text="Rotation", slider=True)
+		sub = col.column(align=True)
+		sub.itemR(game, "damping", text="Translation", slider=True)
+		sub.itemR(game, "rotation_damping", text="Rotation", slider=True)
 		
 		col = split.column()
+		col.itemL(text="Velocity:")
+		sub = col.column(align=True)
+		sub.itemR(game, "minimum_velocity", text="Minimum")
+		sub.itemR(game, "maximum_velocity", text="Maximum")
 		
-		col.itemL(text="Velocity:")
-		colsub = col.column(align=True)
-		colsub.itemR(game, "minimum_velocity", text="Minimum")
-		colsub.itemR(game, "maximum_velocity", text="Maximum")
 		col.itemS()
+		
 		col.itemR(game, "anisotropic_friction")
+		sub = col.column()
+		sub.active = game.anisotropic_friction
+		sub.itemR(game, "friction_coefficients", text="", slider=True)
 		
-		colsub = col.column()
-		colsub.active = game.anisotropic_friction
-		colsub.itemR(game, "friction_coefficients", text="", slider=True)
+		layout.itemS()
 		
-		layout.itemS()
 		split = layout.split()
-		sub = split.column()
-		sub.itemL(text="Lock Translation:")
-		sub.itemR(game, "lock_x_axis", text="X")
-		sub.itemR(game, "lock_y_axis", text="Y")
-		sub.itemR(game, "lock_z_axis", text="Z")
-		sub = split.column()
-		sub.itemL(text="Lock Rotation:")
-		sub.itemR(game, "lock_x_rot_axis", text="X")
-		sub.itemR(game, "lock_y_rot_axis", text="Y")
-		sub.itemR(game, "lock_z_rot_axis", text="Z")
+		
+		col = split.column()
+		col.itemL(text="Lock Translation:")
+		col.itemR(game, "lock_x_axis", text="X")
+		col.itemR(game, "lock_y_axis", text="Y")
+		col.itemR(game, "lock_z_axis", text="Z")
+		
+		col = split.column()
+		col.itemL(text="Lock Rotation:")
+		col.itemR(game, "lock_x_rot_axis", text="X")
+		col.itemR(game, "lock_y_rot_axis", text="Y")
+		col.itemR(game, "lock_z_rot_axis", text="Z")
 
 class PHYSICS_PT_game_collision_bounds(PhysicsButtonsPanel):
 	__label__ = "Collision Bounds"
 
 	def draw_header(self, context):
 		layout = self.layout
+		
 		ob = context.active_object
 		game = ob.game
 
@@ -90,17 +98,13 @@
 		
 		ob = context.scene.objects[0]
 		game = ob.game
+		
 		layout.active = game.use_collision_bounds
-		
-		
-		
 		layout.itemR(game, "collision_bounds", text="Bounds")
 		
-		split = layout.split()
-		sub = split.column()
-		sub.itemR(game, "collision_compound", text="Compound")
-		sub = split.column()
-		sub.itemR(game, "collision_margin", text="Margin", slider=True)
+		row = layout.row()
+		row.itemR(game, "collision_compound", text="Compound")
+		row.itemR(game, "collision_margin", text="Margin", slider=True)
 
 bpy.types.register(PHYSICS_PT_game_physics)
 bpy.types.register(PHYSICS_PT_game_collision_bounds)
@@ -119,6 +123,7 @@
 
 	def draw(self, context):
 		layout = self.layout
+		
 		rd = context.scene.render_data
 
 		row = layout.row()
@@ -130,64 +135,63 @@
 
 	def draw(self, context):
 		layout = self.layout
+		
 		gs = context.scene.game_data
-		row = layout.row()
-		row.itemR(gs, "fullscreen")
+		
+		layout.itemR(gs, "fullscreen")
 
 		split = layout.split()
+		
 		col = split.column()
 		col.itemL(text="Resolution:")
-		colsub = col.column(align=True)
-		colsub.itemR(gs, "resolution_x", slider=False, text="X")
-		colsub.itemR(gs, "resolution_y", slider=False, text="Y")
+		sub = col.column(align=True)
+		sub.itemR(gs, "resolution_x", slider=False, text="X")
+		sub.itemR(gs, "resolution_y", slider=False, text="Y")
 
 		col = split.column()
 		col.itemL(text="Quality:")
-		colsub = col.column(align=True)
-		colsub.itemR(gs, "depth", text="Bit Depth", slider=False)
-		colsub.itemR(gs, "frequency", text="FPS", slider=False)
+		sub = col.column(align=True)
+		sub.itemR(gs, "depth", text="Bit Depth", slider=False)
+		sub.itemR(gs, "frequency", text="FPS", slider=False)
 
 		# framing:
 		col = layout.column()
 		col.itemL(text="Framing:")
 		col.row().itemR(gs, "framing_type", expand=True)
+		sub = col.column()
+		sub.itemR(gs, "framing_color", text="")
 
-		colsub = col.column()
-		colsub.itemR(gs, "framing_color", text="")
-
 class SCENE_PT_game_stereo(SceneButtonsPanel):
 	__label__ = "Stereo"
 
 	def draw(self, context):
 		layout = self.layout
+		
 		gs = context.scene.game_data
+		stereo_mode = gs.stereo
 
 		# stereo options:
-		col= layout.column()
-		row = col.row()
-		row.itemR(gs, "stereo", expand=True)
+		layout.itemR(gs, "stereo", expand=True)
  
-		stereo_mode = gs.stereo
-
 		# stereo:
 		if stereo_mode == 'STEREO':
-			row = layout.row()
-			row.itemR(gs, "stereo_mode")
+			layout.itemR(gs, "stereo_mode")
 
 		# dome:
 		if stereo_mode == 'DOME':
-			row = layout.row()
-			row.itemR(gs, "dome_mode", text="Dome Type")
+			layout.itemR(gs, "dome_mode", text="Dome Type")
 
 			split=layout.split()
+			
 			col=split.column()
 			col.itemR(gs, "dome_angle", slider=True)
 			col.itemR(gs, "dome_tesselation", text="Tesselation")
+			
 			col=split.column()
 			col.itemR(gs, "dome_tilt")
 			col.itemR(gs, "dome_buffer_resolution", text="Resolution", slider=True)
-			col=layout.column()
-			col.itemR(gs, "dome_text")
+			
+			layout.itemR(gs, "dome_text")
 
 bpy.types.register(SCENE_PT_game)
 bpy.types.register(SCENE_PT_game_player)
@@ -207,7 +211,7 @@
 
 	def poll(self, context):
 		rd = context.scene.render_data
-		return (context.scene != None) and (rd.use_game_engine)
+		return (context.scene) and (rd.use_game_engine)
 
 	def draw(self, context):
 		layout = self.layout
@@ -228,6 +232,7 @@
 
 	def draw(self, context):
 		layout = self.layout
+		
 		world = context.world
 
 		row = layout.row()
@@ -270,35 +275,39 @@
  
 	def draw(self, context):
 		layout = self.layout
+		
 		gs = context.scene.game_data
-		flow = layout.column_flow()
-		flow.itemR(gs, "physics_engine")
+		
+		layout.itemR(gs, "physics_engine")
 		if gs.physics_engine != "NONE":
-			flow.itemR(gs, "physics_gravity", text="Gravity")
+			layout.itemR(gs, "physics_gravity", text="Gravity")
  
 			split = layout.split()
+			
 			col = split.column()
 			col.itemL(text="Physics Steps:")
-			colsub = col.column(align=True)
-			colsub.itemR(gs, "physics_step_max", text="Max")
-			colsub.itemR(gs, "physics_step_sub", text="Substeps")
+			sub = col.column(align=True)
+			sub.itemR(gs, "physics_step_max", text="Max")
+			sub.itemR(gs, "physics_step_sub", text="Substeps")
 			col.itemR(gs, "fps", text="FPS")
 			
 			col = split.column()
 			col.itemL(text="Logic Steps:")
 			col.itemR(gs, "logic_step_max", text="Max")
-			col.itemS()
+			
+			col = layout.column()
 			col.itemR(gs, "use_occlusion_culling", text="Occlusion Culling")
-			colsub = col.column()
-			colsub.active = gs.use_occlusion_culling
-			colsub.itemR(gs, "occlusion_culling_resolution", text="Resolution")
-			
+			sub = col.column()
+			sub.active = gs.use_occlusion_culling
+			sub.itemR(gs, "occlusion_culling_resolution", text="Resolution")
 
 		else:
 			split = layout.split()
+			
 			col = split.column()

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list