Merging r49834 through r49839 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Sun, 12 Aug 2012 13:38:46 +0000 (13:38 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Sun, 12 Aug 2012 13:38:46 +0000 (13:38 +0000)
release/scripts/startup/bl_ui/space_sequencer.py
source/blender/blenkernel/intern/sequencer.c
source/blender/editors/space_clip/clip_intern.h
source/blender/editors/space_clip/clip_ops.c
source/blender/editors/space_clip/space_clip.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/editors/space_sequencer/sequencer_intern.h
source/blender/editors/space_sequencer/space_sequencer.c
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/intern/rna_space.c

index 9c996cc31dc6b22fbe2361922a30c81dc908b34e..bcadd47cea3a28542c59e85be6396cf2ce57e07d 100644 (file)
@@ -75,6 +75,9 @@ class SEQUENCER_HT_header(Header):
                     row.prop(ed, "overlay_frame", text="")
                     row.prop(ed, "overlay_lock", text="", icon='LOCKED')
 
+                    row = layout.row()
+                    row.prop(st, "overlay_type", text="")
+
                 row = layout.row(align=True)
                 props = row.operator("render.opengl", text="", icon='RENDER_STILL')
                 props.sequencer = True
index 920588d9f47607498595b7bc14f45d78a29f53c9..45259b5dbc9f4b4d0e9612805f05ada717054e2f 100644 (file)
@@ -136,6 +136,8 @@ static void free_proxy_seq(Sequence *seq)
                IMB_free_anim(seq->strip->proxy->anim);
                seq->strip->proxy->anim = NULL;
        }
+
+       BKE_sequencer_cache_cleanup_sequence(seq);
 }
 
 static void seq_free_strip(Strip *strip)
index 392367f90718a9e3c2a82a64c0b16b0f81d6cd3e..d33f77c106435003e6a503ea952aaa1764a5727d 100644 (file)
@@ -102,6 +102,8 @@ void CLIP_OT_change_frame(wmOperatorType *ot);
 void CLIP_OT_rebuild_proxy(struct wmOperatorType *ot);
 void CLIP_OT_mode_set(struct wmOperatorType *ot);
 
+void CLIP_OT_view_ndof(struct wmOperatorType *ot);
+
 /* clip_toolbar.c */
 struct ARegion *ED_clip_has_properties_region(struct ScrArea *sa);
 void CLIP_OT_tools(struct wmOperatorType *ot);
index b8657f9e688bc88c4591be183587027654095ed8..9b4f3fcdd68ff650ab6e8b48428ffb11b06f61ed 100644 (file)
@@ -1111,6 +1111,65 @@ void CLIP_OT_mode_set(wmOperatorType *ot)
        RNA_def_enum(ot->srna, "mode", clip_editor_mode_items, SC_MODE_TRACKING, "Mode", "");
 }
 
+/********************** NDOF operator *********************/
+
+/* Combined pan/zoom from a 3D mouse device.
+ * Z zooms, XY pans
+ * "view" (not "paper") control -- user moves the viewpoint, not the image being viewed
+ * that explains the negative signs in the code below
+ */
+
+static int clip_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
+{
+       if (event->type != NDOF_MOTION)
+               return OPERATOR_CANCELLED;
+       else {
+               SpaceClip *sc = CTX_wm_space_clip(C);
+               ARegion *ar = CTX_wm_region(C);
+
+               wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata;
+
+               float dt = ndof->dt;
+
+               /* tune these until it feels right */
+               const float zoom_sensitivity = 0.5f;  /* 50% per second (I think) */
+               const float pan_sensitivity = 300.0f; /* screen pixels per second */
+
+               float pan_x = pan_sensitivity * dt * ndof->tvec[0] / sc->zoom;
+               float pan_y = pan_sensitivity * dt * ndof->tvec[1] / sc->zoom;
+
+               /* "mouse zoom" factor = 1 + (dx + dy) / 300
+                * what about "ndof zoom" factor? should behave like this:
+                * at rest -> factor = 1
+                * move forward -> factor > 1
+                * move backward -> factor < 1
+                */
+               float zoom_factor = 1.0f + zoom_sensitivity * dt * - ndof->tvec[2];
+
+               if (U.ndof_flag & NDOF_ZOOM_INVERT)
+                       zoom_factor = -zoom_factor;
+
+               sclip_zoom_set_factor(C, zoom_factor, NULL);
+               sc->xof += pan_x;
+               sc->yof += pan_y;
+
+               ED_region_tag_redraw(ar);
+
+               return OPERATOR_FINISHED;
+       }
+}
+
+void CLIP_OT_view_ndof(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "NDOF Pan/Zoom";
+       ot->idname = "CLIP_OT_view_ndof";
+       ot->description = "Use a 3D mouse device to pan/zoom the view";
+
+       /* api callbacks */
+       ot->invoke = clip_view_ndof_invoke;
+}
+
 /********************** macroses *********************/
 
 void ED_operatormacros_clip(void)
index 39ad2465a483fdcfaf5bbe277f328eab7e28ff44..3da9f1b018f318392bc55465f1b4fe512ad23875 100644 (file)
@@ -444,6 +444,7 @@ static void clip_operatortypes(void)
        WM_operatortype_append(CLIP_OT_change_frame);
        WM_operatortype_append(CLIP_OT_rebuild_proxy);
        WM_operatortype_append(CLIP_OT_mode_set);
+       WM_operatortype_append(CLIP_OT_view_ndof);
 
        /* ** clip_toolbar.c ** */
        WM_operatortype_append(CLIP_OT_tools);
@@ -608,6 +609,9 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
 
        WM_keymap_add_item(keymap, "CLIP_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
 
+       WM_keymap_add_item(keymap, "CLIP_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "CLIP_OT_view_ndof", NDOF_MOTION, 0, 0, 0);
+
        /* jump to special frame */
        kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
        RNA_enum_set(kmi->ptr, "position", 0);
index bf7d0df02e84e06aeb6041eb26a48d8181649c5d..f3122d04fac5f40224085e0042d53047b27c8ded 100644 (file)
@@ -802,7 +802,7 @@ static void UNUSED_FUNCTION(set_special_seq_update) (int val)
        else special_seq_update = NULL;
 }
 
-void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs)
+void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs, int draw_overlay)
 {
        struct Main *bmain = CTX_data_main(C);
        struct ImBuf *ibuf = NULL;
@@ -842,7 +842,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
                viewrecty /= proxy_size / 100.0f;
        }
 
-       if (frame_ofs == 0) {
+       if (!draw_overlay || sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) {
                UI_GetThemeColor3fv(TH_SEQ_PREVIEW, col);
                glClearColor(col[0], col[1], col[2], 0.0);
                glClear(GL_COLOR_BUFFER_BIT);
@@ -930,17 +930,25 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
        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);
+       if (draw_overlay) {
+               if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) {
+                       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 if (sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) {
+                       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);
+               }
        }
        else {
                glTexCoord2f(0.0f, 0.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymin);
index 14d2ccdbbbe4fb1b929b2a3756e6a3c7dbde5a41..16cf929a832aef466e12a5f7351a0945d17464cd 100644 (file)
@@ -51,7 +51,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, int cfra, int offset);
+void draw_image_seq(const struct bContext* C, struct Scene *scene, struct  ARegion *ar, struct SpaceSeq *sseq, int cfra, int offset, int draw_overlay);
 
 void seq_reset_imageofs(struct SpaceSeq *sseq);
 
index 34ca26a317632c3bb3f55606df0964e1058b21a5..f7362aab7aa388c8467e79c5fe3e6987bd9c877b 100644 (file)
@@ -487,13 +487,15 @@ 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);
+       int show_split = scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW && sseq->mainb == SEQ_DRAW_IMG_IMBUF;
        
        /* 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, scene->r.cfra, 0);
+       if (!show_split || sseq->overlay_type != SEQ_DRAW_OVERLAY_REFERENCE)
+               draw_image_seq(C, scene, ar, sseq, scene->r.cfra, 0, FALSE);
 
-       if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW && sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
+       if (show_split && sseq->overlay_type != SEQ_DRAW_OVERLAY_CURRENT) {
                int over_cfra;
 
                if (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS)
@@ -501,8 +503,8 @@ static void sequencer_preview_area_draw(const bContext *C, ARegion *ar)
                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);
+               if (over_cfra != scene->r.cfra || sseq->overlay_type != SEQ_DRAW_OVERLAY_RECT)
+                       draw_image_seq(C, scene, ar, sseq, scene->r.cfra, over_cfra - scene->r.cfra, TRUE);
        }
 
 }
index 779e3987d6807f54276121e887464581961f1cef..89a027cbcfbdf948e055eaaf50b36dacbf529dd6 100644 (file)
@@ -470,7 +470,7 @@ typedef struct SpaceSeq {
        int flag;
        float zoom DNA_DEPRECATED;  /* deprecated, handled by View2D now */
        int view; /* see SEQ_VIEW_* below */
-       int pad;
+       int overlay_type;
 
        struct bGPdata *gpd;        /* grease-pencil data */
 
@@ -526,6 +526,13 @@ typedef struct MaskSpaceInfo
        char pad3[6];
 } MaskSpaceInfo;
 
+/* sseq->mainb */
+typedef enum eSpaceSeq_OverlayType {
+       SEQ_DRAW_OVERLAY_RECT = 0,
+       SEQ_DRAW_OVERLAY_REFERENCE = 1,
+       SEQ_DRAW_OVERLAY_CURRENT = 2
+} eSpaceSeq_OverlayType;
+
 /* File Selector ========================================== */
 
 /* Config and Input for File Selector */
index 23ea6d0120f3b5b4c8b474f77b115728e53efdbc..489caff1f813c9a6dda253a7c1ac7e891087dffa 100644 (file)
@@ -2132,7 +2132,14 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
                {SEQ_PROXY_RENDER_SIZE_FULL, "FULL", 0, "No proxy, full render", ""},
                {0, NULL, 0, NULL, NULL}
        };
-       
+
+       static EnumPropertyItem overlay_type_items[] = {
+               {SEQ_DRAW_OVERLAY_RECT, "RECTANGLE", 0, "Rectangle", "Show rectangle area overlay"},
+               {SEQ_DRAW_OVERLAY_REFERENCE, "REFERENCE", 0, "Reference", "Show reference frame only"},
+               {SEQ_DRAW_OVERLAY_CURRENT, "CURRENT", 0, "Current", "Show current frame only"},
+               {0, NULL, 0, NULL, NULL}
+       };
+
        srna = RNA_def_struct(brna, "SpaceSequenceEditor", "Space");
        RNA_def_struct_sdna(srna, "SpaceSeq");
        RNA_def_struct_ui_text(srna, "Space Sequence Editor", "Sequence editor space data");
@@ -2215,6 +2222,12 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
        RNA_def_property_pointer_sdna(prop, NULL, "view_settings");
        RNA_def_property_struct_type(prop, "ColorManagedViewSettings");
        RNA_def_property_ui_text(prop, "View Settings", "Color management settings used for displaying images on the display");
+
+       prop = RNA_def_property(srna, "overlay_type", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "overlay_type");
+       RNA_def_property_enum_items(prop, overlay_type_items);
+       RNA_def_property_ui_text(prop, "Overlay Type", "Overlay draw type");
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
 }
 
 static void rna_def_space_text(BlenderRNA *brna)