GPencil: Add blank frame when add layer in Dopesheet

When use the dopesheet add layer operator a new blank frame is created. It's very strange to create a layer and don't see anything in dopesheet.

If the layer is added in properties, the frame is not created.

Reviewed by: @pepeland @mendio
This commit is contained in:
Antonio Vazquez 2020-03-24 16:16:30 +01:00
parent d626ced6f1
commit 7ac5c5b08c
Notes: blender-bot 2023-02-14 02:30:10 +01:00
Referenced by issue #75050, GPencil: Strokes get darker while drawing in SOLID mode
1 changed files with 8 additions and 1 deletions

View File

@ -211,9 +211,12 @@ void GPENCIL_OT_data_unlink(wmOperatorType *ot)
static int gp_layer_add_exec(bContext *C, wmOperator *op)
{
const bool is_annotation = STREQ(op->idname, "GPENCIL_OT_layer_annotation_add");
ScrArea *sa = CTX_wm_area(C);
const bool is_dopesheet = (sa->spacetype == SPACE_ACTION);
PointerRNA gpd_owner = {NULL};
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
bGPdata *gpd = NULL;
if (is_annotation) {
@ -238,7 +241,11 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
if ((ob != NULL) && (ob->type == OB_GPENCIL)) {
gpd = (bGPdata *)ob->data;
BKE_gpencil_layer_addnew(gpd, DATA_("GP_Layer"), true);
bGPDlayer *gpl = BKE_gpencil_layer_addnew(gpd, DATA_("GP_Layer"), true);
/* In dopesheet add a new frame. */
if ((gpl != NULL) && (is_dopesheet)) {
gpl->actframe = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_ADD_NEW);
}
}
}