[Bf-blender-cvs] [0f652a1ec07] blender2.8: GP: New deselect by material option

Antonioya noreply at git.blender.org
Tue Sep 25 19:01:22 CEST 2018


Commit: 0f652a1ec072955de32868051e532fe0b5fb64a5
Author: Antonioya
Date:   Tue Sep 25 19:01:12 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB0f652a1ec072955de32868051e532fe0b5fb64a5

GP: New deselect by material option

Now the operator to select by color can unselect too.

===================================================================

M	release/scripts/startup/bl_ui/properties_material_gpencil.py
M	source/blender/editors/gpencil/gpencil_data.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py b/release/scripts/startup/bl_ui/properties_material_gpencil.py
index 1294d0f8d85..7dc1141b8e3 100644
--- a/release/scripts/startup/bl_ui/properties_material_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py
@@ -147,7 +147,8 @@ class MATERIAL_PT_gpencil_slots(Panel):
             if gpd.use_stroke_edit_mode:
                 row = layout.row(align=True)
                 row.operator("gpencil.stroke_change_color", text="Assign")
-                row.operator("gpencil.color_select", text="Select")
+                row.operator("gpencil.color_select", text="Select").deselect=False
+                row.operator("gpencil.color_select", text="Deselect").deselect=True
 
         elif mat:
             row.template_ID(space, "pin_id")
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 439053957c5..828eff7f630 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -2581,12 +2581,13 @@ void GPENCIL_OT_color_unlock_all(wmOperatorType *ot)
 
 /* ***************** Select all strokes using color ************************ */
 
-static int gpencil_color_select_exec(bContext *C, wmOperator *UNUSED(op))
+static int gpencil_color_select_exec(bContext *C, wmOperator *op)
 {
 	bGPdata *gpd = ED_gpencil_data_get_active(C);
 	Object *ob = CTX_data_active_object(C);
 	MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, ob->actcol);
-	bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+	const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+	const bool deselected = RNA_boolean_get(op->ptr, "deselect");
 
 	/* sanity checks */
 	if (ELEM(NULL, gpd, gp_style))
@@ -2616,9 +2617,19 @@ static int gpencil_color_select_exec(bContext *C, wmOperator *UNUSED(op))
 						bGPDspoint *pt;
 						int i;
 
-						gps->flag |= GP_STROKE_SELECT;
+						if (!deselected) {
+							gps->flag |= GP_STROKE_SELECT;
+						}
+						else {
+							gps->flag &= ~GP_STROKE_SELECT;
+						}
 						for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
-							pt->flag |= GP_SPOINT_SELECT;
+							if (!deselected) {
+								pt->flag |= GP_SPOINT_SELECT;
+							}
+							else {
+								pt->flag &= ~GP_SPOINT_SELECT;
+							}
 						}
 					}
 				}
@@ -2654,4 +2665,8 @@ void GPENCIL_OT_color_select(wmOperatorType *ot)
 
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+	/* props */
+	ot->prop = RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Unselect strokes");
+	RNA_def_property_flag(ot->prop, PROP_HIDDEN | PROP_SKIP_SAVE);
 }



More information about the Bf-blender-cvs mailing list