[Bf-blender-cvs] [fecb276ef7b] master: UI: New option to invert search filter in Dopesheet

Antonio Vazquez noreply at git.blender.org
Wed Oct 14 15:24:58 CEST 2020


Commit: fecb276ef7b337145190a090169fe736145799b8
Author: Antonio Vazquez
Date:   Wed Oct 14 15:21:55 2020 +0200
Branches: master
https://developer.blender.org/rBfecb276ef7b337145190a090169fe736145799b8

UI: New option to invert search filter in Dopesheet

A lot of animator request an option to invert the filter of the dopesheet channels. This patch adds that invert filter option. This is not for Grease Pencil only, affect to all modes.

{F8983328}

Note: I have seen the new button has a rounded borders on the left. It would be better get rectangle shape, but not sure how to do it.

Reviewed By: campbellbarton, pepeland

Maniphest Tasks: T81676

Differential Revision: https://developer.blender.org/D9182
c68a2a

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

M	source/blender/editors/animation/anim_filter.c
M	source/blender/editors/animation/time_scrub_ui.c
M	source/blender/makesdna/DNA_action_types.h
M	source/blender/makesrna/intern/rna_action.c

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

diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 11581adf919..7cf4cb87fc8 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -1173,10 +1173,11 @@ static bool name_matches_dopesheet_filter(bDopeSheet *ads, char *name)
     }
 
     /* if we have a match somewhere, this returns true */
-    return found;
+    return ((ads->flag & ADS_FLAG_INVERT_FILTER) == 0) ? found : !found;
   }
   /* fallback/default - just case insensitive, but starts from start of word */
-  return BLI_strcasestr(name, ads->searchstr) != NULL;
+  bool found = BLI_strcasestr(name, ads->searchstr) != NULL;
+  return ((ads->flag & ADS_FLAG_INVERT_FILTER) == 0) ? found : !found;
 }
 
 /* (Display-)Name-based F-Curve filtering
diff --git a/source/blender/editors/animation/time_scrub_ui.c b/source/blender/editors/animation/time_scrub_ui.c
index 0615e21c4a5..acbac93b654 100644
--- a/source/blender/editors/animation/time_scrub_ui.c
+++ b/source/blender/editors/animation/time_scrub_ui.c
@@ -226,23 +226,30 @@ void ED_time_scrub_channel_search_draw(const bContext *C, ARegion *region, bDope
   immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
   immUnbindProgram();
 
-  uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
-
   PointerRNA ptr;
   RNA_pointer_create(&CTX_wm_screen(C)->id, &RNA_DopeSheet, dopesheet, &ptr);
-  PropertyRNA *prop = RNA_struct_find_property(&ptr, "filter_text");
-
-  int padding = 2 * UI_DPI_FAC;
-  uiDefAutoButR(block,
-                &ptr,
-                prop,
-                -1,
-                "",
-                ICON_NONE,
-                rect.xmin + padding,
-                rect.ymin + padding,
-                BLI_rcti_size_x(&rect) - 2 * padding,
-                BLI_rcti_size_y(&rect) - 2 * padding);
+
+  const uiStyle *style = UI_style_get_dpi();
+  const float padding_x = 2 * UI_DPI_FAC;
+  const float padding_y = UI_DPI_FAC;
+
+  uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
+  uiLayout *layout = UI_block_layout(block,
+                                     UI_LAYOUT_VERTICAL,
+                                     UI_LAYOUT_HEADER,
+                                     rect.xmin + padding_x,
+                                     rect.ymin + UI_UNIT_Y + padding_y,
+                                     BLI_rcti_size_x(&rect) - 2 * padding_x,
+                                     1,
+                                     0,
+                                     style);
+  uiLayoutSetScaleY(layout, (UI_UNIT_Y - padding_y) / UI_UNIT_Y);
+  UI_block_layout_set_current(block, layout);
+  UI_block_align_begin(block);
+  uiItemR(layout, &ptr, "filter_text", 0, "", ICON_NONE);
+  uiItemR(layout, &ptr, "use_filter_invert", 0, "", ICON_ARROW_LEFTRIGHT);
+  UI_block_align_end(block);
+  UI_block_layout_resolve(block, NULL, NULL);
 
   UI_block_end(C, block);
   UI_block_draw(C, block);
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 9da5c302290..ac6160b28e4 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -796,6 +796,8 @@ typedef enum eDopeSheet_Flag {
   ADS_FLAG_FUZZY_NAMES = (1 << 2),
   /** do not sort datablocks (mostly objects) by name (NOTE: potentially expensive operation) */
   ADS_FLAG_NO_DB_SORT = (1 << 3),
+  /** Invert the search filter */
+  ADS_FLAG_INVERT_FILTER = (1 << 4),
 } eDopeSheet_Flag;
 
 typedef struct SpaceAction_Runtime {
diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c
index cec32877c0b..89687c1234c 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -365,6 +365,12 @@ static void rna_def_dopesheet(BlenderRNA *brna)
   RNA_def_property_ui_icon(prop, ICON_SORTALPHA, 0);
   RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
 
+  prop = RNA_def_property(srna, "use_filter_invert", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", ADS_FLAG_INVERT_FILTER);
+  RNA_def_property_ui_text(prop, "Invert", "Invert filter search");
+  RNA_def_property_ui_icon(prop, ICON_ZOOM_IN, 0);
+  RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+
   /* Debug Filtering Settings */
   prop = RNA_def_property(srna, "show_only_errors", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLY_ERRORS);



More information about the Bf-blender-cvs mailing list