Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2014-06-24 09:52:40 +0400
committerJoshua Leung <aligorith@gmail.com>2014-06-24 09:53:13 +0400
commit9ca0c7eea3cc2cdda9d6c6014a565372230a059e (patch)
treead194887edfe11ff6b35c9cb15b38293f0fe3de2 /source/blender/editors/animation
parentafaf6e8d71fb205378eb9f160247e3734d68cef0 (diff)
Ctrl-F now activates the filter-by-name functionality for Animation Editors
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c86
1 files changed, 83 insertions, 3 deletions
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index bc425580c36..5dc3a414bf6 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -2052,7 +2052,7 @@ static void ANIM_OT_channels_collapse(wmOperatorType *ot)
static int animchannels_enable_poll(bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
-
+
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
if (ELEM(NULL, sa, CTX_wm_region(C)))
@@ -2120,6 +2120,82 @@ static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+/* ****************** Find / Set Filter Operator ******************** */
+
+/* XXX: make this generic? */
+static int animchannels_find_poll(bContext *C)
+{
+ ScrArea *sa = CTX_wm_area(C);
+
+ if (sa == NULL)
+ return 0;
+
+ /* animation editor with dopesheet */
+ return ELEM3(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA);
+}
+
+/* find_invoke() - Get initial channels */
+static int animchannels_find_invoke(bContext *C, wmOperator *op, const wmEvent *evt)
+{
+ bAnimContext ac;
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return OPERATOR_CANCELLED;
+
+ /* set initial filter text, and enable filter */
+ RNA_string_set(op->ptr, "query", ac.ads->searchstr);
+
+ /* defer to popup */
+ return WM_operator_props_popup(C, op, evt);
+}
+
+/* find_exec() - Called to set the value */
+static int animchannels_find_exec(bContext *C, wmOperator *op)
+{
+ bAnimContext ac;
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return OPERATOR_CANCELLED;
+
+ /* update filter text, and ensure that filter is enabled if there's something there
+ * NOTE: we turn the filter off if there's nothing (this is a quicky shortcut for dismissing)
+ */
+ RNA_string_get(op->ptr, "query", ac.ads->searchstr);
+
+ if (ac.ads->searchstr[0]) {
+ ac.ads->filterflag |= ADS_FILTER_BY_FCU_NAME;
+ }
+ else {
+ ac.ads->filterflag &= ~ADS_FILTER_BY_FCU_NAME;
+ }
+
+ /* redraw */
+ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+static void ANIM_OT_channels_find(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Find Channels";
+ ot->idname = "ANIM_OT_channels_find";
+ ot->description = "Filter the set of channels shown to only include those with matching names";
+
+ /* callbacks */
+ ot->invoke = animchannels_find_invoke;
+ ot->exec = animchannels_find_exec;
+ ot->poll = animchannels_find_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ ot->prop = RNA_def_string(ot->srna, "query", "Query", sizeof(((bDopeSheet *)NULL)->searchstr), "", "Text to search for in channel names");
+}
+
/* ********************** Select All Operator *********************** */
static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
@@ -2824,6 +2900,8 @@ void ED_operatortypes_animchannels(void)
WM_operatortype_append(ANIM_OT_channels_click);
WM_operatortype_append(ANIM_OT_channels_rename);
+ WM_operatortype_append(ANIM_OT_channels_find);
+
WM_operatortype_append(ANIM_OT_channels_setting_enable);
WM_operatortype_append(ANIM_OT_channels_setting_disable);
WM_operatortype_append(ANIM_OT_channels_setting_toggle);
@@ -2852,8 +2930,7 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_find(keyconf, "Animation Channels", 0, 0);
wmKeyMapItem *kmi;
-
- /* selection */
+
/* click-select */
/* XXX for now, only leftmouse.... */
WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, 0, 0);
@@ -2864,6 +2941,9 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "ANIM_OT_channels_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ANIM_OT_channels_rename", LEFTMOUSE, KM_DBL_CLICK, 0, 0);
+ /* find (i.e. a shortcut for setting the name filter) */
+ WM_keymap_add_item(keymap, "ANIM_OT_channels_find", FKEY, KM_PRESS, KM_CTRL, 0);
+
/* deselect all */
WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", AKEY, KM_PRESS, 0, 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", true);