diff options
author | Antonioya <blendergit@gmail.com> | 2018-11-28 21:44:41 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-11-28 21:44:41 +0300 |
commit | 5c48b97e8c86c34e605e052dc1c30dd1a1ad4621 (patch) | |
tree | 840710ceedf016e017207a7ebdb0786901797c67 /source/blender/editors/gpencil/gpencil_select.c | |
parent | 303b49ea37b7e1be96f357436428806b950897c1 (diff) |
GP: Deselect points if click outside selection area
To make consistent with Left click select, now if click outside any point, all points are deselected.
Reduced the circle of selection to get more precission. The radius used before was too wide.
Note: There is a minimum distance to consider outside selection area.
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_select.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_select.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index b3606d26bee..bf90a13b584 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -1306,7 +1306,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) ToolSettings *ts = CTX_data_tool_settings(C); /* "radius" is simply a threshold (screen space) to make it easier to test with a tolerance */ - const float radius = 0.75f * U.widget_unit; + const float radius = 0.50f * U.widget_unit; const int radius_squared = (int)(radius * radius); bool extend = RNA_boolean_get(op->ptr, "extend"); @@ -1374,6 +1374,30 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) /* Abort if nothing hit... */ if (ELEM(NULL, hit_stroke, hit_point)) { + + /* since left mouse select change, deselect all if click outside any hit */ + CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) + { + /* deselect stroke and its points if selected */ + if (gps->flag & GP_STROKE_SELECT) { + bGPDspoint *pt; + int i; + + /* deselect points */ + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { + pt->flag &= ~GP_SPOINT_SELECT; + } + + /* deselect stroke itself too */ + gps->flag &= ~GP_STROKE_SELECT; + } + } + CTX_DATA_END; + /* copy on write tag is needed, or else no refresh happens */ + DEG_id_tag_update(&gpd->id, OB_RECALC_DATA); + DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE); + WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL); + return OPERATOR_CANCELLED; } |