Understanding the needed files
Groups of icons
As you see, icons are disposed in rows, which are grouped in a logical way and marked with the labels on the right.
Apart from the GPL license and comments, you will find a big list starting with:
DEF_ICON(BLENDER) DEF_ICON(QUESTION) DEF_ICON(ERROR) DEF_ICON(CANCEL) DEF_ICON(TRIA_RIGHT)
As you can see in
source/blender/editors/include/UI_resources.h, the macro
#define DEF_ICON(name) ICON_##name,
hence it takes the name in parentheses and defines ICON_<name-in-parentheses>
That is, in
source/blender/editors/include/UI_icons.h we define a list of names like
Using the "Icons" addons
Now to help you understand how this works, enable the Icons addon.
Go in the console space and in the view menu enable the icon viewer: you will get a nice list of icons to scrub in Console or in the Text Editor.
By scrolling the slider in the console header, you'll see that these icons appear:
- in the same order they are defined in
- in the same order they are in the
- the first icon in the icons viewer (ICON_QUESTION) is the second icon at the bottom-left in in
- the second icon in the icons viewer (ICON_ERROR) is the second icon at the bottom-left in in
- and so on...
Their order is in rows, from left to right, and reading rows from the bottom to the top of the
For some reason, the first one is not available in Blender's buttons (will investigate).
You may have noticed that there are empty slots in
blenderbutton, for example in the first line the slots 16 and 17, which are preceded by the MENU_PANEL icon and followed by the DOT icon.
These empty slots have a correspondant code in
source/blender/editors/include/UI_icons.h as shown below:
DEF_ICON(MENU_PANEL) #ifndef DEF_ICON_BLANK_SKIP DEF_ICON(BLANK002) DEF_ICON(BLANK003) #endif DEF_ICON(DOT)
Adding an icon
Add the icon image
Find an empty slot where to put your icon in the
blenderbutton file, putting it in the right group.
Add the icon in the image, for example the first free slot, number 16.
This corresponds to
DEF_ICON(BLANK002) in the source code.
Add your icon name
Choose a name which won't clash with existing names, for example
DEF_ICON(BLANK002)correspondant to the blank slot you have chosen out of the
- change it to
DEF_ICON(MENU_PANEL) DEF_ICON(MYICON) #ifndef DEF_ICON_BLANK_SKIP DEF_ICON(BLANK003) #endif DEF_ICON(DOT)
release/datafiles/ use this command:
This will produce a file called
./datatoc.py blenderbuttons Making C file <blenderbuttons.c> 211507
Now copy the content of
Finally, compiling blender you should see your icon
MYICON in Blender!
Enable the Icon addon again and search for it at number 16.