Page MenuHome

Refactor buttton extra icons to support multiple icons with custom operators
ClosedPublic

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

Details

Summary

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

Repository
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.

source/blender/editors/interface/interface.c
1483–1487

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.

source/blender/editors/interface/interface_intern.h
290–295

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

source/blender/windowmanager/WM_types.h
778–786

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.

source/blender/editors/interface/interface.c
1483–1487

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.

source/blender/editors/interface/interface_intern.h
290–295

Agreed, wasn't sure about the name.

source/blender/windowmanager/WM_types.h
778–786

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.
This revision was automatically updated to reflect the committed changes.