Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_edit.c
| Show First 20 Lines • Show All 214 Lines • ▼ Show 20 Lines | void GPENCIL_OT_editmode_toggle(wmOperatorType *ot) | ||||
| /* properties */ | /* properties */ | ||||
| prop = RNA_def_boolean( | prop = RNA_def_boolean( | ||||
| ot->srna, "back", 0, "Return to Previous Mode", "Return to previous mode"); | ot->srna, "back", 0, "Return to Previous Mode", "Return to previous mode"); | ||||
| RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | ||||
| } | } | ||||
| /* set select mode */ | /* set select mode */ | ||||
| static bool gpencil_selectmode_toggle_poll(bContext *C) | |||||
| { | |||||
| /* edit only supported with grease pencil objects */ | |||||
| Object *ob = CTX_data_active_object(C); | |||||
| if ((ob == NULL) || (ob->type != OB_GPENCIL) || (ob->mode != OB_MODE_EDIT_GPENCIL)) { | |||||
| return false; | |||||
| } | |||||
| return ED_operator_view3d_active(C); | |||||
| } | |||||
| static int gpencil_selectmode_toggle_exec(bContext *C, wmOperator *op) | static int gpencil_selectmode_toggle_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ToolSettings *ts = CTX_data_tool_settings(C); | ToolSettings *ts = CTX_data_tool_settings(C); | ||||
| Object *ob = CTX_data_active_object(C); | |||||
| const int mode = RNA_int_get(op->ptr, "mode"); | const int mode = RNA_int_get(op->ptr, "mode"); | ||||
| /* Just set mode */ | /* Just set mode */ | ||||
| ts->gpencil_selectmode = mode; | ts->gpencil_selectmode_edit = mode; | ||||
| WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL); | WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL); | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE); | DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void GPENCIL_OT_selectmode_toggle(wmOperatorType *ot) | void GPENCIL_OT_selectmode_toggle(wmOperatorType *ot) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Select Mode Toggle"; | ot->name = "Select Mode Toggle"; | ||||
| ot->idname = "GPENCIL_OT_selectmode_toggle"; | ot->idname = "GPENCIL_OT_selectmode_toggle"; | ||||
| ot->description = "Set selection mode for Grease Pencil strokes"; | ot->description = "Set selection mode for Grease Pencil strokes"; | ||||
| /* callbacks */ | /* callbacks */ | ||||
| ot->exec = gpencil_selectmode_toggle_exec; | ot->exec = gpencil_selectmode_toggle_exec; | ||||
| ot->poll = gp_strokes_edit3d_poll; | ot->poll = gpencil_selectmode_toggle_poll; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER; | ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER; | ||||
| /* properties */ | /* properties */ | ||||
| prop = RNA_def_int(ot->srna, "mode", 0, 0, 2, "Select mode", "Select mode", 0, 2); | prop = RNA_def_int(ot->srna, "mode", 0, 0, 2, "Select mode", "Select mode", 0, 2); | ||||
| RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 4,387 Lines • Show Last 20 Lines | |||||