[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59632] trunk/blender/source/blender: Support transformation around 2D cursor in movie clip editor.
Sergey Sharybin
sergey.vfx at gmail.com
Thu Aug 29 15:04:12 CEST 2013
Revision: 59632
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59632
Author: nazgul
Date: 2013-08-29 13:04:12 +0000 (Thu, 29 Aug 2013)
Log Message:
-----------
Support transformation around 2D cursor in movie clip editor.
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_clip/clip_ops.c
trunk/blender/source/blender/editors/space_clip/space_clip.c
trunk/blender/source/blender/editors/transform/transform_generics.c
trunk/blender/source/blender/makesrna/intern/rna_space.c
Modified: trunk/blender/source/blender/editors/space_clip/clip_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_ops.c 2013-08-29 12:55:31 UTC (rev 59631)
+++ trunk/blender/source/blender/editors/space_clip/clip_ops.c 2013-08-29 13:04:12 UTC (rev 59632)
@@ -1493,7 +1493,7 @@
/* api callbacks */
ot->exec = clip_set_2d_cursor_exec;
ot->invoke = clip_set_2d_cursor_invoke;
- ot->poll = ED_space_clip_maskedit_mask_poll;
+ ot->poll = ED_space_clip_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
Modified: trunk/blender/source/blender/editors/space_clip/space_clip.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/space_clip.c 2013-08-29 12:55:31 UTC (rev 59631)
+++ trunk/blender/source/blender/editors/space_clip/space_clip.c 2013-08-29 13:04:12 UTC (rev 59632)
@@ -1121,6 +1121,8 @@
/* draw entirely, view changes should be handled here */
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
+ float aspx, aspy, zoomx, zoomy, x, y;
+ int width, height;
/* if tracking is in progress, we should synchronize framenr from clipuser
* so latest tracked frame would be shown */
@@ -1152,36 +1154,35 @@
clip_draw_main(C, sc, ar);
+ /* TODO(sergey): would be nice to find a way to de-duplicate all this space conversions */
+ UI_view2d_to_region_float(&ar->v2d, 0.0f, 0.0f, &x, &y);
+ ED_space_clip_get_size(sc, &width, &height);
+ ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
+ ED_space_clip_get_aspect(sc, &aspx, &aspy);
+
if (sc->mode == SC_MODE_MASKEDIT) {
-
Mask *mask = CTX_data_edit_mask(C);
if (mask) {
ScrArea *sa = CTX_wm_area(C);
- int width, height;
- float aspx, aspy, zoomx, zoomy, x, y;
- ED_mask_get_size(sa, &width, &height);
- ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
- ED_space_clip_get_aspect(sc, &aspx, &aspy);
+ int mask_width, mask_height;
+ ED_mask_get_size(sa, &mask_width, &mask_height);
ED_mask_draw_region(mask, ar,
sc->mask_info.draw_flag, sc->mask_info.draw_type,
- width, height,
+ mask_width, mask_height,
aspx, aspy,
TRUE, TRUE,
sc->stabmat, C);
-
- /* TODO(sergey): would be nice to find a way to de-duplicate all this space conversions */
- UI_view2d_to_region_float(&ar->v2d, 0.0f, 0.0f, &x, &y);
-
- glPushMatrix();
- glTranslatef(x, y, 0);
- glScalef(zoomx, zoomy, 0);
- glMultMatrixf(sc->stabmat);
- glScalef(width, height, 0);
- draw_image_cursor(ar, sc->cursor);
- glPopMatrix();
}
}
+ glPushMatrix();
+ glTranslatef(x, y, 0);
+ glScalef(zoomx, zoomy, 0);
+ glMultMatrixf(sc->stabmat);
+ glScalef(width, height, 0);
+ draw_image_cursor(ar, sc->cursor);
+ glPopMatrix();
+
if (sc->flag & SC_SHOW_GPENCIL) {
/* Grease Pencil */
clip_draw_grease_pencil((bContext *)C, TRUE);
Modified: trunk/blender/source/blender/editors/transform/transform_generics.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_generics.c 2013-08-29 12:55:31 UTC (rev 59631)
+++ trunk/blender/source/blender/editors/transform/transform_generics.c 2013-08-29 13:04:12 UTC (rev 59632)
@@ -1523,7 +1523,6 @@
if (t->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
- /* only space supported right now but may change */
if (t->options & CTX_MASK) {
ED_space_image_get_aspect(sima, &aspx, &aspy);
}
@@ -1532,18 +1531,38 @@
}
cursor = sima->cursor;
}
+ else if (t->spacetype == SPACE_CLIP) {
+ SpaceClip *space_clip = (SpaceClip *) t->sa->spacedata.first;
+ if (t->options & CTX_MOVIECLIP) {
+ ED_space_clip_get_aspect_dimension_aware(space_clip, &aspx, &aspy);
+ }
+ else {
+ ED_space_clip_get_aspect(space_clip, &aspx, &aspy);
+ }
+ cursor = space_clip->cursor;
+ }
if (cursor) {
if (t->options & CTX_MASK) {
float co[2];
float frame_size[2];
- SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
- ED_space_image_get_size_fl(sima, frame_size);
- BKE_mask_coord_from_frame(co, cursor, frame_size);
+ if (t->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
+ ED_space_image_get_size_fl(sima, frame_size);
+ BKE_mask_coord_from_frame(co, cursor, frame_size);
+ ED_space_image_get_aspect(sima, &aspx, &aspy);
+ }
+ else if (t->spacetype == SPACE_CLIP) {
+ SpaceClip *space_clip = (SpaceClip *) t->sa->spacedata.first;
+ ED_space_clip_get_size_fl(space_clip, frame_size);
+ BKE_mask_coord_from_frame(co, cursor, frame_size);
+ ED_space_clip_get_aspect(space_clip, &aspx, &aspy);
+ }
+ else {
+ BLI_assert(!"Shall not happen");
+ }
- ED_space_image_get_aspect(sima, &aspx, &aspy);
-
t->center[0] = co[0] * aspx;
t->center[1] = co[1] * aspy;
}
@@ -1621,7 +1640,7 @@
calculateCenterMedian(t);
break;
case V3D_CURSOR:
- if (t->spacetype == SPACE_IMAGE)
+ if (ELEM(t->spacetype, SPACE_IMAGE, SPACE_CLIP))
calculateCenterCursor2D(t);
else if (t->spacetype == SPACE_IPO)
calculateCenterCursorGraph2D(t);
Modified: trunk/blender/source/blender/makesrna/intern/rna_space.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_space.c 2013-08-29 12:55:31 UTC (rev 59631)
+++ trunk/blender/source/blender/makesrna/intern/rna_space.c 2013-08-29 13:04:12 UTC (rev 59632)
@@ -3534,6 +3534,7 @@
static EnumPropertyItem pivot_items[] = {
{V3D_CENTER, "BOUNDING_BOX_CENTER", ICON_ROTATE, "Bounding Box Center",
"Pivot around bounding box center of selected object(s)"},
+ {V3D_CURSOR, "CURSOR", ICON_CURSOR, "2D Cursor", "Pivot around the 2D cursor"},
{V3D_LOCAL, "INDIVIDUAL_ORIGINS", ICON_ROTATECOLLECTION,
"Individual Origins", "Pivot around each object's own origin"},
{V3D_CENTROID, "MEDIAN_POINT", ICON_ROTATECENTER, "Median Point",
More information about the Bf-blender-cvs
mailing list