NLA Branch: Merge from 2.5 20116:20214
authorJoshua Leung <aligorith@gmail.com>
Fri, 15 May 2009 13:35:29 +0000 (13:35 +0000)
committerJoshua Leung <aligorith@gmail.com>
Fri, 15 May 2009 13:35:29 +0000 (13:35 +0000)
74 files changed:
projectfiles_vc9/blender/editors/ED_editors.vcproj
release/ui/buttons_data_camera.py
release/ui/buttons_data_empty.py [new file with mode: 0644]
release/ui/buttons_data_lamp.py
release/ui/buttons_data_lattice.py
release/ui/buttons_data_modifier.py
release/ui/buttons_material.py [new file with mode: 0644]
release/ui/buttons_objects.py
release/ui/buttons_scene.py
release/ui/buttons_world.py
release/ui/space_text.py
source/blender/blenkernel/intern/fcurve.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/animation/anim_ipo_utils.c
source/blender/editors/animation/keyframing.c
source/blender/editors/armature/editarmature.c
source/blender/editors/armature/poselib.c
source/blender/editors/curve/curve_ops.c
source/blender/editors/curve/editcurve.c
source/blender/editors/include/BIF_glutil.h
source/blender/editors/include/ED_fileselect.h
source/blender/editors/include/ED_screen.h
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_anim.c
source/blender/editors/interface/interface_api.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/interface/interface_style.c
source/blender/editors/interface/interface_templates.c [new file with mode: 0644]
source/blender/editors/interface/interface_utils.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/object/object_edit.c
source/blender/editors/physics/editparticle.c
source/blender/editors/screen/area.c
source/blender/editors/screen/glutil.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_file/Makefile
source/blender/editors/space_file/SConscript
source/blender/editors/space_file/file_draw.c
source/blender/editors/space_file/file_header.c
source/blender/editors/space_file/file_intern.h
source/blender/editors/space_file/file_ops.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_file/filelist.h
source/blender/editors/space_file/filesel.c
source/blender/editors/space_graph/graph_edit.c
source/blender/editors/space_image/image_header.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_text/space_text.c
source/blender/editors/space_text/text_header.c
source/blender/editors/space_text/text_ops.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/editors/space_view3d/view3d_snap.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_ops.c
source/blender/editors/uvedit/uvedit_unwrap_ops.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_context.c
source/blender/makesrna/intern/rna_curve.c
source/blender/makesrna/intern/rna_lamp.c
source/blender/makesrna/intern/rna_material.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_screen.c
source/blender/python/epy_doc_gen.py
source/blender/python/intern/bpy_interface.c
source/blender/python/intern/bpy_ui.c
source/blender/windowmanager/intern/wm_operators.c

index a7deb22555ef4823ed862c0b805af20ca6450103..7f3cac8df2a69610a57bbbbdb2b810ed739ab83a 100644 (file)
@@ -44,7 +44,7 @@
                                Name="VCCLCompilerTool"\r
                                InlineFunctionExpansion="1"\r
                                AdditionalIncludeDirectories="..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\build\msvc_9\intern\bsp\include;..\..\..\..\build\msvc_9\intern\ghost\include;..\..\..\..\build\msvc_9\intern\elbeem\include;..\..\..\..\build\msvc_9\intern\opennl\include;..\..\..\..\build\msvc_9\intern\bmfont\include;..\..\..\..\build\msvc_9\intern\blenkey\include;..\..\..\..\build\msvc_9\intern\decimation\include;..\..\..\..\build\msvc_9\intern\memutil\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\source\blender;..\..\..\source\blender\img;..\..\..\source\blender\verify;..\..\..\source\blender\ftfont;..\..\..\source\blender\misc;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\editors\include;..\..\..\source\blender\renderui;..\..\..\source\blender\blenloader;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenfont;..\..\..\source\blender\makesdna;..\..\..\source\blender\makesrna;..\..\..\source\blender\nodes;..\..\..\source\blender\windowmanager;..\..\..\source\blender\blenpluginapi;..\..\..\source\blender\renderconverter;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include;..\..\..\source\blender\radiosity\extern\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\network;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\..\build\msvc_9\extern\verse\include;..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\blender\gpu"\r
-                               PreprocessorDefinitions="NDEBUG;WIN32;_LIB;_CONSOLE;GAMEBLENDER=1;WITH_QUICKTIME;INTERNATIONAL;WITH_OPENEXR;WITH_DDS;WITH_BULLET=1;WITH_FFMPEG"\r
+                               PreprocessorDefinitions="NDEBUG;WIN32;_LIB;_CONSOLE;GAMEBLENDER=1;WITH_QUICKTIME;INTERNATIONAL;WITH_FREETYPE2;WITH_INTERNATIONAL;WITH_OPENEXR;WITH_DDS;WITH_BULLET=1;WITH_FFMPEG"\r
                                StringPooling="true"\r
                                RuntimeLibrary="0"\r
                                EnableFunctionLevelLinking="true"\r
                                Name="VCCLCompilerTool"\r
                                Optimization="0"\r
                                AdditionalIncludeDirectories="..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\build\msvc_9\intern\bsp\include;..\..\..\..\build\msvc_9\intern\ghost\include;..\..\..\..\build\msvc_9\intern\elbeem\include;..\..\..\..\build\msvc_9\intern\opennl\include;..\..\..\..\build\msvc_9\intern\bmfont\include;..\..\..\..\build\msvc_9\intern\blenkey\include;..\..\..\..\build\msvc_9\intern\decimation\include;..\..\..\..\build\msvc_9\intern\memutil\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\source\blender;..\..\..\source\blender\img;..\..\..\source\blender\verify;..\..\..\source\blender\ftfont;..\..\..\source\blender\misc;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\editors\include;..\..\..\source\blender\renderui;..\..\..\source\blender\blenloader;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenfont;..\..\..\source\blender\makesdna;..\..\..\source\blender\makesrna;..\..\..\source\blender\nodes;..\..\..\source\blender\windowmanager;..\..\..\source\blender\blenpluginapi;..\..\..\source\blender\renderconverter;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include;..\..\..\source\blender\radiosity\extern\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\network;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\..\build\msvc_9\extern\verse\include;..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\blender\gpu"\r
-                               PreprocessorDefinitions="_DEBUG;WIN32;_LIB;_CONSOLE;GAMEBLENDER;WITH_QUICKTIME;INTERNATIONAL;WITH_OPENEXR;WITH_DDS;WITH_BULLET = 1;WITH_FFMPEG"\r
+                               PreprocessorDefinitions="_DEBUG;WIN32;_LIB;_CONSOLE;GAMEBLENDER;WITH_QUICKTIME;INTERNATIONAL;WITH_BF_INTERNATIONAL;WITH_FREETYPE2;WITH_OPENEXR;WITH_DDS;WITH_BULLET = 1;WITH_FFMPEG"\r
                                BasicRuntimeChecks="3"\r
                                RuntimeLibrary="1"\r
                                DefaultCharIsUnsigned="true"\r
index 0f852216a87690e6331df23b809a4c39a20d4f4d..27f63669cf74877aea6b19ab3540c9978a632e6e 100644 (file)
@@ -21,30 +21,30 @@ class DATA_PT_cameralens(DataButtonsPanel):
                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 @@ class DATA_PT_cameradisplay(DataButtonsPanel):
                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)
diff --git a/release/ui/buttons_data_empty.py b/release/ui/buttons_data_empty.py
new file mode 100644 (file)
index 0000000..5fe1e94
--- /dev/null
@@ -0,0 +1,27 @@
+
+import bpy
+
+class DataButtonsPanel(bpy.types.Panel):
+       __space_type__ = "BUTTONS_WINDOW"
+       __region_type__ = "WINDOW"
+       __context__ = "data"
+       
+       def poll(self, context):
+               ob = context.active_object
+               return (ob and ob.type == 'EMPTY')
+       
+class DATA_PT_empty(DataButtonsPanel):
+       __idname__ = "DATA_PT_empty"
+       __label__ = "Empty"
+
+       def draw(self, context):
+               ob = context.active_object
+               layout = self.layout
+
+               if not ob:
+                       return
+                       
+               layout.itemR(ob, "empty_draw_type")
+               layout.itemR(ob, "empty_draw_size")
+               
+bpy.types.register(DATA_PT_empty)
index 5db840ccefed7f98d97df64a2abf4c1b4461709b..da2701a43f234ff39bcf5c1d3067f455b950c19f 100644 (file)
@@ -21,29 +21,23 @@ class DATA_PT_lamp(DataButtonsPanel):
                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.itemL(text="LAMP DATABLOCKS")
+               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.itemL(text="Illumination:")
-               sub.itemR(lamp, "layer")
-               sub.itemR(lamp, "negative")
+               sub = split.column()
+               sub.itemR(lamp, "layer", text="This Layer Only")
                sub.itemR(lamp, "specular")
                sub.itemR(lamp, "diffuse")
                
-               if (lamp.type in ('LOCAL', 'SPOT')):
-                       sub.column()
+               if lamp.type in ('POINT', 'SPOT'):
                        sub.itemR(lamp, "falloff_type")
                        sub.itemR(lamp, "sphere")
                        
@@ -51,7 +45,7 @@ class DATA_PT_lamp(DataButtonsPanel):
                                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")
@@ -77,33 +71,31 @@ class DATA_PT_sunsky(DataButtonsPanel):
                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 = 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")
-                               sub.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")
-                       
-                       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")
@@ -116,7 +108,7 @@ class DATA_PT_shadow(DataButtonsPanel):
        def poll(self, context):
                ob = context.active_object
                lamp = context.main.lamps[0]
-               return (ob.type == 'LAMP' and lamp.type in ('LOCAL','SUN', 'SPOT', 'AREA'))
+               return (ob.type == 'LAMP' and lamp.type in ('POINT','SUN', 'SPOT', 'AREA'))
 
        def draw(self, context):
                lamp = context.main.lamps[0]
@@ -125,42 +117,72 @@ class DATA_PT_shadow(DataButtonsPanel):
                if not lamp:
                        return
                
-               layout.row()
                layout.itemR(lamp, "shadow_method", expand=True)
                
-               layout.row()
-               layout.itemR(lamp, "only_shadow")
-               layout.itemR(lamp, "shadow_layer", text="Layer")
-               if (lamp.shadow_method == 'RAY_SHADOW'):
-                       if (lamp.type in ('LOCAL', 'SUN', 'SPOT', 'AREA')):
-
-                               layout.split(number=2)
-
-                               sub = layout.sub(0)
-                               sub.column()
-                               sub.itemL(text="Display:")
-                               sub.itemR(lamp, "shadow_color")
+               if lamp.shadow_method in ('BUFFER_SHADOW', 'RAY_SHADOW'):
                
-                               sub = layout.sub(1)
-                               sub.column()
-                               sub.itemL(text="Sampling:")
-                               sub.itemR(lamp, "shadow_ray_sampling_method", text="")
+                       split = layout.split()
+                       
+                       sub = split.column()
+                       sub.itemR(lamp, "only_shadow")
+                       sub.itemR(lamp, "shadow_layer")
+                       
+                       sub = split.column()
+                       sub.itemR(lamp, "shadow_color")
+               
+               if lamp.shadow_method == 'RAY_SHADOW':
+               
+                       col = layout.column()
+                       col.itemL(text="Sampling:")
+                       col.row().itemR(lamp, "shadow_ray_sampling_method", expand=True)
                                
-                               if (lamp.type in ('LOCAL', 'SUN', 'SPOT') and lamp.shadow_ray_sampling_method in ('CONSTANT_QMC', 'ADAPTIVE_QMC')):
-                                       sub.itemR(lamp, "shadow_soft_size", text="Soft Size")
-                                       sub.itemR(lamp, "shadow_ray_samples", text="Samples")
-                                       if (lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC'):
-                                               sub.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
-                                               
-                               if (lamp.type == 'AREA'):
-                                       sub.itemR(lamp, "shadow_ray_samples_x", text="Samples")
-                                       if (lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC'):
-                                               sub.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
-                                       if (lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED'):
-                                               sub.itemR(lamp, "umbra")
-                                               sub.itemR(lamp, "dither")
-                                               sub.itemR(lamp, "jitter")
+                       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':
+                               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'):
+                               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'):
+                               row = layout.row()
+                               row.itemR(lamp, "shadow_buffer_bias", text="Bias")
+                       
+                       row = layout.row()
+                       row.itemR(lamp, "auto_clip_start", text="Autoclip Start")
+                       if not (lamp.auto_clip_start):
+                               row.itemR(lamp, "shadow_buffer_clip_start", text="Clip Start")
+                       row = layout.row()
+                       row.itemR(lamp, "auto_clip_end", text="Autoclip End")
+                       if not (lamp.auto_clip_end):
+                               row.itemR(lamp, "shadow_buffer_clip_end", text=" Clip End")
+
 class DATA_PT_spot(DataButtonsPanel):
        __idname__ = "DATA_PT_spot"
        __label__ = "Spot"
@@ -177,20 +199,21 @@ class DATA_PT_spot(DataButtonsPanel):
                if not lamp:
                        return
                
-               layout.split(number=2)
+               split = layout.split()
                
-               sub = layout.sub(0)
-               sub.column()
+               sub = split.column()
                sub.itemR(lamp, "square")
-               sub.itemR(lamp, "halo")
-               
-               sub = layout.sub(1)
-               sub.column()
                sub.itemR(lamp, "spot_size")
                sub.itemR(lamp, "spot_blend")
-               sub.itemR(lamp, "halo_intensity")
+               
+               sub = split.column()
+               sub.itemR(lamp, "halo")
+               if lamp.halo:
+                       sub.itemR(lamp, "halo_intensity")
+                       if lamp.shadow_method == 'BUFFER_SHADOW':
+                               sub.itemR(lamp, "halo_step")
 
 bpy.types.register(DATA_PT_lamp)
-bpy.types.register(DATA_PT_sunsky)
 bpy.types.register(DATA_PT_shadow)
+bpy.types.register(DATA_PT_sunsky)
 bpy.types.register(DATA_PT_spot)
index cf2053ae495af3d6491e040da9d2128a7bb93a10..0446f3916a17b6afda5eac270b55441e2ea63fe6 100644 (file)
@@ -21,20 +21,20 @@ class DATA_PT_lattice(DataButtonsPanel):
                if not lat:
                        return
                
-               layout.row()
-               layout.itemR(lat, "points_u")
-               layout.itemR(lat, "interpolation_type_u", expand=True)
+               row = layout.row()
+               row.itemR(lat, "points_u")
+               row.itemR(lat, "interpolation_type_u", expand=True)
                
-               layout.row()
-               layout.itemR(lat, "points_v")
-               layout.itemR(lat, "interpolation_type_v", expand=True)
+               row = layout.row()
+               row.itemR(lat, "points_v")
+               row.itemR(lat, "interpolation_type_v", expand=True)
                
-               layout.row()
-               layout.itemR(lat, "points_w")
-               layout.itemR(lat, "interpolation_type_w", expand=True)
+               row = layout.row()
+               row.itemR(lat, "points_w")
+               row.itemR(lat, "interpolation_type_w", expand=True)
                
-               layout.row()
-               layout.itemR(lat, "outside")
-               layout.itemR(lat, "shape_keys")
+               row = layout.row()
+               row.itemR(lat, "outside")
+               row.itemR(lat, "shape_keys")
 
-bpy.types.register(DATA_PT_lattice)
\ No newline at end of file
+bpy.types.register(DATA_PT_lattice)
index f07a6cc48822c8829a25fd56f40c0f53e072370a..b93f0d6f218b3ebbdd34634e7a57e9313751d776 100644 (file)
@@ -27,34 +27,32 @@ class DATA_PT_modifiers(DataButtonsPanel):
                for md in ob.modifiers:
                        sub = layout.box()
 
-                       sub.row()
-                       sub.itemR(md, "expanded", text="")
-                       sub.itemR(md, "name", text="")
+                       row = sub.row()
+                       row.itemR(md, "expanded", text="")
+                       row.itemR(md, "name", text="")
 
-                       sub.itemR(md, "render", text="")
-                       sub.itemR(md, "realtime", text="")
-                       sub.itemR(md, "editmode", text="")
-                       sub.itemR(md, "on_cage", text="")
+                       row.itemR(md, "render", text="")
+                       row.itemR(md, "realtime", text="")
+                       row.itemR(md, "editmode", text="")
+                       row.itemR(md, "on_cage", text="")
 
-                       if (md.expanded):
-                               sub.row()
+                       if md.expanded:
                                sub.itemS()
 
                                if (md.type == 'ARMATURE'):
                                        self.armature(sub, md)
 
        def armature(self, layout, md):
-               layout.column()
                layout.itemR(md, "object")
-               layout.row()
-               layout.itemR(md, "vertex_group")
-               layout.itemR(md, "invert")
-               layout.column_flow()
-               layout.itemR(md, "use_vertex_groups")
-               layout.itemR(md, "use_bone_envelopes")
-               layout.itemR(md, "quaternion")
-               layout.itemR(md, "b_bone_rest")
-               layout.itemR(md, "multi_modifier")
+               row = layout.row()
+               row.itemR(md, "vertex_group")
+               row.itemR(md, "invert")
+               flow = layout.column_flow()
+               flow.itemR(md, "use_vertex_groups")
+               flow.itemR(md, "use_bone_envelopes")
+               flow.itemR(md, "quaternion")
+               flow.itemR(md, "b_bone_rest")
+               flow.itemR(md, "multi_modifier")
                
 bpy.types.register(DATA_PT_modifiers)
 
diff --git a/release/ui/buttons_material.py b/release/ui/buttons_material.py
new file mode 100644 (file)
index 0000000..a80ae8d
--- /dev/null
@@ -0,0 +1,196 @@
+
+import bpy
+
+class MaterialButtonsPanel(bpy.types.Panel):
+       __space_type__ = "BUTTONS_WINDOW"
+       __region_type__ = "WINDOW"
+       __context__ = "material"
+       
+class MATERIAL_PT_material(MaterialButtonsPanel):
+       __idname__= "MATERIAL_PT_material"
+       __label__ = "Material"
+       
+       def draw(self, context):
+               layout = self.layout
+               try:            
+                       mat = context.active_object.active_material
+               except: 
+                       mat = None
+               
+               if not mat:
+                       return
+       
+               row = layout.row()
+               row.column().itemR(mat, "diffuse_color")
+               row.column().itemR(mat, "specular_color")
+               row.column().itemR(mat, "mirror_color")
+               
+               row = layout.row()
+               row.itemR(mat, "color_model")
+               row.itemR(mat, "alpha")
+                       
+class MATERIAL_PT_sss(MaterialButtonsPanel):
+       __idname__= "MATERIAL_PT_sss"
+       __label__ = "Subsurface Scattering"
+       
+       def draw(self, context):
+               layout = self.layout
+               try:            
+                       sss = context.active_object.active_material.subsurface_scattering
+               except: 
+                       sss = None
+               
+               if not sss:
+                       return
+               
+               layout.itemR(sss, "enabled", text="Enable")
+               
+               flow = layout.column_flow()
+               flow.itemR(sss, "error_tolerance")
+               flow.itemR(sss, "ior")
+               flow.itemR(sss, "scale")
+               
+               row = layout.row()
+               row.column().itemR(sss, "color")
+               row.column().itemR(sss, "radius")
+               
+               flow = layout.column_flow()
+               flow.itemR(sss, "color_factor")
+               flow.itemR(sss, "texture_factor")
+               flow.itemR(sss, "front")
+               flow.itemR(sss, "back")
+               
+class MATERIAL_PT_raymir(MaterialButtonsPanel):
+       __idname__= "MATERIAL_PT_raymir"
+       __label__ = "Ray Mirror"
+       
+       def draw(self, context):
+               layout = self.layout
+               try:            
+                       raym = context.active_object.active_material.raytrace_mirror
+               except: 
+                       raym = None
+               
+               if not raym:
+                       return 
+               
+               layout.itemR(raym, "enabled", text="Enable")
+               
+               split = layout.split()
+               
+               sub = split.column()
+               sub.itemR(raym, "reflect", text="RayMir")
+               sub.itemR(raym, "fresnel")
+               sub.itemR(raym, "fresnel_fac", text="Fac")
+               
+               sub = split.column()
+               sub.itemR(raym, "gloss")
+               sub.itemR(raym, "gloss_threshold")
+               sub.itemR(raym, "gloss_samples")
+               sub.itemR(raym, "gloss_anisotropic")
+               
+               flow = layout.column_flow()
+               flow.itemR(raym, "distance", text="Max Dist")
+               flow.itemR(raym, "depth")
+               flow.itemR(raym, "fade_to")
+               
+class MATERIAL_PT_raytransp(MaterialButtonsPanel):
+       __idname__= "MATERIAL_PT_raytransp"
+       __label__= "Ray Transparency"
+
+       def draw(self, context):
+               layout = self.layout
+               try:            
+                       rayt = context.active_object.active_material.raytrace_transparency
+               except: 
+                       rayt = None
+
+               if not rayt:
+                       return
+
+               layout.itemR(rayt, "enabled", text="Enable")
+               
+               split = layout.split()
+               
+               sub = split.column()
+               sub.itemR(rayt, "ior")
+               sub.itemR(rayt, "fresnel")
+               sub.itemR(rayt, "fresnel_fac", text="Fac")
+               
+               sub = split.column()
+               sub.itemR(rayt, "gloss")
+               sub.itemR(rayt, "gloss_threshold")
+               sub.itemR(rayt, "gloss_samples")
+               
+               flow = layout.column_flow()
+               flow.itemR(rayt, "filter")
+               flow.itemR(rayt, "limit")
+               flow.itemR(rayt, "falloff")
+               flow.itemR(rayt, "specular_opacity")
+               flow.itemR(rayt, "depth")
+               
+class MATERIAL_PT_halo(MaterialButtonsPanel):
+       __idname__= "MATERIAL_PT_halo"
+       __label__= "Halo"
+       
+       def draw(self, context):
+               layout = self.layout
+               try:            
+                       halo = context.active_object.active_material.halo
+               except: 
+                       halo = None
+
+               if not halo:
+                       return
+       
+               layout.itemR(halo, "enabled", text="Enable Halo")
+
+               if halo.enabled:
+                       
+                       split = layout.split()
+                       
+                       sub = split.column()
+                       sub.itemL(text="General Settings:")
+                       sub.itemR(halo, "size")
+                       sub.itemR(halo, "hardness")
+                       sub.itemR(halo, "add")
+                       
+                       sub = split.column()
+                       sub.itemL(text="Elements:")
+                       sub.itemR(halo, "ring")
+                       sub.itemR(halo, "lines")
+                       sub.itemR(halo, "star")
+                       sub.itemR(halo, "flare_mode")
+
+                       row = layout.row()
+                       
+                       sub = row.column()
+                       sub.itemL(text="Options:")
+                       sub.itemR(halo, "use_texture", text="Texture")
+                       sub.itemR(halo, "use_vertex_normal", text="Vertex Normal")
+                       sub.itemR(halo, "xalpha")
+                       sub.itemR(halo, "shaded")
+                       sub.itemR(halo, "soft")
+               
+                       sub = row.column()
+                       if (halo.ring):
+                               sub.itemR(halo, "rings")
+                       if (halo.lines):
+                               sub.itemR(halo, "line_number")
+                       if (halo.ring or halo.lines):
+                               sub.itemR(halo, "seed")
+                       if (halo.star):
+                               sub.itemR(halo, "star_tips")
+                       if (halo.flare_mode):
+                               sub.itemL(text="Flare:")
+                               sub.itemR(halo, "flare_size", text="Size")
+                               sub.itemR(halo, "flare_subsize", text="Subsize")
+                               sub.itemR(halo, "flare_boost", text="Boost")
+                               sub.itemR(halo, "flare_seed", text="Seed")
+                               sub.itemR(halo, "flares_sub", text="Sub")
+                               
+bpy.types.register(MATERIAL_PT_material)
+bpy.types.register(MATERIAL_PT_raymir)
+bpy.types.register(MATERIAL_PT_raytransp)
+bpy.types.register(MATERIAL_PT_sss)
+bpy.types.register(MATERIAL_PT_halo)
index 8e76bf5083732d6631b51601deddf6fe7cbac7e0..816995be224d464b744e42397eb57c8a39f6e258 100644 (file)
@@ -17,10 +17,10 @@ class OBJECT_PT_transform(ObjectButtonsPanel):
                ob = context.active_object
                layout = self.layout
 
-               layout.row()
-               layout.itemR(ob, "location")
-               layout.itemR(ob, "rotation")
-               layout.itemR(ob, "scale")
+               row = layout.row()
+               row.column().itemR(ob, "location")
+               row.column().itemR(ob, "rotation")
+               row.column().itemR(ob, "scale")
 
 class OBJECT_PT_groups(ObjectButtonsPanel):
        __idname__ = "OBJECT_PT_groups"
@@ -30,24 +30,24 @@ class OBJECT_PT_groups(ObjectButtonsPanel):
                ob = context.active_object
                layout = self.layout
 
-               layout.row()
-               layout.itemR(ob, "pass_index")
-               layout.itemR(ob, "parent")
+               row = layout.row()
+               row.itemR(ob, "pass_index")
+               row.itemR(ob, "parent")
 
                # layout.left_right()
                # layout.itemO("OBJECT_OT_add_group");
 
                for group in bpy.data.groups:
                        if ob in group.objects:
-                               sub = layout.box()
+                               box = layout.box()
 
-                               sub.split(number=2, lr=True)
-                               sub.sub(0).itemR(group, "name")
-                               # sub.sub(1).itemO("OBJECT_OT_remove_group")
+                               row = box.row()
+                               row.itemR(group, "name")
+                               #row.itemO("OBJECT_OT_remove_group")
 
-                               sub.row()
-                               sub.itemR(group, "layer")
-                               sub.itemR(group, "dupli_offset")
+                               row = box.row()
+                               row.column().itemR(group, "layer")
+                               row.column().itemR(group, "dupli_offset")
 
 class OBJECT_PT_display(ObjectButtonsPanel):
        __idname__ = "OBJECT_PT_display"
@@ -57,17 +57,17 @@ class OBJECT_PT_display(ObjectButtonsPanel):
                ob = context.active_object
                layout = self.layout
                        
-               layout.row()
-               layout.itemR(ob, "max_draw_type", text="Type")
-               layout.itemR(ob, "draw_bounds_type", text="Bounds")
-
-               layout.column_flow()
-               layout.itemR(ob, "draw_name", text="Name")
-               layout.itemR(ob, "draw_axis", text="Axis")
-               layout.itemR(ob, "draw_wire", text="Wire")
-               layout.itemR(ob, "draw_texture_space", text="Texture Space")
-               layout.itemR(ob, "x_ray", text="X-Ray")
-               layout.itemR(ob, "draw_transparent", text="Transparency")
+               row = layout.row()
+               row.itemR(ob, "max_draw_type", text="Type")
+               row.itemR(ob, "draw_bounds_type", text="Bounds")
+
+               flow = layout.column_flow()
+               flow.itemR(ob, "draw_name", text="Name")
+               flow.itemR(ob, "draw_axis", text="Axis")
+               flow.itemR(ob, "draw_wire", text="Wire")
+               flow.itemR(ob, "draw_texture_space", text="Texture Space")
+               flow.itemR(ob, "x_ray", text="X-Ray")
+               flow.itemR(ob, "draw_transparent", text="Transparency")
 
 class OBJECT_PT_duplication(ObjectButtonsPanel):
        __idname__ = "OBJECT_PT_duplication"
@@ -77,15 +77,15 @@ class OBJECT_PT_duplication(ObjectButtonsPanel):
                ob = context.active_object
                layout = self.layout
 
-               layout.column()
-               layout.itemR(ob, "dupli_type", text="", expand=True)
+               row = layout.row()
+               row.itemR(ob, "dupli_type", text="", expand=True)
 
                if ob.dupli_type == "FRAMES":
-                       layout.column_flow()
-                       layout.itemR(ob, "dupli_frames_start", text="Start")
-                       layout.itemR(ob, "dupli_frames_end", text="End")
-                       layout.itemR(ob, "dupli_frames_on", text="On")
-                       layout.itemR(ob, "dupli_frames_off", text="Off")
+                       col = layout.column_flow()
+                       col.itemR(ob, "dupli_frames_start", text="Start")
+                       col.itemR(ob, "dupli_frames_end", text="End")
+                       col.itemR(ob, "dupli_frames_on", text="On")
+                       col.itemR(ob, "dupli_frames_off", text="Off")
 
 class OBJECT_PT_animation(ObjectButtonsPanel):
        __idname__ = "OBJECT_PT_animation"
@@ -95,10 +95,9 @@ class OBJECT_PT_animation(ObjectButtonsPanel):
                ob = context.active_object
                layout = self.layout
 
-               layout.split(number=2)
+               row = layout.row()
                
-               sub = layout.sub(0)
-               sub.column()
+               sub = row.column()
                sub.itemL(text="Time Offset:")
                sub.itemR(ob, "time_offset_edit", text="Edit")
                sub.itemR(ob, "time_offset_particle", text="Particle")
@@ -106,8 +105,7 @@ class OBJECT_PT_animation(ObjectButtonsPanel):
                sub.itemR(ob, "slow_parent")
                sub.itemR(ob, "time_offset", text="Offset")
                
-               sub = layout.sub(1)
-               sub.column()
+               sub = row.column()
                sub.itemL(text="Tracking:")
                sub.itemR(ob, "track_axis", text="Axis")
                sub.itemR(ob, "up_axis", text="Up Axis")
index 6b3c7dca49dc471d914bca071c87e2583dff3622..170c94cdef17910f10e1b6ac23166f47a9eb3ea2 100644 (file)
@@ -15,22 +15,19 @@ class RENDER_PT_shading(RenderButtonsPanel):
 
                rd = scene.render_data
                
-               layout.split(number=2)
+               split = layout.split()
                
-               sub = layout.sub(0)
-               sub.column()
+               sub = split.column()
                sub.itemR(rd, "render_shadows", text="Shadows")
                sub.itemR(rd, "render_sss", text="SSS")
                sub.itemR(rd, "render_envmaps", text="EnvMap")
                sub.itemR(rd, "render_radiosity", text="Radio")
                
-               sub = layout.sub(1)
+               sub = split.column()
                subsub = sub.box()
-               subsub.column()
                subsub.itemR(rd, "render_raytracing", text="Ray Tracing")
                if (rd.render_raytracing):
                        subsub.itemR(rd, "octree_resolution", text="Octree")
-               sub.row()
                sub.itemR(rd, "alpha_mode")
                
 class RENDER_PT_image(RenderButtonsPanel):
@@ -42,21 +39,21 @@ class RENDER_PT_image(RenderButtonsPanel):
 
                rd = scene.render_data
 
-               layout.column_flow()
-               layout.itemR(rd, "resolution_x", text="SizeX")
-               layout.itemR(rd, "resolution_y", text="SizeY")
-               layout.itemR(rd, "pixel_aspect_x", text="AspX")
-               layout.itemR(rd, "pixel_aspect_y", text="AspY")
-
-               sub = layout.box()
-               sub.row()
-               sub.itemR(rd, "image_type")
-               sub.row()
-               sub.itemR(rd, "file_extensions")
-               sub.itemR(rd, "color_mode")
+               flow = layout.column_flow()
+               flow.itemR(rd, "resolution_x", text="SizeX")
+               flow.itemR(rd, "resolution_y", text="SizeY")
+               flow.itemR(rd, "pixel_aspect_x", text="AspX")
+               flow.itemR(rd, "pixel_aspect_y", text="AspY")
+
+               box = layout.box()
+               box.itemR(rd, "output_path")
+               box.itemR(rd, "image_type")
+               row = box.row()
+               row.itemR(rd, "file_extensions")
+               row.itemR(rd, "color_mode")
                if rd.image_type in ("AVIJPEG", "JPEG"):
-                       sub.row()
-                       sub.itemR(rd, "quality")
+                       row = box.row()
+                       row.itemR(rd, "quality")
        
 class RENDER_PT_antialiasing(RenderButtonsPanel):
        __label__ = "Anti-Aliasing"
@@ -67,20 +64,21 @@ class RENDER_PT_antialiasing(RenderButtonsPanel):
 
                rd = scene.render_data
 
-               layout.row()
-               layout.itemR(rd, "antialiasing", text="Enable")
-               if (rd.antialiasing):
-                       layout.row()
-                       layout.itemL(text="Samples:")
-                       layout.itemR(rd, "antialiasing_samples", expand=True)
-                       layout.row()
-                       layout.itemR(rd, "pixel_filter")
-                       layout.itemR(rd, "filter_size")
-
-                       layout.row()
-                       layout.itemR(rd, "save_buffers")
-                       if (rd.save_buffers):
-                               layout.itemR(rd, "full_sample")
+               row = layout.row()
+               row.itemR(rd, "antialiasing", text="Enable")
+
+               if rd.antialiasing:
+                       row = layout.row()
+                       row.itemL(text="Samples:")
+                       row.itemR(rd, "antialiasing_samples", expand=True)
+                       row = layout.row()
+                       row.itemR(rd, "pixel_filter")
+                       row.itemR(rd, "filter_size")
+
+                       row = layout.row()
+                       row.itemR(rd, "save_buffers")
+                       if rd.save_buffers:
+                               row.itemR(rd, "full_sample")
 
 class RENDER_PT_render(RenderButtonsPanel):
        __label__ = "Render"
@@ -91,71 +89,67 @@ class RENDER_PT_render(RenderButtonsPanel):
 
                rd = scene.render_data
 
-               layout.row()
-               layout.itemO("SCREEN_OT_render", text="RENDER", icon=0) # ICON_SCENE
-               #layout.itemO("SCREEN_OT_render", text="ANIM", icon=0) # "anim", 1
+               row = layout.row()
+               row.itemO("SCREEN_OT_render", text="RENDER", icon=0) # ICON_SCENE
+               row.item_booleanO("SCREEN_OT_render", "anim", True, text="ANIM", icon=0)
 
-               layout.row()
-               layout.itemR(scene, "start_frame", text="Start")
-               layout.itemR(rd, "fps")
-               layout.itemR(scene, "current_frame", text="Frame")
+               row = layout.row()
+               row.itemR(scene, "start_frame", text="Start")
+               row.itemR(rd, "fps")
+               row.itemR(scene, "current_frame", text="Frame")
                
-               layout.row()
-               layout.itemR(scene, "end_frame", text="End")
-               layout.itemR(rd, "fps_base",text="/")
-               layout.itemR(scene, "frame_step", text="Step")
-
-               layout.row()
-               layout.itemR(rd, "do_composite")
-               layout.itemR(rd, "do_sequence")
-
-               layout.row()
-               layout.itemL(text="General:")
-
-               layout.column_flow()
-               layout.itemR(rd, "resolution_percentage", text="Size ")
-               layout.itemR(rd, "dither_intensity")
-               layout.itemR(rd, "parts_x")
-               layout.itemR(rd, "parts_y")
+               row = layout.row()
+               row.itemR(scene, "end_frame", text="End")
+               row.itemR(rd, "fps_base",text="/")
+               row.itemR(scene, "frame_step", text="Step")
+
+               row = layout.row()
+               row.itemR(rd, "do_composite")
+               row.itemR(rd, "do_sequence")
+
+               row = layout.row()
+               row.itemL(text="General:")
+
+               flow = layout.column_flow()
+               flow.itemR(rd, "resolution_percentage", text="Size ")
+               flow.itemR(rd, "dither_intensity")
+               flow.itemR(rd, "parts_x")
+               flow.itemR(rd, "parts_y")
                
-               layout.split(number=2)
+               split = layout.split()
                
-               sub = layout.sub(0)
+               sub = split.column()
                subsub = sub.box()
-               subsub.column()
                subsub.itemL(text="Threads Mode:")
                subsub.itemR(rd, "threads_mode", expand=True)
                if rd.threads_mode == 'THREADS_FIXED':
                        subsub.itemR(rd, "threads")
                
                subsub = sub.box()
-               subsub.column()
                subsub.itemL(text="Distributed Rendering:")
                subsub.itemR(rd, "placeholders")
                subsub.itemR(rd, "no_overwrite")
                subsub = sub.box()
-               subsub.column()
                subsub.itemR(rd, "fields", text="Fields")
-               if (rd.fields):
+               if rd.fields:
                        subsub.itemR(rd, "fields_still", text="Still")
                        subsub.itemR(rd, "field_order", text="Order")
                
-               sub = layout.sub(1)
+               sub = split.column()
                subsub = sub.box()
-               subsub.column()
                subsub.itemL(text="Extra:")
                subsub.itemR(rd, "panorama")
                subsub.itemR(rd, "backbuf")
                subsub.itemR(rd, "free_image_textures")
                
                subsub = sub.box()
-               subsub.column()
                subsub.itemL(text="Border:")
                subsub.itemR(rd, "border", text="Border Render")
-               if (rd.border):
+               if rd.border:
                        subsub.itemR(rd, "crop_to_border")
 
 bpy.types.register(RENDER_PT_render)
 bpy.types.register(RENDER_PT_antialiasing)
 bpy.types.register(RENDER_PT_shading)
 bpy.types.register(RENDER_PT_image)
+
index 44ce472bf5d4682e14d3df45dc609a3d7df9da78..124c9d3d766131f2ab5d64c44f34353dc69538b8 100644 (file)
@@ -16,15 +16,15 @@ class WORLD_PT_world(WorldButtonsPanel):
                world = context.scene.world
                layout = self.layout
                
-               layout.row()
-               layout.itemR(world, "blend_sky")
-               layout.itemR(world, "paper_sky")
-               layout.itemR(world, "real_sky")
+               row = layout.row()
+               row.itemR(world, "blend_sky")
+               row.itemR(world, "paper_sky")
+               row.itemR(world, "real_sky")
                
-               layout.row()
-               layout.itemR(world, "horizon_color")
-               layout.itemR(world, "zenith_color")
-               layout.itemR(world, "ambient_color")
+               row = layout.row()
+               row.column().itemR(world, "horizon_color")
+               row.column().itemR(world, "zenith_color")
+               row.column().itemR(world, "ambient_color")
                
 class WORLD_PT_color_correction(WorldButtonsPanel):
        __label__ = "Color Correction"
@@ -33,9 +33,9 @@ class WORLD_PT_color_correction(WorldButtonsPanel):
                world = context.scene.world
                layout = self.layout
 
-               layout.row()
-               layout.itemR(world, "exposure")
-               layout.itemR(world, "range")
+               row = layout.row()
+               row.itemR(world, "exposure")
+               row.itemR(world, "range")
        
 class WORLD_PT_mist(WorldButtonsPanel):
        __label__ = "Mist"
@@ -44,18 +44,18 @@ class WORLD_PT_mist(WorldButtonsPanel):
                world = context.scene.world
                layout = self.layout
 
-               layout.row()
-               layout.itemR(world.mist, "enabled", text="Enable")
+               row = layout.row()
+               row.itemR(world.mist, "enabled", text="Enable")
                if (world.mist.enabled):
        
-                       layout.column_flow()
-                       layout.itemR(world.mist, "start")
-                       layout.itemR(world.mist, "depth")
-                       layout.itemR(world.mist, "height")
-                       layout.itemR(world.mist, "intensity")
-                       layout.column()
-                       layout.itemL(text="Fallof:")
-                       layout.itemR(world.mist, "falloff", expand=True)
+                       flow = layout.column_flow()
+                       flow.itemR(world.mist, "start")
+                       flow.itemR(world.mist, "depth")
+                       flow.itemR(world.mist, "height")
+                       flow.itemR(world.mist, "intensity")
+                       col = layout.column()
+                       col.itemL(text="Fallof:")
+                       col.row().itemR(world.mist, "falloff", expand=True)
                
 class WORLD_PT_stars(WorldButtonsPanel):
        __label__ = "Stars"
@@ -64,15 +64,15 @@ class WORLD_PT_stars(WorldButtonsPanel):
                world = context.scene.world
                layout = self.layout
 
-               layout.row()
-               layout.itemR(world.stars, "enabled", text="Enable")
+               row = layout.row()
+               row.itemR(world.stars, "enabled", text="Enable")
                if (world.stars.enabled):
 
-                       layout.column_flow()
-                       layout.itemR(world.stars, "size")
-                       layout.itemR(world.stars, "min_distance", text="MinDist")
-                       layout.itemR(world.stars, "average_separation", text="StarDist")
-                       layout.itemR(world.stars, "color_randomization", text="Colnoise")
+                       flow = layout.column_flow()
+                       flow.itemR(world.stars, "size")
+                       flow.itemR(world.stars, "min_distance", text="MinDist")
+                       flow.itemR(world.stars, "average_separation", text="StarDist")
+                       flow.itemR(world.stars, "color_randomization", text="Colnoise")
                
 class WORLD_PT_ambient_occlusion(WorldButtonsPanel):
        __label__ = "Ambient Occlusion"
@@ -83,49 +83,49 @@ class WORLD_PT_ambient_occlusion(WorldButtonsPanel):
 
                ao = world.ambient_occlusion
                
-               layout.row()
-               layout.itemR(ao, "enabled", text="Enable")
+               row = layout.row()
+               row.itemR(ao, "enabled", text="Enable")
                if (ao.enabled):
 
-                       layout.row()
-                       layout.itemR(ao, "gather_method", expand=True)
+                       row = layout.row()
+                       row.itemR(ao, "gather_method", expand=True)
                        
                        if ao.gather_method == 'RAYTRACE':
-                               layout.row()
-                               layout.itemR(ao, "samples")
-                               layout.itemR(ao, "distance")
+                               row = layout.row()
+                               row.itemR(ao, "samples")
+                               row.itemR(ao, "distance")
                                
-                               layout.row()
-                               layout.itemR(ao, "sample_method")
+                               row = layout.row()
+                               row.itemR(ao, "sample_method")
                                if ao.sample_method == 'ADAPTIVE_QMC':
-                                       layout.row()
-                                       layout.itemR(ao, "threshold")
-                                       layout.itemR(ao, "adapt_to_speed")
+                                       row = layout.row()
+                                       row.itemR(ao, "threshold")
+                                       row.itemR(ao, "adapt_to_speed")
                                        
                                if ao.sample_method == 'CONSTANT_JITTERED':
-                                       layout.row()
-                                       layout.itemR(ao, "bias")
+                                       row = layout.row()
+                                       row.itemR(ao, "bias")
                                                        
                        if ao.gather_method == 'APPROXIMATE':
-                               layout.row()
-                               layout.itemR(ao, "passes")
-                               layout.itemR(ao, "error_tolerance")
+                               row = layout.row()
+                               row.itemR(ao, "passes")
+                               row.itemR(ao, "error_tolerance")
                                
-                               layout.row()
-                               layout.itemR(ao, "correction")
-                               layout.itemR(ao, "pixel_cache")
+                               row = layout.row()
+                               row.itemR(ao, "correction")
+                               row.itemR(ao, "pixel_cache")
 
-                       layout.row()
-                       layout.itemS()
+                       row = layout.row()
+                       row.itemS()
                                
-                       layout.row()
-                       layout.itemR(ao, "falloff")     
-                       layout.itemR(ao, "strength")
+                       row = layout.row()
+                       row.itemR(ao, "falloff")        
+                       row.itemR(ao, "strength")
                        
-                       layout.column()
-                       layout.itemR(ao, "blend_mode", expand=True)
-                       layout.itemR(ao, "color", expand=True)
-                       layout.itemR(ao, "energy")
+                       col = layout.column()
+                       col.row().itemR(ao, "blend_mode", expand=True)
+                       col.row().itemR(ao, "color", expand=True)
+                       col.itemR(ao, "energy")
        
 bpy.types.register(WORLD_PT_world)
 bpy.types.register(WORLD_PT_mist)
index a3d27370ffa5b33f1e55a3b58fdc9dfd6940e367..d4187c10b69beb752ad3938705f2059efcf234f1 100644 (file)
@@ -18,38 +18,40 @@ class TEXT_HT_header(bpy.types.Header):
                text = st.text
                layout = self.layout
 
-               layout.template_header()
-               layout.itemM("TEXT_MT_text")
-               if text:
-                       layout.itemM("TEXT_MT_edit")
-                       layout.itemM("TEXT_MT_format")
+               layout.template_header(context)
+
+               if context.area.show_menus:
+                       row = layout.row(align=True)
+                       row.itemM(context, "TEXT_MT_text")
+                       if text:
+                               row.itemM(context, "TEXT_MT_edit")
+                               row.itemM(context, "TEXT_MT_format")
 
                if text and text.modified:
-                       layout.row()
-                       # layout.color(redalert)
-                       layout.itemO("TEXT_OT_resolve_conflict", text="", icon=ICON_HELP)
+                       row = layout.row()
+                       # row.color(redalert)
+                       row.itemO("TEXT_OT_resolve_conflict", text="", icon=ICON_HELP)
 
-               layout.row()
-               layout.itemR(st, "line_numbers", text="", icon=ICON_LINENUMBERS_OFF)
-               layout.itemR(st, "word_wrap", text="", icon=ICON_WORDWRAP_OFF)
-               layout.itemR(st, "syntax_highlight", text="", icon=ICON_SYNTAX_OFF)
-               # layout.itemR(st, "do_python_plugins", text="", icon=ICON_SCRIPTPLUGINS)
+               row = layout.row(align=True)
+               row.itemR(st, "line_numbers", text="", icon=ICON_LINENUMBERS_OFF)
+               row.itemR(st, "word_wrap", text="", icon=ICON_WORDWRAP_OFF)
+               row.itemR(st, "syntax_highlight", text="", icon=ICON_SYNTAX_OFF)
+               # row.itemR(st, "do_python_plugins", text="", icon=ICON_SCRIPTPLUGINS)
 
-               layout.row()
-               layout.template_header_ID(st, "text", new="TEXT_OT_new", open="TEXT_OT_open", unlink="TEXT_OT_unlink")
+               layout.template_header_ID(context, st, "text", new="TEXT_OT_new", open="TEXT_OT_open", unlink="TEXT_OT_unlink")
 
                if text:
-                       layout.row()
+                       row = layout.row()
                        if text.filename != "":
                                if text.dirty:
-                                       layout.itemL(text="File: *" + text.filename + " (unsaved)")
+                                       row.itemL(text="File: *" + text.filename + " (unsaved)")
                                else:
-                                       layout.itemL(text="File: " + text.filename)
+                                       row.itemL(text="File: " + text.filename)
                        else:
                                if text.library:
-                                       layout.itemL(text="Text: External")
+                                       row.itemL(text="Text: External")
                                else:
-                                       layout.itemL(text="Text: Internal")
+                                       row.itemL(text="Text: Internal")
 
 class TEXT_PT_properties(bpy.types.Panel):
        __space_type__ = "TEXT_EDITOR"
@@ -60,14 +62,14 @@ class TEXT_PT_properties(bpy.types.Panel):
                st = context.space_data
                layout = self.layout
 
-               layout.column_flow()
-               layout.itemR(st, "line_numbers", icon=ICON_LINENUMBERS_OFF)
-               layout.itemR(st, "word_wrap", icon=ICON_WORDWRAP_OFF)
-               layout.itemR(st, "syntax_highlight", icon=ICON_SYNTAX_OFF)
+               flow = layout.column_flow()
+               flow.itemR(st, "line_numbers", icon=ICON_LINENUMBERS_OFF)
+               flow.itemR(st, "word_wrap", icon=ICON_WORDWRAP_OFF)
+               flow.itemR(st, "syntax_highlight", icon=ICON_SYNTAX_OFF)
 
-               layout.column_flow()
-               layout.itemR(st, "font_size")
-               layout.itemR(st, "tab_width")
+               flow = layout.column_flow()
+               flow.itemR(st, "font_size")
+               flow.itemR(st, "tab_width")
 
 class TEXT_PT_find(bpy.types.Panel):
        __space_type__ = "TEXT_EDITOR"
@@ -79,27 +81,26 @@ class TEXT_PT_find(bpy.types.Panel):
                layout = self.layout
 
                # find
-               layout.row()
-               layout.itemR(st, "find_text", text="")
-               layout.itemO("TEXT_OT_find_set_selected", text="", icon=ICON_TEXT)
-               layout.column()
-               layout.itemO("TEXT_OT_find")
+               col = layout.column(align=True)
+               row = col.row()
+               row.itemR(st, "find_text", text="")
+               row.itemO("TEXT_OT_find_set_selected", text="", icon=ICON_TEXT)
+               col.itemO("TEXT_OT_find")
 
                # replace
-               layout.row()
-               layout.itemR(st, "replace_text", text="")
-               layout.itemO("TEXT_OT_replace_set_selected", text="", icon=ICON_TEXT)
-               layout.column()
-               layout.itemO("TEXT_OT_replace")
+               col = layout.column(align=True)
+               row = col.row()
+               row.itemR(st, "replace_text", text="")
+               row.itemO("TEXT_OT_replace_set_selected", text="", icon=ICON_TEXT)
+               col.itemO("TEXT_OT_replace")
 
                # mark
-               layout.column()
                layout.itemO("TEXT_OT_mark_all")
 
                # settings
-               layout.row()
-               layout.itemR(st, "find_wrap", text="Wrap")
-               layout.itemR(st, "find_all", text="All")
+               row = layout.row()
+               row.itemR(st, "find_wrap", text="Wrap")
+               row.itemR(st, "find_all", text="All")
 
 class TEXT_MT_text(bpy.types.Menu):
        __space_type__ = "TEXT_EDITOR"
index 1a40911170e1ae3d5e4a835b7877d9f518db0a57..b30eba5a631a6a6df3a6c1d8365d25ed63a7609a 100644 (file)
@@ -210,8 +210,10 @@ void calc_fcurve_bounds (FCurve *fcu, float *xmin, float *xmax, float *ymin, flo
                                BezTriple *bezt;
                                
                                for (bezt=fcu->bezt, i=0; i < fcu->totvert; bezt++, i++) {
-                                       yminv= MIN2(yminv, bezt->vec[1][1]);
-                                       ymaxv= MAX2(ymaxv, bezt->vec[1][1]);
+                                       if (bezt->vec[1][1] < yminv)
+                                               yminv= bezt->vec[1][1];
+                                       if (bezt->vec[1][1] > ymaxv)
+                                               ymaxv= bezt->vec[1][1];
                                }
                        }
                }
@@ -227,8 +229,10 @@ void calc_fcurve_bounds (FCurve *fcu, float *xmin, float *xmax, float *ymin, flo
                                FPoint *fpt;
                                
                                for (fpt=fcu->fpt, i=0; i < fcu->totvert; fpt++, i++) {
-                                       yminv= MIN2(yminv, fpt->vec[1]);
-                                       ymaxv= MAX2(ymaxv, fpt->vec[1]);
+                                       if (fpt->vec[1] < yminv)
+                                               yminv= fpt->vec[1];
+                                       if (fpt->vec[1] > ymaxv)
+                                               ymaxv= fpt->vec[1];
                                }
                        }
                }
index 67f89b3358df22952356d2770964a687ecac4fb6..afad396607bfb6991b23d388d649e27cb82863ad 100644 (file)
@@ -754,7 +754,17 @@ static int animdata_filter_dopesheet_mats (ListBase *anim_data, bDopeSheet *ads,
                Material *ma= give_current_material(ob, a);
                
                /* for now, if no material returned, skip (this shouldn't confuse the user I hope) */
-               if (ELEM3(NULL, ma, ma->adt, ma->adt->action)) continue;
+               if (ELEM(NULL, ma, ma->adt)) 
+                       continue;
+               
+               if ((ads->filterflag & ADS_FILTER_ONLYDRIVERS)==0) {
+                       if (ANIMDATA_HAS_KEYS(ma) == 0)
+                               continue;
+               }
+               else {
+                       if (ANIMDATA_HAS_DRIVERS(ma) == 0)
+                               continue;
+               }
                
                /* make a temp list elem for this */
                ld= MEM_callocN(sizeof(LinkData), "DopeSheet-MaterialCache");
@@ -791,10 +801,16 @@ static int animdata_filter_dopesheet_mats (ListBase *anim_data, bDopeSheet *ads,
                                }
                        }
                        
-                       /* add material's F-Curve channels? */
+                       /* add material's F-Curve or Driver channels? */
                        if (FILTER_MAT_OBJD(ma) || (filter_mode & ANIMFILTER_CURVESONLY)) {
+                               if ((ads->filterflag & ADS_FILTER_ONLYDRIVERS)==0) {
                                        // XXX the 'owner' info here is still subject to improvement
-                               items += animdata_filter_action(anim_data, ma->adt->action, filter_mode, ma, ANIMTYPE_DSMAT, (ID *)ma);
+                                       items += animdata_filter_action(anim_data, ma->adt->action, filter_mode, ma, ANIMTYPE_DSMAT, (ID *)ma);
+                               }
+                               else {
+                                       // need to make the ownertype normal object here... (maybe type should be a separate one for clarity?)
+                                       items += animdata_filter_fcurves(anim_data, ma->adt->drivers.first, NULL, ma, ANIMTYPE_DSMAT, filter_mode, (ID *)ma);
+                               }       
                        }
                }
        }
index 4d4079a260ad3f2363d1598b9376be2c190d1ceb..14780ebb7942e1c38aa70c53f3b163005b89df39 100644 (file)
@@ -148,12 +148,6 @@ void getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
                        
                        /* Array Index - only if applicable */
                        if (RNA_property_array_length(prop)) {
-                                       // XXX the format of these is not final... we don't know how this will go yet
-                                       // format 1 style
-                               //static char *vectoritem[4]= {".X", ".Y", ".Z", ".W"};
-                               //static char *quatitem[4]= {".W", ".X", ".Y", ".Z"};
-                               //static char *coloritem[4]= {".R", ".G", ".B", ".A"};
-                                       // format 2 style
                                static char *vectoritem[4]= {"X ", "Y ", "Z ", "W "};
                                static char *quatitem[4]= {"W ", "X ", "Y ", "Z "};
                                static char *coloritem[4]= {"R ", "G ", "B ", "A "};
@@ -181,8 +175,7 @@ void getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
                        
                        /* putting this all together into the buffer */
                        // XXX we need to check for invalid names...
-                       //BLI_snprintf(name, 128, "%s.%s%s", structname, propname, arrayname);  // format 1
-                       BLI_snprintf(name, 128, "%s%s (%s)", arrayname, propname, structname);  // format 2
+                       BLI_snprintf(name, 128, "%s%s (%s)", arrayname, propname, structname); 
                        
                        /* free temp name if nameprop is set */
                        if (nameprop)
@@ -197,6 +190,7 @@ void getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
 
 /* ------------------------------- Color Codes for F-Curve Channels ---------------------------- */
 
+#if 0
 /* used for FCURVE_COLOR_AUTO_RAINBOW */
 // XXX this still doesn't work too great when there are more than 32 curves (which happens most of the time)
 void ipo_rainbow (int cur, int tot, float *out)
@@ -206,14 +200,57 @@ void ipo_rainbow (int cur, int tot, float *out)
        dfac= (float)(1.0/( (float)tot+1.0));
        
        /* this calculation makes 2 or 4 different cycles of rainbow colors */
+               // 2 different cycles - for hue
        if(cur< tot/2) fac= (float)(cur*2.0f*dfac);
        else fac= (float)((cur-tot/2)*2.0f*dfac +dfac);
+       
+               // third cycle with altered hue
        if(tot > 32) fac= fac*1.95f;
+               // clamping for excessive ranges
        if(fac>1.0f) fac-= 1.0f;
        
+               // saturation adjustments for more visible range
        if(fac>0.5f && fac<0.8f) sat= 0.5f;
        else sat= 0.6f;
        
-       //return hsv_to_cpack(fac, sat, 1.0f);
        hsv_to_rgb(fac, sat, 1.0f, out, out+1, out+2);
 }
+#endif
+
+/* step between the major distinguishable color bands of the primary colors */
+#define HSV_BANDWIDTH  0.3f
+
+/* testbed for FCURVE_COLOR_AUTO_RAINBOW determination methods */
+//void fcurve_rainbow (unsigned int cur, unsigned int tot, float *out)
+void ipo_rainbow (int cur, int tot, float *out)
+{
+       float hue, val, sat, fac;
+       int grouping;
+       
+       /* we try to divide the colours into groupings of n colors,
+        * where n is:
+        *      3 - for 'odd' numbers of curves - there should be a majority of triplets of curves
+        *      4 - for 'even' numbers of curves - there should be a majority of quartets of curves
+        * so the base color is simply one of the three primary colors
+        */
+       grouping= (4 - (tot % 2));
+       hue= HSV_BANDWIDTH * (float)(cur % grouping);
+       
+       /* 'Value' (i.e. darkness) needs to vary so that larger sets of three will be 
+        * 'darker' (i.e. smaller value), so that they don't look that similar to previous ones.
+        * However, only a range of 0.3 to 1.0 is really usable to avoid clashing
+        * with some other stuff 
+        */
+       fac = ((float)cur / (float)tot) * 0.7f;
+       val = 1.0f - fac;
+       
+       /* the base color can get offset a bit so that the colors aren't so identical */
+       hue += fac * HSV_BANDWIDTH; 
+       if (hue > 1.0f) hue= fmod(hue, 1.0f);
+       
+       /* saturation fluctuates between 0.5 and 1.0 */
+       sat = ((cur / grouping) % 2) ? 0.61f : 0.96f;
+       
+       /* finally, conver this to RGB colors */
+       hsv_to_rgb(hue, sat, val, out, out+1, out+2); 
+}
index b09cc3b78e196135849fcf605517cac676e2cc83..6d0c15ab724b42adb0f58b1843c7ee17f7ef01d1 100644 (file)
@@ -29,6 +29,7 @@
 #include "BKE_action.h"
 #include "BKE_constraint.h"
 #include "BKE_fcurve.h"
+#include "BKE_global.h"
 #include "BKE_utildefines.h"
 #include "BKE_context.h"
 #include "BKE_report.h"
@@ -68,6 +69,7 @@ bAction *verify_adt_action (ID *id, short add)
                adt= BKE_id_add_animdata(id);
        if (adt == NULL) { 
                /* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */
+               printf("ERROR: Couldn't add AnimData (ID = %s) \n", (id) ? (id->name) : "<None>");
                return NULL;
        }
                
@@ -793,6 +795,9 @@ short insert_keyframe (ID *id, bAction *act, const char group[], const char rna_
                }
        }
        
+       /* no F-Curve to add keyframes to */
+       printf("ERROR: no F-Curve to add keyframes to \n");
+       
        /* return failure */
        return 0;
 }
@@ -993,7 +998,7 @@ static int insert_key_menu_invoke (bContext *C, wmOperator *op, wmEvent *event)
        uiLayout *layout;
        int i = 0;
        
-       pup= uiPupMenuBegin("Insert Keyframe", 0);
+       pup= uiPupMenuBegin(C, "Insert Keyframe", 0);
        layout= uiPupMenuLayout(pup);
        
        /* active Keying Set */
@@ -1203,11 +1208,11 @@ static int insert_key_button_exec (bContext *C, wmOperator *op)
        memset(&ptr, 0, sizeof(PointerRNA));
        uiAnimContextProperty(C, &ptr, &prop, &index);
        
-       if(ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
+       if ((ptr.data && prop) && RNA_property_animateable(&ptr, prop)) {
                path= RNA_path_from_ID_to_property(&ptr, prop);
                
-               if(path) {
-                       if(all) {
+               if (path) {
+                       if (all) {
                                length= RNA_property_array_length(prop);
                                
                                if(length) index= 0;
@@ -1216,14 +1221,20 @@ static int insert_key_button_exec (bContext *C, wmOperator *op)
                        else
                                length= 1;
                        
-                       for(a=0; a<length; a++)
+                       for (a=0; a<length; a++)
                                success+= insert_keyframe(ptr.id.data, NULL, NULL, path, index+a, cfra, 0);
                        
                        MEM_freeN(path);
                }
+               else if (G.f & G_DEBUG)
+                       printf("Button Insert-Key: no path to property \n");
+       }
+       else if (G.f & G_DEBUG) {
+               printf("ptr.data = %p, prop = %p,", ptr.data, prop);
+               printf("animateable = %d \n", RNA_property_animateable(&ptr, prop));
        }
        
-       if(success) {
+       if (success) {
                /* send updates */
                ED_anim_dag_flush_update(C);    
                
@@ -1267,11 +1278,11 @@ static int delete_key_button_exec (bContext *C, wmOperator *op)
        memset(&ptr, 0, sizeof(PointerRNA));
        uiAnimContextProperty(C, &ptr, &prop, &index);
 
-       if(ptr.data && prop) {
+       if (ptr.data && prop) {
                path= RNA_path_from_ID_to_property(&ptr, prop);
                
-               if(path) {
-                       if(all) {
+               if (path) {
+                       if (all) {
                                length= RNA_property_array_length(prop);
                                
                                if(length) index= 0;
@@ -1280,11 +1291,16 @@ static int delete_key_button_exec (bContext *C, wmOperator *op)
                        else
                                length= 1;
                        
-                       for(a=0; a<length; a++)
+                       for (a=0; a<length; a++)
                                success+= delete_keyframe(ptr.id.data, NULL, NULL, path, index+a, cfra, 0);
                        
                        MEM_freeN(path);
                }
+               else if (G.f & G_DEBUG)
+                       printf("Button Delete-Key: no path to property \n");
+       }
+       else if (G.f & G_DEBUG) {
+               printf("ptr.data = %p, prop = %p \n", ptr.data, prop);
        }
        
        
index 98f51a4015d0aa247c00e955ee6697b6edb17d66..1c113c25720651d8ebec08d9b0e0cf3a6a556c9e 100644 (file)
@@ -3461,7 +3461,7 @@ static int armature_subdivs_invoke(bContext *C, wmOperator *op, wmEvent *event)
        uiPopupMenu *pup;
        uiLayout *layout;
 
-       pup= uiPupMenuBegin("Subdivision Type", 0);
+       pup= uiPupMenuBegin(C, "Subdivision Type", 0);
        layout= uiPupMenuLayout(pup);
        uiItemsEnumO(layout, "ARMATURE_OT_subdivs", "type");
        uiPupMenuEnd(C, pup);
@@ -3744,7 +3744,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
 static int armature_parent_set_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        EditBone *actbone = CTX_data_active_bone(C);
-       uiPopupMenu *pup= uiPupMenuBegin("Make Parent ", 0);
+       uiPopupMenu *pup= uiPupMenuBegin(C, "Make Parent ", 0);
        uiLayout *layout= uiPupMenuLayout(pup);
        int allchildbones = 0;
        
index 43590346299ee3e4f20aa4054dbeaa365ddfe6fd..dec4847f12596e975b9a52e7d128e64699a225e7 100644 (file)
@@ -326,7 +326,7 @@ static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *evt)
                return OPERATOR_CANCELLED;
        
        /* start building */
-       pup= uiPupMenuBegin(op->type->name, 0);
+       pup= uiPupMenuBegin(C, op->type->name, 0);
        layout= uiPupMenuLayout(pup);
        uiLayoutContext(layout, WM_OP_EXEC_DEFAULT);
        
@@ -460,7 +460,7 @@ static int poselib_stored_pose_menu_invoke (bContext *C, wmOperator *op, wmEvent
                return OPERATOR_CANCELLED;
        
        /* start building */
-       pup= uiPupMenuBegin(op->type->name, 0);
+       pup= uiPupMenuBegin(C, op->type->name, 0);
        layout= uiPupMenuLayout(pup);
        uiLayoutContext(layout, WM_OP_EXEC_DEFAULT);
        
index 49d86d08db22470df61465da7e1c06219ebf14db..5292d86d3c9ab1385a0e6f63f2a98bc8151845c9 100644 (file)
@@ -70,7 +70,7 @@ static int specials_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
        uiPopupMenu *pup;
        uiLayout *layout;
 
-       pup= uiPupMenuBegin("Specials", 0);
+       pup= uiPupMenuBegin(C, "Specials", 0);
        layout= uiPupMenuLayout(pup);
        uiItemO(layout, NULL, 0, "CURVE_OT_subdivide");
        uiItemO(layout, NULL, 0, "CURVE_OT_switch_direction");
index c60007680baf335e4d868deaff3b5003a560a757..45b9a589bd51d5f32ba2928e4b2f0143471d373a 100644 (file)
@@ -3567,7 +3567,7 @@ static int toggle_cyclic_invoke(bContext *C, wmOperator *op, wmEvent *event)
        for(nu= editnurb->first; nu; nu= nu->next) {
                if(nu->pntsu>1 || nu->pntsv>1) {
                        if(nu->type==CU_NURBS) {
-                               pup= uiPupMenuBegin("Direction", 0);
+                               pup= uiPupMenuBegin(C, "Direction", 0);
                                layout= uiPupMenuLayout(pup);
                                uiItemsEnumO(layout, op->type->idname, "direction");
                                uiPupMenuEnd(C, pup);
@@ -4511,14 +4511,14 @@ static int delete_invoke(bContext *C, wmOperator *op, wmEvent *event)
        uiLayout *layout;
 
        if(obedit->type==OB_SURF) {
-               pup= uiPupMenuBegin("Delete", 0);
+               pup= uiPupMenuBegin(C, "Delete", 0);
                layout= uiPupMenuLayout(pup);
                uiItemEnumO(layout, NULL, 0, op->type->idname, "type", 0);
                uiItemEnumO(layout, NULL, 0, op->type->idname, "type", 2);
                uiPupMenuEnd(C, pup);
        }
        else {
-               pup= uiPupMenuBegin("Delete", 0);
+               pup= uiPupMenuBegin(C, "Delete", 0);
                layout= uiPupMenuLayout(pup);
                uiItemsEnumO(layout, op->type->idname, "type");
                uiPupMenuEnd(C, pup);
index 63bd451132d2e967f1f4db5a76b6ff51803e241c..5c611365a7ecef646fee1d45933d86fcc14edbdf 100644 (file)
@@ -137,6 +137,8 @@ void glaDrawPixelsSafe_to32(float fx, float fy, int img_w, int img_h, int row_w,
 
 void glaDrawPixelsTex          (float x, float y, int img_w, int img_h, int format, void *rect);
 
+void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, void *rect, float scaleX, float scaleY);
+
        /* 2D Drawing Assistance */
 
        /** Define a 2D area (viewport, scissor, matrices) for OpenGL rendering.
index bb5ced664289f5ec25fe325c214f70f30b6a0723..7cbef4984d7e8a9a68a97706bec0fcba0125dce0 100644 (file)
@@ -62,6 +62,19 @@ typedef struct FileSelectParams {
 #define FILE_LAYOUT_HOR 1
 #define FILE_LAYOUT_VER 2
 
+#define MAX_FILE_COLUMN 8
+
+typedef enum FileListColumns {
+       COLUMN_NAME = 0,
+       COLUMN_DATE,
+       COLUMN_TIME,
+       COLUMN_SIZE,
+       COLUMN_MODE1,
+       COLUMN_MODE2,
+       COLUMN_MODE3,
+       COLUMN_OWNER
+} FileListColumns;
+
 typedef struct FileLayout
 {
        /* view settings - XXX - move into own struct */
@@ -78,7 +91,7 @@ typedef struct FileLayout
        short width;
        short height;
        short flag;
-
+       float column_widths[MAX_FILE_COLUMN];
 } FileLayout;
 
 FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile);
index 847120a58042ee18200971e34eafea827ef2236f..bfa0c680bd6b5510965a6181151d18666107afaf 100644 (file)
@@ -53,6 +53,8 @@ void  ED_region_pixelspace(struct ARegion *ar);
 void   ED_region_init(struct bContext *C, struct ARegion *ar);
 void   ED_region_tag_redraw(struct ARegion *ar);
 void   ED_region_tag_redraw_partial(struct ARegion *ar, struct rcti *rct);
+void   ED_region_panels(const struct bContext *C, struct ARegion *ar, int vertical, char *context);
+void   ED_region_header(const struct bContext *C, struct ARegion *ar);
 
 /* spaces */
 void   ED_spacetypes_init(void);
index 0e34b3702ed60f7d09feaa7dcff0be847ce41640..475d77d90f346233e7425fd4fecffe8a3c61eca0 100644 (file)
@@ -131,6 +131,8 @@ typedef struct uiLayout uiLayout;
 #define UI_BUT_ANIMATED_KEY    (1<<21)
 #define UI_BUT_DRIVEN          (1<<22)
 
+#define UI_PANEL_WIDTH                 340
+#define UI_COMPACT_PANEL_WIDTH 160
 
 /* Button types, bits stored in 1 value... and a short even!
 - bits 0-4:  bitnr (0-31)
@@ -215,7 +217,7 @@ typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event);
 
 typedef struct uiPopupMenu uiPopupMenu;
 
-uiPopupMenu *uiPupMenuBegin(const char *title, int icon);
+uiPopupMenu *uiPupMenuBegin(struct bContext *C, const char *title, int icon);
 void uiPupMenuEnd(struct bContext *C, struct uiPopupMenu *head);
 struct uiLayout *uiPupMenuLayout(uiPopupMenu *head);
 
@@ -260,6 +262,8 @@ void uiFreeBlock(const struct bContext *C, uiBlock *block);
 void uiFreeBlocks(const struct bContext *C, struct ListBase *lb);
 void uiFreeInactiveBlocks(const struct bContext *C, struct ListBase *lb);
 
+void uiBlockSetRegion(uiBlock *block, struct ARegion *region);
+
 void uiBlockSetButLock(uiBlock *block, int val, char *lockstr);
 void uiBlockClearButLock(uiBlock *block);
 
@@ -523,7 +527,8 @@ uiBut *uiDefMenuTogR(uiBlock *block, struct PointerRNA *ptr, char *propname, cha
  * - Template: predefined layouts for buttons with a number of slots, each
  *   slot can contain multiple items.
  * - Item: item to put in a template slot, being either an RNA property,
- *   operator, label or menu currently. */
+ *   operator, label or menu. Also regular buttons can be used when setting
+ *   uiBlockCurLayout. */
 
 /* layout */
 #define UI_LAYOUT_HORIZONTAL   0
@@ -533,23 +538,29 @@ uiBut *uiDefMenuTogR(uiBlock *block, struct PointerRNA *ptr, char *propname, cha
 #define UI_LAYOUT_HEADER               1
 #define UI_LAYOUT_MENU                 2
 
-uiLayout *uiLayoutBegin(int dir, int type, int x, int y, int size, int em, struct uiStyle *style);
-void uiLayoutEnd(const struct bContext *C, uiBlock *block, uiLayout *layout, int *x, int *y);
+#define UI_UNIT_X              20
+#define UI_UNIT_Y              20
+
+uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, struct uiStyle *style);
+void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout);
+void uiBlockLayoutResolve(const struct bContext *C, uiBlock *block, int *x, int *y);
+float uiBlockAspect(uiBlock *block); /* temporary */
 
 void uiLayoutContext(uiLayout *layout, int opcontext);
 void uiLayoutFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv);
+uiBlock *uiLayoutBlock(uiLayout *layout);
 
 /* layout specifiers */
-void uiLayoutRow(uiLayout *layout);
-void uiLayoutColumn(uiLayout *layout);
-void uiLayoutColumnFlow(uiLayout *layout, int number);
-void uiLayoutSplit(uiLayout *layout, int number, int lr);
+uiLayout *uiLayoutRow(uiLayout *layout, int align);
+uiLayout *uiLayoutColumn(uiLayout *layout, int align);
+uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align);
 uiLayout *uiLayoutBox(uiLayout *layout);
-uiLayout *uiLayoutSub(uiLayout *layout, int n);
+uiLayout *uiLayoutFree(uiLayout *layout, int align);
+uiLayout *uiLayoutSplit(uiLayout *layout);
 
 /* templates */
-void uiTemplateHeader(uiLayout *layout);
-void uiTemplateHeaderID(uiLayout *layout, struct PointerRNA *ptr, char *propname,
+void uiTemplateHeader(uiLayout *layout, struct bContext *C);
+void uiTemplateHeaderID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname,
        char *newop, char *openop, char *unlinkop);
 
 /* items */
@@ -568,7 +579,7 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr,
 void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname);
 
 void uiItemL(uiLayout *layout, char *name, int icon); /* label */
-void uiItemM(uiLayout *layout, char *name, int icon, char *menuname); /* menu */
+void uiItemM(uiLayout *layout, struct bContext *C, char *name, int icon, char *menuname); /* menu */
 void uiItemV(uiLayout *layout, char *name, int icon, int argval); /* value */
 void uiItemS(uiLayout *layout); /* separator */
 
@@ -576,21 +587,10 @@ void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func);
 void uiItemMenuEnumO(uiLayout *layout, char *name, int icon, char *opname, char *propname);
 void uiItemMenuEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname);
 
-/* utilities */
-#define UI_PANEL_WIDTH                 340
-#define UI_COMPACT_PANEL_WIDTH 160
-
-typedef void (*uiHeaderCreateFunc)(const struct bContext *C, uiLayout *layout);
-typedef void (*uiPanelCreateFunc)(const struct bContext *C, uiLayout *layout);
-
-void uiRegionPanelLayout(const struct bContext *C, struct ARegion *ar, int vertical, char *context);
-void uiRegionHeaderLayout(const struct bContext *C, struct ARegion *ar);
-
 /* Animation */
 
 void uiAnimContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index);
 
-
 /* Styled text draw */
 void uiStyleFontSet(struct uiFontStyle *fs);
 void uiStyleFontDraw(struct uiFontStyle *fs, struct rcti *rect, char *str);
index fd082c34238fe6c83fd2bc195cfd58c474f34d12..57f450598653e1a47c3efcf00b86785862a11dbe 100644 (file)
@@ -502,10 +502,10 @@ void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
                return;
 
        for(but=block->buttons.first; but; but=but->next) {
-               if(but->opname) {
+               if(but->optype) {
                        prop= (but->opptr)? but->opptr->data: NULL;
 
-                       if(WM_key_event_operator_string(C, but->opname, but->opcontext, prop, buf, sizeof(buf))) {
+                       if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, buf, sizeof(buf))) {
                                butstr= MEM_mallocN(strlen(but->str)+strlen(buf)+2, "menu_block_set_keymaps");
                                strcpy(butstr, but->str);
                                strcat(butstr, "|");
@@ -535,8 +535,8 @@ void uiEndBlock(const bContext *C, uiBlock *block)
                        ui_check_but(but);
                
                /* temp? Proper check for greying out */
-               if(but->opname) {
-                       wmOperatorType *ot= WM_operatortype_find(but->opname);
+               if(but->optype) {
+                       wmOperatorType *ot= but->optype;
                        if(ot==NULL || (ot->poll && ot->poll((bContext *)C)==0)) {
                                but->flag |= UI_BUT_DISABLED;
                                but->lock = 1;
@@ -559,6 +559,8 @@ void uiEndBlock(const bContext *C, uiBlock *block)
        }
 
        /* handle pending stuff */
+       if(block->layout) uiBlockLayoutResolve(C, block, NULL, NULL);
+       ui_block_do_align(block);
        if(block->flag & UI_BLOCK_LOOP) ui_menu_block_set_keymaps(C, block);
        
        /* after keymaps! */
@@ -598,7 +600,7 @@ static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBlock *block, u
        
        getsizex= ar->winx;
        getsizey= ar->winy;
-       
+
        gx= (but?but->x1:block->minx) + (block->panel?block->panel->ofsx:0.0f);
        gy= (but?but->y1:block->miny) + (block->panel?block->panel->ofsy:0.0f);
        
@@ -1716,21 +1718,18 @@ void uiFreeInactiveBlocks(const bContext *C, ListBase *lb)
        }
 }
 
-uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, short dt)
+void uiBlockSetRegion(uiBlock *block, ARegion *region)
 {
        ListBase *lb;
-       uiBlock *block, *oldblock= NULL;
-       wmWindow *window;
-       int getsizex, getsizey;
+       uiBlock *oldblock= NULL;
 
-       window= CTX_wm_window(C);
        lb= &region->uiblocks;
        
        /* each listbase only has one block with this name, free block
         * if is already there so it can be rebuilt from scratch */
        if(lb) {
                for (oldblock= lb->first; oldblock; oldblock= oldblock->next)
-                       if (BLI_streq(oldblock->name, name))
+                       if (BLI_streq(oldblock->name, block->name))
                                break;
 
                if (oldblock) {
@@ -1738,20 +1737,32 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor
                        oldblock->panel= NULL;
                }
        }
-       
-       block= MEM_callocN(sizeof(uiBlock), "uiBlock");
+
        block->oldblock= oldblock;
-       block->active= 1;
-       block->dt= dt;
 
        /* at the beginning of the list! for dynamical menus/blocks */
        if(lb)
                BLI_addhead(lb, block);
+}
+
+uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, short dt)
+{
+       uiBlock *block;
+       wmWindow *window;
+       int getsizex, getsizey;
 
+       window= CTX_wm_window(C);
+
+       block= MEM_callocN(sizeof(uiBlock), "uiBlock");
+       block->active= 1;
+       block->dt= dt;
        BLI_strncpy(block->name, name, sizeof(block->name));
 
+       if(region)
+               uiBlockSetRegion(block, region);
+
        /* window matrix and aspect */
-       if(region->swinid) {
+       if(region && region->swinid) {
                wm_subwindow_getmatrix(window, region->swinid, block->winmat);
                wm_subwindow_getsize(window, region->swinid, &getsizex, &getsizey);
 
@@ -1952,7 +1963,9 @@ void uiBlockBeginAlign(uiBlock *block)
        if(block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block);
 
        block->flag |= UI_BUT_ALIGN_DOWN;       
-       /* buttons declared after this call will this align flag */
+       block->alignnr++;
+
+       /* buttons declared after this call will get this align nr */ // XXX flag?
 }
 
 static int buts_are_horiz(uiBut *but1, uiBut *but2)
@@ -1967,37 +1980,34 @@ static int buts_are_horiz(uiBut *but1, uiBut *but2)
 }
 
 void uiBlockEndAlign(uiBlock *block)
+{
+       block->flag &= ~UI_BUT_ALIGN;   // all 4 flags
+}
+
+static void ui_block_do_align_but(uiBlock *block, uiBut *first, int nr)
 {
        uiBut *prev, *but=NULL, *next;
        int flag= 0, cols=0, rows=0;
        
-       /* auto align:
-               - go back to first button of align start (ALIGN_DOWN)
-               - compare triples, and define flags
-       */
-       prev= block->buttons.last;
-       while(prev) {
-               if( (prev->flag & UI_BUT_ALIGN_DOWN)) but= prev;
-               else break;
-               
-               if(but && but->next) {
+       /* auto align */
+
+       for(but=first; but && but->alignnr == nr; but=but->next) {
+               if(but->next && but->next->alignnr == nr) {
                        if(buts_are_horiz(but, but->next)) cols++;
                        else rows++;
                }
-               
-               prev= prev->prev;
        }
-       if(but==NULL) return;
-       
+
        /* rows==0: 1 row, cols==0: 1 collumn */
        
        /* note;  how it uses 'flag' in loop below (either set it, or OR it) is confusing */
-       prev= NULL;
-       while(but) {
+       for(but=first, prev=NULL; but && but->alignnr == nr; prev=but, but=but->next) {
                next= but->next;
-               
+               if(next && next->alignnr != nr)
+                       next= NULL;
+
                /* clear old flag */
-               but->flag &= ~UI_BUT_ALIGN_DOWN;
+               but->flag &= ~UI_BUT_ALIGN;
                
                if(flag==0) {   /* first case */
                        if(next) {
@@ -2030,11 +2040,11 @@ void uiBlockEndAlign(uiBlock *block)
                                /* exception case: bottom row */
                                if(rows>0) {
                                        uiBut *bt= but;
-                                       while(bt) {
-                                               if(bt->next && buts_are_horiz(bt, bt->next)==0 ) break; 
+                                       while(bt && bt->alignnr == nr) {
+                                               if(bt->next && bt->next->alignnr == nr && buts_are_horiz(bt, bt->next)==0 ) break; 
                                                bt= bt->next;
                                        }
-                                       if(bt==0) flag= UI_BUT_ALIGN_TOP|UI_BUT_ALIGN_RIGHT;
+                                       if(bt==0 || bt->alignnr != nr) flag= UI_BUT_ALIGN_TOP|UI_BUT_ALIGN_RIGHT;
                                }
                        }
                        else flag |= UI_BUT_ALIGN_LEFT;
@@ -2086,35 +2096,30 @@ void uiBlockEndAlign(uiBlock *block)
                                }
                        }
                }
-               
-               prev= but;
-               but= next;
        }
-       
-       block->flag &= ~UI_BUT_ALIGN;   // all 4 flags
 }
 
-#if 0
-static void uiBlockEndAligno(uiBlock *block)
+void ui_block_do_align(uiBlock *block)
 {
        uiBut *but;
-       
-       /* correct last defined button */
-       but= block->buttons.last;
-       if(but) {
-               /* vertical align case */
-               if( (block->flag & UI_BUT_ALIGN) == (UI_BUT_ALIGN_TOP|UI_BUT_ALIGN_DOWN) ) {
-                       but->flag &= ~UI_BUT_ALIGN_DOWN;
-               }
-               /* horizontal align case */
-               if( (block->flag & UI_BUT_ALIGN) == (UI_BUT_ALIGN_LEFT|UI_BUT_ALIGN_RIGHT) ) {
-                       but->flag &= ~UI_BUT_ALIGN_RIGHT;
+       int nr;
+
+       /* align buttons with same align nr */
+       for(but=block->buttons.first; but;) {
+               if(but->alignnr) {
+                       nr= but->alignnr;
+                       ui_block_do_align_but(block, but, nr);
+
+                       /* skip with same number */
+                       for(; but && but->alignnr == nr; but=but->next);
+
+                       if(!but)
+                               break;
                }
-               /* else do nothing, manually provided flags */
+               else
+                       but= but->next;
        }
-       block->flag &= ~UI_BUT_ALIGN;   // all 4 flags
 }
-#endif
 
 /*
 ui_def_but is the function that draws many button types
@@ -2171,6 +2176,9 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short
        but->aspect= 1.0f; //XXX block->aspect;
        but->block= block;              // pointer back, used for frontbuffer status, and picker
 
+       if(block->flag & UI_BUT_ALIGN)
+               but->alignnr= block->alignnr;
+
        but->func= block->func;
        but->func_arg1= block->func_arg1;
        but->func_arg2= block->func_arg2;
@@ -2217,6 +2225,9 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short
        }
        else
                BLI_addtail(&block->buttons, but);
+       
+       if(block->curlayout)
+               ui_layout_add_but(block->curlayout, but);
 
        return but;
 }
@@ -2374,7 +2385,7 @@ uiBut *ui_def_but_operator(uiBlock *block, int type, char *opname, int opcontext
        }
 
        but= ui_def_but(block, type, -1, str, x1, y1, x2, y2, NULL, 0, 0, 0, 0, tip);
-       but->opname= opname;
+       but->optype= ot;
        but->opcontext= opcontext;
 
        if(!ot) {
@@ -2894,9 +2905,9 @@ int uiButGetRetVal(uiBut *but)
 
 PointerRNA *uiButGetOperatorPtrRNA(uiBut *but)
 {
-       if(but->opname && !but->opptr) {
+       if(but->optype && !but->opptr) {
                but->opptr= MEM_callocN(sizeof(PointerRNA), "uiButOpPtr");
-               WM_operator_properties_create(but->opptr, but->opname);
+               WM_operator_properties_create(but->opptr, but->optype->idname);
        }
 
        return but->opptr;
index ac6f5d970eb78fc326ea3cb21fe746c825c215f9..4a26db291603d8715bf3e566b85e830edd5b5a56 100644 (file)
@@ -119,7 +119,7 @@ void ui_but_anim_menu(bContext *C, uiBut *but)
        int length;
 
        if(but->rnapoin.data && but->rnaprop) {
-               pup= uiPupMenuBegin(RNA_property_ui_name(but->rnaprop), 0);
+               pup= uiPupMenuBegin(C, RNA_property_ui_name(but->rnaprop), 0);
                layout= uiPupMenuLayout(pup);
                
                length= RNA_property_array_length(but->rnaprop);
index 1cd804851b5468e4381b76c7fd0fabb8a8fab5c1..873406de7aabed86511d1fb4d3f8c3b61d9931f3 100644 (file)
@@ -56,9 +56,20 @@ void RNA_api_ui_layout(StructRNA *srna)
 
        /* simple layout specifiers */
        func= RNA_def_function(srna, "row", "uiLayoutRow");
+       parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
+       RNA_def_function_return(func, parm);
+       RNA_def_boolean(func, "align", 0, "", "Align buttons to each other.");
+
        func= RNA_def_function(srna, "column", "uiLayoutColumn");
+       parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
+       RNA_def_function_return(func, parm);
+       RNA_def_boolean(func, "align", 0, "", "Align buttons to each other.");
+
        func= RNA_def_function(srna, "column_flow", "uiLayoutColumnFlow");
        parm= RNA_def_int(func, "columns", 0, 0, INT_MAX, "", "Number of columns, 0 is automatic.", 0, INT_MAX);
+       parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
+       RNA_def_function_return(func, parm);
+       RNA_def_boolean(func, "align", 0, "", "Align buttons to each other.");
 
        /* box layout */
        func= RNA_def_function(srna, "box", "uiLayoutBox");
@@ -67,13 +78,6 @@ void RNA_api_ui_layout(StructRNA *srna)
 
        /* split layout */
        func= RNA_def_function(srna, "split", "uiLayoutSplit");
-       parm= RNA_def_int(func, "number", 2, 0, INT_MAX, "", "Number of splits.", 0, INT_MAX);
-       parm= RNA_def_boolean(func, "lr", 0, "", "LR.");
-
-       /* sub layout */
-       func= RNA_def_function(srna, "sub", "uiLayoutSub");
-       parm= RNA_def_int(func, "n", 0, 0, INT_MAX, "", "Index of sub-layout.", 0, INT_MAX);
-       RNA_def_property_flag(parm, PROP_REQUIRED);
        parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
        RNA_def_function_return(func, parm);
 
@@ -161,6 +165,8 @@ void RNA_api_ui_layout(StructRNA *srna)
        api_ui_item_common(func);
 
        func= RNA_def_function(srna, "itemM", "uiItemM");
+       parm= RNA_def_pointer(func, "context", "Context", "", "Current context.");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
        api_ui_item_common(func);
        parm= RNA_def_string(func, "menu", "", 0, "", "Identifier of the menu.");
        RNA_def_property_flag(parm, PROP_REQUIRED);
@@ -169,8 +175,12 @@ void RNA_api_ui_layout(StructRNA *srna)
 
        /* templates */
        func= RNA_def_function(srna, "template_header", "uiTemplateHeader");
+       parm= RNA_def_pointer(func, "context", "Context", "", "Current context.");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
 
        func= RNA_def_function(srna, "template_header_ID", "uiTemplateHeaderID");
+       parm= RNA_def_pointer(func, "context", "Context", "", "Current context.");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
        parm= RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property.");
        RNA_def_property_flag(parm, PROP_REQUIRED);
        parm= RNA_def_string(func, "property", "", 0, "", "Identifier of pointer property in data.");
index 5aa2cded642159b6e05a5e08e55ebad5a8de2aac..02c803963eb78f08735b1d9667615e6e6f5d13ca 100644 (file)
@@ -151,7 +151,7 @@ typedef struct uiAfterFunc {
        void *butm_func_arg;
        int a2;
 
-       const char *opname;
+       wmOperatorType *optype;
        int opcontext;
        PointerRNA *opptr;
 
@@ -222,7 +222,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
         * handling is done, i.e. menus are closed, in order to avoid conflicts
         * with these functions removing the buttons we are working with */
 
-       if(but->func || but->funcN || block->handle_func || (but->type == BUTM && block->butm_func) || but->opname || but->rnaprop) {
+       if(but->func || but->funcN || block->handle_func || (but->type == BUTM && block->butm_func) || but->optype || but->rnaprop) {
                after= MEM_callocN(sizeof(uiAfterFunc), "uiAfterFunc");
 
                after->func= but->func;
@@ -242,14 +242,14 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
                        after->a2= but->a2;
                }
 
-               after->opname= but->opname;
+               after->optype= but->optype;
                after->opcontext= but->opcontext;
                after->opptr= but->opptr;
 
                after->rnapoin= but->rnapoin;
                after->rnaprop= but->rnaprop;
 
-               but->opname= NULL;
+               but->optype= NULL;
                but->opcontext= 0;
                but->opptr= NULL;
 
@@ -280,8 +280,8 @@ static void ui_apply_but_funcs_after(bContext *C)
                if(after.butm_func)
                        after.butm_func(C, after.butm_func_arg, after.a2);
 
-               if(after.opname)
-                       WM_operator_name_call(C, after.opname, after.opcontext, after.opptr);
+               if(after.optype)
+                       WM_operator_name_call(C, after.optype->idname, after.opcontext, after.opptr);
                if(after.opptr) {
                        WM_operator_properties_free(after.opptr);
                        MEM_freeN(after.opptr);
@@ -3780,8 +3780,8 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata)
                if(temp.menuretval == UI_RETURN_OK) {
                        if(temp.popup_func)
                                temp.popup_func(C, temp.popup_arg, temp.retvalue);
-                       if(temp.opname)
-                               WM_operator_name_call(C, temp.opname, temp.opcontext, NULL);
+                       if(temp.optype)
+                               WM_operator_name_call(C, temp.optype->idname, temp.opcontext, NULL);
                }
                else if(temp.cancel_func)
                        temp.cancel_func(temp.popup_arg);
index 0edcc95f7af3fb5e555001153a7ea2bb14921bdc..b96726a5eada91b9d064c274203d0fcefd9f06cc 100644 (file)
@@ -38,9 +38,11 @@ struct bContext;
 struct IDProperty;
 struct uiHandleButtonData;
 struct wmEvent;
+struct wmOperatorType;
 struct wmWindow;
 struct uiStyle;
 struct uiWidgetColors;
+struct uiLayout;
 
 /* ****************** general defines ************** */
 
@@ -99,8 +101,6 @@ typedef enum {
 
 /* internal panel drawing defines */
 #define PNL_GRID       4
-#define PNL_DIST       4
-#define PNL_SAFETY     8
 #define PNL_HEADER  20
 
 /* panel->flag */
@@ -145,6 +145,7 @@ typedef struct {
 struct uiBut {
        struct uiBut *next, *prev;
        short type, pointype, bit, bitnr, retval, strwidth, ofs, pos, selsta, selend;
+       short alignnr;
        int flag;
        
        char *str;
@@ -196,7 +197,7 @@ struct uiBut {
        int rnaindex;
 
        /* Operator data */
-       const char *opname;
+       struct wmOperatorType *optype;
        int opcontext;
        struct IDProperty *opproperties;
        struct PointerRNA *opptr;
@@ -216,10 +217,13 @@ struct uiBut {
 
 struct uiBlock {
        uiBlock *next, *prev;
-       
+
        ListBase buttons;
        Panel *panel;
        uiBlock *oldblock;
+
+       struct uiLayout *layout;
+       struct uiLayout *curlayout;
        
        char name[UI_MAX_NAME_STR];
        
@@ -228,6 +232,8 @@ struct uiBlock {
        float minx, miny, maxx, maxy;
        float aspect;
 
+       short alignnr;
+
        uiButHandleFunc func;
        void *func_arg1;
        void *func_arg2;
@@ -302,6 +308,7 @@ extern void ui_update_block_buts_hsv(uiBlock *block, float *hsv);
 
 extern void ui_bounds_block(uiBlock *block);
 extern void ui_block_translate(uiBlock *block, int x, int y);
+extern void ui_block_do_align(uiBlock *block);
 
 /* interface_regions.c */
 
@@ -318,7 +325,7 @@ struct uiPopupBlockHandle {
        void *popup_arg;
 
        /* for operator popups */
-       const char *opname;
+       struct wmOperatorType *optype;
        int opcontext;
        ScrArea *ctx_area;
        ARegion *ctx_region;
@@ -389,6 +396,8 @@ void ui_theme_init_userdef(void);
 void ui_resources_init(void);
 void ui_resources_free(void);
 
+/* interface_layout.c */
+void ui_layout_add_but(struct uiLayout *layout, uiBut *but);
 
 /* interface_anim.c */
 void ui_but_anim_flag(uiBut *but, float cfra);
index 6a02e99239022bc8cc7e98a2d269f72a780c304c..ab2bb57a25fa023e5c5f330dc8976753836be824 100644 (file)
@@ -1,3 +1,26 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * Contributor(s): Blender Foundation 2009.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
 
 #include <limits.h>
 #include <math.h>
 #define RNA_NO_INDEX   -1
 #define RNA_ENUM_VALUE -2
 
-#define EM_UNIT_X              XIC
-#define EM_UNIT_Y              YIC
-
 #define EM_SEPR_X              6
 #define EM_SEPR_Y              6
 
-/* Item */
-
-typedef enum uiItemType {
-       ITEM_OPERATOR,
-       ITEM_RNA_PROPERTY,
-       ITEM_MENU,
-       ITEM_LABEL,
-       ITEM_VALUE,
-       ITEM_SEPARATOR
-} uiItemType;
-
-enum uiItemFlag {
-       ITEM_ICON,
-       ITEM_TEXT
-};
-
-typedef struct uiItem {
-       struct uiItem *next, *prev;
-       uiItemType type;
-       int slot;
-
-       char *name;
-       char namestr[UI_MAX_NAME_STR];
-       int icon;
-       int disabled;
-} uiItem;
-
-typedef struct uiItemRNA {
-       uiItem item;
-
-       PointerRNA ptr;
-       PropertyRNA *prop;
-       int index, value;
-       int expand;
-} uiItemRNA;
+/* uiLayoutCommon */
 
-typedef struct uiItemOp {
-       uiItem item;
+typedef struct uiLayoutCommon {
+       int type;
+       int opcontext;
 
-       wmOperatorType *ot;
-       IDProperty *properties;
-       int context;
-} uiItemOp;
+       int emw, emh;
 
-typedef struct uiItemMenu {
-       uiItem item;
+       uiMenuHandleFunc handlefunc;
+       void *argv;
 
-       char *menuname;
-       uiMenuCreateFunc func;
-       void *arg, *argN;
-} uiItemMenu;
+       uiStyle *style;
+       uiBlock *block;
+} uiLayoutCommon;
 
-typedef struct uiItemValue {
-       uiItem item;
+/* Item */
 
-       int argval;
-} uiItemValue;
+typedef enum uiItemType {
+       ITEM_BUTTON,
 
-/* Template */
+       ITEM_LAYOUT_ROW,
+       ITEM_LAYOUT_COLUMN,
+       ITEM_LAYOUT_COLUMN_FLOW,
+       ITEM_LAYOUT_ROW_FLOW,
+       ITEM_LAYOUT_BOX,
+       ITEM_LAYOUT_FREE,
+       ITEM_LAYOUT_SPLIT,
 
-typedef enum uiTemplateType {
-       TEMPLATE_ROW,
-       TEMPLATE_COLUMN,
+       ITEM_LAYOUT_ROOT
+#if 0
        TEMPLATE_COLUMN_FLOW,
        TEMPLATE_SPLIT,
        TEMPLATE_BOX,
 
        TEMPLATE_HEADER,
        TEMPLATE_HEADER_ID
-} uiTemplateType;
+#endif
+} uiItemType;
 
-typedef struct uiTemplate {
-       struct uiTemplate *next, *prev;
-       uiTemplateType type;
+typedef struct uiItem {
+       void *next, *prev;
+       uiItemType type;
+} uiItem;
+
+typedef struct uiButtonItem {
+       uiItem item;
+       uiBut *but;
+} uiButtonItem;
+
+struct uiLayout {
+       uiItem item;
 
+       uiLayoutCommon *common;
        ListBase items;
-       int slot;
-} uiTemplate;
 
-typedef struct uiTemplateFlow {
-       uiTemplate template;
+       int x, y, w, h;
+       int space;
+       int align;
+};
+
+typedef struct uiLayoutItemFlow {
+       uiLayout litem;
        int number;
-} uiTemplateFlow;
+       int totcol;
+} uiLayoutItemFlow;
 
-typedef struct uiTemplateSplt {
-       uiTemplate template;
+typedef struct uiLayoutItemSplt {
+       uiLayout litem;
        int number;
        int lr;
-       uiLayout **sublayout;
-} uiTemplateSplt;
-
-typedef struct uiTemplateBx {
-       uiTemplate template;
-       uiLayout *sublayout;
-} uiTemplateBx;
-
-typedef struct uiTemplateHeadID {
-       uiTemplate template;
-
-       PointerRNA ptr;
-       PropertyRNA *prop;
-
-       int flag;
-       short browse;
-       char *newop;
-       char *openop;
-       char *unlinkop;
-} uiTemplateHeadID;
-
-/* Layout */
-
-struct uiLayout {
-       ListBase templates;
-       int opcontext;
-       int dir, type;
-       int x, y, w, h;
-       int emw, emh;
+} uiLayoutItemSplt;
 
-       uiMenuHandleFunc handlefunc;
-       void *argv;
-
-       uiStyle *style;
-};
+typedef struct uiLayoutItemBx {
+       uiLayout litem;
+} uiLayoutItemBx;
 
-void ui_layout_free(uiLayout *layout);
-void ui_layout_end(const bContext *C, uiBlock *block, uiLayout *layout, int *x, int *y);
+typedef struct uiLayoutItemRoot {
+       uiLayout litem;
+} uiLayoutItemRoot;
 
 /************************** Item ***************************/
 
-static void ui_item_name(uiItem *item, char *name)
-{
-       if(!item->name && name) {
-               BLI_strncpy(item->namestr, name, sizeof(item->namestr));
-               item->name= item->namestr;
-       }
-}
-static void ui_item_name_add_colon(uiItem *item)
+static char *ui_item_name_add_colon(char *name, char namestr[UI_MAX_NAME_STR])
 {
-       int len= strlen(item->namestr);
+       int len= strlen(name);
 
-       if(len != 0 && len+1 < sizeof(item->namestr)) {
-               item->namestr[len]= ':';
-               item->namestr[len+1]= '\0';
+       if(len != 0 && len+1 < UI_MAX_NAME_STR) {
+               BLI_strncpy(namestr, name, UI_MAX_NAME_STR);
+               namestr[len]= ':';
+               namestr[len+1]= '\0';
+               return namestr;
        }
+
+       return name;
 }
 
 #define UI_FIT_EXPAND 1
 
 static int ui_item_fit(int item, int pos, int all, int available, int spacing, int last, int flag)
 {
-       if(all > available-spacing) {
+       /* available == 0 is unlimited */
+
+       if(available != 0 && all > available-spacing) {
                /* contents is bigger than available space */
                if(last)
                        return available-pos;
@@ -209,7 +181,7 @@ static int ui_item_fit(int item, int pos, int all, int available, int spacing, i
        }
        else {
                /* contents is smaller or equal to available space */
-               if(flag & UI_FIT_EXPAND) {
+               if(available != 0 && (flag & UI_FIT_EXPAND)) {
                        if(last)
                                return available-pos;
                        else
@@ -220,54 +192,162 @@ static int ui_item_fit(int item, int pos, int all, int available, int spacing, i
        }
 }
 
+/* variable button size in which direction? */
+#define UI_ITEM_VARY_X 1
+#define UI_ITEM_VARY_Y 2
+
+static int ui_layout_vary_direction(uiLayout *layout)
+{
+       return (layout->common->type == UI_LAYOUT_HEADER)? UI_ITEM_VARY_X: UI_ITEM_VARY_Y;
+}
+
+/* estimated size of text + icon */
+static int ui_text_icon_width(uiLayout *layout, char *name, int icon)
+{
+       int variable = ui_layout_vary_direction(layout) == UI_ITEM_VARY_X;
+
+       if(icon && strcmp(name, "") == 0)
+               return UI_UNIT_X; /* icon only */
+       else if(icon)
+               return (variable)? UI_GetStringWidth(name) + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */
+       else
+               return (variable)? UI_GetStringWidth(name) + UI_UNIT_X: 10*UI_UNIT_X; /* text only */
+}
+
+static void ui_item_size(uiItem *item, int *r_w, int *r_h)
+{
+       if(item->type == ITEM_BUTTON) {
+               uiButtonItem *bitem= (uiButtonItem*)item;
+
+               if(r_w) *r_w= bitem->but->x2 - bitem->but->x1;
+               if(r_h) *r_h= bitem->but->y2 - bitem->but->y1;
+       }
+       else {
+               uiLayout *litem= (uiLayout*)item;
+
+               if(r_w) *r_w= litem->w;
+               if(r_h) *r_h= litem->h;
+       }
+}
+
+static void ui_item_offset(uiItem *item, int *r_x, int *r_y)
+{
+       if(item->type == ITEM_BUTTON) {
+               uiButtonItem *bitem= (uiButtonItem*)item;
+
+               if(r_x) *r_x= bitem->but->x1;
+               if(r_y) *r_y= bitem->but->y1;
+       }
+       else {
+               if(r_x) *r_x= 0;
+               if(r_y) *r_y= 0;
+       }
+}
+
+static void ui_item_position(uiItem *item, int x, int y, int w, int h)
+{
+       if(item->type == ITEM_BUTTON) {
+               uiButtonItem *bitem= (uiButtonItem*)item;
+
+               bitem->but->x1= x;
+               bitem->but->y1= y;
+               bitem->but->x2= x+w;
+               bitem->but->y2= y+h;
+       }
+       else {
+               uiLayout *litem= (uiLayout*)item;
+
+               litem->x= x;
+               litem->y= y+h;
+               litem->w= w;
+               litem->h= h;
+       }
+}
+
+/******************** Special RNA Items *********************/
+
+static int ui_layout_local_dir(uiLayout *layout)
+{
+       switch(layout->item.type) {
+               case ITEM_LAYOUT_ROW:
+               case ITEM_LAYOUT_ROOT:
+                       return UI_LAYOUT_HORIZONTAL;
+               case ITEM_LAYOUT_COLUMN:
+               case ITEM_LAYOUT_COLUMN_FLOW:
+               case ITEM_LAYOUT_SPLIT:
+               case ITEM_LAYOUT_FREE:
+               case ITEM_LAYOUT_BOX:
+               default:
+                       return UI_LAYOUT_VERTICAL;
+       }
+}
+
+static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, int align)
+{
+       uiLayout *sub;
+
+       if(ui_layout_local_dir(test) == UI_LAYOUT_HORIZONTAL)
+               sub= uiLayoutRow(layout, align);
+       else
+               sub= uiLayoutColumn(layout, align);
+       
+       sub->space= 0;
+       return sub;
+}
+
 /* create buttons for an item with an RNA array */
-static void ui_item_array(uiLayout *layout, uiBlock *block, uiItemRNA *rnaitem, int len, int x, int y, int w, int h)
+static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int len, int x, int y, int w, int h, int expand)
 {
-       uiStyle *style= layout->style;
+       uiStyle *style= layout->common->style;
        PropertyType type;
        PropertySubType subtype;
+       uiLayout *sub;
        int a;
 
        /* retrieve type and subtype */
-       type= RNA_property_type(rnaitem->prop);
-       subtype= RNA_property_subtype(rnaitem->prop);
+       type= RNA_property_type(prop);
+       subtype= RNA_property_subtype(prop);
+
+       sub= ui_item_local_sublayout(layout, layout, 0);
+       uiBlockSetCurLayout(block, sub);
 
        /* create label */
-       if(strcmp(rnaitem->item.name, "") != 0)
-               uiDefBut(block, LABEL, 0, rnaitem->item.name, x, y + h - EM_UNIT_Y, w, EM_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+       if(strcmp(name, "") != 0)
+               uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
 
        /* create buttons */
-       uiBlockBeginAlign(block);
-
        if(type == PROP_BOOLEAN && len == 20) {
                /* special check for layer layout */
-               int butw, buth;
+               int butw, buth, unit;
 
-               butw= ui_item_fit(EM_UNIT_X, 0, EM_UNIT_X*10 + style->buttonspacex, w, 0, 0, UI_FIT_EXPAND);
-               buth= MIN2(EM_UNIT_Y, butw);
+               uiBlockSetCurLayout(block, uiLayoutFree(layout, 0));
 
-               y += 2*(EM_UNIT_Y - buth);
+               unit= UI_UNIT_X*0.75;
+               butw= unit;
+               buth= unit;
 
                uiBlockBeginAlign(block);
                for(a=0; a<5; a++)
-                       uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, a, "", ICON_BLANK1, x + butw*a, y+buth, butw, buth);
+                       uiDefAutoButR(block, ptr, prop, a, "", ICON_BLANK1, x + butw*a, y+buth, butw, buth);
                for(a=0; a<5; a++)
-                       uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, a+10, "", ICON_BLANK1, x + butw*a, y, butw, buth);
+                       uiDefAutoButR(block, ptr, prop, a+10, "", ICON_BLANK1, x + butw*a, y, butw, buth);
                uiBlockEndAlign(block);
 
                x += 5*butw + style->buttonspacex;
 
                uiBlockBeginAlign(block);
                for(a=0; a<5; a++)
-                       uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, a+5, "", ICON_BLANK1, x + butw*a, y+buth, butw, buth);
+                       uiDefAutoButR(block, ptr, prop, a+5, "", ICON_BLANK1, x + butw*a, y+buth, butw, buth);
                for(a=0; a<5; a++)
-                       uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, a+15, "", ICON_BLANK1, x + butw*a, y, butw, buth);
+                       uiDefAutoButR(block, ptr, prop, a+15, "", ICON_BLANK1, x + butw*a, y, butw, buth);
                uiBlockEndAlign(block);
        }
        else if(subtype == PROP_MATRIX) {
                /* matrix layout */
                int row, col;
 
+               uiBlockSetCurLayout(block, uiLayoutFree(layout, 1));
+
                len= ceil(sqrt(len));
 
                h /= len;
@@ -278,315 +358,156 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, uiItemRNA *rnaitem,
                        col= a%len;
                        row= a/len;
 
-                       uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, a, "", 0, x + w*col, y+(row-a-1)*EM_UNIT_Y, w, EM_UNIT_Y);
+                       uiDefAutoButR(block, ptr, prop, a, "", 0, x + w*col, y+(row-a-1)*UI_UNIT_Y, w, UI_UNIT_Y);
                }
        }
        else if(len <= 4 && ELEM3(subtype, PROP_ROTATION, PROP_VECTOR, PROP_COLOR)) {
-               /* layout for known array subtypes */
-               static char vectoritem[4]= {'X', 'Y', 'Z', 'W'};
-               static char quatitem[4]= {'W', 'X', 'Y', 'Z'};
-               static char coloritem[4]= {'R', 'G', 'B', 'A'};
-               char str[3];
-
-               for(a=0; a<len; a++) {
-                       if(len == 4 && subtype == PROP_ROTATION)
-                               str[0]= quatitem[a];
-                       else if(subtype == PROP_VECTOR || subtype == PROP_ROTATION)
-                               str[0]= vectoritem[a];
-                       else
-                               str[0]= coloritem[a];
+               uiBlockSetCurLayout(block, ui_item_local_sublayout(layout, sub, 1));
+
+               if(subtype == PROP_COLOR)
+                       uiDefAutoButR(block, ptr, prop, -1, "", 0, 0, 0, w, UI_UNIT_Y);
+
+               if(subtype != PROP_COLOR || expand) {
+                       /* layout for known array subtypes */
+                       static char vectoritem[4]= {'X', 'Y', 'Z', 'W'};
+                       static char quatitem[4]= {'W', 'X', 'Y', 'Z'};
+                       static char coloritem[4]= {'R', 'G', 'B', 'A'};
+                       char str[3];
+
+                       for(a=0; a<len; a++) {
+                               if(len == 4 && subtype == PROP_ROTATION)
+                                       str[0]= quatitem[a];
+                               else if(subtype == PROP_VECTOR || subtype == PROP_ROTATION)
+                                       str[0]= vectoritem[a];
+                               else
+                                       str[0]= coloritem[a];
+
+                               if(type == PROP_BOOLEAN) {
+                                       str[1]= '\0';
+                               }
+                               else {
+                                       str[1]= ':';
+                                       str[2]= '\0';
+                               }
 
-                       if(type == PROP_BOOLEAN) {
-                               str[1]= '\0';
-                       }
-                       else {
-                               str[1]= ':';
-                               str[2]= '\0';
+                               uiDefAutoButR(block, ptr, prop, a, str, 0, 0, 0, w, UI_UNIT_Y);
                        }
-
-                       uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, a, str, 0, x, y+(len-a-1)*EM_UNIT_Y, w, EM_UNIT_Y);
                }
+               else if(subtype == PROP_COLOR && len == 4)
+                       uiDefAutoButR(block, ptr, prop, 3, "A:", 0, 0, 0, w, UI_UNIT_Y);
        }
        else {
                /* default array layout */
+               uiBlockSetCurLayout(block, ui_item_local_sublayout(layout, sub, 1));
+
                for(a=0; a<len; a++)
-                       uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, a, "", 0, x, y+(len-a-1)*EM_UNIT_Y, w, EM_UNIT_Y);
+                       uiDefAutoButR(block, ptr, prop, a, "", 0, 0, 0, w, UI_UNIT_Y);
        }
 
-       uiBlockEndAlign(block);
+       uiBlockSetCurLayout(block, layout);
 }
 
-static void ui_item_enum_row(uiBlock *block, uiItemRNA *rnaitem, int x, int y, int w, int h)
+static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int x, int y, int w, int h)
 {
        const EnumPropertyItem *item;
-       int a, totitem, pos, itemw;
+       int a, totitem, itemw;
        const char *propname;
-       
-       propname= RNA_property_identifier(rnaitem->prop);
-       RNA_property_enum_items(&rnaitem->ptr, rnaitem->prop, &item, &totitem);
 
-       uiBlockBeginAlign(block);
-       pos= 0;
+       propname= RNA_property_identifier(prop);
+       RNA_property_enum_items(ptr, prop, &item, &totitem);
+
+       uiBlockSetCurLayout(block, ui_item_local_sublayout(layout, layout, 1));
        for(a=0; a<totitem; a++) {
-               itemw= ui_item_fit(1, pos, totitem, w, 0, a == totitem-1, UI_FIT_EXPAND);
-               uiDefButR(block, ROW, 0, NULL, x+pos, y, itemw, h, &rnaitem->ptr, propname, -1, 0, item[a].value, -1, -1, NULL);
-               pos += itemw;
+               itemw= ui_text_icon_width(block->curlayout, (char*)item[a].name, 0);
+               uiDefButR(block, ROW, 0, NULL, 0, 0, itemw, h, ptr, propname, -1, 0, item[a].value, -1, -1, NULL);
        }
-       uiBlockEndAlign(block);
+       uiBlockSetCurLayout(block, layout);
 }
 
 /* create label + button for RNA property */
-static void ui_item_with_label(uiBlock *block, uiItemRNA *rnaitem, int x, int y, int w, int h)
+static void ui_item_with_label(uiLayout *layout, uiBlock *block, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int x, int y, int w, int h)
 {
-       if(strcmp(rnaitem->item.name, "") != 0) {
-               w= w/2;
-               uiDefBut(block, LABEL, 0, rnaitem->item.name, x, y, w, h, NULL, 0.0, 0.0, 0, 0, "");
-               x += w;
-       }
+       uiLayout *sub;
+       PropertySubType subtype;
 
-       uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, rnaitem->index, "", rnaitem->item.icon, x, y, w, h);
-}
-
-/* create buttons for an arbitrary item */
-static void ui_item_buts(uiLayout *layout, uiBlock *block, uiItem *item, int x, int y, int w, int h)
-{
-       if(item->type == ITEM_RNA_PROPERTY) {
-               /* RNA property */
-               uiItemRNA *rnaitem= (uiItemRNA*)item;
-               PropertyType type;
-               int len;
-               
-               /* retrieve info */
-               type= RNA_property_type(rnaitem->prop);
-               len= RNA_property_array_length(rnaitem->prop);
-
-               /* array property */
-               if(rnaitem->index == RNA_NO_INDEX && len > 0)
-                       ui_item_array(layout, block, rnaitem, len, x, y, w, h);
-               /* enum item */
-               else if(type == PROP_ENUM && rnaitem->index == RNA_ENUM_VALUE) {
-                       char *identifier= (char*)RNA_property_identifier(rnaitem->prop);
-
-                       if(item->icon && strcmp(item->name, "") != 0)
-                               uiDefIconTextButR(block, ROW, 0, item->icon, item->name, x, y, w, h, &rnaitem->ptr, identifier, -1, 0, rnaitem->value, -1, -1, NULL);
-                       else if(item->icon)
-                               uiDefIconButR(block, ROW, 0, item->icon, x, y, w, h, &rnaitem->ptr, identifier, -1, 0, rnaitem->value, -1, -1, NULL);
-                       else
-                               uiDefButR(block, ROW, 0, item->name, x, y, w, h, &rnaitem->ptr, identifier, -1, 0, rnaitem->value, -1, -1, NULL);
-               }
-               /* expanded enum */
-               else if(type == PROP_ENUM && rnaitem->expand)
-                       ui_item_enum_row(block, rnaitem, x, y, w, h);
-               /* property with separate label */
-               else if(type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER)
-                       ui_item_with_label(block, rnaitem, x, y, w, h);
-               /* single button */
-               else
-                       uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, rnaitem->index, (char*)item->name, item->icon, x, y, w, h);
-       }
-       else if(item->type == ITEM_OPERATOR) {
-               /* operator */
-               uiItemOp *opitem= (uiItemOp*)item;
-               uiBut *but;
-
-               if(item->icon && strcmp(item->name, "") != 0)
-                       but= uiDefIconTextButO(block, BUT, opitem->ot->idname, opitem->context, item->icon, (char*)item->name, x, y, w, h, NULL);
-               else if(item->icon)
-                       but= uiDefIconButO(block, BUT, opitem->ot->idname, opitem->context, item->icon, x, y, w, h, NULL);
-               /* text only */
-               else
-                       but= uiDefButO(block, BUT, opitem->ot->idname, opitem->context, (char*)item->name, x, y, w, h, NULL);
+       sub= uiLayoutRow(layout, 0);
+       uiBlockSetCurLayout(block, sub);
 
-               if(but && opitem->properties) {
-                       /* assign properties */
-                       PointerRNA *opptr= uiButGetOperatorPtrRNA(but);
-                       opptr->data= opitem->properties;
-                       opitem->properties= NULL;
-               }
+       if(strcmp(name, "") != 0) {
+               w= w/2;
+               uiDefBut(block, LABEL, 0, name, x, y, w, h, NULL, 0.0, 0.0, 0, 0, "");
        }
-       else if(item->type == ITEM_MENU) {
-               /* menu */
-               uiBut *but;
-               uiItemMenu *menuitem= (uiItemMenu*)item;
-
-               if(layout->type == UI_LAYOUT_HEADER) { /* ugly .. */
-                       y -= 2;
-                       w -= 3;
-                       h += 4;
-               }
-
-               if(item->icon)
-                       but= uiDefIconTextMenuBut(block, menuitem->func, menuitem->arg, item->icon, (char*)item->name, x, y, w, h, "");
-               else
-                       but= uiDefMenuBut(block, menuitem->func, menuitem->arg, (char*)item->name, x, y, w, h, "");
 
-               if(menuitem->argN) { /* ugly .. */
-                       but->poin= (char*)but;
-                       but->func_argN= menuitem->argN;
-               }
-       }
-       else if(item->type == ITEM_LABEL) {
-               /* label */
-               uiBut *but;
-
-               if(item->icon && strcmp(item->name, "") != 0)
-                       but= uiDefIconTextBut(block, LABEL, 0, item->icon, (char*)item->name, x, y, w, h, NULL, 0.0, 0.0, 0, 0, "");
-               else if(item->icon)
-                       but= uiDefIconBut(block, LABEL, 0, item->icon, x, y, w, h, NULL, 0.0, 0.0, 0, 0, "");
-               else
-                       but= uiDefBut(block, LABEL, 0, (char*)item->name, x, y, w, h, NULL, 0.0, 0.0, 0, 0, "");
+       subtype= RNA_property_subtype(prop);
 
-               if(item->disabled) {
-                       but->flag |= UI_BUT_DISABLED;
-                       but->lock = 1;
-                       but->lockstr = "";
-               }
-       }
-       else if(item->type == ITEM_VALUE) {
-               /* label */
-               uiItemValue *vitem= (uiItemValue*)item;
-               float *retvalue= (block->handle)? &block->handle->retvalue: NULL;
-
-               if(item->icon && strcmp(item->name, "") != 0)
-                       uiDefIconTextButF(block, BUTM, 0, item->icon, (char*)item->name, x, y, w, h, retvalue, 0.0, 0.0, 0, vitem->argval, "");
-               else if(item->icon)
-                       uiDefIconButF(block, BUTM, 0, item->icon, x, y, w, h, retvalue, 0.0, 0.0, 0, vitem->argval, "");
-               else
-                       uiDefButF(block, BUTM, 0, (char*)item->name, x, y, w, h, retvalue, 0.0, 0.0, 0, vitem->argval, "");
-       }
-       else {
-               /* separator */
-               uiDefBut(block, SEPR, 0, "", x, y, w, h, NULL, 0.0, 0.0, 0, 0, "");
+       if(subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) {
+               uiBlockSetCurLayout(block, uiLayoutRow(sub, 1));
+               uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w-UI_UNIT_X, h);
+               uiDefIconBut(block, BUT, 0, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL, 0.0f, 0.0f, 0.0f, 0.0f, "DUMMY file select button"); /* XXX */
        }
-}
-
-/* estimated size of text + icon */
-static int ui_text_icon_width(char *name, int icon, int variable)
-{
-       if(icon && strcmp(name, "") == 0)
-               return EM_UNIT_X; /* icon only */
-       else if(icon)
-               return (variable)? UI_GetStringWidth(name) + EM_UNIT_X: 10*EM_UNIT_X; /* icon + text */
        else
-               return (variable)? UI_GetStringWidth(name) + EM_UNIT_X: 10*EM_UNIT_X; /* text only */
-}
-
-/* estimated size of an item */
-#define UI_ITEM_VARY_X 1
-#define UI_ITEM_VARY_Y 2
-
-static void ui_item_size(uiItem *item, int *r_w, int *r_h, int flag)
-{
-       int w, h;
-
-       if(item->type == ITEM_RNA_PROPERTY) {
-               /* RNA property */
-               uiItemRNA *rnaitem= (uiItemRNA*)item;
-               PropertyType type;
-               PropertySubType subtype;
-               int len;
-
-               w= ui_text_icon_width(item->name, item->icon, flag & UI_ITEM_VARY_X);
-               h= EM_UNIT_Y;
-
-               /* arbitrary extended width by type */
-               type= RNA_property_type(rnaitem->prop);
-               subtype= RNA_property_subtype(rnaitem->prop);
-               len= RNA_property_array_length(rnaitem->prop);
-
-               if(type == PROP_STRING)
-                       w += 10*EM_UNIT_X;
-
-               /* increase height for arrays */
-               if(rnaitem->index == RNA_NO_INDEX && len > 0) {
-                       if(strcmp(item->name, "") == 0 && item->icon == 0)
-                               h= 0;
-
-                       if(type == PROP_BOOLEAN && len == 20)
-                               h += 2*EM_UNIT_Y;
-                       else if(subtype == PROP_MATRIX)
-                               h += ceil(sqrt(len))*EM_UNIT_Y;
-                       else
-                               h += len*EM_UNIT_Y;
-               }
-               else if(flag & UI_ITEM_VARY_X) {
-                       if(type == PROP_BOOLEAN && strcmp(item->name, "") != 0)
-                               w += EM_UNIT_X;
-               }
-       }
-       else {
-               /* other */
-               if(item->type == ITEM_SEPARATOR) {
-                       w= EM_SEPR_X;
-                       h= EM_SEPR_Y;
-               }
-               else {
-                       w= ui_text_icon_width(item->name, item->icon, flag & UI_ITEM_VARY_X);
-                       h= EM_UNIT_Y;
-               }
-       }
+               uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w, h);
 
-       if(r_w) *r_w= w;
-       if(r_h) *r_h= h;
+       uiBlockSetCurLayout(block, layout);
 }
 
-static void ui_item_free(uiItem *item)
-{
-       if(item->type == ITEM_OPERATOR) {
-               uiItemOp *opitem= (uiItemOp*)item;
-
-               if(opitem->properties) {
-                       IDP_FreeProperty(opitem->properties);
-                       MEM_freeN(opitem->properties);
-               }
-       }
-}
+/********************* Button Items *************************/
 
 /* disabled item */
 static void ui_item_disabled(uiLayout *layout, char *name)
 {
-       uiTemplate *template= layout->templates.last;
-       uiItem *item;
-       
-       if(!template)
-               return;
+       uiBlock *block= layout->common->block;
+       uiBut *but;
+       int w;
+
+       uiBlockSetCurLayout(block, layout);
 
-       item= MEM_callocN(sizeof(uiItem), "uiItem");
+       if(!name)
+               name= "";
 
-       ui_item_name(item, name);
-       item->disabled= 1;
-       item->type= ITEM_LABEL;
-       item->slot= template->slot;
+       w= ui_text_icon_width(layout, name, 0);
 
-       BLI_addtail(&template->items, item);
+       but= uiDefBut(block, LABEL, 0, (char*)name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+       but->flag |= UI_BUT_DISABLED;
+       but->lock = 1;
+       but->lockstr = "";
 }
 
 /* operator items */
 void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDProperty *properties, int context)
 {
-       uiTemplate *template= layout->templates.last;
+       uiBlock *block= layout->common->block;
        wmOperatorType *ot= WM_operatortype_find(idname);
-       uiItemOp *opitem;
+       uiBut *but;
+       int w;
 
-       if(!template)
-               return;
        if(!ot) {
                ui_item_disabled(layout, idname);
                return;
        }
 
-       opitem= MEM_callocN(sizeof(uiItemOp), "uiItemOp");
+       if(!name)
+               name= ot->name;
+       if(layout->common->type == UI_LAYOUT_MENU && !icon)
+               icon= ICON_BLANK1;
+
+       /* create button */
+       uiBlockSetCurLayout(block, layout);
 
-       ui_item_name(&opitem->item, name);
-       opitem->item.icon= icon;
-       opitem->item.type= ITEM_OPERATOR;
-       opitem->item.slot= template->slot;
+       w= ui_text_icon_width(layout, name, icon);
 
-       opitem->ot= ot;
-       opitem->properties= properties;
-       opitem->context= context;
+       if(icon && strcmp(name, "") != 0)
+               but= uiDefIconTextButO(block, BUT, ot->idname, context, icon, (char*)name, 0, 0, w, UI_UNIT_Y, NULL);
+       else if(icon)
+               but= uiDefIconButO(block, BUT, ot->idname, context, icon, 0, 0, w, UI_UNIT_Y, NULL);
+       else
+               but= uiDefButO(block, BUT, ot->idname, context, (char*)name, 0, 0, w, UI_UNIT_Y, NULL);
 
-       BLI_addtail(&template->items, opitem);
+       /* assign properties */
+       if(properties) {
+               PointerRNA *opptr= uiButGetOperatorPtrRNA(but);
+               opptr->data= properties;
+       }
 }
 
 static char *ui_menu_enumpropname(char *opname, char *propname, int retval)
@@ -597,16 +518,16 @@ static char *ui_menu_enumpropname(char *opname, char *propname, int retval)
 
        if(!ot || !ot->srna)
                return "";
-       
+
        RNA_pointer_create(NULL, ot->srna, NULL, &ptr);
        prop= RNA_struct_find_property(&ptr, propname);
-       
+
        if(prop) {
                const EnumPropertyItem *item;
                int totitem, i;
-               
+
                RNA_property_enum_items(&ptr, prop, &item, &totitem);
-               
+
                for (i=0; i<totitem; i++) {
                        if(item[i].value==retval)
                                return (char*)item[i].name;
@@ -626,7 +547,7 @@ void uiItemEnumO(uiLayout *layout, char *name, int icon, char *opname, char *pro
        if(!name)
                name= ui_menu_enumpropname(opname, propname, value);
 
-       uiItemFullO(layout, name, icon, opname, ptr.data, layout->opcontext);
+       uiItemFullO(layout, name, icon, opname, ptr.data, layout->common->opcontext);
 }
 
 void uiItemsEnumO(uiLayout *layout, char *opname, char *propname)
@@ -661,7 +582,7 @@ void uiItemBooleanO(uiLayout *layout, char *name, int icon, char *opname, char *
        WM_operator_properties_create(&ptr, opname);
        RNA_boolean_set(&ptr, propname, value);
 
-       uiItemFullO(layout, name, icon, opname, ptr.data, layout->opcontext);
+       uiItemFullO(layout, name, icon, opname, ptr.data, layout->common->opcontext);
 }
 
 void uiItemIntO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value)
@@ -671,7 +592,7 @@ void uiItemIntO(uiLayout *layout, char *name, int icon, char *opname, char *prop
        WM_operator_properties_create(&ptr, opname);
        RNA_int_set(&ptr, propname, value);
 
-       uiItemFullO(layout, name, icon, opname, ptr.data, layout->opcontext);
+       uiItemFullO(layout, name, icon, opname, ptr.data, layout->common->opcontext);
 }
 
 void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *propname, float value)
@@ -681,7 +602,7 @@ void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *pr
        WM_operator_properties_create(&ptr, opname);
        RNA_float_set(&ptr, propname, value);
 
-       uiItemFullO(layout, name, icon, opname, ptr.data, layout->opcontext);
+       uiItemFullO(layout, name, icon, opname, ptr.data, layout->common->opcontext);
 }
 
 void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value)
@@ -691,39 +612,112 @@ void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *p
        WM_operator_properties_create(&ptr, opname);
        RNA_string_set(&ptr, propname, value);
 
-       uiItemFullO(layout, name, icon, opname, ptr.data, layout->opcontext);
+       uiItemFullO(layout, name, icon, opname, ptr.data, layout->common->opcontext);
 }
 
 void uiItemO(uiLayout *layout, char *name, int icon, char *opname)
 {
-       uiItemFullO(layout, name, icon, opname, NULL, layout->opcontext);
+       uiItemFullO(layout, name, icon, opname, NULL, layout->common->opcontext);
 }
 
 /* RNA property items */
+
+static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA *prop, int index, int *r_w, int *r_h)
+{
+       PropertyType type;
+       PropertySubType subtype;
+       int len, w, h;
+
+       w= ui_text_icon_width(layout, name, icon);
+       h= UI_UNIT_Y;
+
+       /* arbitrary extended width by type */
+       type= RNA_property_type(prop);
+       subtype= RNA_property_subtype(prop);
+       len= RNA_property_array_length(prop);
+
+       if(type == PROP_STRING)
+               w += 10*UI_UNIT_X;
+
+       /* increase height for arrays */
+       if(index == RNA_NO_INDEX && len > 0) {
+               if(strcmp(name, "") == 0 && icon == 0)
+                       h= 0;
+
+               if(type == PROP_BOOLEAN && len == 20)
+                       h += 2*UI_UNIT_Y;
+               else if(subtype == PROP_MATRIX)
+                       h += ceil(sqrt(len))*UI_UNIT_Y;
+               else
+                       h += len*UI_UNIT_Y;
+       }
+       else if(ui_layout_vary_direction(layout) == UI_ITEM_VARY_X) {
+               if(type == PROP_BOOLEAN && strcmp(name, "") != 0)
+                       w += UI_UNIT_X;
+       }
+
+       *r_w= w;
+       *r_h= h;
+}
+
 void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int expand)
 {
-       uiTemplate *template= layout->templates.last;
-       uiItemRNA *rnaitem;
+       uiBlock *block= layout->common->block;
+       PropertyType type;
+       char namestr[UI_MAX_NAME_STR];
+       int len, w, h;
 
        if(!ptr->data || !prop)
                return;
-       if(!template)
-               return;
 
-       rnaitem= MEM_callocN(sizeof(uiItemRNA), "uiItemRNA");
+       uiBlockSetCurLayout(block, layout);
+
+       /* retrieve info */
+       type= RNA_property_type(prop);
+       len= RNA_property_array_length(prop);
 
-       ui_item_name(&rnaitem->item, name);
-       rnaitem->item.icon= icon;
-       rnaitem->item.type= ITEM_RNA_PROPERTY;
-       rnaitem->item.slot= template->slot;
+       /* set name and icon */
+       if(!name)
+               name= (char*)RNA_property_ui_name(prop);
+
+       if(ELEM5(type, PROP_INT, PROP_FLOAT, PROP_STRING, PROP_ENUM, PROP_POINTER))
+               name= ui_item_name_add_colon(name, namestr);
+       if(type == PROP_BOOLEAN && len)
+               name= ui_item_name_add_colon(name, namestr);
+
+       if(layout->common->type == UI_LAYOUT_MENU) {
+               if(type == PROP_BOOLEAN)
+                       icon= (RNA_property_boolean_get(ptr, prop))? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT;
+               else if(type == PROP_ENUM && index == RNA_ENUM_VALUE)
+                       icon= (RNA_property_enum_get(ptr, prop) == value)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; 
+       }
+
+       /* get size */
+       ui_item_rna_size(layout, name, icon, prop, index, &w, &h);
 
-       rnaitem->ptr= *ptr;
-       rnaitem->prop= prop;
-       rnaitem->index= index;
-       rnaitem->value= value;
-       rnaitem->expand= expand;
+       /* array property */
+       if(index == RNA_NO_INDEX && len > 0)
+               ui_item_array(layout, block, name, icon, ptr, prop, len, 0, 0, w, h, expand);
+       /* enum item */
+       else if(type == PROP_ENUM && index == RNA_ENUM_VALUE) {
+               char *identifier= (char*)RNA_property_identifier(prop);
 
-       BLI_addtail(&template->items, rnaitem);
+               if(icon && strcmp(name, "") != 0)
+                       uiDefIconTextButR(block, ROW, 0, icon, name, 0, 0, w, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
+               else if(icon)
+                       uiDefIconButR(block, ROW, 0, icon, 0, 0, w, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
+               else
+                       uiDefButR(block, ROW, 0, name, 0, 0, w, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
+       }
+       /* expanded enum */
+       else if(type == PROP_ENUM && expand)
+               ui_item_enum_row(layout, block, ptr, prop, 0, 0, w, h);
+       /* property with separate label */
+       else if(type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER)
+               ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h);
+       /* single button */
+       else
+               uiDefAutoButR(block, ptr, prop, index, (char*)name, icon, 0, 0, w, h);
 }
 
 void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *propname, int expand)
@@ -740,7 +734,7 @@ void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *prop
                printf("uiItemR: property not found: %s\n", propname);
                return;
        }
-       
+
        uiItemFullR(layout, name, icon, ptr, prop, RNA_NO_INDEX, 0, expand);
 }
 
@@ -758,7 +752,7 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr,
                printf("uiItemEnumR: property not found: %s\n", propname);
                return;
        }
-       
+
        uiItemFullR(layout, name, icon, ptr, prop, RNA_ENUM_VALUE, value, 0);
 }
 
@@ -795,106 +789,127 @@ static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
        mt->draw(C, &menu);
 }
 
-void uiItemM(uiLayout *layout, char *name, int icon, char *menuname)
+static void ui_item_menu(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func, void *arg, void *argN)
 {
-       uiTemplate *template= layout->templates.last;
-       uiItemMenu *menuitem;
-       
-       if(!template)
-               return;
-       if(!menuname)
-               return;
+       uiBlock *block= layout->common->block;
+       uiBut *but;
+       int w, h;
 
-       menuitem= MEM_callocN(sizeof(uiItemMenu), "uiItemMenu");
+       uiBlockSetCurLayout(block, layout);
 
-       ui_item_name(&menuitem->item, name);
-       menuitem->item.icon= icon;
-       menuitem->item.type= ITEM_MENU;
-       menuitem->item.slot= template->slot;
+       if(layout->common->type == UI_LAYOUT_HEADER)
+               uiBlockSetEmboss(block, UI_EMBOSSP);
 
-       menuitem->func= ui_item_menutype_func;
-       menuitem->menuname= menuname;
+       if(!name)
+               name= "";
+       if(layout->common->type == UI_LAYOUT_MENU && !icon)
+               icon= ICON_BLANK1;
 
-       BLI_addtail(&template->items, menuitem);
-}
+       w= ui_text_icon_width(layout, name, icon);
+       h= UI_UNIT_Y;
 
-/* label item */
-void uiItemL(uiLayout *layout, char *name, int icon)
-{
-       uiTemplate *template= layout->templates.last;
-       uiItem *item;
-       
-       if(!template)
-               return;
+       if(layout->common->type == UI_LAYOUT_HEADER) /* ugly .. */
+               w -= 3;
 
-       item= MEM_callocN(sizeof(uiItem), "uiItem");
+       if(icon)
+               but= uiDefIconTextMenuBut(block, func, arg, icon, (char*)name, 0, 0, w, h, "");
+       else
+               but= uiDefMenuBut(block, func, arg, (char*)name, 0, 0, w, h, "");
 
-       ui_item_name(item, name);
-       item->icon= icon;
-       item->type= ITEM_LABEL;
-       item->slot= template->slot;
+       if(argN) { /* ugly .. */
+               but->poin= (char*)but;
+               but->func_argN= argN;
+       }
 
-       BLI_addtail(&template->items, item);
+       if(layout->common->type == UI_LAYOUT_HEADER)
+               uiBlockSetEmboss(block, UI_EMBOSS);
 }
 
-/* value item */
-void uiItemV(uiLayout *layout, char *name, int icon, int argval)
+void uiItemM(uiLayout *layout, bContext *C, char *name, int icon, char *menuname)
 {
-       uiTemplate *template= layout->templates.last;
-       uiItemValue *vitem;
-       
-       if(!template)
-               return;
-
-       vitem= MEM_callocN(sizeof(uiItemValue), "uiItemValue");
+       ARegion *ar= CTX_wm_region(C);
+       MenuType *mt;
 
-       vitem->item.name= name;
-       vitem->item.icon= icon;
-       vitem->item.type= ITEM_VALUE;
-       vitem->item.slot= template->slot;
-       vitem->argval= argval;
+       if(!menuname)
+               return;
 
-       BLI_addtail(&template->items, vitem);
-}
+       for(mt=ar->type->menutypes.first; mt; mt=mt->next) {
+               if(strcmp(menuname, mt->idname) == 0) {
+                       if(!name)
+                               name= mt->label;
+                       if(layout->common->type == UI_LAYOUT_MENU && !icon)
+                               icon= ICON_BLANK1;
+                       ui_item_menu(layout, name, icon, ui_item_menutype_func, mt, NULL);
+                       break;
+               }
+       }
+}
 
-/* separator item */
-void uiItemS(uiLayout *layout)
+/* label item */
+void uiItemL(uiLayout *layout, char *name, int icon)
 {
-       uiTemplate *template= layout->templates.last;
-       uiItem *item;
-       
-       if(!template)
-               return;
+       uiBlock *block= layout->common->block;
+       uiBut *but;
+       int w;
+
+       uiBlockSetCurLayout(block, layout);
+
+       if(!name)
+               name= "";
+       if(layout->common->type == UI_LAYOUT_MENU && !icon)
+               icon= ICON_BLANK1;
+
+       w= ui_text_icon_width(layout, name, icon);
+
+       if(icon && strcmp(name, "") != 0)
+               but= uiDefIconTextBut(block, LABEL, 0, icon, (char*)name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+       else if(icon)
+               but= uiDefIconBut(block, LABEL, 0, icon, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+       else
+               but= uiDefBut(block, LABEL, 0, (char*)name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+}
+
+/* value item */
+void uiItemV(uiLayout *layout, char *name, int icon, int argval)
+{
+       /* label */
+       uiBlock *block= layout->common->block;
+       float *retvalue= (block->handle)? &block->handle->retvalue: NULL;
+       int w;
 
-       item= MEM_callocN(sizeof(uiItem), "uiItem");
+       uiBlockSetCurLayout(block, layout);
 
-       item->type= ITEM_SEPARATOR;
-       item->slot= template->slot;
+       if(!name)
+               name= "";
+       if(layout->common->type == UI_LAYOUT_MENU && !icon)
+               icon= ICON_BLANK1;
+
+       w= ui_text_icon_width(layout, name, icon);
 
-       BLI_addtail(&template->items, item);
+       if(icon && strcmp(name, "") != 0)
+               uiDefIconTextButF(block, BUTM, 0, icon, (char*)name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, argval, "");
+       else if(icon)
+               uiDefIconButF(block, BUTM, 0, icon, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, argval, "");
+       else
+               uiDefButF(block, BUTM, 0, (char*)name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, argval, "");
+}
+
+/* separator item */
+void uiItemS(uiLayout *layout)
+{
+       uiBlock *block= layout->common->block;
+
+       uiBlockSetCurLayout(block, layout);
+       uiDefBut(block, SEPR, 0, "", 0, 0, EM_SEPR_X, EM_SEPR_Y, NULL, 0.0, 0.0, 0, 0, "");
 }
 
 /* level items */
 void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func)
 {
-       uiTemplate *template= layout->templates.last;
-       uiItemMenu *menuitem;
-       
-       if(!template)
-               return;
        if(!func)
                return;
 
-       menuitem= MEM_callocN(sizeof(uiItemMenu), "uiItemMenu");
-
-       ui_item_name(&menuitem->item, name);
-       menuitem->item.icon= icon;
-       menuitem->item.type= ITEM_MENU;
-       menuitem->item.slot= template->slot;
-
-       menuitem->func= func;
-
-       BLI_addtail(&template->items, menuitem);
+       ui_item_menu(layout, name, icon, func, NULL, NULL);
 }
 
 typedef struct MenuItemLevel {
@@ -915,36 +930,24 @@ static void menu_item_enum_opname_menu(bContext *C, uiLayout *layout, void *arg)
 void uiItemMenuEnumO(uiLayout *layout, char *name, int icon, char *opname, char *propname)
 {
        wmOperatorType *ot= WM_operatortype_find(opname);
-       uiTemplate *template= layout->templates.last;
-       uiItemMenu *menuitem;
        MenuItemLevel *lvl;
 
        if(!ot || !ot->srna) {
                ui_item_disabled(layout, opname);
                return;
        }
-       if(!template)
-               return;
-
-       menuitem= MEM_callocN(sizeof(uiItemMenu), "uiItemMenu");
 
        if(!name)
                name= ot->name;
-
-       ui_item_name(&menuitem->item, name);
-       menuitem->item.icon= icon;
-       menuitem->item.type= ITEM_MENU;
-       menuitem->item.slot= template->slot;
+       if(layout->common->type == UI_LAYOUT_MENU && !icon)
+               icon= ICON_BLANK1;
 
        lvl= MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
        lvl->opname= opname;
        lvl->propname= propname;
-       lvl->opcontext= layout->opcontext;
+       lvl->opcontext= layout->common->opcontext;
 
-       menuitem->func= menu_item_enum_opname_menu;
-       menuitem->argN= lvl;
-
-       BLI_addtail(&template->items, menuitem);
+       ui_item_menu(layout, name, icon, menu_item_enum_opname_menu, NULL, lvl);
 }
 
 static void menu_item_enum_rna_menu(bContext *C, uiLayout *layout, void *arg)
@@ -957,13 +960,8 @@ static void menu_item_enum_rna_menu(bContext *C, uiLayout *layout, void *arg)
 
 void uiItemMenuEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname)
 {
-       uiTemplate *template= layout->templates.last;
-       uiItemMenu *menuitem;
        MenuItemLevel *lvl;
        PropertyRNA *prop;
-       
-       if(!template)
-               return;
 
        prop= RNA_struct_find_property(ptr, propname);
        if(!prop) {
@@ -971,118 +969,210 @@ void uiItemMenuEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *
                return;
        }
 
-       menuitem= MEM_callocN(sizeof(uiItemMenu), "uiItemMenu");
-
        if(!name)
                name= (char*)RNA_property_ui_name(prop);
-
-       ui_item_name(&menuitem->item, name);
-       menuitem->item.icon= icon;
-       menuitem->item.type= ITEM_MENU;
-       menuitem->item.slot= template->slot;
+       if(layout->common->type == UI_LAYOUT_MENU && !icon)
+               icon= ICON_BLANK1;
 
        lvl= MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
        lvl->rnapoin= *ptr;
        lvl->propname= propname;
-       lvl->opcontext= layout->opcontext;
-
-       menuitem->func= menu_item_enum_rna_menu;
-       menuitem->argN= lvl;
+       lvl->opcontext= layout->common->opcontext;
 
-       BLI_addtail(&template->items, menuitem);
+       ui_item_menu(layout, name, icon, menu_item_enum_rna_menu, NULL, lvl);
 }
 
-/**************************** Template ***************************/
+/**************************** Layout Items ***************************/
 
-/* single row layout */
-static void ui_layout_row(uiLayout *layout, uiBlock *block, uiTemplate *template)
+/* single-row layout */
+static void ui_litem_estimate_row(uiLayout *litem)
 {
-       uiStyle *style= layout->style;
        uiItem *item;
-       int tot=0, totw= 0, maxh= 0, itemw, itemh, x, w;
+       int itemw, itemh;
+
+       litem->w= 0;
+       litem->h= 0;
+
+       for(item=litem->items.first; item; item=item->next) {
+               ui_item_size(item, &itemw, &itemh);
 
-       /* estimate total width of buttons */
-       for(item=template->items.first; item; item=item->next) {
-               ui_item_size(item, &itemw, &itemh, UI_ITEM_VARY_Y);
+               litem->w += itemw;
+               litem->h= MAX2(itemh, litem->h);
+
+               if(item->next)
+                       litem->w += litem->space;
+       }
+}
+
+static void ui_litem_layout_row(uiLayout *litem)
+{
+       uiItem *item;
+       int neww, itemw, itemh, x, y, w, tot= 0, totw= 0, extra=0, available=0;
+
+       x= litem->x;
+       y= litem->y;
+       w= litem->w;
+
+       for(item=litem->items.first; item; item=item->next) {
+               ui_item_size(item, &itemw, &itemh);
                totw += itemw;
-               maxh= MAX2(maxh, itemh);
                tot++;
        }
 
        if(totw == 0)
                return;
        
-       /* create buttons starting from left */
-       x= 0;
-       w= layout->w;
+       /* two step to enforce minimum button with .. could be better */
+       for(item=litem->items.first; item; item=item->next) {
+               ui_item_size(item, &itemw, &itemh);
+
+               itemw= ui_item_fit(itemw, x-litem->x, totw, w, (tot-1)*litem->space, !item->next, UI_FIT_EXPAND);
+               x += itemw;
+
+               if(itemw < UI_UNIT_X)
+                       extra += UI_UNIT_X - itemw;
+               else
+                       available += itemw - UI_UNIT_X;
 
-       for(item=template->items.first; item; item=item->next) {
-               ui_item_size(item, &itemw, &itemh, UI_ITEM_VARY_Y);
-               itemw= ui_item_fit(itemw, x, totw, w, (tot-1)*style->buttonspacex, !item->next, UI_FIT_EXPAND);
+               if(item->next)
+                       x += litem->space;
+       }
+
+       x= litem->x;
+
+       for(item=litem->items.first; item; item=item->next) {
+               ui_item_size(item, &itemw, &itemh);
 
-               ui_item_buts(layout, block, item, layout->x+x, layout->y-itemh, itemw, itemh);
-               x += itemw+style->buttonspacex;
+               neww= ui_item_fit(itemw, x-litem->x, totw, w, (tot-1)*litem->space, !item->next, UI_FIT_EXPAND);
+               if(neww < UI_UNIT_X) {
+                       if(item->next)
+                               itemw= UI_UNIT_X;
+                       else
+                               itemw= litem->w - (x-litem->x);
+               }
+               else
+                       itemw= ui_item_fit(itemw, x-litem->x, totw, w-extra, (tot-1)*litem->space, !item->next, UI_FIT_EXPAND);
+
+               ui_item_position(item, x, y-itemh, itemw, itemh);
+               x += itemw;
+
+               if(item->next)
+                       x += litem->space;
        }
 
-       layout->y -= maxh;
+       litem->w= x - litem->x;
+       litem->h= litem->y - y;
+       litem->x= x;
+       litem->y= y;
 }
 
-/* multi-column layout */
-static void ui_layout_column(uiLayout *layout, uiBlock *block, uiTemplate *template)
+/* single-column layout */
+static void ui_litem_estimate_column(uiLayout *litem)
 {
-       uiStyle *style= layout->style;
        uiItem *item;
-       int col, totcol= 0, x, y, miny, itemw, itemh, w;
+       int itemw, itemh;
 
-       /* compute number of columns */
-       for(item=template->items.first; item; item=item->next)
-               totcol= MAX2(item->slot+1, totcol);
-       
-       if(totcol == 0)
-               return;
-       
-       x= 0;
-       miny= 0;
-       w= layout->w;
+       litem->w= 0;
+       litem->h= 0;
 
-       /* create column per column */
-       for(col=0; col<totcol; col++) {
-               y= 0;
+       for(item=litem->items.first; item; item=item->next) {
+               ui_item_size(item, &itemw, &itemh);
 
-               itemw= ui_item_fit(1, x, totcol, w, (totcol-1)*style->columnspace, col == totcol-1, UI_FIT_EXPAND);
+               litem->w= MAX2(litem->w, itemw);
+               litem->h += itemh;
 
-               for(item=template->items.first; item; item=item->next) {
-                       if(item->slot != col)
-                               continue;
+               if(item->next)
+                       litem->h += litem->space;
+       }
+}
 
-                       ui_item_size(item, NULL, &itemh, UI_ITEM_VARY_Y);
+static void ui_litem_layout_column(uiLayout *litem)
+{
+       uiItem *item;
+       int itemh, x, y;
 
-                       y -= itemh;
-                       ui_item_buts(layout, block, item, layout->x+x, layout->y+y, itemw, itemh);
-                       y -= style->buttonspacey;
-               }
+       x= litem->x;
+       y= litem->y;
 
-               x += itemw + style->columnspace;
-               miny= MIN2(miny, y);
+       for(item=litem->items.first; item; item=item->next) {
+               ui_item_size(item, NULL, &itemh);
+
+               y -= itemh;
+               ui_item_position(item, x, y, litem->w, itemh);
+
+               if(item->next)
+                       y -= litem->space;
        }
 
-       layout->y += miny;
+       litem->h= litem->y - y;
+       litem->x= x;
+       litem->y= y;
+}
+
+/* root layout */
+static void ui_litem_estimate_root(uiLayout *litem)
+{
+       /* nothing to do */
+}
+
+static void ui_litem_layout_root(uiLayout *litem)
+{
+       if(litem->common->type == UI_LAYOUT_HEADER)
+               ui_litem_layout_row(litem);
+       else
+               ui_litem_layout_column(litem);
+}
+
+/* box layout */
+static void ui_litem_estimate_box(uiLayout *litem)
+{
+       uiStyle *style= litem->common->style;
+
+       ui_litem_estimate_column(litem);
+       litem->w += 2*style->boxspace;
+       litem->h += 2*style->boxspace;
+}
+
+static void ui_litem_layout_box(uiLayout *litem)
+{
+       uiStyle *style= litem->common->style;
+       int w, h;
+
+       w= litem->w;
+       h= litem->h;
+
+       litem->x += style->boxspace;
+       litem->y -= style->boxspace;
+
+       if(w != 0) litem->w -= 2*style->boxspace;
+       if(h != 0) litem->h -= 2*style->boxspace;
+
+       ui_litem_layout_column(litem);
+
+       litem->x -= style->boxspace;
+       litem->y -= style->boxspace;
+
+       if(w != 0) litem->w += 2*style->boxspace;
+       if(h != 0) litem->h += 2*style->boxspace;
+
+       /* roundbox around the sublayout */
+       uiDefBut(litem->common->block, ROUNDBOX, 0, "", litem->x, litem->y, litem->w, litem->h, NULL, 7.0, 0.0, 3, 20, "");
 }
 
 /* multi-column layout, automatically flowing to the next */
-static void ui_layout_column_flow(uiLayout *layout, uiBlock *block, uiTemplate *template)
+static void ui_litem_estimate_column_flow(uiLayout *litem)
 {
-       uiStyle *style= layout->style;
-       uiTemplateFlow *flow= (uiTemplateFlow*)template;
+       uiStyle *style= litem->common->style;
+       uiLayoutItemFlow *flow= (uiLayoutItemFlow*)litem;
        uiItem *item;
-       int col, x, y, w, emh, emy, miny, itemw, itemh, maxw=0;
-       int toth, totcol, totitem;
+       int col, x, y, emh, emy, miny, itemw, itemh, maxw=0;
+       int toth, totitem;
 
        /* compute max needed width and total height */
        toth= 0;
        totitem= 0;
-       for(item=template->items.first; item; item=item->next) {
-               ui_item_size(item, &itemw, &itemh, UI_ITEM_VARY_Y);
+       for(item=litem->items.first; item; item=item->next) {
+               ui_item_size(item, &itemw, &itemh);
                maxw= MAX2(maxw, itemw);
                toth += itemh;
                totitem++;
@@ -1090,14 +1180,16 @@ static void ui_layout_column_flow(uiLayout *layout, uiBlock *block, uiTemplate *
 
        if(flow->number <= 0) {
                /* auto compute number of columns, not very good */
-               if(maxw == 0)
+               if(maxw == 0) {
+                       flow->totcol= 1;
                        return;
+               }
 
-               totcol= MAX2(layout->emw/maxw, 1);
-               totcol= MIN2(totcol, totitem);
+               flow->totcol= MAX2(litem->common->emw/maxw, 1);
+               flow->totcol= MIN2(flow->totcol, totitem);
        }
        else
-               totcol= flow->number;
+               flow->totcol= flow->number;
 
        /* compute sizes */
        x= 0;
@@ -1105,742 +1197,512 @@ static void ui_layout_column_flow(uiLayout *layout, uiBlock *block, uiTemplate *
        emy= 0;
        miny= 0;
 
-       w= layout->w;
-       emh= toth/totcol;
+       maxw= 0;
+       emh= toth/flow->totcol;
 
        /* create column per column */
        col= 0;
-       for(item=template->items.first; item; item=item->next) {
-               ui_item_size(item, NULL, &itemh, UI_ITEM_VARY_Y);
-               itemw= ui_item_fit(1, x, totcol, w, (totcol-1)*style->columnspace, col == totcol-1, UI_FIT_EXPAND);
-       
-               y -= itemh;
-               emy -= itemh;
-               ui_item_buts(layout, block, item, layout->x+x, layout->y+y, itemw, itemh);
-               y -= style->buttonspacey;
+       for(item=litem->items.first; item; item=item->next) {
+               ui_item_size(item, &itemw, &itemh);
+
+               y -= itemh + style->buttonspacey;
                miny= MIN2(miny, y);
+               emy -= itemh;
+               maxw= MAX2(itemw, maxw);
 
                /* decide to go to next one */
-               if(col < totcol-1 && emy <= -emh) {
-                       x += itemw + style->columnspace;
+               if(col < flow->totcol-1 && emy <= -emh) {
+                       x += maxw + litem->space;
+                       maxw= 0;
                        y= 0;
                        col++;
                }
        }
 
-       layout->y += miny;
+       litem->h= litem->y - miny;
 }
 
-#if 0
-/* left-right layout, with buttons aligned on both sides */
-static void ui_layout_split(uiLayout *layout, uiBlock *block, uiTemplate *template)
+static void ui_litem_layout_column_flow(uiLayout *litem)
 {
+       uiStyle *style= litem->common->style;
+       uiLayoutItemFlow *flow= (uiLayoutItemFlow*)litem;
        uiItem *item;
-       int tot=0, totw= 0, maxh= 0, itemw, itemh, lx, rx, w;
+       int col, x, y, w, emh, emy, miny, itemw, itemh;
+       int toth, totitem;
 
-       /* estimate total width of buttons */
-       for(item=template->items.first; item; item=item->next) {
-               ui_item_size(item, &itemw, &itemh, UI_ITEM_VARY_Y);
-               totw += itemw;
-               maxh= MAX2(maxh, itemh);
-               tot++;
+       /* compute max needed width and total height */
+       toth= 0;
+       totitem= 0;
+       for(item=litem->items.first; item; item=item->next) {
+               ui_item_size(item, &itemw, &itemh);
+               toth += itemh;
+               totitem++;
        }
 
-       if(totw == 0)
-               return;
+       /* compute sizes */
+       x= litem->x;
+       y= litem->y;
+       emy= 0;
+       miny= 0;
+
+       w= litem->w;
+       emh= toth/flow->totcol;
+
+       /* create column per column */
+       col= 0;
+       for(item=litem->items.first; item; item=item->next) {
+               ui_item_size(item, NULL, &itemh);
+               itemw= ui_item_fit(1, x-litem->x, flow->totcol, w, (flow->totcol-1)*style->columnspace, col == flow->totcol-1, UI_FIT_EXPAND);
        
-       /* create buttons starting from left and right */
-       lx= 0;
-       rx= 0;
-       w= layout->w - style->buttonspacex*(tot-1) + style->buttonspacex;
-
-       for(item=template->items.first; item; item=item->next) {
-               ui_item_size(item, &itemw, &itemh, UI_ITEM_VARY_Y);
-
-               if(item->slot == UI_TSLOT_LR_LEFT) {
-                       itemw= ui_item_fit(itemw, lx, totw, w, 0, 0);
-                       ui_item_buts(layout, block, item, layout->x+lx, layout->y-itemh, itemw, itemh);
-                       lx += itemw + style->buttonspacex;
-               }
-               else {
-                       itemw= ui_item_fit(itemw, totw + rx, totw, w, 0, 0);
-                       rx -= itemw + style->buttonspacex;
-                       ui_item_buts(layout, block, item, layout->x+layout->w+rx, layout->y-itemh, itemw, itemh);
+               y -= itemh;
+               emy -= itemh;
+               ui_item_position(item, x, y, itemw, itemh);
+               y -= style->buttonspacey;
+               miny= MIN2(miny, y);
+
+               /* decide to go to next one */
+               if(col < flow->totcol-1 && emy <= -emh) {
+                       x += itemw + style->columnspace;
+                       y= litem->y;
+                       col++;
                }
        }
 
-       layout->y -= maxh;
+       litem->h= litem->y - miny;
+       litem->x= x;
+       litem->y= miny;
 }
-#endif
 
-/* split in columns */
-static void ui_layout_split(const bContext *C, uiLayout *layout, uiBlock *block, uiTemplate *template)
+/* free layout */
+static void ui_litem_estimate_free(uiLayout *litem)
 {
-       uiStyle *style= layout->style;
-       uiTemplateSplt *split= (uiTemplateSplt*)template;
-       uiLayout *sublayout;
-       int a, x, y, miny, w= layout->w, h= layout->h, splitw;
-
-       x= 0;
-       y= 0;
-       miny= layout->y;
-
-       for(a=0; a<split->number; a++) {
-               sublayout= split->sublayout[a];
+       uiItem *item;
+       int itemx, itemy, itemw, itemh, minx, miny;
 
-               splitw= ui_item_fit(1, x, split->number, w, (split->number-1)*style->columnspace, a == split->number-1, UI_FIT_EXPAND);
-               sublayout->x= layout->x + x;
-               sublayout->w= splitw;
-               sublayout->y= layout->y;
-               sublayout->h= h;
+       minx= 1e6;
+       miny= 1e6;
+       litem->w= 0;
+       litem->h= 0;
 
-               sublayout->emw= layout->emw/split->number;
-               sublayout->emh= layout->emh;
+       for(item=litem->items.first; item; item=item->next) {
+               ui_item_offset(item, &itemx, &itemy);
+               ui_item_size(item, &itemw, &itemh);
 
-               /* do layout for elements in sublayout */
-               ui_layout_end(C, block, sublayout, NULL, &y);
-               miny= MIN2(y, miny);
+               minx= MIN2(minx, itemx);
+               miny= MIN2(miny, itemy);
 
-               x += splitw + style->columnspace;
+               litem->w= MAX2(litem->w, itemx+itemw);
+               litem->h= MAX2(litem->h, itemy+itemh);
        }
 
-       layout->y= miny;
+       litem->w -= minx;
+       litem->h -= miny;
 }
 
-/* element in a box layout */
-static void ui_layout_box(const bContext *C, uiLayout *layout, uiBlock *block, uiTemplate *template)
+static void ui_litem_layout_free(uiLayout *litem)
 {
-       uiStyle *style= layout->style;
-       uiTemplateBx *box= (uiTemplateBx*)template;
-       int starty, startx, w= layout->w, h= layout->h;
+       uiItem *item;
+       float scalex=1.0f, scaley=1.0f;
+       int x, y, newx, newy, itemx, itemy, itemh, itemw, minx, miny, totw, toth;
 
-       startx= layout->x;
-       starty= layout->y;
+       minx= 1e6;
+       miny= 1e6;
+       totw= 0;
+       toth= 0;
 
-       /* some extra padding */
-       box->sublayout->x= layout->x + style->boxspace;
-       box->sublayout->w= w - 2*style->boxspace;
-       box->sublayout->y= layout->y - style->boxspace;
-       box->sublayout->h= h;
+       for(item=litem->items.first; item; item=item->next) {
+               ui_item_offset(item, &itemx, &itemy);
+               ui_item_size(item, &itemw, &itemh);
 
-       box->sublayout->emw= layout->emw;
-       box->sublayout->emh= layout->emh;
+               minx= MIN2(minx, itemx);
+               miny= MIN2(miny, itemy);
 
-       /* do layout for elements in sublayout */
-       ui_layout_end(C, block, box->sublayout, NULL, &layout->y);
+               totw= MAX2(totw, itemx+itemw);
+               toth= MAX2(toth, itemy+itemh);
+       }
 
-       /* roundbox around the sublayout */
-       uiDefBut(block, ROUNDBOX, 0, "", startx, layout->y, w, starty - layout->y, NULL, 7.0, 0.0, 3, 20, "");
-}
+       totw -= minx;
+       toth -= miny;
 
-static void ui_layout_header_buttons(uiLayout *layout, uiBlock *block, uiTemplate *template)
-{
-       uiItem *item;
-       int itemw, itemh;
+       if(litem->w && totw > litem->w)
+               scalex= (float)litem->w/(float)totw;
+       if(litem->h && toth > litem->h)
+               scaley= (float)litem->h/(float)toth;
        
-       uiBlockBeginAlign(block);
+       x= litem->x;
+       y= litem->y - scalex*toth;
 
-       for(item=template->items.first; item; item=item->next) {
-               ui_item_size(item, &itemw, &itemh, UI_ITEM_VARY_X);
-               ui_item_buts(layout, block, item, layout->x, layout->y, itemw, itemh);
-               layout->x += itemw;
-       }
+       for(item=litem->items.first; item; item=item->next) {
+               ui_item_offset(item, &itemx, &itemy);
+               ui_item_size(item, &itemw, &itemh);
 
-       uiBlockEndAlign(block);
-}
-
-static void ui_layout_header(const bContext *C, uiLayout *layout, uiBlock *block, uiTemplate *template)
-{
-       ScrArea *sa= CTX_wm_area(C);
+               if(scalex != 1.0f) {
+                       newx= itemx*scalex;
+                       itemw= (itemx + itemw)*scalex - newx;
+                       itemx= newx;
+               }
 
-       layout->x= ED_area_header_standardbuttons(C, block, layout->y);
+               if(scaley != 1.0f) {
+                       newy= itemy*scaley;
+                       itemh= (itemy + itemh)*scaley - newy;
+                       itemy= newy;
+               }
 
-       if((sa->flag & HEADER_NO_PULLDOWN)==0) {
-               uiBlockSetEmboss(block, UI_EMBOSSP);
-               ui_layout_header_buttons(layout, block, template);
+               ui_item_position(item, x+itemx-minx, y+itemy-miny, itemw, itemh);
        }
 
-       uiBlockSetEmboss(block, UI_EMBOSS);
+       litem->w= scalex*totw;
+       litem->h= litem->y - y;
+       litem->x= x + litem->w;
+       litem->y= y;
 }
 
-static void header_id_cb(bContext *C, void *arg_template, void *arg_event)
+/* split layout */
+static void ui_litem_estimate_split(uiLayout *litem)
 {
-       uiTemplateHeadID *idtemplate= (uiTemplateHeadID*)arg_template;
-       PointerRNA idptr= RNA_property_pointer_get(&idtemplate->ptr, idtemplate->prop);
-       ID *idtest, *id= idptr.data;
-       ListBase *lb= wich_libbase(CTX_data_main(C), ID_TXT); // XXX
-       int nr, event= GET_INT_FROM_POINTER(arg_event);
-       
-       if(event == UI_ID_BROWSE && idtemplate->browse == 32767)
-               event= UI_ID_ADD_NEW;
-       else if(event == UI_ID_BROWSE && idtemplate->browse == 32766)
-               event= UI_ID_OPEN;
-
-       switch(event) {
-               case UI_ID_BROWSE: {
-                       if(id==0) id= lb->first;
-                       if(id==0) return;
-
-                       if(idtemplate->browse== -2) {
-                               /* XXX implement or find a replacement
-                                * activate_databrowse((ID *)G.buts->lockpoin, GS(id->name), 0, B_MESHBROWSE, &idtemplate->browse, do_global_buttons); */
-                               return;
-                       }
-                       if(idtemplate->browse < 0)
-                               return;
-
-                       for(idtest=lb->first, nr=1; idtest; idtest=idtest->next, nr++) {
-                               if(nr==idtemplate->browse) {
-                                       if(id == idtest)
-                                               return;
-
-                                       id= idtest;
-                                       RNA_id_pointer_create(id, &idptr);
-                                       RNA_property_pointer_set(&idtemplate->ptr, idtemplate->prop, idptr);
-                                       RNA_property_update(C, &idtemplate->ptr, idtemplate->prop);
-                                       /* XXX */
-
-                                       break;
-                               }
-                       }
-                       break;
-               }
-#if 0
-               case UI_ID_DELETE:
-                       id= NULL;
-                       break;
-               case UI_ID_FAKE_USER:
-                       if(id) {
-                               if(id->flag & LIB_FAKEUSER) id->us++;
-                               else id->us--;
-                       }
-                       else return;
-                       break;
-#endif
-               case UI_ID_PIN:
-                       break;
-               case UI_ID_ADD_NEW:
-                       WM_operator_name_call(C, idtemplate->newop, WM_OP_INVOKE_REGION_WIN, NULL);
-                       break;
-               case UI_ID_OPEN:
-                       WM_operator_name_call(C, idtemplate->openop, WM_OP_INVOKE_REGION_WIN, NULL);
-                       break;
-#if 0
-               case UI_ID_ALONE:
-                       if(!id || id->us < 1)
-                               return;
-                       break;
-               case UI_ID_LOCAL:
-                       if(!id || id->us < 1)
-                               return;
-                       break;
-               case UI_ID_AUTO_NAME:
-                       break;
-#endif
-       }
+       ui_litem_estimate_row(litem);
 }
 
-static void ui_layout_header_id(const bContext *C, uiLayout *layout, uiBlock *block, uiTemplate *template)
+static void ui_litem_layout_split(uiLayout *litem)
 {
-       uiTemplateHeadID *duptemplate, *idtemplate= (uiTemplateHeadID*)template;
-       uiBut *but;
-       PointerRNA idptr= RNA_property_pointer_get(&idtemplate->ptr, idtemplate->prop);
-       ListBase *lb= wich_libbase(CTX_data_main(C), ID_TXT); // XXX
-
-       if(idtemplate->flag & UI_ID_BROWSE) {
-               char *extrastr, *str;
-               
-               if((idtemplate->flag & UI_ID_ADD_NEW) && (idtemplate->flag && UI_ID_OPEN))
-                       extrastr= "OPEN NEW %x 32766 |ADD NEW %x 32767";
-               else if(idtemplate->flag & UI_ID_ADD_NEW)
-                       extrastr= "ADD NEW %x 32767";
-               else if(idtemplate->flag & UI_ID_OPEN)
-                       extrastr= "OPEN NEW %x 32766";
-               else
-                       extrastr= NULL;
+       uiItem *item;
+       int itemh, x, y, w, tot=0, colw=0;
 
-               duptemplate= MEM_dupallocN(idtemplate);
-               IDnames_to_pupstring(&str, NULL, extrastr, lb, idptr.data, &duptemplate->browse);
+       x= litem->x;
+       y= litem->y;
+       w= litem->w;
 
-               but= uiDefButS(block, MENU, 0, str, layout->x, layout->y, EM_UNIT_X, EM_UNIT_Y, &duptemplate->browse, 0, 0, 0, 0, "Browse existing choices, or add new");
-               uiButSetNFunc(but, header_id_cb, duptemplate, SET_INT_IN_POINTER(UI_ID_BROWSE));
-               layout->x+= EM_UNIT_X;
+       for(item=litem->items.first; item; item=item->next)
+               tot++;
        
-               MEM_freeN(str);
-       }
+       if(tot == 0)
+               return;
+       
+       colw= (litem->w - (tot-1)*litem->space)/tot;
+       colw= MAX2(colw, 0);
 
-       /* text button with name */
-       if(idptr.data) {
-               char name[64];
+       for(item=litem->items.first; item; item=item->next) {
+               ui_item_size(item, NULL, &itemh);
 
-               text_idbutton(idptr.data, name);
-               but= uiDefButR(block, TEX, 0, name, layout->x, layout->y, EM_UNIT_X*6, EM_UNIT_Y, &idptr, "name", -1, 0, 0, -1, -1, NULL);
-               uiButSetNFunc(but, header_id_cb, MEM_dupallocN(idtemplate), SET_INT_IN_POINTER(UI_ID_RENAME));
-               layout->x += EM_UNIT_X*6;
+               ui_item_position(item, x, y-itemh, colw, itemh);
+               x += colw;
 
-               /* delete button */
-               if(idtemplate->flag & UI_ID_DELETE) {
-                       but= uiDefIconButO(block, BUT, idtemplate->unlinkop, WM_OP_EXEC_REGION_WIN, ICON_X, layout->x, layout->y, EM_UNIT_X, EM_UNIT_Y, NULL);
-                       layout->x += EM_UNIT_X;
-               }
+               if(item->next)
+                       x += litem->space;
        }
+
+       litem->w= x - litem->x;
+       litem->h= litem->y - y;
+       litem->x= x;
+       litem->y= y;
 }
 
-void ui_template_free(uiTemplate *template)
+/* layout create functions */
+uiLayout *uiLayoutRow(uiLayout *layout, int align)
 {
-       uiItem *item;
-       int a;
+       uiLayout *litem;
 
-       if(template->type == TEMPLATE_BOX) {
-               uiTemplateBx *box= (uiTemplateBx*)template;
-               ui_layout_free(box->sublayout);
-       }
-       if(template->type == TEMPLATE_SPLIT) {
-               uiTemplateSplt *split= (uiTemplateSplt*)template;
-
-               for(a=0; a<split->number; a++)
-                       ui_layout_free(split->sublayout[a]);
-               MEM_freeN(split->sublayout);
-       }
+       litem= MEM_callocN(sizeof(uiLayout), "uiLayoutRow");
+       litem->item.type= ITEM_LAYOUT_ROW;
+       litem->common= layout->common;
+       litem->align= align;
+       litem->space= (align)? 0: layout->common->style->buttonspacex;
+       BLI_addtail(&layout->items, litem);
 
-       for(item=template->items.first; item; item=item->next)
-               ui_item_free(item);
-
-       BLI_freelistN(&template->items);
+       return litem;
 }
 
-/* template create functions */
-void uiLayoutRow(uiLayout *layout)
+uiLayout *uiLayoutColumn(uiLayout *layout, int align)
 {
-       uiTemplate *template;
+       uiLayout *litem;
 
-       template= MEM_callocN(sizeof(uiTemplate), "uiTemplate");
-       template->type= TEMPLATE_ROW;
+       litem= MEM_callocN(sizeof(uiLayout), "uiLayoutColumn");
+       litem->item.type= ITEM_LAYOUT_COLUMN;
+       litem->common= layout->common;
+       litem->align= align;
+       litem->space= (litem->align)? 0: layout->common->style->buttonspacey;
+       BLI_addtail(&layout->items, litem);
 
-       BLI_addtail(&layout->templates, template);
+       return litem;
 }
 
-void uiLayoutColumn(uiLayout *layout)
+uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align)
 {
-       uiTemplate *template;
+       uiLayoutItemFlow *flow;
 
-       template= MEM_callocN(sizeof(uiTemplate), "uiTemplate");
-       template->type= TEMPLATE_COLUMN;
+       flow= MEM_callocN(sizeof(uiLayoutItemFlow), "uiLayoutItemFlow");
+       flow->litem.item.type= ITEM_LAYOUT_COLUMN_FLOW;
+       flow->litem.common= layout->common;
+       flow->litem.align= align;
+       flow->litem.space= (flow->litem.align)? 0: layout->common->style->columnspace;
+       flow->number= number;
+       BLI_addtail(&layout->items, flow);
 
-       BLI_addtail(&layout->templates, template);
+       return &flow->litem;
 }
 
-void uiLayoutColumnFlow(uiLayout *layout, int number)
+uiLayout *uiLayoutBox(uiLayout *layout)
 {
-       uiTemplateFlow *flow;
+       uiLayoutItemBx *box;
 
-       flow= MEM_callocN(sizeof(uiTemplateFlow), "uiTemplateFlow");
-       flow->template.type= TEMPLATE_COLUMN_FLOW;
-       flow->number= number;
-       BLI_addtail(&layout->templates, flow);
+       box= MEM_callocN(sizeof(uiLayoutItemBx), "uiLayoutItemBx");
+       box->litem.item.type= ITEM_LAYOUT_BOX;
+       box->litem.common= layout->common;
+       box->litem.space= layout->common->style->columnspace;
+       BLI_addtail(&layout->items, box);
+
+       return &box->litem;
 }
 
-uiLayout *uiLayoutBox(uiLayout *layout)
+uiLayout *uiLayoutFree(uiLayout *layout, int align)
 {
-       uiTemplateBx *box;
+       uiLayout *litem;
 
-       box= MEM_callocN(sizeof(uiTemplateBx), "uiTemplateBx");
-       box->template.type= TEMPLATE_BOX;
-       box->sublayout= uiLayoutBegin(layout->dir, layout->type, 0, 0, 0, 0, layout->style);
-       BLI_addtail(&layout->templates, box);
+       litem= MEM_callocN(sizeof(uiLayout), "uiLayoutFree");
+       litem->item.type= ITEM_LAYOUT_FREE;
+       litem->common= layout->common;
+       litem->align= align;
+       BLI_addtail(&layout->items, litem);
 
-       return box->sublayout;
+       return litem;
 }
 
-void uiLayoutSplit(uiLayout *layout, int number, int lr)
+uiLayout *uiLayoutSplit(uiLayout *layout)
 {
-       uiTemplateSplt *split;
-       int a;
+       uiLayout *litem;
 
-       split= MEM_callocN(sizeof(uiTemplateSplt), "uiTemplateSplt");
-       split->template.type= TEMPLATE_SPLIT;
-       split->number= number;
-       split->lr= lr;
-       split->sublayout= MEM_callocN(sizeof(uiLayout*)*number, "uiTemplateSpltSub");
+       litem= uiLayoutRow(layout, 0);
+       litem->item.type = ITEM_LAYOUT_SPLIT;
+       litem->common= layout->common;
+       litem->space= layout->common->style->columnspace;
 
-       for(a=0; a<number; a++)
-               split->sublayout[a]= uiLayoutBegin(layout->dir, layout->type, 0, 0, 0, 0, layout->style);
-
-       BLI_addtail(&layout->templates, split);
+       return litem;
 }
 
-uiLayout *uiLayoutSub(uiLayout *layout, int n)
+/********************** Layout *******************/
+
+static void ui_item_estimate(uiItem *item)
 {
-       uiTemplate *template= layout->templates.last;
+       uiItem *subitem;
 
-       if(template) {
-               switch(template->type) {
-                       case TEMPLATE_SPLIT:
-                               if(n >= 0 && n < ((uiTemplateSplt*)template)->number)
-                                       return ((uiTemplateSplt*)template)->sublayout[n];
+       if(item->type != ITEM_BUTTON) {
+               uiLayout *litem= (uiLayout*)item;
+
+               for(subitem=litem->items.first; subitem; subitem=subitem->next)
+                       ui_item_estimate(subitem);
+
+               switch(litem->item.type) {
+                       case ITEM_LAYOUT_COLUMN:
+                               ui_litem_estimate_column(litem);
+                               break;
+                       case ITEM_LAYOUT_COLUMN_FLOW:
+                               ui_litem_estimate_column_flow(litem);
                                break;
-                       case TEMPLATE_BOX:
-                               return ((uiTemplateBx*)template)->sublayout;
+                       case ITEM_LAYOUT_ROW:
+                               ui_litem_estimate_row(litem);
+                               break;
+                       case ITEM_LAYOUT_BOX:
+                               ui_litem_estimate_box(litem);
+                               break;
+                       case ITEM_LAYOUT_ROOT:
+                               ui_litem_estimate_root(litem);
+                               break;
+                       case ITEM_LAYOUT_FREE:
+                               ui_litem_estimate_free(litem);
+                               break;
+                       case ITEM_LAYOUT_SPLIT:
+                               ui_litem_estimate_split(litem);
                                break;
                        default:
                                break;
                }
        }
-
-       return NULL;
 }
 
-void uiTemplateHeader(uiLayout *layout)
+static void ui_item_align(uiLayout *litem, int nr)
 {
-       uiTemplate *template;
-
-       template= MEM_callocN(sizeof(uiTemplate), "uiTemplate");
-       template->type= TEMPLATE_HEADER;
+       uiItem *item;
 
-       BLI_addtail(&layout->templates, template);
+       for(item=litem->items.first; item; item=item->next) {
+               if(item->type == ITEM_BUTTON)
+                       ((uiButtonItem*)item)->but->alignnr= nr;
+               else
+                       ui_item_align((uiLayout*)item, nr);
+       }
 }
 
-void uiTemplateHeaderID(uiLayout *layout, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop)
+static void ui_item_layout(uiItem *item, int align)
 {
-       uiTemplateHeadID *idtemplate;
-       PropertyRNA *prop;
+       uiItem *subitem;
 
-       if(!ptr->data)
-               return;
-
-       prop= RNA_struct_find_property(ptr, propname);
+       if(item->type != ITEM_BUTTON) {
+               uiLayout *litem= (uiLayout*)item;
 
-       if(!prop) {
-               printf("uiTemplateHeaderID: property not found: %s\n", propname);
-               return;
-       }
+               if(litem->align && !align)
+                       ui_item_align(litem, ++litem->common->block->alignnr);
 
-       idtemplate= MEM_callocN(sizeof(uiTemplateHeadID), "uiTemplateHeadID");
-       idtemplate->template.type= TEMPLATE_HEADER_ID;
-       idtemplate->ptr= *ptr;
-       idtemplate->prop= prop;
-       idtemplate->flag= UI_ID_BROWSE|UI_ID_RENAME;
+               switch(litem->item.type) {
+                       case ITEM_LAYOUT_COLUMN:
+                               ui_litem_layout_column(litem);
+                               break;
+                       case ITEM_LAYOUT_COLUMN_FLOW:
+                               ui_litem_layout_column_flow(litem);
+                               break;
+                       case ITEM_LAYOUT_ROW:
+                               ui_litem_layout_row(litem);
+                               break;
+                       case ITEM_LAYOUT_BOX:
+                               ui_litem_layout_box(litem);
+                               break;
+                       case ITEM_LAYOUT_ROOT:
+                               ui_litem_layout_root(litem);
+                               break;
+                       case ITEM_LAYOUT_FREE:
+                               ui_litem_layout_free(litem);
+                               break;
+                       case ITEM_LAYOUT_SPLIT:
+                               ui_litem_layout_split(litem);
+                               break;
+                       default:
+                               break;
+               }
 
-       if(newop) {
-               idtemplate->flag |= UI_ID_ADD_NEW;
-               idtemplate->newop= newop;
+               for(subitem=litem->items.first; subitem; subitem=subitem->next)
+                       ui_item_layout(subitem, litem->align || align);
        }
-       if(openop) {
-               idtemplate->flag |= UI_ID_OPEN;
-               idtemplate->openop= openop;
-       }
-       if(unlinkop) {
-               idtemplate->flag |= UI_ID_DELETE;
-               idtemplate->unlinkop= unlinkop;
-       }
-
-       BLI_addtail(&layout->templates, idtemplate);
 }
 
-void uiTemplateSlot(uiLayout *layout, int slot)
+static void ui_layout_items(const bContext *C, uiBlock *block, uiLayout *layout)
 {
-       uiTemplate *template= layout->templates.last;
-
-       if(template)
-               template->slot= slot;
+       ui_item_estimate(&layout->item);
+       ui_item_layout(&layout->item, 0);
 }
 
-/********************** Layout *******************/
-
-static void ui_layout_init_items(const bContext *C, uiLayout *layout)
+static void ui_layout_end(const bContext *C, uiBlock *block, uiLayout *layout, int *x, int *y)
 {
-       ARegion *ar= CTX_wm_region(C);
-       MenuType *mt;
-       uiTemplate *template;
-       uiItem *item;
-       uiItemMenu *menuitem;
-       uiItemRNA *rnaitem;
-       uiItemOp *opitem;
-       PropertyType type;
+       if(layout->common->handlefunc)
+               uiBlockSetButmFunc(block, layout->common->handlefunc, layout->common->argv);
 
-       for(template=layout->templates.first; template; template=template->next) {
-               for(item=template->items.first; item; item=item->next) {
-                       /* initialize buttons names */
-                       if(item->type == ITEM_MENU) {
-                               menuitem= (uiItemMenu*)item;
-
-                               if(menuitem->menuname) {
-                                       for(mt=ar->type->menutypes.first; mt; mt=mt->next) {
-                                               if(strcmp(menuitem->menuname, mt->idname) == 0) {
-                                                       menuitem->arg= mt;
-                                                       ui_item_name(item, mt->label);
-                                                       break;
-                                               }
-                                       }
-                               }
-                       }
-                       else if(item->type == ITEM_RNA_PROPERTY) {
-                               rnaitem= (uiItemRNA*)item;
-                               type= RNA_property_type(rnaitem->prop);
-
-                               ui_item_name(item, (char*)RNA_property_ui_name(rnaitem->prop));
-
-                               if(ELEM4(type, PROP_INT, PROP_FLOAT, PROP_STRING, PROP_ENUM))
-                                       ui_item_name_add_colon(item);
-                       }
-                       else if(item->type == ITEM_OPERATOR) {
-                               opitem= (uiItemOp*)item;
-                               ui_item_name(item, opitem->ot->name);
-                       }
+       ui_layout_items(C, block, layout);
 
-                       ui_item_name(item, "");
+       if(x) *x= layout->x;
+       if(y) *y= layout->y;
+}
 
-                       /* initialize icons */
-                       if(layout->type == UI_LAYOUT_MENU) {
-                               if(item->type == ITEM_RNA_PROPERTY) {
-                                       rnaitem= (uiItemRNA*)item;
-                                       type= RNA_property_type(rnaitem->prop);
+static void ui_layout_free(uiLayout *layout)
+{
+       uiItem *item, *next;
 
-                                       if(type == PROP_BOOLEAN)
-                                               item->icon= (RNA_property_boolean_get(&rnaitem->ptr, rnaitem->prop))? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT;
-                                       else if(type == PROP_ENUM && rnaitem->index == RNA_ENUM_VALUE)
-                                               item->icon= (RNA_property_enum_get(&rnaitem->ptr, rnaitem->prop) == rnaitem->value)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; 
-                               }
+       for(item=layout->items.first; item; item=next) {
+               next= item->next;
 
-                               if(!item->icon)
-                                       item->icon= ICON_BLANK1;
-                       }
-               }
+               if(item->type == ITEM_BUTTON)
+                       MEM_freeN(item);
+               else
+                       ui_layout_free((uiLayout*)item);
        }
+
+       MEM_freeN(layout);
 }
 
-static void ui_layout_templates(const bContext *C, uiBlock *block, uiLayout *layout)
+uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, uiStyle *style)
 {
-       uiStyle *style= layout->style;
-       uiTemplate *template;
+       uiLayout *layout;
+       uiLayoutCommon *common;
 
-       ui_layout_init_items(C, layout);
+       if(!block->layout) {
+               common= MEM_callocN(sizeof(uiLayoutCommon), "uiLayoutCommon");
+               common->type= type;
+               common->style= style;
+               common->block= block;
+               common->opcontext= WM_OP_INVOKE_REGION_WIN;
 
-       if(layout->dir == UI_LAYOUT_HORIZONTAL) {
-               for(template=layout->templates.first; template; template=template->next) {
-                       switch(template->type) {
-                               case TEMPLATE_HEADER:
-                                       ui_layout_header(C, layout, block, template);
-                                       break;
-                               case TEMPLATE_HEADER_ID:
-                                       ui_layout_header_id(C, layout, block, template);
-                                       break;
-                               default:
-                                       ui_layout_header_buttons(layout, block, template);
-                                       break;
-                       }
+               layout= MEM_callocN(sizeof(uiLayout), "uiLayout");
+               layout->item.type= ITEM_LAYOUT_ROOT;
 
-                       layout->x += style->templatespace;
-               }
-       }
-       else {
-               for(template=layout->templates.first; template; template=template->next) {
-                       switch(template->type) {
-                               case TEMPLATE_ROW:
-                                       ui_layout_row(layout, block, template);
-                                       break;
-                               case TEMPLATE_COLUMN_FLOW:
-                                       ui_layout_column_flow(layout, block, template);
-                                       break;
-                               case TEMPLATE_SPLIT:
-                                       ui_layout_split(C, layout, block, template);
-                                       break;
-                               case TEMPLATE_BOX:
-                                       ui_layout_box(C, layout, block, template);
-                                       break;
-                               case TEMPLATE_COLUMN:
-                               default:
-                                       ui_layout_column(layout, block, template);
-                                       break;
-                       }
+               layout->x= x;
+               layout->y= y;
+               layout->common= common;
+               layout->space= style->templatespace;
+
+               if(type == UI_LAYOUT_MENU)
+                       layout->space= 0;
 
-                       layout->y -= style->templatespace;
+               if(dir == UI_LAYOUT_HORIZONTAL) {
+                       layout->h= size;
+                       layout->common->emh= em*UI_UNIT_Y;
+               }
+               else {
+                       layout->w= size;
+                       layout->common->emw= em*UI_UNIT_X;
                }
+
+               block->curlayout= layout;
+               block->layout= layout;
        }
+       
+       return block->layout;
 }
 
-void ui_layout_end(const bContext *C, uiBlock *block, uiLayout *layout, int *x, int *y)
+uiBlock *uiLayoutBlock(uiLayout *layout)
 {
-       if(layout->handlefunc)
-               uiBlockSetButmFunc(block, layout->handlefunc, layout->argv);
-
-       ui_layout_templates(C, block, layout);
-
-       if(x) *x= layout->x;
-       if(y) *y= layout->y;
-       
+       return layout->common->block;
 }
 
-void ui_layout_free(uiLayout *layout)
+void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout)
 {
-       uiTemplate *template;
-
-       for(template=layout->templates.first; template; template=template->next)
-               ui_template_free(template);
-
-       BLI_freelistN(&layout->templates);
-       MEM_freeN(layout);
+       block->curlayout= layout;
 }
 
-uiLayout *uiLayoutBegin(int dir, int type, int x, int y, int size, int em, uiStyle *style)
+void ui_layout_add_but(uiLayout *layout, uiBut *but)
 {
-       uiLayout *layout;
-
-       layout= MEM_callocN(sizeof(uiLayout), "uiLayout");
-       layout->opcontext= WM_OP_INVOKE_REGION_WIN;
-       layout->dir= dir;
-       layout->type= type;
-       layout->x= x;
-       layout->y= y;
-       layout->style= style;
-
-       if(dir == UI_LAYOUT_HORIZONTAL) {
-               layout->h= size;
-               layout->emh= em*EM_UNIT_Y;
-       }
-       else {
-               layout->w= size;
-               layout->emw= em*EM_UNIT_X;
-       }
-
-       return layout;
+       uiButtonItem *bitem;
+       
+       bitem= MEM_callocN(sizeof(uiButtonItem), "uiButtonItem");
+       bitem->item.type= ITEM_BUTTON;
+       bitem->but= but;
+       BLI_addtail(&layout->items, bitem);
 }
 
 void uiLayoutContext(uiLayout *layout, int opcontext)
 {
-       layout->opcontext= opcontext;
+       layout->common->opcontext= opcontext;
 }
 
 void uiLayoutFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv)
 {
-       layout->handlefunc= handlefunc;
-       layout->argv= argv;
+       layout->common->handlefunc= handlefunc;
+       layout->common->argv= argv;
 }
 
-void uiLayoutEnd(const bContext *C, uiBlock *block, uiLayout *layout, int *x, int *y)
+void uiBlockLayoutResolve(const bContext *C, uiBlock *block, int *x, int *y)
 {
-       ui_layout_end(C, block, layout, x, y);
-       ui_layout_free(layout);
-}
-
-/************************ Utilities ************************/
-
-void uiRegionPanelLayout(const bContext *C, ARegion *ar, int vertical, char *context)
-{
-       uiStyle *style= U.uistyles.first;
-       uiBlock *block;
-       PanelType *pt;
-       Panel *panel;
-       float col[3];
-       int xco, yco, x=PNL_DIST, y=-PNL_HEADER-PNL_DIST, w, em;
+       uiLayout *layout= block->layout;
 
-       // XXX this only hides cruft
+       if(layout) {
+               /* NULL in advance so we don't interfere when adding button */
+               block->layout= NULL;
+               block->curlayout= NULL;
 
-       /* clear */
-       UI_GetThemeColor3fv(TH_BACK, col);
-       glClearColor(col[0], col[1], col[2], 0.0);
-       glClear(GL_COLOR_BUFFER_BIT);
-       
-       /* set view2d view matrix for scrolling (without scrollers) */
-       UI_view2d_view_ortho(C, &ar->v2d);
-       
-       uiBeginPanels(C, ar);
-
-       for(pt= ar->type->paneltypes.first; pt; pt= pt->next) {
-               if(context)
-                       if(!pt->context || strcmp(context, pt->context) != 0)
-                               continue;
-
-               if(pt->draw && (!pt->poll || pt->poll(C, pt))) {
-                       block= uiBeginBlock(C, ar, pt->idname, UI_EMBOSS);
-                       panel= uiBeginPanel(ar, block, pt);
-
-                       if(panel) {
-                               if(vertical) {
-                                       w= (ar->type->minsizex)? ar->type->minsizex-12: block->aspect*ar->winx-12;
-                                       em= (ar->type->minsizex)? 10: 20;
-                               }
-                               else {
-                                       w= (ar->type->minsizex)? ar->type->minsizex-12: UI_PANEL_WIDTH-12;
-                                       em= (ar->type->minsizex)? 10: 20;
-                               }
-
-                               panel->type= pt;
-                               panel->layout= uiLayoutBegin(UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, PNL_SAFETY, 0, w-2*PNL_SAFETY, em, style);
-
-                               pt->draw(C, panel);
-
-                               uiLayoutEnd(C, block, panel->layout, &xco, &yco);
-                               panel->layout= NULL;
-                               uiEndPanel(block, w, -yco + 12);
-                       }
-                       else {
-                               w= PNL_HEADER;
-                               yco= PNL_HEADER;
-                       }
-
-                       uiEndBlock(C, block);
-
-                       if(vertical)
-                               y += yco+PNL_DIST;
-                       else
-                               x += w+PNL_DIST;
-               }
+               ui_layout_end(C, block, layout, x, y);
+               MEM_freeN(layout->common);
+               ui_layout_free(layout);
+       }
+       else {
+               if(x) *x= 0;
+               if(y) *y= 0;
        }
 
-       uiEndPanels(C, ar);
-       
-       /* restore view matrix? */
-       UI_view2d_view_restore(C);
+       /* XXX silly trick, interface_templates.c doesn't get linked
+        * because it's not used by other files in this module? */
+       {
+               void ui_template_fix_linking();
+               ui_template_fix_linking();
+       }
 }
 
-void uiRegionHeaderLayout(const bContext *C, ARegion *ar)
+float uiBlockAspect(uiBlock *block)
 {
-       uiStyle *style= U.uistyles.first;
-       uiBlock *block;
-       uiLayout *layout;
-       HeaderType *ht;
-       Header header = {0};
-       float col[3];
-       int xco, yco;
-
-       // XXX this only hides cruft
-       
-       /* clear */
-       if(ED_screen_area_active(C))
-               UI_GetThemeColor3fv(TH_HEADER, col);
-       else
-               UI_GetThemeColor3fv(TH_HEADERDESEL, col);
-       
-       glClearColor(col[0], col[1], col[2], 0.0);
-       glClear(GL_COLOR_BUFFER_BIT);
-       
-       /* set view2d view matrix for scrolling (without scrollers) */
-       UI_view2d_view_ortho(C, &ar->v2d);
-
-       xco= 8;
-       yco= 3;
-
-       /* draw all headers types */
-       for(ht= ar->type->headertypes.first; ht; ht= ht->next) {
-               block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS);
-               layout= uiLayoutBegin(UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, 24, 1, style);
-
-               if(ht->draw) {
-                       header.type= ht;
-                       header.layout= layout;
-                       ht->draw(C, &header);
-               }
-
-               uiLayoutEnd(C, block, layout, &xco, &yco);
-               uiEndBlock(C, block);
-               uiDrawBlock(C, block);
-       }
-
-       /* always as last  */
-       UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
-
-       /* restore view matrix? */
-       UI_view2d_view_restore(C);
+       return block->aspect; /* temporary */
 }
 
index 730f22e33901f8301144c3d5f53fe42cd659afbf..36c794ab09832a51f929601e9ce5bdc857febef3 100644 (file)
@@ -157,6 +157,7 @@ static void ui_panel_copy_offset(Panel *pa, Panel *papar)
 
 Panel *uiBeginPanel(ARegion *ar, uiBlock *block, PanelType *pt)
 {
+       uiStyle *style= U.uistyles.first;
        Panel *pa, *patab, *palast, *panext;
        char *panelname= pt->label;
        char *tabname= pt->label;
@@ -181,8 +182,8 @@ Panel *uiBeginPanel(ARegion *ar, uiBlock *block, PanelType *pt)
                BLI_strncpy(pa->panelname, panelname, UI_MAX_NAME_STR);
                BLI_strncpy(pa->tabname, tabname, UI_MAX_NAME_STR);
        
-               pa->ofsx= PNL_DIST;
-               pa->ofsy= PNL_DIST;
+               pa->ofsx= style->panelouter;
+               pa->ofsy= style->panelouter;
                pa->sizex= 0;
                pa->sizey= 0;
 
@@ -377,31 +378,32 @@ static int panel_has_tabs(ARegion *ar, Panel *panel)
 
 static void ui_scale_panel_block(uiBlock *block)
 {
+       uiStyle *style= U.uistyles.first;
        uiBut *but;
        float facx= 1.0, facy= 1.0;
-       int centerx= 0, topy=0, tabsy=0;
+       int centerx= 0, topy=0, tabsy=0, space= style->panelspace;
        
        if(block->panel==NULL) return;
 
        /* buttons min/max centered, offset calculated */
        ui_bounds_block(block);
 
-       if((!block->panel->type) && block->maxx-block->minx > block->panel->sizex - 2*PNL_SAFETY)
-               facx= (block->panel->sizex - (2*PNL_SAFETY))/(block->maxx-block->minx);
+       if((!block->panel->type) && block->maxx-block->minx > block->panel->sizex - 2*space)
+               facx= (block->panel->sizex - (2*space))/(block->maxx-block->minx);
        else
-               centerx= (block->panel->sizex-(block->maxx-block->minx) - 2*PNL_SAFETY)/2;
+               centerx= (block->panel->sizex-(block->maxx-block->minx) - 2*space)/2;
        
        // tabsy= PNL_HEADER*panel_has_tabs(block->panel);
-       if((!block->panel->type) && (block->maxy-block->miny) > block->panel->sizey - 2*PNL_SAFETY - tabsy)
-               facy= (block->panel->sizey - (2*PNL_SAFETY) - tabsy)/(block->maxy-block->miny);
+       if((!block->panel->type) && (block->maxy-block->miny) > block->panel->sizey - 2*space - tabsy)
+               facy= (block->panel->sizey - (2*space) - tabsy)/(block->maxy-block->miny);
        else
-               topy= (block->panel->sizey- 2*PNL_SAFETY - tabsy) - (block->maxy-block->miny) ;
+               topy= (block->panel->sizey- 2*space - tabsy) - (block->maxy-block->miny) ;
 
        for(but= block->buttons.first; but; but=but->next) {
-               but->x1= PNL_SAFETY+centerx+ facx*(but->x1-block->minx);
-               but->y1= PNL_SAFETY+topy   + facy*(but->y1-block->miny);
-               but->x2= PNL_SAFETY+centerx+ facx*(but->x2-block->minx);
-               but->y2= PNL_SAFETY+topy   + facy*(but->y2-block->miny);
+               but->x1= space+centerx+ facx*(but->x1-block->minx);
+               but->y1= space+topy   + facy*(but->y1-block->miny);
+               but->x2= space+centerx+ facx*(but->x2-block->minx);
+               but->y2= space+topy   + facy*(but->y2-block->miny);
                if(facx!=1.0) ui_check_but(but);        /* for strlen */
        }
 
@@ -413,6 +415,7 @@ static void ui_scale_panel_block(uiBlock *block)
 // for 'home' key
 void uiPanelsHome(ARegion *ar)
 {
+       uiStyle *style= U.uistyles.first;
        Panel *pa;
        uiBlock *block;
        View2D *v2d;
@@ -432,10 +435,10 @@ void uiPanelsHome(ARegion *ar)
        }
 
        if(done) {
-               v2d->tot.xmin= minx-PNL_DIST;
-               v2d->tot.xmax= maxx+PNL_DIST;
-               v2d->tot.ymin= miny-PNL_DIST;
-               v2d->tot.ymax= maxy+PNL_DIST;
+               v2d->tot.xmin= minx-style->panelouter;
+               v2d->tot.xmax= maxx+style->panelouter;
+               v2d->tot.ymin= miny-style->panelouter;
+               v2d->tot.ymax= maxy+style->panelouter;
        }
        else {
                v2d->tot.xmin= 0;
@@ -890,6 +893,7 @@ static int compare_panel(const void *a1, const void *a2)
 /* returns 1 when it did something */
 int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag)
 {
+       uiStyle *style= U.uistyles.first;
        Panel *pa;
        PanelSort *ps, *panelsort, *psnext;
        int a, tot=0, done;
@@ -940,18 +944,18 @@ int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag)
        
        /* no smart other default start loc! this keeps switching f5/f6/etc compatible */
        ps= panelsort;
-       ps->pa->ofsx= PNL_DIST;
-       ps->pa->ofsy= -ps->pa->sizey-PNL_HEADER-PNL_DIST;
+       ps->pa->ofsx= style->panelouter;
+       ps->pa->ofsy= -ps->pa->sizey-PNL_HEADER-style->panelouter;
 
        for(a=0; a<tot-1; a++, ps++) {
                psnext= ps+1;
        
                if(align==BUT_VERTICAL) {
                        psnext->pa->ofsx= ps->pa->ofsx;
-                       psnext->pa->ofsy= get_panel_real_ofsy(ps->pa) - psnext->pa->sizey-PNL_HEADER-PNL_DIST;
+                       psnext->pa->ofsy= get_panel_real_ofsy(ps->pa) - psnext->pa->sizey-PNL_HEADER-style->panelouter;
                }
                else {
-                       psnext->pa->ofsx= get_panel_real_ofsx(ps->pa)+PNL_DIST;
+                       psnext->pa->ofsx= get_panel_real_ofsx(ps->pa)+style->panelouter;
                        psnext->pa->ofsy= ps->pa->ofsy + ps->pa->sizey - psnext->pa->sizey;
                }
        }
index 59725cc495429b0a7b5da808d8ad69d91eeb6176..57644e5decc42df4132f3d7ba0e3e4f48e9b8303 100644 (file)
@@ -624,6 +624,7 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
        
        /* create area region */
        ar= ui_add_temporary_region(CTX_wm_screen(C));
+       handle->region= ar;
 
        memset(&type, 0, sizeof(ARegionType));
        type.draw= ui_block_region_draw;
@@ -631,15 +632,21 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
 
        UI_add_region_handlers(&ar->handlers);
 
-       handle->region= ar;
-       ar->regiondata= handle;
-
        /* create ui block */
        if(create_func)
                block= create_func(C, handle->region, arg);
        else
                block= handle_create_func(C, handle, arg);
-       block->handle= handle;
+       
+       if(block->handle) {
+               memcpy(block->handle, handle, sizeof(uiPopupBlockHandle));
+               MEM_freeN(handle);
+               handle= block->handle;
+       }
+       else
+               block->handle= handle;
+
+       ar->regiondata= handle;
 
        if(!block->endblock)
                uiEndBlock(C, block);
@@ -1625,28 +1632,9 @@ uiBlock *ui_block_func_PUPMENUCOL(bContext *C, uiPopupBlockHandle *handle, void
 /* prototype */
 static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, void *arg_info);
 
-#define MAX_MENU_STR   64
-
-/* type, internal */
-#define MENU_ITEM_TITLE                                0
-#define MENU_ITEM_ITEM                         1
-#define MENU_ITEM_SEPARATOR                    2
-#define MENU_ITEM_OPNAME                       10
-#define MENU_ITEM_OPNAME_BOOL          11
-#define MENU_ITEM_OPNAME_ENUM          12
-#define MENU_ITEM_OPNAME_INT           13
-#define MENU_ITEM_OPNAME_FLOAT         14
-#define MENU_ITEM_OPNAME_STRING                15
-#define MENU_ITEM_RNA_BOOL                     20
-#define MENU_ITEM_RNA_ENUM                     21
-#define MENU_ITEM_LEVEL                                30
-#define MENU_ITEM_LEVEL_OPNAME_ENUM    31
-#define MENU_ITEM_LEVEL_RNA_ENUM       32
-
 struct uiPopupMenu {
+       uiBlock *block;
        uiLayout *layout;
-       int icon;
-       char name[MAX_MENU_STR];
 };
 
 typedef struct uiMenuInfo {
@@ -1694,46 +1682,26 @@ typedef struct MenuItemLevel {
 static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, void *arg_info)
 {
        uiBlock *block;
-       uiBut *but;
        uiMenuInfo *info= arg_info;
        uiPopupMenu *pup;
        ScrArea *sa;
        ARegion *ar;
-       static int counter= 0;
-       char str[16];
        
        pup= info->pup;
+       block= pup->block;
        
        /* block stuff first, need to know the font */
-       sprintf(str, "tb %d", counter++);
-       block= uiBeginBlock(C, handle->region, str, UI_EMBOSSP);
+       uiBlockSetRegion(block, handle->region);
        block->direction= UI_DOWN;
 
-       /* here we go! */
-       if(pup->name[0]) {
-               char titlestr[256];
-               
-               if(pup->icon) {
-                       sprintf(titlestr, " %s", pup->name);
-                       uiDefIconTextBut(block, LABEL, 0, pup->icon, titlestr, 0, 0, 200, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
-               }
-               else {
-                       but= uiDefBut(block, LABEL, 0, pup->name, 0, 0, 200, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
-                       but->flag= UI_TEXT_LEFT;
-               }
-               
-               //uiDefBut(block, SEPR, 0, "", startx, (short)(starty+height)-MENU_SEPR_HEIGHT, width, MENU_SEPR_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
-       }
-       
-       block->handle= handle;
-       uiLayoutEnd(C, block, pup->layout, NULL, NULL);
+       uiBlockLayoutResolve(C, block, NULL, NULL);
 
        if(info->popup) {
                uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT|UI_BLOCK_RET_1);
                uiBlockSetDirection(block, UI_DOWN);
 
                /* here we set an offset for the mouse position */
-               uiMenuPopupBoundsBlock(block, 1, 0, MENU_BUTTON_HEIGHT/2);
+               uiMenuPopupBoundsBlock(block, 1, 0, 1.5*MENU_BUTTON_HEIGHT);
        }
        else {
                /* for a header menu we set the direction automatic */
@@ -1769,9 +1737,12 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut
        uiMenuInfo info;
        
        pup= MEM_callocN(sizeof(uiPopupMenu), "menu dummy");
-       pup->layout= uiLayoutBegin(UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
+       pup->block= uiBeginBlock(C, NULL, "ui_popup_menu_create", UI_EMBOSSP);
+       pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
        uiLayoutContext(pup->layout, WM_OP_INVOKE_REGION_WIN);
-       uiLayoutColumn(pup->layout);
+
+       /* create in advance so we can let buttons point to retval already */
+       pup->block->handle= MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle");
 
        menu_func(C, pup->layout, arg);
        
@@ -1792,20 +1763,35 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut
 /*************************** Popup Menu API **************************/
 
 /* only return handler, and set optional title */
-uiPopupMenu *uiPupMenuBegin(const char *title, int icon)
+uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
 {
        uiStyle *style= U.uistyles.first;
        uiPopupMenu *pup= MEM_callocN(sizeof(uiPopupMenu), "menu start");
+       uiBut *but;
        
-       pup->icon= icon;
-       pup->layout= uiLayoutBegin(UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
+       pup->block= uiBeginBlock(C, NULL, "uiPupMenuBegin", UI_EMBOSSP);
+       pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
        uiLayoutContext(pup->layout, WM_OP_EXEC_REGION_WIN);
-       uiLayoutColumn(pup->layout);
-       
-       /* NULL is no title */
-       if(title)
-               BLI_strncpy(pup->name, title, MAX_MENU_STR);
+
+       /* create in advance so we can let buttons point to retval already */
+       pup->block->handle= MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle");
        
+       /* create title button */
+       if(title && title[0]) {
+               char titlestr[256];
+               
+               if(icon) {
+                       sprintf(titlestr, " %s", title);
+                       uiDefIconTextBut(pup->block, LABEL, 0, icon, titlestr, 0, 0, 200, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
+               }
+               else {
+                       but= uiDefBut(pup->block, LABEL, 0, (char*)title, 0, 0, 200, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
+                       but->flag= UI_TEXT_LEFT;
+               }
+               
+               //uiDefBut(block, SEPR, 0, "", startx, (short)(starty+height)-MENU_SEPR_HEIGHT, width, MENU_SEPR_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
+       }
+
        return pup;
 }
 
@@ -2002,7 +1988,7 @@ void uiPupBlockO(bContext *C, uiBlockCreateFunc func, void *arg, char *opname, i
        
        handle= ui_popup_block_create(C, NULL, NULL, func, NULL, arg);
        handle->popup= 1;
-       handle->opname= opname;
+       handle->optype= (opname)? WM_operatortype_find(opname): NULL;
        handle->opcontext= opcontext;
        
        UI_add_popup_handlers(C, &window->handlers, handle);
index d0361174e70a354a0fe1850dd1083986d0db5b8b..f789f81e0d3504aa30e9b149551120e9d266a003 100644 (file)
@@ -121,6 +121,8 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name)
        style->boxspace= 5;
        style->buttonspacex= 5;
        style->buttonspacey= 2;
+       style->panelspace= 8;
+       style->panelouter= 4;
        
        return style;
 }
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
new file mode 100644 (file)
index 0000000..5244c99
--- /dev/null
@@ -0,0 +1,248 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * Contributor(s): Blender Foundation 2009.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_string.h"
+
+#include "BKE_context.h"
+#include "BKE_library.h"
+#include "BKE_utildefines.h"
+
+#include "ED_screen.h"
+
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+static uiBlock *block_free_layout(uiLayout *layout)
+{
+       uiBlock *block;
+
+       block= uiLayoutBlock(layout);
+       uiBlockSetCurLayout(block, uiLayoutFree(layout, 0));
+
+       return block;
+}
+
+void ui_template_fix_linking()
+{
+}
+
+/********************** Header Template *************************/
+
+void uiTemplateHeader(uiLayout *layout, bContext *C)
+{
+       uiBlock *block;
+       
+       block= block_free_layout(layout);
+       ED_area_header_standardbuttons(C, block, 0);
+}
+
+/******************* Header ID Template ************************/
+
+typedef struct TemplateHeaderID {
+       PointerRNA ptr;
+       PropertyRNA *prop;
+
+       int flag;
+       short browse;
+
+       char newop[256];
+       char openop[256];
+       char unlinkop[256];
+} TemplateHeaderID;
+
+static void template_header_id_cb(bContext *C, void *arg_litem, void *arg_event)
+{
+       TemplateHeaderID *template= (TemplateHeaderID*)arg_litem;
+       PointerRNA idptr= RNA_property_pointer_get(&template->ptr, template->prop);
+       ID *idtest, *id= idptr.data;
+       ListBase *lb= wich_libbase(CTX_data_main(C), ID_TXT);
+       int nr, event= GET_INT_FROM_POINTER(arg_event);
+       
+       if(event == UI_ID_BROWSE && template->browse == 32767)
+               event= UI_ID_ADD_NEW;
+       else if(event == UI_ID_BROWSE && template->browse == 32766)
+               event= UI_ID_OPEN;
+
+       switch(event) {
+               case UI_ID_BROWSE: {
+                       if(template->browse== -2) {
+                               /* XXX implement or find a replacement
+                                * activate_databrowse((ID *)G.buts->lockpoin, GS(id->name), 0, B_MESHBROWSE, &template->browse, do_global_buttons); */
+                               return;
+                       }
+                       if(template->browse < 0)
+                               return;
+
+                       for(idtest=lb->first, nr=1; idtest; idtest=idtest->next, nr++) {
+                               if(nr==template->browse) {
+                                       if(id == idtest)
+                                               return;
+
+                                       id= idtest;
+                                       RNA_id_pointer_create(id, &idptr);
+                                       RNA_property_pointer_set(&template->ptr, template->prop, idptr);
+                                       RNA_property_update(C, &template->ptr, template->prop);
+                                       /* XXX */
+
+                                       break;
+                               }
+                       }
+                       break;
+               }
+#if 0
+               case UI_ID_DELETE:
+                       id= NULL;
+                       break;
+               case UI_ID_FAKE_USER:
+                       if(id) {
+                               if(id->flag & LIB_FAKEUSER) id->us++;
+                               else id->us--;
+                       }
+                       else return;
+                       break;
+#endif
+               case UI_ID_PIN:
+                       break;
+               case UI_ID_ADD_NEW:
+                       WM_operator_name_call(C, template->newop, WM_OP_INVOKE_REGION_WIN, NULL);
+                       break;
+               case UI_ID_OPEN:
+                       WM_operator_name_call(C, template->openop, WM_OP_INVOKE_REGION_WIN, NULL);
+                       break;
+#if 0
+               case UI_ID_ALONE:
+                       if(!id || id->us < 1)
+                               return;
+                       break;
+               case UI_ID_LOCAL:
+                       if(!id || id->us < 1)
+                               return;
+                       break;
+               case UI_ID_AUTO_NAME:
+                       break;
+#endif
+       }
+}
+
+static void template_header_ID(bContext *C, uiBlock *block, TemplateHeaderID *template)
+{
+       uiBut *but;
+       TemplateHeaderID *duptemplate;
+       PointerRNA idptr;
+       ListBase *lb;
+       int x= 0, y= 0;
+
+       idptr= RNA_property_pointer_get(&template->ptr, template->prop);
+       lb= wich_libbase(CTX_data_main(C), ID_TXT);
+
+       uiBlockBeginAlign(block);
+       if(template->flag & UI_ID_BROWSE) {
+               char *extrastr, *str;
+               
+               if((template->flag & UI_ID_ADD_NEW) && (template->flag && UI_ID_OPEN))
+                       extrastr= "OPEN NEW %x 32766 |ADD NEW %x 32767";
+               else if(template->flag & UI_ID_ADD_NEW)
+                       extrastr= "ADD NEW %x 32767";
+               else if(template->flag & UI_ID_OPEN)
+                       extrastr= "OPEN NEW %x 32766";
+               else
+                       extrastr= NULL;
+
+               duptemplate= MEM_dupallocN(template);
+               IDnames_to_pupstring(&str, NULL, extrastr, lb, idptr.data, &duptemplate->browse);
+
+               but= uiDefButS(block, MENU, 0, str, x, y, UI_UNIT_X, UI_UNIT_Y, &duptemplate->browse, 0, 0, 0, 0, "Browse existing choices, or add new");
+               uiButSetNFunc(but, template_header_id_cb, duptemplate, SET_INT_IN_POINTER(UI_ID_BROWSE));
+               x+= UI_UNIT_X;
+       
+               MEM_freeN(str);
+       }
+
+       /* text button with name */
+       if(idptr.data) {
+               char name[64];
+
+               text_idbutton(idptr.data, name);
+               but= uiDefButR(block, TEX, 0, name, x, y, UI_UNIT_X*6, UI_UNIT_Y, &idptr, "name", -1, 0, 0, -1, -1, NULL);
+               uiButSetNFunc(but, template_header_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_RENAME));
+               x += UI_UNIT_X*6;
+
+               /* delete button */
+               if(template->flag & UI_ID_DELETE) {
+                       but= uiDefIconButO(block, BUT, template->unlinkop, WM_OP_EXEC_REGION_WIN, ICON_X, x, y, UI_UNIT_X, UI_UNIT_Y, NULL);
+                       x += UI_UNIT_X;
+               }
+       }
+       uiBlockEndAlign(block);
+}
+
+void uiTemplateHeaderID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop)
+{
+       TemplateHeaderID *template;
+       uiBlock *block;
+       PropertyRNA *prop;
+
+       if(!ptr->data)
+               return;
+
+       prop= RNA_struct_find_property(ptr, propname);
+
+       if(!prop) {
+               printf("uiTemplateHeaderID: property not found: %s\n", propname);
+               return;
+       }
+
+       template= MEM_callocN(sizeof(TemplateHeaderID), "TemplateHeaderID");
+       template->ptr= *ptr;
+       template->prop= prop;
+       template->flag= UI_ID_BROWSE|UI_ID_RENAME;
+
+       if(newop) {
+               template->flag |= UI_ID_ADD_NEW;
+               BLI_strncpy(template->newop, newop, sizeof(template->newop));
+       }
+       if(openop) {
+               template->flag |= UI_ID_OPEN;
+               BLI_strncpy(template->openop, openop, sizeof(template->openop));
+       }
+       if(unlinkop) {
+               template->flag |= UI_ID_DELETE;
+               BLI_strncpy(template->unlinkop, unlinkop, sizeof(template->unlinkop));
+       }
+
+       block= block_free_layout(layout);
+       template_header_ID(C, block, template);
+
+       MEM_freeN(template);
+}
+
index dc346be7af20675210e2388d446ea3a30adbb6a0..e3f986efde9a1b3ad7c92cc62706d9c062460244 100644 (file)
@@ -320,13 +320,12 @@ int uiDefAutoButsRNA(const bContext *C, uiBlock *block, PointerRNA *ptr)
        uiStyle *style= U.uistyles.first;
        CollectionPropertyIterator iter;
        PropertyRNA *iterprop, *prop;
-       uiLayout *layout;
+       uiLayout *layout, *split;
        char *name;
        int x= 0, y= 0;
 
-       layout= uiLayoutBegin(UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y, DEF_BUT_WIDTH*2, 20, style);
+       layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y, DEF_BUT_WIDTH*2, 20, style);
 
-       uiLayoutColumn(layout);
        uiItemL(layout, (char*)RNA_struct_ui_name(ptr->type), 0);
 
        iterprop= RNA_struct_iterator_property(ptr->type);
@@ -338,17 +337,16 @@ int uiDefAutoButsRNA(const bContext *C, uiBlock *block, PointerRNA *ptr)
                if(strcmp(RNA_property_identifier(prop), "rna_type") == 0)
                        continue;
 
-               uiLayoutSplit(layout, 2, 0);
+               split = uiLayoutSplit(layout);
 
                name= (char*)RNA_property_ui_name(prop);
-               uiLayoutColumn(uiLayoutSub(layout, 0));
-               uiItemL(uiLayoutSub(layout, 0), name, 0);
-               uiLayoutColumn(uiLayoutSub(layout, 1));
-               uiItemFullR(uiLayoutSub(layout, 1), "", 0, ptr, prop, -1, 0, 0);
+
+               uiItemL(uiLayoutColumn(split, 0), name, 0);
+               uiItemFullR(uiLayoutColumn(split, 0), "", 0, ptr, prop, -1, 0, 0);
        }
 
        RNA_property_collection_end(&iter);
-       uiLayoutEnd(C, block, layout, &x, &y);
+       uiBlockLayoutResolve(C, block, &x, &y);
 
        return -y;
 }
@@ -363,9 +361,8 @@ int uiDefAutoButsRNA_single(const bContext *C, uiBlock *block, PointerRNA *ptr)
        char *name;
        int x= 0, y= 0;
        
-       layout= uiLayoutBegin(UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y, block->panel->sizex, 20, style);
+       layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y, block->panel->sizex, 20, style);
        
-       uiLayoutColumn(layout);
        uiItemL(layout, (char*)RNA_struct_ui_name(ptr->type), 0);
        
        iterprop= RNA_struct_iterator_property(ptr->type);
@@ -377,17 +374,13 @@ int uiDefAutoButsRNA_single(const bContext *C, uiBlock *block, PointerRNA *ptr)
                if(strcmp(RNA_property_identifier(prop), "rna_type") == 0)
                        continue;
                
-               uiLayoutSplit(layout, 1, 0);
-               uiLayoutColumn(uiLayoutSub(layout, 0));
-               
                name= (char*)RNA_property_ui_name(prop);
-               uiItemL(uiLayoutSub(layout, 0), name, 0);
-
-               uiItemFullR(uiLayoutSub(layout, 0), "", 0, ptr, prop, -1, 0, 0);
+               uiItemL(layout, name, 0);
+               uiItemFullR(layout, "", 0, ptr, prop, -1, 0, 0);
        }
        
        RNA_property_collection_end(&iter);
-       uiLayoutEnd(C, block, layout, &x, &y);
+       uiBlockLayoutResolve(C, block, &x, &y);
        
        return -y;
 }
index b6e679468e019841f577b08c8310aa75c0817504..3035ff6d3a60a931b3db44804ebed7866bcf7f80 100644 (file)
@@ -6588,7 +6588,7 @@ static int subdivs_invoke(bContext *C, wmOperator *op, wmEvent *event)
        uiPopupMenu *pup;
        uiLayout *layout;
 
-       pup= uiPupMenuBegin("Subdivision Type", 0);
+       pup= uiPupMenuBegin(C, "Subdivision Type", 0);
        layout= uiPupMenuLayout(pup);
        uiItemsEnumO(layout, "MESH_OT_subdivs", "type");
        uiPupMenuEnd(C, pup);
index 68a2cf04692788cb700e90b25a3e025a1e34edb6..cf61c16fbe4944ee90aa5b868107b12cd35f551f 100644 (file)
@@ -463,7 +463,7 @@ static int object_add_curve_invoke(bContext *C, wmOperator *op, wmEvent *event)
        uiPopupMenu *pup;
        uiLayout *layout;
 
-       pup= uiPupMenuBegin(op->type->name, 0);
+       pup= uiPupMenuBegin(C, op->type->name, 0);
        layout= uiPupMenuLayout(pup);
        if(!obedit || obedit->type == OB_CURVE)
                uiItemsEnumO(layout, op->type->idname, "type");
@@ -632,7 +632,7 @@ void OBJECT_OT_armature_add(wmOperatorType *ot)
 
 static int object_primitive_add_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       uiPopupMenu *pup= uiPupMenuBegin("Add Object", 0);
+       uiPopupMenu *pup= uiPupMenuBegin(C, "Add Object", 0);
        uiLayout *layout= uiPupMenuLayout(pup);
        
        uiItemMenuEnumO(layout, NULL, ICON_OUTLINER_OB_MESH, "OBJECT_OT_mesh_add", "type");
@@ -2623,7 +2623,7 @@ static int parent_set_exec(bContext *C, wmOperator *op)
 static int parent_set_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        Object *ob= CTX_data_active_object(C);
-       uiPopupMenu *pup= uiPupMenuBegin("Set Parent To", 0);
+       uiPopupMenu *pup= uiPupMenuBegin(C, "Set Parent To", 0);
        uiLayout *layout= uiPupMenuLayout(pup);
        
        uiLayoutContext(layout, WM_OP_EXEC_DEFAULT);
index 0d58a0bfdcd35dae54cda57ef6c990b3d5273763..1c2b3c6b309dab35e021df5bf8d72b8056ff3805 100644 (file)
@@ -3842,7 +3842,7 @@ static int specials_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
        uiPopupMenu *pup;
        uiLayout *layout;
 
-       pup= uiPupMenuBegin("Specials", 0);
+       pup= uiPupMenuBegin(C, "Specials", 0);
        layout= uiPupMenuLayout(pup);
 
        uiItemO(layout, NULL, 0, "PARTICLE_OT_rekey");
index 6b7b7a914f4095394c957bc3b484382cab800074..e344a1775171e211baca78ee9ce8aa0174243eba 100644 (file)
@@ -31,6 +31,9 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "DNA_screen_types.h"
+#include "DNA_userdef_types.h"
+
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
 #include "BLI_rand.h"
@@ -955,3 +958,128 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco)
        return xco;
 }
 
+/************************ standard UI regions ************************/
+
+void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *context)
+{
+       uiStyle *style= U.uistyles.first;
+       uiBlock *block;
+       PanelType *pt;
+       Panel *panel;
+       float col[3];
+       int xco, yco, x, y, w, em, header;
+
+       header= 20; // XXX
+       x= style->panelouter;
+       y= -(header + style->panelouter);
+
+       /* clear */
+       UI_GetThemeColor3fv(TH_BACK, col);
+       glClearColor(col[0], col[1], col[2], 0.0);
+       glClear(GL_COLOR_BUFFER_BIT);
+       
+       /* set view2d view matrix for scrolling (without scrollers) */
+       UI_view2d_view_ortho(C, &ar->v2d);
+       
+       /* create panels */
+       uiBeginPanels(C, ar);
+
+       for(pt= ar->type->paneltypes.first; pt; pt= pt->next) {
+               /* verify context */
+               if(context)
+                       if(!pt->context || strcmp(context, pt->context) != 0)
+                               continue;
+
+               /* draw panel */
+               if(pt->draw && (!pt->poll || pt->poll(C, pt))) {
+                       block= uiBeginBlock(C, ar, pt->idname, UI_EMBOSS);
+                       panel= uiBeginPanel(ar, block, pt);
+
+                       if(panel) {
+                               if(vertical) {
+                                       w= (ar->type->minsizex)? ar->type->minsizex-12: uiBlockAspect(block)*ar->winx-12;
+                                       em= (ar->type->minsizex)? 10: 20;
+                               }
+                               else {
+                                       w= (ar->type->minsizex)? ar->type->minsizex-12: UI_PANEL_WIDTH-12;
+                                       em= (ar->type->minsizex)? 10: 20;
+                               }
+
+                               panel->type= pt;
+                               panel->layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
+                                       style->panelspace, 0, w-2*style->panelspace, em, style);
+
+                               pt->draw(C, panel);
+
+                               uiBlockLayoutResolve(C, block, &xco, &yco);
+                               uiEndPanel(block, w, -yco + 12);
+                               panel->layout= NULL;
+                       }
+                       else {
+                               w= header;
+                               yco= header;
+                       }
+
+                       uiEndBlock(C, block);
+
+                       if(vertical)
+                               y += yco+style->panelouter;
+                       else
+                               x += w+style->panelouter;
+               }
+       }
+
+       uiEndPanels(C, ar);
+       
+       /* restore view matrix? */
+       UI_view2d_view_restore(C);
+}
+
+void ED_region_header(const bContext *C, ARegion *ar)
+{
+       uiStyle *style= U.uistyles.first;
+       uiBlock *block;
+       uiLayout *layout;
+       HeaderType *ht;
+       Header header = {0};
+       float col[3];
+       int xco, yco;
+
+       /* clear */
+       if(ED_screen_area_active(C))
+               UI_GetThemeColor3fv(TH_HEADER, col);
+       else
+               UI_GetThemeColor3fv(TH_HEADERDESEL, col);
+       
+       glClearColor(col[0], col[1], col[2], 0.0);
+       glClear(GL_COLOR_BUFFER_BIT);
+       
+       /* set view2d view matrix for scrolling (without scrollers) */
+       UI_view2d_view_ortho(C, &ar->v2d);
+
+       xco= 8;
+       yco= HEADERY-3;
+
+       /* draw all headers types */
+       for(ht= ar->type->headertypes.first; ht; ht= ht->next) {
+               block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS);
+               layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, HEADERY-6, 1, style);
+
+               if(ht->draw) {
+                       header.type= ht;
+                       header.layout= layout;
+                       ht->draw(C, &header);
+               }
+
+               uiBlockLayoutResolve(C, block, &xco, &yco);
+               uiEndBlock(C, block);
+               uiDrawBlock(C, block);
+       }
+
+       /* always as last  */
+       UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
+
+       /* restore view matrix? */
+       UI_view2d_view_restore(C);
+}
+
index 74e0bc3852eb4b8854c81829daaaa6cd3f82ba1f..e0849bae51f08aa6b0d98a5cb0c080bd0488a051 100644 (file)
@@ -419,7 +419,7 @@ static int get_cached_work_texture(int *w_r, int *h_r)
        return texid;
 }
 
-void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, void *rect)
+void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, void *rect, float scaleX, float scaleY)
 {
        unsigned char *uc_rect= (unsigned char*) rect;
        float *f_rect= (float *)rect;
@@ -460,13 +460,13 @@ void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, void *
                        glVertex2f(rast_x, rast_y);
 
                        glTexCoord2f((float) (subpart_w-1)/tex_w, 0);
-                       glVertex2f(rast_x+subpart_w*xzoom, rast_y);
+                       glVertex2f(rast_x+subpart_w*xzoom*scaleX, rast_y);
 
                        glTexCoord2f((float) (subpart_w-1)/tex_w, (float) (subpart_h-1)/tex_h);
-                       glVertex2f(rast_x+subpart_w*xzoom, rast_y+subpart_h*yzoom);
+                       glVertex2f(rast_x+subpart_w*xzoom*scaleX, rast_y+subpart_h*yzoom*scaleY);
 
                        glTexCoord2f(0, (float) (subpart_h-1)/tex_h);
-                       glVertex2f(rast_x, rast_y+subpart_h*yzoom);
+                       glVertex2f(rast_x, rast_y+subpart_h*yzoom*scaleY);
                        glEnd();
                        glDisable(GL_TEXTURE_2D);
                }
@@ -477,6 +477,11 @@ void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, void *
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 }
 
+void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, void *rect)
+{
+       glaDrawPixelsTexScaled(x, y, img_w, img_h, format, rect, 1.0f, 1.0f);
+}
+
 void glaDrawPixelsSafe_to32(float fx, float fy, int img_w, int img_h, int row_w, float *rectf)
 {
        float *rf;
index e441a93fe2397e2d810b6ae9d46e3f8de62da472..10139f9851f0e2c8c54e26cf04594b01776d6c08 100644 (file)
@@ -1581,7 +1581,7 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *event)
        if(items==0)
                return OPERATOR_CANCELLED;
        
-       pup= uiPupMenuBegin(op->type->name, 0);
+       pup= uiPupMenuBegin(C, op->type->name, 0);
        layout= uiPupMenuLayout(pup);
 
        for (i=items-1, lastop= wm->operators.last; lastop; lastop= lastop->prev, i--)
@@ -1827,7 +1827,7 @@ static void newlevel1(bContext *C, uiLayout *layout, void *arg)
 
 static int testing123(bContext *C, wmOperator *op, wmEvent *event)
 {
-       uiPopupMenu *pup= uiPupMenuBegin("Hello world", 0);
+       uiPopupMenu *pup= uiPupMenuBegin(C, "Hello world", 0);
        uiLayout *layout= uiPupMenuLayout(pup);
        
        uiLayoutContext(layout, WM_OP_EXEC_DEFAULT);
index 2013c3d72a999bb4c481c808c40d429c6f9df9ae..893ef139bad5e22df8785be78e23d8be18130150 100644 (file)
@@ -170,21 +170,21 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar)
        int vertical= (sbuts->align == BUT_VERTICAL);
 
        if(sbuts->mainb == BCONTEXT_SCENE)
-               uiRegionPanelLayout(C, ar, vertical, "scene");
+               ED_region_panels(C, ar, vertical, "scene");
        else if(sbuts->mainb == BCONTEXT_WORLD)
-               uiRegionPanelLayout(C, ar, vertical, "world");
+               ED_region_panels(C, ar, vertical, "world");
        else if(sbuts->mainb == BCONTEXT_OBJECT)
-               uiRegionPanelLayout(C, ar, vertical, "object");
+               ED_region_panels(C, ar, vertical, "object");
        else if(sbuts->mainb == BCONTEXT_DATA)
-               uiRegionPanelLayout(C, ar, vertical, "data");
+               ED_region_panels(C, ar, vertical, "data");
        else if(sbuts->mainb == BCONTEXT_MATERIAL)
-               uiRegionPanelLayout(C, ar, vertical, "material");
+               ED_region_panels(C, ar, vertical, "material");
        else if(sbuts->mainb == BCONTEXT_TEXTURE)
-               uiRegionPanelLayout(C, ar, vertical, "texture");
+               ED_region_panels(C, ar, vertical, "texture");
        else if(sbuts->mainb == BCONTEXT_PARTICLE)
-               uiRegionPanelLayout(C, ar, vertical, "particle");
+               ED_region_panels(C, ar, vertical, "particle");
        else if(sbuts->mainb == BCONTEXT_PHYSICS)
-               uiRegionPanelLayout(C, ar, vertical, "physics");
+               ED_region_panels(C, ar, vertical, "physics");
 
     sbuts->re_align= 0;
        sbuts->mainbo= sbuts->mainb;
index c8f2af9c2e8f83d930226f1877083e73d6d0363d..8f48217473c45b7b44e4c00395bed54060f848e8 100644 (file)
@@ -48,6 +48,7 @@ CPPFLAGS += -I../../makesrna
 CPPFLAGS += -I../../imbuf
 CPPFLAGS += -I../../render/extern/include
 CPPFLAGS += -I../../python
+CPPFLAGS += -I../../blenfont
 CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
 
 # own include 
index 699b988f50fd4a61e745364aeaacf553394eeb98..36e042bdaa6adaabe097fe5583b23cd0222ac91e 100644 (file)
@@ -4,8 +4,8 @@ Import ('env')
 sources = env.Glob('*.c')
 
 incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
-incs += ' ../../blenloader ../../makesrna'
-incs += ' ../../render/extern/include '
+incs += ' ../../blenloader ../../makesrna ../../blenfont'
+incs += ' ../../render/extern/include'
 incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
 
 defs = []
index dafb254f4bc28f9b25226488c947f79e8f205605..55b2910f769d9194485d64a569c68a8ef83509fa 100644 (file)
 #include "BKE_global.h"
 #include "BKE_utildefines.h"
 
+#include "BLF_api.h"
+
 #include "DNA_space_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_userdef_types.h"
 #include "DNA_windowmanager_types.h"
 
+#include "ED_datafiles.h"
+
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
  
@@ -88,8 +92,6 @@ enum {
        B_FS_PARENT,
 } eFile_ButEvents;
 
-/* XXX very bad, need to check font code */
-static int gFontsize=12;
 
 static void do_file_buttons(bContext *C, void *arg, int event)
 {
@@ -152,19 +154,6 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
                uiDefBut(block, BUT, B_FS_CANCEL, "Cancel",             xmax-loadbutton, filebuty1, loadbutton, 21, params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0, "");
        }
 
-#if 0
-       /* menu[0] = NULL happens when no .Bfs is there, and first time browse
-          disallow external directory browsing for databrowse */
-
-       if(menu[0] && (params->type != FILE_MAIN))      { 
-               uiDefButS(block, MENU, 0 /* B_FS_DIR_MENU */, menu, xmin, filebuty2, fsmenubut_width, 21, &params->menu, 0, 0, 0, 0, "");
-               uiDefBut(block, BUT, 0 /* B_FS_BOOKMARK */, "B", xmin, filebuty1, bookmarkbut_width, 21, 0, 0, 0, 0, 0, "Bookmark current directory");
-       }
-
-       MEM_freeN(menu);
-#endif
-
-
        uiEndBlock(C, block);
        uiDrawBlock(C, block);
 }
@@ -180,8 +169,6 @@ static void draw_tile(short sx, short sy, short width, short height, int colorid
        
        UI_ThemeColorShade(colorid, shade);
        uiSetRoundBox(15);      
-       // glRecti(sx, sy - height, sx + width, sy);
-
        uiRoundBox(sx, sy - height, sx + width, sy, 6);
 }
 
@@ -195,14 +182,14 @@ static float shorten_string(char* string, float w, int flag)
        float sw = 0;
        float pad = 0;
 
-       sw = UI_GetStringWidth(string);
+       sw = file_string_width(string);
        if (flag == FILE_SHORTEN_FRONT) {
                char *s = string;
                BLI_strncpy(temp, "...", 4);
-               pad = UI_GetStringWidth(temp);
+               pad = file_string_width(temp);
                while (s && (sw+pad>w)) {
                        s++;
-                       sw = UI_GetStringWidth(s);
+                       sw = file_string_width(s);
                        shortened = 1;
                }
                if (shortened) {
@@ -216,7 +203,7 @@ static float shorten_string(char* string, float w, int flag)
                while (sw>w) {
                        int slen = strlen(string);
                        string[slen-1] = '\0';
-                       sw = UI_GetStringWidth(s);
+                       sw = file_string_width(s);
                        shortened = 1;
                }
                if (shortened) {
@@ -267,7 +254,8 @@ static void file_draw_icon(short sx, short sy, int icon, short width, short heig
        UI_icon_draw_aspect_blended(x, y, icon, 1.f, blend);
 }
 
-static void file_draw_string(short sx, short sy, const char* string, short width, short height, int flag)
+
+static void file_draw_string(short sx, short sy, const char* string, float width, short height, int flag)
 {
        short soffs;
        char fname[FILE_MAXFILE];
@@ -281,12 +269,8 @@ static void file_draw_string(short sx, short sy, const char* string, short width
        x = (float)(sx);
        y = (float)(sy-height);
 
-       /* XXX TODO: handling of international fonts.
-           TODO: proper support for utf8 in languages different from ja_JP abd zh_CH
-           needs update of iconv in lib/windows to support getting the system language string
-       */
-       UI_DrawString(x, y, fname);
-
+       BLF_position(x, y, 0);
+       BLF_draw(fname);
 }
 
 void file_calc_previews(const bContext *C, ARegion *ar)
@@ -329,7 +313,7 @@ void file_draw_previews(const bContext *C, ARegion *ar)
                ED_fileselect_layout_tilepos(layout, i, &sx, &sy);
                sx += v2d->tot.xmin+2;
                sy = v2d->tot.ymax - sy;
-               file = filelist_file(files, i);                         
+               file = filelist_file(files, i); 
 
                if (file->flags & ACTIVE) {
                        colorid = TH_HILITE;
@@ -351,29 +335,54 @@ void file_draw_previews(const bContext *C, ARegion *ar)
                }
 
                if (imb) {
-                       float fx = ((float)layout->prv_w - (float)imb->x)/2.0f;
-                       float fy = ((float)layout->prv_h - (float)imb->y)/2.0f;
-                       float dx = (fx + 0.5f + sfile->layout->prv_border_x);
-                       float dy = (fy + 0.5f - sfile->layout->prv_border_y);
-                       short xco = (float)sx + dx;
-                       short yco = (float)sy - sfile->layout->prv_h + dy;
-                       
+                       float fx, fy;
+                       float dx, dy;
+                       short xco, yco;
+                       float scaledx, scaledy;
+                       float scale;
+                       short ex, ey;
+
+                       if ( (imb->x > layout->prv_w) || (imb->y > layout->prv_h) ) {
+                               if (imb->x > imb->y) {
+                                       scaledx = (float)layout->prv_w;
+                                       scaledy =  ( (float)imb->y/(float)imb->x )*layout->prv_w;
+                                       scale = scaledx/imb->x;
+                               }
+                               else {
+                                       scaledy = (float)layout->prv_h;
+                                       scaledx =  ( (float)imb->x/(float)imb->y )*layout->prv_h;
+                                       scale = scaledy/imb->y;
+                               }
+                       } else {
+                               scaledx = (float)imb->x;
+                               scaledy = (float)imb->y;
+                               scale = 1.0;
+                       }
+                       ex = (short)scaledx;
+                       ey = (short)scaledy;
+                       fx = ((float)layout->prv_w - (float)ex)/2.0f;
+                       fy = ((float)layout->prv_h - (float)ey)/2.0f;
+                       dx = (fx + 0.5f + sfile->layout->prv_border_x);
+                       dy = (fy + 0.5f - sfile->layout->prv_border_y);
+                       xco = (float)sx + dx;
+                       yco = (float)sy - sfile->layout->prv_h + dy;
+
                        glBlendFunc(GL_SRC_ALPHA,  GL_ONE_MINUS_SRC_ALPHA);
                        
                        /* shadow */
                        if (!is_icon && (file->flags & IMAGEFILE))
-                               uiDrawBoxShadow(220, xco, yco, xco + imb->x, yco + imb->y);
+                               uiDrawBoxShadow(220, xco, yco, xco + ex, yco + ey);
                        
                        glEnable(GL_BLEND);
                        
                        /* the image */
                        glColor4f(1.0, 1.0, 1.0, 1.0);
-                       glaDrawPixelsTex(xco, yco, imb->x, imb->y, GL_UNSIGNED_BYTE, imb->rect);
+                       glaDrawPixelsTexScaled(xco, yco, imb->x, imb->y, GL_UNSIGNED_BYTE, imb->rect, scale, scale);
                        
                        /* border */
                        if (!is_icon && (file->flags & IMAGEFILE)) {
                                glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
-                               fdrawbox(xco, yco, xco + imb->x, yco + imb->y);
+                               fdrawbox(xco, yco, xco + ex, yco + ey);
                        }
                        
                        glDisable(GL_BLEND);
@@ -443,17 +452,14 @@ void file_draw_list(const bContext *C, ARegion *ar)
        if (offset<0) offset=0;
 
        /* alternating flat shade background */
-       for (i=0; (i <= layout->rows); ++i)
+       for (i=0; (i <= layout->rows); i+=2)
        {
                sx = v2d->cur.xmin;
                sy = v2d->cur.ymax - i*(layout->tile_h+2*layout->tile_border_y) - layout->tile_border_y;
-               
-               if (i % 2) {
-                       UI_ThemeColor(TH_BACK);
-               } else {
-                       UI_ThemeColorShade(TH_BACK, -7);
-               }
+
+               UI_ThemeColorShade(TH_BACK, -7);
                glRectf(v2d->cur.xmin, sy, v2d->cur.xmax, sy+layout->tile_h+2*layout->tile_border_y);
+               
        }
        
        /* vertical column dividers */
@@