diff options
author | Andrea Weikert <elubie@gmx.net> | 2009-12-15 00:42:25 +0300 |
---|---|---|
committer | Andrea Weikert <elubie@gmx.net> | 2009-12-15 00:42:25 +0300 |
commit | 18cc2b76c2878846a540c463bd6de8ac96ab7611 (patch) | |
tree | 90d00a3cd655634b3e5df05c948229ec277d7515 /source/blender/editors/space_sequencer/sequencer_edit.c | |
parent | fd703342420da13d585254496063b6cab7b3e2e2 (diff) |
Sequencer drawing cleanup (Part 1)
Separated preview drawing into own ARegion, this should make using View2D possible
The Sequencer now has three view types: Sequencer, Preview and split Sequencer/Preview.
Changing the preview can be done either by the combobox in the header or toggling through those types with CTRL+TAB.
Notes:
* Icon for split Sequencer/Preview view missing still.
* Naming items in the comboboxes can be improved (just Preview instead of Image Preview?)
Next steps:
* bringing back View2D handling (zoom/pan) for image preview
* experimenting with splitting the Preview ARegion for In/Out editing
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_edit.c')
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_edit.c | 124 |
1 files changed, 93 insertions, 31 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index c421c7fbb85..277d32d6360 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -83,6 +83,7 @@ #include "ED_screen.h" #include "ED_transform.h" #include "ED_util.h" +#include "ED_sequencer.h" #include "UI_interface.h" #include "UI_resources.h" @@ -2268,58 +2269,85 @@ static int sequencer_view_all_exec(bContext *C, wmOperator *op) bScreen *sc= CTX_wm_screen(C); ScrArea *area= CTX_wm_area(C); ARegion *ar= CTX_wm_region(C); + View2D *v2d= UI_view2d_fromcontext(C); + + v2d->cur= v2d->tot; + UI_view2d_curRect_validate(v2d); + UI_view2d_sync(sc, area, v2d, V2D_LOCK_COPY); + + ED_area_tag_redraw(CTX_wm_area(C)); + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_view_all(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "View All"; + ot->idname= "SEQUENCER_OT_view_all"; + ot->description="View all the strips in the sequencer."; + + /* api callbacks */ + ot->exec= sequencer_view_all_exec; + + ot->poll= ED_operator_sequencer_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER; +} + +/* view_all operator */ +static int sequencer_view_all_preview_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + bScreen *sc= CTX_wm_screen(C); + ScrArea *area= CTX_wm_area(C); + ARegion *ar= CTX_wm_region(C); SpaceSeq *sseq= area->spacedata.first; View2D *v2d= UI_view2d_fromcontext(C); - if (sseq->mainb==SEQ_DRAW_SEQUENCE) { - v2d->cur= v2d->tot; - UI_view2d_curRect_validate(v2d); - UI_view2d_sync(sc, area, v2d, V2D_LOCK_COPY); - } else { - /* Like zooming on an image view */ - float zoomX, zoomY; - int width, height, imgwidth, imgheight; - width = ar->winx; - height = ar->winy; + /* Like zooming on an image view */ + float zoomX, zoomY; + int width, height, imgwidth, imgheight; - seq_reset_imageofs(sseq); + width = ar->winx; + height = ar->winy; - imgwidth= (scene->r.size*scene->r.xsch)/100; - imgheight= (scene->r.size*scene->r.ysch)/100; + seq_reset_imageofs(sseq); - /* Apply aspect, dosnt need to be that accurate */ - imgwidth= (int)(imgwidth * ((float)scene->r.xasp / (float)scene->r.yasp)); + imgwidth= (scene->r.size*scene->r.xsch)/100; + imgheight= (scene->r.size*scene->r.ysch)/100; - if (((imgwidth >= width) || (imgheight >= height)) && - ((width > 0) && (height > 0))) { + /* Apply aspect, dosnt need to be that accurate */ + imgwidth= (int)(imgwidth * ((float)scene->r.xasp / (float)scene->r.yasp)); - /* Find the zoom value that will fit the image in the image space */ - zoomX = ((float)width) / ((float)imgwidth); - zoomY = ((float)height) / ((float)imgheight); - sseq->zoom= (zoomX < zoomY) ? zoomX : zoomY; + if (((imgwidth >= width) || (imgheight >= height)) && + ((width > 0) && (height > 0))) { - sseq->zoom = 1.0f / power_of_2(1/ MIN2(zoomX, zoomY) ); - } - else { - sseq->zoom= 1.0f; - } - } + /* Find the zoom value that will fit the image in the image space */ + zoomX = ((float)width) / ((float)imgwidth); + zoomY = ((float)height) / ((float)imgheight); + sseq->zoom= (zoomX < zoomY) ? zoomX : zoomY; + sseq->zoom = 1.0f / power_of_2(1/ MIN2(zoomX, zoomY) ); + } + else { + sseq->zoom= 1.0f; + } ED_area_tag_redraw(CTX_wm_area(C)); return OPERATOR_FINISHED; } -void SEQUENCER_OT_view_all(wmOperatorType *ot) +void SEQUENCER_OT_view_all_preview(wmOperatorType *ot) { /* identifiers */ ot->name= "View All"; - ot->idname= "SEQUENCER_OT_view_all"; - ot->description="View all the strips in the sequencer."; + ot->idname= "SEQUENCER_OT_view_all_preview"; + ot->description="Zoom preview to fit in the area."; /* api callbacks */ - ot->exec= sequencer_view_all_exec; + ot->exec= sequencer_view_all_preview_exec; ot->poll= ED_operator_sequencer_active; @@ -2327,8 +2355,42 @@ void SEQUENCER_OT_view_all(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER; } +static EnumPropertyItem view_type_items[] = { + {SEQ_VIEW_SEQUENCE, "SEQUENCER", ICON_SEQ_SEQUENCER, "Sequencer", ""}, + {SEQ_VIEW_PREVIEW, "PREVIEW", ICON_SEQ_PREVIEW, "Image Preview", ""}, + {SEQ_VIEW_SEQUENCE_PREVIEW, "SEQUENCER_PREVIEW", ICON_SEQ_SEQUENCER, "Sequencer and Image Preview", ""}, + {0, NULL, 0, NULL, NULL}}; /* view_all operator */ +static int sequencer_view_toggle_exec(bContext *C, wmOperator *op) +{ + SpaceSeq *sseq= CTX_wm_space_data(C); + + sseq->view++; + if (sseq->view > SEQ_VIEW_SEQUENCE_PREVIEW) sseq->view = SEQ_VIEW_SEQUENCE; + + ED_sequencer_update_view(C, sseq->view); + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_view_toggle(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "View Toggle"; + ot->idname= "SEQUENCER_OT_view_toggle"; + ot->description="Toggle between sequencer views (sequence, preview, both)."; + + /* api callbacks */ + ot->exec= sequencer_view_toggle_exec; + ot->poll= ED_operator_sequencer_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER; +} + + +/* view_selected operator */ static int sequencer_view_selected_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); |