Fixed camera scrolling for ComponentLists to always be by row heights.

This commit is contained in:
Aloshi 2014-03-24 15:34:38 -05:00
parent 2203e9ff81
commit 7875c2271c

View file

@ -111,7 +111,16 @@ void ComponentList::onCursorChanged(const CursorState& state)
const float totalHeight = getTotalRowHeight();
if(totalHeight > mSize.y())
{
mCameraOffset = mSelectorBarOffset - (mSize.y() / 2);
float target = mSelectorBarOffset + getRowHeight(mEntries.at(mCursor).data)/2 - (mSize.y() / 2);
// clamp it
mCameraOffset = 0;
unsigned int i = 0;
while(mCameraOffset < target && i < mEntries.size())
{
mCameraOffset += getRowHeight(mEntries.at(i).data);
i++;
}
if(mCameraOffset < 0)
mCameraOffset = 0;