Page MenuHome

UI: Use instanced panel custom data instead of list index
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Aug 13 2020, 2:38 AM.

Details

Summary

For modifier shortcuts we added a custom_data field to panels, this way the context would only
have to be used once and the modifier for each panel can be accessed more quickly later.

This ends up being mostly a cleanup commit with the 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 created again for every panel.

The list_index variable in Panel.runtime is removed as it's now unnecessary.

This also brings the instanced panel list idea closer to my goal of a generalized system that
could be used for any RNA collection. D7997 also becomes simpler with this method, as the
animation / NLA context doesn't have to be accessed for every single panel layout call.

Diff Detail

Repository
rB Blender

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Aug 13 2020, 2:38 AM
Hans Goudey (HooglyBoogly) planned changes to this revision.Aug 13 2020, 2:40 AM
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)

I haven't been able to get the python side of this working for constraints (see changes in rna_ui.c and properties_constraint.py).

source/blender/editors/interface/interface_panel.c
285

I should just delete this function and set the panel name to include the index in UI_panel_add_instanced_ex

  • Fix panel custom data access in python
  • Cleanup: Remove panel_free_block
  • Use a simpler solution for list panel custom data
  • Cleanup: Use new UI_panel_custom_data_get function
  • Correct mistake in last commit
  • Merge master after splitting off cleanup commit

Nice change. Simplifies things quite a bit. I have one question and one little uncertainty, noted inline.

I didn't check all details, but generally things make sense. And I only gave it a quick whirl to check for possible leaks, undo/redo sanity, warnings, etc. Seems all fine.

release/scripts/startup/bl_ui/properties_constraint.py
117

I think this is fine, for objects we use object.data, but custom_data makes more sense to me in this context. I'm not totally sure though, there may be better ways to go about this. @Campbell Barton (campbellbarton) any opinion?

source/blender/editors/interface/interface_panel.c
304โ€“305

Why isn't this needed anymore? When is the block freed now?

This revision is now accepted and ready to land.Aug 26 2020, 9:43 PM

Thanks a lot for the review!

source/blender/editors/interface/interface_panel.c
304โ€“305

Sorry for putting this in here, it was related at one point developing these changes but not anymore.

Originally I thought I had to remove the block immediately when the panel was removed, but we can just leave it and it will be removed later by ED_region_do_draw and the like.

Removing it is nice because it reduces reliance on the somewhat hacky UI_list_panel_unique_str and results in fewer unnecessary string lookups.

I can commit this separately.