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:
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_data.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c132
1 files changed, 88 insertions, 44 deletions
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 7cab9def553..f44c90001e1 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -298,8 +298,9 @@ static int gp_layer_remove_exec(bContext *C, wmOperator *op)
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
/* sanity checks */
- if (ELEM(NULL, gpd, gpl))
+ if (ELEM(NULL, gpd, gpl)) {
return OPERATOR_CANCELLED;
+ }
if (gpl->flag & GP_LAYER_LOCKED) {
BKE_report(op->reports, RPT_ERROR, "Cannot delete locked layers");
@@ -310,10 +311,12 @@ static int gp_layer_remove_exec(bContext *C, wmOperator *op)
* - use the one after if this is the first
* - if this is the only layer, this naturally becomes NULL
*/
- if (gpl->prev)
+ if (gpl->prev) {
BKE_gpencil_layer_setactive(gpd, gpl->prev);
- else
+ }
+ else {
BKE_gpencil_layer_setactive(gpd, gpl->next);
+ }
/* delete the layer now... */
BKE_gpencil_layer_delete(gpd, gpl);
@@ -354,8 +357,9 @@ static int gp_layer_move_exec(bContext *C, wmOperator *op)
const int direction = RNA_enum_get(op->ptr, "type") * -1;
/* sanity checks */
- if (ELEM(NULL, gpd, gpl))
+ if (ELEM(NULL, gpd, gpl)) {
return OPERATOR_CANCELLED;
+ }
BLI_assert(ELEM(direction, -1, 0, 1)); /* we use value below */
if (BLI_listbase_link_move(&gpd->layers, gpl, direction)) {
@@ -398,8 +402,9 @@ static int gp_layer_copy_exec(bContext *C, wmOperator *UNUSED(op))
bGPDlayer *new_layer;
/* sanity checks */
- if (ELEM(NULL, gpd, gpl))
+ if (ELEM(NULL, gpd, gpl)) {
return OPERATOR_CANCELLED;
+ }
/* make copy of layer, and add it immediately after the existing layer */
new_layer = BKE_gpencil_layer_duplicate(gpl);
@@ -446,19 +451,22 @@ static bool gp_layer_duplicate_object_poll(bContext *C)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = CTX_data_active_object(C);
- if ((ob == NULL) || (ob->type != OB_GPENCIL))
+ if ((ob == NULL) || (ob->type != OB_GPENCIL)) {
return false;
+ }
bGPdata *gpd = (bGPdata *)ob->data;
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
- if (gpl == NULL)
+ if (gpl == NULL) {
return false;
+ }
/* check there are more grease pencil objects */
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
- if ((base->object != ob) && (base->object->type == OB_GPENCIL))
+ if ((base->object != ob) && (base->object->type == OB_GPENCIL)) {
return true;
+ }
}
return false;
@@ -591,8 +599,9 @@ static int gp_frame_duplicate_exec(bContext *C, wmOperator *op)
int mode = RNA_enum_get(op->ptr, "mode");
/* sanity checks */
- if (ELEM(NULL, gpd, gpl))
+ if (ELEM(NULL, gpd, gpl)) {
return OPERATOR_CANCELLED;
+ }
if (mode == 0) {
BKE_gpencil_frame_addcopy(gpl, cfra_eval);
@@ -656,16 +665,18 @@ static int gp_frame_clean_fill_exec(bContext *C, wmOperator *op)
if ((gpf == gpl->actframe) || (mode == GP_FRAME_CLEAN_FILL_ALL)) {
bGPDstroke *gps, *gpsn;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* simply delete strokes which are no fill */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* free stroke */
if (gps->flag & GP_STROKE_NOFILL) {
@@ -738,16 +749,18 @@ static int gp_frame_clean_loose_exec(bContext *C, wmOperator *op)
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* simply delete strokes which are no loose */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* free stroke */
if (gps->totpoints <= limit) {
@@ -818,8 +831,9 @@ static int gp_hide_exec(bContext *C, wmOperator *op)
bool unselected = RNA_boolean_get(op->ptr, "unselected");
/* sanity checks */
- if (ELEM(NULL, gpd, layer))
+ if (ELEM(NULL, gpd, layer)) {
return OPERATOR_CANCELLED;
+ }
if (unselected) {
bGPDlayer *gpl;
@@ -898,8 +912,9 @@ static int gp_reveal_exec(bContext *C, wmOperator *op)
const bool select = RNA_boolean_get(op->ptr, "select");
/* sanity checks */
- if (gpd == NULL)
+ if (gpd == NULL) {
return OPERATOR_CANCELLED;
+ }
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -958,8 +973,9 @@ static int gp_lock_all_exec(bContext *C, wmOperator *UNUSED(op))
bGPDlayer *gpl;
/* sanity checks */
- if (gpd == NULL)
+ if (gpd == NULL) {
return OPERATOR_CANCELLED;
+ }
/* make all layers non-editable */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -997,8 +1013,9 @@ static int gp_unlock_all_exec(bContext *C, wmOperator *UNUSED(op))
bGPDlayer *gpl;
/* sanity checks */
- if (gpd == NULL)
+ if (gpd == NULL) {
return OPERATOR_CANCELLED;
+ }
/* make all layers editable again */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -1037,8 +1054,9 @@ static int gp_isolate_layer_exec(bContext *C, wmOperator *op)
int flags = GP_LAYER_LOCKED;
bool isolate = false;
- if (RNA_boolean_get(op->ptr, "affect_visibility"))
+ if (RNA_boolean_get(op->ptr, "affect_visibility")) {
flags |= GP_LAYER_HIDE;
+ }
if (ELEM(NULL, gpd, layer)) {
BKE_report(op->reports, RPT_ERROR, "No active layer to isolate");
@@ -1048,8 +1066,9 @@ static int gp_isolate_layer_exec(bContext *C, wmOperator *op)
/* Test whether to isolate or clear all flags */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* Skip if this is the active layer */
- if (gpl == layer)
+ if (gpl == layer) {
continue;
+ }
/* If the flags aren't set, that means that the layer is
* not alone, so we have some layers to isolate still
@@ -1065,10 +1084,12 @@ static int gp_isolate_layer_exec(bContext *C, wmOperator *op)
if (isolate) {
/* Set flags on all "other" layers */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- if (gpl == layer)
+ if (gpl == layer) {
continue;
- else
+ }
+ else {
gpl->flag |= flags;
+ }
}
}
else {
@@ -1425,18 +1446,21 @@ static int gp_stroke_change_color_exec(bContext *C, wmOperator *op)
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* only if selected */
if (gps->flag & GP_STROKE_SELECT) {
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* check if the color is editable */
- if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false)
+ if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false) {
continue;
+ }
/* assign new color */
gps->mat_nr = idx;
@@ -1486,8 +1510,9 @@ static int gp_stroke_lock_color_exec(bContext *C, wmOperator *UNUSED(op))
short *totcol = give_totcolp(ob);
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* first lock all colors */
for (short i = 0; i < *totcol; i++) {
@@ -1610,8 +1635,9 @@ static int gpencil_vertex_group_assign_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = CTX_data_active_object(C);
/* sanity checks */
- if (ELEM(NULL, ts, ob, ob->data))
+ if (ELEM(NULL, ts, ob, ob->data)) {
return OPERATOR_CANCELLED;
+ }
ED_gpencil_vgroup_assign(C, ob, ts->vgroup_weight);
@@ -1644,8 +1670,9 @@ static int gpencil_vertex_group_remove_from_exec(bContext *C, wmOperator *UNUSED
Object *ob = CTX_data_active_object(C);
/* sanity checks */
- if (ELEM(NULL, ob, ob->data))
+ if (ELEM(NULL, ob, ob->data)) {
return OPERATOR_CANCELLED;
+ }
ED_gpencil_vgroup_remove(C, ob);
@@ -1677,8 +1704,9 @@ static int gpencil_vertex_group_select_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = CTX_data_active_object(C);
/* sanity checks */
- if (ELEM(NULL, ob, ob->data))
+ if (ELEM(NULL, ob, ob->data)) {
return OPERATOR_CANCELLED;
+ }
ED_gpencil_vgroup_select(C, ob);
@@ -1710,8 +1738,9 @@ static int gpencil_vertex_group_deselect_exec(bContext *C, wmOperator *UNUSED(op
Object *ob = CTX_data_active_object(C);
/* sanity checks */
- if (ELEM(NULL, ob, ob->data))
+ if (ELEM(NULL, ob, ob->data)) {
return OPERATOR_CANCELLED;
+ }
ED_gpencil_vgroup_deselect(C, ob);
@@ -2172,8 +2201,9 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
bool ok = false;
/* Ensure we're in right mode and that the active object is correct */
- if (!ob_active || ob_active->type != OB_GPENCIL)
+ if (!ob_active || ob_active->type != OB_GPENCIL) {
return OPERATOR_CANCELLED;
+ }
bGPdata *gpd = (bGPdata *)ob_active->data;
if ((!gpd) || GPENCIL_ANY_MODE(gpd)) {
@@ -2386,14 +2416,16 @@ static int gpencil_lock_layer_exec(bContext *C, wmOperator *UNUSED(op))
MaterialGPencilStyle *gp_style = NULL;
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* first lock and hide all colors */
Material *ma = NULL;
short *totcol = give_totcolp(ob);
- if (totcol == 0)
+ if (totcol == 0) {
return OPERATOR_CANCELLED;
+ }
for (short i = 0; i < *totcol; i++) {
ma = give_current_material(ob, i + 1);
@@ -2410,8 +2442,9 @@ static int gpencil_lock_layer_exec(bContext *C, wmOperator *UNUSED(op))
(gpl->flag & GP_LAYER_ACTIVE)) {
for (bGPDstroke *gps = gpl->actframe->strokes.last; gps; gps = gps->prev) {
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
ma = give_current_material(ob, gps->mat_nr + 1);
DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
@@ -2463,8 +2496,9 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op)
int flags = GP_STYLE_COLOR_LOCKED;
bool isolate = false;
- if (RNA_boolean_get(op->ptr, "affect_visibility"))
+ if (RNA_boolean_get(op->ptr, "affect_visibility")) {
flags |= GP_STYLE_COLOR_HIDE;
+ }
if (ELEM(NULL, gpd, active_color)) {
BKE_report(op->reports, RPT_ERROR, "No active color to isolate");
@@ -2477,8 +2511,9 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op)
for (short i = 0; i < *totcol; i++) {
ma = give_current_material(ob, i + 1);
/* Skip if this is the active one */
- if (ma == active_ma)
+ if (ma == active_ma) {
continue;
+ }
/* If the flags aren't set, that means that the color is
* not alone, so we have some colors to isolate still
@@ -2496,10 +2531,12 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op)
for (short i = 0; i < *totcol; i++) {
ma = give_current_material(ob, i + 1);
gp_style = ma->gp_style;
- if (gp_style == active_color)
+ if (gp_style == active_color) {
continue;
- else
+ }
+ else {
gp_style->flag |= flags;
+ }
DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
}
}
@@ -2560,8 +2597,9 @@ static int gpencil_color_hide_exec(bContext *C, wmOperator *op)
Material *ma = NULL;
short *totcol = give_totcolp(ob);
- if (totcol == 0)
+ if (totcol == 0) {
return OPERATOR_CANCELLED;
+ }
if (unselected) {
/* hide unselected */
@@ -2620,8 +2658,9 @@ static int gpencil_color_reveal_exec(bContext *C, wmOperator *UNUSED(op))
Material *ma = NULL;
short *totcol = give_totcolp(ob);
- if (totcol == 0)
+ if (totcol == 0) {
return OPERATOR_CANCELLED;
+ }
/* make all colors visible */
MaterialGPencilStyle *gp_style = NULL;
@@ -2670,8 +2709,9 @@ static int gpencil_color_lock_all_exec(bContext *C, wmOperator *UNUSED(op))
Material *ma = NULL;
short *totcol = give_totcolp(ob);
- if (totcol == 0)
+ if (totcol == 0) {
return OPERATOR_CANCELLED;
+ }
/* make all layers non-editable */
MaterialGPencilStyle *gp_style = NULL;
@@ -2720,8 +2760,9 @@ static int gpencil_color_unlock_all_exec(bContext *C, wmOperator *UNUSED(op))
Material *ma = NULL;
short *totcol = give_totcolp(ob);
- if (totcol == 0)
+ if (totcol == 0) {
return OPERATOR_CANCELLED;
+ }
/* make all layers editable again*/
MaterialGPencilStyle *gp_style = NULL;
@@ -2771,8 +2812,9 @@ static int gpencil_color_select_exec(bContext *C, wmOperator *op)
const bool deselected = RNA_boolean_get(op->ptr, "deselect");
/* sanity checks */
- if (ELEM(NULL, gpd, gp_style))
+ if (ELEM(NULL, gpd, gp_style)) {
return OPERATOR_CANCELLED;
+ }
/* read all strokes and select*/
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
@@ -2786,11 +2828,13 @@ static int gpencil_color_select_exec(bContext *C, wmOperator *op)
/* verify something to do */
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* check if the color is editable */
- if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false)
+ if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false) {
continue;
+ }
/* select */
if (ob->actcol == gps->mat_nr + 1) {