UI: avoid property lookup for uiItemMenuEnumR
This commit is contained in:
@@ -945,6 +945,7 @@ void uiItemS(uiLayout *layout); /* separator */
|
|||||||
|
|
||||||
void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg);
|
void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg);
|
||||||
void uiItemMenuEnumO(uiLayout *layout, struct bContext *C, const char *opname, const char *propname, const char *name, int icon);
|
void uiItemMenuEnumO(uiLayout *layout, struct bContext *C, const char *opname, const char *propname, const char *name, int icon);
|
||||||
|
void uiItemMenuEnumR_prop(uiLayout *layout, struct PointerRNA *ptr, PropertyRNA *prop, const char *name, int icon);
|
||||||
void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon);
|
void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon);
|
||||||
|
|
||||||
/* UI Operators */
|
/* UI Operators */
|
||||||
|
|||||||
@@ -1922,9 +1922,25 @@ static void menu_item_enum_rna_menu(bContext *UNUSED(C), uiLayout *layout, void
|
|||||||
layout->root->block->flag |= UI_BLOCK_IS_FLIP;
|
layout->root->block->flag |= UI_BLOCK_IS_FLIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon)
|
void uiItemMenuEnumR_prop(uiLayout *layout, struct PointerRNA *ptr, PropertyRNA *prop, const char *name, int icon)
|
||||||
{
|
{
|
||||||
MenuItemLevel *lvl;
|
MenuItemLevel *lvl;
|
||||||
|
|
||||||
|
if (!name)
|
||||||
|
name = RNA_property_ui_name(prop);
|
||||||
|
if (layout->root->type == UI_LAYOUT_MENU && !icon)
|
||||||
|
icon = ICON_BLANK1;
|
||||||
|
|
||||||
|
lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
|
||||||
|
lvl->rnapoin = *ptr;
|
||||||
|
BLI_strncpy(lvl->propname, RNA_property_identifier(prop), sizeof(lvl->propname));
|
||||||
|
lvl->opcontext = layout->root->opcontext;
|
||||||
|
|
||||||
|
ui_item_menu(layout, name, icon, menu_item_enum_rna_menu, NULL, lvl, RNA_property_description(prop), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon)
|
||||||
|
{
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
|
|
||||||
prop = RNA_struct_find_property(ptr, propname);
|
prop = RNA_struct_find_property(ptr, propname);
|
||||||
@@ -1934,17 +1950,7 @@ void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propn
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!name)
|
uiItemMenuEnumR_prop(layout, ptr, prop, name, icon);
|
||||||
name = RNA_property_ui_name(prop);
|
|
||||||
if (layout->root->type == UI_LAYOUT_MENU && !icon)
|
|
||||||
icon = ICON_BLANK1;
|
|
||||||
|
|
||||||
lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
|
|
||||||
lvl->rnapoin = *ptr;
|
|
||||||
BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname));
|
|
||||||
lvl->opcontext = layout->root->opcontext;
|
|
||||||
|
|
||||||
ui_item_menu(layout, name, icon, menu_item_enum_rna_menu, NULL, lvl, RNA_property_description(prop), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************** Layout Items ***************************/
|
/**************************** Layout Items ***************************/
|
||||||
|
|||||||
@@ -137,9 +137,7 @@ static void rna_uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const
|
|||||||
|
|
||||||
/* Get translated name (label). */
|
/* Get translated name (label). */
|
||||||
name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
|
name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
|
||||||
|
uiItemMenuEnumR_prop(layout, ptr, prop, name, icon);
|
||||||
/* XXX This will search property again :( */
|
|
||||||
uiItemMenuEnumR(layout, ptr, propname, name, icon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rna_uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value,
|
static void rna_uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value,
|
||||||
|
|||||||
@@ -502,6 +502,7 @@ struct uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align) RE
|
|||||||
bool uiLayoutGetRedAlert(struct uiLayout *layout) RET_ZERO
|
bool uiLayoutGetRedAlert(struct uiLayout *layout) RET_ZERO
|
||||||
void uiLayoutSetRedAlert(uiLayout *layout, bool redalert) RET_NONE
|
void uiLayoutSetRedAlert(uiLayout *layout, bool redalert) RET_NONE
|
||||||
void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname) RET_NONE
|
void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname) RET_NONE
|
||||||
|
void uiItemMenuEnumR_prop(uiLayout *layout, struct PointerRNA *ptr, PropertyRNA *prop, const char *name, int icon) RET_NONE
|
||||||
void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon) RET_NONE
|
void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon) RET_NONE
|
||||||
void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value, const char *name, int icon) RET_NONE
|
void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value, const char *name, int icon) RET_NONE
|
||||||
void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon) RET_NONE
|
void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon) RET_NONE
|
||||||
|
|||||||
Reference in New Issue
Block a user