UI: Use instanced panel custom data instead of list index
For modifier shortcuts we added a "custom_data" field to panels. This commit uses the same system for accessing the list data that corresponds to each panel. This way the context is only used once and the modifier for each panel can be accessed more easily later. This ends up being mostly a cleanup commit with a few small changes in interface_panel.c. The large changes in the UI functions are due to the fact that the panel custom data is now passed around as a single pointer instead of being created again for every panel. The list_index variable in Panel.runtime is removed as it's now unnecessary. Differential Revision: https://developer.blender.org/D8559
This commit is contained in:
@@ -114,11 +114,7 @@ class ConstraintButtonsPanel(Panel):
|
||||
col.prop_search(con, "subtarget", con.target, "vertex_groups", text="Vertex Group")
|
||||
|
||||
def get_constraint(self, context):
|
||||
con = None
|
||||
if context.pose_bone:
|
||||
con = context.pose_bone.constraints[self.list_panel_index]
|
||||
else:
|
||||
con = context.object.constraints[self.list_panel_index]
|
||||
con = self.custom_data
|
||||
self.layout.context_pointer_set("constraint", con)
|
||||
return con
|
||||
|
||||
@@ -963,11 +959,7 @@ class ConstraintButtonsSubPanel(Panel):
|
||||
bl_options = {'DRAW_BOX'}
|
||||
|
||||
def get_constraint(self, context):
|
||||
con = None
|
||||
if context.pose_bone:
|
||||
con = context.pose_bone.constraints[self.list_panel_index]
|
||||
else:
|
||||
con = context.object.constraints[self.list_panel_index]
|
||||
con = self.custom_data
|
||||
self.layout.context_pointer_set("constraint", con)
|
||||
return con
|
||||
|
||||
|
||||
Reference in New Issue
Block a user