Fix T42581: Add 'icon_value' feature to UI Py/RNA's operator button and items of enums.

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.
This commit is contained in:
2014-11-16 15:45:00 +01:00
parent 902ba7b25c
commit 97e2d62c79
2 changed files with 13 additions and 4 deletions

View File

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