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_action/action_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_action/action_edit.c')
-rw-r--r-- | source/blender/editors/space_action/action_edit.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 8df773e98d6..d8ed25c86d3 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -325,24 +325,23 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *min, /* 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)ACHANNEL_FIRST(ac); + float ymax = ACHANNEL_FIRST_TOP(ac); - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac)) { 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 - ACHANNEL_HEIGHT_HALF(ac)); - *max = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); + *min = ymax - ACHANNEL_HEIGHT(ac); + *max = ymax; /* is this high enough priority yet? */ found = acf->channel_role; @@ -354,9 +353,6 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *min, break; } } - - /* adjust y-position for next one */ - y -= ACHANNEL_STEP(ac); } /* free all temp data */ |