Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_ui_api.c
| Show First 20 Lines • Show All 340 Lines • ▼ Show 20 Lines | static PointerRNA rna_uiItemOMenuHold(uiLayout *layout, | ||||
| flag |= (depress) ? UI_ITEM_O_DEPRESS : 0; | flag |= (depress) ? UI_ITEM_O_DEPRESS : 0; | ||||
| PointerRNA opptr; | PointerRNA opptr; | ||||
| uiItemFullOMenuHold_ptr( | uiItemFullOMenuHold_ptr( | ||||
| layout, ot, name, icon, NULL, uiLayoutGetOperatorContext(layout), flag, menu, &opptr); | layout, ot, name, icon, NULL, uiLayoutGetOperatorContext(layout), flag, menu, &opptr); | ||||
| return opptr; | return opptr; | ||||
| } | } | ||||
| static void rna_uiItemsEnumO(uiLayout *layout, | |||||
| const char *opname, | |||||
| const char *propname, | |||||
| const bool icon_only) | |||||
| { | |||||
| int flag = icon_only ? UI_ITEM_R_ICON_ONLY : 0; | |||||
| uiItemsFullEnumO(layout, opname, propname, NULL, uiLayoutGetOperatorContext(layout), flag); | |||||
| } | |||||
| static void rna_uiItemMenuEnumO(uiLayout *layout, | static void rna_uiItemMenuEnumO(uiLayout *layout, | ||||
Severin: Ah sorry, I just noticed that `uiItemsFullEnumO()` (called by `uiItemsEnumO()`) already does… | |||||
| bContext *C, | bContext *C, | ||||
| const char *opname, | const char *opname, | ||||
| const char *propname, | const char *propname, | ||||
| const char *name, | const char *name, | ||||
| const char *text_ctxt, | const char *text_ctxt, | ||||
| bool translate, | bool translate, | ||||
| int icon) | int icon) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 609 Lines • ▼ Show 20 Lines | for (int is_menu_hold = 0; is_menu_hold < 2; is_menu_hold++) { | ||||
| parm = RNA_def_pointer( | parm = RNA_def_pointer( | ||||
| func, "properties", "OperatorProperties", "", "Operator properties to fill in"); | func, "properties", "OperatorProperties", "", "Operator properties to fill in"); | ||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR); | RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR); | ||||
| RNA_def_function_return(func, parm); | RNA_def_function_return(func, parm); | ||||
| RNA_def_function_ui_description(func, | RNA_def_function_ui_description(func, | ||||
| "Item. Places a button into the layout to call an Operator"); | "Item. Places a button into the layout to call an Operator"); | ||||
| } | } | ||||
| func = RNA_def_function(srna, "operator_enum", "uiItemsEnumO"); | func = RNA_def_function(srna, "operator_enum", "rna_uiItemsEnumO"); | ||||
| parm = RNA_def_string(func, "operator", NULL, 0, "", "Identifier of the operator"); | parm = RNA_def_string(func, "operator", NULL, 0, "", "Identifier of the operator"); | ||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | ||||
| parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in operator"); | parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in operator"); | ||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | ||||
| RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in buttons, no text"); | |||||
| func = RNA_def_function(srna, "operator_menu_enum", "rna_uiItemMenuEnumO"); | func = RNA_def_function(srna, "operator_menu_enum", "rna_uiItemMenuEnumO"); | ||||
| RNA_def_function_flag(func, FUNC_USE_CONTEXT); | RNA_def_function_flag(func, FUNC_USE_CONTEXT); | ||||
| api_ui_item_op(func); /* cant use api_ui_item_op_common because property must come right after */ | api_ui_item_op(func); /* cant use api_ui_item_op_common because property must come right after */ | ||||
| parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in operator"); | parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in operator"); | ||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | ||||
| api_ui_item_common(func); | api_ui_item_common(func); | ||||
| ▲ Show 20 Lines • Show All 657 Lines • Show Last 20 Lines | |||||
Ah sorry, I just noticed that uiItemsFullEnumO() (called by uiItemsEnumO()) already does these sanity checks.
So you can just set the flag value here and call uiItemsFullEnumO() directly, using uiLayoutGetOperatorContext() to get the context parameter. No need for doing the sanity checks right in RNA then.