Fix T50184: Grease Pencil Layer synchronization between Dope Sheet and Properties panel

This commit is contained in:
Joshua Leung
2016-12-28 16:54:57 +13:00
parent 7f262acb92
commit c5338fd162
3 changed files with 39 additions and 7 deletions

View File

@@ -309,6 +309,28 @@ static void animchan_sync_fcurve(bAnimContext *ac, bAnimListElem *ale, FCurve **
}
}
/* perform syncing updates for GPencil Layers */
static void animchan_sync_gplayer(bAnimContext *UNUSED(ac), bAnimListElem *ale)
{
bGPDlayer *gpl = (bGPDlayer *)ale->data;
/* Make sure the selection flags agree with the "active" flag.
* The selection flags are used in the Dopesheet only, whereas
* the active flag is used everywhere else. Hence, we try to
* sync these here so that it all seems to be have as the user
* expects - T50184
*
* Assume that we only really do this when the active status changes.
* (NOTE: This may prove annoying if it means selection is always lost)
*/
if (gpl->flag & GP_LAYER_ACTIVE) {
gpl->flag |= GP_LAYER_SELECT;
}
else {
gpl->flag &= ~GP_LAYER_SELECT;
}
}
/* ---------------- */
/* Main call to be exported to animation editors */
@@ -343,6 +365,10 @@ void ANIM_sync_animchannels_to_data(const bContext *C)
case ANIMTYPE_FCURVE:
animchan_sync_fcurve(&ac, ale, &active_fcurve);
break;
case ANIMTYPE_GPLAYER:
animchan_sync_gplayer(&ac, ale);
break;
}
}

View File

@@ -337,7 +337,7 @@ static void action_channel_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(
}
break;
case NC_GPENCIL:
if (wmn->action == NA_RENAME)
if (ELEM(wmn->action, NA_RENAME, NA_SELECTED))
ED_region_tag_redraw(ar);
break;
case NC_ID:
@@ -407,10 +407,15 @@ static void action_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn)
/* context changes */
switch (wmn->category) {
case NC_GPENCIL:
if (wmn->action == NA_EDITED) {
/* only handle this event in GPencil mode for performance considerations */
if (saction->mode == SACTCONT_GPENCIL)
/* only handle these events in GPencil mode for performance considerations */
if (saction->mode == SACTCONT_GPENCIL) {
if (wmn->action == NA_EDITED) {
ED_area_tag_redraw(sa);
}
else if (wmn->action == NA_SELECTED) {
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
ED_area_tag_refresh(sa);
}
}
break;
case NC_ANIMATION:

View File

@@ -1276,13 +1276,13 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_ACTIVE);
RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencilLayer_active_set");
RNA_def_property_ui_text(prop, "Active", "Set active layer for editing");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
#endif
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_SELECT);
RNA_def_property_ui_text(prop, "Select", "Layer is selected for editing in the Dope Sheet");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_SELECTED, "rna_GPencil_update");
/* XXX keep this option? */
prop = RNA_def_property(srna, "show_points", PROP_BOOLEAN, PROP_NONE);
@@ -1370,14 +1370,15 @@ static void rna_def_gpencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_pointer_funcs(prop, "rna_GPencil_active_layer_get", "rna_GPencil_active_layer_set", NULL, NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Active Layer", "Active grease pencil layer");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_funcs(prop,
"rna_GPencil_active_layer_index_get",
"rna_GPencil_active_layer_index_set",
"rna_GPencil_active_layer_index_range");
RNA_def_property_ui_text(prop, "Active Layer Index", "Index of active grease pencil layer");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
}
static void rna_def_gpencil_palettecolor(BlenderRNA *brna)