Dev:Ref/Proposals/UI/Custom Icons for addons

提供: wiki
< Dev:Ref‎ | Proposals‎ | UI
2014年7月5日 (土) 18:32時点におけるwiki>Rebellionによる版 (Created page with "=== Issue === New addons come with new operators, with the increasing of operator it's becoming more difficult for developer to reuse the icon blender offer, so it' necessary to...")
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

Issue

New addons come with new operators, with the increasing of operator it's becoming more difficult for developer to reuse the icon blender offer, so it' necessary to allow developer use custom icons to identity the operator they create.

Solution

Doing a quick scan on the code I think the best way to accomplish this is to create a PyObject and expose it to the public API. In C the python object should work similar of how texture and material icons are created. Instead when scripting the python code, you just call for example: bpy.utils.upload_icon(path = "", ID = ""), where path is the path of the png file, and ID is the id of the icon. Later when drawing the interface, for example an operator: layout.operator(operator, text="", text_ctxt="", translate=True, icon= 'ID' , emboss=True) the ID is used to reading from the internal icons list.

I think this the best and easy way to do this, because other option require too much functions overload..

Pro

Addons with a lot of operator or workspace with a lot of addons enabled can benefit from this, because the interface become more cleaner and immediate.

Con

Of course this feature should be used with care and avoid icons when possible. Blender can can start slower with multiple addons enabled. Addons should be shipped with the icon file, make them more "heavy".