Graph Editor: Bugfixes for option where only the keyframes of selected F-Curves are shown

* Selected keyframes in unselected F-Curves were still being modified, although not shown
* Selection tools for keyframes were changing the selection status of F-Curves, making keyframes sometimes disappear after trying to select another keyframe

* Warning fixes in a few other files
This commit is contained in:
Joshua Leung 2010-01-22 23:51:31 +00:00
parent f0d89a041f
commit 8dd14e1eed
5 changed files with 79 additions and 38 deletions

@ -1480,7 +1480,6 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
bPose *pose= ob->pose, *frompose= from->pose; bPose *pose= ob->pose, *frompose= from->pose;
bPoseChannel *pchan, *pchanp, pchanw; bPoseChannel *pchan, *pchanp, pchanw;
bConstraint *con; bConstraint *con;
AnimData *adt, *fromadt;
int error = 0; int error = 0;
if (frompose==NULL) return; if (frompose==NULL) return;

@ -2325,7 +2325,7 @@ void makeBevelList(Object *ob)
/* /*
* handlecodes: * handlecodes:
* 1: nothing, 1:auto, 2:vector, 3:aligned * 0: nothing, 1:auto, 2:vector, 3:aligned
*/ */
/* mode: is not zero when FCurve, is 2 when forced horizontal for autohandles */ /* mode: is not zero when FCurve, is 2 when forced horizontal for autohandles */

@ -442,11 +442,15 @@ short ANIM_animdata_get_context (const bContext *C, bAnimContext *ac)
/* quick macro to test if an anim-channel (F-Curve) is selected ok for editing purposes /* quick macro to test if an anim-channel (F-Curve) is selected ok for editing purposes
* - _SELEDIT means that only selected curves will have visible+editable keyframes * - _SELEDIT means that only selected curves will have visible+editable keyframes
*
* checks here work as follows:
* 1) seledit off - don't need to consider the implications of this option
* 2) foredit off - we're not considering editing, so channel is ok still
* 3) test_func (i.e. selection test) - only if selected, this test will pass
*/ */
// FIXME: this doesn't work cleanly yet...
#define ANIMCHANNEL_SELEDITOK(test_func) \ #define ANIMCHANNEL_SELEDITOK(test_func) \
( !(filter_mode & ANIMFILTER_SELEDIT) || \ ( !(filter_mode & ANIMFILTER_SELEDIT) || \
(filter_mode & ANIMFILTER_CHANNELS) || \ !(filter_mode & ANIMFILTER_FOREDIT) || \
(test_func) ) (test_func) )
/* ----------- 'Private' Stuff --------------- */ /* ----------- 'Private' Stuff --------------- */
@ -952,6 +956,7 @@ static int animdata_filter_action (ListBase *anim_data, bDopeSheet *ads, bAction
* - group is expanded * - group is expanded
* - we just need the F-Curves present * - we just need the F-Curves present
*/ */
// FIXME: checking if groups are expanded is only valid if in one or other modes
if ( (!(filter_mode & ANIMFILTER_VISIBLE) || EXPANDED_AGRP(agrp)) || (filter_mode & ANIMFILTER_CURVESONLY) ) if ( (!(filter_mode & ANIMFILTER_VISIBLE) || EXPANDED_AGRP(agrp)) || (filter_mode & ANIMFILTER_CURVESONLY) )
{ {
/* for the Graph Editor, curves may be set to not be visible in the view to lessen clutter, /* for the Graph Editor, curves may be set to not be visible in the view to lessen clutter,
@ -1804,6 +1809,14 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bAnimContext *ac, bDo
return 0; return 0;
} }
/* augment the filter-flags with settings based on the dopesheet filterflags
* so that some temp settings can get added automagically...
*/
if (ads->filterflag & ADS_FILTER_SELEDIT) {
/* only selected F-Curves should get their keyframes considered for editability */
filter_mode |= ANIMFILTER_SELEDIT;
}
/* scene-linked animation */ /* scene-linked animation */
// TODO: sequencer, composite nodes - are we to include those here too? // TODO: sequencer, composite nodes - are we to include those here too?
{ {

@ -109,6 +109,7 @@ static void deselect_graph_keys (bAnimContext *ac, short test, short sel)
bAnimListElem *ale; bAnimListElem *ale;
int filter; int filter;
SpaceIpo *sipo= (SpaceIpo *)ac->sa->spacedata.first;
BeztEditData bed; BeztEditData bed;
BeztEditFunc test_cb, sel_cb; BeztEditFunc test_cb, sel_cb;
@ -142,13 +143,18 @@ static void deselect_graph_keys (bAnimContext *ac, short test, short sel)
/* Keyframes First */ /* Keyframes First */
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, sel_cb, NULL); ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, sel_cb, NULL);
/* deactivate the F-Curve, and deselect if deselecting keyframes. /* only change selection of channel when the visibility of keyframes doesn't depend on this */
* otherwise select the F-Curve too since we've selected all the keyframes if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
*/ /* deactivate the F-Curve, and deselect if deselecting keyframes.
if (sel == SELECT_SUBTRACT) * otherwise select the F-Curve too since we've selected all the keyframes
fcu->flag &= ~FCURVE_SELECTED; */
else if (sel == SELECT_SUBTRACT)
fcu->flag |= FCURVE_SELECTED; fcu->flag &= ~FCURVE_SELECTED;
else
fcu->flag |= FCURVE_SELECTED;
}
/* always deactivate all F-Curves if we perform batch ops for selection */
fcu->flag &= ~FCURVE_ACTIVE; fcu->flag &= ~FCURVE_ACTIVE;
} }
@ -214,6 +220,7 @@ static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, sho
bAnimListElem *ale; bAnimListElem *ale;
int filter; int filter;
SpaceIpo *sipo= (SpaceIpo *)ac->sa->spacedata.first;
BeztEditData bed; BeztEditData bed;
BeztEditFunc ok_cb, select_cb; BeztEditFunc ok_cb, select_cb;
View2D *v2d= &ac->ar->v2d; View2D *v2d= &ac->ar->v2d;
@ -264,9 +271,12 @@ static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, sho
/* select keyframes that are in the appropriate places */ /* select keyframes that are in the appropriate places */
ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL); ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL);
/* select the curve too now that curve will be touched */ /* only change selection of channel when the visibility of keyframes doesn't depend on this */
if (selectmode == SELECT_ADD) if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
fcu->flag |= FCURVE_SELECTED; /* select the curve too now that curve will be touched */
if (selectmode == SELECT_ADD)
fcu->flag |= FCURVE_SELECTED;
}
} }
/* un-apply NLA mapping from all the keyframes */ /* un-apply NLA mapping from all the keyframes */
@ -290,7 +300,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op)
if (ANIM_animdata_get_context(C, &ac) == 0) if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
if(RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT) if (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT)
selectmode= SELECT_ADD; selectmode= SELECT_ADD;
else else
selectmode= SELECT_SUBTRACT; selectmode= SELECT_SUBTRACT;
@ -584,7 +594,7 @@ static short findnearest_fcurve_vert (bAnimContext *ac, int mval[2], FCurve **fc
* include the 'only selected' flag... * include the 'only selected' flag...
*/ */
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_CURVESONLY); filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_CURVESONLY);
if (sipo->flag & SIPO_SELCUVERTSONLY) if (sipo->flag & SIPO_SELCUVERTSONLY) // FIXME: this should really be check for by the filtering code...
filter |= ANIMFILTER_SEL; filter |= ANIMFILTER_SEL;
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
@ -670,6 +680,7 @@ static short findnearest_fcurve_vert (bAnimContext *ac, int mval[2], FCurve **fc
/* option 1) select keyframe directly under mouse */ /* option 1) select keyframe directly under mouse */
static void mouse_graph_keys (bAnimContext *ac, int mval[], short select_mode, short curves_only) static void mouse_graph_keys (bAnimContext *ac, int mval[], short select_mode, short curves_only)
{ {
SpaceIpo *sipo= (SpaceIpo *)ac->sa->spacedata.first;
FCurve *fcu; FCurve *fcu;
BezTriple *bezt; BezTriple *bezt;
short handle; short handle;
@ -687,9 +698,15 @@ static void mouse_graph_keys (bAnimContext *ac, int mval[], short select_mode, s
/* reset selection mode */ /* reset selection mode */
select_mode= SELECT_ADD; select_mode= SELECT_ADD;
/* deselect all other channels and keyframes */ /* deselect all other keyframes */
//ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
deselect_graph_keys(ac, 0, SELECT_SUBTRACT); deselect_graph_keys(ac, 0, SELECT_SUBTRACT);
/* deselect other channels too, but only only do this if
* selection of channel when the visibility of keyframes
* doesn't depend on this
*/
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0)
ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
} }
/* if points can be selected on this F-Curve */ /* if points can be selected on this F-Curve */
@ -746,16 +763,19 @@ static void mouse_graph_keys (bAnimContext *ac, int mval[], short select_mode, s
ANIM_fcurve_keys_bezier_loop(&bed, fcu, NULL, select_cb, NULL); ANIM_fcurve_keys_bezier_loop(&bed, fcu, NULL, select_cb, NULL);
} }
/* select or deselect curve? */ /* only change selection of channel when the visibility of keyframes doesn't depend on this */
if (select_mode == SELECT_INVERT) if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
fcu->flag ^= FCURVE_SELECTED; /* select or deselect curve? */
else if (select_mode == SELECT_ADD) if (select_mode == SELECT_INVERT)
fcu->flag |= FCURVE_SELECTED; fcu->flag ^= FCURVE_SELECTED;
else if (select_mode == SELECT_ADD)
/* set active F-Curve (NOTE: sync the filter flags with findnearest_fcurve_vert) */ fcu->flag |= FCURVE_SELECTED;
if (fcu->flag & FCURVE_SELECTED) {
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_CURVESONLY); /* set active F-Curve (NOTE: sync the filter flags with findnearest_fcurve_vert) */
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE); if (fcu->flag & FCURVE_SELECTED) {
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_CURVESONLY);
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE);
}
} }
} }
@ -766,6 +786,7 @@ static void graphkeys_mselect_leftright (bAnimContext *ac, short leftright, shor
bAnimListElem *ale; bAnimListElem *ale;
int filter; int filter;
SpaceIpo *sipo= (SpaceIpo *)ac->sa->spacedata.first;
BeztEditFunc ok_cb, select_cb; BeztEditFunc ok_cb, select_cb;
BeztEditData bed; BeztEditData bed;
Scene *scene= ac->scene; Scene *scene= ac->scene;
@ -775,9 +796,15 @@ static void graphkeys_mselect_leftright (bAnimContext *ac, short leftright, shor
/* reset selection mode to add to selection */ /* reset selection mode to add to selection */
select_mode= SELECT_ADD; select_mode= SELECT_ADD;
/* deselect all other channels and keyframes */ /* deselect all other keyframes */
ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
deselect_graph_keys(ac, 0, SELECT_SUBTRACT); deselect_graph_keys(ac, 0, SELECT_SUBTRACT);
/* deselect other channels too, but only only do this if
* selection of channel when the visibility of keyframes
* doesn't depend on this
*/
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0)
ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
} }
/* set callbacks and editing data */ /* set callbacks and editing data */
@ -822,6 +849,7 @@ static void graphkeys_mselect_column (bAnimContext *ac, int mval[2], short selec
bAnimListElem *ale; bAnimListElem *ale;
int filter; int filter;
SpaceIpo *sipo= (SpaceIpo *)ac->sa->spacedata.first;
BeztEditFunc select_cb, ok_cb; BeztEditFunc select_cb, ok_cb;
BeztEditData bed; BeztEditData bed;
FCurve *fcu; FCurve *fcu;
@ -841,9 +869,15 @@ static void graphkeys_mselect_column (bAnimContext *ac, int mval[2], short selec
/* reset selection mode to add to selection */ /* reset selection mode to add to selection */
select_mode= SELECT_ADD; select_mode= SELECT_ADD;
/* deselect all other channels and keyframes */ /* deselect all other keyframes */
ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
deselect_graph_keys(ac, 0, SELECT_SUBTRACT); deselect_graph_keys(ac, 0, SELECT_SUBTRACT);
/* deselect other channels too, but only only do this if
* selection of channel when the visibility of keyframes
* doesn't depend on this
*/
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0)
ANIM_deselect_anim_channels(ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
} }
/* initialise keyframe editing data */ /* initialise keyframe editing data */

@ -80,12 +80,7 @@ static void rna_def_dopesheet(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLYNLA); RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLYNLA);
RNA_def_property_ui_text(prop, "Only NLA", "Only include NLA data from Animation data."); RNA_def_property_ui_text(prop, "Only NLA", "Only include NLA data from Animation data.");
RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL); RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
prop= RNA_def_property(srna, "use_filter", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_SELEDIT);
RNA_def_property_ui_text(prop, "Use Filter", "Indicates if filtering options must be taken into account.");
RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
prop= RNA_def_property(srna, "display_summary", PROP_BOOLEAN, PROP_NONE); prop= RNA_def_property(srna, "display_summary", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_SUMMARY); RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_SUMMARY);
RNA_def_property_ui_text(prop, "Display Summary", "Display an additional 'summary' line. (DopeSheet Editors only)"); RNA_def_property_ui_text(prop, "Display Summary", "Display an additional 'summary' line. (DopeSheet Editors only)");