Commit: b36d5570c8179241e4829904b40974fb552cad20
Author: Bastien Montagne
Date:   Mon Dec 15 14:52:10 2014 +0100
Branches: asset-experiments
https://developer.blender.org/rBb36d5570c8179241e4829904b40974fb552cad20

Refactor 'immediate search'

Previous implementation was uglyly relying on button using a specific
icon (VIEWZOOM) to enable this feature. Now we have a dedicated button flag
(UI_BUT_TEXTEDIT_UPDATE) and a dedicated RNA subtype (PROP_SEARCH) for that.

Also, if no icon is specified, it automatically set VIEWZOOM for it,
which saves us explicitely defining it in UI py code!

NOTE: this is to be committed asap in master, but has to wait for
after 2.73, so storing it here for now.

===================================================================

M       release/scripts/modules/rna_keymap_ui.py
M       release/scripts/startup/bl_ui/__init__.py
M       release/scripts/startup/bl_ui/space_outliner.py
M       release/scripts/startup/bl_ui/space_userpref.py
M       source/blender/editors/include/UI_interface.h
M       source/blender/editors/interface/interface_handlers.c
M       source/blender/editors/interface/interface_utils.c
M       source/blender/editors/space_file/space_file.c
M       source/blender/makesrna/RNA_types.h
M       source/blender/makesrna/intern/makesrna.c
M       source/blender/makesrna/intern/rna_rna.c
M       source/blender/makesrna/intern/rna_space.c
M       source/blender/makesrna/intern/rna_ui.c
M       source/blender/python/intern/bpy_props.c

===================================================================

diff --git a/release/scripts/modules/rna_keymap_ui.py 
b/release/scripts/modules/rna_keymap_ui.py
index 12d99a0..b049360 100644
--- a/release/scripts/modules/rna_keymap_ui.py
+++ b/release/scripts/modules/rna_keymap_ui.py
@@ -404,4 +404,5 @@ def draw_keymaps(context, layout):
     rowsubsub = rowsub.row(align=True)
     if not ok:
         rowsubsub.alert = True
-    rowsubsub.prop(spref, "filter_text", text="", icon='VIEWZOOM')
+    rowsubsub.prop(spref, "filter_text", text="")
+
diff --git a/release/scripts/startup/bl_ui/__init__.py 
b/release/scripts/startup/bl_ui/__init__.py
index 6174dd9..7ba0ff3 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -117,6 +117,7 @@ def register():
     WindowManager.addon_search = StringProperty(
             name="Search",
             description="Search within the selected filter",
+            subtype='SEARCH',
             )
     WindowManager.addon_filter = EnumProperty(
             items=addon_filter_items,
diff --git a/release/scripts/startup/bl_ui/space_outliner.py 
b/release/scripts/startup/bl_ui/space_outliner.py
index 7b508c0..0ce6204 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -38,7 +38,7 @@ class OUTLINER_HT_header(Header):
 
         layout.prop(space, "display_mode", text="")
 
-        layout.prop(space, "filter_text", icon='VIEWZOOM', text="")
+        layout.prop(space, "filter_text", text="")
 
         layout.separator()
 
diff --git a/release/scripts/startup/bl_ui/space_userpref.py 
b/release/scripts/startup/bl_ui/space_userpref.py
index 10394e5..65496ab 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1217,7 +1217,7 @@ class USERPREF_PT_addons(Panel):
 
         split = layout.split(percentage=0.2)
         col = split.column()
-        col.prop(context.window_manager, "addon_search", text="", 
icon='VIEWZOOM')
+        col.prop(context.window_manager, "addon_search", text="")
 
         col.label(text="Supported Level")
         col.prop(context.window_manager, "addon_support", expand=True)
diff --git a/source/blender/editors/include/UI_interface.h 
b/source/blender/editors/include/UI_interface.h
index 2251f3f..8789e83 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 413f878..30ae537 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -2888,9 +2888,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 6cd5f5a..405b143 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -101,13 +101,24 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, 
PropertyRNA *prop, int ind
                                but = uiDefButR_prop(block, UI_BTYPE_MENU, 0, 
name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
                        break;
                case PROP_STRING:
+               {
+                       const bool is_search = (RNA_property_subtype(prop) == 
PROP_SEARCH);
+
+                       if (is_search && !icon) {
+                               icon = ICON_VIEWZOOM;
+                       }
                        if (icon && name && name[0] == '\0')
                                but = uiDefIconButR_prop(block, UI_BTYPE_TEXT, 
0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
                        else if (icon)
                                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 (is_search) {
+                               UI_but_flag_enable(but, UI_BUT_TEXTEDIT_UPDATE);
+                       }
                        break;
+               }
                case PROP_POINTER:
                {
                        PointerRNA pptr;
diff --git a/source/blender/editors/space_file/space_file.c 
b/source/blender/editors/space_file/space_file.c
index 9e6155a..a7ba441 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -193,6 +193,8 @@ static void file_refresh(const bContext *C, ScrArea 
*UNUSED(sa))
        SpaceFile *sfile = CTX_wm_space_file(C);
        FileSelectParams *params = ED_fileselect_get_params(sfile);
 
+       //~ printf("%s : %s\n", __func__, params->filter_search);
+
        if (!sfile->folders_prev)
                sfile->folders_prev = folderlist_new();
        if (!sfile->files) {
diff --git a/source/blender/makesrna/RNA_types.h 
b/source/blender/makesrna/RNA_types.h
index 83f3870..d1dd7b8 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -112,7 +112,7 @@ typedef enum PropertySubType {
        PROP_DIRPATH           = 2,
        PROP_FILENAME          = 3,
        PROP_BYTESTRING        = 4, /* a string which should be represented as 
bytes in python, NULL terminated though. */
-       /* 5 was used by "PROP_TRANSLATE" sub-type, which is now a flag. */
+       PROP_SEARCH            = 5, /* a search string, which updates on each 
keystroke instead of waiting for final enter. */
        PROP_PASSWORD          = 6, /* a string which should not be displayed 
in UI */
 
        /* numbers */
diff --git a/source/blender/makesrna/intern/makesrna.c 
b/source/blender/makesrna/intern/makesrna.c
index d45771c..93a424d 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -2511,6 +2511,7 @@ static const char 
*rna_property_subtypename(PropertySubType type)
                case PROP_LAYER: return "PROP_LAYER";
                case PROP_LAYER_MEMBER: return "PROP_LAYER_MEMBER";
                case PROP_PASSWORD: return "PROP_PASSWORD";
+               case PROP_SEARCH: return "PROP_SEARCH";
                default:
                {
                        /* in case we don't have a type preset that includes 
the subtype */
diff --git a/source/blender/makesrna/intern/rna_rna.c 
b/source/blender/makesrna/intern/rna_rna.c
index 4f51ec5..4ddcf66 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -57,6 +57,7 @@ EnumPropertyItem property_subtype_items[] = {
        {PROP_FILEPATH, "FILEPATH", 0, "File Path", ""},
        {PROP_DIRPATH, "DIRPATH", 0, "Directory Path", ""},
        {PROP_FILENAME, "FILENAME", 0, "File Name", ""},
+       {PROP_SEARCH, "SEARCH", 0, "Search", "A search string (updates on each 
keystroke)"},
        {PROP_PASSWORD, "PASSWORD", 0, "Password", "A string that is displayed 
hidden ('********')"},
 
        /* numbers */
diff --git a/source/blender/makesrna/intern/rna_space.c 
b/source/blender/makesrna/intern/rna_space.c
index 1955679..6304690 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1592,7 +1592,7 @@ static void rna_def_space_outliner(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Display Mode", "Type of information to 
display");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL);
        
-       prop = 

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to