diff options
author | Jacques Lucke <mail@jlucke.com> | 2019-05-03 14:00:18 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2019-05-03 14:05:03 +0300 |
commit | fa59346c1340da4189e5c7d38164a74dc096db10 (patch) | |
tree | e1d7a70936b38a284d68b5b7e2721cfbeb75ce33 /source/blender/editors/space_nla/nla_edit.c | |
parent | b5eb6548d1e7f8c01d84e4949ce614c83c7174c8 (diff) |
Refactor: Support arbitrary y offset for channel list
At first you could think that this refactor would not be
necessary, because `ACHANNEL_FIRST` exists already.
It contained the small y offset that all channels had.
Unfortunately, a lot of code assumed that
`ACHANNEL_FIRST = -ACHANNEL_HEIGHT`, making the
define pretty much useless. This refactor fixes that
for the action and nla editor.
As a nice side effect, this patch fixes channel box select.
Before there was always have a half-channel offset.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D4783
Diffstat (limited to 'source/blender/editors/space_nla/nla_edit.c')
-rw-r--r-- | source/blender/editors/space_nla/nla_edit.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 0446235a776..07853e5850a 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -421,27 +421,25 @@ static bool nla_channels_get_selected_extents(bAnimContext *ac, float *min, floa int filter; SpaceNla *snla = (SpaceNla *)ac->sl; - const float half_height = NLACHANNEL_HEIGHT_HALF(snla); /* NOTE: not bool, since we want prioritise individual channels over expanders */ short found = 0; - float y; /* get all items - we need to do it this way */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through all channels, finding the first one that's selected */ - y = (float)NLACHANNEL_FIRST; + float ymax = NLACHANNEL_FIRST_TOP(snla); - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = anim_data.first; ale; ale = ale->next, ymax -= NLACHANNEL_STEP(snla)) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); /* must be selected... */ if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) && ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT)) { /* update best estimate */ - *min = (float)(y - half_height); - *max = (float)(y + half_height); + *min = ymax - NLACHANNEL_HEIGHT(snla); + *max = ymax; /* is this high enough priority yet? */ found = acf->channel_role; @@ -453,9 +451,6 @@ static bool nla_channels_get_selected_extents(bAnimContext *ac, float *min, floa break; } } - - /* adjust y-position for next one */ - y -= NLACHANNEL_STEP(snla); } /* free all temp data */ |