Page MenuHome

UI: Add icon_only argument to operator_enum
ClosedPublic

Authored by Nathan Craddock (Zachman) on Sep 13 2020, 4:27 AM.

Details

Summary

Adds an argument to draw only icons in operator_enum menus. This is useful for drawing inline icons in the outliner context menu for collection color tagging.

Diff Detail

Repository
rB Blender
Branch
icon-only (branched from master)
Build Status
Buildable 10195
Build 10195: arc lint + arc unit

Event Timeline

Nathan Craddock (Zachman) requested review of this revision.Sep 13 2020, 4:27 AM
Nathan Craddock (Zachman) created this revision.
Julian Eisel (Severin) requested changes to this revision.Sep 14 2020, 9:53 PM

Usually we convert the BPY options like icon_only into flags right in RNA. So rather than calling uiItemsEnumO() directly, there could be a rna_uiItemsEnumO() that does this + additional sanity checks. See uiItemO() and rna_uiItemO(). I would do this for the sake of consistency.

Also see my last comment in D8317. Other than that, this patch is ready I think.

source/blender/editors/interface/interface_layout.c
1511

split may be used uninitialized here. I think just NULL-checking is fine.

This revision now requires changes to proceed.Sep 14 2020, 9:53 PM
Nathan Craddock (Zachman) marked an inline comment as done.
  • Add null-check for split layout
  • Add rna_uiItemsEnumO function
  • Move uiItemsEnumO icon_only to rna

I believe I've got it working as expected now with the RNA function.

Julian Eisel (Severin) added inline comments.
source/blender/makesrna/intern/rna_ui_api.c
354–358

Ah sorry, I just noticed that uiItemsFullEnumO() (called by uiItemsEnumO()) already does these sanity checks.
So you can just set the flag value here and call uiItemsFullEnumO() directly, using uiLayoutGetOperatorContext() to get the context parameter. No need for doing the sanity checks right in RNA then.

This revision is now accepted and ready to land.Sep 15 2020, 1:08 PM
  • Simplify RNA uiItemsEnumO
Nathan Craddock (Zachman) marked an inline comment as done.Sep 15 2020, 3:37 PM

Ah sorry, I just noticed that uiItemsFullEnumO() (called by uiItemsEnumO()) already does these sanity checks.

I should have looked a bit deeper rather than blindly trusting your suggestions :)