blender/scripts/startup/bl_ui/properties_data_armature.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

288 lines
8.3 KiB
Python
Raw Normal View History

# SPDX-License-Identifier: GPL-2.0-or-later
import bpy
from bpy.types import Panel, Menu, UIList
from rna_prop_ui import PropertyPanel
2011-03-27 05:23:14 +00:00
from bl_ui.properties_animviz import (
2019-03-19 23:44:13 +00:00
MotionPathButtonsPanel,
MotionPathButtonsPanel_display,
)
2011-09-20 18:29:19 +00:00
2019-04-09 13:16:11 +00:00
class ArmatureButtonsPanel:
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "data"
@classmethod
def poll(cls, context):
return context.armature
class DATA_PT_context_arm(ArmatureButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
def draw(self, context):
layout = self.layout
ob = context.object
arm = context.armature
space = context.space_data
if ob:
layout.template_ID(ob, "data")
elif arm:
layout.template_ID(space, "pin_id")
class DATA_PT_skeleton(ArmatureButtonsPanel, Panel):
bl_label = "Skeleton"
def draw(self, context):
layout = self.layout
arm = context.armature
layout.row().prop(arm, "pose_position", expand=True)
col = layout.column()
col.label(text="Layers:")
2010-08-18 07:45:32 +00:00
col.prop(arm, "layers", text="")
col.label(text="Protected Layers:")
col.prop(arm, "layers_protected", text="")
class DATA_PT_display(ArmatureButtonsPanel, Panel):
bl_label = "Viewport Display"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
layout.use_property_split = True
ob = context.object
arm = context.armature
layout.prop(arm, "display_type", text="Display As")
UI: Layout changes for new checkbox layout possibilities Follow-up to previous commit. Some examples: {F8473507} {F8473508} {F8473509} {F8473510} For more screenshots, please see D7430. We use column or row headings here to bring more structure, and to give the eye visual anchors which aid eye-scanning. The left-aligned checkboxes likewise help with this. And we keep the adherence to the center line, so the alignment matches up between the various buttons and controls. * Changes the property split percentage from 50/50% to 40/60%. This is needed to give enough space for the checkboxes. But in most cases this looks better anyway - see Transform panel. In some cases it simply fills out the available space more efficently. * Fix various hacks where we previously used manually defined splits. When we did this, the alignment was never quite right, and the layout code was a mess. * Adds column headings to many places where a list of checkboxes all share a common purpose or leading text. * Add checkbox + value configurations various places where a checkbox only serves to enable the value slider * Removes most uses of grid flow layout. The grid flow layouts combine poorly with column headings, and also they would mess alignment up badly. The grid flow layouts also often made buttons and controls jump around on the screen if you would just resize editors slightly, causing visual confusion, making users lose their place. The logic for at what time the list of items would re-flow was often flawed, jumping to multiple columns too fast or too late - and frankly, the grid flow layouts would often just look bad. Maniphest Task: https://developer.blender.org/T65965 Differential Revision: https://developer.blender.org/D7430 Reviewed by: Brecht Van Lommel, Pablo Vazquez. Most work here by William Reynish, few changes by Julian Eisel.
2020-04-17 14:54:03 +00:00
col = layout.column(heading="Show")
col.prop(arm, "show_names", text="Names")
col.prop(arm, "show_bone_custom_shapes", text="Shapes")
col.prop(arm, "show_group_colors", text="Group Colors")
if ob:
col.prop(ob, "show_in_front", text="In Front")
col = layout.column(align=False, heading="Axes")
row = col.row(align=True)
row.prop(arm, "show_axes", text="")
sub = row.row(align=True)
sub.active = arm.show_axes
sub.prop(arm, "axes_position", text="Position")
class DATA_MT_bone_group_context_menu(Menu):
bl_label = "Bone Group Specials"
def draw(self, _context):
layout = self.layout
layout.operator("pose.group_sort", icon='SORTALPHA')
class DATA_UL_bone_groups(UIList):
def draw_item(self, _context, layout, _data, item, _icon, _active_data, _active_propname, _index):
layout.prop(item, "name", text="", emboss=False, icon='GROUP_BONE')
if item.is_custom_color_set or item.color_set == 'DEFAULT':
layout.prop(item, "color_set", icon_only=True, icon="COLOR")
else:
layout.prop(item, "color_set", icon_only=True)
class DATA_PT_bone_groups(ArmatureButtonsPanel, Panel):
bl_label = "Bone Groups"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
return (context.object and context.object.type == 'ARMATURE' and context.object.pose)
def draw(self, context):
layout = self.layout
ob = context.object
pose = ob.pose
group = pose.bone_groups.active
row = layout.row()
rows = 1
if group:
rows = 4
2019-05-21 14:27:01 +00:00
row.template_list(
"DATA_UL_bone_groups",
2019-05-21 14:27:01 +00:00
"bone_groups",
pose,
"bone_groups",
pose.bone_groups,
"active_index",
rows=rows,
)
col = row.column(align=True)
col.operator("pose.group_add", icon='ADD', text="")
col.operator("pose.group_remove", icon='REMOVE', text="")
col.menu("DATA_MT_bone_group_context_menu", icon='DOWNARROW_HLT', text="")
if group:
col.separator()
col.operator("pose.group_move", icon='TRIA_UP', text="").direction = 'UP'
col.operator("pose.group_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
if group.is_custom_color_set:
col = layout.column()
split = col.split(factor=0.4)
col = split.column()
row = col.row()
row.alignment = 'RIGHT'
row.label(text="Custom Colors")
col = split.column(align=True)
row = col.row(align=True)
row.prop(group.colors, "normal", text="")
row.prop(group.colors, "select", text="")
row.prop(group.colors, "active", text="")
row = layout.row()
sub = row.row(align=True)
sub.operator("pose.group_assign", text="Assign")
# row.operator("pose.bone_group_remove_from", text="Remove")
sub.operator("pose.group_unassign", text="Remove")
sub = row.row(align=True)
sub.operator("pose.group_select", text="Select")
sub.operator("pose.group_deselect", text="Deselect")
2010-01-31 14:46:28 +00:00
class DATA_PT_iksolver_itasc(ArmatureButtonsPanel, Panel):
bl_label = "Inverse Kinematics"
bl_options = {"DEFAULT_CLOSED"}
@classmethod
def poll(cls, context):
ob = context.object
return ob and ob.pose
def draw(self, context):
layout = self.layout
layout.use_property_split = True
ob = context.object
itasc = ob.pose.ik_param
layout.prop(ob.pose, "ik_solver")
2009-12-17 13:14:29 +00:00
if itasc:
layout.prop(itasc, "mode")
2009-12-17 13:14:29 +00:00
simulation = (itasc.mode == 'SIMULATION')
if simulation:
layout.prop(itasc, "reiteration_method", expand=False)
col = layout.column()
col.active = not simulation or itasc.reiteration_method != 'NEVER'
col.prop(itasc, "precision")
col.prop(itasc, "iterations")
2009-12-17 13:14:29 +00:00
if simulation:
col.prop(itasc, "use_auto_step")
sub = layout.column(align=True)
if itasc.use_auto_step:
sub.prop(itasc, "step_min", text="Steps Min")
sub.prop(itasc, "step_max", text="Max")
2009-12-17 13:14:29 +00:00
else:
sub.prop(itasc, "step_count", text="Steps")
2009-12-17 13:14:29 +00:00
col.prop(itasc, "solver")
2009-12-17 13:14:29 +00:00
if simulation:
col.prop(itasc, "feedback")
col.prop(itasc, "velocity_max")
2009-12-17 13:14:29 +00:00
if itasc.solver == 'DLS':
col.separator()
col.prop(itasc, "damping_max", text="Damping Max", slider=True)
col.prop(itasc, "damping_epsilon", text="Damping Epsilon", slider=True)
class DATA_PT_motion_paths(MotionPathButtonsPanel, Panel):
#bl_label = "Bones Motion Paths"
bl_options = {'DEFAULT_CLOSED'}
bl_context = "data"
@classmethod
def poll(cls, context):
2011-10-17 06:58:07 +00:00
# XXX: include pose-mode check?
return (context.object) and (context.armature)
def draw(self, context):
# layout = self.layout
ob = context.object
avs = ob.pose.animation_visualization
2012-05-15 18:50:51 +00:00
pchan = context.active_pose_bone
mpath = pchan.motion_path if pchan else None
2012-05-15 18:50:51 +00:00
self.draw_settings(context, avs, mpath, bones=True)
class DATA_PT_motion_paths_display(MotionPathButtonsPanel_display, Panel):
#bl_label = "Bones Motion Paths"
bl_context = "data"
bl_parent_id = "DATA_PT_motion_paths"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
# XXX: include pose-mode check?
return (context.object) and (context.armature)
def draw(self, context):
# layout = self.layout
ob = context.object
avs = ob.pose.animation_visualization
pchan = context.active_pose_bone
mpath = pchan.motion_path if pchan else None
self.draw_settings(context, avs, mpath, bones=True)
class DATA_PT_custom_props_arm(ArmatureButtonsPanel, PropertyPanel, Panel):
2023-01-24 16:58:58 +00:00
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH', 'BLENDER_WORKBENCH_NEXT'}
_context_path = "object.data"
_property_type = bpy.types.Armature
classes = (
DATA_PT_context_arm,
DATA_PT_skeleton,
DATA_MT_bone_group_context_menu,
DATA_PT_bone_groups,
DATA_UL_bone_groups,
DATA_PT_motion_paths,
DATA_PT_motion_paths_display,
DATA_PT_display,
DATA_PT_iksolver_itasc,
DATA_PT_custom_props_arm,
)
if __name__ == "__main__": # only for live edit.
from bpy.utils import register_class
for cls in classes:
register_class(cls)