From 97e2d62c79fc30eacdbcb7d0464ed6d1726833a5 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 16 Nov 2014 15:45:00 +0100 Subject: Fix T42581: Add 'icon_value' feature to UI Py/RNA's operator button and items of enums. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rather straightforward, allows for 'DATA' icons (like mat or tex 'previews') to be used as icon for operator button or items of an enum. Patch by Simon LuĊĦenc, with minor cleanup by self. --- source/blender/python/intern/bpy_props.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source/blender/python/intern/bpy_props.c') diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 0bffe2cb11f..b0232a4211c 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -1374,7 +1374,8 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i (tmp.description = _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 2), &desc_str_size)) && /* TODO, number isn't ensured to be unique from the script author */ (item_size != 4 || py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.value) != -1) && - (item_size != 5 || ((tmp_icon = _PyUnicode_AsString(PyTuple_GET_ITEM(item, 3))) && + (item_size != 5 || ((py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.icon) != -1 || + (tmp_icon = _PyUnicode_AsString(PyTuple_GET_ITEM(item, 3)))) && py_long_as_int(PyTuple_GET_ITEM(item, 4), &tmp.value) != -1))) { if (is_enum_flag) { @@ -2610,8 +2611,8 @@ PyDoc_STRVAR(BPy_EnumProperty_doc, " [(identifier, name, description, icon, number), ...] where the identifier is used\n" " for python access and other values are used for the interface.\n" " The three first elements of the tuples are mandatory.\n" -" The forth one is either the (unique!) number id of the item or, if followed by a fith element \n" -" (which must be the numid), an icon string identifier.\n" +" The forth one is either the (unique!) number id of the item or, if followed by a fith element\n" +" (which must be the numid), an icon string identifier or integer icon value (e.g. returned by icon()...).\n" " Note the item is optional.\n" " For dynamic values a callback can be passed which returns a list in\n" " the same format as the static list.\n" -- cgit v1.2.3