From fa59346c1340da4189e5c7d38164a74dc096db10 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 3 May 2019 13:00:18 +0200 Subject: 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 --- source/blender/editors/space_action/action_edit.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'source/blender/editors/space_action/action_edit.c') 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 */ -- cgit v1.2.3