Page MenuHome

Support for custom interface icons
Needs RevisionPublic

Authored by Yevgeny Makarov (jenkm) on Sep 2 2019, 10:28 AM.
Tokens
"Like" token, awarded by dupoxy."Love" token, awarded by johnsyed."Like" token, awarded by Imaginer."Like" token, awarded by duarteframos."Heartbreak" token, awarded by jenkm."Party Time" token, awarded by xdanic."Love" token, awarded by HooglyBoogly."Love" token, awarded by fobsta."Like" token, awarded by 1D_Inc."Party Time" token, awarded by Modanung."Love" token, awarded by erickblender."Love" token, awarded by tiles."Love" token, awarded by StroBlend."Like" token, awarded by Fracture128."Like" token, awarded by amonpaike."Love" token, awarded by brilliant_ape.

Details

Summary

Support for user icon sheets.

If the ../datafiles/interface_icons directory exists, we will first try to load icons from it,
if an icon cannot be loaded, the built-in one will be used.

The icon names can be found/copied in the "Icon Viewer" add-on,
examples of file names: CUBE.png, SNAP_ON.png, TOOL_SETTINGS.png.

Images can be of any size, not square images will be cropped.

Some test icons:

Diff Detail

Repository
rB Blender

Event Timeline

Yevgeny Makarov (jenkm) planned changes to this revision.Sep 11 2019, 4:55 PM
Yevgeny Makarov (jenkm) retitled this revision from Support for custom user icon sheets to Support for custom icon sheets.
Yevgeny Makarov (jenkm) edited the summary of this revision. (Show Details)
Yevgeny Makarov (jenkm) planned changes to this revision.Sep 21 2019, 8:51 PM
Yevgeny Makarov (jenkm) edited the summary of this revision. (Show Details)

Revert back to a simpler version without the "Icon Directory" theme option.

Updated to current state of master.

Updated to current state of master.
Reflect D6662 changes.

Yevgeny Makarov (jenkm) edited the summary of this revision. (Show Details)Jan 28 2020, 4:28 PM

There are some design questions.

  1. The distinction MONO and COLOR icons
    • based on the filename, blender_icons_mono_32.png vs blender_icons_color_32.png
    • or based on amount of bits, Grayscale image (16 bit) vs RGBA images (32 bit)
  2. If only one icon file is successfully loaded, e.g. only 16x16 icons provided
    • show 16px version on hidpi display (will be blur)
    • or ignore and use the built-in icon sheet
  3. "Load Factory Settings" won't reset icons to default ones
    • ok...
    • must reset to default
  4. if something went wrong, the built-in icon sheet will be saved to the temporary directory
    • good, for use as a reference
    • no need for garbage

Can the default built-in icons (and splash screen image) be stored outside the binary file, just like the toolbar icons, in the datafiles folder?

dupoxy added a subscriber: dupoxy.Jan 28 2020, 7:05 PM

My biggest concern with this, is that we regularly update and move the icons around, add new icons, etc. We also might want to move away from the concept of an icon sheet completely, because it easily becomes messy to manage sensible locations in the sheet.

User-created icon sheets will very quickly be out of date and need to be maintained, and I don't want us to be constrained by having to worry about custom icon sheets breaking.

But, if some users or contributors are willing to keep things up to date, then I guess it may be alright.

That's a good point, but I see it more as an undocumented feature. It's the same as when a user replaces Geom icons or edits UI scripts.
So there's no need to worry about user icon sheets breaking, it's a user matter.

We can only search for icons in the BLENDER_SYSTEM_DATAFILES folder (where Geom icons are stored),
so when the user updates Blender, the custom icons will not be automatically loaded along with the previous settings.

Yevgeny Makarov (jenkm) planned changes to this revision.Feb 18 2020, 8:38 AM
Yevgeny Makarov (jenkm) updated this revision to Diff 22399.
Yevgeny Makarov (jenkm) edited the summary of this revision. (Show Details)

I will abandon that idea for now.

We have a "prvicons.png", "alerticons.png", "blender_icons16.png" and bunch ".dat" icons.
It wouldn't be nice if some of them were customizable and others not.

The icon sheet is regularly updated, which will require checking for changes for each new Blender release
and will cause additional headache for the user.

We can use one icon in different colors to indicate different things.
The user-defined color icons will break this color indication.

For most users it will be difficult to create a correct icon sheet,
it should be possible to simply replace individual icon files, with fallback to default icons.

Pity. Mostly I just wanted to customize the icons of the tabs in properties editor.

rip

Mostly I just wanted to customize the icons of the tabs in properties editor.

We can hope that there will be more theme options for such purposes. It'll be a better solution. Crossed fingers.

Maybe a directory of pngs that override current icons? So we scan that directory on startup, but after the regular icons are processed, then "home.png" would replace ICON_HOME if found? No matter what size we just scale it to target size. Might work?

Yes, storing icons as individual files should make this much simpler. We wouldn't have to worry about the changing layout of the icon sheet, and would not be an issue if not all icons are included in the overridden icon set.

OMG. It seems super easy to implement.
Just define an icon of BUFFER type instead of TEXTURE (in the init_internal_icons) if the file corresponding to the current id is present.
I already have a working code, LOL. Just need to match the numeric id to the icon name.

@Yevgeny Makarov (jenkm) - Just need to match the numeric id to the icon name.

That "just" part seems hard to me. I guess RNA has those names since we can refer to icons by name in Python, but doubt we can get to those. Apparently there are tricks to make the c preprocessor do this so might be able to put the names into something.

Yevgeny Makarov (jenkm) edited the summary of this revision. (Show Details)

new implementation

Yevgeny Makarov (jenkm) retitled this revision from Support for custom icon sheets to Support for custom interface icons.Mar 9 2020, 1:19 PM
Yevgeny Makarov (jenkm) edited the summary of this revision. (Show Details)

It seems to work well except that when the icons are scaled, dark halos appear (can be seen with light icons on a light background).
So it's necessary to premultiply icons before scaling in the "icon_draw_rect".
This halos also present in the "studio_light" icons. So it can be considered as a separate patch.
But the difficulty is that it needs to be done without affecting the "matcap" and "preview" icons, they work correctly.

This revision is now accepted and ready to land.Apr 29 2020, 10:59 AM
Campbell Barton (campbellbarton) requested changes to this revision.May 4 2020, 7:30 AM

While the basic approach to this patch is fine, I think it messes a way for users to customize their icons.

  • Users should be able to customize icons similar to a theme (select from presets for example).
  • Users shouldn't need know or care about where to copy files in order to be able to customize their icons.

I'd suggest to handle icons similar to themes, as a kind of preset, where users can select them from a list, with the option to install an icon pack.

This revision now requires changes to proceed.May 4 2020, 7:30 AM

I'd suggest to handle icons similar to themes, as a kind of preset, where users can select them from a list, with the option to install an icon pack.

That would actually be great!

If I understand correctly the current implementation scans a certain Icons directory for png files and overrides builtin ones when a name match is found.

Not sure how easy it is to implement or much more work it requires, but if it could scan a subfolder instead, then maybe these icons could be bundled into a regular zip file hence forth called an Icon Packs.
These icon packs could be installed into above Icons directory, just like a regular addon, and unpacked into it own subfolder, which gets scanned instead.
UI wise we would present users with a simple mechanism to install them, just like addons currently, and a pulldown menu to choose the active one (including the default builtin icons).

Not sure if necessary, maybe the zip files could include an (option?) python header with metadata like author name or additional information.