Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-11-08 06:57:28 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-08 06:57:28 +0400
commitcb890a49fbd653c71d2fe639265a1a562136113f (patch)
tree10ddd1f7198c85408f83794fe560caa9512e2a2e /source/blender/editors/gpencil
parentaea95c78606a99b0fa9c4c29c9e922e4a03f2a69 (diff)
parentf086201518b85f6dd2ae60ae37dc14f1d1406c01 (diff)
svn merge ^/trunk/blender -r41602:41638 .
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c3
-rw-r--r--source/blender/editors/gpencil/editaction_gpencil.c1
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c14
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c56
4 files changed, 68 insertions, 6 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 64da61f8f55..081d604819d 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -693,6 +693,7 @@ void draw_gpencil_2dimage (bContext *C, ImBuf *ibuf)
/* calculate rect */
switch (sa->spacetype) {
case SPACE_IMAGE: /* image */
+ case SPACE_CLIP: /* clip */
{
/* just draw using standard scaling (settings here are currently ignored anyways) */
@@ -766,7 +767,7 @@ void draw_gpencil_view2d (bContext *C, short onlyv2d)
/* special hack for Image Editor */
// FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled
- if (sa->spacetype == SPACE_IMAGE)
+ if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP))
dflag |= GP_DRAWDATA_IEDITHACK;
/* draw it! */
diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c
index 56210864593..81a5f6777e7 100644
--- a/source/blender/editors/gpencil/editaction_gpencil.c
+++ b/source/blender/editors/gpencil/editaction_gpencil.c
@@ -422,6 +422,7 @@ void paste_gpdata (Scene *scene)
case SPACE_NODE: /* Nodes Editor: either screen-aligned or view-aligned */
case SPACE_IMAGE: /* Image Editor: either screen-aligned or view\image-aligned */
+ case SPACE_CLIP: /* Image Editor: either screen-aligned or view\image-aligned */
if ((gps->flag == 0) || (gps->flag & GP_STROKE_2DSPACE))
stroke_ok= 1;
break;
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 7b79384fbb4..65db5e27ed7 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -69,6 +69,7 @@
#include "ED_gpencil.h"
#include "ED_view3d.h"
+#include "ED_clip.h"
#include "gpencil_intern.h"
@@ -137,6 +138,19 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr)
}
break;
+ case SPACE_CLIP: /* Nodes Editor */
+ {
+ SpaceClip *sc= (SpaceClip *)CTX_wm_space_data(C);
+ MovieClip *clip= ED_space_clip(sc);
+
+ if(clip) {
+ /* for now, as long as there's a clip, default to using that in Clip Editor */
+ if (ptr) RNA_id_pointer_create(&clip->id, ptr);
+ return &clip->gpd;
+ }
+ }
+ break;
+
default: /* unsupported space */
return NULL;
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 12f03f7341c..bd02df2ddba 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -103,6 +103,11 @@ typedef struct tGPsdata {
short radius; /* radius of influence for eraser */
short flags; /* flags that can get set during runtime */
+
+ float imat[4][4]; /* inverted transformation matrix applying when converting coords from screen-space
+ to region space */
+
+ float custom_color[3]; /* custom color for */
} tGPsdata;
/* values for tGPsdata->status */
@@ -277,6 +282,7 @@ static void gp_stroke_convertcoords (tGPsdata *p, const int mval[2], float out[3
/* 2d - on 'canvas' (assume that p->v2d is set) */
else if ((gpd->sbuffer_sflag & GP_STROKE_2DSPACE) && (p->v2d)) {
UI_view2d_region_to_view(p->v2d, mval[0], mval[1], &out[0], &out[1]);
+ mul_v3_m4v3(out, p->imat, out);
}
#if 0
@@ -997,6 +1003,8 @@ static int gp_session_initdata (bContext *C, tGPsdata *p)
/* pass on current scene and window */
p->scene= CTX_data_scene(C);
p->win= CTX_wm_window(C);
+
+ unit_m4(p->imat);
switch (curarea->spacetype) {
/* supported views first */
@@ -1097,6 +1105,33 @@ static int gp_session_initdata (bContext *C, tGPsdata *p)
#endif
}
break;
+ case SPACE_CLIP:
+ {
+ SpaceClip *sc= curarea->spacedata.first;
+
+ /* set the current area */
+ p->sa= curarea;
+ p->ar= ar;
+ p->v2d= &ar->v2d;
+ //p->ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
+
+ invert_m4_m4(p->imat, sc->unistabmat);
+
+ /* custom color for new layer */
+ p->custom_color[0]= 1.0f;
+ p->custom_color[1]= 0.0f;
+ p->custom_color[2]= 0.5f;
+ p->custom_color[3]= 0.9f;
+
+ /* check that gpencil data is allowed to be drawn */
+ if ((sc->flag & SC_SHOW_GPENCIL)==0) {
+ p->status= GP_STATUS_ERROR;
+ if (G.f & G_DEBUG)
+ printf("Error: In active view, Grease Pencil not shown \n");
+ return 0;
+ }
+ }
+ break;
/* unsupported views */
default:
@@ -1182,8 +1217,12 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode)
{
/* get active layer (or add a new one if non-existent) */
p->gpl= gpencil_layer_getactive(p->gpd);
- if (p->gpl == NULL)
+ if (p->gpl == NULL) {
p->gpl= gpencil_layer_addnew(p->gpd);
+
+ if(p->custom_color[3])
+ copy_v3_v3(p->gpl->color, p->custom_color);
+ }
if (p->gpl->flag & GP_LAYER_LOCKED) {
p->status= GP_STATUS_ERROR;
if (G.f & G_DEBUG)
@@ -1299,6 +1338,12 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode)
p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE;
}
break;
+
+ case SPACE_CLIP:
+ {
+ p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE;
+ }
+ break;
}
}
}
@@ -1336,9 +1381,12 @@ static void gp_paint_strokeend (tGPsdata *p)
/* finish off stroke painting operation */
static void gp_paint_cleanup (tGPsdata *p)
{
- /* finish off a stroke */
- if(p->gpd)
+ /* p->gpd==NULL happens when stroke failed to initialize,
+ for example. when GP is hidden in current space (sergey) */
+ if (p->gpd) {
+ /* finish off a stroke */
gp_paint_strokeend(p);
+ }
/* "unlock" frame */
if (p->gpf)
@@ -1724,8 +1772,6 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
if (gp_session_initdata(C, p))
gp_paint_initstroke(p, p->paintmode);
- p= op->customdata;
-
if(p->status != GP_STATUS_ERROR)
p->status= GP_STATUS_PAINTING;