Sequencer: Preview dragging playhead over strips

Bring back the 2.4x feature.

also show a highlight when a strip is being previewed.
This commit is contained in:
Campbell Barton 2015-01-05 02:12:50 +11:00
parent c7eb83bc17
commit 8abdc89912
Notes: blender-bot 2023-05-08 11:29:52 +02:00
Referenced by commit 037b3f87bd, Fix: scrubbing time always has extra update that is only used by sequencer
5 changed files with 96 additions and 16 deletions

View File

@ -56,6 +56,7 @@
#include "ED_anim_api.h"
#include "ED_screen.h"
#include "ED_sequencer.h"
#include "anim_intern.h"
@ -143,6 +144,25 @@ static int frame_from_event(bContext *C, const wmEvent *event)
return frame;
}
static void change_frame_seq_preview_begin(bContext *C, const wmEvent *event)
{
ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype == SPACE_SEQ) {
SpaceSeq *sseq = sa->spacedata.first;
if (ED_space_sequencer_check_show_strip(sseq)) {
ED_sequencer_special_preview_set(C, event->mval);
}
}
}
static void change_frame_seq_preview_end(bContext *C)
{
if (ED_sequencer_special_preview_get() != NULL) {
Scene *scene = CTX_data_scene(C);
ED_sequencer_special_preview_clear();
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
}
/* Modal Operator init */
static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
@ -152,6 +172,8 @@ static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event
*/
RNA_int_set(op->ptr, "frame", frame_from_event(C, event));
change_frame_seq_preview_begin(C, event);
change_frame_apply(C, op);
/* add temp handler */
@ -160,14 +182,21 @@ static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event
return OPERATOR_RUNNING_MODAL;
}
static void change_frame_cancel(bContext *C, wmOperator *UNUSED(op))
{
change_frame_seq_preview_end(C);
}
/* Modal event handling of frame changing */
static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
int ret = OPERATOR_RUNNING_MODAL;
/* execute the events */
switch (event->type) {
case ESCKEY:
return OPERATOR_FINISHED;
ret = OPERATOR_FINISHED;
break;
case MOUSEMOVE:
RNA_int_set(op->ptr, "frame", frame_from_event(C, event));
change_frame_apply(C, op);
@ -180,7 +209,7 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
* the modal op) doesn't work for some reason
*/
if (event->val == KM_RELEASE)
return OPERATOR_FINISHED;
ret = OPERATOR_FINISHED;
break;
case LEFTCTRLKEY:
@ -194,7 +223,11 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
break;
}
return OPERATOR_RUNNING_MODAL;
if (ret == OPERATOR_FINISHED) {
change_frame_seq_preview_end(C);
}
return ret;
}
static void ANIM_OT_change_frame(wmOperatorType *ot)
@ -209,6 +242,7 @@ static void ANIM_OT_change_frame(wmOperatorType *ot)
/* api callbacks */
ot->exec = change_frame_exec;
ot->invoke = change_frame_invoke;
ot->cancel = change_frame_cancel;
ot->modal = change_frame_modal;
ot->poll = change_frame_poll;

View File

@ -27,6 +27,7 @@
#ifndef __ED_SEQUENCER_H__
#define __ED_SEQUENCER_H__
struct bContext;
struct Scene;
struct Sequence;
struct SpaceSeq;
@ -39,7 +40,12 @@ bool ED_space_sequencer_check_show_maskedit(struct SpaceSeq *sseq, struct Scene
int ED_space_sequencer_maskedit_poll(struct bContext *C);
bool ED_space_sequencer_check_show_imbuf(struct SpaceSeq *sseq);
bool ED_space_sequencer_check_show_strip(struct SpaceSeq *sseq);
void ED_operatormacros_sequencer(void);
Sequence *ED_sequencer_special_preview_get(void);
void ED_sequencer_special_preview_set(struct bContext *C, const int mval[2]);
void ED_sequencer_special_preview_clear(void);
#endif /* __ED_SEQUENCER_H__ */

View File

@ -830,17 +830,29 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg
static Sequence *special_seq_update = NULL;
static void UNUSED_FUNCTION(set_special_seq_update) (int val)
void sequencer_special_update_set(Sequence *seq)
{
// int x;
special_seq_update = seq;
}
/* if mouse over a sequence && LEFTMOUSE */
if (val) {
// XXX special_seq_update = find_nearest_seq(&x);
}
else {
special_seq_update = NULL;
}
Sequence *ED_sequencer_special_preview_get(void)
{
return special_seq_update;
}
void ED_sequencer_special_preview_set(bContext *C, const int mval[2])
{
Scene *scene = CTX_data_scene(C);
ARegion *ar = CTX_wm_region(C);
int hand;
Sequence *seq;
seq = find_nearest_seq(scene, &ar->v2d, &hand, mval);
sequencer_special_update_set(seq);
}
void ED_sequencer_special_preview_clear(void)
{
sequencer_special_update_set(NULL);
}
ImBuf *sequencer_ibuf_get(struct Main *bmain, Scene *scene, SpaceSeq *sseq, int cfra, int frame_ofs)
@ -1450,6 +1462,15 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
/* draw the last selected last (i.e. 'active' in other parts of Blender), removes some overlapping error */
if (last_seq)
draw_seq_strip(C, sseq, scene, ar, last_seq, 120, pixelx);
/* draw highlight when previewing a single strip */
if (special_seq_update) {
const Sequence *seq = special_seq_update;
glEnable(GL_BLEND);
glColor4ub(255, 255, 255, 48);
glRectf(seq->startdisp, seq->machine + SEQ_STRIP_OFSBOTTOM, seq->enddisp, seq->machine + SEQ_STRIP_OFSTOP);
glDisable(GL_BLEND);
}
}
static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)

View File

@ -495,6 +495,13 @@ bool ED_space_sequencer_check_show_imbuf(SpaceSeq *sseq)
ELEM(sseq->mainb, SEQ_DRAW_SEQUENCE, SEQ_DRAW_IMG_IMBUF));
}
bool ED_space_sequencer_check_show_strip(SpaceSeq *sseq)
{
return (ELEM(sseq->view, SEQ_VIEW_SEQUENCE, SEQ_VIEW_SEQUENCE_PREVIEW) &&
ELEM(sseq->mainb, SEQ_DRAW_SEQUENCE, SEQ_DRAW_IMG_IMBUF));
}
int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequence **selseq1, Sequence **selseq2, Sequence **selseq3, const char **error_str)
{
Editing *ed = BKE_sequencer_editing_get(scene, false);
@ -1130,7 +1137,7 @@ int sequencer_strip_has_path_poll(bContext *C)
return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), false)) != NULL) && ((seq = ed->act_seq) != NULL) && (SEQ_HAS_PATH(seq)));
}
int sequencer_view_poll(bContext *C)
int sequencer_view_preview_poll(bContext *C)
{
SpaceSeq *sseq = CTX_wm_space_seq(C);
Editing *ed = BKE_sequencer_editing_get(CTX_data_scene(C), false);
@ -1140,6 +1147,15 @@ int sequencer_view_poll(bContext *C)
return 0;
}
int sequencer_view_strips_poll(bContext *C)
{
SpaceSeq *sseq = CTX_wm_space_seq(C);
if (sseq && ED_space_sequencer_check_show_strip(sseq))
return 1;
return 0;
}
/* snap operator*/
static int sequencer_snap_exec(bContext *C, wmOperator *op)
{
@ -3314,7 +3330,7 @@ void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot)
ot->invoke = WM_border_select_invoke;
ot->exec = view_ghost_border_exec;
ot->modal = WM_border_select_modal;
ot->poll = sequencer_view_poll;
ot->poll = sequencer_view_preview_poll;
ot->cancel = WM_border_select_cancel;
/* flags */

View File

@ -58,6 +58,8 @@ void color3ubv_from_seq(struct Scene *curscene, struct Sequence *seq, unsigned c
void draw_shadedstrip(struct Sequence *seq, unsigned char col[3], float x1, float y1, float x2, float y2);
void draw_sequence_extensions(struct Scene *scene, struct ARegion *ar, struct Sequence *seq);
void sequencer_special_update_set(Sequence *seq);
/* UNUSED */
// void seq_reset_imageofs(struct SpaceSeq *sseq);
@ -77,7 +79,8 @@ int sequencer_edit_poll(struct bContext *C);
/* UNUSED */
//int sequencer_strip_poll(struct bContext *C);
int sequencer_strip_has_path_poll(struct bContext *C);
int sequencer_view_poll(struct bContext *C);
int sequencer_view_preview_poll(struct bContext *C);
int sequencer_view_strips_poll(struct bContext *C);
/* externs */
extern EnumPropertyItem sequencer_prop_effect_types[];