diff options
author | Joshua Leung <aligorith@gmail.com> | 2014-06-24 09:52:40 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2014-06-24 09:53:13 +0400 |
commit | 9ca0c7eea3cc2cdda9d6c6014a565372230a059e (patch) | |
tree | ad194887edfe11ff6b35c9cb15b38293f0fe3de2 /source | |
parent | afaf6e8d71fb205378eb9f160247e3734d68cef0 (diff) |
Ctrl-F now activates the filter-by-name functionality for Animation Editors
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/animation/anim_channels_edit.c | 86 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 1 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_ops.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_action/space_action.c | 9 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_ops.c | 3 |
6 files changed, 101 insertions, 5 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); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index eb79b0ca550..2ddda19fb28 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -267,7 +267,6 @@ int ED_operator_node_editable(bContext *C) return 0; } -/* XXX rename */ int ED_operator_graphedit_active(bContext *C) { return ed_spacetype_test(C, SPACE_IPO); diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index 93cd94ed892..b99419dec20 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -224,6 +224,9 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) */ WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 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); + /* transform system */ transform_keymap_for_space(keyconf, keymap, SPACE_ACTION); diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 69eeac69e85..7ca8968a705 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -476,7 +476,14 @@ static void action_header_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa) break; case NC_ANIMATION: switch (wmn->data) { - case ND_KEYFRAME: + case ND_ANIMCHAN: /* set of visible animchannels changed */ + /* NOTE: for now, this should usually just mean that the filters changed + * It may be better if we had a dedicated flag for that though + */ + ED_region_tag_redraw(ar); + break; + + case ND_KEYFRAME: /* new keyframed added -> active action may have changed */ //saction->flag |= SACTION_TEMP_NEEDCHANSYNC; ED_region_tag_redraw(ar); break; diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index cfd82b67289..fbfa9358a22 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -441,8 +441,12 @@ void graphedit_keymap(wmKeyConfig *keyconf) /* keymap for all regions */ keymap = WM_keymap_find(keyconf, "Graph Editor Generic", SPACE_IPO, 0); WM_keymap_add_item(keymap, "GRAPH_OT_properties", NKEY, KM_PRESS, 0, 0); + /* extrapolation works on channels, not keys */ WM_keymap_add_item(keymap, "GRAPH_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 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); /* channels */ /* Channels are not directly handled by the Graph Editor module, but are inherited from the Animation module. diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index 295a7ab2e04..5e1381db696 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -323,6 +323,9 @@ void nla_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "NLA_OT_tweakmode_enter", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NLA_OT_tweakmode_exit", TABKEY, KM_PRESS, 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); + /* channels ---------------------------------------------------------- */ /* Channels are not directly handled by the NLA Editor module, but are inherited from the Animation module. * Most of the relevant operations, keymaps, drawing, etc. can therefore all be found in that module instead, as there |