GPencil: Added a new version of the "delete active frame" operator which deletes on all editable layers
This new operator will delete any GP frame it finds on the current frame, regardless of whether it's on the active layer or not. It will only remove the frames if the layer is editable, but otherwise, it will just go for it. The existing operator is great for use in the panel (where it only applies to the active frame), but it was not so good for all the other places where tools can be invoked (e.g. D-X, or Delete) as you're typically thinking about the whole scene more holisticaly than just caring about a particular layer.
This commit is contained in:
@@ -2637,7 +2637,7 @@ class VIEW3D_MT_edit_gpencil_delete(Menu):
|
|||||||
|
|
||||||
layout.separator()
|
layout.separator()
|
||||||
|
|
||||||
layout.operator("gpencil.active_frame_delete")
|
layout.operator("gpencil.active_frames_delete_all")
|
||||||
|
|
||||||
|
|
||||||
# Edit Curve
|
# Edit Curve
|
||||||
|
|||||||
@@ -652,7 +652,7 @@ void GPENCIL_OT_active_frame_delete(wmOperatorType *ot)
|
|||||||
/* 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 datablock";
|
ot->description = "Delete the active frame for the active Grease Pencil Layer";
|
||||||
|
|
||||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||||
|
|
||||||
@@ -661,6 +661,64 @@ void GPENCIL_OT_active_frame_delete(wmOperatorType *ot)
|
|||||||
ot->poll = gp_actframe_delete_poll;
|
ot->poll = gp_actframe_delete_poll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* **************** Delete All Active Frames ****************** */
|
||||||
|
|
||||||
|
static int gp_actframe_delete_all_poll(bContext *C)
|
||||||
|
{
|
||||||
|
bGPdata *gpd = ED_gpencil_data_get_active(C);
|
||||||
|
|
||||||
|
/* 1) There must be grease pencil data
|
||||||
|
* 2) Hopefully some of the layers have stuff we can use
|
||||||
|
*/
|
||||||
|
return (gpd && gpd->layers.first);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int gp_actframe_delete_all_exec(bContext *C, wmOperator *op)
|
||||||
|
{
|
||||||
|
Scene *scene = CTX_data_scene(C);
|
||||||
|
bool success = false;
|
||||||
|
|
||||||
|
CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
|
||||||
|
{
|
||||||
|
/* try to get the "active" frame - but only if it actually occurs on this frame */
|
||||||
|
bGPDframe *gpf = gpencil_layer_getframe(gpl, CFRA, 0);
|
||||||
|
|
||||||
|
if (gpf == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* delete it... */
|
||||||
|
gpencil_layer_delframe(gpl, gpf);
|
||||||
|
|
||||||
|
/* we successfully modified something */
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
CTX_DATA_END;
|
||||||
|
|
||||||
|
/* updates */
|
||||||
|
if (success) {
|
||||||
|
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
|
||||||
|
return OPERATOR_FINISHED;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BKE_report(op->reports, RPT_ERROR, "No active frame(s) to delete");
|
||||||
|
return OPERATOR_CANCELLED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPENCIL_OT_active_frames_delete_all(wmOperatorType *ot)
|
||||||
|
{
|
||||||
|
/* identifiers */
|
||||||
|
ot->name = "Delete All Active Frames";
|
||||||
|
ot->idname = "GPENCIL_OT_active_frames_delete_all";
|
||||||
|
ot->description = "Delete the active frame(s) of all editable Grease Pencil layers";
|
||||||
|
|
||||||
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||||
|
|
||||||
|
/* callbacks */
|
||||||
|
ot->exec = gp_actframe_delete_all_exec;
|
||||||
|
ot->poll = gp_actframe_delete_all_poll;
|
||||||
|
}
|
||||||
|
|
||||||
/* ******************* Delete Operator ************************ */
|
/* ******************* Delete Operator ************************ */
|
||||||
|
|
||||||
typedef enum eGP_DeleteMode {
|
typedef enum eGP_DeleteMode {
|
||||||
|
|||||||
@@ -218,6 +218,7 @@ void GPENCIL_OT_unlock_all(struct wmOperatorType *ot);
|
|||||||
void GPENCIL_OT_layer_isolate(struct wmOperatorType *ot);
|
void GPENCIL_OT_layer_isolate(struct wmOperatorType *ot);
|
||||||
|
|
||||||
void GPENCIL_OT_active_frame_delete(struct wmOperatorType *ot);
|
void GPENCIL_OT_active_frame_delete(struct wmOperatorType *ot);
|
||||||
|
void GPENCIL_OT_active_frames_delete_all(struct wmOperatorType *ot);
|
||||||
|
|
||||||
void GPENCIL_OT_convert(struct wmOperatorType *ot);
|
void GPENCIL_OT_convert(struct wmOperatorType *ot);
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ static void ed_keymap_gpencil_general(wmKeyConfig *keyconf)
|
|||||||
|
|
||||||
/* Delete Active Frame - For easier video tutorials/review sessions */
|
/* Delete Active Frame - For easier video tutorials/review sessions */
|
||||||
/* NOTE: This works even when not in EditMode */
|
/* NOTE: This works even when not in EditMode */
|
||||||
WM_keymap_add_item(keymap, "GPENCIL_OT_active_frame_delete", XKEY, KM_PRESS, 0, DKEY);
|
WM_keymap_add_item(keymap, "GPENCIL_OT_active_frames_delete_all", XKEY, KM_PRESS, 0, DKEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ==================== */
|
/* ==================== */
|
||||||
@@ -238,7 +238,7 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf)
|
|||||||
WM_keymap_add_item(keymap, "GPENCIL_OT_dissolve", XKEY, KM_PRESS, KM_CTRL, 0);
|
WM_keymap_add_item(keymap, "GPENCIL_OT_dissolve", XKEY, KM_PRESS, KM_CTRL, 0);
|
||||||
WM_keymap_add_item(keymap, "GPENCIL_OT_dissolve", DELKEY, KM_PRESS, KM_CTRL, 0);
|
WM_keymap_add_item(keymap, "GPENCIL_OT_dissolve", DELKEY, KM_PRESS, KM_CTRL, 0);
|
||||||
|
|
||||||
WM_keymap_add_item(keymap, "GPENCIL_OT_active_frame_delete", XKEY, KM_PRESS, KM_SHIFT, 0);
|
WM_keymap_add_item(keymap, "GPENCIL_OT_active_frames_delete_all", XKEY, KM_PRESS, KM_SHIFT, 0);
|
||||||
|
|
||||||
/* copy + paste */
|
/* copy + paste */
|
||||||
WM_keymap_add_item(keymap, "GPENCIL_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
|
WM_keymap_add_item(keymap, "GPENCIL_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
|
||||||
@@ -364,6 +364,7 @@ void ED_operatortypes_gpencil(void)
|
|||||||
WM_operatortype_append(GPENCIL_OT_layer_isolate);
|
WM_operatortype_append(GPENCIL_OT_layer_isolate);
|
||||||
|
|
||||||
WM_operatortype_append(GPENCIL_OT_active_frame_delete);
|
WM_operatortype_append(GPENCIL_OT_active_frame_delete);
|
||||||
|
WM_operatortype_append(GPENCIL_OT_active_frames_delete_all);
|
||||||
|
|
||||||
WM_operatortype_append(GPENCIL_OT_convert);
|
WM_operatortype_append(GPENCIL_OT_convert);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user