{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
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
{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
<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
__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")
__label__ = "Display"
def draw(self, context):
- arm = context.active_object.data
+ arm = context.armature
layout = self.layout
split = layout.split()
__label__ = "Paths"
def draw(self, context):
- arm = context.active_object.data
+ arm = context.armature
layout = self.layout
split = layout.split()
__label__ = "Ghost"
def draw(self, context):
- arm = context.active_object.data
+ arm = context.armature
layout = self.layout
split = layout.split()
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)
__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()
__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)
__label__ = "Display"
def draw(self, context):
- cam = context.active_object.data
+ cam = context.camera
layout = self.layout
split = layout.split()
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)
__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")
__label__ = "Geometry"
def draw(self, context):
- curve = context.active_object.data
+ curve = context.curve
layout = self.layout
split = layout.split()
__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
__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()
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)
__context__ = "data"
def poll(self, context):
- ob = context.active_object
+ ob = context.object
return (ob and ob.type == 'EMPTY')
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)
__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)
__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()
__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)
__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()
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)
+
__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()
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)
__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()
layout.itemR(mesh, "texco_mesh")
-bpy.types.register(DATA_PT_surface)
\ No newline at end of file
+bpy.types.register(DATA_PT_surface)
__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):
__label__ = "Modifiers"
def draw(self, context):
- ob = context.active_object
+ ob = context.object
layout = self.layout
row = layout.row()
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':
layout.itemR(md, "length")
if md.fit_type == 'FIT_CURVE':
layout.itemR(md, "curve")
+
+ layout.itemS()
split = layout.split()
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
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")
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")
__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):
__label__ = "Shape"
def draw(self, context):
- curve = context.active_object.data
+ curve = context.curve
layout = self.layout
layout.itemR(curve, "curve_2d")
__label__ = "Font"
def draw(self, context):
- text = context.active_object.data
+ text = context.curve
layout = self.layout
layout.row()
__label__ = "Paragraph"
def draw(self, context):
- text = context.active_object.data
+ text = context.curve
layout = self.layout
layout.itemL(text="Align:")
__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)
__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"
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):
def draw(self, context):
layout = self.layout
- mat = context.active_object.active_material
+ mat = context.material
layout.itemR(mat, "type", expand=True)
__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()
__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()
__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()
__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()
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)
+
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":
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":
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()
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)
__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()
__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()
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)
+
__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()
__label__ = "Groups"
def draw(self, context):
- ob = context.active_object
+ ob = context.object
layout = self.layout
row = layout.row()
__label__ = "Display"
def draw(self, context):
- ob = context.active_object
+ ob = context.object
layout = self.layout
row = layout.row()
__label__ = "Duplication"
def draw(self, context):
- ob = context.active_object
+ ob = context.object
layout = self.layout
layout.itemR(ob, "dupli_type", expand=True)
__label__ = "Animation"
def draw(self, context):
- ob = context.active_object
+ ob = context.object
layout = self.layout
split = layout.split()
bpy.types.register(OBJECT_PT_display)
bpy.types.register(OBJECT_PT_duplication)
bpy.types.register(OBJECT_PT_animation)
+
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)
__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"
def draw(self, context):
layout = self.layout
- md = self.cloth_modifier(context)
+ md = context.cloth
cloth = md.settings
split = layout.split()
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="")
def draw(self, context):
layout = self.layout
- md = self.cloth_modifier(context)
+ md = context.cloth
cloth = md.collision_settings
layout.active = cloth.enable_collision
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="")
def draw(self, context):
layout = self.layout
- md = self.cloth_modifier(context)
+ md = context.cloth
cloth = md.settings
layout.active = cloth.stiffness_scaling
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)
__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"
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):
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:")
__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)
__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)
__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")
__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")
__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:")
__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()
__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()
__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")
__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")
__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")
__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")
__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")
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)
__context__ = "world"
def poll(self, context):
- return (context.scene.world != None)
+ return (context.world != None)
class WORLD_PT_preview(WorldButtonsPanel):
__label__ = "Preview"
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()
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()
__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
__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
__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
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)
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);
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);
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;
}
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)
{
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)
{
}
}
-/* 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);
}
}
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){
}
}
- 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 */
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);
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;
init= 1;
}
- if(psys->recalc & PSYS_DISTR) {
+ if(psys->recalc & PSYS_RECALC_RESET) {
distr= 1;
init= 1;
}
}
if(only_children_changed==0) {
+ free_keyed_keys(psys);
+
initialize_all_particles(ob, psys, psmd);
if(alloc)
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;
}
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;
else
skip = 1;
}
+ else if((psys->recalc & PSYS_RECALC_RESET)==0)
+ skip = 1;
if(skip == 0) {
BKE_ptcache_id_from_particles(&pid, ob, psys);
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);
}
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) {
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;
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;
}
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;
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;
Mesh *me;
Scene *sce;
Tex *tx;
+ ParticleSettings *part;
for(screen= main->screen.first; screen; screen= screen->id.next) {
do_versions_windowmanager_2_50(screen);
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
#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 */
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);
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 */
struct uiStyle;
struct uiFontStyle;
struct ColorBand;
+struct CurveMapping;
typedef struct uiBut uiBut;
typedef struct uiBlock uiBlock;
#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
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);
*
* 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);
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
#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);
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);
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);
// 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);
/* 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 */
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;
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;
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;
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;
/* 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 ) {
case IDPOIN:
case TEX:
+ case SEARCH_MENU:
if(!but->editstr) {
char str[UI_MAX_DRAW_STR];
block->func_arg2= arg2;
}
+void uiBlockSetRenameFunc(uiBlock *block, uiButHandleRenameFunc func, void *arg1)
+{
+
+}
+
void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)())
{
block->drawextra= func;
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)
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.");
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.");
}
/* overall state */
uiHandleButtonState state;
- int cancel, retval;
+ int cancel, escapecancel, retval;
int applied, appliedinteractive;
wmTimer *flashtimer;
/* menu open */
uiPopupBlockHandle *menu;
int menuretval;
+
+ /* search box */
+ ARegion *searchbox;
/* post activate */
uiButtonActivateType posttype;
uiButHandleFunc func;
void *func_arg1;
void *func_arg2;
-
+ void *func_arg3;
+
uiButHandleNFunc funcN;
void *func_argN;
PointerRNA rnapoin;
PropertyRNA *rnaprop;
+
+ bContextStore *context;
} uiAfterFunc;
static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state);
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;
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;
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)
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);
+ }
}
}
/* 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;
ui_apply_but_BUT(C, but, data);
break;
case TEX:
+ case SEARCH_MENU:
ui_apply_but_TEX(C, but, data);
break;
case TOGBUT:
}
}
- return WM_UI_HANDLER_BREAK;
+ return changed;
}
void ui_textedit_move(uiBut *but, uiHandleButtonData *data, int direction, int select, int jump)
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++)
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);
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;
}
}
}
}
+
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;
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;
}
}
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;
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))
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;
}
}
}
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
}
}
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
break;
case TEX:
case IDPOIN:
+ case SEARCH_MENU:
retval= ui_do_but_TEX(C, block, but, data, event);
break;
case MENU:
/* 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)
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 */
/* 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 */
/************** 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;
}
uiButHandleFunc func;
void *func_arg1;
void *func_arg2;
+ void *func_arg3;
uiButHandleNFunc funcN;
void *func_argN;
uiButCompleteFunc autocomplete_func;
void *autofunc_arg;
+ uiButSearchFunc search_func;
+ void *search_arg;
+
uiLink *link;
char *tip, *lockstr;
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,
/* 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);
typedef struct uiItem {
void *next, *prev;
uiItemType type;
+ int flag;
} uiItem;
typedef struct uiButtonItem {
ListBase items;
int x, y, w, h;
- float scale;
+ float scale[2];
short space;
char align;
char active;
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;
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 */
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)
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)
}
}
+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);
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;
}
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;
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);
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)
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;
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);
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)
#include "BIF_gl.h"
#include "UI_interface.h"
+#include "UI_interface_icons.h"
#include "UI_view2d.h"
#include "BLF_api.h"
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 */
/* 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);
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);
}
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);
#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"
#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);
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);
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);
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);
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);
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);
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);
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, "");
/* 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);
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); */
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 */
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);
}
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) {
}
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 */
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;
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);
}
// 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) {
}
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");
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");
}
break;
+ */
case CONSTRAINT_TYPE_NULL:
{
}
+/********************** 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);
+ }
+}
+
#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"
#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;
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;
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);
+}
+
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;
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);
}
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);
+
}
}
/* 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;
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);
wt= widget_type(UI_WTYPE_RADIO);
break;
case TEX:
+ case SEARCH_MENU:
wt= widget_type(UI_WTYPE_NAME);
break;
case TOGBUT:
}
+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;
+
+}
{
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");
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) {
/* 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);
#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"
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)
{
}
#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
+
+
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);
}
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);
}
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;
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);
+
}
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 */
return 1;
}
- BKE_mesh_end_editmesh(obedit->data, em);
+ if(obedit)
+ BKE_mesh_end_editmesh(obedit->data, em);
return 0;
}
return 1;
}
- BKE_mesh_end_editmesh(obedit->data, em);
+ if(obedit)
+ BKE_mesh_end_editmesh(obedit->data, em);
return 0;
}
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;
}
/* 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;
}
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)
{
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);
}
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;
}
}
--- /dev/null
+/**
+ * $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