Sequencer display overlay option, this can show a border area from another time to help compare for color grading.

- Okey sets the border in the display.
- Okey resets the frame offset in the sequencer timeline.
- ghost icon in the header can enable/disable.
- frame offset can be relative or absolute (lock icon)

Not very happy that this commit adds a call to BKE_animsys_evaluate_animdata(scene, ...) in do_build_seq_array_recursively()
without this the offset frames dont have fcurves applied.
Though we will need something like this for prefetch frames to work too.
This commit is contained in:
Campbell Barton 2010-07-08 10:03:29 +00:00
parent ff51a96d58
commit b511fbea6d
10 changed files with 224 additions and 13 deletions

@ -69,6 +69,14 @@ class SEQUENCER_HT_header(bpy.types.Header):
else:
layout.prop(st, "display_channel", text="Channel")
ed = context.scene.sequence_editor
if ed:
row = layout.row(align=True)
row.prop(ed, "show_overlay", text="", icon='GHOST_ENABLED')
if ed.show_overlay:
row.prop(ed, "overlay_frame", text="")
row.prop(ed, "overlay_lock", text="", icon='LOCKED')
class SEQUENCER_MT_view_toggle(bpy.types.Menu):
bl_label = "View Type"
@ -126,6 +134,10 @@ class SEQUENCER_MT_view(bpy.types.Menu):
layout.operator_context = 'INVOKE_REGION_PREVIEW'
layout.operator("sequencer.view_all_preview", text='Fit preview in window')
layout.operator_context = 'INVOKE_DEFAULT'
# # XXX, invokes in the header view
# layout.operator("sequencer.view_ghost_border", text='Overlay Border')
layout.operator("sequencer.view_selected")
layout.prop(st, "draw_frames")

@ -2544,6 +2544,10 @@ static TStripElem* do_build_seq_array_recursively(
int i;
TStripElem* se = 0;
// XXX for prefetch and overlay offset!..., very bad!!!
AnimData *adt= BKE_animdata_from_id(&scene->id);
BKE_animsys_evaluate_animdata(&scene->id, adt, cfra, ADT_RECALC_ANIM);
count = get_shown_sequences(seqbasep, cfra, chanshown,
(Sequence **)&seq_arr);

@ -690,7 +690,7 @@ void set_special_seq_update(int val)
else special_seq_update= 0;
}
void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq)
void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs)
{
extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
struct ImBuf *ibuf;
@ -726,9 +726,11 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq
viewrecty /= proxy_size / 100.0;
}
/* XXX TODO: take color from theme */
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
if(frame_ofs == 0) {
/* XXX TODO: take color from theme */
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
}
/* without this colors can flicker from previous opengl state */
glColor4ub(255, 255, 255, 255);
@ -746,13 +748,13 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq
else {
recursive= 1;
if (special_seq_update) {
ibuf= give_ibuf_seq_direct(scene, rectx, recty, (scene->r.cfra), proxy_size, special_seq_update);
ibuf= give_ibuf_seq_direct(scene, rectx, recty, cfra + frame_ofs, proxy_size, special_seq_update);
}
else if (!U.prefetchframes) { // XXX || (G.f & G_PLAYANIM) == 0) {
ibuf= (ImBuf *)give_ibuf_seq(scene, rectx, recty, (scene->r.cfra), sseq->chanshown, proxy_size);
ibuf= (ImBuf *)give_ibuf_seq(scene, rectx, recty, cfra + frame_ofs, sseq->chanshown, proxy_size);
}
else {
ibuf= (ImBuf *)give_ibuf_seq_threaded(scene, rectx, recty, (scene->r.cfra), sseq->chanshown, proxy_size);
ibuf= (ImBuf *)give_ibuf_seq_threaded(scene, rectx, recty, cfra + frame_ofs, sseq->chanshown, proxy_size);
}
recursive= 0;
@ -812,11 +814,26 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymin);
glTexCoord2f(0.0f, 1.0f);glVertex2f(v2d->tot.xmin, v2d->tot.ymax);
glBegin(GL_QUADS);
if(frame_ofs) {
rctf tot_clip;
tot_clip.xmin= v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmin);
tot_clip.ymin= v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymin);
tot_clip.xmax= v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmax);
tot_clip.ymax= v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymax);
glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin);glVertex2f(tot_clip.xmin, tot_clip.ymin);
glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax);glVertex2f(tot_clip.xmin, tot_clip.ymax);
glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymax);glVertex2f(tot_clip.xmax, tot_clip.ymax);
glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymin);glVertex2f(tot_clip.xmax, tot_clip.ymin);
}
else {
glTexCoord2f(0.0f, 0.0f);glVertex2f(v2d->tot.xmin, v2d->tot.ymin);
glTexCoord2f(0.0f, 1.0f);glVertex2f(v2d->tot.xmin, v2d->tot.ymax);
glTexCoord2f(1.0f, 1.0f);glVertex2f(v2d->tot.xmax, v2d->tot.ymax);
glTexCoord2f(1.0f, 0.0f);glVertex2f(v2d->tot.xmax, v2d->tot.ymin);
glTexCoord2f(1.0f, 0.0f);glVertex2f(v2d->tot.xmax, v2d->tot.ymin);
}
glEnd( );
glBindTexture(GL_TEXTURE_2D, last_texid);
glDisable(GL_TEXTURE_2D);
@ -1056,6 +1073,19 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
/* preview range */
UI_view2d_view_ortho(C, v2d);
ANIM_draw_previewrange(C, v2d);
/* overlap playhead */
if(scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) {
int cfra_over= (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ? scene->ed->over_cfra : scene->r.cfra + scene->ed->over_ofs;
glColor3f(0.2, 0.2, 0.2);
// glRectf(cfra_over, v2d->cur.ymin, scene->ed->over_ofs + scene->r.cfra + 1, v2d->cur.ymax);
glBegin(GL_LINES);
glVertex2f(cfra_over, v2d->cur.ymin);
glVertex2f(cfra_over, v2d->cur.ymax);
glEnd();
}
/* reset view matrix */
UI_view2d_view_restore(C);

@ -1117,6 +1117,15 @@ int sequencer_edit_poll(bContext *C)
return (seq_give_editing(CTX_data_scene(C), FALSE) != NULL);
}
int sequencer_view_poll(bContext *C)
{
SpaceSeq *sseq= CTX_wm_space_seq(C);
Editing *ed= seq_give_editing(CTX_data_scene(C), FALSE);
if (ed && sseq && (sseq->mainb == SEQ_DRAW_IMG_IMBUF))
return 1;
return 0;
}
/* snap operator*/
static int sequencer_snap_exec(bContext *C, wmOperator *op)
@ -2723,3 +2732,62 @@ void SEQUENCER_OT_swap_data(wmOperatorType *ot)
/* properties */
}
/* borderselect operator */
static int view_ghost_border_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
Editing *ed= seq_give_editing(scene, FALSE);
View2D *v2d= UI_view2d_fromcontext(C);
rctf rect;
/* convert coordinates of rect to 'tot' rect coordinates */
UI_view2d_region_to_view(v2d, RNA_int_get(op->ptr, "xmin"), RNA_int_get(op->ptr, "ymin"), &rect.xmin, &rect.ymin);
UI_view2d_region_to_view(v2d, RNA_int_get(op->ptr, "xmax"), RNA_int_get(op->ptr, "ymax"), &rect.xmax, &rect.ymax);
if(ed==NULL)
return OPERATOR_CANCELLED;
rect.xmin /= (float)(ABS(v2d->tot.xmax - v2d->tot.xmin));
rect.ymin /= (float)(ABS(v2d->tot.ymax - v2d->tot.ymin));
rect.xmax /= (float)(ABS(v2d->tot.xmax - v2d->tot.xmin));
rect.ymax /= (float)(ABS(v2d->tot.ymax - v2d->tot.ymin));
rect.xmin+=0.5;
rect.xmax+=0.5;
rect.ymin+=0.5;
rect.ymax+=0.5;
CLAMP(rect.xmin, 0.0f, 1.0f);
CLAMP(rect.ymin, 0.0f, 1.0f);
CLAMP(rect.xmax, 0.0f, 1.0f);
CLAMP(rect.ymax, 0.0f, 1.0f);
scene->ed->over_border= rect;
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
/* ****** Border Select ****** */
void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Border Offset View";
ot->idname= "SEQUENCER_OT_view_ghost_border";
ot->description="Enable border select mode";
/* api callbacks */
ot->invoke= WM_border_select_invoke;
ot->exec= view_ghost_border_exec;
ot->modal= WM_border_select_modal;
ot->poll= sequencer_view_poll;
/* flags */
ot->flag= 0;
/* rna */
WM_operator_properties_gesture_border(ot, FALSE);
}

@ -48,7 +48,7 @@ struct ARegion *sequencer_has_buttons_region(struct ScrArea *sa);
/* sequencer_draw.c */
void draw_timeline_seq(const struct bContext *C, struct ARegion *ar);
void draw_image_seq(const struct bContext* C, struct Scene *scene,struct ARegion *ar, struct SpaceSeq *sseq);
void draw_image_seq(const struct bContext* C, struct Scene *scene,struct ARegion *ar, struct SpaceSeq *sseq, int cfra, int offset);
void seq_reset_imageofs(struct SpaceSeq *sseq);
@ -69,6 +69,7 @@ struct Sequence *alloc_sequence(struct ListBase *lb, int cfra, int machine);
/* operator helpers */
int sequencer_edit_poll(struct bContext *C);
int sequencer_view_poll(struct bContext *C);
/* externs */
extern EnumPropertyItem sequencer_prop_effect_types[];
@ -103,6 +104,7 @@ void SEQUENCER_OT_view_toggle(struct wmOperatorType *ot);
void SEQUENCER_OT_view_all(struct wmOperatorType *ot);
void SEQUENCER_OT_view_selected(struct wmOperatorType *ot);
void SEQUENCER_OT_view_zoom_ratio(struct wmOperatorType *ot);
void SEQUENCER_OT_view_ghost_border(struct wmOperatorType *ot);
void SEQUENCER_OT_copy(struct wmOperatorType *ot);
void SEQUENCER_OT_paste(struct wmOperatorType *ot);

@ -82,6 +82,7 @@ void sequencer_operatortypes(void)
WM_operatortype_append(SEQUENCER_OT_view_all_preview);
WM_operatortype_append(SEQUENCER_OT_view_toggle);
WM_operatortype_append(SEQUENCER_OT_view_zoom_ratio);
WM_operatortype_append(SEQUENCER_OT_view_ghost_border);
/* sequencer_select.c */
WM_operatortype_append(SEQUENCER_OT_select_all_toggle);
@ -223,6 +224,10 @@ void sequencer_keymap(wmKeyConfig *keyconf)
WM_keymap_add_menu(keymap, "SEQUENCER_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
kmi= WM_keymap_add_item(keymap, "WM_OT_context_set_int", OKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "scene.sequence_editor.overlay_frame");
RNA_int_set(kmi->ptr, "value", 0);
transform_keymap_for_space(keyconf, keymap, SPACE_SEQ);
keymap= WM_keymap_find(keyconf, "SequencerPreview", SPACE_SEQ, 0);
@ -232,6 +237,8 @@ void sequencer_keymap(wmKeyConfig *keyconf)
keymap= WM_keymap_find(keyconf, "SequencerPreview", SPACE_SEQ, 0);
WM_keymap_add_item(keymap, "SEQUENCER_OT_view_ghost_border", OKEY, KM_PRESS, 0, 0);
/* would prefer to use numpad keys for job */
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD8, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 8.0f);
RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD4, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 4.0f);

@ -396,7 +396,21 @@ static void sequencer_preview_area_draw(const bContext *C, ARegion *ar)
/* XXX temp fix for wrong setting in sseq->mainb */
if (sseq->mainb == SEQ_DRAW_SEQUENCE) sseq->mainb = SEQ_DRAW_IMG_IMBUF;
draw_image_seq(C, scene, ar, sseq);
draw_image_seq(C, scene, ar, sseq, scene->r.cfra, 0);
if(scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW && sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
int over_cfra;
if(scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS)
over_cfra= scene->ed->over_cfra;
else
over_cfra= scene->r.cfra + scene->ed->over_ofs;
if(over_cfra != scene->r.cfra)
draw_image_seq(C, scene, ar, sseq, scene->r.cfra, over_cfra - scene->r.cfra);
}
}
static void sequencer_preview_area_listener(ARegion *ar, wmNotifier *wmn)

@ -196,6 +196,10 @@ typedef struct Editing {
Sequence *act_seq;
char act_imagedir[256];
char act_sounddir[256];
int over_ofs, over_cfra;
int over_flag, pad;
rctf over_border;
} Editing;
/* ************* Effect Variable Structs ********* */
@ -242,6 +246,10 @@ typedef struct SpeedControlVars {
int lastValidFrame;
} SpeedControlVars;
/* Editor->over_flag */
#define SEQ_EDIT_OVERLAY_SHOW 1
#define SEQ_EDIT_OVERLAY_ABS 2
#define SEQ_STRIP_OFSBOTTOM 0.2f
#define SEQ_STRIP_OFSTOP 0.8f

@ -521,6 +521,55 @@ static char *rna_SequenceColorBalance_path(PointerRNA *ptr)
return BLI_strdup("");
}
static void rna_SequenceEditor_overlay_lock_set(PointerRNA *ptr, int value)
{
Scene *scene= ptr->id.data;
Editing *ed= seq_give_editing(scene, FALSE);
if(ed==NULL)
return;
/* convert from abs to relative and back */
if((ed->over_flag & SEQ_EDIT_OVERLAY_ABS)==0 && value) {
ed->over_cfra= scene->r.cfra + ed->over_ofs;
ed->over_flag |= SEQ_EDIT_OVERLAY_ABS;
}
else if((ed->over_flag & SEQ_EDIT_OVERLAY_ABS) && !value) {
ed->over_ofs= ed->over_cfra - scene->r.cfra;
ed->over_flag &= ~SEQ_EDIT_OVERLAY_ABS;
}
}
static int rna_SequenceEditor_overlay_frame_get(PointerRNA *ptr)
{
Scene *scene= (Scene *)ptr->id.data;
Editing *ed= seq_give_editing(scene, FALSE);
if(ed==NULL)
return scene->r.cfra;
if(ed->over_flag & SEQ_EDIT_OVERLAY_ABS)
return ed->over_cfra - scene->r.cfra;
else
return ed->over_ofs;
}
static void rna_SequenceEditor_overlay_frame_set(PointerRNA *ptr, int value)
{
Scene *scene= (Scene *)ptr->id.data;
Editing *ed= seq_give_editing(scene, FALSE);
if(ed==NULL)
return;
if(ed->over_flag & SEQ_EDIT_OVERLAY_ABS)
ed->over_cfra= (scene->r.cfra + value);
else
ed->over_ofs= value;
}
#else
static void rna_def_strip_element(BlenderRNA *brna)
@ -887,6 +936,22 @@ static void rna_def_editor(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "act_seq");
RNA_def_property_flag(prop, PROP_EDITABLE);
prop= RNA_def_property(srna, "show_overlay", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "over_flag", SEQ_EDIT_OVERLAY_SHOW);
RNA_def_property_ui_text(prop, "Draw Axes", "Partial overlay ontop of the sequencer");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_SEQUENCER, NULL);
prop= RNA_def_property(srna, "overlay_lock", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "over_flag", SEQ_EDIT_OVERLAY_ABS);
RNA_def_property_ui_text(prop, "Overlay Lock", "");
RNA_def_property_boolean_funcs(prop, NULL, "rna_SequenceEditor_overlay_lock_set");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_SEQUENCER, NULL);
/* access to fixed and relative frame */
prop= RNA_def_property(srna, "overlay_frame", PROP_INT, PROP_NONE);
RNA_def_property_ui_text(prop, "Overlay Offset", "");
RNA_def_property_int_funcs(prop, "rna_SequenceEditor_overlay_frame_get", "rna_SequenceEditor_overlay_frame_set", NULL);
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_SEQUENCER, NULL);
RNA_def_property_ui_text(prop, "Active Strip", "Sequencers active strip");
}

@ -3141,6 +3141,7 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf)
WM_modalkeymap_assign(keymap, "NODE_OT_select_border");
// WM_modalkeymap_assign(keymap, "SCREEN_OT_border_select"); // template
WM_modalkeymap_assign(keymap, "SEQUENCER_OT_select_border");
WM_modalkeymap_assign(keymap, "SEQUENCER_OT_view_ghost_border");
WM_modalkeymap_assign(keymap, "UV_OT_select_border");
WM_modalkeymap_assign(keymap, "VIEW2D_OT_zoom_border");
WM_modalkeymap_assign(keymap, "VIEW3D_OT_clip_border");