Fix T69963: GPencil Hotkeys (1,2,3) do not work to switch Select Mode in Edit Mode
This commit is contained in:
parent
271c6794d6
commit
df5fae1fcc
Notes:
blender-bot
2023-02-14 06:00:51 +01:00
Referenced by issue #69963, GPencil: Hotkeys (1,2,3) do not work to switch Select Mode in Edit Mode
|
@ -237,11 +237,38 @@ static int gpencil_selectmode_toggle_exec(bContext *C, wmOperator *op)
|
|||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
const int mode = RNA_int_get(op->ptr, "mode");
|
||||
bool changed = false;
|
||||
|
||||
if (ts->gpencil_selectmode_edit == mode) {
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
/* Just set mode */
|
||||
ts->gpencil_selectmode_edit = mode;
|
||||
|
||||
/* If the mode is Stroke, extend selection. */
|
||||
if ((ob) && (ts->gpencil_selectmode_edit & GP_SELECTMODE_STROKE)) {
|
||||
bGPdata *gpd = (bGPdata *)ob->data;
|
||||
/* Extend selection to all points in all selected strokes. */
|
||||
CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) {
|
||||
if ((gps->flag & GP_STROKE_SELECT) && (gps->totpoints > 1)) {
|
||||
changed = true;
|
||||
bGPDspoint *pt;
|
||||
for (int i = 0; i < gps->totpoints; i++) {
|
||||
pt = &gps->points[i];
|
||||
pt->flag |= GP_SPOINT_SELECT;
|
||||
}
|
||||
}
|
||||
}
|
||||
CTX_DATA_END;
|
||||
if (changed) {
|
||||
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
|
||||
}
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
|
||||
WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL);
|
||||
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
|
||||
|
||||
|
|
Loading…
Reference in New Issue