forked from bartvdbraak/blender
1b1667018e
* Added Constraints template and Add Constraint operator. * Added toggle=True/False parameter to uiItemR, to get a toggle button (actual button) rather than an "option" button (checkbox) * Added OPTION/OPTIONN button type, to distinguish with TOG/TOGN. RNA: * Make all modifier pointers editable, including correct updates. * Added notifiers and updates to constraints. * Fix a stack corruption, pointed out by Andrea, and potentially causing crashes.
55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
|
|
import bpy
|
|
|
|
class DataButtonsPanel(bpy.types.Panel):
|
|
__space_type__ = "BUTTONS_WINDOW"
|
|
__region_type__ = "WINDOW"
|
|
__context__ = "object"
|
|
|
|
def poll(self, context):
|
|
ob = context.active_object
|
|
return (ob != None)
|
|
|
|
class DATA_PT_constraints(DataButtonsPanel):
|
|
__idname__ = "DATA_PT_constraints"
|
|
__label__ = "Constraints"
|
|
|
|
def draw(self, context):
|
|
ob = context.active_object
|
|
layout = self.layout
|
|
|
|
row = layout.row()
|
|
row.item_menu_enumO("OBJECT_OT_constraint_add", "type")
|
|
row.itemL();
|
|
|
|
for con in ob.constraints:
|
|
box = layout.template_constraint(con)
|
|
|
|
if box:
|
|
if con.type == 'COPY_LOCATION':
|
|
self.copy_location(box, con)
|
|
|
|
def copy_location(self, layout, con):
|
|
layout.itemR(con, "target")
|
|
|
|
if con.target and con.target.type == "ARMATURE":
|
|
layout.itemR(con, "subtarget", text="Bone") # XXX autocomplete
|
|
row = layout.row()
|
|
row.itemL(text="Head/Tail:")
|
|
row.itemR(con, "head_tail", text="")
|
|
elif con.target and con.target.type == "MESH":
|
|
layout.itemR(con, "subtarget", text="Vertex Group") # XXX autocomplete
|
|
|
|
row = layout.row(align=True)
|
|
row.itemR(con, "locate_like_x", text="X", toggle=True)
|
|
row.itemR(con, "invert_x", text="-", toggle=True)
|
|
row.itemR(con, "locate_like_y", text="Y", toggle=True)
|
|
row.itemR(con, "invert_y", text="-", toggle=True)
|
|
row.itemR(con, "locate_like_z", text="Z", toggle=True)
|
|
row.itemR(con, "invert_z", text="-", toggle=True)
|
|
|
|
layout.itemR(con, "offset")
|
|
|
|
bpy.types.register(DATA_PT_constraints)
|
|
|