[Bf-blender-cvs] [b043ea26cad] greasepencil-object: Use Shift key to fill on back
Antonio Vazquez
noreply at git.blender.org
Mon Jan 8 17:28:27 CET 2018
Commit: b043ea26cad4a8b91ca417324c6201ea90ae139e
Author: Antonio Vazquez
Date: Mon Jan 8 17:23:41 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rBb043ea26cad4a8b91ca417324c6201ea90ae139e
Use Shift key to fill on back
This key override the draw on back option of the panel for the current fill only.
===================================================================
M source/blender/editors/gpencil/gpencil_fill.c
M source/blender/editors/gpencil/gpencil_ops.c
M source/blender/editors/include/ED_gpencil.h
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 9573c58814c..9efa37b606c 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -55,6 +55,9 @@
#include "ED_space_api.h"
#include "ED_view3d.h"
+#include "RNA_access.h"
+#include "RNA_define.h"
+
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -715,7 +718,7 @@ static void gpencil_stroke_from_stack(tGPDfill *tgpf)
gps->flag |= GP_STROKE_RECALC_CACHES;
/* add stroke to frame */
- if (ts->gpencil_flags & GP_TOOL_FLAG_PAINT_ONBACK) {
+ if ((ts->gpencil_flags & GP_TOOL_FLAG_PAINT_ONBACK) || (tgpf->on_back == true)){
BLI_addhead(&tgpf->gpf->strokes, gps);
}
else {
@@ -784,7 +787,7 @@ static void gpencil_fill_status_indicators(tGPDfill *tgpf)
Scene *scene = tgpf->scene;
char status_str[UI_MAX_DRAW_STR];
- BLI_snprintf(status_str, sizeof(status_str), IFACE_("Fill: ESC/RMB cancel, LMB Fill"));
+ BLI_snprintf(status_str, sizeof(status_str), IFACE_("Fill: ESC/RMB cancel, LMB Fill, Shift Draw on Back"));
ED_area_headerprint(tgpf->sa, status_str);
}
@@ -1001,72 +1004,69 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event)
tGPDfill *tgpf = op->customdata;
int estate = OPERATOR_PASS_THROUGH; /* default exit state - pass through */
-
- /* we don't pass on key events, GP is used with key-modifiers - prevents Dkey to insert drivers */
- if (ISKEYBOARD(event->type)) {
- if (ELEM(event->type, ESCKEY)) {
+
+ switch (event->type) {
+ case ESCKEY:
+ case RIGHTMOUSE:
estate = OPERATOR_CANCELLED;
- }
- }
- if ELEM(event->type, RIGHTMOUSE) {
- estate = OPERATOR_CANCELLED;
- }
- if ELEM(event->type, LEFTMOUSE) {
- /* first time the event is not enabled to show help lines */
- if ((tgpf->oldkey != -1) || ((tgpf->flag & GP_BRUSH_FILL_SHOW_BOUNDARY) == 0)) {
- ARegion *ar = BKE_area_find_region_xy(CTX_wm_area(C), RGN_TYPE_ANY, event->x, event->y);
- if (ar) {
- rcti region_rect;
- bool in_bounds = false;
+ break;
+ case LEFTMOUSE:
+ tgpf->on_back = RNA_boolean_get(op->ptr, "on_back");
+ /* first time the event is not enabled to show help lines */
+ if ((tgpf->oldkey != -1) || ((tgpf->flag & GP_BRUSH_FILL_SHOW_BOUNDARY) == 0)) {
+ ARegion *ar = BKE_area_find_region_xy(CTX_wm_area(C), RGN_TYPE_ANY, event->x, event->y);
+ if (ar) {
+ rcti region_rect;
+ bool in_bounds = false;
- /* Perform bounds check */
- ED_region_visible_rect(ar, ®ion_rect);
- in_bounds = BLI_rcti_isect_pt_v(®ion_rect, event->mval);
+ /* Perform bounds check */
+ ED_region_visible_rect(ar, ®ion_rect);
+ in_bounds = BLI_rcti_isect_pt_v(®ion_rect, event->mval);
- if ((in_bounds) && (ar->regiontype == RGN_TYPE_WINDOW)) {
- tgpf->center[0] = event->mval[0];
- tgpf->center[1] = event->mval[1];
+ if ((in_bounds) && (ar->regiontype == RGN_TYPE_WINDOW)) {
+ tgpf->center[0] = event->mval[0];
+ tgpf->center[1] = event->mval[1];
- /* save size (don't sub minsize data to get right mouse click position) */
- tgpf->sizex = region_rect.xmax;
- tgpf->sizey = region_rect.ymax;
+ /* save size (don't sub minsize data to get right mouse click position) */
+ tgpf->sizex = region_rect.xmax;
+ tgpf->sizey = region_rect.ymax;
- /* render screen to temp image */
- gp_render_offscreen(tgpf);
+ /* render screen to temp image */
+ gp_render_offscreen(tgpf);
- /* apply boundary fill */
- gpencil_boundaryfill_area(tgpf);
+ /* apply boundary fill */
+ gpencil_boundaryfill_area(tgpf);
- /* clean borders to avoid infinite loops */
- gpencil_clean_borders(tgpf);
+ /* clean borders to avoid infinite loops */
+ gpencil_clean_borders(tgpf);
- /* analyze outline */
- gpencil_get_outline_points(tgpf);
+ /* analyze outline */
+ gpencil_get_outline_points(tgpf);
- /* create stroke and reproject */
- gpencil_stroke_from_stack(tgpf);
+ /* create stroke and reproject */
+ gpencil_stroke_from_stack(tgpf);
- /* free temp stack data */
- if (tgpf->stack) {
- BLI_stack_free(tgpf->stack);
- }
+ /* free temp stack data */
+ if (tgpf->stack) {
+ BLI_stack_free(tgpf->stack);
+ }
- /* push undo data */
- gpencil_undo_push(tgpf->gpd);
+ /* push undo data */
+ gpencil_undo_push(tgpf->gpd);
- estate = OPERATOR_FINISHED;
+ estate = OPERATOR_FINISHED;
+ }
+ else {
+ estate = OPERATOR_CANCELLED;
+ }
}
else {
estate = OPERATOR_CANCELLED;
}
}
- else {
- estate = OPERATOR_CANCELLED;
- }
- }
- tgpf->oldkey = event->type;
+ tgpf->oldkey = event->type;
+ break;
}
-
/* process last operations before exiting */
switch (estate) {
case OPERATOR_FINISHED:
@@ -1088,6 +1088,8 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event)
void GPENCIL_OT_fill(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
ot->name = "Grease Pencil Fill";
ot->idname = "GPENCIL_OT_fill";
@@ -1101,4 +1103,7 @@ void GPENCIL_OT_fill(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING;
+
+ prop = RNA_def_boolean(ot->srna, "on_back", false, "Draw On Back", "Send new stroke to Back");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index d306ec5e462..062d7655cc8 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -449,11 +449,16 @@ static void ed_keymap_gpencil_painting_draw(wmKeyConfig *keyconf)
static void ed_keymap_gpencil_painting_fill(wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_find(keyconf, "Grease Pencil Stroke Paint (Fill)", 0, 0);
+ wmKeyMapItem *kmi;
/* set poll callback */
keymap->poll = gp_stroke_paintmode_fill_poll;
- WM_keymap_add_item(keymap, "GPENCIL_OT_fill", LEFTMOUSE, KM_PRESS, 0, 0);
+ kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_fill", LEFTMOUSE, KM_PRESS, 0, 0);
+ RNA_boolean_set(kmi->ptr, "on_back", false);
+
+ kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_fill", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
+ RNA_boolean_set(kmi->ptr, "on_back", true);
}
/* Stroke Painting Keymap - Only when paintmode is enabled */
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index f89603bff41..b1305108620 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -173,6 +173,7 @@ typedef struct tGPDfill {
short flag; /* flags */
short oldkey; /* avoid too fast events */
+ bool on_back; /* send to back stroke */
int center[2]; /* mouse fill center position */
int sizex; /* windows width */
More information about the Bf-blender-cvs
mailing list