Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_edit.c
| Show First 20 Lines • Show All 1,644 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| bGPdata *gpd = ED_gpencil_data_get_active(C); | bGPdata *gpd = ED_gpencil_data_get_active(C); | ||||
| bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); | bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); | ||||
| /* only if there's an active layer with an active frame */ | /* only if there's an active layer with an active frame */ | ||||
| return (gpl && gpl->actframe); | return (gpl && gpl->actframe); | ||||
| } | } | ||||
| static bool gp_annotation_actframe_delete_poll(bContext *C) | |||||
| { | |||||
| bGPdata *gpd = ED_annotation_data_get_active(C); | |||||
| bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); | |||||
| /* only if there's an active layer with an active frame */ | |||||
| return (gpl && gpl->actframe); | |||||
| } | |||||
| /* delete active frame - wrapper around API calls */ | /* delete active frame - wrapper around API calls */ | ||||
| static int gp_actframe_delete_exec(bContext *C, wmOperator *op) | static int gp_actframe_delete_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| bGPdata *gpd = ED_gpencil_data_get_active(C); | const int is_annotation = RNA_boolean_get(op->ptr, "is_annotation"); | ||||
| bGPdata *gpd = (!is_annotation) ? ED_gpencil_data_get_active(C) : | |||||
| ED_annotation_data_get_active(C); | |||||
| bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); | bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_USE_PREV); | bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_USE_PREV); | ||||
| /* if there's no existing Grease-Pencil data there, add some */ | /* if there's no existing Grease-Pencil data there, add some */ | ||||
| if (gpd == NULL) { | if (gpd == NULL) { | ||||
| Show All 12 Lines | static int gp_actframe_delete_exec(bContext *C, wmOperator *op) | ||||
| DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); | DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); | ||||
| WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void GPENCIL_OT_active_frame_delete(wmOperatorType *ot) | void GPENCIL_OT_active_frame_delete(wmOperatorType *ot) | ||||
| { | { | ||||
| PropertyRNA *prop; | |||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Delete Active Frame"; | ot->name = "Delete Active Frame"; | ||||
| ot->idname = "GPENCIL_OT_active_frame_delete"; | ot->idname = "GPENCIL_OT_active_frame_delete"; | ||||
| ot->description = "Delete the active frame for the active Grease Pencil Layer"; | ot->description = "Delete the active frame for the active Grease Pencil Layer"; | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| /* callbacks */ | /* callbacks */ | ||||
| ot->exec = gp_actframe_delete_exec; | ot->exec = gp_actframe_delete_exec; | ||||
| ot->poll = gp_actframe_delete_poll; | ot->poll = gp_actframe_delete_poll; | ||||
| prop = RNA_def_boolean(ot->srna, "is_annotation", false, "Annotation", ""); | |||||
| RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | |||||
| } | } | ||||
| void GPENCIL_OT_annotation_active_frame_delete(wmOperatorType *ot) | |||||
| { | |||||
| PropertyRNA *prop; | |||||
| /* identifiers */ | |||||
| ot->name = "Delete Active Frame"; | |||||
| ot->idname = "GPENCIL_OT_annotation_active_frame_delete"; | |||||
| ot->description = "Delete the active frame for the active Annotation Layer"; | |||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | |||||
| /* callbacks */ | |||||
| ot->exec = gp_actframe_delete_exec; | |||||
| ot->poll = gp_annotation_actframe_delete_poll; | |||||
| prop = RNA_def_boolean(ot->srna, "is_annotation", true, "Annotation", ""); | |||||
| RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); | |||||
| } | |||||
| /* **************** Delete All Active Frames ****************** */ | /* **************** Delete All Active Frames ****************** */ | ||||
| static bool gp_actframe_delete_all_poll(bContext *C) | static bool gp_actframe_delete_all_poll(bContext *C) | ||||
| { | { | ||||
| bGPdata *gpd = ED_gpencil_data_get_active(C); | bGPdata *gpd = ED_gpencil_data_get_active(C); | ||||
| /* 1) There must be grease pencil data | /* 1) There must be grease pencil data | ||||
| * 2) Hopefully some of the layers have stuff we can use | * 2) Hopefully some of the layers have stuff we can use | ||||
| ▲ Show 20 Lines • Show All 3,000 Lines • Show Last 20 Lines | |||||