Page MenuHome

Cleanup: Register node property layout callbacks in files
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Feb 7 2021, 9:14 PM.

Details

Summary

This commit moves the property layout callbacks for node types to their
implementation files from drawnode.c. This was proposed a while ago in
T75724.

Benefits

  • Fewer files need to be changed when adding a new node.
  • Makes it possible to reuse functions from the node's implementation in the layout code.
  • Except for RNA, all of the node "inputs" are in the same place.
  • Code gets shorter overall, avoids the large switch statements.

Downsides

  • Requires including two UI headers.
  • Requires adding an editors dependency to the nodes folder.

I've only changed function nodes and geometry nodes for now.
I can do more in the future if this is accepted.

Diff Detail

Repository
rB Blender

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Feb 7 2021, 9:14 PM
Hans Goudey (HooglyBoogly) created this revision.
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/editors/include/UI_interface_icons.h
26

This is to get around an error with the forward enum declaration a few lines down, enum eIconSizes;. I searched around for a bit but I didn't see a way around this.

source/blender/editors/include/UI_interface_icons.h
26

Related: D9811.

This looks good overall. For the sake of following an existing naming convention, I'd suggest to prefix the _layout functions with geo_node_. E.g. volume_to_mesh_layout -> node_geo_volume_to_mesh_layout.

I'm fine with the general idea, will let others review the actual code.

  • Merge branch 'master' into cleanup-drawnode-remove
  • Add prefix
source/blender/editors/include/UI_interface_icons.h
26

So it looks like I could add a DNA_ID_enums.h and include that here instead of DNA_ID.h. That doesn't seem worth it to me at this point, not sure though.

If you agree, I'll just keep it this way (and remove the forward declaration).

source/blender/editors/include/UI_interface_icons.h
26

Yeah, just keep it this way for now. I'm not a big fan of extracting the enums to separate files either..

This revision is now accepted and ready to land.Feb 8 2021, 10:04 PM