diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2018-10-29 23:20:58 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2018-10-29 23:20:58 +0300 |
commit | ce148716c8163162ba7275980792d432c0b3f5ed (patch) | |
tree | d642821bd70c29a633a0381dbedfbd27a1f213aa /source/blender/makesrna/intern/rna_ui_api.c | |
parent | a0dfa320cddd8396911058bae7c3a0eb52e7f2ee (diff) |
UI: Support Displaying Enums as Tabs
Adds `uiLayout.prop_tabs_enum(data, property, icon_only)` to BPY.
Diffstat (limited to 'source/blender/makesrna/intern/rna_ui_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_ui_api.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index e40db8842af..84673029eb9 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -140,6 +140,25 @@ static void rna_uiItemMenuEnumR( uiItemMenuEnumR_prop(layout, ptr, prop, name, icon); } +static void rna_uiItemTabsEnumR( + uiLayout *layout, bContext *C, + struct PointerRNA *ptr, const char *propname, + bool icon_only) +{ + PropertyRNA *prop = RNA_struct_find_property(ptr, propname); + + if (!prop) { + RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); + return; + } + if (RNA_property_type(prop) != PROP_ENUM) { + RNA_warning("property is not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname); + return; + } + + uiItemTabsEnumR_prop(layout, C, ptr, prop, icon_only); +} + static void rna_uiItemEnumR_string( uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value, const char *name, const char *text_ctxt, bool translate, int icon) @@ -617,6 +636,11 @@ void RNA_api_ui_layout(StructRNA *srna) api_ui_item_rna_common(func); api_ui_item_common(func); + func = RNA_def_function(srna, "prop_tabs_enum", "rna_uiItemTabsEnumR"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + api_ui_item_rna_common(func); + RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in tabs, no text"); + func = RNA_def_function(srna, "prop_enum", "rna_uiItemEnumR_string"); api_ui_item_rna_common(func); parm = RNA_def_string(func, "value", NULL, 0, "", "Enum property value"); |