diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-03-21 16:30:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-03-21 16:32:01 +0300 |
commit | 9a09246dc02df29302130fc902cc69f827c99311 (patch) | |
tree | 412c9af8fd6a74c8e3f6194a83abbeace3a1c2e4 /source/blender/editors/interface | |
parent | 19dc7f7fdfc996f7cb68f3f5269c9ce7b839a005 (diff) |
WM: enable activate on init for wmOperatorType.prop
This enables popups to edit text when displayed,
use for new collection popup.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_utils.c | 22 |
2 files changed, 20 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index b4bfdbd340f..e63b4572894 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -4466,6 +4466,7 @@ eAutoPropButsReturn uiTemplateOperatorPropertyButs( layout, &ptr, op->type->poll_property ? ui_layout_operator_buts_poll_property : NULL, op->type->poll_property ? &user_data : NULL, + op->type->prop, label_align, (flag & UI_TEMPLATE_OP_PROPS_COMPACT)); if ((return_info & UI_PROP_BUTS_NONE_ADDED) && (flag & UI_TEMPLATE_OP_PROPS_SHOW_EMPTY)) { diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 85eae9a253d..74f65220433 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -146,20 +146,22 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind /** * \a check_prop callback filters functions to avoid drawing certain properties, * in cases where PROP_HIDDEN flag can't be used for a property. + * + * \param prop_activate_init: Property to activate on initial popup (#UI_BUT_ACTIVATE_ON_INIT). */ eAutoPropButsReturn uiDefAutoButsRNA( uiLayout *layout, PointerRNA *ptr, bool (*check_prop)(PointerRNA *ptr, PropertyRNA *prop, void *user_data), void *user_data, + PropertyRNA *prop_activate_init, const eButLabelAlign label_align, const bool compact) { eAutoPropButsReturn return_info = UI_PROP_BUTS_NONE_ADDED; uiLayout *split, *col; - int flag; const char *name; RNA_STRUCT_BEGIN (ptr, prop) { - flag = RNA_property_flag(prop); + const int flag = RNA_property_flag(prop); if (flag & PROP_HIDDEN) { continue; @@ -169,11 +171,11 @@ eAutoPropButsReturn uiDefAutoButsRNA( continue; } + const PropertyType type = RNA_property_type(prop); switch (label_align) { case UI_BUT_LABEL_ALIGN_COLUMN: case UI_BUT_LABEL_ALIGN_SPLIT_COLUMN: { - PropertyType type = RNA_property_type(prop); const bool is_boolean = (type == PROP_BOOLEAN && !RNA_property_array_check(prop)); name = RNA_property_ui_name(prop); @@ -208,8 +210,22 @@ eAutoPropButsReturn uiDefAutoButsRNA( break; } + /* Only buttons that can be edited as text. */ + const bool use_activate_init = ( + (prop == prop_activate_init) && + (ELEM(type, PROP_STRING, PROP_INT, PROP_FLOAT))); + + if (use_activate_init) { + uiLayoutSetActivateInit(col, true); + } + uiItemFullR(col, ptr, prop, -1, 0, compact ? UI_ITEM_R_COMPACT : 0, name, ICON_NONE); return_info &= ~UI_PROP_BUTS_NONE_ADDED; + + if (use_activate_init) { + uiLayoutSetActivateInit(col, false); + } + } RNA_STRUCT_END; |