[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47586] trunk/blender/source/blender/ editors: initial support for editing masks in the sequencer, currently only draw the mask.

Campbell Barton ideasman42 at gmail.com
Thu Jun 7 21:24:56 CEST 2012


Revision: 47586
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47586
Author:   campbellbarton
Date:     2012-06-07 19:24:49 +0000 (Thu, 07 Jun 2012)
Log Message:
-----------
initial support for editing masks in the sequencer, currently only draw the mask.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/mask/mask_edit.c
    trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c
    trunk/blender/source/blender/editors/space_sequencer/space_sequencer.c

Modified: trunk/blender/source/blender/editors/mask/mask_edit.c
===================================================================
--- trunk/blender/source/blender/editors/mask/mask_edit.c	2012-06-07 18:33:36 UTC (rev 47585)
+++ trunk/blender/source/blender/editors/mask/mask_edit.c	2012-06-07 19:24:49 UTC (rev 47586)
@@ -35,6 +35,8 @@
 #include "BKE_context.h"
 #include "BKE_mask.h"
 
+#include "DNA_scene_types.h"
+
 #include "WM_api.h"
 #include "WM_types.h"
 
@@ -132,16 +134,24 @@
 
 void ED_mask_size(bContext *C, int *width, int *height)
 {
-	SpaceClip *sc = CTX_wm_space_clip(C);
+	ScrArea *sa = CTX_wm_area(C);
+	if (sa && sa->spacedata.first) {
+		if (sa->spacetype == SPACE_CLIP) {
+			SpaceClip *sc = sa->spacedata.first;
+			ED_space_clip_mask_size(sc, width, height);
+			return;
+		}
+		else if (sa->spacetype == SPACE_SEQ) {
+			Scene *scene = CTX_data_scene(C);
+			*width = (scene->r.size * scene->r.xsch) / 100;
+			*height = (scene->r.size * scene->r.ysch) / 100;
+			return;
+		}
+	}
 
-	if (sc) {
-		ED_space_clip_mask_size(sc, width, height);
-	}
-	else {
-		/* possible other spaces from which mask editing is available */
-		*width = 0;
-		*height = 0;
-	}
+	/* possible other spaces from which mask editing is available */
+	*width = 0;
+	*height = 0;
 }
 
 void ED_mask_aspect(bContext *C, float *aspx, float *aspy)

Modified: trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c	2012-06-07 18:33:36 UTC (rev 47585)
+++ trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c	2012-06-07 19:24:49 UTC (rev 47586)
@@ -59,7 +59,9 @@
 
 #include "ED_anim_api.h"
 #include "ED_markers.h"
+#include "ED_mask.h"
 #include "ED_types.h"
+#include "ED_space_api.h"
 
 #include "UI_interface.h"
 #include "UI_resources.h"
@@ -984,6 +986,59 @@
 	
 	/* ortho at pixel level */
 	UI_view2d_view_restore(C);
+
+	//if (sc->mode == SC_MODE_MASKEDIT) {
+	if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
+		Sequence *seq_act = BKE_sequencer_active_get(scene);
+
+		if (seq_act && seq_act->type == SEQ_TYPE_MASK && seq_act->mask) {
+			int x, y;
+			int width, height;
+			float zoomx, zoomy;
+
+			/* frame image */
+			float maxdim;
+			float xofs, yofs;
+
+			/* find window pixel coordinates of origin */
+			UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
+
+			width = v2d->tot.xmax - v2d->tot.xmin;
+			height = v2d->tot.ymax - v2d->tot.ymin;
+
+			zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin));
+			zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin));
+
+			x += v2d->tot.xmin * zoomx;
+			y += v2d->tot.ymin * zoomy;
+
+			/* frame the image */
+			maxdim = maxf(width, height);
+			if (width == height) {
+				xofs = yofs = 0;
+			}
+			else if (width < height) {
+				xofs = ((height - width) / -2.0f) * zoomx;
+				yofs = 0.0f;
+			}
+			else { /* (width > height) */
+				xofs = 0.0f;
+				yofs = ((width - height) / -2.0f) * zoomy;
+			}
+
+			/* apply transformation so mask editing tools will assume drawing from the origin in normalized space */
+			glPushMatrix();
+			glTranslatef(x + xofs, y + yofs, 0);
+			glScalef(maxdim * zoomx, maxdim * zoomy, 0);
+
+			ED_mask_draw((bContext *)C, 0, 0); // sc->mask_draw_flag, sc->mask_draw_type
+
+			ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
+
+			glPopMatrix();
+		}
+	}
+
 }
 
 #if 0

Modified: trunk/blender/source/blender/editors/space_sequencer/space_sequencer.c
===================================================================
--- trunk/blender/source/blender/editors/space_sequencer/space_sequencer.c	2012-06-07 18:33:36 UTC (rev 47585)
+++ trunk/blender/source/blender/editors/space_sequencer/space_sequencer.c	2012-06-07 19:24:49 UTC (rev 47586)
@@ -33,6 +33,7 @@
 #include <stdio.h>
 
 #include "DNA_scene_types.h"
+#include "DNA_mask_types.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -380,6 +381,29 @@
 
 /* ************* end drop *********** */
 
+const char *sequencer_context_dir[] = {"edit_mask", NULL};
+
+static int sequencer_context(const bContext *C, const char *member, bContextDataResult *result)
+{
+	Scene *scene = CTX_data_scene(C);
+
+	if (CTX_data_dir(member)) {
+		CTX_data_dir_set(result, sequencer_context_dir);
+
+		return TRUE;
+	}
+	else if (CTX_data_equals(member, "edit_mask")) {
+		Sequence *seq_act = BKE_sequencer_active_get(scene);
+		if (seq_act && seq_act->type == SEQ_TYPE_MASK && seq_act->mask) {
+			CTX_data_id_pointer_set(result, &seq_act->mask->id);
+		}
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+
 /* add handlers, stuff you only do once or on area/region changes */
 static void sequencer_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar)
 {
@@ -545,6 +569,7 @@
 	st->duplicate = sequencer_duplicate;
 	st->operatortypes = sequencer_operatortypes;
 	st->keymap = sequencer_keymap;
+	st->context = sequencer_context;
 	st->dropboxes = sequencer_dropboxes;
 	st->refresh = sequencer_refresh;
 
@@ -597,4 +622,3 @@
 		sequencer_view3d_cb = ED_view3d_draw_offscreen_imbuf_simple;
 	}
 }
-




More information about the Bf-blender-cvs mailing list