diff options
author | Antonioya <blendergit@gmail.com> | 2018-09-25 20:01:12 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-09-25 20:01:12 +0300 |
commit | 0f652a1ec072955de32868051e532fe0b5fb64a5 (patch) | |
tree | 1657877d5eeb02f948ed1cd4167c0c1b9ccd4721 | |
parent | fd1870b995fa4540c342526ca6525641bba5aab5 (diff) |
GP: New deselect by material option
Now the operator to select by color can unselect too.
-rw-r--r-- | release/scripts/startup/bl_ui/properties_material_gpencil.py | 3 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_data.c | 23 |
2 files changed, 21 insertions, 5 deletions
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); } |