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:
-rw-r--r--source/blender/blenkernel/intern/gpencil.c5
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_buttons.c20
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c28
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c6
5 files changed, 38 insertions, 23 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index dd8f44c71d5..b02128c3c68 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -214,6 +214,11 @@ bGPdata *gpencil_data_addnew (char name[])
/* initial settings */
gpd->flag = (GP_DATA_DISPINFO|GP_DATA_EXPAND);
+ /* for now, stick to view is also enabled by default
+ * since this is more useful...
+ */
+ gpd->flag |= GP_DATA_VIEWALIGN;
+
return gpd;
}
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index a89a038d760..d6678b50d7b 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -773,7 +773,7 @@ void draw_gpencil_oglrender (bContext *C)
/* pass 2: draw 2d-strokes ------------ > */
/* adjust view matrices */
- wmOrtho2(-0.375f, (float)(ar->winx)-0.375f, -0.375f, (float)(ar->winy)-0.375f);
+ wmOrtho2(-0.375f, (float)(ar->winx)-0.375f, -0.375f, (float)(ar->winy)-0.375f); // XXX may not be correct anymore
glLoadIdentity();
/* draw it! */
diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c
index f29d37311fb..774f7b7162b 100644
--- a/source/blender/editors/gpencil/gpencil_buttons.c
+++ b/source/blender/editors/gpencil/gpencil_buttons.c
@@ -226,9 +226,13 @@ static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl)
/* Draw the contents for a grease-pencil panel*/
static void draw_gpencil_panel (bContext *C, uiLayout *layout, bGPdata *gpd, PointerRNA *ctx_ptr)
{
+ PointerRNA gpd_ptr;
bGPDlayer *gpl;
uiLayout *col;
+ /* make new PointerRNA for Grease Pencil block */
+ RNA_id_pointer_create((ID *)gpd, &gpd_ptr);
+
/* draw gpd settings first ------------------------------------- */
col= uiLayoutColumn(layout, 0);
/* current Grease Pencil block */
@@ -238,19 +242,19 @@ static void draw_gpencil_panel (bContext *C, uiLayout *layout, bGPdata *gpd, Poi
/* add new layer button */
uiItemO(col, NULL, 0, "GPENCIL_OT_layer_add");
- /* 'view align' button (naming depends on context) */
-#if 0 // XXX for now, this is enabled by default anyways
- if (sa->spacetype == SPACE_VIEW3D)
- uiDefButBitI(block, TOG, GP_DATA_VIEWALIGN, B_REDR, "Sketch in 3D", 170, 205, 150, 20, &gpd->flag, 0, 0, 0, 0, "New strokes are added in 3D-space");
- else
- uiDefButBitI(block, TOG, GP_DATA_VIEWALIGN, B_REDR, "Stick to View", 170, 205, 150, 20, &gpd->flag, 0, 0, 0, 0, "New strokes are added on 2d-canvas");
-#endif
-
/* draw each layer --------------------------------------------- */
for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
col= uiLayoutColumn(layout, 1);
gp_drawui_layer(col, gpd, gpl);
}
+
+ /* draw gpd drawing settings first ------------------------------------- */
+ col= uiLayoutColumn(layout, 0);
+ /* label */
+ uiItemL(col, "Drawing Settings:", 0);
+
+ /* 'stick to view' option */
+ uiItemR(col, NULL, 0, &gpd_ptr, "view_space_draw", 0);
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index c18a807f9d4..b5d25ce651f 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -239,8 +239,8 @@ static void gp_stroke_convertcoords (tGPsdata *p, short mval[], float out[])
/* 2d - relative to screen (viewport area) */
else {
- out[0] = (float)(mval[0]) / (float)(p->sa->winx) * 100;
- out[1] = (float)(mval[1]) / (float)(p->sa->winy) * 100;
+ out[0] = (float)(mval[0]) / (float)(p->ar->winx) * 100;
+ out[1] = (float)(mval[1]) / (float)(p->ar->winy) * 100;
}
}
@@ -310,8 +310,8 @@ static short gp_stroke_addpoint (tGPsdata *p, int mval[2], float pressure)
return GP_STROKEADD_NORMAL;
}
- /* just say it's normal for now, since we don't have another state... */
- return GP_STROKEADD_NORMAL;
+ /* return invalid state for now... */
+ return GP_STROKEADD_INVALID;
}
/* smooth a stroke (in buffer) before storing it */
@@ -614,8 +614,8 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho
}
#endif
else {
- x0= (int)(gps->points->x / 100 * p->sa->winx);
- y0= (int)(gps->points->y / 100 * p->sa->winy);
+ x0= (int)(gps->points->x / 100 * p->ar->winx);
+ y0= (int)(gps->points->y / 100 * p->ar->winy);
}
/* do boundbox check first */
@@ -671,10 +671,10 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho
}
#endif
else {
- x0= (int)(pt1->x / 100 * p->sa->winx);
- y0= (int)(pt1->y / 100 * p->sa->winy);
- x1= (int)(pt2->x / 100 * p->sa->winx);
- y1= (int)(pt2->y / 100 * p->sa->winy);
+ x0= (int)(pt1->x / 100 * p->ar->winx);
+ y0= (int)(pt1->y / 100 * p->ar->winy);
+ x1= (int)(pt2->x / 100 * p->ar->winx);
+ y1= (int)(pt2->y / 100 * p->ar->winy);
}
/* check that point segment of the boundbox of the eraser stroke */
@@ -944,15 +944,15 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode)
p->gpd->sbuffer_sflag |= GP_STROKE_ERASER;
/* check if points will need to be made in view-aligned space */
- // XXX this should be the default? this is something that needs review
- /*if (p->gpd->flag & GP_DATA_VIEWALIGN)*/ {
+ if (p->gpd->flag & GP_DATA_VIEWALIGN) {
switch (p->sa->spacetype) {
case SPACE_VIEW3D:
{
View3D *v3d= (View3D *)p->sa->spacedata.first;
RegionView3D *rv3d= p->ar->regiondata;
- // TODO: this should only happen for scene... otherwise apply correction for object center!
+ // TODO 1: when using objects, make the data stick to the object centers?
+ // TODO 2: what happens when cursor is behind view-camera plane?
float *fp= give_cursor(p->scene, v3d);
initgrabz(rv3d, fp[0], fp[1], fp[2]);
@@ -1139,7 +1139,7 @@ static void gpencil_draw_apply (bContext *C, wmOperator *op, tGPsdata *p)
if (G.f & G_DEBUG)
printf("Error: Grease-Pencil Paint - Add Point Invalid \n");
- // XXX break!
+ return;
}
/* store used values */
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index e025aca010c..df0e5ae6703 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -208,6 +208,7 @@ void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_SELECT);
RNA_def_property_ui_text(prop, "Selected", "Layer is selected for editing in the DopeSheet.");
+ // XXX keep this option?
prop= RNA_def_property(srna, "show_points", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_DRAWDEBUG);
RNA_def_property_ui_text(prop, "Show Points", "Draw the points which make up the strokes (for debugging purposes).");
@@ -229,6 +230,11 @@ void rna_def_gpencil_data(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "layers", NULL);
RNA_def_property_struct_type(prop, "GPencilLayer");
RNA_def_property_ui_text(prop, "Layers", "Similar to layers in Photoshop.");
+
+ /* Flags */
+ prop= RNA_def_property(srna, "view_space_draw", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_VIEWALIGN);
+ RNA_def_property_ui_text(prop, "Stick to View", "Newly drawn strokes get added in view space (i.e. sketches stick to data when view is manipulated).");
}
/* --- */