Sequencer drawing cleanup (Part 1)
authorAndrea Weikert <elubie@gmx.net>
Mon, 14 Dec 2009 21:42:25 +0000 (21:42 +0000)
committerAndrea Weikert <elubie@gmx.net>
Mon, 14 Dec 2009 21:42:25 +0000 (21:42 +0000)
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

release/scripts/ui/space_sequencer.py
source/blender/blenloader/intern/readfile.c
source/blender/editors/include/ED_sequencer.h
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_sequencer/sequencer_intern.h
source/blender/editors/space_sequencer/sequencer_ops.c
source/blender/editors/space_sequencer/space_sequencer.c
source/blender/makesdna/DNA_screen_types.h
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/intern/rna_space.c

index 2beb2ff22d9dd65861490f2c4d92f77f93b7d05f..54fe48758f18a35b04ca2cb894b6c69888538c36 100644 (file)
@@ -44,20 +44,37 @@ class SEQUENCER_HT_header(bpy.types.Header):
 
             row.separator()
 
-            if st.display_mode == 'SEQUENCER':
+            if (st.view_type == 'SEQUENCER') or (st.view_type == 'SEQUENCER_PREVIEW'):
                 sub.menu("SEQUENCER_MT_select")
                 sub.menu("SEQUENCER_MT_marker")
                 sub.menu("SEQUENCER_MT_add")
                 sub.menu("SEQUENCER_MT_strip")
 
-        layout.prop(st, "display_mode", text="")
+        layout.prop(st, "view_type", text="")
 
-        if st.display_mode == 'SEQUENCER':
+        if (st.view_type == 'PREVIEW') or (st.view_type == 'SEQUENCER_PREVIEW'):
+            layout.prop(st, "display_mode", text="")
+
+        if (st.view_type == 'SEQUENCER'):
+            layout.separator()
+            layout.operator("sequencer.refresh_all")
+        elif (st.view_type == 'SEQUENCER_PREVIEW'):
             layout.separator()
             layout.operator("sequencer.refresh_all")
+            layout.prop(st, "display_channel", text="Channel")
         else:
             layout.prop(st, "display_channel", text="Channel")
 
+class SEQUENCER_MT_view_toggle(bpy.types.Menu):
+    bl_label = "View Type"
+
+    def draw(self, context):
+        layout = self.layout
+        
+        layout.operator("sequencer.view_toggle").type = 'SEQUENCER'
+        layout.operator("sequencer.view_toggle").type = 'PREVIEW'
+        layout.operator("sequencer.view_toggle").type = 'SEQUENCER_PREVIEW'
+
 
 class SEQUENCER_MT_view(bpy.types.Menu):
     bl_label = "View"
@@ -98,7 +115,10 @@ class SEQUENCER_MT_view(bpy.types.Menu):
 
         """
         layout.separator()
-        layout.operator("sequencer.view_all")
+        if (st.view_type == 'SEQUENCER') or (st.view_type == 'SEQUENCER_PREVIEW'):
+            layout.operator("sequencer.view_all", text='View all Sequences')
+        if (st.view_type == 'PREVIEW') or (st.view_type == 'SEQUENCER_PREVIEW'):
+            layout.operator("sequencer.view_all_preview", text='Fit preview in window')
         layout.operator("sequencer.view_selected")
 
         layout.prop(st, "draw_frames")
@@ -262,17 +282,23 @@ class SEQUENCER_MT_strip(bpy.types.Menu):
 class SequencerButtonsPanel(bpy.types.Panel):
     bl_space_type = 'SEQUENCE_EDITOR'
     bl_region_type = 'UI'
+    
+    def has_sequencer(self, context):
+        return (context.space_data.view_type == 'SEQUENCER') or (context.space_data.view_type == 'SEQUENCER_PREVIEW')
 
     def poll(self, context):
-        return (context.space_data.display_mode == 'SEQUENCER') and (act_strip(context) is not None)
+        return self.has_sequencer(context) and (act_strip(context) is not None)
 
 
 class SequencerButtonsPanel_Output(bpy.types.Panel):
     bl_space_type = 'SEQUENCE_EDITOR'
     bl_region_type = 'UI'
 
+    def has_preview(self, context):
+        return (context.space_data.view_type == 'PREVIEW') or (context.space_data.view_type == 'SEQUENCER_PREVIEW')
+
     def poll(self, context):
-        return context.space_data.display_mode != 'SEQUENCER'
+        return self.has_preview(context)
 
 
 class SEQUENCER_PT_edit(SequencerButtonsPanel):
@@ -331,7 +357,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel):
     bl_label = "Effect Strip"
 
     def poll(self, context):
-        if context.space_data.display_mode != 'SEQUENCER':
+        if not self.has_sequencer(context):
             return False
 
         strip = act_strip(context)
@@ -429,7 +455,7 @@ class SEQUENCER_PT_input(SequencerButtonsPanel):
     bl_label = "Strip Input"
 
     def poll(self, context):
-        if context.space_data.display_mode != 'SEQUENCER':
+        if not self.has_sequencer(context):
             return False
 
         strip = act_strip(context)
@@ -485,7 +511,7 @@ class SEQUENCER_PT_sound(SequencerButtonsPanel):
     bl_label = "Sound"
 
     def poll(self, context):
-        if context.space_data.display_mode != 'SEQUENCER':
+        if not self.has_sequencer(context):
             return False
 
         strip = act_strip(context)
@@ -519,7 +545,7 @@ class SEQUENCER_PT_scene(SequencerButtonsPanel):
     bl_label = "Scene"
 
     def poll(self, context):
-        if context.space_data.display_mode != 'SEQUENCER':
+        if not self.has_sequencer(context):
             return False
 
         strip = act_strip(context)
@@ -540,7 +566,7 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel):
     bl_label = "Filter"
 
     def poll(self, context):
-        if context.space_data.display_mode != 'SEQUENCER':
+        if not self.has_sequencer(context):
             return False
 
         strip = act_strip(context)
@@ -590,7 +616,7 @@ class SEQUENCER_PT_proxy(SequencerButtonsPanel):
     bl_label = "Proxy"
 
     def poll(self, context):
-        if context.space_data.display_mode != 'SEQUENCER':
+        if not self.has_sequencer(context):
             return False
 
         strip = act_strip(context)
@@ -630,6 +656,7 @@ class SEQUENCER_PT_view(SequencerButtonsPanel_Output):
 
 bpy.types.register(SEQUENCER_HT_header) # header/menu classes
 bpy.types.register(SEQUENCER_MT_view)
+bpy.types.register(SEQUENCER_MT_view_toggle)
 bpy.types.register(SEQUENCER_MT_select)
 bpy.types.register(SEQUENCER_MT_marker)
 bpy.types.register(SEQUENCER_MT_add)
index 384b1fcfd4dc3af4aa099ff0239de16ed990ca53..ef0022ccb66bf85592ee56b4147a6972c94e9aed 100644 (file)
@@ -6003,6 +6003,12 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
                                ar->regiontype= RGN_TYPE_UI;
                                ar->alignment= RGN_ALIGN_TOP;
                                break;
+                       case SPACE_SEQ:
+                               ar= MEM_callocN(sizeof(ARegion), "preview area for sequencer");
+                               BLI_addtail(lb, ar);
+                               ar->regiontype= RGN_TYPE_UI;
+                               ar->alignment= RGN_ALIGN_TOP;
+                               break;
                        case SPACE_VIEW3D:
                                /* toolbar */
                                ar= MEM_callocN(sizeof(ARegion), "toolbar for view3d");
@@ -10169,6 +10175,23 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        }
                }
        }
+       { /* fix for new view type in sequencer */
+               bScreen *screen;
+               ScrArea *sa;
+               SpaceLink *sl;
+               
+               for(screen= main->screen.first; screen; screen= screen->id.next) {
+                       for(sa= screen->areabase.first; sa; sa= sa->next) {
+                               for(sl= sa->spacedata.first; sl; sl= sl->next) {
+                                       if(sl->spacetype==SPACE_SEQ) {
+                                               SpaceSeq *sseq = (SpaceSeq *)sl;
+                                               if (sseq->view == 0) sseq->view = SEQ_VIEW_SEQUENCE;
+                                               if (sseq->mainb == 0) sseq->mainb = SEQ_DRAW_IMG_IMBUF;
+                                       }
+                               }
+                       }
+               }
+       }
 
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
index 2a3b5445dfe22adef405b57ef451973999096aa2..07c4dd6ca41b0893f3d536107436cf8cadcbeab8 100644 (file)
@@ -28,4 +28,7 @@
 #define SEQ_ZOOM_FAC(szoom) (szoom > 0)? (szoom) : (szoom == 0)? (1.0) : (-1.0/szoom)
 
 
+/* in space_sequencer.c, for rna update function */
+void ED_sequencer_update_view(bContext *C, int view);
+
 #endif /*  ED_SEQUENCER_H */
index c421c7fbb8568cbfce19b2aa8f0d8fc7b91d6f5d..277d32d636019e2737276c12144c21a05d09e2d1 100644 (file)
@@ -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"
@@ -2263,6 +2264,39 @@ void SEQUENCER_OT_meta_separate(wmOperatorType *ot)
 
 /* view_all operator */
 static int sequencer_view_all_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);
+       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);
@@ -2271,55 +2305,49 @@ static int sequencer_view_all_exec(bContext *C, wmOperator *op)
        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);
index a68001e536b17a1ed7d113f97eeff3b440a9be5f..e5e159138fc4b02ae396888e3959b350604baaaa 100644 (file)
@@ -95,9 +95,13 @@ void SEQUENCER_OT_swap_right(struct wmOperatorType *ot);
 void SEQUENCER_OT_swap_left(struct wmOperatorType *ot);
 void SEQUENCER_OT_rendersize(struct wmOperatorType *ot);
 
+void SEQUENCER_OT_view_toggle(struct wmOperatorType *ot);
 void SEQUENCER_OT_view_all(struct wmOperatorType *ot);
 void SEQUENCER_OT_view_selected(struct wmOperatorType *ot);
 
+/* preview specific operators */
+void SEQUENCER_OT_view_all_preview(struct wmOperatorType *ot);
+
 /* sequencer_select.c */
 void SEQUENCER_OT_select_all_toggle(struct wmOperatorType *ot);
 void SEQUENCER_OT_select(struct wmOperatorType *ot);
index 73a2070ca54b091445885f87ee96ca33fa5033c3..2636fa67c47cc11b5322be05331bb297bb13927a 100644 (file)
@@ -85,7 +85,9 @@ void sequencer_operatortypes(void)
 
        WM_operatortype_append(SEQUENCER_OT_view_all);
        WM_operatortype_append(SEQUENCER_OT_view_selected);
-       
+       WM_operatortype_append(SEQUENCER_OT_view_all_preview);
+       WM_operatortype_append(SEQUENCER_OT_view_toggle);
+
        /* sequencer_select.c */
        WM_operatortype_append(SEQUENCER_OT_select_all_toggle);
        WM_operatortype_append(SEQUENCER_OT_select_inverse);
@@ -110,9 +112,14 @@ void sequencer_operatortypes(void)
 
 void sequencer_keymap(wmKeyConfig *keyconf)
 {
-       wmKeyMap *keymap= WM_keymap_find(keyconf, "Sequencer", SPACE_SEQ, 0);
+       wmKeyMap *keymap= WM_keymap_find(keyconf, "SequencerCommon", SPACE_SEQ, 0);
        wmKeyMapItem *kmi;
-       
+
+       /* operators common to sequence and preview view */
+       WM_keymap_add_item(keymap, "SEQUENCER_OT_view_toggle", TABKEY, KM_PRESS, KM_CTRL, 0);
+
+       /* operators for sequence */
+       keymap= WM_keymap_find(keyconf, "Sequencer", SPACE_SEQ, 0);
        WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0);
        
        WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
@@ -214,5 +221,8 @@ void sequencer_keymap(wmKeyConfig *keyconf)
        WM_keymap_add_menu(keymap, "SEQUENCER_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
        
        transform_keymap_for_space(keyconf, keymap, SPACE_SEQ);
+
+       keymap= WM_keymap_find(keyconf, "SequencerPreview", SPACE_SEQ, 0);
+       WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all_preview", HOMEKEY, KM_PRESS, 0, 0);
 }
 
index 1e2fc1f59d313b50ce79d7038dc5731fc0616fb6..4c610dc6668fc790520cc9ba97678a360d3d492a 100644 (file)
@@ -90,6 +90,69 @@ ARegion *sequencer_has_buttons_region(ScrArea *sa)
        return arnew;
 }
 
+ARegion *sequencer_find_region(ScrArea *sa, short type)
+{
+       ARegion *ar=NULL;
+       
+       for(ar= sa->regionbase.first; ar; ar= ar->next)
+               if(ar->regiontype==type)
+                       return ar;
+
+       return ar;
+}
+
+void ED_sequencer_update_view(bContext *C, int view)
+{
+       ScrArea *sa= CTX_wm_area(C);
+       
+       ARegion *ar_main= sequencer_find_region(sa, RGN_TYPE_WINDOW);
+       ARegion *ar_preview= sequencer_find_region(sa, RGN_TYPE_PREVIEW);
+
+       switch (view) {
+               case SEQ_VIEW_SEQUENCE:
+                       if (ar_main->flag & RGN_FLAG_HIDDEN) {
+                               ar_main->flag &= ~RGN_FLAG_HIDDEN;
+                               ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
+                       }
+                       if (!(ar_preview->flag & RGN_FLAG_HIDDEN)) {
+                               ar_preview->flag |= RGN_FLAG_HIDDEN;
+                               ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+                               WM_event_remove_handlers(C, &ar_preview->handlers);
+                       }
+                       ar_main->alignment= RGN_ALIGN_NONE;
+                       ar_preview->alignment= RGN_ALIGN_NONE;
+                       break;
+               case SEQ_VIEW_PREVIEW:
+                       if (!(ar_main->flag & RGN_FLAG_HIDDEN)) {
+                               ar_main->flag |= RGN_FLAG_HIDDEN;
+                               ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
+                               WM_event_remove_handlers(C, &ar_main->handlers);
+                       }
+                       if (ar_preview->flag & RGN_FLAG_HIDDEN) {
+                               ar_preview->flag &= ~RGN_FLAG_HIDDEN;
+                               ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+                       }
+                       ar_main->alignment= RGN_ALIGN_NONE;
+                       ar_preview->alignment= RGN_ALIGN_NONE;
+                       break;
+               case SEQ_VIEW_SEQUENCE_PREVIEW:
+                       if (ar_main->flag & RGN_FLAG_HIDDEN) {
+                               ar_main->flag &= ~RGN_FLAG_HIDDEN;
+                               ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
+                       }
+                       if (ar_preview->flag & RGN_FLAG_HIDDEN) {
+                               ar_preview->flag &= ~RGN_FLAG_HIDDEN;
+                               ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+                       }
+                       ar_main->alignment= RGN_ALIGN_NONE;
+                       ar_preview->alignment= RGN_ALIGN_TOP;
+                       break;
+       }
+
+       ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
+       ED_area_tag_redraw(sa);
+}
+
 
 /* ******************** default callbacks for sequencer space ***************** */
 
@@ -103,8 +166,8 @@ static SpaceLink *sequencer_new(const bContext *C)
        sseq->spacetype= SPACE_SEQ;
        sseq->zoom= 4;
        sseq->chanshown = 0;
-       
-       
+       sseq->view = SEQ_VIEW_SEQUENCE;
+       sseq->mainb = SEQ_DRAW_IMG_IMBUF;
        /* header */
        ar= MEM_callocN(sizeof(ARegion), "header for sequencer");
        
@@ -120,6 +183,13 @@ static SpaceLink *sequencer_new(const bContext *C)
        ar->alignment= RGN_ALIGN_RIGHT;
        ar->flag = RGN_FLAG_HIDDEN;
        
+       /* preview area */
+       ar= MEM_callocN(sizeof(ARegion), "preview area for sequencer");
+       BLI_addtail(&sseq->regionbase, ar);
+       ar->regiontype= RGN_TYPE_PREVIEW;
+       ar->alignment= RGN_ALIGN_TOP;
+       ar->flag |= RGN_FLAG_HIDDEN;
+
        /* main area */
        ar= MEM_callocN(sizeof(ARegion), "main area for sequencer");
        
@@ -150,7 +220,7 @@ static SpaceLink *sequencer_new(const bContext *C)
        ar->v2d.keepzoom= 0;
        ar->v2d.keeptot= 0;
        ar->v2d.align= V2D_ALIGN_NO_NEG_Y;
-       
+
        return (SpaceLink *)sseq;
 }
 
@@ -181,7 +251,7 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl)
 }
 
 
-
+/* *********************** sequencer (main) region ************************ */
 /* add handlers, stuff you only do once or on area/region changes */
 static void sequencer_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
@@ -189,6 +259,9 @@ static void sequencer_main_area_init(wmWindowManager *wm, ARegion *ar)
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
        
+       keymap= WM_keymap_find(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
+       WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+       
        /* own keymap */
        keymap= WM_keymap_find(wm->defaultconf, "Sequencer", SPACE_SEQ, 0);
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
@@ -197,18 +270,9 @@ static void sequencer_main_area_init(wmWindowManager *wm, ARegion *ar)
 static void sequencer_main_area_draw(const bContext *C, ARegion *ar)
 {
        ScrArea *sa= CTX_wm_area(C);
-       SpaceSeq *sseq= sa->spacedata.first;
-       Scene *scene= CTX_data_scene(C);
-       
        
-       if (sseq->mainb != SEQ_DRAW_SEQUENCE) {
-               /* image-viewer types */
-               draw_image_seq(scene, ar, sseq);
-       }
-       else {
-               /* NLE - strip editing timeline interface */
-               draw_timeline_seq(C, ar);
-       }
+       /* NLE - strip editing timeline interface */
+       draw_timeline_seq(C, ar);
 }
 
 
@@ -248,6 +312,60 @@ static void sequencer_main_area_listener(ARegion *ar, wmNotifier *wmn)
        }
 }
 
+/* *********************** preview region ************************ */
+static void sequencer_preview_area_init(wmWindowManager *wm, ARegion *ar)
+{
+       wmKeyMap *keymap;
+       
+       UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
+       
+       keymap= WM_keymap_find(wm->defaultconf, "SequencerCommon", SPACE_SEQ, 0);
+       WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+
+       /* own keymap */
+       keymap= WM_keymap_find(wm->defaultconf, "SequencerPreview", SPACE_SEQ, 0);
+       WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+}
+
+static void sequencer_preview_area_draw(const bContext *C, ARegion *ar)
+{
+       ScrArea *sa= CTX_wm_area(C);
+       SpaceSeq *sseq= sa->spacedata.first;
+       Scene *scene= CTX_data_scene(C);
+       
+       /* XXX temp fix for wrong setting in sseq->mainb */
+       if (sseq->mainb == SEQ_DRAW_SEQUENCE) sseq->mainb = SEQ_DRAW_IMG_IMBUF;
+       draw_image_seq(scene, ar, sseq);
+}
+
+static void sequencer_preview_area_listener(ARegion *ar, wmNotifier *wmn)
+{
+       /* context changes */
+       switch(wmn->category) {
+               case NC_SCENE:
+                       switch(wmn->data) {
+                               case ND_FRAME:
+                               case ND_MARKERS:
+                               case ND_SEQUENCER:
+                               case ND_SEQUENCER_SELECT:
+                                       ED_region_tag_redraw(ar);
+                                       break;
+                       }
+                       break;
+               case NC_SPACE:
+                       if(wmn->data == ND_SPACE_SEQUENCER)
+                               ED_region_tag_redraw(ar);
+                       break;
+               case NC_ID:
+                       switch(wmn->data) {
+                               case NA_RENAME:
+                                       ED_region_tag_redraw(ar);
+                                       break;
+                       }
+                       break;
+       }
+}
+
 /* *********************** buttons region ************************ */
 
 /* add handlers, stuff you only do once or on area/region changes */
@@ -312,6 +430,16 @@ void ED_spacetype_sequencer(void)
        art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_ANIMATION;
 
        BLI_addhead(&st->regiontypes, art);
+
+       /* preview */
+       art= MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
+       art->regionid = RGN_TYPE_PREVIEW;
+       art->minsizey = 240; // XXX
+       art->init= sequencer_preview_area_init;
+       art->draw= sequencer_preview_area_draw;
+       art->listener= sequencer_preview_area_listener;
+       art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_ANIMATION;
+       BLI_addhead(&st->regiontypes, art);
        
        /* regions: listview/buttons */
        art= MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
index 18c7a819eb35dbcfb3224600c5eb9f35bb4038c5..2bc7b1e8431e659246eeed00e915f8bf402653a7 100644 (file)
@@ -219,6 +219,7 @@ typedef struct ARegion {
 #define RGN_TYPE_UI                    4
 #define RGN_TYPE_TOOLS         5
 #define RGN_TYPE_TOOL_PROPS    6
+#define RGN_TYPE_PREVIEW       7
 
 /* region alignment */
 #define RGN_ALIGN_NONE         0
index 40d59b666bf447fd66739b187e55e1ff4b46e66e..e02d719470f06a5336a702dcb1b7afd179c5d105 100644 (file)
@@ -146,7 +146,9 @@ typedef struct SpaceSeq {
        short zebra;
        int flag;
        float zoom;
-       
+       int view; /* see SEQ_VIEW_* below */
+       int pad;
+
        struct bGPdata *gpd;            /* grease-pencil data */
 } SpaceSeq;
 
@@ -857,6 +859,12 @@ enum {
 #define SEQ_DRAW_GPENCIL                       16
 #define SEQ_NO_DRAW_CFRANUM                    32
 
+/* sseq->view */
+#define SEQ_VIEW_SEQUENCE                      1
+#define SEQ_VIEW_PREVIEW                       2
+#define SEQ_VIEW_SEQUENCE_PREVIEW      3
+
+
 /* space types, moved from DNA_screen_types.h */
 enum {
        SPACE_EMPTY,
index 382ab96f059eb2f88c6f0ef996025d8360850127..2fd0bf1810a25564eeab01ff528ad6bd29c82ff7 100644 (file)
@@ -106,6 +106,7 @@ EnumPropertyItem autosnap_items[] = {
 #include "ED_image.h"
 #include "ED_screen.h"
 #include "ED_view3d.h"
+#include "ED_sequencer.h"
 
 #include "IMB_imbuf_types.h"
 
@@ -482,6 +483,13 @@ static int rna_SpaceGraphEditor_has_ghost_curves_get(PointerRNA *ptr)
        return (sipo->ghostCurves.first != NULL);
 }
 
+static void rna_Sequencer_display_mode_update(bContext *C, PointerRNA *ptr)
+{
+       int view = RNA_int_get(ptr, "view_type");
+
+       ED_sequencer_update_view(C, view);
+}
+
 #else
 
 static void rna_def_space(BlenderRNA *brna)
@@ -1068,8 +1076,13 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
        StructRNA *srna;
        PropertyRNA *prop;
        
+       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}};
+
        static EnumPropertyItem display_mode_items[] = {
-               {SEQ_DRAW_SEQUENCE, "SEQUENCER", ICON_SEQ_SEQUENCER, "Sequencer", ""},
                {SEQ_DRAW_IMG_IMBUF, "IMAGE", ICON_SEQ_PREVIEW, "Image Preview", ""},
                {SEQ_DRAW_IMG_WAVEFORM, "WAVEFORM", ICON_SEQ_LUMA_WAVEFORM, "Luma Waveform", ""},
                {SEQ_DRAW_IMG_VECTORSCOPE, "VECTOR_SCOPE", ICON_SEQ_CHROMA_SCOPE, "Chroma Vectorscope", ""},
@@ -1080,6 +1093,14 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
        RNA_def_struct_sdna(srna, "SpaceSeq");
        RNA_def_struct_ui_text(srna, "Space Sequence Editor", "Sequence editor space data.");
        
+       /* view type, fairly important */
+       prop= RNA_def_property(srna, "view_type", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "view");
+       RNA_def_property_enum_items(prop, view_type_items);
+       RNA_def_property_ui_text(prop, "View Type", "The type of the Sequencere view (sequencer, preview or both).");
+       RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+       RNA_def_property_update(prop, 0, "rna_Sequencer_display_mode_update");
+
        /* display type, fairly important */
        prop= RNA_def_property(srna, "display_mode", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "mainb");