diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 51 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 22 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_utils.c | 8 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_types.h | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ui.c | 1 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_props.c | 1 |
7 files changed, 58 insertions, 33 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 2251f3fd0e4..8789e837f17 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -159,31 +159,32 @@ enum { /* but->flag - general state flags. */ enum { /* warning, the first 6 flags are internal */ - UI_BUT_ICON_SUBMENU = (1 << 6), - UI_BUT_ICON_PREVIEW = (1 << 7), - - UI_BUT_NODE_LINK = (1 << 8), - UI_BUT_NODE_ACTIVE = (1 << 9), - UI_BUT_DRAG_LOCK = (1 << 10), - UI_BUT_DISABLED = (1 << 11), - UI_BUT_COLOR_LOCK = (1 << 12), - UI_BUT_ANIMATED = (1 << 13), - UI_BUT_ANIMATED_KEY = (1 << 14), - UI_BUT_DRIVEN = (1 << 15), - UI_BUT_REDALERT = (1 << 16), - UI_BUT_INACTIVE = (1 << 17), - UI_BUT_LAST_ACTIVE = (1 << 18), - UI_BUT_UNDO = (1 << 19), - UI_BUT_IMMEDIATE = (1 << 20), - UI_BUT_NO_UTF8 = (1 << 21), - - UI_BUT_VEC_SIZE_LOCK = (1 << 22), /* used to flag if color hsv-circle should keep luminance */ - UI_BUT_COLOR_CUBIC = (1 << 23), /* cubic saturation for the color wheel */ - UI_BUT_LIST_ITEM = (1 << 24), /* This but is "inside" a list item (currently used to change theme colors). */ - UI_BUT_DRAG_MULTI = (1 << 25), /* edit this button as well as the active button (not just dragging) */ - UI_BUT_SCA_LINK_GREY = (1 << 26), /* used to flag if sca links shoud be grey out */ - UI_BUT_HAS_SEP_CHAR = (1 << 27), /* but->str contains UI_SEP_CHAR, used for key shortcuts */ - UI_BUT_TIP_FORCE = (1 << 28), /* force show tooltips when holding option/alt if U's USER_TOOLTIPS is off */ + UI_BUT_ICON_SUBMENU = (1 << 6), + UI_BUT_ICON_PREVIEW = (1 << 7), + + UI_BUT_NODE_LINK = (1 << 8), + UI_BUT_NODE_ACTIVE = (1 << 9), + UI_BUT_DRAG_LOCK = (1 << 10), + UI_BUT_DISABLED = (1 << 11), + UI_BUT_COLOR_LOCK = (1 << 12), + UI_BUT_ANIMATED = (1 << 13), + UI_BUT_ANIMATED_KEY = (1 << 14), + UI_BUT_DRIVEN = (1 << 15), + UI_BUT_REDALERT = (1 << 16), + UI_BUT_INACTIVE = (1 << 17), + UI_BUT_LAST_ACTIVE = (1 << 18), + UI_BUT_UNDO = (1 << 19), + UI_BUT_IMMEDIATE = (1 << 20), + UI_BUT_NO_UTF8 = (1 << 21), + + UI_BUT_VEC_SIZE_LOCK = (1 << 22), /* used to flag if color hsv-circle should keep luminance */ + UI_BUT_COLOR_CUBIC = (1 << 23), /* cubic saturation for the color wheel */ + UI_BUT_LIST_ITEM = (1 << 24), /* This but is "inside" a list item (currently used to change theme colors). */ + UI_BUT_DRAG_MULTI = (1 << 25), /* edit this button as well as the active button (not just dragging) */ + UI_BUT_SCA_LINK_GREY = (1 << 26), /* used to flag if sca links shoud be grey out */ + UI_BUT_HAS_SEP_CHAR = (1 << 27), /* but->str contains UI_SEP_CHAR, used for key shortcuts */ + UI_BUT_TIP_FORCE = (1 << 28), /* force show tooltips when holding option/alt if U's USER_TOOLTIPS is off */ + UI_BUT_TEXTEDIT_UPDATE = (1 << 29), /* when widget is in textedit mode, update value on each char stroke */ }; #define UI_PANEL_WIDTH 340 diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 86414d98951..c7ceea05b4f 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -784,11 +784,18 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data) ui_but_string_set(C, but, data->str); ui_but_update(but); - /* give butfunc the original text too */ - /* feature used for bone renaming, channels, etc */ - /* afterfunc frees origstr */ - but->rename_orig = data->origstr; - data->origstr = NULL; + /* give butfunc a copy of the original text too. + * feature used for bone renaming, channels, etc. + * afterfunc frees rename_orig */ + if (data->origstr && (but->flag & UI_BUT_TEXTEDIT_UPDATE)) { + /* In this case, we need to keep origstr available, to restore real org string in case we cancel after + * having typed something already. */ + but->rename_orig = BLI_strdup(data->origstr); + } + else { + but->rename_orig = data->origstr; + data->origstr = NULL; + } ui_apply_but_func(C, but); data->retval = but->retval; @@ -2891,9 +2898,10 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle retval = WM_UI_HANDLER_BREAK; } - /* textbutton with magnifier icon: do live update for search button */ - if (but->icon == ICON_VIEWZOOM) + /* textbutton with this flag: do live update (e.g. for search buttons) */ + if (but->flag & UI_BUT_TEXTEDIT_UPDATE) { update = true; + } } #ifdef WITH_INPUT_IME diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 6cd5f5a7e05..c083a280763 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -90,6 +90,10 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind but = uiDefButR_prop(block, UI_BTYPE_NUM_SLIDER, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); else but = uiDefButR_prop(block, UI_BTYPE_NUM, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); + + if (RNA_property_flag(prop) & PROP_TEXTEDIT_UPDATE) { + UI_but_flag_enable(but, UI_BUT_TEXTEDIT_UPDATE); + } break; } case PROP_ENUM: @@ -107,6 +111,10 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind but = uiDefIconTextButR_prop(block, UI_BTYPE_TEXT, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); else but = uiDefButR_prop(block, UI_BTYPE_TEXT, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); + + if (RNA_property_flag(prop) & PROP_TEXTEDIT_UPDATE) { + UI_but_flag_enable(but, UI_BUT_TEXTEDIT_UPDATE); + } break; case PROP_POINTER: { diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 83f3870c29a..a9c0f591858 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -147,7 +147,7 @@ typedef enum PropertySubType { } PropertySubType; /* Make sure enums are updated with these */ -/* HIGHEST FLAG IN USE: 1 << 30 */ +/* HIGHEST FLAG IN USE: 1 << 31 */ typedef enum PropertyFlag { /* editable means the property is editable in the user * interface, properties are editable by default except @@ -165,6 +165,10 @@ typedef enum PropertyFlag { * and collections */ PROP_ANIMATABLE = (1 << 1), + /* This flag means when the property's widget is in 'textedit' mode, it will be updated after every typed char, + * instead of waiting final validation. Used e.g. for text searchbox. */ + PROP_TEXTEDIT_UPDATE = (1 << 31), + /* icon */ PROP_ICONS_CONSECUTIVE = (1 << 12), diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 17d4c1bfebb..86beec78d33 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1588,6 +1588,7 @@ static void rna_def_space_outliner(BlenderRNA *brna) prop = RNA_def_property(srna, "filter_text", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "search_string"); RNA_def_property_ui_text(prop, "Display Filter", "Live search filtering string"); + RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL); prop = RNA_def_property(srna, "use_filter_case_sensitive", PROP_BOOLEAN, PROP_NONE); @@ -3376,6 +3377,7 @@ static void rna_def_space_userpref(BlenderRNA *brna) prop = RNA_def_property(srna, "filter_text", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "filter"); + RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE); RNA_def_property_ui_text(prop, "Filter", "Search term for filtering in the UI"); } diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 92c5530202b..a61846fa028 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -1062,6 +1062,7 @@ static void rna_def_uilist(BlenderRNA *brna) prop = RNA_def_property(srna, "filter_name", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "filter_byname"); + RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE); RNA_def_property_ui_text(prop, "Filter by Name", "Only show items matching this name (use '*' as wildcard)"); prop = RNA_def_property(srna, "use_filter_invert", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index b0232a4211c..b536e91bca8 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -64,6 +64,7 @@ static EnumPropertyItem property_flag_items[] = { {PROP_ANIMATABLE, "ANIMATABLE", 0, "Animatable", ""}, {PROP_LIB_EXCEPTION, "LIBRARY_EDITABLE", 0, "Library Editable", ""}, {PROP_PROPORTIONAL, "PROPORTIONAL", 0, "Adjust values proportionally to eachother", ""}, + {PROP_TEXTEDIT_UPDATE, "TEXTEDIT_UPDATE", 0, "Update on every keystroke in textedit 'mode'", ""}, {0, NULL, 0, NULL, NULL}}; #define BPY_PROPDEF_OPTIONS_DOC \ |