Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_ui_api.c
| Show First 20 Lines • Show All 697 Lines • ▼ Show 20 Lines | |||||
| static const char *rna_ui_get_enum_name(bContext *C, | static const char *rna_ui_get_enum_name(bContext *C, | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| const char *propname, | const char *propname, | ||||
| const char *identifier) | const char *identifier) | ||||
| { | { | ||||
| PropertyRNA *prop = NULL; | PropertyRNA *prop = NULL; | ||||
| const EnumPropertyItem *items = NULL; | const EnumPropertyItem *items = NULL; | ||||
| const EnumPropertyItem_Order *item_order = NULL; | |||||
| bool free; | bool free; | ||||
| const char *name = ""; | const char *name = ""; | ||||
| prop = RNA_struct_find_property(ptr, propname); | prop = RNA_struct_find_property(ptr, propname); | ||||
| if (!prop || (RNA_property_type(prop) != PROP_ENUM)) { | if (!prop || (RNA_property_type(prop) != PROP_ENUM)) { | ||||
| RNA_warning( | RNA_warning( | ||||
| "Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname); | "Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname); | ||||
| return name; | return name; | ||||
| } | } | ||||
| RNA_property_enum_items_gettexted(C, ptr, prop, &items, NULL, &free); | RNA_property_enum_items_gettexted_with_order(C, ptr, prop, &items, &item_order, NULL, &free); | ||||
| if (items) { | if (items) { | ||||
| const int index = RNA_enum_from_identifier(items, identifier); | const int index = RNA_enum_from_identifier_with_order(items, item_order, identifier); | ||||
| if (index != -1) { | if (index != -1) { | ||||
| name = items[index].name; | name = items[index].name; | ||||
| } | } | ||||
| if (free) { | if (free) { | ||||
| MEM_freeN((void *)items); | MEM_freeN((void *)items); | ||||
| } | } | ||||
| } | } | ||||
| return name; | return name; | ||||
| } | } | ||||
| static const char *rna_ui_get_enum_description(bContext *C, | static const char *rna_ui_get_enum_description(bContext *C, | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| const char *propname, | const char *propname, | ||||
| const char *identifier) | const char *identifier) | ||||
| { | { | ||||
| PropertyRNA *prop = NULL; | PropertyRNA *prop = NULL; | ||||
| const EnumPropertyItem *items = NULL; | const EnumPropertyItem *items = NULL; | ||||
| const EnumPropertyItem_Order *item_order = NULL; | |||||
| bool free; | bool free; | ||||
| const char *desc = ""; | const char *desc = ""; | ||||
| prop = RNA_struct_find_property(ptr, propname); | prop = RNA_struct_find_property(ptr, propname); | ||||
| if (!prop || (RNA_property_type(prop) != PROP_ENUM)) { | if (!prop || (RNA_property_type(prop) != PROP_ENUM)) { | ||||
| RNA_warning( | RNA_warning( | ||||
| "Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname); | "Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname); | ||||
| return desc; | return desc; | ||||
| } | } | ||||
| RNA_property_enum_items_gettexted(C, ptr, prop, &items, NULL, &free); | RNA_property_enum_items_gettexted_with_order(C, ptr, prop, &items, &item_order, NULL, &free); | ||||
| if (items) { | if (items) { | ||||
| const int index = RNA_enum_from_identifier(items, identifier); | const int index = RNA_enum_from_identifier_with_order(items, item_order, identifier); | ||||
| if (index != -1) { | if (index != -1) { | ||||
| desc = items[index].description; | desc = items[index].description; | ||||
| } | } | ||||
| if (free) { | if (free) { | ||||
| MEM_freeN((void *)items); | MEM_freeN((void *)items); | ||||
| } | } | ||||
| } | } | ||||
| return desc; | return desc; | ||||
| } | } | ||||
| static int rna_ui_get_enum_icon(bContext *C, | static int rna_ui_get_enum_icon(bContext *C, | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| const char *propname, | const char *propname, | ||||
| const char *identifier) | const char *identifier) | ||||
| { | { | ||||
| PropertyRNA *prop = NULL; | PropertyRNA *prop = NULL; | ||||
| const EnumPropertyItem *items = NULL; | const EnumPropertyItem *items = NULL; | ||||
| const EnumPropertyItem_Order *item_order = NULL; | |||||
| bool free; | bool free; | ||||
| int icon = ICON_NONE; | int icon = ICON_NONE; | ||||
| prop = RNA_struct_find_property(ptr, propname); | prop = RNA_struct_find_property(ptr, propname); | ||||
| if (!prop || (RNA_property_type(prop) != PROP_ENUM)) { | if (!prop || (RNA_property_type(prop) != PROP_ENUM)) { | ||||
| RNA_warning( | RNA_warning( | ||||
| "Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname); | "Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname); | ||||
| return icon; | return icon; | ||||
| } | } | ||||
| RNA_property_enum_items(C, ptr, prop, &items, NULL, &free); | RNA_property_enum_items_with_order(C, ptr, prop, &items, &item_order, NULL, &free); | ||||
| if (items) { | if (items) { | ||||
| const int index = RNA_enum_from_identifier(items, identifier); | const int index = RNA_enum_from_identifier_with_order(items, item_order, identifier); | ||||
| if (index != -1) { | if (index != -1) { | ||||
| icon = items[index].icon; | icon = items[index].icon; | ||||
| } | } | ||||
| if (free) { | if (free) { | ||||
| MEM_freeN((void *)items); | MEM_freeN((void *)items); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,083 Lines • Show Last 20 Lines | |||||