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:
Diffstat (limited to 'source/blender/editors/animation/anim_channels_edit.c')
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c79
1 files changed, 39 insertions, 40 deletions
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index afbd9b2c92d..69fabd004cc 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -51,6 +51,7 @@
#include "BKE_mask.h"
#include "BKE_nla.h"
#include "BKE_scene.h"
+#include "BKE_screen.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
@@ -2522,10 +2523,10 @@ static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/* ****************** Find / Set Filter Operator ******************** */
+/* ****************** Select Filter Textbox Operator ******************** */
/* XXX: make this generic? */
-static bool animchannels_find_poll(bContext *C)
+static bool animchannels_select_filter_poll(bContext *C)
{
ScrArea *area = CTX_wm_area(C);
@@ -2537,64 +2538,62 @@ static bool animchannels_find_poll(bContext *C)
return ELEM(area->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA);
}
-/* find_invoke() - Get initial channels */
-static int animchannels_find_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+static int animchannels_select_filter_invoke(struct bContext *C,
+ struct wmOperator *op,
+ const struct wmEvent *UNUSED(event))
{
- bAnimContext ac;
+ ScrArea *area = CTX_wm_area(C);
+ ARegion *region_ctx = CTX_wm_region(C);
+ ARegion *region_channels = BKE_area_find_region_type(area, RGN_TYPE_CHANNELS);
- /* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0) {
- return OPERATOR_CANCELLED;
+ CTX_wm_region_set(C, region_channels);
+
+ /* Show the channel region if it's hidden. This means that direct activation of the input field
+ * is impossible, as it may not exist yet. For that reason, the actual activation is deferred to
+ * the modal callback function; by the time it runs, the screen has been redrawn and the UI
+ * element is there to activate. */
+ if (region_channels->flag & RGN_FLAG_HIDDEN) {
+ ED_region_toggle_hidden(C, region_channels);
+ ED_region_tag_redraw(region_channels);
}
- /* set initial filter text, and enable filter */
- RNA_string_set(op->ptr, "query", ac.ads->searchstr);
+ WM_event_add_modal_handler(C, op);
- /* defer to popup */
- return WM_operator_props_popup(C, op, event);
+ CTX_wm_region_set(C, region_ctx);
+ return OPERATOR_RUNNING_MODAL;
}
-/* find_exec() - Called to set the value */
-static int animchannels_find_exec(bContext *C, wmOperator *op)
+static int animchannels_select_filter_modal(bContext *C,
+ wmOperator *UNUSED(op),
+ const wmEvent *UNUSED(event))
{
bAnimContext ac;
-
- /* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
}
- /* update filter text */
- RNA_string_get(op->ptr, "query", ac.ads->searchstr);
-
- /* redraw */
- WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+ ARegion *region = CTX_wm_region(C);
+ if (UI_textbutton_activate_rna(C, region, ac.ads, "filter_text")) {
+ /* Redraw to make sure it shows the cursor after activating */
+ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+ }
return OPERATOR_FINISHED;
}
-static void ANIM_OT_channels_find(wmOperatorType *ot)
+static void ANIM_OT_channels_select_filter(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";
+ ot->name = "Filter Channels";
+ ot->idname = "ANIM_OT_channels_select_filter";
+ ot->description =
+ "Start entering text which filters 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");
+ ot->invoke = animchannels_select_filter_invoke;
+ ot->modal = animchannels_select_filter_modal;
+ ot->poll = animchannels_select_filter_poll;
}
/* ********************** Select All Operator *********************** */
@@ -3563,7 +3562,7 @@ void ED_operatortypes_animchannels(void)
WM_operatortype_append(ANIM_OT_channel_select_keys);
WM_operatortype_append(ANIM_OT_channels_rename);
- WM_operatortype_append(ANIM_OT_channels_find);
+ WM_operatortype_append(ANIM_OT_channels_select_filter);
WM_operatortype_append(ANIM_OT_channels_setting_enable);
WM_operatortype_append(ANIM_OT_channels_setting_disable);