diff options
Diffstat (limited to 'source/blender/editors/space_action/action_select.c')
-rw-r--r-- | source/blender/editors/space_action/action_select.c | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 0c6b0f5eb3d..bd73e35815b 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -43,6 +43,7 @@ #include "DNA_gpencil_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_mask_types.h" #include "RNA_access.h" #include "RNA_define.h" @@ -55,6 +56,7 @@ #include "ED_anim_api.h" #include "ED_gpencil.h" +#include "ED_mask.h" #include "ED_keyframes_draw.h" #include "ED_keyframes_edit.h" #include "ED_markers.h" @@ -92,7 +94,7 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel) KeyframeEditFunc test_cb, sel_cb; /* determine type-based settings */ - if (ac->datatype == ANIMCONT_GPENCIL) + if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); @@ -112,6 +114,12 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel) break; } } + else if (ale->type == ANIMTYPE_MASKLAYER) { + if (is_masklayer_frame_selected(ale->data)) { + sel = SELECT_SUBTRACT; + break; + } + } else { if (ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, test_cb, NULL)) { sel = SELECT_SUBTRACT; @@ -128,6 +136,8 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel) for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_GPLAYER) set_gplayer_frame_selection(ale->data, sel); + else if (ale->type == ANIMTYPE_MASKLAYER) + set_masklayer_frame_selection(ale->data, sel); else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL); } @@ -250,6 +260,8 @@ static void borderselect_action(bAnimContext *ac, rcti rect, short mode, short s /* loop over data selecting */ if (ale->type == ANIMTYPE_GPLAYER) borderselect_gplayer_frames(ale->data, rectf.xmin, rectf.xmax, selectmode); + else if (ale->type == ANIMTYPE_MASKLAYER) + borderselect_masklayer_frames(ale->data, rectf.xmin, rectf.xmax, selectmode); else ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, NULL); } @@ -400,6 +412,9 @@ static void markers_selectkeys_between(bAnimContext *ac) else if (ale->type == ANIMTYPE_GPLAYER) { borderselect_gplayer_frames(ale->data, min, max, SELECT_ADD); } + else if (ale->type == ANIMTYPE_MASKLAYER) { + borderselect_masklayer_frames(ale->data, min, max, SELECT_ADD); + } else { ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } @@ -467,7 +482,7 @@ static void columnselect_action_keys(bAnimContext *ac, short mode) /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ - if (ac->datatype == ANIMCONT_GPENCIL) + if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/); @@ -489,6 +504,8 @@ static void columnselect_action_keys(bAnimContext *ac, short mode) /* select elements with frame number matching cfraelem */ if (ale->type == ANIMTYPE_GPLAYER) select_gpencil_frame(ale->data, ce->cfra, SELECT_ADD); + else if (ale->type == ANIMTYPE_MASKLAYER) + select_mask_frame(ale->data, ce->cfra, SELECT_ADD); else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } @@ -755,7 +772,7 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se } /* filter data */ - if (ac->datatype == ANIMCONT_GPENCIL) + if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); @@ -772,6 +789,8 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se } else if (ale->type == ANIMTYPE_GPLAYER) borderselect_gplayer_frames(ale->data, ked.f1, ked.f2, select_mode); + else if (ale->type == ANIMTYPE_MASKLAYER) + borderselect_masklayer_frames(ale->data, ked.f1, ked.f2, select_mode); else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } @@ -909,6 +928,8 @@ static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short s /* select the nominated keyframe on the given frame */ if (ale->type == ANIMTYPE_GPLAYER) select_gpencil_frame(ale->data, selx, select_mode); + else if (ale->type == ANIMTYPE_MASKLAYER) + select_mask_frame(ale->data, selx, select_mode); else ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, NULL); } @@ -933,7 +954,7 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ - if (ac->datatype == ANIMCONT_GPENCIL) + if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); @@ -951,7 +972,9 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se /* select elements with frame number matching cfra */ if (ale->type == ANIMTYPE_GPLAYER) select_gpencil_frame(ale->key_data, selx, select_mode); - else + else if (ale->type == ANIMTYPE_MASKLAYER) + select_mask_frame(ale->key_data, selx, select_mode); + else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } @@ -1051,7 +1074,12 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ bGPDlayer *gpl = (bGPDlayer *)ale->data; gpl_to_keylist(ads, gpl, &anim_keys); } - + else if (ale->type == ANIMTYPE_MASKLAYER) { + // TODO: why don't we just give masklayers key_data too? + MaskLayer *masklay = (MaskLayer *)ale->data; + mask_to_keylist(ads, masklay, &anim_keys); + } + /* start from keyframe at root of BST, traversing until we find one within the range that was clicked on */ for (ak = anim_keys.root; ak; ak = akn) { if (IN_RANGE(ak->cfra, rectf.xmin, rectf.xmax)) { @@ -1120,6 +1148,18 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ //gpencil_layer_setactive(gpd, gpl); } } + else if (ac->datatype == ANIMCONT_MASK) { + /* deselect all other channels first */ + ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); + + /* Highlight GPencil Layer */ + if ((ale && ale->data) && (ale->type == ANIMTYPE_MASKLAYER)) { + MaskLayer *masklay = ale->data; + + masklay->flag |= MASK_LAYERFLAG_SELECT; + //gpencil_layer_setactive(gpd, gpl); + } + } } /* only select keyframes if we clicked on a valid channel and hit something */ |