NLA SoC: Merge from 2.5
authorJoshua Leung <aligorith@gmail.com>
Sat, 6 Jun 2009 05:00:40 +0000 (05:00 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sat, 6 Jun 2009 05:00:40 +0000 (05:00 +0000)
20571 to 20667

123 files changed:
projectfiles_vc9/blender/blender.sln
projectfiles_vc9/blender/editors/ED_editors.vcproj
release/ui/buttons_data_armature.py
release/ui/buttons_data_bone.py
release/ui/buttons_data_camera.py
release/ui/buttons_data_curve.py
release/ui/buttons_data_empty.py
release/ui/buttons_data_lamp.py
release/ui/buttons_data_lattice.py
release/ui/buttons_data_mesh.py
release/ui/buttons_data_modifier.py
release/ui/buttons_data_text.py
release/ui/buttons_material.py
release/ui/buttons_object_constraint.py
release/ui/buttons_objects.py
release/ui/buttons_particle.py
release/ui/buttons_physic_cloth.py
release/ui/buttons_scene.py
release/ui/buttons_texture.py
release/ui/buttons_world.py
source/blender/blenkernel/BKE_particle.h
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/include/ED_fileselect.h
source/blender/editors/include/ED_object.h
source/blender/editors/include/UI_interface.h
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/interface.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
source/blender/editors/interface/interface_utils.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/object/editconstraint.c
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_modifier.c
source/blender/editors/object/object_ops.c
source/blender/editors/physics/editparticle.c
source/blender/editors/preview/previewrender.c
source/blender/editors/screen/area.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/space_buttons/buttons_context.c [new file with mode: 0644]
source/blender/editors/space_buttons/buttons_intern.h
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_file/file_draw.c
source/blender/editors/space_file/file_header.c
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_file/space_file.c
source/blender/editors/space_info/info_header.c
source/blender/editors/space_outliner/outliner.c
source/blender/editors/space_sequencer/sequencer_add.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/makesdna/DNA_particle_types.h
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/RNA_access.h
source/blender/makesrna/RNA_define.h
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_ID.c
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_action.c
source/blender/makesrna/intern/rna_armature.c
source/blender/makesrna/intern/rna_brush.c
source/blender/makesrna/intern/rna_camera.c
source/blender/makesrna/intern/rna_constraint.c
source/blender/makesrna/intern/rna_curve.c
source/blender/makesrna/intern/rna_define.c
source/blender/makesrna/intern/rna_fcurve.c
source/blender/makesrna/intern/rna_group.c
source/blender/makesrna/intern/rna_image.c
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_internal_types.h
source/blender/makesrna/intern/rna_key.c
source/blender/makesrna/intern/rna_lamp.c
source/blender/makesrna/intern/rna_lattice.c
source/blender/makesrna/intern/rna_main.c
source/blender/makesrna/intern/rna_material.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_meta.c
source/blender/makesrna/intern/rna_modifier.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_nodetree_types.h
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_object_force.c
source/blender/makesrna/intern/rna_particle.c
source/blender/makesrna/intern/rna_rna.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_screen.c
source/blender/makesrna/intern/rna_scriptlink.c
source/blender/makesrna/intern/rna_sound.c
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_text.c
source/blender/makesrna/intern/rna_texture.c
source/blender/makesrna/intern/rna_ui.c
source/blender/makesrna/intern/rna_vfont.c
source/blender/makesrna/intern/rna_wm.c
source/blender/makesrna/intern/rna_world.c
source/blender/python/intern/bpy_interface.c
source/blender/python/intern/bpy_operator.c
source/blender/python/intern/bpy_operator.h
source/blender/python/intern/bpy_operator_wrap.c
source/blender/python/intern/bpy_rna.c
source/blender/python/intern/bpy_rna.h
source/blender/python/intern/bpy_ui.c
source/blender/render/intern/source/convertblender.c
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/wm_event_types.h

index 315adc06723b7b3f7d0ec300e0ca717b25d0e0db..b782f9b8a864a5be175080dfd308f314ad2c34d9 100644 (file)
@@ -39,7 +39,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blender", "blender.vcproj",
                {BAC615B0-F1AF-418B-8D23-A10FD8870D6A} = {BAC615B0-F1AF-418B-8D23-A10FD8870D6A}\r
                {E90C7BC2-CF30-4A60-A8F2-0050D592E358} = {E90C7BC2-CF30-4A60-A8F2-0050D592E358}\r
                {8B8D4FC3-3234-4E54-8376-5AB83D00D164} = {8B8D4FC3-3234-4E54-8376-5AB83D00D164}\r
-               {9991A3C3-83FE-4AFE-9E18-9D01CB57E879} = {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}\r
                {4B6AFCC5-968C-424A-8F20-76E41B3BEF74} = {4B6AFCC5-968C-424A-8F20-76E41B3BEF74}\r
                {0112CAD5-3584-412A-A2E5-1315A00437B4} = {0112CAD5-3584-412A-A2E5-1315A00437B4}\r
                {EB75F4D6-2970-4A3A-8D99-2BAD7201C0E9} = {EB75F4D6-2970-4A3A-8D99-2BAD7201C0E9}\r
@@ -210,8 +209,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gen_messaging", "..\kernel\
 EndProject\r
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PHY_Sumo", "..\gameengine\physics\PHY_Physics\PHY_Sumo\PHY_Sumo.vcproj", "{9625642D-6F20-4FB6-A089-BE7441B223E3}"\r
 EndProject\r
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BRE_yafray", "yafray\BRE_yafray.vcproj", "{9991A3C3-83FE-4AFE-9E18-9D01CB57E879}"\r
-EndProject\r
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PHY_Bullet", "..\gameengine\physics\PHY_Physics\PHY_Bullet\PHY_Bullet.vcproj", "{E90C7BC2-CF30-4A60-A8F2-0050D592E358}"\r
        ProjectSection(ProjectDependencies) = postProject\r
                {FFD3C64A-30E2-4BC7-BC8F-51818C320400} = {FFD3C64A-30E2-4BC7-BC8F-51818C320400}\r
@@ -831,20 +828,6 @@ Global
                {9625642D-6F20-4FB6-A089-BE7441B223E3}.Debug|Win32.Build.0 = 3D Plugin Debug|Win32\r
                {9625642D-6F20-4FB6-A089-BE7441B223E3}.Release|Win32.ActiveCfg = BlenderPlayer Release|Win32\r
                {9625642D-6F20-4FB6-A089-BE7441B223E3}.Release|Win32.Build.0 = BlenderPlayer Release|Win32\r
-               {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.3D Plugin Debug|Win32.ActiveCfg = Blender Release|Win32\r
-               {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.3D Plugin Debug|Win32.Build.0 = Blender Release|Win32\r
-               {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.3D Plugin Release|Win32.ActiveCfg = Blender Release|Win32\r
-               {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.3D Plugin Release|Win32.Build.0 = Blender Release|Win32\r
-               {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.Blender Debug|Win32.ActiveCfg = Blender Debug|Win32\r
-               {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.Blender Debug|Win32.Build.0 = Blender Debug|Win32\r
-               {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.Blender Release|Win32.ActiveCfg = Blender Release|Win32\r
-               {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.Blender Release|Win32.Build.0 = Blender Release|Win32\r
-               {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.BlenderPlayer Debug|Win32.ActiveCfg = Blender Debug|Win32\r
-               {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.BlenderPlayer Release|Win32.ActiveCfg = Blender Release|Win32\r
-               {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.Debug|Win32.ActiveCfg = Blender Debug|Win32\r
-               {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.Debug|Win32.Build.0 = Blender Debug|Win32\r
-               {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.Release|Win32.ActiveCfg = Blender Release|Win32\r
-               {9991A3C3-83FE-4AFE-9E18-9D01CB57E879}.Release|Win32.Build.0 = Blender Release|Win32\r
                {E90C7BC2-CF30-4A60-A8F2-0050D592E358}.3D Plugin Debug|Win32.ActiveCfg = 3D Plugin Debug|Win32\r
                {E90C7BC2-CF30-4A60-A8F2-0050D592E358}.3D Plugin Debug|Win32.Build.0 = 3D Plugin Debug|Win32\r
                {E90C7BC2-CF30-4A60-A8F2-0050D592E358}.3D Plugin Release|Win32.ActiveCfg = 3D Plugin Release|Win32\r
index 3ed0e772d2ff2224aa5a56cbbcc4e33e21e58b6b..8fa89f2c4a5ff296ef8ec20c595ed02fb801e6a1 100644 (file)
                <Filter\r
                        Name="space_buttons"\r
                        >\r
+                       <File\r
+                               RelativePath="..\..\..\source\blender\editors\space_buttons\buttons_context.c"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\source\blender\editors\space_buttons\buttons_header.c"\r
                                >\r
index 1d0043a5179df34c02a996b9a9a98bccb954aaf0..46a077ebfdb7b51db74b616e490040afd52df940 100644 (file)
@@ -7,15 +7,14 @@ class DataButtonsPanel(bpy.types.Panel):
        __context__ = "data"
        
        def poll(self, context):
-               ob = context.active_object
-               return (ob and ob.type == 'ARMATURE')
+               return (context.armature != None)
 
 class DATA_PT_skeleton(DataButtonsPanel):
        __idname__ = "DATA_PT_skeleton"
        __label__ = "Skeleton"
 
        def draw(self, context):
-               arm = context.active_object.data
+               arm = context.armature
                layout = self.layout
                
                layout.itemR(arm, "rest_position")
@@ -42,7 +41,7 @@ class DATA_PT_display(DataButtonsPanel):
        __label__ = "Display"
        
        def draw(self, context):
-               arm = context.active_object.data
+               arm = context.armature
                layout = self.layout
 
                split = layout.split()
@@ -62,7 +61,7 @@ class DATA_PT_paths(DataButtonsPanel):
        __label__ = "Paths"
 
        def draw(self, context):
-               arm = context.active_object.data
+               arm = context.armature
                layout = self.layout
 
                split = layout.split()
@@ -90,7 +89,7 @@ class DATA_PT_ghost(DataButtonsPanel):
        __label__ = "Ghost"
 
        def draw(self, context):
-               arm = context.active_object.data
+               arm = context.armature
                layout = self.layout
 
                split = layout.split()
@@ -111,4 +110,4 @@ class DATA_PT_ghost(DataButtonsPanel):
 bpy.types.register(DATA_PT_skeleton)
 bpy.types.register(DATA_PT_display)
 bpy.types.register(DATA_PT_paths)
-bpy.types.register(DATA_PT_ghost)
\ No newline at end of file
+bpy.types.register(DATA_PT_ghost)
index a4e0fe4e2fb5caca20b5b7d74bf0692937bc6545..75c201f015e7856175d015570615571f1c675a04 100644 (file)
@@ -7,15 +7,14 @@ class BoneButtonsPanel(bpy.types.Panel):
        __context__ = "bone"
        
        def poll(self, context):
-               ob = context.active_object
-               return (ob and ob.type == 'ARMATURE')
+               return (context.bone != None)
 
 class BONE_PT_bone(BoneButtonsPanel):
        __idname__ = "BONE_PT_bone"
        __label__ = "Bone"
 
        def draw(self, context):
-               bone = context.active_object.data.bones[0]
+               bone = context.bone
                layout = self.layout
 
                split = layout.split()
index d4dabea94803f9a72fd7be994ef8d757ded3fed3..7f3682b1c942545ef0be79a8c3af8b895d3cc648 100644 (file)
@@ -7,15 +7,14 @@ class DataButtonsPanel(bpy.types.Panel):
        __context__ = "data"
 
        def poll(self, context):
-               ob = context.active_object
-               return (ob and ob.type == 'CAMERA')
+               return (context.camera != None)
                
 class DATA_PT_cameralens(DataButtonsPanel):
        __idname__ = "DATA_PT_camera"
        __label__ = "Lens"
 
        def draw(self, context):
-               cam = context.active_object.data
+               cam = context.camera
                layout = self.layout
 
                layout.itemR(cam, "type", expand=True)
@@ -52,7 +51,7 @@ class DATA_PT_cameradisplay(DataButtonsPanel):
        __label__ = "Display"
        
        def draw(self, context):
-               cam = context.active_object.data
+               cam = context.camera
                layout = self.layout
 
                split = layout.split()
@@ -71,4 +70,4 @@ class DATA_PT_cameradisplay(DataButtonsPanel):
                col.itemR(cam, "draw_size", text="Size")
                
 bpy.types.register(DATA_PT_cameralens)
-bpy.types.register(DATA_PT_cameradisplay)
\ No newline at end of file
+bpy.types.register(DATA_PT_cameradisplay)
index 754c26aa3e68067a5df7c5227771be475c4fa3e9..9baee5516bed9c7a4e5599ff334cec3f3d30f1f0 100644 (file)
@@ -7,15 +7,15 @@ class DataButtonsPanel(bpy.types.Panel):
        __context__ = "data"
        
        def poll(self, context):
-               ob = context.active_object
-               return (ob and ob.type == 'CURVE')
+               ob = context.object
+               return (ob and ob.type == 'CURVE' and context.curve)
 
 class DATA_PT_shape_curve(DataButtonsPanel):
                __idname__ = "DATA_PT_shape_curve"
                __label__ = "Shape"
 
                def draw(self, context):
-                       curve = context.active_object.data
+                       curve = context.curve
                        layout = self.layout
 
                        layout.itemR(curve, "curve_2d")                 
@@ -50,7 +50,7 @@ class DATA_PT_geometry(DataButtonsPanel):
                __label__ = "Geometry"
 
                def draw(self, context):
-                       curve = context.active_object.data
+                       curve = context.curve
                        layout = self.layout
 
                        split = layout.split()
@@ -72,13 +72,13 @@ class DATA_PT_pathanim(DataButtonsPanel):
                __label__ = "Path Animation"
                
                def draw_header(self, context):
-                       curve = context.active_object.data
+                       curve = context.curve
 
                        layout = self.layout
                        layout.itemR(curve, "path", text="")
 
                def draw(self, context):
-                       curve = context.active_object.data
+                       curve = context.curve
                        layout = self.layout
                        layout.active = curve.path      
                        
@@ -97,7 +97,7 @@ class DATA_PT_current_curve(DataButtonsPanel):
                __label__ = "Current Curve"
 
                def draw(self, context):
-                       currentcurve = context.active_object.data.curves[0]
+                       currentcurve = context.curve.curves[0] # XXX
                        layout = self.layout
 
                        split = layout.split()
@@ -128,4 +128,4 @@ class DATA_PT_current_curve(DataButtonsPanel):
 bpy.types.register(DATA_PT_shape_curve)
 bpy.types.register(DATA_PT_geometry)
 bpy.types.register(DATA_PT_pathanim)
-bpy.types.register(DATA_PT_current_curve)
\ No newline at end of file
+bpy.types.register(DATA_PT_current_curve)
index 94caa4ed700551f5c800e1456447e3c4d6edab88..7f994c94a07e28dc70c041b21fe6080c7661d2a9 100644 (file)
@@ -7,7 +7,7 @@ class DataButtonsPanel(bpy.types.Panel):
        __context__ = "data"
        
        def poll(self, context):
-               ob = context.active_object
+               ob = context.object
                return (ob and ob.type == 'EMPTY')
        
 class DATA_PT_empty(DataButtonsPanel):
@@ -15,10 +15,10 @@ class DATA_PT_empty(DataButtonsPanel):
        __label__ = "Empty"
 
        def draw(self, context):
-               ob = context.active_object
+               ob = context.object
                layout = self.layout
 
                layout.itemR(ob, "empty_draw_type")
                layout.itemR(ob, "empty_draw_size")
                
-bpy.types.register(DATA_PT_empty)
\ No newline at end of file
+bpy.types.register(DATA_PT_empty)
index a2a6ad0426c5acfde1457c07e65517cd6e3b39e5..86be9cd1a68b5ee600c27db8544eb8029ba941ad 100644 (file)
@@ -7,15 +7,14 @@ class DataButtonsPanel(bpy.types.Panel):
        __context__ = "data"
        
        def poll(self, context):
-               ob = context.active_object
-               return (ob and ob.type == 'LAMP')
+               return (context.lamp != None)
        
 class DATA_PT_lamp(DataButtonsPanel):
        __idname__ = "DATA_PT_lamp"
        __label__ = "Lamp"
 
        def draw(self, context):
-               lamp = context.active_object.data
+               lamp = context.lamp
                layout = self.layout
 
                layout.itemR(lamp, "type", expand=True)
@@ -56,11 +55,11 @@ class DATA_PT_sunsky(DataButtonsPanel):
        __label__ = "Sun/Sky"
        
        def poll(self, context):
-               ob = context.active_object
-               return (ob.type == 'LAMP' and ob.data.type == 'SUN')
+               lamp = context.lamp
+               return (lamp and lamp.type == 'SUN')
 
        def draw(self, context):
-               lamp = context.active_object.data.sky
+               lamp = context.lamp.sky
                layout = self.layout
 
                row = layout.row()
@@ -99,11 +98,11 @@ class DATA_PT_shadow(DataButtonsPanel):
        __label__ = "Shadow"
        
        def poll(self, context):
-               ob = context.active_object
-               return (ob.type == 'LAMP' and ob.data.type in ('POINT','SUN', 'SPOT', 'AREA'))
+               lamp = context.lamp
+               return (lamp and lamp.type in ('POINT','SUN', 'SPOT', 'AREA'))
 
        def draw(self, context):
-               lamp = context.active_object.data
+               lamp = context.lamp
                layout = self.layout
 
                layout.itemR(lamp, "shadow_method", expand=True)
@@ -178,11 +177,11 @@ class DATA_PT_spot(DataButtonsPanel):
        __label__ = "Spot"
        
        def poll(self, context):
-               ob = context.active_object
-               return (ob.type == 'LAMP' and ob.data.type == 'SPOT')
+               lamp = context.lamp
+               return (lamp and lamp.type == 'SPOT')
 
        def draw(self, context):
-               lamp = context.active_object.data
+               lamp = context.lamp
                layout = self.layout
 
                split = layout.split()
@@ -200,7 +199,28 @@ class DATA_PT_spot(DataButtonsPanel):
                if lamp.shadow_method == 'BUFFER_SHADOW':
                        colsub.itemR(lamp, "halo_step", text="Step")
 
+class DATA_PT_falloff_curve(DataButtonsPanel):
+       __idname__ = "DATA_PT_falloff_curve"
+       __label__ = "Falloff Curve"
+       
+       def poll(self, context):
+               lamp = context.lamp
+
+               if lamp and lamp.type in ('POINT', 'SPOT'):
+                       if lamp.falloff_type == 'CUSTOM_CURVE':
+                               return True
+
+               return False
+
+       def draw(self, context):
+               lamp = context.lamp
+               layout = self.layout
+
+               layout.template_curve_mapping(lamp.falloff_curve)
+
 bpy.types.register(DATA_PT_lamp)
 bpy.types.register(DATA_PT_shadow)
 bpy.types.register(DATA_PT_sunsky)
-bpy.types.register(DATA_PT_spot)
\ No newline at end of file
+bpy.types.register(DATA_PT_spot)
+bpy.types.register(DATA_PT_falloff_curve)
+
index 4bcff9f53892f75f0c4ba1d47dc93ae8b9f66a00..6172c255d154c89d21bf82668385c5d7fbf8bb9b 100644 (file)
@@ -7,15 +7,14 @@ class DataButtonsPanel(bpy.types.Panel):
        __context__ = "data"
        
        def poll(self, context):
-               ob = context.active_object
-               return (ob and ob.type == 'LATTICE')
+               return (context.lattice != None)
        
 class DATA_PT_lattice(DataButtonsPanel):
        __idname__ = "DATA_PT_lattice"
        __label__ = "Lattice"
 
        def draw(self, context):
-               lat = context.active_object.data
+               lat = context.lattice
                layout = self.layout
 
                row = layout.row()
@@ -34,4 +33,4 @@ class DATA_PT_lattice(DataButtonsPanel):
                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 6e9a30cefbcfc5e6046590b4df0b6c94fbcdc0d9..fceb235343a5471da7c7f4ad3d15b492b9d14773 100644 (file)
@@ -7,15 +7,14 @@ class DataButtonsPanel(bpy.types.Panel):
        __context__ = "data"
        
        def poll(self, context):
-               ob = context.active_object
-               return (ob and ob.type == 'MESH')
+               return (context.mesh != None)
 
 class DATA_PT_surface(DataButtonsPanel):
                __idname__ = "DATA_PT_surface"
                __label__ = "Mesh"
 
                def draw(self, context):
-                       mesh = context.active_object.data
+                       mesh = context.mesh
                        layout = self.layout
 
                        split = layout.split()
@@ -31,4 +30,4 @@ class DATA_PT_surface(DataButtonsPanel):
                        
                        layout.itemR(mesh, "texco_mesh")                        
                                                
-bpy.types.register(DATA_PT_surface)
\ No newline at end of file
+bpy.types.register(DATA_PT_surface)
index 6de2d6454714d0920b73ccf3c6ded0df1d250243..72b2f29100eb4ecbb1a194e4ed37e67194dbe934 100644 (file)
@@ -7,7 +7,7 @@ class DataButtonsPanel(bpy.types.Panel):
        __context__ = "modifier"
 
        def poll(self, context):
-               ob = context.active_object
+               ob = context.object
                return (ob and ob.type in ('MESH', 'CURVE', 'SURFACE', 'TEXT', 'LATTICE'))
                
 class DATA_PT_modifiers(DataButtonsPanel):
@@ -15,7 +15,7 @@ class DATA_PT_modifiers(DataButtonsPanel):
        __label__ = "Modifiers"
 
        def draw(self, context):
-               ob = context.active_object
+               ob = context.object
                layout = self.layout
 
                row = layout.row()
@@ -61,7 +61,7 @@ class DATA_PT_modifiers(DataButtonsPanel):
                                if md.type == 'MASK':
                                        self.mask(box, md)
                                if md.type == 'MESH_DEFORM':
-                                       self.meshdeform(box, md)
+                                       self.mesh_deform(box, md)
                                if md.type == 'MIRROR':
                                        self.mirror(box, md)
                                if md.type == 'MULTIRES':
@@ -104,6 +104,8 @@ class DATA_PT_modifiers(DataButtonsPanel):
                        layout.itemR(md, "length")
                if md.fit_type == 'FIT_CURVE':
                                layout.itemR(md, "curve")
+
+               layout.itemS()
                
                split = layout.split()
                
@@ -112,7 +114,10 @@ class DATA_PT_modifiers(DataButtonsPanel):
                col.itemR(md, "constant_offset")
                colsub = col.column()
                colsub.active = md.constant_offset
-               colsub.itemR(md, "constant_offset_displacement", text="Displacement")
+               colsub.itemR(md, "constant_offset_displacement", text="")
+
+               col.itemS()
+
                sub = col.row().itemR(md, "merge_adjacent_vertices", text="Merge")
                colsub = col.column()
                colsub.active = md.merge_adjacent_vertices
@@ -124,12 +129,17 @@ class DATA_PT_modifiers(DataButtonsPanel):
                col.itemR(md, "relative_offset")
                colsub = col.column()
                colsub.active = md.relative_offset
-               colsub.itemR(md, "relative_offset_displacement", text="Displacement")
+               colsub.itemR(md, "relative_offset_displacement", text="")
+
+               col.itemS()
+
                col = col.column()
                col.itemR(md, "add_offset_object")
                colsub = col.column()
                colsub.active = md.add_offset_object
-               colsub.itemR(md, "offset_object")
+               colsub.itemR(md, "offset_object", text="")
+
+               layout.itemS()
                
                col = layout.column()
                col.itemR(md, "start_cap")
@@ -249,13 +259,16 @@ class DATA_PT_modifiers(DataButtonsPanel):
                        layout.itemR(md, "vertex_group")
                layout.itemR(md, "inverse")
                
-       def meshdeform(self, layout, md):
+       def mesh_deform(self, layout, md):
                layout.itemR(md, "mesh")
                layout.itemR(md, "vertex_group")
                layout.itemR(md, "invert")
-               layout.itemR(md, "precision")
-               layout.itemR(md, "dynamic")
-               # Missing: "Bind"
+
+               layout.itemS()
+               layout.itemO("OBJECT_OT_modifier_mdef_bind", text="Bind")
+               row = layout.row()
+               row.itemR(md, "precision")
+               row.itemR(md, "dynamic")
                
        def mirror(self, layout, md):
                layout.itemR(md, "merge_limit")
index 96147270209dd9bfc56d4428f687e53e95860165..9683dbee22bc84c09b536c1a7c89d59c247677e6 100644 (file)
@@ -7,7 +7,7 @@ class DataButtonsPanel(bpy.types.Panel):
        __context__ = "data"
        
        def poll(self, context):
-               ob = context.active_object
+               ob = context.object
                return (ob and ob.type == 'TEXT')
                
 class DATA_PT_shape_text(DataButtonsPanel):
@@ -15,7 +15,7 @@ class DATA_PT_shape_text(DataButtonsPanel):
                __label__ = "Shape"
 
                def draw(self, context):
-                       curve = context.active_object.data
+                       curve = context.curve
                        layout = self.layout
 
                        layout.itemR(curve, "curve_2d")                 
@@ -46,7 +46,7 @@ class DATA_PT_font(DataButtonsPanel):
        __label__ = "Font"
 
        def draw(self, context):
-               text = context.active_object.data
+               text = context.curve
                layout = self.layout
 
                layout.row()
@@ -77,7 +77,7 @@ class DATA_PT_paragraph(DataButtonsPanel):
        __label__ = "Paragraph"
 
        def draw(self, context):
-               text = context.active_object.data
+               text = context.curve
                layout = self.layout
 
                layout.itemL(text="Align:")
@@ -102,10 +102,10 @@ class DATA_PT_textboxes(DataButtonsPanel):
                __label__ = "Text Boxes"
 
                def draw(self, context):
-                       text = context.active_object.data
+                       text = context.curve
                        layout = self.layout
 
 bpy.types.register(DATA_PT_shape_text) 
 bpy.types.register(DATA_PT_font)
 bpy.types.register(DATA_PT_paragraph)
-#bpy.types.register(DATA_PT_textboxes)
\ No newline at end of file
+#bpy.types.register(DATA_PT_textboxes)
index c9a5fa6db0680e35ca6fd365f854ff6458a618b3..7cffb5b18cf9b11c5e07c6a9d6ca84d7e76dee75 100644 (file)
@@ -7,8 +7,7 @@ class MaterialButtonsPanel(bpy.types.Panel):
        __context__ = "material"
 
        def poll(self, context):
-               ob = context.active_object
-               return (ob and ob.active_material)
+               return (context.material != None)
 
 class MATERIAL_PT_preview(MaterialButtonsPanel):
        __idname__= "MATERIAL_PT_preview"
@@ -17,7 +16,7 @@ class MATERIAL_PT_preview(MaterialButtonsPanel):
        def draw(self, context):
                layout = self.layout
 
-               mat = context.active_object.active_material
+               mat = context.material
                layout.template_preview(mat)
        
 class MATERIAL_PT_material(MaterialButtonsPanel):
@@ -26,7 +25,7 @@ class MATERIAL_PT_material(MaterialButtonsPanel):
 
        def draw(self, context):
                layout = self.layout
-               mat = context.active_object.active_material
+               mat = context.material
        
                layout.itemR(mat, "type", expand=True)
 
@@ -42,18 +41,18 @@ class MATERIAL_PT_sss(MaterialButtonsPanel):
        __label__ = "Subsurface Scattering"
 
        def poll(self, context):
-               ob = context.active_object
-               return (ob and ob.active_material and ob.active_material.type == "SURFACE")
+               mat = context.material
+               return (mat and mat.type == "SURFACE")
 
        def draw_header(self, context):
-               sss = context.active_object.active_material.subsurface_scattering
+               sss = context.material.subsurface_scattering
 
                layout = self.layout
                layout.itemR(sss, "enabled", text="")
        
        def draw(self, context):
                layout = self.layout
-               sss = context.active_object.active_material.subsurface_scattering
+               sss = context.material.subsurface_scattering
                layout.active = sss.enabled     
                
                flow = layout.column_flow()
@@ -76,18 +75,18 @@ class MATERIAL_PT_raymir(MaterialButtonsPanel):
        __label__ = "Ray Mirror"
        
        def poll(self, context):
-               ob = context.active_object
-               return (ob and ob.active_material and ob.active_material.type == "SURFACE")
+               mat = context.material
+               return (mat and mat.type == "SURFACE")
        
        def draw_header(self, context):
-               raym = context.active_object.active_material.raytrace_mirror
+               raym = context.material.raytrace_mirror
 
                layout = self.layout
                layout.itemR(raym, "enabled", text="")
        
        def draw(self, context):
                layout = self.layout
-               raym = context.active_object.active_material.raytrace_mirror
+               raym = context.material.raytrace_mirror
                layout.active = raym.enabled    
                split = layout.split()
                
@@ -113,18 +112,18 @@ class MATERIAL_PT_raytransp(MaterialButtonsPanel):
        __label__= "Ray Transparency"
        
        def poll(self, context):
-               ob = context.active_object
-               return (ob and ob.active_material and ob.active_material.type == "SURFACE")
+               mat = context.material
+               return (mat and mat.type == "SURFACE")
 
        def draw_header(self, context):
-               rayt = context.active_object.active_material.raytrace_transparency
+               rayt = context.material.raytrace_transparency
 
                layout = self.layout
                layout.itemR(rayt, "enabled", text="")
 
        def draw(self, context):
                layout = self.layout
-               rayt = context.active_object.active_material.raytrace_transparency
+               rayt = context.material.raytrace_transparency
                layout.active = rayt.enabled    
                
                split = layout.split()
@@ -151,12 +150,12 @@ class MATERIAL_PT_halo(MaterialButtonsPanel):
        __label__= "Halo"
        
        def poll(self, context):
-               ob = context.active_object
-               return (ob and ob.active_material and ob.active_material.type == "HALO")
+               mat = context.material
+               return (mat and mat.type == "HALO")
        
        def draw(self, context):
                layout = self.layout
-               mat = context.active_object.active_material
+               mat = context.material
                halo = mat.halo
 
                split = layout.split()
@@ -202,4 +201,5 @@ 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)
\ No newline at end of file
+bpy.types.register(MATERIAL_PT_halo)
+
index a4ac6dfff863c968808e6ace231bfb16bf1dd53b..5b32124ff334b5321b7e3b32c79d8f7f3f42eb0d 100644 (file)
@@ -15,8 +15,8 @@ class ConstraintButtonsPanel(bpy.types.Panel):
                                self.child_of(box, con)
                        elif con.type == "TRACK_TO":
                                self.track_to(box, con)
-                       #elif con.type == "IK":
-                       #       self.ik(box, con)
+                       elif con.type == "IK":
+                               self.ik(box, con)
                        elif con.type == "FOLLOW_PATH":
                                self.follow_path(box, con)
                        elif con.type == "LIMIT_ROTATION":
@@ -43,8 +43,8 @@ class ConstraintButtonsPanel(bpy.types.Panel):
                                self.stretch_to(box, con)
                        elif con.type == "FLOOR":
                                self.floor(box, con)
-                       #elif con.type == "RIGID_BODY_JOINT"
-                       #       self.rigid_body(box, con)
+                       elif con.type == "RIGID_BODY_JOINT":
+                               self.rigid_body(box, con)
                        elif con.type == "CLAMP_TO":
                                self.clamp_to(box, con)
                        elif con.type == "TRANSFORM":
@@ -126,13 +126,30 @@ class ConstraintButtonsPanel(bpy.types.Panel):
                
                self.space_template(layout, con)
                
-       #def ik(self, layout, con):
-       
+       def ik(self, layout, con):
+               self.target_template(layout, con)
+               
+               layout.itemR(con, "pole_target")
+               layout.itemR(con, "pole_subtarget")
+               
+               col = layout.column_flow()
+               col.itemR(con, "iterations")
+               col.itemR(con, "pole_angle")
+               col.itemR(con, "weight")
+               col.itemR(con, "orient_weight")
+               col.itemR(con, "chain_length")
+               
+               col = layout.column_flow()
+               col.itemR(con, "tail")
+               col.itemR(con, "rotation")
+               col.itemR(con, "targetless")
+               col.itemR(con, "stretch")
+               
        def follow_path(self, layout, con):
                self.target_template(layout, con)
                
                row = layout.row()
-               row.itemR(con, "curve_follow", toggle=True)
+               row.itemR(con, "curve_follow")
                row.itemR(con, "offset")
                
                row = layout.row()
@@ -394,7 +411,29 @@ class ConstraintButtonsPanel(bpy.types.Panel):
                row.itemL(text="Min/Max:")
                row.itemR(con, "floor_location", expand=True)
                
-       #def rigid_body(self, layout, con):
+       def rigid_body(self, layout, con):
+               self.target_template(layout, con)
+               
+               layout.itemR(con, "pivot_type")
+               layout.itemR(con, "child")
+               
+               row = layout.row()
+               row.itemR(con, "disable_linked_collision", text="No Collision")
+               row.itemR(con, "draw_pivot")
+               
+               split = layout.split()
+               
+               col = split.column()
+               col.itemR(con, "pivot_x")
+               col.itemR(con, "pivot_y")
+               col.itemR(con, "pivot_z")
+               
+               col = split.column()
+               col.itemR(con, "axis_x")
+               col.itemR(con, "axis_y")
+               col.itemR(con, "axis_z")
+               
+               #Missing: Limit arrays (not wrapped in RNA yet) 
        
        def clamp_to(self, layout, con):
                self.target_template(layout, con)
@@ -473,11 +512,10 @@ class OBJECT_PT_constraints(ConstraintButtonsPanel):
        __context__ = "object"
 
        def poll(self, context):
-               ob = context.active_object
-               return (ob != None)
+               return (context.object != None)
                
        def draw(self, context):
-               ob = context.active_object
+               ob = context.object
                layout = self.layout
 
                row = layout.row()
@@ -493,12 +531,12 @@ class BONE_PT_constraints(ConstraintButtonsPanel):
        __context__ = "bone"
 
        def poll(self, context):
-               ob = context.active_object
+               ob = context.object
                return (ob and ob.type == "ARMATURE")
                
        def draw(self, context):
-               ob = context.active_object
-               pchan = ob.pose.pose_channels[0]
+               ob = context.object
+               pchan = ob.pose.pose_channels[0] # XXX
                layout = self.layout
 
                #row = layout.row()
@@ -509,4 +547,5 @@ class BONE_PT_constraints(ConstraintButtonsPanel):
                        self.draw_constraint(con)
 
 bpy.types.register(OBJECT_PT_constraints)
-bpy.types.register(BONE_PT_constraints)
\ No newline at end of file
+bpy.types.register(BONE_PT_constraints)
+
index a5074614515880906bbba711d7ce492296b6aa14..6d75146fe5ffb11436e3a30687d9b1dcefb9fbe2 100644 (file)
@@ -7,14 +7,14 @@ class ObjectButtonsPanel(bpy.types.Panel):
        __context__ = "object"
 
        def poll(self, context):
-               return (context.active_object != None)
+               return (context.object != None)
 
 class OBJECT_PT_transform(ObjectButtonsPanel):
        __idname__ = "OBJECT_PT_transform"
        __label__ = "Transform"
 
        def draw(self, context):
-               ob = context.active_object
+               ob = context.object
                layout = self.layout
 
                row = layout.row()
@@ -27,7 +27,7 @@ class OBJECT_PT_groups(ObjectButtonsPanel):
        __label__ = "Groups"
 
        def draw(self, context):
-               ob = context.active_object
+               ob = context.object
                layout = self.layout
 
                row = layout.row()
@@ -54,7 +54,7 @@ class OBJECT_PT_display(ObjectButtonsPanel):
        __label__ = "Display"
 
        def draw(self, context):
-               ob = context.active_object
+               ob = context.object
                layout = self.layout
                        
                row = layout.row()
@@ -74,7 +74,7 @@ class OBJECT_PT_duplication(ObjectButtonsPanel):
        __label__ = "Duplication"
 
        def draw(self, context):
-               ob = context.active_object
+               ob = context.object
                layout = self.layout
 
                layout.itemR(ob, "dupli_type", expand=True)
@@ -108,7 +108,7 @@ class OBJECT_PT_animation(ObjectButtonsPanel):
        __label__ = "Animation"
 
        def draw(self, context):
-               ob = context.active_object
+               ob = context.object
                layout = self.layout
                
                split = layout.split()
@@ -132,3 +132,4 @@ bpy.types.register(OBJECT_PT_groups)
 bpy.types.register(OBJECT_PT_display)
 bpy.types.register(OBJECT_PT_duplication)
 bpy.types.register(OBJECT_PT_animation)
+
index 52e20b03538f982cfd97f01019fcdc0b1771ee1d..da04fad4adcce84ac8962fe4fd9a8cfeb247732c 100644 (file)
 
 import bpy
 
+def particle_panel_enabled(psys):
+       return psys.point_cache.baked==False and psys.editable==False
+       
+def particle_panel_poll(context):
+       psys = context.particle_system
+       type = psys.settings.type
+       return psys != None and (type=='EMITTER' or type=='REACTOR'or type=='HAIR')
+
 class ParticleButtonsPanel(bpy.types.Panel):
        __space_type__ = "BUTTONS_WINDOW"
        __region_type__ = "WINDOW"
        __context__ = "particle"
 
        def poll(self, context):
-               ob = context.active_object
-               return (ob and ob.active_particle_system)
+               psys = context.particle_system
+               type = psys.settings.type
+               return psys != None and (type=='EMITTER' or type=='REACTOR'or type=='HAIR')
 
 class PARTICLE_PT_particles(ParticleButtonsPanel):
        __idname__= "PARTICLE_PT_particles"
-       __label__ = "Particles"
+       __label__ = "ParticleSystem"
+
+       def poll(self, context):
+               return (context.particle_system != None)
+       
+       def draw(self, context):
+               layout = self.layout
+
+               psys = context.particle_system
+               part = psys.settings
+               
+               #row = layout.row()
+               #row.itemL(text="Particle system datablock")
+               #row.itemL(text="Viewport")
+               #row.itemL(text="Render")
+               
+               type = psys.settings.type
+               
+               if(type!='EMITTER' and type!='REACTOR' and type!='HAIR'):
+                       layout.itemL(text="No settings for fluid particles")
+                       return
+               
+               row = layout.row()
+               row.enabled = particle_panel_enabled(psys)
+               row.itemR(part, "type")
+               row.itemR(psys, "seed")
+               
+               row = layout.row()
+               if part.type=='HAIR':
+                       if psys.editable==True:
+                               row.itemO("PARTICLE_OT_editable_set", text="Free Edit")
+                       else:
+                               row.itemO("PARTICLE_OT_editable_set", text="Make Editable")
+                       subrow = row.row()
+                       subrow.enabled = particle_panel_enabled(psys)
+                       subrow.itemR(part, "hair_step")
+               elif part.type=='REACTOR':
+                       row.itemR(psys, "reactor_target_object")
+                       row.itemR(psys, "reactor_target_particle_system", text="Particle System")
+               
+class PARTICLE_PT_emission(ParticleButtonsPanel):
+       __idname__= "PARTICLE_PT_emission"
+       __label__ = "Emission"
+       
+       def draw(self, context):
+               layout = self.layout
+
+               psys = context.particle_system
+               part = psys.settings
+               
+               layout.enabled = particle_panel_enabled(psys)
+               
+               row = layout.row()
+               #col.itemL(text="TODO: Rate instead of amount")
+               row.itemR(part, "amount")
+               row.itemL(text="")
+               
+               split = layout.split()
+               
+               col = split.column(align=True)
+               col.itemR(part, "start")
+               col.itemR(part, "end")
+
+               col = split.column(align=True)
+               col.itemR(part, "lifetime")
+               col.itemR(part, "random_lifetime", slider=True)
+               
+class PARTICLE_PT_cache(ParticleButtonsPanel):
+       __idname__= "PARTICLE_PT_cache"
+       __label__ = "Cache"
+       
+       def poll(self, context):
+               psys = context.particle_system
+               type = psys.settings.type
+               return psys != None and (type=='EMITTER' or type== 'REACTOR')
+
+       def draw(self, context):
+               layout = self.layout
+
+               psys = context.particle_system
+               part = psys.settings
+               cache = psys.point_cache
+               
+               #if cache.baked==True:
+                       #layout.itemO("PARTICLE_OT_free_bake", text="BAKE")
+               #else:
+               row = layout.row()
+                       #row.itemO("PARTICLE_OT_bake", text="BAKE")
+               row.itemR(cache, "start_frame")
+               row.itemR(cache, "end_frame")
+                       
+                       #layout.row().itemL(text="No simulation frames in disk cache.")
+               
+               
+class PARTICLE_PT_initial(ParticleButtonsPanel):
+       __idname__= "PARTICLE_PT_initial"
+       __label__ = "Initial values"
+
+       def draw(self, context):
+               layout = self.layout
+
+               psys = context.particle_system
+               part = psys.settings
+               
+               layout.enabled = particle_panel_enabled(psys)
+               
+               layout.row().itemL(text="Location from:")
+               
+               box = layout.box()
+               row = box.row()
+               row.itemR(part, "trand")
+               
+               col = row.column()
+               col.row().itemR(part, "emit_from", expand=True)
+               
+               if part.emit_from=='FACE' or part.emit_from=='VOLUME':
+                       row = box.row()
+
+                       if part.distribution!='GRID':
+                               row.itemR(part, "even_distribution")
+                       else:
+                               row.itemL(text="")
+                               
+                       row.itemR(part, "distribution", expand=True)
+                       
+                       row = box.row()
+
+                       if part.distribution=='JIT':
+                               row.itemR(part, "userjit", text="Particles/Face")
+                               row.itemR(part, "jitter_factor", text="Jittering Amount", slider=True)
+                       elif part.distribution=='GRID':
+                               row.itemR(part, "grid_resolution")
+
+               #layout.row().itemL(text="")
+                               
+               layout.row().itemL(text="Velocity:")
+               box = layout.box()
+               row = box.row()
+               col = row.column()
+               col.itemR(part, "normal_factor")
+               if part.emit_from=='PARTICLE':
+                       col.itemR(part, "particle_factor")
+               else:
+                       col.itemR(part, "object_factor", slider=True)
+               col.itemR(part, "random_factor")
+               
+               col = row.column(align=True)
+               col.itemL(text="TODO:")
+               col.itemL(text="Object aligned")
+               col.itemL(text="direction: X, Y, Z")
+               
+               row = box.row()
+               col = row.column(align=True)
+               col.itemR(part, "tangent_factor")
+               col.itemR(part, "tangent_phase", slider=True)
+               
+               col = row.column(align=True)
+               if part.type=='REACTOR':
+                       col.itemR(part, "reactor_factor")
+                       col.itemR(part, "reaction_shape", slider=True)
+               else:
+                       col.itemL(text="")
+               
+               layout.row().itemL(text="Rotation:")
+               box = layout.box()
+               box.row().itemR(part, "rotation_dynamic")
+               
+               row = box.row()
+               col = row.column(align=True)
+               col.itemR(part, "rotation_mode", text="")
+               col.itemR(part, "random_rotation_factor", slider=True)
+               col = row.column(align=True)
+               col.itemR(part, "phase_factor", slider=True)
+               col.itemR(part, "random_phase_factor", text="Random", slider=True)
+               
+               
+               layout.row().itemL(text="Angular velocity:")
+
+               box = layout.box()
+               row = box.row()
+               row.itemR(part, "angular_velocity_mode", expand=True)
+               row.itemR(part, "angular_velocity_factor", text="")
+               
+class PARTICLE_PT_physics(ParticleButtonsPanel):
+       __idname__= "PARTICLE_PT_physics"
+       __label__ = "Physics"
 
        def draw(self, context):
                layout = self.layout
 
-               psys = context.active_object.active_particle_system
+               psys = context.particle_system
                part = psys.settings
+               
+               layout.enabled = layout.enabled = particle_panel_enabled(psys)
+               
+               layout.itemR(part, "effector_group")
+               
+               layout.itemL(text="General:")
+               box = layout.box()
+               row = box.row()
+               col = row.column(align=True)
+               col.itemR(part, "particle_size")
+               col.itemR(part, "random_size", slider=True)
+               col = row.column(align=True)
+               col.itemR(part, "mass")
+               col.itemR(part, "sizemass", text="Multiply mass with size")
+               
+               layout.row().itemL(text="")
+               
+               row = layout.row()
+               row.itemL(text="Physics Type:")
+               row.itemR(part, "physics_type", expand=True)
+               
+               if part.physics_type != 'NO':
+                       box = layout.box()
+                       row = box.row()
+               
+               if part.physics_type == 'NEWTON':
+                       row.itemR(part, "integrator")
+                       row = box.row()
+                       col = row.column(align=True)
+                       col.itemL(text="Forces:")
+                       col.itemR(part, "brownian_factor")
+                       col.itemR(part, "drag_factor", slider=True)
+                       col.itemR(part, "damp_factor", slider=True)
+                       
+                       row.column().itemR(part, "acceleration")
+               elif part.physics_type == 'KEYED':
+                       row.itemR(psys, "keyed_first")
+                       if psys.keyed_first==True:
+                               row.itemR(psys, "timed_keys", text="Key timing")
+                       else:
+                               row.itemR(part, "keyed_time")
+                       
+                       row = box.row()
+                       row.itemL(text="Next key from object:")
+                       row.itemR(psys, "keyed_object", text="")
+                       row.itemR(psys, "keyed_particle_system")
+               
+               if part.physics_type=='NEWTON' or part.physics_type=='BOIDS':
+                       row = box.row()
+                       row.itemR(part, "size_deflect")
+                       row.itemR(part, "die_on_collision")
+                       row.itemR(part, "sticky")
+
+class PARTICLE_PT_render(ParticleButtonsPanel):
+       __idname__= "PARTICLE_PT_render"
+       __label__ = "Render"
+       
+       def poll(self, context):
+               return (context.particle_system != None)
+               
+       def draw(self, context):
+               layout = self.layout
+
+               psys = context.particle_system
+               part = psys.settings
+               
+               row = layout.row()
+               row.itemR(part, "material")
+               col = row.column()
+               col.itemR(part, "emitter");
+               col.itemR(part, "parent");
+               col = row.column()
+               col.itemR(part, "unborn");
+               col.itemR(part, "died");
+               
+               row = layout.row()
+               row.itemR(part, "ren_as", expand=True)
+               
+               row = layout.row(align=True)
+               
+               if part.ren_as == 'LINE':
+                       row.itemR(part, "line_length_tail")
+                       row.itemR(part, "line_length_head")
+                       row.itemR(part, "velocity_length")
+               elif part.ren_as == 'PATH':
+               
+                       if (part.type!='HAIR' and psys.point_cache.baked==False):
+                               box = layout.box()
+                               box.itemL(text="Baked or keyed particles needed for correct rendering.")
+                               return
+                               
+                       row.itemR(part, "hair_bspline")
+                       row.itemR(part, "render_step", text="Steps")
+                       
+                       row = layout.row()
+                       row.itemR(part, "abs_length")
+                       col = row.column(align=True)
+                       col.itemR(part, "absolute_length")
+                       col.itemR(part, "random_length", slider=True)
+                       
+                       #row = layout.row()
+                       #row.itemR(part, "timed_path")
+                       #col = row.column(align=True)
+                       #col.active = part.timed_path == True
+                       #col.itemR(part, "line_length_tail", text="Start")
+                       #col.itemR(part, "line_length_head", text="End")
+                       
+                       row = layout.row()
+                       col = row.column()
+                       col.itemR(part, "render_strand")
+                       
+                       subrow = col.row()
+                       subrow.active = part.render_strand == False
+                       subrow.itemR(part, "render_adaptive")
+                       col = row.column(align=True)
+                       subrow = col.row()
+                       subrow.active = part.render_adaptive or part.render_strand == True
+                       subrow.itemR(part, "adaptive_angle")
+                       subrow = col.row()
+                       subrow.active = part.render_adaptive == True and part.render_strand == False
+                       subrow.itemR(part, "adaptive_pix")
+                       
+                       if part.type=='HAIR' and part.render_strand==True and part.child_type=='FACES':
+                               layout.itemR(part, "enable_simplify")
+                               if part.enable_simplify==True:
+                                       box = layout.box()
+                                       row = box.row()
+                                       row.itemR(part, "simplify_refsize")
+                                       row.itemR(part, "simplify_rate")
+                                       row.itemR(part, "simplify_transition")
+                                       row = box.row()
+                                       row.itemR(part, "viewport")
+                                       subrow = row.row()
+                                       subrow.active = part.viewport==True
+                                       subrow.itemR(part, "simplify_viewport")
+                       
+
+               elif part.ren_as == 'OBJECT':
+                       row.itemR(part, "dupli_object")
+               elif part.ren_as == 'GROUP':
+                       split = layout.split()
+                       col = split.column()
+                       row = col.row()
+                       row.itemR(part, "whole_group")
+                       subcol = row.column()
+                       subcol.active = part.whole_group == False
+                       subcol.itemR(part, "rand_group")
+                       split.column().itemR(part, "dupli_group", text="")
+               elif part.ren_as == 'BILLBOARD':
+                       row.itemL(text="Align:")
+                       row.itemR(part, "billboard_lock", text="Lock")
+                       row = layout.row()
+                       row.itemR(part, "billboard_align", expand=True)
+                       row = layout.row()
+                       row.itemR(part, "billboard_object")
+               
+                       row = layout.row()
+                       col = row.column(align=True)
+                       col.itemL(text="Tilt:")
+                       col.itemR(part, "billboard_tilt", text="Angle", slider=True)
+                       col.itemR(part, "billboard_random_tilt", slider=True)
+                       col = row.column()
+                       col.itemR(part, "billboard_offset")
+                       
+                       row = layout.row()
+                       row.itemR(psys, "billboard_normal_uv")
+                       row = layout.row()
+                       row.itemR(psys, "billboard_time_index_uv")
+                       
+                       row = layout.row()
+                       row.itemL(text="Split uv's:")
+                       row.itemR(part, "billboard_uv_split", text="Number of splits")
+                       row = layout.row()
+                       row.itemR(psys, "billboard_split_uv")
+                       row = layout.row()
+                       row.itemL(text="Animate:")
+                       row.itemR(part, "billboard_animation", expand=True)
+                       row.itemL(text="Offset:")
+                       row.itemR(part, "billboard_split_offset", expand=True)
+               
+class PARTICLE_PT_draw(ParticleButtonsPanel):
+       __idname__= "PARTICLE_PT_draw"
+       __label__ = "Draw"
+       
+       def poll(self, context):
+               return (context.particle_system != None)
+       
+       def draw(self, context):
+               layout = self.layout
+
+               psys = context.particle_system
+               part = psys.settings
+               
+               row = layout.row()
+               row.itemR(part, "draw_as", expand=True)
+               
+               if part.draw_as=='NONE' or (part.ren_as=='NONE' and part.draw_as=='RENDER'):
+                       return
+                       
+               path = (part.ren_as=='PATH' and part.draw_as=='RENDER') or part.draw_as=='PATH'
+                       
+               if path and part.type!='HAIR' and psys.point_cache.baked==False:
+                       box = layout.box()
+                       box.itemL(text="Baked or keyed particles needed for correct drawing.")
+                       return
+               
+               row = layout.row()
+               row.itemR(part, "display", slider=True)
+               if part.draw_as!='RENDER' or part.ren_as=='HALO':
+                       row.itemR(part, "draw_size")
+               else:
+                       row.itemL(text="")
+               
+               row = layout.row()
+               col = row.column()
+               col.itemR(part, "show_size")
+               col.itemR(part, "velocity")
+               col.itemR(part, "num")
+               if part.physics_type == 'BOIDS':
+                       col.itemR(part, "draw_health")
+               
+               col = row.column()
+               if (path):
+                       box = col.box()                         
+                       box.itemR(part, "draw_step")
+               else:
+                       col.itemR(part, "material_color", text="Use material color")
+                       subcol = col.column()
+                       subcol.active = part.material_color==False
+                       #subcol.itemL(text="color")
+                       #subcol.itemL(text="Override material color")
+                       
+
+class PARTICLE_PT_children(ParticleButtonsPanel):
+       __idname__= "PARTICLE_PT_children"
+       __label__ = "Children"
+
+       def draw(self, context):
+               layout = self.layout
+
+               psys = context.particle_system
+               part = psys.settings
+               
+               layout.row().itemR(part, "child_type", expand=True)
+               
+               if part.child_type=='NONE':
+                       return
+               
+               row = layout.row()
+               
+               col = row.column(align=True)
+               col.itemR(part, "child_nbr", text="Draw")
+               col.itemR(part, "rendered_child_nbr", text="Render")
+               
+               col = row.column(align=True)
+               
+               if part.child_type=='FACES':
+                       col.itemR(part, "virtual_parents", slider=True)
+               else:
+                       col.itemR(part, "child_radius", text="Radius")
+                       col.itemR(part, "child_roundness", text="Roundness", slider=True)
+               
+                       col = row.column(align=True)
+                       col.itemR(part, "child_size", text="Size")
+                       col.itemR(part, "child_random_size", text="Random")
+               
+               layout.row().itemL(text="Effects:")
+               
+               row = layout.row()
+               
+               col = row.column(align=True)
+               col.itemR(part, "clump_factor", slider=True)
+               col.itemR(part, "clumppow", slider=True)
+               
+               col = row.column(align=True)
+               col.itemR(part, "rough_endpoint")
+               col.itemR(part, "rough_end_shape")
+
+               row = layout.row()
+               
+               col = row.column(align=True)
+               col.itemR(part, "rough1")
+               col.itemR(part, "rough1_size")
+
+               col = row.column(align=True)
+               col.itemR(part, "rough2")
+               col.itemR(part, "rough2_size")
+               col.itemR(part, "rough2_thres", slider=True)
+               
+               layout.row().itemL(text="Kink:")
+               layout.row().itemR(part, "kink", expand=True)
+               
+               row = layout.row()
+               row.itemR(part, "kink_amplitude")
+               row.itemR(part, "kink_frequency")
+               row.itemR(part, "kink_shape", slider=True)
+
+                               
+               
+class PARTICLE_PT_vertexgroups(ParticleButtonsPanel):
+       __idname__= "PARTICLE_PT_vertexgroups"
+       __label__ = "Vertexgroups"
+
+       def draw(self, context):
+               layout = self.layout
+
+               psys = context.particle_system
+               part = psys.settings
+               
+               layout.itemL(text="Nothing here yet.")
+
+               #row = layout.row()
+               #row.itemL(text="Vertex Group")
+               #row.itemL(text="Negate")
 
-               layout.itemR(part, "amount")
+               
+               #row = layout.row()
+               #row.itemR(psys, "vertex_group_density")
+               #row.itemR(psys, "vertex_group_density_negate", text="")
+               
+               #row = layout.row()
+               #row.itemR(psys, "vertex_group_velocity")
+               #row.itemR(psys, "vertex_group_velocity_negate", text="")
+               
+               #row = layout.row()
+               #row.itemR(psys, "vertex_group_length")
+               #row.itemR(psys, "vertex_group_length_negate", text="")
+               
+               #row = layout.row()
+               #row.itemR(psys, "vertex_group_clump")
+               #row.itemR(psys, "vertex_group_clump_negate", text="")
+               
+               #row = layout.row()
+               #row.itemR(psys, "vertex_group_kink")
+               #row.itemR(psys, "vertex_group_kink_negate", text="")
+               
+               #row = layout.row()
+               #row.itemR(psys, "vertex_group_roughness1")
+               #row.itemR(psys, "vertex_group_roughness1_negate", text="")
+               
+               #row = layout.row()
+               #row.itemR(psys, "vertex_group_roughness2")
+               #row.itemR(psys, "vertex_group_roughness2_negate", text="")
+               
+               #row = layout.row()
+               #row.itemR(psys, "vertex_group_roughness_end")
+               #row.itemR(psys, "vertex_group_roughness_end_negate", text="")
 
+               #row = layout.row()
+               #row.itemR(psys, "vertex_group_size")
+               #row.itemR(psys, "vertex_group_size_negate", text="")
+               
+               #row = layout.row()
+               #row.itemR(psys, "vertex_group_tangent")
+               #row.itemR(psys, "vertex_group_tangent_negate", text="")
+               
+               #row = layout.row()
+               #row.itemR(psys, "vertex_group_rotation")
+               #row.itemR(psys, "vertex_group_rotation_negate", text="")
+               
+               #row = layout.row()
+               #row.itemR(psys, "vertex_group_field")
+               #row.itemR(psys, "vertex_group_field_negate", text="")
+               
 bpy.types.register(PARTICLE_PT_particles)
+bpy.types.register(PARTICLE_PT_cache)
+bpy.types.register(PARTICLE_PT_emission)
+bpy.types.register(PARTICLE_PT_initial)
+bpy.types.register(PARTICLE_PT_physics)
+bpy.types.register(PARTICLE_PT_render)
+bpy.types.register(PARTICLE_PT_draw)
+bpy.types.register(PARTICLE_PT_children)
+bpy.types.register(PARTICLE_PT_vertexgroups)
 
index 6dab2bcf57c8df41a25d01e7cd4362297fa2433f..efa796df5b029d6d2c711656671ad7b19fe5177e 100644 (file)
@@ -6,17 +6,8 @@ class PhysicButtonsPanel(bpy.types.Panel):
        __region_type__ = "WINDOW"
        __context__ = "physics"
 
-       def cloth_modifier(self, context):
-               ob = context.active_object
-               for md in ob.modifiers:
-                       if md.type == 'CLOTH':
-                               return md
-
-               return None
-       
        def poll(self, context):
-               md = self.cloth_modifier(context)
-               return (md != None)
+               return (context.cloth != None)
                
 class Physic_PT_cloth(PhysicButtonsPanel):
        __idname__ = "Physic_PT_cloth"
@@ -24,7 +15,7 @@ class Physic_PT_cloth(PhysicButtonsPanel):
 
        def draw(self, context):
                layout = self.layout
-               md = self.cloth_modifier(context)
+               md = context.cloth
                cloth = md.settings
                
                split = layout.split()
@@ -60,7 +51,7 @@ class Physic_PT_cloth_collision(PhysicButtonsPanel):
        
        def draw_header(self, context):
                layout = self.layout
-               md = self.cloth_modifier(context)                       
+               md = context.cloth
                cloth = md.collision_settings
        
                layout.itemR(cloth, "enable_collision", text="")
@@ -68,7 +59,7 @@ class Physic_PT_cloth_collision(PhysicButtonsPanel):
        def draw(self, context):
                layout = self.layout
                
-               md = self.cloth_modifier(context)
+               md = context.cloth
                cloth = md.collision_settings
                layout.active = cloth.enable_collision  
                
@@ -91,7 +82,7 @@ class Physic_PT_cloth_stiffness(PhysicButtonsPanel):
        
        def draw_header(self, context):
                layout = self.layout
-               md = self.cloth_modifier(context)
+               md = context.cloth
                cloth = md.settings
        
                layout.itemR(cloth, "stiffness_scaling", text="")
@@ -99,7 +90,7 @@ class Physic_PT_cloth_stiffness(PhysicButtonsPanel):
        def draw(self, context):
                layout = self.layout
                
-               md = self.cloth_modifier(context)
+               md = context.cloth
                cloth = md.settings
                layout.active = cloth.stiffness_scaling 
                
index 561e5b94e3ee17ad0c462866dba7a092653466fe..d7f215f2297e4847ed92bb92d8c8d28ddcd59a65 100644 (file)
@@ -218,4 +218,4 @@ bpy.types.register(RENDER_PT_dimensions)
 bpy.types.register(RENDER_PT_antialiasing)
 bpy.types.register(RENDER_PT_shading)
 bpy.types.register(RENDER_PT_output)
-bpy.types.register(RENDER_PT_stamp)
\ No newline at end of file
+bpy.types.register(RENDER_PT_stamp)
index ccdbda5d54dddeda610ace8dfab840bbf84248dc..7d0ef9371d7563f69bd8c5d46a0438a788bb5d64 100644 (file)
@@ -7,8 +7,7 @@ class TextureButtonsPanel(bpy.types.Panel):
        __context__ = "texture"
        
        def poll(self, context):
-               try:    return (context.active_object.active_material.active_texture.texture != None)
-               except:return False
+               return (context.texture != None)
 
 class TEXTURE_PT_preview(TextureButtonsPanel):
        __idname__= "TEXTURE_PT_preview"
@@ -17,7 +16,7 @@ class TEXTURE_PT_preview(TextureButtonsPanel):
        def draw(self, context):
                layout = self.layout
 
-               tex = context.active_object.active_material.active_texture.texture
+               tex = context.texture
                layout.template_preview(tex)
 
 class TEXTURE_PT_texture(TextureButtonsPanel):
@@ -26,21 +25,38 @@ class TEXTURE_PT_texture(TextureButtonsPanel):
 
        def draw(self, context):
                layout = self.layout
-               tex = context.active_object.active_material.active_texture.texture
+               tex = context.texture
                
                layout.itemR(tex, "type")
 
+class TEXTURE_PT_colors(TextureButtonsPanel):
+       __idname__= "TEXTURE_PT_colors"
+       __label__ = "Colors"
+
+       def draw(self, context):
+               layout = self.layout
+               tex = context.texture
+
+               if tex.color_ramp:
+                       layout.template_color_ramp(tex.color_ramp, expand=True)
+               else:
+                       layout.itemR(tex, "rgb_factor")
+
+               row = layout.row()
+               row.itemR(tex, "brightness")
+               row.itemR(tex, "contrast")
+
 class TEXTURE_PT_clouds(TextureButtonsPanel):
        __idname__= "TEXTURE_PT_clouds"
        __label__ = "Clouds"
        
        def poll(self, context):
-               try:    return (context.active_object.active_material.active_texture.texture.type == 'CLOUDS')
-               except:return False
+               tex = context.texture
+               return (tex and tex.type == 'CLOUDS')
 
        def draw(self, context):
                layout = self.layout
-               tex = context.active_object.active_material.active_texture.texture
+               tex = context.texture
                
                layout.itemR(tex, "stype", expand=True)
                layout.itemL(text="Noise:")
@@ -57,12 +73,12 @@ class TEXTURE_PT_wood(TextureButtonsPanel):
        __label__ = "Wood"
        
        def poll(self, context):
-               try:    return (context.active_object.active_material.active_texture.texture.type == 'WOOD')
-               except:return False
+               tex = context.texture
+               return (tex and tex.type == 'WOOD')
 
        def draw(self, context):
                layout = self.layout
-               tex = context.active_object.active_material.active_texture.texture
+               tex = context.texture
                
                layout.itemR(tex, "stype", expand=True)
                layout.itemR(tex, "noisebasis2", expand=True)
@@ -80,12 +96,12 @@ class TEXTURE_PT_marble(TextureButtonsPanel):
        __label__ = "Marble"
        
        def poll(self, context):
-               try:    return (context.active_object.active_material.active_texture.texture.type == 'MARBLE')
-               except:return False
+               tex = context.texture
+               return (tex and tex.type == 'MARBLE')
 
        def draw(self, context):
                layout = self.layout
-               tex = context.active_object.active_material.active_texture.texture
+               tex = context.texture
                
                layout.itemR(tex, "stype", expand=True)
                layout.itemR(tex, "noisebasis2", expand=True)
@@ -104,12 +120,12 @@ class TEXTURE_PT_magic(TextureButtonsPanel):
        __label__ = "Magic"
        
        def poll(self, context):
-               try:    return (context.active_object.active_material.active_texture.texture.type == 'MAGIC')
-               except:return False
+               tex = context.texture
+               return (tex and tex.type == 'MAGIC')
 
        def draw(self, context):
                layout = self.layout
-               tex = context.active_object.active_material.active_texture.texture
+               tex = context.texture
                        
                row = layout.row()
                row.itemR(tex, "noise_depth", text="Depth")
@@ -120,12 +136,12 @@ class TEXTURE_PT_blend(TextureButtonsPanel):
        __label__ = "Blend"
        
        def poll(self, context):
-               try:    return (context.active_object.active_material.active_texture.texture.type == 'BLEND')
-               except:return False
+               tex = context.texture
+               return (tex and tex.type == 'BLEND')
 
        def draw(self, context):
                layout = self.layout
-               tex = context.active_object.active_material.active_texture.texture
+               tex = context.texture
 
                layout.itemR(tex, "progression")
                layout.itemR(tex, "flip_axis")
@@ -135,12 +151,12 @@ class TEXTURE_PT_stucci(TextureButtonsPanel):
        __label__ = "Stucci"
        
        def poll(self, context):
-               try:    return (context.active_object.active_material.active_texture.texture.type == 'STUCCI')
-               except:return False
+               tex = context.texture
+               return (tex and tex.type == 'STUCCI')
 
        def draw(self, context):
                layout = self.layout
-               tex = context.active_object.active_material.active_texture.texture
+               tex = context.texture
                
                layout.itemR(tex, "stype", expand=True)
                layout.itemL(text="Noise:")
@@ -156,12 +172,12 @@ class TEXTURE_PT_image(TextureButtonsPanel):
        __label__ = "Image/Movie"
        
        def poll(self, context):
-               try:    return (context.active_object.active_material.active_texture.texture.type == 'IMAGE')
-               except:return False
+               tex = context.texture
+               return (tex and tex.type == 'IMAGE')
 
        def draw(self, context):
                layout = self.layout
-               tex = context.active_object.active_material.active_texture.texture
+               tex = context.texture
                
                split = layout.split()
                
@@ -183,12 +199,12 @@ class TEXTURE_PT_mapping(TextureButtonsPanel):
        __label__ = "Mapping"
        
        def poll(self, context):
-               try:    return (context.active_object.active_material.active_texture.texture.type == 'IMAGE')
-               except:return False
+               tex = context.texture
+               return (tex and tex.type == 'IMAGE')
 
        def draw(self, context):
                layout = self.layout
-               tex = context.active_object.active_material.active_texture.texture
+               tex = context.texture
                                
                split = layout.split()
                
@@ -226,12 +242,12 @@ class TEXTURE_PT_plugin(TextureButtonsPanel):
        __label__ = "Plugin"
        
        def poll(self, context):
-               try:    return (context.active_object.active_material.active_texture.texture.type == 'PLUGIN')
-               except:return False
+               tex = context.texture
+               return (tex and tex.type == 'PLUGIN')
 
        def draw(self, context):
                layout = self.layout
-               tex = context.active_object.active_material.active_texture.texture
+               tex = context.texture
                
                layout.itemL(text="Nothing yet")
                
@@ -240,12 +256,12 @@ class TEXTURE_PT_envmap(TextureButtonsPanel):
        __label__ = "Environment Map"
        
        def poll(self, context):
-               try:    return (context.active_object.active_material.active_texture.texture.type == 'ENVIRONMENT_MAP')
-               except:return False
+               tex = context.texture
+               return (tex and tex.type == 'ENVIRONMENT_MAP')
 
        def draw(self, context):
                layout = self.layout
-               tex = context.active_object.active_material.active_texture.texture
+               tex = context.texture
                
                layout.itemL(text="Nothing yet")
                
@@ -254,12 +270,12 @@ class TEXTURE_PT_musgrave(TextureButtonsPanel):
        __label__ = "Musgrave"
        
        def poll(self, context):
-               try:    return (context.active_object.active_material.active_texture.texture.type == 'MUSGRAVE')
-               except:return False
+               tex = context.texture
+               return (tex and tex.type == 'MUSGRAVE')
 
        def draw(self, context):
                layout = self.layout
-               tex = context.active_object.active_material.active_texture.texture
+               tex = context.texture
                
                layout.itemR(tex, "musgrave_type")      
                
@@ -289,13 +305,12 @@ class TEXTURE_PT_voronoi(TextureButtonsPanel):
        __label__ = "Voronoi"
        
        def poll(self, context):
-               try:    return (context.active_object.active_material.active_texture.texture.type == 'VORONOI')
-               except:return False
-
+               tex = context.texture
+               return (tex and tex.type == 'VORONOI')
 
        def draw(self, context):
                layout = self.layout
-               tex = context.active_object.active_material.active_texture.texture
+               tex = context.texture
        
                layout.itemR(tex, "distance_metric")
                layout.itemR(tex, "coloring")
@@ -321,12 +336,12 @@ class TEXTURE_PT_distortednoise(TextureButtonsPanel):
        __label__ = "Distorted Noise"
        
        def poll(self, context):
-               try:    return (context.active_object.active_material.active_texture.texture.type == 'DISTORTED_NOISE')
-               except:return False
+               tex = context.texture
+               return (tex and tex.type == 'DISTORTED_NOISE')
 
        def draw(self, context):
                layout = self.layout
-               tex = context.active_object.active_material.active_texture.texture
+               tex = context.texture
 
                layout.itemR(tex, "noise_distortion")
                layout.itemR(tex, "noise_basis", text="Basis")
@@ -342,6 +357,7 @@ class TEXTURE_PT_distortednoise(TextureButtonsPanel):
 
 bpy.types.register(TEXTURE_PT_preview)
 bpy.types.register(TEXTURE_PT_texture)
+bpy.types.register(TEXTURE_PT_colors)
 bpy.types.register(TEXTURE_PT_clouds)
 bpy.types.register(TEXTURE_PT_wood)
 bpy.types.register(TEXTURE_PT_marble)
index f12a76bfb669a269621dbad24d6780ee401bf044..79826e04dfce4d2539b0592f0b372acbedb14446 100644 (file)
@@ -7,7 +7,7 @@ class WorldButtonsPanel(bpy.types.Panel):
        __context__ = "world"
 
        def poll(self, context):
-               return (context.scene.world != None)
+               return (context.world != None)
 
 class WORLD_PT_preview(WorldButtonsPanel):
        __label__ = "Preview"
@@ -15,14 +15,14 @@ class WORLD_PT_preview(WorldButtonsPanel):
        def draw(self, context):
                layout = self.layout
 
-               world = context.scene.world
+               world = context.world
                layout.template_preview(world)
        
 class WORLD_PT_world(WorldButtonsPanel):
        __label__ = "World"
 
        def draw(self, context):
-               world = context.scene.world
+               world = context.world
                layout = self.layout
                
                row = layout.row()
@@ -32,14 +32,16 @@ class WORLD_PT_world(WorldButtonsPanel):
                
                row = layout.row()
                row.column().itemR(world, "horizon_color")
-               row.column().itemR(world, "zenith_color")
+               col = row.column()
+               col.itemR(world, "zenith_color")
+               col.active = world.blend_sky
                row.column().itemR(world, "ambient_color")
                
 class WORLD_PT_color_correction(WorldButtonsPanel):
        __label__ = "Color Correction"
 
        def draw(self, context):
-               world = context.scene.world
+               world = context.world
                layout = self.layout
 
                row = layout.row()
@@ -50,13 +52,13 @@ class WORLD_PT_mist(WorldButtonsPanel):
        __label__ = "Mist"
 
        def draw_header(self, context):
-               world = context.scene.world
+               world = context.world
 
                layout = self.layout
                layout.itemR(world.mist, "enabled", text="")
 
        def draw(self, context):
-               world = context.scene.world
+               world = context.world
                layout = self.layout
                layout.active = world.mist.enabled
 
@@ -73,13 +75,13 @@ class WORLD_PT_stars(WorldButtonsPanel):
        __label__ = "Stars"
 
        def draw_header(self, context):
-               world = context.scene.world
+               world = context.world
 
                layout = self.layout
                layout.itemR(world.stars, "enabled", text="")
 
        def draw(self, context):
-               world = context.scene.world
+               world = context.world
                layout = self.layout
                layout.active = world.stars.enabled
 
@@ -93,13 +95,13 @@ class WORLD_PT_ambient_occlusion(WorldButtonsPanel):
        __label__ = "Ambient Occlusion"
 
        def draw_header(self, context):
-               world = context.scene.world
+               world = context.world
 
                layout = self.layout
                layout.itemR(world.ambient_occlusion, "enabled", text="")
 
        def draw(self, context):
-               world = context.scene.world
+               world = context.world
                ao = world.ambient_occlusion
                layout = self.layout
                layout.active = ao.enabled
@@ -150,4 +152,4 @@ bpy.types.register(WORLD_PT_world)
 bpy.types.register(WORLD_PT_ambient_occlusion)
 bpy.types.register(WORLD_PT_mist)
 bpy.types.register(WORLD_PT_stars)
-bpy.types.register(WORLD_PT_color_correction)
\ No newline at end of file
+bpy.types.register(WORLD_PT_color_correction)
index db4d948216e1affe74d8e2e3aa2dc3ae674a9f8e..4efd9a7f8baf5dddeebecdb394a2bc6189b212ab 100644 (file)
@@ -251,7 +251,7 @@ struct ParticleSystemModifierData *psys_get_modifier(struct Object *ob, struct P
 
 struct ParticleSettings *psys_new_settings(char *name, struct Main *main);
 struct ParticleSettings *psys_copy_settings(struct ParticleSettings *part);
-void psys_flush_settings(struct Scene *scene, struct ParticleSettings *part, int event, int hair_recalc);
+void psys_flush_particle_settings(struct Scene *scene, struct ParticleSettings *part, int recalc);
 void make_local_particlesettings(struct ParticleSettings *part);
 
 struct LinkNode *psys_using_settings(struct Scene *scene, struct ParticleSettings *part, int flush_update);
index 5610db355e13fa70d8a7ffab38f378402dca36ef..ec8d28aee6cb054a53187aa1f4842b711e689953 100644 (file)
@@ -6347,8 +6347,7 @@ static void particleSystemModifier_deformVerts(
                  psmd->dm->getNumFaces(psmd->dm)!=psmd->totdmface){
                /* in file read dm hasn't really changed but just wasn't saved in file */
 
-               psys->recalc |= PSYS_RECALC_HAIR;
-               psys->recalc |= PSYS_DISTR;
+               psys->recalc |= PSYS_RECALC_RESET;
                psmd->flag |= eParticleSystemFlag_DM_changed;
 
                psmd->totdmvert= psmd->dm->getNumVerts(psmd->dm);
index 941e73982a5dbbc3cd4b02c56501cb6b4fb8ac80..43df11335febc07631ae6e4040b6545bc03ff9cd 100644 (file)
@@ -1055,6 +1055,14 @@ bNodeTree *ntreeAddTree(int type)
        ntree->type= type;
        ntree->alltypes.first = NULL;
        ntree->alltypes.last = NULL;
+
+       /* this helps RNA identify ID pointers as nodetree */
+    if(ntree->type==NTREE_SHADER)
+               BLI_strncpy(ntree->id.name, "NTShader Nodetree", sizeof(ntree->id.name));
+    else if(ntree->type==NTREE_COMPOSIT)
+               BLI_strncpy(ntree->id.name, "NTComposit Nodetree", sizeof(ntree->id.name));
+    else if(ntree->type==NTREE_TEXTURE)
+               BLI_strncpy(ntree->id.name, "NTTexture Nodetree", sizeof(ntree->id.name));
        
        ntreeInitTypes(ntree);
        return ntree;
index 7d998a481f68abcb094e8cef5a91bb52b1754013..6cef9959d8b61710dedc406dfda054bbd8a1a4f3 100644 (file)
@@ -348,8 +348,17 @@ void free_hair(ParticleSystem *psys, int softbody)
 }
 void free_keyed_keys(ParticleSystem *psys)
 {
-       if(psys->particles && psys->particles->keys)
+       if(psys->particles && psys->particles->keys) {
+               ParticleData *pa;
+               int i, totpart=psys->totpart;
+
                MEM_freeN(psys->particles->keys);
+
+               for(i=0, pa=psys->particles; i<totpart; i++,pa++){
+                       pa->keys = NULL;
+                       pa->totkey = 0;
+               }
+       }
 }
 void free_child_path_cache(ParticleSystem *psys)
 {
@@ -1739,12 +1748,12 @@ static void do_path_effectors(Scene *scene, Object *ob, ParticleSystem *psys, in
 
        Normalize(force);
 
+       VECADDFAC(ca->co, (ca-1)->co, force, *length);
+
        if(k < steps) {
                VecSubf(vec, (ca+1)->co, ca->co);
                *length = VecLength(vec);
        }
-
-       VECADDFAC(ca->co, (ca-1)->co, force, *length);
 }
 static int check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *state, float max_length, float *cur_length, float length, float *dvec)
 {
@@ -3052,42 +3061,22 @@ void make_local_particlesettings(ParticleSettings *part)
        }
 }
 
-/* should be integrated to depgraph signals */
-void psys_flush_settings(struct Scene *scene, ParticleSettings *part, int event, int hair_recalc)
+void psys_flush_particle_settings(Scene *scene, ParticleSettings *part, int recalc)
 {
-       Base *base;
-       Object *ob, *tob;
+       Base *base = scene->base.first;
        ParticleSystem *psys;
        int flush;
 
-       /* update all that have same particle settings */
-       for(base = scene->base.first; base; base= base->next) {
-               if(base->object->particlesystem.first) {
-                       ob=base->object;
-                       flush=0;
-                       for(psys=ob->particlesystem.first; psys; psys=psys->next){
-                               if(psys->part==part){
-                                       psys->recalc |= event;
-                                       if(hair_recalc)
-                                               psys->recalc |= PSYS_RECALC_HAIR;
-                                       flush++;
-                               }
-                               else if(psys->part->type==PART_REACTOR){
-                                       ParticleSystem *tpsys;
-                                       tob=psys->target_ob;
-                                       if(tob==0)
-                                               tob=ob;
-                                       tpsys=BLI_findlink(&tob->particlesystem,psys->target_psys-1);
-
-                                       if(tpsys && tpsys->part==part){
-                                               psys->recalc |= event;
-                                               flush++;
-                                       }
-                               }
+       for(base = scene->base.first; base; base = base->next) {
+               flush = 0;
+               for(psys = base->object->particlesystem.first; psys; psys=psys->next) {
+                       if(psys->part == part) {
+                               psys->recalc |= recalc;
+                               flush++;
                        }
-                       if(flush)
-                               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
                }
+               if(flush)
+                       DAG_object_flush_update(scene, base->object, OB_RECALC_DATA);
        }
 }
 
index f8b1852b728de8508c23977e9524aecfc5728b92..f097af279b6da5b7cb17c113efc5612952b0b33d 100644 (file)
@@ -4173,10 +4173,10 @@ static void psys_update_path_cache(Scene *scene, Object *ob, ParticleSystemModif
        ParticleEditSettings *pset=&scene->toolsettings->particle;
        int distr=0,alloc=0;
 
-       if((psys->part->childtype && psys->totchild != get_psys_tot_child(scene, psys)) || psys->recalc&PSYS_ALLOC)
+       if((psys->part->childtype && psys->totchild != get_psys_tot_child(scene, psys)) || psys->recalc&PSYS_RECALC_RESET)
                alloc=1;
 
-       if(alloc || psys->recalc&PSYS_DISTR || (psys->vgroup[PSYS_VG_DENSITY] && (G.f & G_WEIGHTPAINT)))
+       if(alloc || psys->recalc&PSYS_RECALC_RESET || (psys->vgroup[PSYS_VG_DENSITY] && (G.f & G_WEIGHTPAINT)))
                distr=1;
 
        if(distr){
@@ -4194,8 +4194,9 @@ static void psys_update_path_cache(Scene *scene, Object *ob, ParticleSystemModif
                }
        }
 
-       if((part->type==PART_HAIR || psys->flag&PSYS_KEYED) && (psys_in_edit_mode(scene, psys)
-               || (part->type==PART_HAIR || part->draw_as==PART_DRAW_PATH))){
+       if((part->type==PART_HAIR || psys->flag&PSYS_KEYED) && ( psys_in_edit_mode(scene, psys) || (part->type==PART_HAIR 
+               || (part->ren_as == PART_DRAW_PATH && (part->draw_as == PART_DRAW_REND || psys->renderdata))))){
+
                psys_cache_paths(scene, ob, psys, cfra, 0);
 
                /* for render, child particle paths are computed on the fly */
@@ -4247,7 +4248,7 @@ static void hair_step(Scene *scene, Object *ob, ParticleSystemModifierData *psmd
                        pa->flag &= ~PARS_NO_DISP;
        }
 
-       if(psys->recalc & PSYS_DISTR)
+       if(psys->recalc & PSYS_RECALC_RESET)
                /* need this for changing subsurf levels */
                psys_calc_dmcache(ob, psmd->dm, psys);
 
@@ -4367,16 +4368,14 @@ void psys_changed_type(ParticleSystem *psys)
                psys->flag &= ~PSYS_KEYED;
 
        if(part->type == PART_HAIR) {
-               part->draw_as = PART_DRAW_PATH;
-               part->rotfrom = PART_ROT_IINCR;
-       }
-       else {
-               free_hair(psys, 1);
+               if(ELEM4(part->ren_as, PART_DRAW_NOT, PART_DRAW_PATH, PART_DRAW_OB, PART_DRAW_GR)==0)
+                       part->ren_as = PART_DRAW_PATH;
 
-               if(part->draw_as == PART_DRAW_PATH)
-                       if(psys->part->phystype != PART_PHYS_KEYED)
-                               part->draw_as = PART_DRAW_DOT;
+               if(ELEM3(part->draw_as, PART_DRAW_NOT, PART_DRAW_REND, PART_DRAW_PATH)==0)
+                       part->draw_as = PART_DRAW_REND;
        }
+       else
+               free_hair(psys, 1);
 
        psys->softflag= 0;
 
@@ -4574,7 +4573,7 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
                init= 1;
        }
 
-       if(psys->recalc & PSYS_DISTR) {
+       if(psys->recalc & PSYS_RECALC_RESET) {
                distr= 1;
                init= 1;
        }
@@ -4594,6 +4593,8 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
                }
 
                if(only_children_changed==0) {
+                       free_keyed_keys(psys);
+
                        initialize_all_particles(ob, psys, psmd);
 
                        if(alloc)
@@ -4747,8 +4748,8 @@ static void psys_to_softbody(Scene *scene, Object *ob, ParticleSystem *psys)
 static int hair_needs_recalc(ParticleSystem *psys)
 {
        if((psys->flag & PSYS_EDITED)==0 &&
-               ((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_HAIR)) {
-               psys->recalc &= ~PSYS_RECALC_HAIR;
+               ((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_REDO)) {
+               psys->recalc &= ~PSYS_RECALC_REDO;
                return 1;
        }
 
@@ -4778,6 +4779,9 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
        if(!psmd->dm)
                return;
 
+       if(psys->recalc & PSYS_RECALC_TYPE)
+               psys_changed_type(psys);
+
        /* (re-)create hair */
        if(psys->part->type==PART_HAIR && hair_needs_recalc(psys)) {
                float hcfra=0.0f;
index 9c74014853d7d4ceb84de55452c5ad1e75e81361..b00755f7135bfeac50ef7ca60470e4a5c207d89f 100644 (file)
@@ -492,6 +492,8 @@ int BKE_ptcache_object_reset(Object *ob, int mode)
                        else
                                skip = 1;
                }
+               else if((psys->recalc & PSYS_RECALC_RESET)==0)
+                       skip = 1;
 
                if(skip == 0) {
                        BKE_ptcache_id_from_particles(&pid, ob, psys);
index 160b094392810979b890aace891be52450581f55..e3869d4bc8a06dc5daec823f9485bd2694f1f952 100644 (file)
@@ -4243,6 +4243,7 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                SpaceButs *sbuts= (SpaceButs *)sl;
                                                sbuts->lockpoin= NULL;
                                                sbuts->ri= NULL;
+                                               sbuts->pinid= newlibadr(fd, sc->id.lib, sbuts->pinid);
                                                if(main->versionfile<132)
                                                        butspace_version_132(sbuts);
                                        }
@@ -4444,6 +4445,7 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
                                else if(sl->spacetype==SPACE_BUTS) {
                                        SpaceButs *sbuts= (SpaceButs *)sl;
                                        sbuts->lockpoin= NULL;
+                                       sbuts->pinid = restore_pointer_by_name(newmain, sbuts->pinid, 0);
                                        //XXX if (sbuts->ri) sbuts->ri->curtile = 0;
                                }
                                else if(sl->spacetype==SPACE_FILE) {
@@ -4732,6 +4734,10 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
                                        direct_link_gpencil(fd, sseq->gpd);
                                }
                        }
+                       else if(sl->spacetype==SPACE_BUTS) {
+                               SpaceButs *sbuts= (SpaceButs *)sl;
+                               sbuts->path= NULL;
+                       }
                }
                
                sa->actionzones.first= sa->actionzones.last= NULL;
@@ -6802,26 +6808,26 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                        
                                                if(sbuts->mainb==BUTS_LAMP) {
                                                        sbuts->mainb= CONTEXT_SHADING;
-                                                       sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP;
+                                                       //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP;
                                                }
                                                else if(sbuts->mainb==BUTS_MAT) {
                                                        sbuts->mainb= CONTEXT_SHADING;
-                                                       sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT;
+                                                       //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT;
                                                }
                                                else if(sbuts->mainb==BUTS_TEX) {
                                                        sbuts->mainb= CONTEXT_SHADING;
-                                                       sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_TEX;
+                                                       //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_TEX;
                                                }
                                                else if(sbuts->mainb==BUTS_ANIM) {
                                                        sbuts->mainb= CONTEXT_OBJECT;
                                                }
                                                else if(sbuts->mainb==BUTS_WORLD) {
                                                        sbuts->mainb= CONTEXT_SCENE;
-                                                       sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_WORLD;
+                                                       //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_WORLD;
                                                }
                                                else if(sbuts->mainb==BUTS_RENDER) {
                                                        sbuts->mainb= CONTEXT_SCENE;
-                                                       sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_RENDER;
+                                                       //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_RENDER;
                                                }
                                                else if(sbuts->mainb==BUTS_GAME) {
                                                        sbuts->mainb= CONTEXT_LOGIC;
@@ -6831,7 +6837,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                                }
                                                else if(sbuts->mainb==BUTS_RADIO) {
                                                        sbuts->mainb= CONTEXT_SHADING;
-                                                       sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_RAD;
+                                                       //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_RAD;
                                                }
                                                else if(sbuts->mainb==BUTS_CONSTRAINT) {
                                                        sbuts->mainb= CONTEXT_OBJECT;
@@ -8458,7 +8464,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
 
                                                part->draw_as = PART_DRAW_PATH;
                                                part->type = PART_HAIR;
-                                               psys->recalc |= PSYS_RECALC_HAIR;
+                                               psys->recalc |= PSYS_RECALC_REDO;
 
                                                part->normfac *= fac;
                                                part->randfac *= fac;
@@ -8924,6 +8930,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                Mesh *me;
                Scene *sce;
                Tex *tx;
+               ParticleSettings *part;
                
                for(screen= main->screen.first; screen; screen= screen->id.next) {
                        do_versions_windowmanager_2_50(screen);
@@ -8965,6 +8972,23 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                for(me= main->mesh.first; me; me= me->id.next) {
                        me->drawflag= ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES;
                }
+
+               /* particle settings conversion */
+               for(part= main->particle.first; part; part= part->id.next) {
+                       if(part->draw_as) {
+                               if(part->draw_as == PART_DRAW_DOT) {
+                                       part->ren_as = PART_DRAW_HALO;
+                                       part->draw_as = PART_DRAW_REND;
+                               }
+                               else if(part->draw_as <= PART_DRAW_AXIS) {
+                                       part->ren_as = PART_DRAW_HALO;
+                               }
+                               else {
+                                       part->ren_as = part->draw_as;
+                                       part->draw_as = PART_DRAW_REND;
+                               }
+                       }
+               }
        }
 
        /* TODO: should be moved into one of the version blocks once this branch moves to trunk and we can
index 7cbef4984d7e8a9a68a97706bec0fcba0125dce0..34aefa9122549b8a1b029cab2b52237ef0804317 100644 (file)
@@ -35,7 +35,6 @@ struct SpaceFile;
 #define FILE_IMGDISPLAY                3
 
 typedef struct FileSelectParams {
-       int type; /* the mode of the filebrowser, FILE_BLENDER, FILE_SPECIAL, FILE_MAIN or FILE_LOADLIB */
        char title[24]; /* title, also used for the text of the execute button */
        char dir[240]; /* directory */
        char file[80]; /* file */
@@ -96,8 +95,8 @@ typedef struct FileLayout
 
 FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile);
 
-short ED_fileselect_set_params(struct SpaceFile *sfile, int type, const char *title, const char *path, 
-                                                  short flag, short display, short filter);
+short ED_fileselect_set_params(struct SpaceFile *sfile, const char *title, const char *path, 
+                                                  short flag, short display, short filter, short sort);
 
 void ED_fileselect_reset_params(struct SpaceFile *sfile);
 
index 3d0de795778cef82348bd8ce482f1b2c8a85d2bc..bfa819632c9fc22831bc4ebd267ed5bee3a45195 100644 (file)
@@ -56,7 +56,7 @@ void ED_base_object_free_and_unlink(struct Scene *scene, struct Base *base);
 
 void ED_object_apply_obmat(struct Object *ob);
        /* single object duplicate, if dupflag==0, fully linked, else it uses U.dupflag */
-Base *ED_object_add_duplicate(struct Scene *scene, struct Base *base, int usedupflag);
+struct Base *ED_object_add_duplicate(struct Scene *scene, struct Base *base, int usedupflag);
 
 
 /* bitflags for enter/exit editmode */
index 97c2da5297f61e2e5171217aa150e03cd8a3205e..6511d4d91ebc5c8bd7518243a4475593084ca181 100644 (file)
@@ -52,6 +52,7 @@ struct rctf;
 struct uiStyle;
 struct uiFontStyle;
 struct ColorBand;
+struct CurveMapping;
 
 typedef struct uiBut uiBut;
 typedef struct uiBlock uiBlock;
@@ -177,20 +178,21 @@ typedef struct uiLayout uiLayout;
 #define INLINK (23<<9)
 #define KEYEVT (24<<9)
 #define ICONTEXTROW (25<<9)
-#define HSVCUBE (26<<9)
-#define PULLDOWN (27<<9)
-#define ROUNDBOX (28<<9)
-#define CHARTAB (29<<9)
+#define HSVCUBE                (26<<9)
+#define PULLDOWN       (27<<9)
+#define ROUNDBOX       (28<<9)
+#define CHARTAB                (29<<9)
 #define BUT_COLORBAND (30<<9)
-#define BUT_NORMAL (31<<9)
-#define BUT_CURVE (32<<9)
+#define BUT_NORMAL     (31<<9)
+#define BUT_CURVE      (32<<9)
 #define BUT_TOGDUAL (33<<9)
-#define ICONTOGN (34<<9)
-#define FTPREVIEW (35<<9)
-#define NUMABS (36<<9)
-#define TOGBUT  (37<<9)
-#define OPTION  (38<<9)
-#define OPTIONN (39<<9)
+#define ICONTOGN       (34<<9)
+#define FTPREVIEW      (35<<9)
+#define NUMABS         (36<<9)
+#define TOGBUT         (37<<9)
+#define OPTION         (38<<9)
+#define OPTIONN                (39<<9)
+#define SEARCH_MENU    (40<<9)
 #define BUTTYPE        (63<<9)
 
 /* Drawing
@@ -401,6 +403,8 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg,
 
 void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip);
 
+uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, short x1, short y1, short x2, short y2, char *tip);
+
 void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval);
 void uiBlockColorbandButtons(struct uiBlock *block, struct ColorBand *coba, struct rctf *butr, int event);
 
@@ -425,20 +429,34 @@ uiBut *uiFindInlink(uiBlock *block, void *poin);
  *
  * uiButSetCompleteFunc is for tab completion.
  *
+ * uiButSearchFunc is for name buttons, showing a popup with matches
+ *
  * uiBlockSetFunc and uiButSetFunc are callbacks run when a button is used,
  * in case events, operators or RNA are not sufficient to handle the button.
  *
  * uiButSetNFunc will free the argument with MEM_freeN. */
 
+typedef struct uiSearchItems uiSearchItems;
+
 typedef void (*uiButHandleFunc)(struct bContext *C, void *arg1, void *arg2);
+typedef void (*uiButHandleRenameFunc)(struct bContext *C, void *arg, char *origstr);
 typedef void (*uiButHandleNFunc)(struct bContext *C, void *argN, void *arg2);
 typedef void (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg);
+typedef void (*uiButSearchFunc)(const struct bContext *C, void *arg, char *str, uiSearchItems *items);
 typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event);
+               
+               /* use inside searchfunc to add items */
+int            uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin);
+               /* bfunc gets search item *poin as arg2, or if NULL the old string */
+void   uiButSetSearchFunc      (uiBut *but,            uiButSearchFunc sfunc, void *arg1, uiButHandleFunc bfunc);
+               /* height in pixels, it's using hardcoded values still */
+int            uiSearchBoxhHeight(void);
 
 void   uiBlockSetHandleFunc(uiBlock *block,    uiBlockHandleFunc func, void *arg);
 void   uiBlockSetButmFunc      (uiBlock *block,        uiMenuHandleFunc func, void *arg);
 
 void   uiBlockSetFunc          (uiBlock *block,        uiButHandleFunc func, void *arg1, void *arg2);
+void   uiBlockSetRenameFunc(uiBlock *block,    uiButHandleRenameFunc func, void *arg1);
 void   uiButSetFunc            (uiBut *but,            uiButHandleFunc func, void *arg1, void *arg2);
 void   uiButSetNFunc           (uiBut *but,            uiButHandleNFunc func, void *argN, void *arg2);
 
@@ -497,9 +515,9 @@ void test_imapoin_but(struct bContext *C, char *name, struct ID **idpp);
 void autocomplete_bone(struct bContext *C, char *str, void *arg_v);
 void autocomplete_vgroup(struct bContext *C, char *str, void *arg_v);
 
-struct CurveMapping;
 struct rctf;
 void curvemap_buttons(uiBlock *block, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect);
+void colorband_buttons(uiBlock *block, struct ColorBand *coba, struct rctf *rect, int small);
 
 
 /* Module
@@ -539,9 +557,10 @@ uiBut *uiDefMenuTogR(uiBlock *block, struct PointerRNA *ptr, char *propname, cha
 #define UI_UNIT_X                              20
 #define UI_UNIT_Y                              20
 
-#define UI_LAYOUT_ALIGN_LEFT   0
-#define UI_LAYOUT_ALIGN_CENTER 1
-#define UI_LAYOUT_ALIGN_RIGHT  2
+#define UI_LAYOUT_ALIGN_EXPAND 0
+#define UI_LAYOUT_ALIGN_LEFT   1
+#define UI_LAYOUT_ALIGN_CENTER 2
+#define UI_LAYOUT_ALIGN_RIGHT  3
 
 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);
@@ -558,14 +577,16 @@ void uiLayoutSetEnabled(uiLayout *layout, int enabled);
 void uiLayoutSetRedAlert(uiLayout *layout, int redalert);
 void uiLayoutSetAlignment(uiLayout *layout, int alignment);
 void uiLayoutSetKeepAspect(uiLayout *layout, int keepaspect);
-void uiLayoutSetScale(uiLayout *layout, float scale);
+void uiLayoutSetScaleX(uiLayout *layout, float scale);
+void uiLayoutSetScaleY(uiLayout *layout, float scale);
 
 int uiLayoutGetActive(uiLayout *layout);
 int uiLayoutGetEnabled(uiLayout *layout);
 int uiLayoutGetRedAlert(uiLayout *layout);
 int uiLayoutGetAlignment(uiLayout *layout);
 int uiLayoutGetKeepAspect(uiLayout *layout);
-float uiLayoutGetScale(uiLayout *layout);
+float uiLayoutGetScaleX(uiLayout *layout);
+float uiLayoutGetScaleY(uiLayout *layout);
 
 /* layout specifiers */
 uiLayout *uiLayoutRow(uiLayout *layout, int align);
@@ -584,6 +605,8 @@ void uiTemplateHeaderID(uiLayout *layout, struct bContext *C, struct PointerRNA
 uiLayout *uiTemplateModifier(uiLayout *layout, struct PointerRNA *ptr);
 uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
 void uiTemplatePreview(uiLayout *layout, struct ID *id);
+void uiTemplateColorRamp(uiLayout *layout, struct ColorBand *coba, int expand);
+void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type);
 
 /* items */
 void uiItemO(uiLayout *layout, char *name, int icon, char *opname);
index 84ce3762f86b09b728316fa0fe63062f037f3ce2..5339a255dbcbd4fcc7603dd58d00021949ae3911 100644 (file)
@@ -1098,9 +1098,6 @@ void      UI_ColorPtrBlendShade3ubv(char *cp1, char *cp2, float fac, int offset);
 // get a 3 byte color, blended and shaded between two other char color pointers
 void   UI_GetColorPtrBlendShade3ubv(char *cp1, char *cp2, char *col, float fac, int offset);
 
-// get pointer from RNA pointer
-int            UI_GetIconRNA(struct PointerRNA *ptr);
-
 // internal (blender) usage only, for init and set active
 void   UI_SetTheme(int spacetype, int regionid);
 
index e9a886375c3b053f6a656e9d4affc46bf27fce7b..68973fe540c6620db4c6418cb8a9dea89eee3c23 100644 (file)
@@ -537,10 +537,17 @@ void uiEndBlock(const bContext *C, uiBlock *block)
                /* temp? Proper check for greying out */
                if(but->optype) {
                        wmOperatorType *ot= but->optype;
+
+                       if(but->context)
+                               CTX_store_set((bContext*)C, but->context);
+
                        if(ot==NULL || (ot->poll && ot->poll((bContext *)C)==0)) {
                                but->flag |= UI_BUT_DISABLED;
                                but->lock = 1;
                        }
+
+                       if(but->context)
+                               CTX_store_set((bContext*)C, NULL);
                }
 
                /* only update soft range while not editing */
@@ -1359,7 +1366,7 @@ int ui_get_but_string_max_length(uiBut *but)
 
 void ui_get_but_string(uiBut *but, char *str, int maxlen)
 {
-       if(but->rnaprop && ELEM(but->type, TEX, IDPOIN)) {
+       if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
                PropertyType type;
                char *buf= NULL;
 
@@ -1402,6 +1409,11 @@ void ui_get_but_string(uiBut *but, char *str, int maxlen)
                BLI_strncpy(str, but->poin, maxlen);
                return;
        }
+       else if(but->type == SEARCH_MENU) {
+               /* string */
+               BLI_strncpy(str, but->poin, maxlen);
+               return;
+       }
        else {
                /* number */
                double value;
@@ -1491,7 +1503,7 @@ static void ui_rna_ID_autocomplete(bContext *C, char *str, void *arg_but)
 
 int ui_set_but_string(bContext *C, uiBut *but, const char *str)
 {
-       if(but->rnaprop && ELEM(but->type, TEX, IDPOIN)) {
+       if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
                if(RNA_property_editable(&but->rnapoin, but->rnaprop)) {
                        PropertyType type;
 
@@ -1535,6 +1547,11 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
                BLI_strncpy(but->poin, str, but->hardmax);
                return 1;
        }
+       else if(but->type == SEARCH_MENU) {
+               /* string */
+               BLI_strncpy(but->poin, str, but->hardmax);
+               return 1;
+       }
        else {
                double value;
 
@@ -1817,11 +1834,11 @@ void ui_check_but(uiBut *but)
        /* if something changed in the button */
        double value;
        float okwidth;
-       int transopts= ui_translate_buttons();
+//     int transopts= ui_translate_buttons();
        
        ui_is_but_sel(but);
        
-       if(but->type==TEX || but->type==IDPOIN) transopts= 0;
+//     if(but->type==TEX || but->type==IDPOIN) transopts= 0;
 
        /* test for min and max, icon sliders, etc */
        switch( but->type ) {
@@ -1926,6 +1943,7 @@ void ui_check_but(uiBut *but)
 
        case IDPOIN:
        case TEX:
+       case SEARCH_MENU:
                if(!but->editstr) {
                        char str[UI_MAX_DRAW_STR];
 
@@ -2945,6 +2963,11 @@ void uiBlockSetFunc(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2
        block->func_arg2= arg2;
 }
 
+void uiBlockSetRenameFunc(uiBlock *block, uiButHandleRenameFunc func, void *arg1)
+{
+       
+}
+
 void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)())
 {
        block->drawextra= func;
@@ -3065,6 +3088,32 @@ void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1,
        ui_check_but(but);
 }
 
+/* arg is pointer to string/name, use uiButSetSearchFunc() below to make this work */
+uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, short x1, short y1, short x2, short y2, char *tip)
+{
+       uiBut *but= ui_def_but(block, SEARCH_MENU, retval, "", x1, y1, x2, y2, arg, 0.0, maxlen, 0.0, 0.0, tip);
+       
+       but->icon= (BIFIconID) icon;
+       but->flag|= UI_HAS_ICON;
+       
+       but->flag|= UI_ICON_LEFT|UI_TEXT_LEFT;
+       but->flag|= UI_ICON_SUBMENU;
+       
+       ui_check_but(but);
+       
+       return but;
+}
+
+/* arg is user value, searchfunc and handlefunc both get it as arg */
+void uiButSetSearchFunc(uiBut *but, uiButSearchFunc sfunc, void *arg, uiButHandleFunc bfunc)
+{
+       but->search_func= sfunc;
+       but->search_arg= arg;
+       
+       uiButSetFunc(but, bfunc, arg, NULL);
+}
+
+
 /* Program Init/Exit */
 
 void UI_init(void)
index 2bbaee857d1704a622050015db179457d893e4af..5aff0c0ad824ed4f7947e30d8152e88a193459b8 100644 (file)
@@ -54,6 +54,12 @@ void RNA_api_ui_layout(StructRNA *srna)
        FunctionRNA *func;
        PropertyRNA *parm;
 
+       static EnumPropertyItem curve_type_items[] = {
+               {0, "NONE", "None", ""},
+               {'v', "VECTOR", "Vector", ""},
+               {'c', "COLOR", "Color", ""},
+               {0, NULL, NULL, NULL}};
+
        /* simple layout specifiers */
        func= RNA_def_function(srna, "row", "uiLayoutRow");
        parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
@@ -214,5 +220,14 @@ void RNA_api_ui_layout(StructRNA *srna)
        parm= RNA_def_pointer(func, "id", "ID", "", "ID datablock.");
        RNA_def_property_flag(parm, PROP_REQUIRED);
 
+       func= RNA_def_function(srna, "template_curve_mapping", "uiTemplateCurveMapping");
+       parm= RNA_def_pointer(func, "curvemap", "CurveMapping", "", "Curve mapping pointer.");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display.");
+
+       func= RNA_def_function(srna, "template_color_ramp", "uiTemplateColorRamp");
+       parm= RNA_def_pointer(func, "ramp", "ColorRamp", "", "Color ramp pointer.");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail.");
 }
 
index ec2f960dd1465141481a94e3cdd958a5a42ab622..933d57c89832b0d4fce71102bb8cc3394211255b 100644 (file)
@@ -97,7 +97,7 @@ typedef struct uiHandleButtonData {
 
        /* overall state */
        uiHandleButtonState state;
-       int cancel, retval;
+       int cancel, escapecancel, retval;
        int applied, appliedinteractive;
        wmTimer *flashtimer;
 
@@ -127,6 +127,9 @@ typedef struct uiHandleButtonData {
        /* menu open */
        uiPopupBlockHandle *menu;
        int menuretval;
+       
+       /* search box */
+       ARegion *searchbox;
 
        /* post activate */
        uiButtonActivateType posttype;
@@ -139,7 +142,8 @@ typedef struct uiAfterFunc {
        uiButHandleFunc func;
        void *func_arg1;
        void *func_arg2;
-
+       void *func_arg3;
+       
        uiButHandleNFunc funcN;
        void *func_argN;
 
@@ -157,6 +161,8 @@ typedef struct uiAfterFunc {
 
        PointerRNA rnapoin;
        PropertyRNA *rnaprop;
+
+       bContextStore *context;
 } uiAfterFunc;
 
 static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state);
@@ -228,6 +234,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
                after->func= but->func;
                after->func_arg1= but->func_arg1;
                after->func_arg2= but->func_arg2;
+               after->func_arg3= but->func_arg3;
 
                after->funcN= but->funcN;
                after->func_argN= but->func_argN;
@@ -249,6 +256,9 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
                after->rnapoin= but->rnapoin;
                after->rnaprop= but->rnaprop;
 
+               if(but->context)
+                       after->context= CTX_store_copy(but->context);
+
                but->optype= NULL;
                but->opcontext= 0;
                but->opptr= NULL;
@@ -270,6 +280,9 @@ static void ui_apply_but_funcs_after(bContext *C)
                after= *afterf; /* copy to avoid memleak on exit() */
                BLI_freelinkN(&funcs, afterf);
 
+               if(after.context)
+                       CTX_store_set(C, after.context);
+
                if(after.func)
                        after.func(C, after.func_arg1, after.func_arg2);
                if(after.funcN)
@@ -289,6 +302,11 @@ static void ui_apply_but_funcs_after(bContext *C)
 
                if(after.rnapoin.data)
                        RNA_property_update(C, &after.rnapoin, after.rnaprop);
+
+               if(after.context) {
+                       CTX_store_set(C, NULL);
+                       CTX_store_free(after.context);
+               }
        }
 }
 
@@ -402,9 +420,10 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data)
 
        /* give butfunc the original text too */
        /* feature used for bone renaming, channels, etc */
-       if(but->func_arg2==NULL) but->func_arg2= data->origstr;
+       /* XXX goes via uiButHandleRenameFunc now */
+//     if(but->func_arg2==NULL) but->func_arg2= data->origstr;
        ui_apply_but_func(C, but);
-       if(but->func_arg2==data->origstr) but->func_arg2= NULL;
+//     if(but->func_arg2==data->origstr) but->func_arg2= NULL;
 
        data->retval= but->retval;
        data->applied= 1;
@@ -557,6 +576,7 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
                        ui_apply_but_BUT(C, but, data);
                        break;
                case TEX:
+               case SEARCH_MENU:
                        ui_apply_but_TEX(C, but, data);
                        break;
                case TOGBUT: 
@@ -871,7 +891,7 @@ static int ui_textedit_type_ascii(uiBut *but, uiHandleButtonData *data, char asc
                }
        }
 
-       return WM_UI_HANDLER_BREAK;
+       return changed;
 }
 
 void ui_textedit_move(uiBut *but, uiHandleButtonData *data, int direction, int select, int jump)
@@ -1030,7 +1050,7 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio
        else { /* backspace */
                if(len!=0) {
                        if ((but->selend - but->selsta) > 0) {
-                               ui_textedit_delete_selection(but, data);
+                               changed= ui_textedit_delete_selection(but, data);
                        }
                        else if(but->pos>0) {
                                for(x=but->pos; x<len; x++)
@@ -1124,7 +1144,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste
        return changed;
 }
 
-static void ui_textedit_begin(uiBut *but, uiHandleButtonData *data)
+static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
 {
        if(data->str) {
                MEM_freeN(data->str);
@@ -1146,13 +1166,27 @@ static void ui_textedit_begin(uiBut *but, uiHandleButtonData *data)
        but->selsta= 0;
        but->selend= strlen(but->drawstr) - strlen(but->str);
 
+       /* optional searchbox */
+       if(but->type==SEARCH_MENU) {
+               data->searchbox= ui_searchbox_create(C, data->region, but);
+               ui_searchbox_update(C, data->searchbox, but, 1); /* 1= reset */
+       }
+       
        ui_check_but(but);
 }
 
-static void ui_textedit_end(uiBut *but, uiHandleButtonData *data)
+static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
 {
        if(but) {
-               but->editstr= 0;
+               if(data->searchbox) {
+                       if(data->cancel==0)
+                               ui_searchbox_apply(but, data->searchbox);
+
+                       ui_searchbox_free(C, data->searchbox);
+                       data->searchbox= NULL;
+               }
+               
+               but->editstr= NULL;
                but->pos= -1;
        }
 }
@@ -1205,18 +1239,30 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
        }
 }
 
+
 static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
 {
-       int mx, my, changed= 0, retval= WM_UI_HANDLER_CONTINUE;
+       int mx, my, changed= 0, inbox=0, retval= WM_UI_HANDLER_CONTINUE;
 
        switch(event->type) {
+               case MOUSEMOVE:
+                       if(data->searchbox)
+                               ui_searchbox_event(C, data->searchbox, but, event);
+                       
+                       break;
                case RIGHTMOUSE:
                case ESCKEY:
                        data->cancel= 1;
+                       data->escapecancel= 1;
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                        retval= WM_UI_HANDLER_BREAK;
                        break;
                case LEFTMOUSE: {
+                       
+                       /* exit on LMB only on RELEASE for searchbox, to mimic other popups, and allow multiple menu levels */
+                       if(data->searchbox)
+                               inbox= BLI_in_rcti(&data->searchbox->winrct, event->x, event->y);
+
                        if(event->val==KM_PRESS) {
                                mx= event->x;
                                my= event->y;
@@ -1230,11 +1276,18 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
                                        button_activate_state(C, but, BUTTON_STATE_TEXT_SELECTING);
                                        retval= WM_UI_HANDLER_BREAK;
                                }
-                               else {
+                               else if(inbox==0) {
+                                       /* if searchbox, click outside will cancel */
+                                       if(data->searchbox)
+                                               data->cancel= data->escapecancel= 1;
                                        button_activate_state(C, but, BUTTON_STATE_EXIT);
                                        retval= WM_UI_HANDLER_BREAK;
                                }
                        }
+                       else if(inbox) {
+                               button_activate_state(C, but, BUTTON_STATE_EXIT);
+                               retval= WM_UI_HANDLER_BREAK;
+                       }
                        break;
                }
        }
@@ -1264,11 +1317,21 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
                                retval= WM_UI_HANDLER_BREAK;
                                break;
                        case DOWNARROWKEY:
+                               if(data->searchbox) {
+                                       ui_searchbox_event(C, data->searchbox, but, event);
+                                       break;
+                               }
+                               /* pass on purposedly */
                        case ENDKEY:
                                ui_textedit_move_end(but, data, 1, event->shift);
                                retval= WM_UI_HANDLER_BREAK;
                                break;
                        case UPARROWKEY:
+                               if(data->searchbox) {
+                                       ui_searchbox_event(C, data->searchbox, but, event);
+                                       break;
+                               }
+                               /* pass on purposedly */
                        case HOMEKEY:
                                ui_textedit_move_end(but, data, 0, event->shift);
                                retval= WM_UI_HANDLER_BREAK;
@@ -1316,6 +1379,9 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
        if(changed) {
                if(data->interactive) ui_apply_button(C, block, but, data, 1);
                else ui_check_but(but);
+               
+               if(data->searchbox)
+                       ui_searchbox_update(C, data->searchbox, but, 1); /* 1 = reset */
        }
 
        if(changed || (retval == WM_UI_HANDLER_BREAK))
@@ -1549,7 +1615,7 @@ static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, w
 static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
 {
        if(data->state == BUTTON_STATE_HIGHLIGHT) {
-               if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
+               if(ELEM4(event->type, LEFTMOUSE, PADENTER, RETKEY, EVT_BUT_OPEN) && event->val==KM_PRESS) {
                        button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
                        return WM_UI_HANDLER_BREAK;
                }
@@ -1710,7 +1776,12 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
                }
        }
        else if(data->state == BUTTON_STATE_NUM_EDITING) {
-               if(event->type == LEFTMOUSE && event->val!=KM_PRESS) {
+               if(event->type == ESCKEY) {
+                       data->cancel= 1;
+                       data->escapecancel= 1;
+                       button_activate_state(C, but, BUTTON_STATE_EXIT);
+               }
+               else if(event->type == LEFTMOUSE && event->val!=KM_PRESS) {
                        if(data->dragchange)
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                        else
@@ -1906,7 +1977,12 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
                }
        }
        else if(data->state == BUTTON_STATE_NUM_EDITING) {
-               if(event->type == LEFTMOUSE && event->val!=KM_PRESS) {
+               if(event->type == ESCKEY) {
+                       data->cancel= 1;
+                       data->escapecancel= 1;
+                       button_activate_state(C, but, BUTTON_STATE_EXIT);
+               }
+               else if(event->type == LEFTMOUSE && event->val!=KM_PRESS) {
                        if(data->dragchange)
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                        else
@@ -2702,6 +2778,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
                break;
        case TEX:
        case IDPOIN:
+       case SEARCH_MENU:
                retval= ui_do_but_TEX(C, block, but, data, event);
                break;
        case MENU:
@@ -2928,9 +3005,9 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
 
        /* text editing */
        if(state == BUTTON_STATE_TEXT_EDITING && data->state != BUTTON_STATE_TEXT_SELECTING)
-               ui_textedit_begin(but, data);
+               ui_textedit_begin(C, but, data);
        else if(data->state == BUTTON_STATE_TEXT_EDITING && state != BUTTON_STATE_TEXT_SELECTING)
-               ui_textedit_end(but, data);
+               ui_textedit_end(C, but, data);
        
        /* number editing */
        if(state == BUTTON_STATE_NUM_EDITING)
@@ -2982,7 +3059,9 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
        data= MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData");
        data->window= CTX_wm_window(C);
        data->region= ar;
-       data->interactive= but->type==BUT_CURVE?0:1; // XXX temp
+       if( ELEM(but->type, BUT_CURVE, SEARCH_MENU) );  // XXX curve is temp
+       else data->interactive= 1;
+       
        data->state = BUTTON_STATE_INIT;
 
        /* activate button */
@@ -3035,12 +3114,14 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
        /* if this button is in a menu, this will set the button return
         * value to the button value and the menu return value to ok, the
         * menu return value will be picked up and the menu will close */
-       if(block->handle && !(block->flag & UI_BLOCK_KEEP_OPEN) && !data->cancel) {
-               uiPopupBlockHandle *menu;
+       if(block->handle && !(block->flag & UI_BLOCK_KEEP_OPEN)) {
+               if(!data->cancel || data->escapecancel) {
+                       uiPopupBlockHandle *menu;
 
-               menu= block->handle;
-               menu->butretval= data->retval;
-               menu->menuretval= UI_RETURN_OK;
+                       menu= block->handle;
+                       menu->butretval= data->retval;
+                       menu->menuretval= (data->cancel)? UI_RETURN_CANCEL: UI_RETURN_OK;
+               }
        }
 
        /* disable tooltips until mousemove */
@@ -3084,16 +3165,35 @@ void ui_button_active_cancel(const bContext *C, uiBut *but)
 
 /************** handle activating a button *************/
 
+static uiBut *uit_but_find_open_event(ARegion *ar, wmEvent *event)
+{
+       uiBlock *block;
+       uiBut *but;
+       
+       for(block=ar->uiblocks.first; block; block=block->next) {
+               for(but=block->buttons.first; but; but= but->next)
+                       if(but==event->customdata)
+                               return but;
+       }
+       return NULL;
+}
+
 static int ui_handle_button_over(bContext *C, wmEvent *event, ARegion *ar)
 {
        uiBut *but;
 
        if(event->type == MOUSEMOVE) {
                but= ui_but_find_mouse_over(ar, event->x, event->y);
-
                if(but)
                        button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER);
        }
+       else if(event->type == EVT_BUT_OPEN) {
+               but= uit_but_find_open_event(ar, event);
+               if(but) {
+                       button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER);
+                       ui_do_button(C, but->block, but, event);
+               }
+       }
 
        return WM_UI_HANDLER_CONTINUE;
 }
index 25a1dbe3d6221a73d799521e453fe860cade6610..c6a93d8f74a45d46e6899bd17e082abdf86c8f31 100644 (file)
@@ -164,6 +164,7 @@ struct uiBut {
        uiButHandleFunc func;
        void *func_arg1;
        void *func_arg2;
+       void *func_arg3;
 
        uiButHandleNFunc funcN;
        void *func_argN;
@@ -176,6 +177,9 @@ struct uiBut {
        uiButCompleteFunc autocomplete_func;
        void *autofunc_arg;
        
+       uiButSearchFunc search_func;
+       void *search_arg;
+       
        uiLink *link;
        
        char *tip, *lockstr;
@@ -351,6 +355,13 @@ uiBlock *ui_block_func_COL(struct bContext *C, uiPopupBlockHandle *handle, void
 struct ARegion *ui_tooltip_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
 void ui_tooltip_free(struct bContext *C, struct ARegion *ar);
 
+/* searchbox for string button */
+ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
+void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but, int reset);
+void ui_searchbox_event(struct bContext *C, struct ARegion *ar, uiBut *but, struct wmEvent *event);
+void ui_searchbox_apply(uiBut *but, struct ARegion *ar);
+void ui_searchbox_free(struct bContext *C, struct ARegion *ar);
+
 typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1);
 
 uiPopupBlockHandle *ui_popup_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but,
@@ -389,11 +400,15 @@ extern int ui_button_is_active(struct ARegion *ar);
 /* interface_widgets.c */
 void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
 void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
+void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect);
+
 extern void ui_draw_but(ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect);
                /* theme color init */
 struct ThemeUI;
 void ui_widget_color_init(struct ThemeUI *tui);
 
+void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, char *name, int state);
+
 /* interface_style.c */
 void uiStyleInit(void);
 
index 2e123c2833943b7e980aee2113af95c06c12a966..8ef1cd32f224d3c486f789f24092557f63c45894 100644 (file)
@@ -115,6 +115,7 @@ typedef enum uiItemType {
 typedef struct uiItem {
        void *next, *prev;
        uiItemType type;
+       int flag;
 } uiItem;
 
 typedef struct uiButtonItem {
@@ -130,7 +131,7 @@ struct uiLayout {
        ListBase items;
 
        int x, y, w, h;
-       float scale;
+       float scale[2];
        short space;
        char align;
        char active;
@@ -177,26 +178,29 @@ static char *ui_item_name_add_colon(char *name, char namestr[UI_MAX_NAME_STR])
        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)
+static int ui_item_fit(int item, int pos, int all, int available, int last, int alignment, int *offset)
 {
        /* available == 0 is unlimited */
-
-       if(available != 0 && all > available-spacing) {
+       if(available == 0)
+               return item;
+       
+       if(offset)
+               *offset= 0;
+       
+       if(all > available) {
                /* contents is bigger than available space */
                if(last)
                        return available-pos;
                else
-                       return (item*(available-spacing))/all;
+                       return (item*available)/all;
        }
        else {
                /* contents is smaller or equal to available space */
-               if(available != 0 && (flag & UI_FIT_EXPAND)) {
+               if(alignment == UI_LAYOUT_ALIGN_EXPAND) {
                        if(last)
                                return available-pos;
                        else
-                               return (item*(available-spacing))/all;
+                               return (item*available)/all;
                }
                else
                        return item;
@@ -209,7 +213,7 @@ static int ui_item_fit(int item, int pos, int all, int available, int spacing, i
 
 static int ui_layout_vary_direction(uiLayout *layout)
 {
-       return (layout->root->type == UI_LAYOUT_HEADER)? UI_ITEM_VARY_X: UI_ITEM_VARY_Y;
+       return (layout->root->type == UI_LAYOUT_HEADER || layout->alignment != UI_LAYOUT_ALIGN_EXPAND)? UI_ITEM_VARY_X: UI_ITEM_VARY_Y;
 }
 
 /* estimated size of text + icon */
@@ -220,9 +224,9 @@ static int ui_text_icon_width(uiLayout *layout, char *name, int icon)
        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 */
+               return (variable)? UI_GetStringWidth(name) + 4 + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */
        else
-               return (variable)? UI_GetStringWidth(name) + UI_UNIT_X: 10*UI_UNIT_X; /* text only */
+               return (variable)? UI_GetStringWidth(name) + 4 + UI_UNIT_X: 10*UI_UNIT_X; /* text only */
 }
 
 static void ui_item_size(uiItem *item, int *r_w, int *r_h)
@@ -655,9 +659,6 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA
        subtype= RNA_property_subtype(prop);
        len= RNA_property_array_length(prop);
 
-       if(ELEM(type, PROP_STRING, PROP_ENUM))
-               w += 10*UI_UNIT_X;
-
        /* increase height for arrays */
        if(index == RNA_NO_INDEX && len > 0) {
                if(strcmp(name, "") == 0 && icon == 0)
@@ -1033,14 +1034,22 @@ static void ui_litem_estimate_row(uiLayout *litem)
        }
 }
 
+static int ui_litem_min_width(int itemw)
+{
+       return MIN2(UI_UNIT_X, itemw);
+}
+
 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;
+       int x, y, w, tot, totw, neww, itemw, minw, itemh, offset;
+       int fixedw, freew, fixedx, freex, flag= 0, lastw= 0;
 
        x= litem->x;
        y= litem->y;
        w= litem->w;
+       totw= 0;
+       tot= 0;
 
        for(item=litem->items.first; item; item=item->next) {
                ui_item_size(item, &itemw, &itemh);
@@ -1051,40 +1060,81 @@ static void ui_litem_layout_row(uiLayout *litem)
        if(totw == 0)
                return;
        
-       /* 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);
+       if(w != 0)
+               w -= (tot-1)*litem->space;
+       fixedw= 0;
 
-               itemw= ui_item_fit(itemw, x-litem->x, totw, w, (tot-1)*litem->space, !item->next, UI_FIT_EXPAND);
-               x += itemw;
+       /* keep clamping items to fixed minimum size until all are done */
+       do {
+               freew= 0;
+               x= 0;
+               flag= 0;
 
-               if(itemw < UI_UNIT_X)
-                       extra += UI_UNIT_X - itemw;
-               else
-                       available += itemw - UI_UNIT_X;
+               for(item=litem->items.first; item; item=item->next) {
+                       if(item->flag)
+                               continue;
 
-               if(item->next)
-                       x += litem->space;
-       }
+                       ui_item_size(item, &itemw, &itemh);
+                       minw= ui_litem_min_width(itemw);
+
+                       if(w - lastw > 0)
+                               neww= ui_item_fit(itemw, x, totw, w-lastw, !item->next, litem->alignment, NULL);
+                       else
+                               neww= 0; /* no space left, all will need clamping to minimum size */
 
+                       x += neww;
+
+                       if(neww < minw && w != 0) {
+                               /* fixed size */
+                               item->flag= 1;
+                               fixedw += minw;
+                               flag= 1;
+                               totw -= itemw;
+                       }
+                       else {
+                               /* keep free size */
+                               item->flag= 0;
+                               freew += itemw;
+                       }
+               }
+
+               lastw= fixedw;
+       } while(flag);
+
+       freex= 0;
+       fixedx= 0;
        x= litem->x;
 
        for(item=litem->items.first; item; item=item->next) {
                ui_item_size(item, &itemw, &itemh);
+               minw= ui_litem_min_width(itemw);
 
-               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);
+               if(item->flag) {
+                       /* fixed minimum size items */
+                       itemw= ui_item_fit(minw, fixedx, fixedw, MIN2(w, fixedw), !item->next, litem->alignment, NULL);
+                       fixedx += itemw;
+               }
+               else {
+                       /* free size item */
+                       itemw= ui_item_fit(itemw, freex, freew, w-fixedw, !item->next, litem->alignment, NULL);
+                       freex += itemw;
                }
-               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;
+               /* align right/center */
+               offset= 0;
+               if(litem->alignment == UI_LAYOUT_ALIGN_RIGHT) {
+                       if(fixedw == 0 && freew < w-fixedw)
+                               offset= (w - fixedw) - freew;
+               }
+               else if(litem->alignment == UI_LAYOUT_ALIGN_CENTER) {
+                       if(fixedw == 0 && freew < w-fixedw)
+                               offset= ((w - fixedw) - freew)/2;
+               }
+
+               /* position item */
+               ui_item_position(item, x+offset, y-itemh, itemw, itemh);
 
+               x += itemw;
                if(item->next)
                        x += litem->space;
        }
@@ -1263,7 +1313,7 @@ static void ui_litem_layout_column_flow(uiLayout *litem)
        uiLayoutItemFlow *flow= (uiLayoutItemFlow*)litem;
        uiItem *item;
        int col, x, y, w, emh, emy, miny, itemw, itemh;
-       int toth, totitem;
+       int toth, totitem, offset;
 
        /* compute max needed width and total height */
        toth= 0;
@@ -1280,18 +1330,18 @@ static void ui_litem_layout_column_flow(uiLayout *litem)
        emy= 0;
        miny= 0;
 
-       w= litem->w;
+       w= litem->w - (flow->totcol-1)*style->columnspace;
        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);
+               itemw= ui_item_fit(1, x-litem->x, flow->totcol, w, col == flow->totcol-1, litem->alignment, &offset);
        
                y -= itemh;
                emy -= itemh;
-               ui_item_position(item, x, y, itemw, itemh);
+               ui_item_position(item, x+offset, y, itemw, itemh);
                y -= style->buttonspacey;
                miny= MIN2(miny, y);
 
@@ -1578,9 +1628,14 @@ void uiLayoutSetAlignment(uiLayout *layout, int alignment)
        layout->alignment= alignment;
 }
 
-void uiLayoutSetScale(uiLayout *layout, float scale)
+void uiLayoutSetScaleX(uiLayout *layout, float scale)
 {
-       layout->scale= scale;
+       layout->scale[0]= scale;
+}
+
+void uiLayoutSetScaleY(uiLayout *layout, float scale)
+{
+       layout->scale[1]= scale;
 }
 
 int uiLayoutGetActive(uiLayout *layout)
@@ -1608,13 +1663,41 @@ int uiLayoutGetAlignment(uiLayout *layout)
        return layout->alignment;
 }
 
-float uiLayoutGetScale(uiLayout *layout)
+float uiLayoutGetScaleX(uiLayout *layout)
 {
-       return layout->scale;
+       return layout->scale[0];
+}
+
+float uiLayoutGetScaleY(uiLayout *layout)
+{
+       return layout->scale[0];
 }
 
 /********************** Layout *******************/
 
+static void ui_item_scale(uiLayout *litem, float scale[2])
+{
+       uiItem *item;
+       int x, y, w, h;
+
+       for(item=litem->items.last; item; item=item->prev) {
+               ui_item_size(item, &w, &h);
+               ui_item_offset(item, &x, &y);
+
+               if(scale[0] != 0.0f) {
+                       x *= scale[0];
+                       w *= scale[0];
+               }
+
+               if(scale[1] != 0.0f) {
+                       y *= scale[1];
+                       h *= scale[1];
+               }
+
+               ui_item_position(item, x, y, w, h);
+       }
+}
+
 static void ui_item_estimate(uiItem *item)
 {
        uiItem *subitem;
@@ -1628,6 +1711,9 @@ static void ui_item_estimate(uiItem *item)
                if(litem->items.first == NULL)
                        return;
 
+               if(litem->scale[0] != 0.0f || litem->scale[1] != 0.0f)
+                       ui_item_scale(litem, litem->scale);
+
                switch(litem->item.type) {
                        case ITEM_LAYOUT_COLUMN:
                                ui_litem_estimate_column(litem);
index 539f18c2cd81693821e53478d10fcb158d3a2762..a141e58fbe9802ef4fb9b9806fb1f58634c9e7ad 100644 (file)
@@ -119,7 +119,7 @@ static int panels_re_align(ScrArea *sa, ARegion *ar, Panel **r_pa)
                SpaceButs *sbuts= sa->spacedata.first;
 
                if(sbuts->align)
-                       if(sbuts->re_align || sbuts->mainbo!=sbuts->mainb || sbuts->tabo!=sbuts->tab[sbuts->mainb])
+                       if(sbuts->re_align || sbuts->mainbo!=sbuts->mainb)
                                return 1;
        }
        else if(ar->regiontype==RGN_TYPE_UI)
index 0109612fdc0eab1a70378783b1185fe830890657..8ea686dfbd6ba728e73f798d3a92a7417db34512 100644 (file)
@@ -56,6 +56,7 @@
 #include "BIF_gl.h"
 
 #include "UI_interface.h"
+#include "UI_interface_icons.h"
 #include "UI_view2d.h"
 
 #include "BLF_api.h"
@@ -383,6 +384,358 @@ void ui_tooltip_free(bContext *C, ARegion *ar)
        ui_remove_temporary_region(C, CTX_wm_screen(C), ar);
 }
 
+
+/************************* Creating Search Box **********************/
+
+struct uiSearchItems {
+       int maxitem, totitem, maxstrlen;
+       
+       int offset, offset_i; /* offset for inserting in array */
+       int more;  /* flag indicating there are more items */
+       
+       char **names;
+       void **pointers;
+       
+};
+
+typedef struct uiSearchboxData {
+       rcti bbox;
+       uiFontStyle fstyle;
+       uiSearchItems items;
+       int active;             /* index in items array */
+       int noback;             /* when menu opened with enough space for this */
+} uiSearchboxData;
+
+#define SEARCH_ITEMS   10
+
+/* exported for use by search callbacks */
+/* returns zero if nothing to add */
+int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin)
+{
+       
+       if(items->totitem>=items->maxitem) {
+               items->more= 1;
+               return 0;
+       }
+       
+       /* skip first items in list */
+       if(items->offset_i > 0) {
+               items->offset_i--;
+               return 1;
+       }
+       
+       BLI_strncpy(items->names[items->totitem], name, items->maxstrlen);
+       items->pointers[items->totitem]= poin;
+       
+       items->totitem++;
+       
+       return 1;
+}
+
+int uiSearchBoxhHeight(void)
+{
+       return SEARCH_ITEMS*MENU_BUTTON_HEIGHT + 2*MENU_TOP;
+}
+
+/* ar is the search box itself */
+static void ui_searchbox_select(bContext *C, ARegion *ar, uiBut *but, int step)
+{
+       uiSearchboxData *data= ar->regiondata;
+       
+       /* apply step */
+       data->active+= step;
+       
+       if(data->items.totitem==0)
+               data->active= 0;
+       else if(data->active > data->items.totitem) {
+               if(data->items.more) {
+                       data->items.offset++;
+                       data->active= data->items.totitem;
+                       ui_searchbox_update(C, ar, but, 0);
+               }
+               else
+                       data->active= data->items.totitem;
+       }
+       else if(data->active < 1) {
+               if(data->items.offset) {
+                       data->items.offset--;
+                       data->active= 1;
+                       ui_searchbox_update(C, ar, but, 0);
+               }
+               else if(data->active < 0)
+                       data->active= 0;
+       }
+       
+       ED_region_tag_redraw(ar);
+}
+
+static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr)
+{
+       int buth= (data->bbox.ymax-data->bbox.ymin - 2*MENU_TOP)/SEARCH_ITEMS;
+       
+       *rect= data->bbox;
+       rect->xmin= data->bbox.xmin + 3.0f;
+       rect->xmax= data->bbox.xmax - 3.0f;
+       
+       rect->ymax= data->bbox.ymax - MENU_TOP - itemnr*buth;
+       rect->ymin= rect->ymax - buth;
+       
+}
+
+/* string validated to be of correct length (but->hardmax) */
+void ui_searchbox_apply(uiBut *but, ARegion *ar)
+{
+       uiSearchboxData *data= ar->regiondata;
+
+       but->func_arg2= NULL;
+       
+       if(data->active) {
+               char *name= data->items.names[data->active-1];
+               char *cpoin= strchr(name, '|');
+               
+               if(cpoin) cpoin[0]= 0;
+               BLI_strncpy(but->editstr, name, data->items.maxstrlen);
+               if(cpoin) cpoin[0]= '|';
+               
+               but->func_arg2= data->items.pointers[data->active-1];
+       }
+}
+
+void ui_searchbox_event(bContext *C, ARegion *ar, uiBut *but, wmEvent *event)
+{
+       uiSearchboxData *data= ar->regiondata;
+       
+       switch(event->type) {
+               case UPARROWKEY:
+                       ui_searchbox_select(C, ar, but, -1);
+                       break;
+               case DOWNARROWKEY:
+                       ui_searchbox_select(C, ar, but, 1);
+                       break;
+               case MOUSEMOVE:
+                       if(BLI_in_rcti(&ar->winrct, event->x, event->y)) {
+                               rcti rect;
+                               int a;
+                               
+                               for(a=0; a<data->items.totitem; a++) {
+                                       ui_searchbox_butrect(&rect, data, a);
+                                       if(BLI_in_rcti(&rect, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin)) {
+                                               if( data->active!= a+1) {
+                                                       data->active= a+1;
+                                                       ui_searchbox_select(C, ar, but, 0);
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+                       break;
+       }
+}
+
+/* ar is the search box itself */
+void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, int reset)
+{
+       uiSearchboxData *data= ar->regiondata;
+       
+       /* reset vars */
+       data->items.totitem= 0;
+       data->items.more= 0;
+       if(reset==0)
+               data->items.offset_i= data->items.offset;
+       else {
+               data->items.offset_i= data->items.offset= 0;
+               data->active= 0;
+       }
+       
+       /* callback */
+       if(but->search_func)
+               but->search_func(C, but->search_arg, but->editstr, &data->items);
+       
+       if(reset) {
+               int a;
+               /* handle case where editstr is equal to one of items */
+               for(a=0; a<data->items.totitem; a++) {
+                       char *cpoin= strchr(data->items.names[a], '|');
+                       
+                       if(cpoin) cpoin[0]= 0;
+                       if(0==strcmp(but->editstr, data->items.names[a]))
+                               data->active= a+1;
+                       if(cpoin) cpoin[0]= '|';
+               }
+       }
+
+       /* validate selected item */
+       ui_searchbox_select(C, ar, but, 0);
+       
+       ED_region_tag_redraw(ar);
+}
+
+static void ui_searchbox_region_draw(const bContext *C, ARegion *ar)
+{
+       uiSearchboxData *data= ar->regiondata;
+       
+       /* pixel space */
+       wmOrtho2(-0.01f, ar->winx-0.01f, -0.01f, ar->winy-0.01f);
+
+       if(!data->noback)
+               ui_draw_search_back(U.uistyles.first, NULL, &data->bbox);
+       
+       /* draw text */
+       if(data->items.totitem) {
+               rcti rect;
+               int a;
+                               
+               /* draw items */
+               for(a=0; a<data->items.totitem; a++) {
+                       ui_searchbox_butrect(&rect, data, a);
+                       
+                       ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], (a+1)==data->active?UI_ACTIVE:0);
+                       
+               }
+               /* indicate more */
+               if(data->items.more) {
+                       glEnable(GL_BLEND);
+                       UI_icon_draw((data->bbox.xmax-data->bbox.xmin)/2, 8, ICON_TRIA_DOWN);
+                       glDisable(GL_BLEND);
+               }
+               if(data->items.offset) {
+                       glEnable(GL_BLEND);
+                       UI_icon_draw((data->bbox.xmax-data->bbox.xmin)/2, data->bbox.ymax-13, ICON_TRIA_UP);
+                       glDisable(GL_BLEND);
+               }
+       }
+}
+
+static void ui_searchbox_region_free(ARegion *ar)
+{
+       uiSearchboxData *data= ar->regiondata;
+       int a;
+
+       /* free search data */
+       for(a=0; a<SEARCH_ITEMS; a++)
+               MEM_freeN(data->items.names[a]);
+       MEM_freeN(data->items.names);
+       MEM_freeN(data->items.pointers);
+       
+       MEM_freeN(data);
+       ar->regiondata= NULL;
+}
+
+ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
+{
+       uiStyle *style= U.uistyles.first;       // XXX pass on as arg
+       static ARegionType type;
+       ARegion *ar;
+       uiSearchboxData *data;
+       float aspect= but->block->aspect;
+       float x1f, x2f, y1f, y2f;
+       int x1, x2, y1, y2, winx, winy, ofsx, ofsy;
+       
+       /* create area region */
+       ar= ui_add_temporary_region(CTX_wm_screen(C));
+       
+       memset(&type, 0, sizeof(ARegionType));
+       type.draw= ui_searchbox_region_draw;
+       type.free= ui_searchbox_region_free;
+       ar->type= &type;
+       
+       /* create searchbox data */
+       data= MEM_callocN(sizeof(uiSearchboxData), "uiSearchboxData");
+       
+       /* set font, get bb */
+       data->fstyle= style->widget; /* copy struct */
+       data->fstyle.align= UI_STYLE_TEXT_CENTER;
+       ui_fontscale(&data->fstyle.points, aspect);
+       uiStyleFontSet(&data->fstyle);
+       
+       ar->regiondata= data;
+       
+       /* special case, hardcoded feature, not draw backdrop when called from menus,
+          assume for design that popup already added it */
+       if(but->block->flag & UI_BLOCK_LOOP)
+               data->noback= 1;
+       
+       /* compute position */
+       ofsx= (but->block->panel)? but->block->panel->ofsx: 0;
+       ofsy= (but->block->panel)? but->block->panel->ofsy: 0;
+       
+       x1f= but->x1 - 5;       /* align text with button */
+       x2f= but->x2 + 5;       /* symmetrical */
+       y2f= but->y1;
+       y1f= y2f - uiSearchBoxhHeight();
+       
+       /* minimal width */
+       if(x2f - x1f < 180) x2f= x1f+180; // XXX arbitrary
+       
+       /* copy to int, gets projected if possible too */
+       x1= x1f; y1= y1f; x2= x2f; y2= y2f; 
+       
+       if(butregion) {
+               if(butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) {
+                       UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1);
+                       UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2);
+               }
+               
+               x1 += butregion->winrct.xmin;
+               x2 += butregion->winrct.xmin;
+               y1 += butregion->winrct.ymin;
+               y2 += butregion->winrct.ymin;
+       }
+       
+       wm_window_get_size(CTX_wm_window(C), &winx, &winy);
+       
+       if(x2 > winx) {
+               /* super size */
+               if(x2 > winx + x1) {
+                       x2= winx;
+                       x1= 0;
+               }
+               else {
+                       x1 -= x2-winx;
+                       x2= winx;
+               }
+       }
+       if(y1 < 0) {
+               y1 += 36;
+               y2 += 36;
+       }
+       
+       /* widget rect, in region coords */
+       data->bbox.xmin= MENU_SHADOW_SIDE;
+       data->bbox.xmax= x2-x1 + MENU_SHADOW_SIDE;
+       data->bbox.ymin= MENU_SHADOW_BOTTOM;
+       data->bbox.ymax= y2-y1 + MENU_SHADOW_BOTTOM;
+       
+       /* region bigger for shadow */
+       ar->winrct.xmin= x1 - MENU_SHADOW_SIDE;
+       ar->winrct.xmax= x2 + MENU_SHADOW_SIDE;
+       ar->winrct.ymin= y1 - MENU_SHADOW_BOTTOM;
+       ar->winrct.ymax= y2;
+       
+       /* adds subwindow */
+       ED_region_init(C, ar);
+       
+       /* notify change and redraw */
+       ED_region_tag_redraw(ar);
+       
+       /* prepare search data */
+       data->items.maxitem= SEARCH_ITEMS;
+       data->items.maxstrlen= but->hardmax;
+       data->items.totitem= 0;
+       data->items.names= MEM_callocN(SEARCH_ITEMS*sizeof(void *), "search names");
+       data->items.pointers= MEM_callocN(SEARCH_ITEMS*sizeof(void *), "search pointers");
+       for(x1=0; x1<SEARCH_ITEMS; x1++)
+               data->items.names[x1]= MEM_callocN(but->hardmax+1, "search pointers");
+       
+       return ar;
+}
+
+void ui_searchbox_free(bContext *C, ARegion *ar)
+{
+       ui_remove_temporary_region(C, CTX_wm_screen(C), ar);
+}
+
+
 /************************* Creating Menu Blocks **********************/
 
 /* position block relative to but, result is in window space */
@@ -703,8 +1056,6 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
 
        /* get winmat now that we actually have the subwindow */
        wmSubWindowSet(window, ar->swinid);
-                       // XXX ton, AA pixel space...
-       wmOrtho2(0.0, (float)ar->winrct.xmax-ar->winrct.xmin+1, 0.0, (float)ar->winrct.ymax-ar->winrct.ymin+1);
        
        wm_subwindow_getmatrix(window, ar->swinid, block->winmat);
        
@@ -716,7 +1067,9 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
 
 void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle)
 {
-       ui_remove_temporary_region(C, CTX_wm_screen(C), handle->region);
+       /* XXX ton added, chrash on load file with popup open... need investigate */
+       if(CTX_wm_screen(C))
+               ui_remove_temporary_region(C, CTX_wm_screen(C), handle->region);
        MEM_freeN(handle);
 }
 
index fca88132771f1e139f025deb878f262cb67c0268..62a4c01bc6c1f56a35ae3bef2b87d0636ce7f9db 100644 (file)
@@ -170,7 +170,7 @@ void uiStyleFontDraw(uiFontStyle *fs, rcti *rect, char *str)
        if(fs->align==UI_STYLE_TEXT_CENTER)
                xofs= floor( 0.5f*(rect->xmax - rect->xmin - BLF_width(str)));
        else if(fs->align==UI_STYLE_TEXT_RIGHT)
-               xofs= rect->xmax - rect->xmin - BLF_width(str);
+               xofs= rect->xmax - rect->xmin - BLF_width(str) - 1;
        
        /* clip is very strict, so we give it some space */
        BLF_clipping(rect->xmin-1, rect->ymin-4, rect->xmax+1, rect->ymax+4);
index 987b7eef4d6bf2425926972445813fcef7c1d540..12954fe77c0ef5afcfb3b63b3bceaaaed9ee7186 100644 (file)
@@ -240,33 +240,16 @@ void uiTemplateHeaderID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *pr
 
 #define ERROR_LIBDATA_MESSAGE "Can't edit external libdata"
 
-#define B_NOP                          0
-#define B_MODIFIER_RECALC      1
-#define B_MODIFIER_REDRAW      2
-#define B_CHANGEDEP                    3
-#define B_ARM_RECALCDATA       4
-
 #include <string.h>
 
-#include "DNA_armature_types.h"
-#include "DNA_curve_types.h"
 #include "DNA_object_force.h"
 #include "DNA_object_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
 #include "DNA_modifier_types.h"
-#include "DNA_particle_types.h"
 #include "DNA_scene_types.h"
 
-#include "BKE_bmesh.h"
-#include "BKE_curve.h"
 #include "BKE_depsgraph.h"
 #include "BKE_DerivedMesh.h"
-#include "BKE_displist.h"
 #include "BKE_global.h"
-#include "BKE_lattice.h"
-#include "BKE_main.h"
-#include "BKE_mesh.h"
 #include "BKE_modifier.h"
 #include "BKE_object.h"
 #include "BKE_particle.h"
@@ -280,33 +263,20 @@ void uiTemplateHeaderID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *pr
 
 #include "ED_object.h"
 
-void do_modifier_panels(bContext *C, void *arg, int event)
+static void modifiers_del(bContext *C, void *ob_v, void *md_v)
 {
        Scene *scene= CTX_data_scene(C);
-       Object *ob = CTX_data_active_object(C);
+       Object *ob= ob_v;
+       ReportList reports;
 
-       switch(event) {
-       case B_MODIFIER_REDRAW:
-               WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
-               break;
+       BKE_reports_init(&reports, RPT_STORE);
 
-       case B_MODIFIER_RECALC:
+       if(ED_object_modifier_delete(&reports, ob_v, md_v)) {
                WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
                DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-               object_handle_update(scene, ob);
-               // XXX countall();
-               break;
-       }
-}
-
-static void modifiers_del(bContext *C, void *ob_v, void *md_v)
-{
-       ReportList reports;
 
-       BKE_reports_init(&reports, RPT_STORE);
-
-       if(ED_object_modifier_delete(&reports, ob_v, md_v))
                ED_undo_push(C, "Delete modifier");
+       }
        else
                uiPupMenuReports(C, &reports);
 
@@ -315,12 +285,18 @@ static void modifiers_del(bContext *C, void *ob_v, void *md_v)
 
 static void modifiers_moveUp(bContext *C, void *ob_v, void *md_v)
 {
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= ob_v;
        ReportList reports;
 
        BKE_reports_init(&reports, RPT_STORE);
 
-       if(ED_object_modifier_move_up(&reports, ob_v, md_v))
+       if(ED_object_modifier_move_up(&reports, ob_v, md_v)) {
+               WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+
                ED_undo_push(C, "Move modifier");
+       }
        else
                uiPupMenuReports(C, &reports);
 
@@ -329,12 +305,18 @@ static void modifiers_moveUp(bContext *C, void *ob_v, void *md_v)
 
 static void modifiers_moveDown(bContext *C, void *ob_v, void *md_v)
 {
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= ob_v;
        ReportList reports;
 
        BKE_reports_init(&reports, RPT_STORE);
 
-       if(ED_object_modifier_move_down(&reports, ob_v, md_v))
+       if(ED_object_modifier_move_down(&reports, ob_v, md_v)) {
+               WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+
                ED_undo_push(C, "Move modifier");
+       }
        else
                uiPupMenuReports(C, &reports);
 
@@ -344,12 +326,17 @@ static void modifiers_moveDown(bContext *C, void *ob_v, void *md_v)
 static void modifiers_convertParticles(bContext *C, void *obv, void *mdv)
 {
        Scene *scene= CTX_data_scene(C);
+       Object *ob= obv;
        ReportList reports;
 
        BKE_reports_init(&reports, RPT_STORE);
 
-       if(ED_object_modifier_convert(&reports, scene, obv, mdv))
+       if(ED_object_modifier_convert(&reports, scene, obv, mdv)) {
+               WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+
                ED_undo_push(C, "Convert particles to mesh object(s).");
+       }
        else
                uiPupMenuReports(C, &reports);
 
@@ -359,12 +346,17 @@ static void modifiers_convertParticles(bContext *C, void *obv, void *mdv)
 static void modifiers_applyModifier(bContext *C, void *obv, void *mdv)
 {
        Scene *scene= CTX_data_scene(C);
+       Object *ob= obv;
        ReportList reports;
 
        BKE_reports_init(&reports, RPT_STORE);
 
-       if(ED_object_modifier_apply(&reports, scene, obv, mdv))
+       if(ED_object_modifier_apply(&reports, scene, obv, mdv)) {
+               WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+
                ED_undo_push(C, "Apply modifier");
+       }
        else
                uiPupMenuReports(C, &reports);
 
@@ -373,12 +365,17 @@ static void modifiers_applyModifier(bContext *C, void *obv, void *mdv)
 
 static void modifiers_copyModifier(bContext *C, void *ob_v, void *md_v)
 {
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= ob_v;
        ReportList reports;
 
        BKE_reports_init(&reports, RPT_STORE);
 
-       if(ED_object_modifier_copy(&reports, ob_v, md_v))
+       if(ED_object_modifier_copy(&reports, ob_v, md_v)) {
+               WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
                ED_undo_push(C, "Copy modifier");
+       }
        else
                uiPupMenuReports(C, &reports);
 
@@ -387,21 +384,27 @@ static void modifiers_copyModifier(bContext *C, void *ob_v, void *md_v)
 
 static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v)
 {
+       Scene *scene= CTX_data_scene(C);
        Object *ob = ob_v;
        ModifierData *md;
        
        int i, cageIndex = modifiers_getCageIndex(ob, NULL );
 
-       for( i = 0, md=ob->modifiers.first; md; ++i, md=md->next )
-               if( md == md_v ) {
-                       if( i >= cageIndex )
+       for(i = 0, md=ob->modifiers.first; md; ++i, md=md->next) {
+               if(md == md_v) {
+                       if(i >= cageIndex)
                                md->mode ^= eModifierMode_OnCage;
                        break;
                }
+       }
+
+       WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
 }
 
 static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
 {
+       Scene *scene= CTX_data_scene(C);
        Object *ob = ob_v;
        ModifierData *md = md_v;
        ModifierData *nmd = modifier_new(md->type);
@@ -413,169 +416,56 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
 
        ob->partype = PAROBJECT;
 
-       ED_undo_push(C, "Modifier convert to real");
-}
-
-#if 0
-static void modifiers_clearHookOffset(bContext *C, void *ob_v, void *md_v)
-{
-       Object *ob = ob_v;
-       ModifierData *md = md_v;
-       HookModifierData *hmd = (HookModifierData*) md;
-       
-       if (hmd->object) {
-               Mat4Invert(hmd->object->imat, hmd->object->obmat);
-               Mat4MulSerie(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL);
-               ED_undo_push(C, "Clear hook offset");
-       }
-}
-
-static void modifiers_cursorHookCenter(bContext *C, void *ob_v, void *md_v)
-{
-       /* XXX 
-       Object *ob = ob_v;
-       ModifierData *md = md_v;
-       HookModifierData *hmd = (HookModifierData*) md;
-
-       if(G.vd) {
-               float *curs = give_cursor();
-               float bmat[3][3], imat[3][3];
-
-               where_is_object(ob);
-       
-               Mat3CpyMat4(bmat, ob->obmat);
-               Mat3Inv(imat, bmat);
-
-               curs= give_cursor();
-               hmd->cent[0]= curs[0]-ob->obmat[3][0];
-               hmd->cent[1]= curs[1]-ob->obmat[3][1];
-               hmd->cent[2]= curs[2]-ob->obmat[3][2];
-               Mat3MulVecfl(imat, hmd->cent);
-
-               ED_undo_push(C, "Hook cursor center");
-       }*/
-}
-
-static void modifiers_selectHook(bContext *C, void *ob_v, void *md_v)
-{
-       /* XXX ModifierData *md = md_v;
-       HookModifierData *hmd = (HookModifierData*) md;
-
-       hook_select(hmd);*/
-}
-
-static void modifiers_reassignHook(bContext *C, void *ob_v, void *md_v)
-{
-       /* XXX ModifierData *md = md_v;
-       HookModifierData *hmd = (HookModifierData*) md;
-       float cent[3];
-       int *indexar, tot, ok;
-       char name[32];
-               
-       ok= hook_getIndexArray(&tot, &indexar, name, cent);
-
-       if (!ok) {
-               uiPupMenuError(C, "Requires selected vertices or active Vertex Group");
-       } else {
-               if (hmd->indexar) {
-                       MEM_freeN(hmd->indexar);
-               }
-
-               VECCOPY(hmd->cent, cent);
-               hmd->indexar = indexar;
-               hmd->totindex = tot;
-       }*/
-}
+       WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
 
-static void modifiers_bindMeshDeform(bContext *C, void *ob_v, void *md_v)
-{
-       Scene *scene= CTX_data_scene(C);
-       MeshDeformModifierData *mmd = (MeshDeformModifierData*) md_v;
-       Object *ob = (Object*)ob_v;
-
-       if(mmd->bindcos) {
-               if(mmd->bindweights) MEM_freeN(mmd->bindweights);
-               if(mmd->bindcos) MEM_freeN(mmd->bindcos);
-               if(mmd->dyngrid) MEM_freeN(mmd->dyngrid);
-               if(mmd->dyninfluences) MEM_freeN(mmd->dyninfluences);
-               if(mmd->dynverts) MEM_freeN(mmd->dynverts);
-               mmd->bindweights= NULL;
-               mmd->bindcos= NULL;
-               mmd->dyngrid= NULL;
-               mmd->dyninfluences= NULL;
-               mmd->dynverts= NULL;
-               mmd->totvert= 0;
-               mmd->totcagevert= 0;
-               mmd->totinfluence= 0;
-       }
-       else {
-               DerivedMesh *dm;
-               int mode= mmd->modifier.mode;
-
-               /* force modifier to run, it will call binding routine */
-               mmd->needbind= 1;
-               mmd->modifier.mode |= eModifierMode_Realtime;
-
-               if(ob->type == OB_MESH) {
-                       dm= mesh_create_derived_view(scene, ob, 0);
-                       dm->release(dm);
-               }
-               else if(ob->type == OB_LATTICE) {
-                       lattice_calc_modifiers(scene, ob);
-               }
-               else if(ob->type==OB_MBALL) {
-                       makeDispListMBall(scene, ob);
-               }
-               else if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
-                       makeDispListCurveTypes(scene, ob, 0);
-               }
-
-               mmd->needbind= 0;
-               mmd->modifier.mode= mode;
-       }
-}
-
-void modifiers_explodeFacepa(bContext *C, void *arg1, void *arg2)
-{
-       ExplodeModifierData *emd=arg1;
-
-       emd->flag |= eExplodeFlag_CalcFaces;
-}
-
-void modifiers_explodeDelVg(bContext *C, void *arg1, void *arg2)
-{
-       ExplodeModifierData *emd=arg1;
-       emd->vgroup = 0;
+       ED_undo_push(C, "Modifier convert to real");
 }
-#endif
 
-static int modifier_is_fluid_particles(ModifierData *md)
+static int modifier_can_delete(ModifierData *md)
 {
-       if(md->type == eModifierType_ParticleSystem) {
+       // deletion over the deflection panel
+       // fluid particle modifier can't be deleted here
+
+       if(md->type==eModifierType_Fluidsim)
+               return 0;
+       if(md->type==eModifierType_Collision)
+               return 0;
+       if(md->type==eModifierType_Surface)
+               return 0;
+       if(md->type == eModifierType_ParticleSystem)
                if(((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID)
-                       return 1;
-       }
-       return 0;
+                       return 0;
+
+       return 1;
 }
 
 static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, int index, int cageIndex, int lastCageIndex)
 {
        ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+       PointerRNA ptr;
        uiBut *but;
        uiBlock *block;
-       uiLayout *column, *row, *result= NULL;
+       uiLayout *column, *row, *subrow, *result= NULL;
        int isVirtual = md->mode&eModifierMode_Virtual;
-       int x = 0, y = 0; // XXX , color = md->error?TH_REDALERT:TH_BUT_NEUTRAL;
+       // XXX short color = md->error?TH_REDALERT:TH_BUT_NEUTRAL;
        short width = 295, buttonWidth = width-120-10;
        char str[128];
 
+       RNA_pointer_create(&ob->id, &RNA_Modifier, md, &ptr);
+
        column= uiLayoutColumn(layout, 1);
+       uiLayoutSetContextPointer(column, "modifier", &ptr);
 
        /* rounded header */
        /* XXX uiBlockSetCol(block, color); */
                /* roundbox 4 free variables: corner-rounding, nop, roundbox type, shade */
-       block= uiLayoutFreeBlock(uiLayoutBox(column));
-       uiBlockSetHandleFunc(block, do_modifier_panels, NULL);
+
+       row= uiLayoutRow(uiLayoutBox(column), 0);
+       block= uiLayoutGetBlock(row);
+
+       subrow= uiLayoutRow(row, 0);
+       uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT);
 
        //uiDefBut(block, ROUNDBOX, 0, "", x-10, y-4, width, 25, NULL, 7.0, 0.0, 
        //               (!isVirtual && (md->mode&eModifierMode_Expanded))?3:15, 20, ""); 
@@ -584,27 +474,27 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
        /* open/close icon */
        if (!isVirtual) {
                uiBlockSetEmboss(block, UI_EMBOSSN);
-               uiDefIconButBitI(block, ICONTOG, eModifierMode_Expanded, B_MODIFIER_REDRAW, ICON_TRIA_RIGHT, x-10, y-2, 20, 20, &md->mode, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Modifier");
+               uiDefIconButBitI(block, ICONTOG, eModifierMode_Expanded, 0, ICON_TRIA_RIGHT, 0, 0, UI_UNIT_X, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Modifier");
        }
 
        uiBlockSetEmboss(block, UI_EMBOSS);
        
        if (isVirtual) {
                sprintf(str, "%s parent deform", md->name);
-               uiDefBut(block, LABEL, 0, str, x+10, y-1, width-110, 19, NULL, 0.0, 0.0, 0.0, 0.0, "Modifier name"); 
+               uiDefBut(block, LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Modifier name"); 
 
-               but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Make Real", x+width-100, y, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Convert virtual modifier to a real modifier");
+               but = uiDefBut(block, BUT, 0, "Make Real", 0, 0, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Convert virtual modifier to a real modifier");
                uiButSetFunc(but, modifiers_convertToReal, ob, md);
        } else {
                uiBlockBeginAlign(block);
-               uiDefBut(block, TEX, B_MODIFIER_REDRAW, "", x+10, y-1, buttonWidth-60, 19, md->name, 0.0, sizeof(md->name)-1, 0.0, 0.0, "Modifier name"); 
+               uiDefBut(block, TEX, 0, "", 0, 0, buttonWidth-60, UI_UNIT_Y, md->name, 0.0, sizeof(md->name)-1, 0.0, 0.0, "Modifier name"); 
 
                /* Softbody not allowed in this situation, enforce! */
                if (((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && (md->type!=eModifierType_Surface)) {
-                       uiDefIconButBitI(block, TOG, eModifierMode_Render, B_MODIFIER_RECALC, ICON_SCENE, x+10+buttonWidth-60, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering");
-                       but= uiDefIconButBitI(block, TOG, eModifierMode_Realtime, B_MODIFIER_RECALC, ICON_VIEW3D, x+10+buttonWidth-40, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display");
+                       uiDefIconButBitI(block, TOG, eModifierMode_Render, 0, ICON_SCENE, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering");
+                       but= uiDefIconButBitI(block, TOG, eModifierMode_Realtime, 0, ICON_VIEW3D, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display");
                        if (mti->flags&eModifierTypeFlag_SupportsEditmode) {
-                               uiDefIconButBitI(block, TOG, eModifierMode_Editmode, B_MODIFIER_RECALC, ICON_EDITMODE_HLT, x+10+buttonWidth-20, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during Editmode (only if enabled for display)");
+                               uiDefIconButBitI(block, TOG, eModifierMode_Editmode, 0, ICON_EDITMODE_HLT, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during Editmode (only if enabled for display)");
                        }
                }
                uiBlockEndAlign(block);
@@ -625,26 +515,28 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
                                icon = ICON_BLANK1;
                        }
                        /* XXX uiBlockSetCol(block, color); */
-                       but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, icon, x+width-105, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Apply modifier to editing cage during Editmode");
+                       but = uiDefIconBut(block, BUT, 0, icon, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Apply modifier to editing cage during Editmode");
                        uiButSetFunc(but, modifiers_setOnCage, ob, md);
                        /* XXX uiBlockSetCol(block, TH_AUTO); */
                }
+       }
+
+       subrow= uiLayoutRow(row, 0);
+       uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT);
 
+       if(!isVirtual) {
                /* XXX uiBlockSetCol(block, TH_BUT_ACTION); */
 
-               but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, VICON_MOVE_UP, x+width-75, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier up in stack");
+               but = uiDefIconBut(block, BUT, 0, VICON_MOVE_UP, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier up in stack");
                uiButSetFunc(but, modifiers_moveUp, ob, md);
 
-               but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, VICON_MOVE_DOWN, x+width-75+20, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier down in stack");
+               but = uiDefIconBut(block, BUT, 0, VICON_MOVE_DOWN, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier down in stack");
                uiButSetFunc(but, modifiers_moveDown, ob, md);
                
                uiBlockSetEmboss(block, UI_EMBOSSN);
                
-               // deletion over the deflection panel
-               // fluid particle modifier can't be deleted here
-               if(md->type!=eModifierType_Fluidsim && md->type!=eModifierType_Collision && md->type!=eModifierType_Surface && !modifier_is_fluid_particles(md))
-               {
-                       but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, VICON_X, x+width-70+40, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Delete modifier");
+               if(modifier_can_delete(md)) {
+                       but = uiDefIconBut(block, BUT, 0, VICON_X, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Delete modifier");
                        uiButSetFunc(but, modifiers_del, ob, md);
                }
                /* XXX uiBlockSetCol(block, TH_AUTO); */
@@ -653,15 +545,11 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
        uiBlockSetEmboss(block, UI_EMBOSS);
 
        if(!isVirtual && (md->mode&eModifierMode_Expanded)) {
-               int cy = y - 8;
-               int lx = x + width - 60 - 15;
                uiLayout *box;
 
                box= uiLayoutBox(column);
                row= uiLayoutRow(box, 1);
 
-               y -= 18;
-
                if (!isVirtual && (md->type!=eModifierType_Collision) && (md->type!=eModifierType_Surface)) {
                        uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE); /* only here obdata, the rest of modifiers is ob level */
 
@@ -670,13 +558,13 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
 
                        if(!(G.f & G_PARTICLEEDIT)) {
                                        if(ELEM3(psys->part->draw_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache) {
-                                               but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Convert",        lx,(cy-=19),60,19, 0, 0, 0, 0, 0, "Convert the current particles to a mesh object");
+                                               but = uiDefBut(block, BUT, 0, "Convert",        0,0,60,19, 0, 0, 0, 0, 0, "Convert the current particles to a mesh object");
                                                uiButSetFunc(but, modifiers_convertParticles, ob, md);
                                        }
                                }
                        }
                        else{
-                               but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Apply",  lx,(cy-=19),60,19, 0, 0, 0, 0, 0, "Apply the current modifier and remove from the stack");
+                               but = uiDefBut(block, BUT, 0, "Apply",  0,0,60,19, 0, 0, 0, 0, 0, "Apply the current modifier and remove from the stack");
                                uiButSetFunc(but, modifiers_applyModifier, ob, md);
                        }
                        
@@ -684,16 +572,13 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
                        uiBlockSetButLock(block, ob && ob->id.lib, ERROR_LIBDATA_MESSAGE);
 
                        if (md->type!=eModifierType_Fluidsim && md->type!=eModifierType_Softbody && md->type!=eModifierType_ParticleSystem && (md->type!=eModifierType_Cloth)) {
-                               but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Copy",   lx,(cy-=19),60,19, 0, 0, 0, 0, 0, "Duplicate the current modifier at the same position in the stack");
+                               but = uiDefBut(block, BUT, 0, "Copy",   0,0,60,19, 0, 0, 0, 0, 0, "Duplicate the current modifier at the same position in the stack");
                                uiButSetFunc(but, modifiers_copyModifier, ob, md);
                        }
                }
 
                result= uiLayoutColumn(box, 0);
                block= uiLayoutFreeBlock(box);
-
-               lx = x + 10;
-               cy = y + 10 - 1;
        }
 
        if (md->error) {
@@ -886,7 +771,7 @@ static void draw_constraint_spaceselect (uiBlock *block, bConstraint *con, short
        }
        
        if ((target != -1) && (owner != -1))
-               uiDefIconBut(block, LABEL, B_NOP, ICON_ARROW_LEFTRIGHT,
+               uiDefIconBut(block, LABEL, 0, ICON_ARROW_LEFTRIGHT,
                        iconx, yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "");
        
        /* Owner-Space */
@@ -906,8 +791,9 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
        bPoseChannel *pchan= get_active_posechannel(ob);
        bConstraintTypeInfo *cti;
        uiBlock *block;
-       uiLayout *result= NULL, *col, *box;
+       uiLayout *result= NULL, *col, *box, *row, *subrow;
        uiBut *but;
+       PointerRNA ptr;
        char typestr[32];
        short width = 265;
        short proxy_protected, xco=0, yco=0;
@@ -936,11 +822,19 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
        uiBlockSetHandleFunc(block, do_constraint_panels, NULL);
        uiBlockSetFunc(block, constraint_active_func, ob, con);
 
+       RNA_pointer_create(&ob->id, &RNA_Constraint, con, &ptr);
+
        col= uiLayoutColumn(layout, 1);
+       uiLayoutSetContextPointer(col, "constraint", &ptr);
+
        box= uiLayoutBox(col);
+       row= uiLayoutRow(box, 0);
 
        block= uiLayoutFreeBlock(box);
-               
+
+       subrow= uiLayoutRow(row, 0);
+       uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT);
+
        /* Draw constraint header */
        uiBlockSetEmboss(block, UI_EMBOSSN);
        
@@ -974,6 +868,9 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
        }
 
        // XXX uiBlockSetCol(block, TH_AUTO);   
+
+       subrow= uiLayoutRow(row, 0);
+       uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT);
        
        /* proxy-protected constraints cannot be edited, so hide up/down + close buttons */
        if (proxy_protected) {
@@ -1141,101 +1038,11 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
                        }
                        break; 
                */
-               case CONSTRAINT_TYPE_KINEMATIC:
-                       {
-                               bKinematicConstraint *data = con->data;
-
-                               /* IK Target */
-                               uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco, yco-24, 80, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
-                               
-                               /* Draw target parameters */
-                               uiBlockBeginAlign(block);
-                               uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco, yco-44, 137, 19, &data->tar, "Target Object"); 
-
-                               if (is_armature_target(data->tar)) {
-                                       but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco, yco-62,137,19, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
-                                       uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
-                               }
-                               else if (is_geom_target(data->tar)) {
-                                       but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco, yco-62,137,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
-                                       uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
-                               }
-                               else {
-                                       strcpy (data->subtarget, "");
-                               }
-                               
-                               uiBlockEndAlign(block);
-                               
-                               /* Settings */
-                               uiBlockBeginAlign(block);
-                               uiDefButBitS(block, TOG, CONSTRAINT_IK_TIP, B_CONSTRAINT_TEST, "Use Tail", xco, yco-92, 137, 19, &data->flag, 0, 0, 0, 0, "Include Bone's tail also last element in Chain");
-                               uiDefButS(block, NUM, B_CONSTRAINT_TEST, "ChainLen:", xco, yco-112,137,19, &data->rootbone, 0, 255, 0, 0, "If not zero, the amount of bones in this chain");
-                               
-                               uiBlockBeginAlign(block);
-                               uiDefButF(block, NUMSLI, B_CONSTRAINT_TEST, "PosW ", xco+147, yco-92, 137, 19, &data->weight, 0.01, 1.0, 2, 2, "For Tree-IK: weight of position control for this target");
-                               uiDefButBitS(block, TOG, CONSTRAINT_IK_ROT, B_CONSTRAINT_TEST, "Rot", xco+147, yco-112, 40,19, &data->flag, 0, 0, 0, 0, "Chain follows rotation of target");
-                               uiDefButF(block, NUMSLI, B_CONSTRAINT_TEST, "W ", xco+187, yco-112, 97, 19, &data->orientweight, 0.01, 1.0, 2, 2, "For Tree-IK: Weight of orientation control for this target");
-                               
-                               uiBlockBeginAlign(block);
-                               
-                               uiDefButBitS(block, TOG, CONSTRAINT_IK_STRETCH, B_CONSTRAINT_TEST, "Stretch", xco, yco-137,137,19, &data->flag, 0, 0, 0, 0, "Enable IK stretching");
-                               uiBlockBeginAlign(block);
-                               uiDefButS(block, NUM, B_CONSTRAINT_TEST, "Iterations:", xco+147, yco-137, 137, 19, &data->iterations, 1, 10000, 0, 0, "Maximum number of solving iterations"); 
-                               uiBlockEndAlign(block);
-                               
-                               /* Pole Vector */
-                               uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Pole Target:", xco+147, yco-24, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
-                               
-                               uiBlockBeginAlign(block);
-                               uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+147, yco-44, 137, 19, &data->poletar, "Pole Target Object"); 
-                               if (is_armature_target(data->poletar)) {
-                                       but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+147, yco-62,137,19, &data->polesubtarget, 0, 24, 0, 0, "Pole Subtarget Bone");
-                                       uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->poletar);
-                               }
-                               else if (is_geom_target(data->poletar)) {
-                                       but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+147, yco-62,137,18, &data->polesubtarget, 0, 24, 0, 0, "Name of Vertex Group defining pole 'target' points");
-                                       uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->poletar);
-                               }
-                               else {
-                                       strcpy(data->polesubtarget, "");
-                               }
-                               
-                               if (data->poletar) {
-                                       uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pole Offset ", xco, yco-167, 137, 19, &data->poleangle, -180.0, 180.0, 0, 0, "Pole rotation offset");
-                               }
-                       }
-                       break;
-               case CONSTRAINT_TYPE_RIGIDBODYJOINT:
+               
+               /*case CONSTRAINT_TYPE_RIGIDBODYJOINT:
                        {
-                               bRigidBodyJointConstraint *data = con->data;
-                               float extremeLin = 999.f;
-                               float extremeAngX = 180.f;
-                               float extremeAngY = 45.f;
-                               float extremeAngZ = 45.f;
-                               int togButWidth = 70;
-                               int offsetY = 150;
-                               int textButWidth = ((width/2)-togButWidth);
-                               
-                               uiDefButI(block, MENU, B_CONSTRAINT_TEST, "Joint Types%t|Ball%x1|Hinge%x2|Generic 6DOF%x12",//|Extra Force%x6",
-                               //uiDefButI(block, MENU, B_CONSTRAINT_TEST, "Joint Types%t|Ball%x1|Hinge%x2|Cone Twist%x4|Generic 6DOF%x12",//|Extra Force%x6",
-                                                                                               xco, yco-25, 150, 18, &data->type, 0, 0, 0, 0, "Choose the joint type");
-
-                               uiDefButBitS(block, TOG, CONSTRAINT_DISABLE_LINKED_COLLISION, B_CONSTRAINT_TEST, "No Collision", xco+155, yco-25, 111, 18, &data->flag, 0, 24, 0, 0, "Disable Collision Between Linked Bodies");
-
-
-                               uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "toObject:", xco, yco-50, 130, 18, &data->tar, "Child Object");
-                               uiDefButBitS(block, TOG, CONSTRAINT_DRAW_PIVOT, B_CONSTRAINT_TEST, "ShowPivot", xco+135, yco-50, 130, 18, &data->flag, 0, 24, 0, 0, "Show pivot position and rotation");                                
-                               
-                               uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot X:", xco, yco-75, 130, 18, &data->pivX, -1000, 1000, 100, 0.0, "Offset pivot on X");
-                               uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Y:", xco, yco-100, 130, 18, &data->pivY, -1000, 1000, 100, 0.0, "Offset pivot on Y");
-                               uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Z:", xco, yco-125, 130, 18, &data->pivZ, -1000, 1000, 100, 0.0, "Offset pivot on z");
-                               
-                               uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax X:", xco+135, yco-75, 130, 18, &data->axX, -360, 360, 1500, 0.0, "Rotate pivot on X Axis (in degrees)");
-                               uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax Y:", xco+135, yco-100, 130, 18, &data->axY, -360, 360, 1500, 0.0, "Rotate pivot on Y Axis (in degrees)");
-                               uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax Z:", xco+135, yco-125, 130, 18, &data->axZ, -360, 360, 1500, 0.0, "Rotate pivot on Z Axis (in degrees)");
-                               
                                if (data->type==CONSTRAINT_RB_GENERIC6DOF) {
-                                       /* Draw Pairs of LimitToggle+LimitValue */
+                                       // Draw Pairs of LimitToggle+LimitValue 
                                        uiBlockBeginAlign(block); 
                                                uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "LinMinX", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit"); 
                                                uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[0]), -extremeLin, extremeLin, 0.1,0.5,"min x limit"); 
@@ -1270,7 +1077,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
                                        offsetY += 20;
                                }
                                if ((data->type==CONSTRAINT_RB_GENERIC6DOF) || (data->type==CONSTRAINT_RB_CONETWIST)) {
-                                       /* Draw Pairs of LimitToggle+LimitValue */
+                                       // Draw Pairs of LimitToggle+LimitValue /
                                        uiBlockBeginAlign(block); 
                                                uiDefButBitS(block, TOG, 8, B_CONSTRAINT_TEST, "AngMinX", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit"); 
                                                uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[3]), -extremeAngX, extremeAngX, 0.1,0.5,"min x limit"); 
@@ -1305,6 +1112,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
                                
                        }
                        break;
+                       */
 
                case CONSTRAINT_TYPE_NULL:
                        {
@@ -1503,3 +1311,37 @@ void uiTemplatePreview(uiLayout *layout, ID *id)
 
 }
 
+/********************** ColorRamp Template **************************/
+
+void uiTemplateColorRamp(uiLayout *layout, ColorBand *coba, int expand)
+{
+       uiBlock *block;
+       rctf rect;
+
+       if(coba) {
+               rect.xmin= 0; rect.xmax= 200;
+               rect.ymin= 0; rect.ymax= 190;
+               
+               block= uiLayoutFreeBlock(layout);
+               colorband_buttons(block, coba, &rect, !expand);
+       }
+}
+
+/********************* CurveMapping Template ************************/
+
+#include "DNA_color_types.h"
+
+void uiTemplateCurveMapping(uiLayout *layout, CurveMapping *cumap, int type)
+{
+       uiBlock *block;
+       rctf rect;
+
+       if(cumap) {
+               rect.xmin= 0; rect.xmax= 200;
+               rect.ymin= 0; rect.ymax= 190;
+               
+               block= uiLayoutFreeBlock(layout);
+               curvemap_buttons(block, cumap, type, 0, 0, &rect);
+       }
+}
+
index 7c739adf1b9424064042a8ba719460abc771aaa0..564ae2c020543de47935c93822b4462c916d671e 100644 (file)
@@ -35,6 +35,7 @@
 #include "DNA_material_types.h"
 #include "DNA_object_types.h"
 #include "DNA_screen_types.h"
+#include "DNA_texture_types.h"
 #include "DNA_windowmanager_types.h"
 
 #include "BKE_colortools.h"
@@ -42,6 +43,7 @@
 #include "BKE_idprop.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
+#include "BKE_texture.h"
 #include "BKE_utildefines.h"
 
 #include "RNA_access.h"
 
 /*************************** RNA Utilities ******************************/
 
-int UI_GetIconRNA(PointerRNA *ptr)
-{
-       StructRNA *rnatype= ptr->type;
-
-       if(rnatype == &RNA_Scene)
-               return ICON_SCENE_DATA;
-       else if(rnatype == &RNA_World)
-               return ICON_WORLD_DATA;
-       else if(rnatype == &RNA_Object)
-               return ICON_OBJECT_DATA;
-       else if(rnatype == &RNA_Mesh)
-               return ICON_MESH_DATA;
-       else if(rnatype == &RNA_MeshVertex)
-               return ICON_VERTEXSEL;
-       else if(rnatype == &RNA_MeshEdge)
-               return ICON_EDGESEL;
-       else if(rnatype == &RNA_MeshFace)
-               return ICON_FACESEL;
-       else if(rnatype == &RNA_MeshTextureFace)
-               return ICON_FACESEL_HLT;
-       else if(rnatype == &RNA_VertexGroup)
-               return ICON_GROUP_VERTEX;
-       else if(rnatype == &RNA_VertexGroupElement)
-               return ICON_GROUP_VERTEX;
-       else if(rnatype == &RNA_Curve)
-               return ICON_CURVE_DATA;
-       else if(rnatype == &RNA_MetaBall)
-               return ICON_META_DATA;
-       else if(rnatype == &RNA_MetaElement)
-               return ICON_OUTLINER_DATA_META;
-       else if(rnatype == &RNA_Lattice)
-               return ICON_LATTICE_DATA;
-       else if(rnatype == &RNA_Armature)
-               return ICON_ARMATURE_DATA;
-       else if(rnatype == &RNA_Bone)
-               return ICON_BONE_DATA;
-       else if(rnatype == &RNA_Camera)
-               return ICON_CAMERA_DATA;
-       else if(rnatype == &RNA_LocalLamp)
-               return ICON_LAMP_DATA;
-       else if(rnatype == &RNA_AreaLamp)
-               return ICON_LAMP_DATA;
-       else if(rnatype == &RNA_SpotLamp)
-               return ICON_LAMP_DATA;
-       else if(rnatype == &RNA_SunLamp)
-               return ICON_LAMP_DATA;
-       else if(rnatype == &RNA_HemiLamp)
-               return ICON_LAMP_DATA;
-       else if(rnatype == &RNA_Lamp)
-               return ICON_LAMP_DATA;
-       else if(rnatype == &RNA_Group)
-               return ICON_GROUP;
-       else if(rnatype == &RNA_ParticleSystem)
-               return ICON_PARTICLE_DATA;
-       else if(rnatype == &RNA_ParticleSettings)
-               return ICON_PARTICLE_DATA;
-       else if(rnatype == &RNA_Material)
-               return ICON_MATERIAL_DATA;
-       else if(rnatype == &RNA_Texture)
-               return ICON_TEXTURE_DATA;
-       else if(rnatype == &RNA_TextureSlot)
-               return ICON_TEXTURE_DATA;
-       else if(rnatype == &RNA_WorldTextureSlot)
-               return ICON_TEXTURE_DATA;
-       else if(rnatype == &RNA_MaterialTextureSlot)
-               return ICON_TEXTURE_DATA;
-       else if(rnatype == &RNA_Image)
-               return ICON_IMAGE_DATA;
-       else if(rnatype == &RNA_Screen)
-               return ICON_SPLITSCREEN;
-       else if(rnatype == &RNA_NodeTree)
-               return ICON_NODE;
-       else if(rnatype == &RNA_Text)
-               return ICON_TEXT;
-       else if(rnatype == &RNA_Sound)
-               return ICON_SOUND;
-       else if(rnatype == &RNA_Brush)
-               return ICON_BRUSH_DATA;
-       else if(rnatype == &RNA_VectorFont)
-               return ICON_FONT_DATA;
-       else if(rnatype == &RNA_Library)
-               return ICON_LIBRARY_DATA_DIRECT;
-       else if(rnatype == &RNA_Action)
-               return ICON_ACTION;
-       else if(rnatype == &RNA_FCurve)
-               return ICON_ANIM_DATA;
-       //else if(rnatype == &RNA_Ipo)
-       //      return ICON_ANIM_DATA;
-       else if(rnatype == &RNA_Key)
-               return ICON_SHAPEKEY_DATA;
-       else if(rnatype == &RNA_Main)
-               return ICON_BLENDER;
-       else if(rnatype == &RNA_Struct)
-               return ICON_RNA;
-       else if(rnatype == &RNA_Property)
-               return ICON_RNA;
-       else if(rnatype == &RNA_BooleanProperty)
-               return ICON_RNA;
-       else if(rnatype == &RNA_IntProperty)
-               return ICON_RNA;
-       else if(rnatype == &RNA_FloatProperty)
-               return ICON_RNA;
-       else if(rnatype == &RNA_StringProperty)
-               return ICON_RNA;
-       else if(rnatype == &RNA_EnumProperty)
-               return ICON_RNA;
-       else if(rnatype == &RNA_EnumPropertyItem)
-               return ICON_RNA;
-       else if(rnatype == &RNA_PointerProperty)
-               return ICON_RNA;
-       else if(rnatype == &RNA_CollectionProperty)
-               return ICON_RNA;
-       else if(rnatype == &RNA_GameObjectSettings)
-               return ICON_GAME;
-       else if(rnatype == &RNA_ScriptLink)
-               return ICON_PYTHON;
-       
-       /* modifiers */
-       else if(rnatype == &RNA_SubsurfModifier)
-               return ICON_MOD_SUBSURF;
-       else if(rnatype == &RNA_ArmatureModifier)
-               return ICON_MOD_ARMATURE;
-       else if(rnatype == &RNA_LatticeModifier)
-               return ICON_MOD_LATTICE;
-       else if(rnatype == &RNA_CurveModifier)
-               return ICON_MOD_CURVE;
-       else if(rnatype == &RNA_BuildModifier)
-               return ICON_MOD_BUILD;
-       else if(rnatype == &RNA_MirrorModifier)
-               return ICON_MOD_MIRROR;
-       else if(rnatype == &RNA_DecimateModifier)
-               return ICON_MOD_DECIM;
-       else if(rnatype == &RNA_WaveModifier)
-               return ICON_MOD_WAVE;
-       else if(rnatype == &RNA_HookModifier)
-               return ICON_HOOK;
-       else if(rnatype == &RNA_SoftbodyModifier)
-               return ICON_MOD_SOFT;
-       else if(rnatype == &RNA_BooleanModifier)
-               return ICON_MOD_BOOLEAN;
-       else if(rnatype == &RNA_ParticleInstanceModifier)
-               return ICON_MOD_PARTICLES;
-       else if(rnatype == &RNA_ParticleSystemModifier)
-               return ICON_MOD_PARTICLES;
-       else if(rnatype == &RNA_EdgeSplitModifier)
-               return ICON_MOD_EDGESPLIT;
-       else if(rnatype == &RNA_ArrayModifier)
-               return ICON_MOD_ARRAY;
-       else if(rnatype == &RNA_UVProjectModifier)
-               return ICON_MOD_UVPROJECT;
-       else if(rnatype == &RNA_DisplaceModifier)
-               return ICON_MOD_DISPLACE;
-       else if(rnatype == &RNA_ShrinkwrapModifier)
-               return ICON_MOD_SHRINKWRAP;
-       else if(rnatype == &RNA_CastModifier)
-               return ICON_MOD_CAST;
-       else if(rnatype == &RNA_MeshDeformModifier)
-               return ICON_MOD_MESHDEFORM;
-       else if(rnatype == &RNA_BevelModifier)
-               return ICON_MOD_BEVEL;
-       else if(rnatype == &RNA_SmoothModifier)
-               return ICON_MOD_SMOOTH;
-       else if(rnatype == &RNA_SimpleDeformModifier)
-               return ICON_MOD_SIMPLEDEFORM;
-       else if(rnatype == &RNA_MaskModifier)
-               return ICON_MOD_MASK;
-       else if(rnatype == &RNA_ClothModifier)
-               return ICON_MOD_CLOTH;
-       else if(rnatype == &RNA_ExplodeModifier)
-               return ICON_MOD_EXPLODE;
-       else if(rnatype == &RNA_CollisionModifier)
-               return ICON_MOD_PHYSICS;
-       else if(rnatype == &RNA_FluidSimulationModifier)
-               return ICON_MOD_FLUIDSIM;
-       else if(rnatype == &RNA_MultiresModifier)
-               return ICON_MOD_MULTIRES;
-       else
-               return ICON_DOT;
-}
-
 uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, char *name, int icon, int x1, int y1, int x2, int y2)
 {
        uiBut *but=NULL;
@@ -295,7 +117,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
                        pptr= RNA_property_pointer_get(ptr, prop);
                        if(!pptr.type)
                                pptr.type= RNA_property_pointer_type(prop);
-                       icon= UI_GetIconRNA(&pptr);
+                       icon= RNA_struct_ui_icon(pptr.type);
 
                        but= uiDefIconTextButR(block, IDPOIN, 0, icon, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
                        break;
@@ -1098,3 +920,128 @@ void curvemap_buttons(uiBlock *block, CurveMapping *cumap, char labeltype, short
                          cumap, 0.0f, 1.0f, 0, 0, "");
 }
 
+#define B_BANDCOL 1
+
+static int vergcband(const void *a1, const void *a2)
+{
+       const CBData *x1=a1, *x2=a2;
+
+       if( x1->pos > x2->pos ) return 1;
+       else if( x1->pos < x2->pos) return -1;
+       return 0;
+}
+
+static void colorband_pos_cb(bContext *C, void *coba_v, void *unused_v)
+{
+       ColorBand *coba= coba_v;
+       int a;
+       
+       if(coba->tot<2) return;
+       
+       for(a=0; a<coba->tot; a++) coba->data[a].cur= a;
+       qsort(coba->data, coba->tot, sizeof(CBData), vergcband);
+       for(a=0; a<coba->tot; a++) {
+               if(coba->data[a].cur==coba->cur) {
+                       // XXX if(coba->cur!=a) addqueue(curarea->win, REDRAW, 0);      /* button cur */
+                       coba->cur= a;
+                       break;
+               }
+       }
+}
+
+static void colorband_add_cb(bContext *C, void *coba_v, void *unused_v)
+{
+       ColorBand *coba= coba_v;
+       
+       if(coba->tot < MAXCOLORBAND-1) coba->tot++;
+       coba->cur= coba->tot-1;
+       
+       colorband_pos_cb(C, coba, NULL);
+       ED_undo_push(C, "Add colorband");
+}
+
+static void colorband_del_cb(bContext *C, void *coba_v, void *unused_v)
+{
+       ColorBand *coba= coba_v;
+       int a;
+       
+       if(coba->tot<2) return;
+       
+       for(a=coba->cur; a<coba->tot; a++) {
+               coba->data[a]= coba->data[a+1];
+       }
+       if(coba->cur) coba->cur--;
+       coba->tot--;
+       
+       ED_undo_push(C, "Delete colorband");
+       // XXX BIF_preview_changed(ID_TE);
+}
+
+
+/* offset aligns from bottom, standard width 300, height 115 */
+static void colorband_buttons_large(uiBlock *block, ColorBand *coba, int xoffs, int yoffs, int redraw)
+{
+       CBData *cbd;
+       uiBut *bt;
+       
+       if(coba==NULL) return;
+       
+       bt= uiDefBut(block, BUT, redraw,        "Add",          80+xoffs,95+yoffs,37,20, 0, 0, 0, 0, 0, "Adds a new color position to the colorband");
+       uiButSetFunc(bt, colorband_add_cb, coba, NULL);
+       uiDefButS(block, NUM, redraw,           "Cur:",         117+xoffs,95+yoffs,81,20, &coba->cur, 0.0, (float)(coba->tot-1), 0, 0, "Displays the active color from the colorband");
+       bt= uiDefBut(block, BUT, redraw,                "Del",          199+xoffs,95+yoffs,37,20, 0, 0, 0, 0, 0, "Deletes the active position");
+       uiButSetFunc(bt, colorband_del_cb, coba, NULL);
+       
+       uiDefButS(block, MENU, redraw,          "Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4",
+               236+xoffs, 95+yoffs, 64, 20,            &coba->ipotype, 0.0, 0.0, 0, 0, "Sets interpolation type");
+
+       uiDefBut(block, BUT_COLORBAND, redraw, "",      xoffs,65+yoffs,300,30, coba, 0, 0, 0, 0, "");
+       
+       cbd= coba->data + coba->cur;
+       
+       uiBlockBeginAlign(block);
+       bt= uiDefButF(block, NUM, redraw, "Pos",                xoffs,40+yoffs,110,20, &cbd->pos, 0.0, 1.0, 10, 0, "Sets the position of the active color");
+       uiButSetFunc(bt, colorband_pos_cb, coba, NULL);
+       uiDefButF(block, COL, redraw,           "",             xoffs,20+yoffs,110,20, &(cbd->r), 0, 0, 0, B_BANDCOL, "");
+       uiDefButF(block, NUMSLI, redraw,        "A ",   xoffs,yoffs,110,20, &cbd->a, 0.0, 1.0, 10, 0, "Sets the alpha value for this position");
+
+       uiBlockBeginAlign(block);
+       uiDefButF(block, NUMSLI, redraw,        "R ",   115+xoffs,40+yoffs,185,20, &cbd->r, 0.0, 1.0, B_BANDCOL, 0, "Sets the red value for the active color");
+       uiDefButF(block, NUMSLI, redraw,        "G ",   115+xoffs,20+yoffs,185,20, &cbd->g, 0.0, 1.0, B_BANDCOL, 0, "Sets the green value for the active color");
+       uiDefButF(block, NUMSLI, redraw,        "B ",   115+xoffs,yoffs,185,20, &cbd->b, 0.0, 1.0, B_BANDCOL, 0, "Sets the blue value for the active color");
+       uiBlockEndAlign(block);
+}
+
+static void colorband_buttons_small(uiBlock *block, ColorBand *coba, rctf *butr, int event)
+{
+       CBData *cbd;
+       uiBut *bt;
+       float unit= (butr->xmax-butr->xmin)/14.0f;
+       float xs= butr->xmin;
+       
+       cbd= coba->data + coba->cur;
+       
+       uiBlockBeginAlign(block);
+       uiDefButF(block, COL, event,            "",                     xs,butr->ymin+20.0f,2.0f*unit,20,                               &(cbd->r), 0, 0, 0, B_BANDCOL, "");
+       uiDefButF(block, NUM, event,            "A:",           xs+2.0f*unit,butr->ymin+20.0f,4.0f*unit,20,     &(cbd->a), 0.0f, 1.0f, 10, 2, "");
+       bt= uiDefBut(block, BUT, event, "Add",          xs+6.0f*unit,butr->ymin+20.0f,2.0f*unit,20,     NULL, 0, 0, 0, 0, "Adds a new color position to the colorband");
+       uiButSetFunc(bt, colorband_add_cb, coba, NULL);
+       bt= uiDefBut(block, BUT, event, "Del",          xs+8.0f*unit,butr->ymin+20.0f,2.0f*unit,20,     NULL, 0, 0, 0, 0, "Deletes the active position");
+       uiButSetFunc(bt, colorband_del_cb, coba, NULL);
+
+       uiDefButS(block, MENU, event,           "Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4",
+               xs+10.0f*unit, butr->ymin+20.0f, unit*4, 20,            &coba->ipotype, 0.0, 0.0, 0, 0, "Sets interpolation type");
+
+       uiDefBut(block, BUT_COLORBAND, event, "",               xs,butr->ymin,butr->xmax-butr->xmin,20.0f, coba, 0, 0, 0, 0, "");
+       uiBlockEndAlign(block);
+       
+}
+
+void colorband_buttons(uiBlock *block, ColorBand *coba, rctf *butr, int small)
+{
+       if(small)
+               colorband_buttons_small(block, coba, butr, 0);
+       else
+               colorband_buttons_large(block, coba, 0, 0, 0);
+}
+
index f4e3a7f289985628f20a72d484796c6d372c6279..e3f850ddfd4a0b520baac1d5ba1a856cd2520a0b 100644 (file)
@@ -630,7 +630,8 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
 
 static void widget_draw_icon(uiBut *but, BIFIconID icon, int blend, rcti *rect)
 {
-       float xs=0, ys=0, aspect, height;
+       int xs=0, ys=0;
+       float aspect, height;
        
        /* this icon doesn't need draw... */
        if(icon==ICON_BLANK1 && (but->flag & UI_ICON_SUBMENU)==0) return;
@@ -663,33 +664,36 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, int blend, rcti *rect)
                if(but->flag & UI_ICON_LEFT) {
                        if (but->type==BUT_TOGDUAL) {
                                if (but->drawstr[0]) {
-                                       xs= rect->xmin-1.0;
+                                       xs= rect->xmin-1;
                                } else {
-                                       xs= (rect->xmin+rect->xmax- height)/2.0;
+                                       xs= (rect->xmin+rect->xmax- height)/2;
                                }
                        }
                        else if (but->block->flag & UI_BLOCK_LOOP) {
-                               xs= rect->xmin+1.0;
+                               if(but->type==SEARCH_MENU)
+                                       xs= rect->xmin+4;
+                               else
+                                       xs= rect->xmin+1;
                        }
                        else if ((but->type==ICONROW) || (but->type==ICONTEXTROW)) {
-                               xs= rect->xmin+3.0;
+                               xs= rect->xmin+3;
                        }
                        else {
-                               xs= rect->xmin+4.0;
+                               xs= rect->xmin+4;
                        }
-                       ys= (rect->ymin+rect->ymax- height)/2.0;
+                       ys= (rect->ymin+rect->ymax- height)/2;
                }
                else {
-                       xs= (rect->xmin+rect->xmax- height)/2.0;
-                       ys= (rect->ymin+rect->ymax- height)/2.0;
+                       xs= (rect->xmin+rect->xmax- height)/2;
+                       ys= (rect->ymin+rect->ymax- height)/2;
                }
        
                UI_icon_draw_aspect_blended(xs, ys, icon, aspect, blend);
        }
        
        if(but->flag & UI_ICON_SUBMENU) {
-               xs= rect->xmax-17.0;
-               ys= (rect->ymin+rect->ymax- height)/2.0;
+               xs= rect->xmax-17;
+               ys= (rect->ymin+rect->ymax- height)/2;
                
                UI_icon_draw_aspect_blended(xs, ys, ICON_RIGHTARROW_THIN, aspect, blend);
        }
@@ -844,29 +848,23 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
                        widget_draw_icon(but, ICON_DOT, dualset?0:-100, rect);
                }
                
-               if(but->drawstr[0]!=0) {
+               /* If there's an icon too (made with uiDefIconTextBut) then draw the icon
+               and offset the text label to accomodate it */
+               
+               if (but->flag & UI_HAS_ICON) {
+                       widget_draw_icon(but, but->icon, 0, rect);
                        
-                       /* If there's an icon too (made with uiDefIconTextBut) then draw the icon
-                       and offset the text label to accomodate it */
+                       rect->xmin += UI_icon_get_width(but->icon);
                        
-                       if (but->flag & UI_HAS_ICON) {
-                               widget_draw_icon(but, but->icon, 0, rect);
-                               
-                               rect->xmin += UI_icon_get_width(but->icon);
-                               
-                               if(but->editstr || (but->flag & UI_TEXT_LEFT)) 
-                                       rect->xmin += 5;
-                       }
-                       else if(but->flag & UI_TEXT_LEFT)
+                       if(but->editstr || (but->flag & UI_TEXT_LEFT)) 
                                rect->xmin += 5;
-                       
-                       widget_draw_text(fstyle, wcol, but, rect);
-                       
-               }
-               /* if there's no text label, then check to see if there's an icon only and draw it */
-               else if( but->flag & UI_HAS_ICON ) {
-                       widget_draw_icon(but, (BIFIconID) (but->icon+but->iconadd), 0, rect);
                }
+               else if(but->flag & UI_TEXT_LEFT)
+                       rect->xmin += 5;
+               
+               /* always draw text for textbutton cursor */
+               widget_draw_text(fstyle, wcol, but, rect);
+
        }
 }
 
@@ -1220,8 +1218,8 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
        
        /* menu is 2nd level or deeper */
        if (flag & UI_BLOCK_POPUP) {
-               rect->ymin -= 4.0;
-               rect->ymax += 4.0;
+               //rect->ymin -= 4.0;
+               //rect->ymax += 4.0;
        }
        else if (direction == UI_DOWN) {
                roundboxalign= 12;
@@ -1473,7 +1471,7 @@ static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roun
        widget_init(&wtb);
        
        /* half rounded */
-       round_box_edges(&wtb, roundboxalign, rect, 4.0f);
+       round_box_edges(&wtb, roundboxalign, rect, 5.0f);
        
        widgetbase_draw(&wtb, wcol);
 
@@ -1827,6 +1825,7 @@ void ui_draw_but(ARegion *ar, uiStyle *style, uiBut *but, rcti *rect)
                                wt= widget_type(UI_WTYPE_RADIO);
                                break;
                        case TEX:
+                       case SEARCH_MENU:
                                wt= widget_type(UI_WTYPE_NAME);
                                break;
                        case TOGBUT:
@@ -1918,4 +1917,60 @@ void ui_draw_menu_back(uiStyle *style, uiBlock *block, rcti *rect)
        
 }
 
+void ui_draw_search_back(uiStyle *style, uiBlock *block, rcti *rect)
+{
+       uiWidgetType *wt= widget_type(UI_WTYPE_BOX);
+       
+       glEnable(GL_BLEND);
+       widget_softshadow(rect, 15, 5.0f, 8.0f);
+       glDisable(GL_BLEND);
+
+       wt->state(wt, 0);
+       if(block)
+               wt->draw(&wt->wcol, rect, block->flag, 15);
+       else
+               wt->draw(&wt->wcol, rect, 0, 15);
+       
+}
+
+
+/* helper call to draw a menu item without button */
+/* state: UI_ACTIVE or 0 */
+void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, char *name, int state)
+{
+       uiWidgetType *wt= widget_type(UI_WTYPE_MENU_ITEM);
+       rcti _rect= *rect;
+       char *cpoin;
+       
+       wt->state(wt, state);
+       wt->draw(&wt->wcol, rect, 0, 0);
+       
+       uiStyleFontSet(fstyle);
+       fstyle->align= UI_STYLE_TEXT_LEFT;
+       
+       /* text location offset */
+       rect->xmin+=5;
+
+       /* cut string in 2 parts? */
+       cpoin= strchr(name, '|');
+       if(cpoin) {
+               *cpoin= 0;
+               rect->xmax -= BLF_width(cpoin+1) + 10;
+       }
+       
+       glColor3ubv(wt->wcol.text);
+       uiStyleFontDraw(fstyle, rect, name);
+       
+       /* part text right aligned */
+       if(cpoin) {
+               fstyle->align= UI_STYLE_TEXT_RIGHT;
+               rect->xmax= _rect.xmax - 5;
+               uiStyleFontDraw(fstyle, rect, cpoin+1);
+               *cpoin= '|';
+       }
+       
+       /* restore rect, was messed with */
+       *rect= _rect;
+
+}
 
index b2cf3be6229ea56c4a42cd32b614f04e4b133a48..485dd890ac1a0a85773a863fffcd84ae9ccf7b49 100644 (file)
@@ -1000,7 +1000,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
     Object *ob = CTX_data_active_object(C);
-       bConstraint *con;
+       bConstraint *con, *coniter;
        ListBase *list= get_active_constraints(ob);
        bPoseChannel *pchan= get_active_posechannel(ob);
        int type= RNA_enum_get(op->ptr, "type");
@@ -1015,8 +1015,8 @@ static int constraint_add_exec(bContext *C, wmOperator *op)
                        con->flag |= CONSTRAINT_PROXY_LOCAL;
                
                con->flag |= CONSTRAINT_ACTIVE;
-               for(con= con->prev; con; con= con->prev)
-                       con->flag &= ~CONSTRAINT_ACTIVE;
+               for(coniter= coniter->prev; coniter; coniter= coniter->prev)
+                       coniter->flag &= ~CONSTRAINT_ACTIVE;
        }
        
        switch(type) {
index ce8bd7287f7f376c12fa613577edc942700faa2e..1eb867e19a059f091109de348158d925a6a56896 100644 (file)
@@ -87,6 +87,7 @@ void GROUP_OT_objects_remove_active(struct wmOperatorType *ot);
 /* object_modifier.c */
 void OBJECT_OT_modifier_add(struct wmOperatorType *ot);
 void OBJECT_OT_multires_subdivide(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_mdef_bind(struct wmOperatorType *ot);
 
 /* editconstraint.c */
 void OBJECT_OT_constraint_add(struct wmOperatorType *ot);
index 2e2c16ee6d641a5c71b2a16a0215a490ac18f637..e6b00fa71554bc288121869ac1b0541aea942533 100644 (file)
 #include "BKE_curve.h"
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
+#include "BKE_displist.h"
 #include "BKE_DerivedMesh.h"
 #include "BKE_global.h"
+#include "BKE_lattice.h"
 #include "BKE_mesh.h"
 #include "BKE_modifier.h"
 #include "BKE_multires.h"
@@ -396,6 +398,80 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
+/************************ mdef bind operator *********************/
+
+static int modifier_mdef_bind_poll(bContext *C)
+{
+       PointerRNA ptr= CTX_data_pointer_get(C, "modifier");
+       return RNA_struct_is_a(ptr.type, &RNA_MeshDeformModifier);
+}
+
+static int modifier_mdef_bind_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       PointerRNA ptr= CTX_data_pointer_get(C, "modifier");
+       Object *ob= ptr.id.data;
+       MeshDeformModifierData *mmd= ptr.data;
+
+       if(mmd->bindcos) {
+               if(mmd->bindweights) MEM_freeN(mmd->bindweights);
+               if(mmd->bindcos) MEM_freeN(mmd->bindcos);
+               if(mmd->dyngrid) MEM_freeN(mmd->dyngrid);
+               if(mmd->dyninfluences) MEM_freeN(mmd->dyninfluences);
+               if(mmd->dynverts) MEM_freeN(mmd->dynverts);
+               mmd->bindweights= NULL;
+               mmd->bindcos= NULL;
+               mmd->dyngrid= NULL;
+               mmd->dyninfluences= NULL;
+               mmd->dynverts= NULL;
+               mmd->totvert= 0;
+               mmd->totcagevert= 0;
+               mmd->totinfluence= 0;
+       }
+       else {
+               DerivedMesh *dm;
+               int mode= mmd->modifier.mode;
+
+               /* force modifier to run, it will call binding routine */
+               mmd->needbind= 1;
+               mmd->modifier.mode |= eModifierMode_Realtime;
+
+               if(ob->type == OB_MESH) {
+                       dm= mesh_create_derived_view(scene, ob, 0);
+                       dm->release(dm);
+               }
+               else if(ob->type == OB_LATTICE) {
+                       lattice_calc_modifiers(scene, ob);
+               }
+               else if(ob->type==OB_MBALL) {
+                       makeDispListMBall(scene, ob);
+               }
+               else if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
+                       makeDispListCurveTypes(scene, ob, 0);
+               }
+
+               mmd->needbind= 0;
+               mmd->modifier.mode= mode;
+       }
+       
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_mdef_bind(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Mesh Deform Bind";
+       ot->description = "Bind mesh to cage in mesh deform modifier.";
+       ot->idname= "OBJECT_OT_modifier_mdef_bind";
+       
+       /* api callbacks */
+       ot->poll= modifier_mdef_bind_poll;
+       ot->exec= modifier_mdef_bind_exec;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
 #if 0
 static void modifiers_add(void *ob_v, int type)
 {
@@ -469,3 +545,89 @@ static uiBlock *modifiers_add_menu(void *ob_v)
 }
 #endif
 
+#if 0
+static void modifiers_clearHookOffset(bContext *C, void *ob_v, void *md_v)
+{
+       Object *ob = ob_v;
+       ModifierData *md = md_v;
+       HookModifierData *hmd = (HookModifierData*) md;
+       
+       if (hmd->object) {
+               Mat4Invert(hmd->object->imat, hmd->object->obmat);
+               Mat4MulSerie(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL);
+               ED_undo_push(C, "Clear hook offset");
+       }
+}
+
+static void modifiers_cursorHookCenter(bContext *C, void *ob_v, void *md_v)
+{
+       /* XXX 
+       Object *ob = ob_v;
+       ModifierData *md = md_v;
+       HookModifierData *hmd = (HookModifierData*) md;
+
+       if(G.vd) {
+               float *curs = give_cursor();
+               float bmat[3][3], imat[3][3];
+
+               where_is_object(ob);
+       
+               Mat3CpyMat4(bmat, ob->obmat);
+               Mat3Inv(imat, bmat);
+
+               curs= give_cursor();
+               hmd->cent[0]= curs[0]-ob->obmat[3][0];
+               hmd->cent[1]= curs[1]-ob->obmat[3][1];
+               hmd->cent[2]= curs[2]-ob->obmat[3][2];
+               Mat3MulVecfl(imat, hmd->cent);
+
+               ED_undo_push(C, "Hook cursor center");
+       }*/
+}
+
+static void modifiers_selectHook(bContext *C, void *ob_v, void *md_v)
+{
+       /* XXX ModifierData *md = md_v;
+       HookModifierData *hmd = (HookModifierData*) md;
+
+       hook_select(hmd);*/
+}
+
+static void modifiers_reassignHook(bContext *C, void *ob_v, void *md_v)
+{
+       /* XXX ModifierData *md = md_v;
+       HookModifierData *hmd = (HookModifierData*) md;
+       float cent[3];
+       int *indexar, tot, ok;
+       char name[32];
+               
+       ok= hook_getIndexArray(&tot, &indexar, name, cent);
+
+       if (!ok) {
+               uiPupMenuError(C, "Requires selected vertices or active Vertex Group");
+       } else {
+               if (hmd->indexar) {
+                       MEM_freeN(hmd->indexar);
+               }
+
+               VECCOPY(hmd->cent, cent);
+               hmd->indexar = indexar;
+               hmd->totindex = tot;
+       }*/
+}
+
+void modifiers_explodeFacepa(bContext *C, void *arg1, void *arg2)
+{
+       ExplodeModifierData *emd=arg1;
+
+       emd->flag |= eExplodeFlag_CalcFaces;
+}
+
+void modifiers_explodeDelVg(bContext *C, void *arg1, void *arg2)
+{
+       ExplodeModifierData *emd=arg1;
+       emd->vgroup = 0;
+}
+#endif
+
+
index 9d8247522e16d3e8e307d2466c8c37ca88cf5554..cfee6a551527187cd4d428c0825b729685e67064 100644 (file)
@@ -101,6 +101,7 @@ void ED_operatortypes_object(void)
 
        WM_operatortype_append(OBJECT_OT_modifier_add);
        WM_operatortype_append(OBJECT_OT_multires_subdivide);
+       WM_operatortype_append(OBJECT_OT_modifier_mdef_bind);
 
        WM_operatortype_append(OBJECT_OT_constraint_add);
 }
index 1c2b3c6b309dab35e021df5bf8d72b8056ff3805..f60d5493058d77c28471b7a5aeb2c13c1b46e5b8 100644 (file)
@@ -3759,7 +3759,7 @@ static int set_editable_exec(bContext *C, wmOperator *op)
                                PE_free_particle_edit(psys);
 
                        psys->flag &= ~PSYS_EDITED;
-                       psys->recalc |= PSYS_RECALC_HAIR;
+                       psys->recalc |= PSYS_RECALC_RESET;
 
                        DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
                }
index 1d5d809a9ee5c7a82523663d7c79c7d4dfac25b0..85cb1e4e1bf9d2057e0b1ff13ae46762ea03e4d5 100644 (file)
@@ -586,7 +586,7 @@ void BIF_previewrender_buts(Scene *scene, SpaceButs *sbuts)
        sbuts->lockpoin= id;
        
        if(sbuts->mainb==CONTEXT_SHADING) {
-               int tab= sbuts->tab[CONTEXT_SHADING];
+               int tab= TAB_SHADING_MAT; // XXX sbuts->tab[CONTEXT_SHADING];
                
                if(tab==TAB_SHADING_MAT) 
                        idshow = sbuts->lockpoin;
index ad6b6e04b8e8e579176a5a8f4072c5bf8a3c216e..81b63b694ba1366bed5dc175ac7b3497a6b45921 100644 (file)
@@ -837,6 +837,11 @@ void ED_region_init(bContext *C, ARegion *ar)
        
        ar->winx= ar->winrct.xmax - ar->winrct.xmin + 1;
        ar->winy= ar->winrct.ymax - ar->winrct.ymin + 1;
+       
+       /* UI convention */
+       wmLoadIdentity();
+       wmOrtho2(-0.01f, ar->winx-0.01f, -0.01f, ar->winy-0.01f);
+       
 }
 
 
@@ -1132,7 +1137,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex
        for(pt= ar->type->paneltypes.first; pt; pt= pt->next) {
                /* verify context */
                if(context)
-                       if(!pt->context || strcmp(context, pt->context) != 0)
+                       if(pt->context[0] && strcmp(context, pt->context) != 0)
                                continue;
 
                /* draw panel */
index db1a39ed056ec779dbe0633ab6584242c4f3e9d7..3e237bff46a6ec5247813c1ae0441c968c22ed97 100644 (file)
@@ -231,7 +231,8 @@ int ED_operator_uvedit(bContext *C)
                return 1;
        }
 
-       BKE_mesh_end_editmesh(obedit->data, em);
+       if(obedit)
+               BKE_mesh_end_editmesh(obedit->data, em);
        return 0;
 }
 
@@ -248,7 +249,8 @@ int ED_operator_uvmap(bContext *C)
                return 1;
        }
 
-       BKE_mesh_end_editmesh(obedit->data, em);
+       if(obedit)
+               BKE_mesh_end_editmesh(obedit->data, em);
        return 0;
 }
 
@@ -612,18 +614,25 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event)
        bScreen *newsc, *sc;
        ScrArea *sa;
        rcti rect;
-       sActionzoneData *sad= event->customdata;
-
-       if(sad==NULL)
-               return OPERATOR_PASS_THROUGH;
        
        win= CTX_wm_window(C);
        sc= CTX_wm_screen(C);
-       sa= sad->sa1;
+       sa= CTX_wm_area(C);
+       
+       /* XXX hrmf! */
+       if(event->type==EVT_ACTIONZONE_AREA) {
+               sActionzoneData *sad= event->customdata;
 
+               if(sad==NULL)
+                       return OPERATOR_PASS_THROUGH;
+       
+               sa= sad->sa1;
+       }
+       
        /*  poll() checks area context, but we don't accept full-area windows */
        if(sc->full != SCREENNORMAL) {
-               actionzone_exit(C, op);
+               if(event->type==EVT_ACTIONZONE_AREA)
+                       actionzone_exit(C, op);
                return OPERATOR_CANCELLED;
        }
        
@@ -642,7 +651,8 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event)
        /* screen, areas init */
        WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
 
-       actionzone_exit(C, op);
+       if(event->type==EVT_ACTIONZONE_AREA)
+               actionzone_exit(C, op);
        
        return OPERATOR_FINISHED;
 }
@@ -1976,37 +1986,6 @@ static int region_flip_exec(bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
-static void testfunc(bContext *C, void *argv, int arg)
-{
-       printf("arg %d\n", arg);
-}
-
-static void newlevel1(bContext *C, uiLayout *layout, void *arg)
-{
-       uiLayoutSetFunc(layout, testfunc, NULL);
-       
-       uiItemV(layout, "First", ICON_PROP_ON, 1);
-       uiItemV(layout, "Second", ICON_PROP_CON, 2);
-       uiItemV(layout, "Third", ICON_SMOOTHCURVE, 3);
-       uiItemV(layout, "Fourth", ICON_SHARPCURVE, 4);  
-}
-
-static int testing123(bContext *C, wmOperator *op, wmEvent *event)
-{
-       uiPopupMenu *pup= uiPupMenuBegin(C, "Hello world", 0);
-       uiLayout *layout= uiPupMenuLayout(pup);
-       
-       uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
-       uiItemO(layout, NULL, ICON_PROP_ON, "SCREEN_OT_region_flip");
-       uiItemO(layout, NULL, ICON_PROP_CON, "SCREEN_OT_screen_full_area");
-       uiItemO(layout, NULL, ICON_SMOOTHCURVE, "SCREEN_OT_region_foursplit");
-       uiItemMenuF(layout, "Submenu", 0, newlevel1);
-       
-       uiPupMenuEnd(C, pup);
-       
-       /* this operator is only for a menu, not used further */
-       return OPERATOR_CANCELLED;
-}
 
 void SCREEN_OT_region_flip(wmOperatorType *ot)
 {
@@ -2015,13 +1994,10 @@ void SCREEN_OT_region_flip(wmOperatorType *ot)
        ot->idname= "SCREEN_OT_region_flip";
        
        /* api callbacks */
-       ot->invoke= testing123; // XXX WM_operator_confirm;
        ot->exec= region_flip_exec;
        
        ot->poll= ED_operator_areaactive;
        ot->flag= OPTYPE_REGISTER;
-       
-       RNA_def_int(ot->srna, "test", 0, INT_MIN, INT_MAX, "test", "", INT_MIN, INT_MAX);
 
 }
 
index 0c20c0cc1cf91e5eabd7ee0562ef1edfef69910e..0710079301b9e2710b100fc9acb1ac0e04bb2a31 100644 (file)
@@ -1274,7 +1274,7 @@ static void wpaint_exit(bContext *C, wmOperator *op)
                for(psys= ob->particlesystem.first; psys; psys= psys->next) {
                        for(i=0; i<PSYS_TOT_VG; i++) {
                                if(psys->vgroup[i]==ob->actdef) {
-                                       psys->recalc |= PSYS_RECALC_HAIR;
+                                       psys->recalc |= PSYS_RECALC_RESET;
                                        break;
                                }
                        }
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
new file mode 100644 (file)
index 0000000..3e6fa9c
--- /dev/null
@@ -0,0 +1,536 @@
+/**
+ * $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.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_armature_types.h"
+#include "DNA_lamp_types.h"
+#include "DNA_material_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+#include "DNA_particle_types.h"
+#include "DNA_texture_types.h"
+#include "DNA_world_types.h"
+
+#include "BLI_listbase.h"
+
+#include "BKE_context.h"
+#include "BKE_material.h"
+#include "BKE_modifier.h"
+#include "BKE_particle.h"
+#include "BKE_screen.h"
+#include "BKE_utildefines.h"
+
+#include "RNA_access.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "buttons_intern.h"    // own include
+
+typedef struct ButsContextPath {
+       PointerRNA ptr[8];
+       int len;
+} ButsContextPath;
+
+/************************* Creating the Path ************************/
+
+static int buttons_context_path_scene(ButsContextPath *path)
+{
+       PointerRNA *ptr= &path->ptr[path->len-1];
+
+       /* this one just verifies */
+       return RNA_struct_is_a(ptr->type, &RNA_Scene);
+}
+
+static int buttons_context_path_world(ButsContextPath *path)
+{
+       Scene *scene;
+       PointerRNA *ptr= &path->ptr[path->len-1];
+
+       /* if we already have a (pinned) world, we're done */
+       if(RNA_struct_is_a(ptr->type, &RNA_World)) {
+               return 1;
+       }
+       /* if we have a scene, use the scene's world */
+       else if(buttons_context_path_scene(path)) {
+               scene= path->ptr[path->len-1].data;
+
+               RNA_id_pointer_create(&scene->world->id, &path->ptr[path->len]);
+               path->len++;
+
+               return 1;
+       }
+
+       /* no path to a world possible */
+       return 0;
+}
+
+static int buttons_context_path_object(ButsContextPath *path)
+{
+       Scene *scene;
+       Object *ob;
+       PointerRNA *ptr= &path->ptr[path->len-1];
+
+       /* if we already have a (pinned) object, we're done */
+       if(RNA_struct_is_a(ptr->type, &RNA_Object)) {
+               return 1;
+       }
+       /* if we have a scene, use the scene's active object */
+       else if(buttons_context_path_scene(path)) {
+               scene= path->ptr[path->len-1].data;
+               ob= (scene->basact)? scene->basact->object: NULL;
+
+               if(ob) {
+                       RNA_id_pointer_create(&ob->id, &path->ptr[path->len]);
+                       path->len++;
+
+                       return 1;
+               }
+       }
+
+       /* no path to a object possible */
+       return 0;
+}
+
+static int buttons_context_path_data(ButsContextPath *path, int type)
+{
+       Object *ob;
+
+       /* try to get an object in the path, no pinning supported here */
+       if(buttons_context_path_object(path)) {
+               ob= path->ptr[path->len-1].data;
+
+               if(type == -1 || type == ob->type) {
+                       RNA_id_pointer_create(ob->data, &path->ptr[path->len]);
+                       path->len++;
+
+                       return 1;
+               }
+       }
+
+       /* no path to data possible */
+       return 0;
+}
+
+static int buttons_context_path_material(ButsContextPath *path)
+{
+       Object *ob;
+       PointerRNA *ptr= &path->ptr[path->len-1];
+
+       /* if we already have a (pinned) material, we're done */
+       if(RNA_struct_is_a(ptr->type, &RNA_Material)) {
+               return 1;
+       }
+       /* if we have an object, use the object material slot */
+       else if(buttons_context_path_object(path)) {
+               ob= path->ptr[path->len-1].data;
+
+               if(ob && ob->type && (ob->type<OB_LAMP)) {
+                       RNA_pointer_create(&ob->id, &RNA_MaterialSlot, ob->mat+ob->actcol-1, &path->ptr[path->len]);
+                       path->len++;
+                       return 1;
+               }
+       }
+
+       /* no path to a material possible */
+       return 0;
+}
+
+static Bone *find_active_bone(Bone *bone)
+{
+       Bone *active;
+
+       for(; bone; bone=bone->next) {
+               if(bone->flag & BONE_ACTIVE)
+                       return bone;
+
+               active= find_active_bone(bone->childbase.first);
+               if(active)
+                       return active;
+       }
+
+       return NULL;
+}
+
+static int buttons_context_path_bone(ButsContextPath *path)
+{
+       bArmature *arm;
+       Bone *bone;
+
+       /* if we have an armature, get the active bone */
+       if(buttons_context_path_data(path, OB_ARMATURE)) {
+               arm= path->ptr[path->len-1].data;
+               bone= find_active_bone(arm->bonebase.first);
+
+     &nbs