Page MenuHome

Refactor buttton extra icons to support multiple icons with custom operators

Authored by Julian Eisel (Severin) on Sep 9 2019, 3:18 PM.



For the file browser we want to do this (note the + and - icons):

However, without this patch there could only be one superimposed icon
and the operators were hard coded for the button types.
This keeps the previous, sort of predefined extra icons working in a
rather generic way, but allows adding specific ones for specific case
through UI_but_extra_operator_icon_set().

Diff Detail

rB Blender

Event Timeline

Note that this patch doesn't actually add the file browser icons, it's just refactoring the extra icons to enable it.


Comment: find it odd that we have a generic way to list icons in a text button, then hard code the types we can call here.


Being Extra is too generic.. Prefer a more spesific prefix that relates to buttons: uiButExtraOpIcon or something like this.


Is this intended to be used elsewhere?

It's named in a generic way but only used once in the UI.

Meaning of Hook is a bit vague in this context, I wouldn't guess from the name that these contain all arguments needed to call an operator. Could call wmOperatorCallParams too.

Heh, I knew you'd point exactly these things out :) Just wanted to have feedback before spending time on coming up with better names.
Thanks for the quick feedback.


I think it's just a matter of renaming this a bit. Maybe PredefinedExtraOpIconTypes and PREDEFINED_EXTRA_OP_ICON_FOO. At least I think we should refer to these as predefined extra operator icons, or something like that.


Agreed, wasn't sure about the name.


Thought about using it in uiBut although that would involve some refactoring. There are for sure more places where we could use this, it seems like a handy wrapper.
wmOperatorCallParams sounds much better.

  • Rename types to address review points
  • Change handling to work for all button types

This patch now also contains the file browser icons.

This revision was not accepted when it landed; it landed in state Needs Review.Sep 9 2019, 4:37 PM
This revision was automatically updated to reflect the committed changes.