diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-07-08 14:03:29 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-07-08 14:03:29 +0400 |
commit | b511fbea6d3e0185f8ba39405bc9f71dab7a5f20 (patch) | |
tree | ee404999004e76ccc6ff941d62b4d62d7afae69a /source/blender/editors/space_sequencer | |
parent | ff51a96d58f423a686cc9b195f0bf2361625fb1a (diff) |
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.
Diffstat (limited to 'source/blender/editors/space_sequencer')
5 files changed, 134 insertions, 13 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 1e5735006ab..30f0f84c092 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -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); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 75774043c68..19b8e9d7a79 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.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); +} diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index df426e91075..bf0dfff8e98 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -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); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 9f5a97d4446..430553890d7 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -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); diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 8b7670a55bc..586b76268e4 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -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) |