「Dev:Ref/Proposals/UI/Custom Icons for addons」の版間の差分

提供: wiki
< Dev:Ref‎ | Proposals‎ | UI
移動先: 案内検索
(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...")
 
(1版 をインポートしました)
 
(相違点なし)

2018年6月29日 (金) 06:09時点における最新版

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