[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20212] branches/blender2.5/blender: UI: Layout Engine

Brecht Van Lommel brecht at blender.org
Fri May 15 13:20:00 CEST 2009


Revision: 20212
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20212
Author:   blendix
Date:     2009-05-15 13:19:59 +0200 (Fri, 15 May 2009)

Log Message:
-----------
UI: Layout Engine

* Buttons are now created first, and after that the layout is computed.
  This means the layout engine now works at button level, and makes it
  easier to write templates. Otherwise you had to store all info and
  create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
  These can contain regular buttons, and can be put in a Free layout,
  which means you can specify manual coordinates, but still get nested
  correct inside other layouts.

* API was changed to allow better nesting. Previously items were added
  in the last added layout specifier, i.e. one level up in the layout
  hierarchy. This doesn't work well in always, so now when creating things
  like rows or columns it always returns a layout which you have to add
  the items in. All py scripts were updated to follow this.

* Computing the layout now goes in two passes, first estimating the
  required width/height of all nested layouts, and then in the second
  pass using the results of that to decide on the actual locations.

* Enum and array buttons now follow the direction of the layout, i.e.
  they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
  RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
  opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
  row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
  buttons).

* Moved some more space variables into Style.

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/buttons_data_camera.py
    branches/blender2.5/blender/release/ui/buttons_data_empty.py
    branches/blender2.5/blender/release/ui/buttons_data_lamp.py
    branches/blender2.5/blender/release/ui/buttons_data_lattice.py
    branches/blender2.5/blender/release/ui/buttons_data_modifier.py
    branches/blender2.5/blender/release/ui/buttons_material.py
    branches/blender2.5/blender/release/ui/buttons_objects.py
    branches/blender2.5/blender/release/ui/buttons_scene.py
    branches/blender2.5/blender/release/ui/buttons_world.py
    branches/blender2.5/blender/release/ui/space_text.py
    branches/blender2.5/blender/source/blender/editors/animation/keyframing.c
    branches/blender2.5/blender/source/blender/editors/armature/editarmature.c
    branches/blender2.5/blender/source/blender/editors/armature/poselib.c
    branches/blender2.5/blender/source/blender/editors/curve/curve_ops.c
    branches/blender2.5/blender/source/blender/editors/curve/editcurve.c
    branches/blender2.5/blender/source/blender/editors/include/ED_screen.h
    branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
    branches/blender2.5/blender/source/blender/editors/interface/interface.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_anim.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_api.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_handlers.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h
    branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_style.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_utils.c
    branches/blender2.5/blender/source/blender/editors/mesh/editmesh_tools.c
    branches/blender2.5/blender/source/blender/editors/object/object_edit.c
    branches/blender2.5/blender/source/blender/editors/physics/editparticle.c
    branches/blender2.5/blender/source/blender/editors/screen/area.c
    branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c
    branches/blender2.5/blender/source/blender/editors/space_buttons/space_buttons.c
    branches/blender2.5/blender/source/blender/editors/space_image/image_header.c
    branches/blender2.5/blender/source/blender/editors/space_image/image_ops.c
    branches/blender2.5/blender/source/blender/editors/space_text/space_text.c
    branches/blender2.5/blender/source/blender/editors/space_text/text_header.c
    branches/blender2.5/blender/source/blender/editors/space_text/text_ops.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_snap.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_ops.c
    branches/blender2.5/blender/source/blender/editors/uvedit/uvedit_unwrap_ops.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_userdef_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_context.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_material.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_scene.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_screen.c
    branches/blender2.5/blender/source/blender/python/intern/bpy_ui.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c

Modified: branches/blender2.5/blender/release/ui/buttons_data_camera.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_data_camera.py	2009-05-15 05:11:10 UTC (rev 20211)
+++ branches/blender2.5/blender/release/ui/buttons_data_camera.py	2009-05-15 11:19:59 UTC (rev 20212)
@@ -21,30 +21,30 @@
 		if not cam:
 			return
 		
-		layout.row()
 		layout.itemR(cam, "type", expand=True)
 		
-		layout.row()
-		if (cam.type == 'PERSP'):
-			layout.itemR(cam, "lens_unit")
-			if (cam.lens_unit == 'MILLIMETERS'):
-				layout.itemR(cam, "lens", text="Angle")
-			if (cam.lens_unit == 'DEGREES'):
-				layout.itemR(cam, "angle")
-		if (cam.type == 'ORTHO'):
-			layout.itemR(cam, "ortho_scale")
+		row = layout.row(align=True)
+		if cam.type == 'PERSP':
+			if cam.lens_unit == 'MILLIMETERS':
+				row.itemR(cam, "lens", text="Angle")
+			elif cam.lens_unit == 'DEGREES':
+				row.itemR(cam, "angle")
+
+			row.itemR(cam, "lens_unit", text="")
+		elif cam.type == 'ORTHO':
+			row.itemR(cam, "ortho_scale")
 		
-		layout.column_flow()
-		layout.itemL(text="Shift:")
-		layout.itemR(cam, "shift_x", text="X")
-		layout.itemR(cam, "shift_y", text="Y")
-		layout.itemL(text="Clipping:")
-		layout.itemR(cam, "clip_start", text="Start")
-		layout.itemR(cam, "clip_end", text="End")
+		flow = layout.column_flow()
+		flow.itemL(text="Shift:")
+		flow.itemR(cam, "shift_x", text="X")
+		flow.itemR(cam, "shift_y", text="Y")
+		flow.itemL(text="Clipping:")
+		flow.itemR(cam, "clip_start", text="Start")
+		flow.itemR(cam, "clip_end", text="End")
 		
-		layout.row()
-		layout.itemR(cam, "dof_object")
-		layout.itemR(cam, "dof_distance")
+		row = layout.row()
+		row.itemR(cam, "dof_object")
+		row.itemR(cam, "dof_distance")
 		
 class DATA_PT_cameradisplay(DataButtonsPanel):
 	__idname__ = "DATA_PT_cameradisplay"
@@ -57,23 +57,21 @@
 		if not cam:
 			return
 			
-		layout.split(number=2)
+		split = layout.split()
 		
-		sub = layout.sub(0)
-		sub.column()
+		sub = split.column()
 		sub.itemR(cam, "show_limits", text="Limits")
 		sub.itemR(cam, "show_mist", text="Mist")
 		sub.itemR(cam, "show_title_safe", text="Title Safe")
 		sub.itemR(cam, "show_name", text="Name")
 		
-		sub = layout.sub(1)
+		sub = split.column()
 		subsub = sub.box()
-		subsub.column()
 		subsub.itemR(cam, "show_passepartout", text="Passepartout")
 		if (cam.show_passepartout):
 			subsub.itemR(cam, "passepartout_alpha", text="Alpha")
-		sub.row()
-		sub.itemR(cam, "draw_size", text="Size")
+		row = sub.row()
+		row.itemR(cam, "draw_size", text="Size")
 		
 bpy.types.register(DATA_PT_cameralens)
 bpy.types.register(DATA_PT_cameradisplay)

Modified: branches/blender2.5/blender/release/ui/buttons_data_empty.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_data_empty.py	2009-05-15 05:11:10 UTC (rev 20211)
+++ branches/blender2.5/blender/release/ui/buttons_data_empty.py	2009-05-15 11:19:59 UTC (rev 20212)
@@ -21,8 +21,7 @@
 		if not ob:
 			return
 			
-		layout.column()
 		layout.itemR(ob, "empty_draw_type")
 		layout.itemR(ob, "empty_draw_size")
 		
-bpy.types.register(DATA_PT_empty)
\ No newline at end of file
+bpy.types.register(DATA_PT_empty)

Modified: branches/blender2.5/blender/release/ui/buttons_data_lamp.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_data_lamp.py	2009-05-15 05:11:10 UTC (rev 20211)
+++ branches/blender2.5/blender/release/ui/buttons_data_lamp.py	2009-05-15 11:19:59 UTC (rev 20212)
@@ -21,26 +21,23 @@
 		if not lamp:
 			return
 		
-		layout.row()
-		layout.itemR(lamp, "type", expand=True)
+		row = layout.row()
+		row.itemR(lamp, "type", expand=True)
 		
-		layout.split(number=2)
+		split = layout.split()
 		
-		sub = layout.sub(0)
-		sub.column()
+		sub = split.column()
 		sub.itemR(lamp, "energy")
 		sub.itemR(lamp, "distance")
 		sub.itemR(lamp, "negative")
 		sub.itemR(lamp, "color")
 	
-		sub = layout.sub(1)
-		sub.column()
+		sub = split.column()
 		sub.itemR(lamp, "layer", text="This Layer Only")
 		sub.itemR(lamp, "specular")
 		sub.itemR(lamp, "diffuse")
 		
-		if (lamp.type in ('POINT', 'SPOT')):
-			sub.column()
+		if lamp.type in ('POINT', 'SPOT'):
 			sub.itemR(lamp, "falloff_type")
 			sub.itemR(lamp, "sphere")
 			
@@ -48,7 +45,7 @@
 				sub.itemR(lamp, "linear_attenuation")
 				sub.itemR(lamp, "quadratic_attenuation")
 			
-		if (lamp.type == 'AREA'):
+		if lamp.type == 'AREA':
 			sub.column()
 			sub.itemR(lamp, "gamma")
 			sub.itemR(lamp, "shape")
@@ -74,33 +71,31 @@
 		if not lamp:
 			return
 		
-		layout.row()
-		layout.itemR(lamp, "sky")
-		layout.itemR(lamp, "atmosphere")
+		row = layout.row()
+		row.itemR(lamp, "sky")
+		row.itemR(lamp, "atmosphere")
 		
-		if (lamp.sky or lamp.atmosphere):
-			layout.row()
+		if lamp.sky or lamp.atmosphere:
 			layout.itemR(lamp, "atmosphere_turbidity", text="Turbidity")
 			
-			layout.split(number=2)
+			split = layout.split()
 			
-			if (lamp.sky):
-				sub = layout.sub(0)
-				sub.column()
+			col = split.column()
+			if lamp.sky:
+				sub = col.column()
 				sub.itemR(lamp, "sky_blend_type", text="Blend Type")
 				sub.itemR(lamp, "sky_blend")
 				sub.itemR(lamp, "sky_color_space", text="Color Space")
 				sub.itemR(lamp, "sky_exposure")
-				sub.column()
+				sub = col.column()
 				sub.itemR(lamp, "horizon_brightness", text="Hor Bright")
 				sub.itemR(lamp, "spread", text="Hor Spread")
 				sub.itemR(lamp, "sun_brightness", text="Sun Bright")
 				sub.itemR(lamp, "sun_size")
 				sub.itemR(lamp, "backscattered_light", text="Back Light")
 				
-			if (lamp.atmosphere):
-				sub = layout.sub(1)
-				sub.column()
+			sub = split.column()
+			if lamp.atmosphere:
 				sub.itemR(lamp, "sun_intensity", text="Sun Intens")
 				sub.itemR(lamp, "atmosphere_inscattering", text="Inscattering")
 				sub.itemR(lamp, "atmosphere_extinction", text="Extinction")
@@ -122,75 +117,71 @@
 		if not lamp:
 			return
 		
-		layout.row()
 		layout.itemR(lamp, "shadow_method", expand=True)
 		
-		if (lamp.shadow_method in ('BUFFER_SHADOW', 'RAY_SHADOW')):
+		if lamp.shadow_method in ('BUFFER_SHADOW', 'RAY_SHADOW'):
 		
-			layout.split(number=2)
+			split = layout.split()
 			
-			sub = layout.sub(0)
-			sub.column()
-			sub.itemL(text="Options:")
+			sub = split.column()
 			sub.itemR(lamp, "only_shadow")
 			sub.itemR(lamp, "shadow_layer")
 			
-			sub = layout.sub(1)
-			sub.column()
+			sub = split.column()
 			sub.itemR(lamp, "shadow_color")
 		
-		if (lamp.shadow_method == 'RAY_SHADOW'):
+		if lamp.shadow_method == 'RAY_SHADOW':
 		
-			layout.column()
-			layout.itemL(text="Sampling:")
-			layout.itemR(lamp, "shadow_ray_sampling_method", expand=True)
+			col = layout.column()
+			col.itemL(text="Sampling:")
+			col.row().itemR(lamp, "shadow_ray_sampling_method", expand=True)
 				
-			if (lamp.type in ('POINT', 'SUN', 'SPOT') and lamp.shadow_ray_sampling_method in ('CONSTANT_QMC', 'ADAPTIVE_QMC')):
-				layout.column_flow()
-				layout.itemR(lamp, "shadow_soft_size", text="Soft Size")
-				layout.itemR(lamp, "shadow_ray_samples", text="Samples")
-				if (lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC'):
-					layout.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
+			if lamp.type in ('POINT', 'SUN', 'SPOT') and lamp.shadow_ray_sampling_method in ('CONSTANT_QMC', 'ADAPTIVE_QMC'):
+				flow = layout.column_flow()
+				flow.itemR(lamp, "shadow_soft_size", text="Soft Size")
+				flow.itemR(lamp, "shadow_ray_samples", text="Samples")
+				if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
+					flow.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
 						
-			if (lamp.type == 'AREA'):
-				layout.column_flow()
-				layout.itemR(lamp, "shadow_ray_samples_x", text="Samples")
-				if (lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC'):
-					layout.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
-				if (lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED'):
-					layout.itemR(lamp, "umbra")
-					layout.itemR(lamp, "dither")
-					layout.itemR(lamp, "jitter")	
-		
-		if (lamp.shadow_method == 'BUFFER_SHADOW'):
-			layout.column()
-			layout.itemL(text="Buffer Type:")
-			layout.itemR(lamp, "shadow_buffer_type", expand=True)
+			if lamp.type == 'AREA':
+				flow = layout.column_flow()
+				flow.itemR(lamp, "shadow_ray_samples_x", text="Samples")
+				if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
+					flow.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
+				if lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED':
+					flow.itemR(lamp, "umbra")
+					flow.itemR(lamp, "dither")
+					flow.itemR(lamp, "jitter")	
+	
+		if lamp.shadow_method == 'BUFFER_SHADOW':
+			col = layout.column()
+			col.itemL(text="Buffer Type:")
+			col.row().itemR(lamp, "shadow_buffer_type", expand=True)
 
-			if (lamp.shadow_buffer_type in ('REGULAR', 'HALFWAY')):
-				layout.column_flow()
-				layout.itemL(text="Sample Buffers:")
-				layout.itemR(lamp, "shadow_sample_buffers", expand=True)
-				layout.itemL(text="Filter Type:")
-				layout.itemR(lamp, "shadow_filter_type", expand=True)
-				layout.column_flow()
-				layout.itemR(lamp, "shadow_buffer_size", text="Size")
-				layout.itemR(lamp, "shadow_buffer_samples", text="Samples")
-				layout.itemR(lamp, "shadow_buffer_bias", text="Bias")
-				layout.itemR(lamp, "shadow_buffer_soft", text="Soft")
+			if lamp.shadow_buffer_type in ('REGULAR', 'HALFWAY'):
+				flow = layout.column_flow()
+				flow.itemL(text="Sample Buffers:")
+				flow.row().itemR(lamp, "shadow_sample_buffers", expand=True)
+				flow.itemL(text="Filter Type:")
+				flow.row().itemR(lamp, "shadow_filter_type", expand=True)
+				flow = layout.column_flow()
+				flow.itemR(lamp, "shadow_buffer_size", text="Size")
+				flow.itemR(lamp, "shadow_buffer_samples", text="Samples")
+				flow.itemR(lamp, "shadow_buffer_bias", text="Bias")
+				flow.itemR(lamp, "shadow_buffer_soft", text="Soft")
 				
 			if (lamp.shadow_buffer_type == 'IRREGULAR'):
-				layout.row()
-				layout.itemR(lamp, "shadow_buffer_bias", text="Bias")
+				row = layout.row()
+				row.itemR(lamp, "shadow_buffer_bias", text="Bias")
 			
-			layout.row()
-			layout.itemR(lamp, "auto_clip_start", text="Autoclip Start")
+			row = layout.row()
+			row.itemR(lamp, "auto_clip_start", text="Autoclip Start")
 			if not (lamp.auto_clip_start):
-				layout.itemR(lamp, "shadow_buffer_clip_start", text="Clip Start")

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list