mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Fixed a cosmetic menu scrolling alignment issue.
This commit is contained in:
parent
53e8b45089
commit
39e8e33733
|
@ -150,21 +150,21 @@ void ComponentList::updateCameraOffset()
|
|||
// Move the camera to scroll.
|
||||
const float totalHeight = getTotalRowHeight();
|
||||
if (totalHeight > mSize.y()) {
|
||||
float target = mSelectorBarOffset + getRowHeight(mEntries.at(mCursor).data)/2 -
|
||||
(mSize.y() / 2);
|
||||
float target = mSelectorBarOffset +
|
||||
getRowHeight(mEntries.at(mCursor).data) / 2.0f - (mSize.y() / 2.0f);
|
||||
|
||||
// Clamp it.
|
||||
mCameraOffset = 0;
|
||||
// Clamp the camera to prevent a fraction of a row from being displayed.
|
||||
mCameraOffset = 0.0f;
|
||||
unsigned int i = 0;
|
||||
while (mCameraOffset < target && i < mEntries.size()) {
|
||||
mCameraOffset += getRowHeight(mEntries.at(i).data);
|
||||
if (mCameraOffset > totalHeight - mSize.y())
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (mCameraOffset < 0)
|
||||
mCameraOffset = 0;
|
||||
else if (mCameraOffset + mSize.y() > totalHeight)
|
||||
mCameraOffset = totalHeight - mSize.y();
|
||||
}
|
||||
else {
|
||||
mCameraOffset = 0;
|
||||
|
|
|
@ -82,12 +82,14 @@ float MenuComponent::getButtonGridHeight() const
|
|||
void MenuComponent::updateSize()
|
||||
{
|
||||
const float maxHeight = Renderer::getScreenHeight() * 0.75f;
|
||||
float height = TITLE_HEIGHT + mList->getTotalRowHeight() + getButtonGridHeight() + 2;
|
||||
float height = TITLE_HEIGHT + mList->getTotalRowHeight() + getButtonGridHeight() +
|
||||
(2 * Renderer::getScreenHeightModifier());
|
||||
if (height > maxHeight) {
|
||||
height = TITLE_HEIGHT + getButtonGridHeight();
|
||||
int i = 0;
|
||||
while (i < mList->size()) {
|
||||
float rowHeight = mList->getRowHeight(i);
|
||||
// Add the separator height to the row height so that it also gets properly rendered.
|
||||
float rowHeight = mList->getRowHeight(i) + (1 * Renderer::getScreenHeightModifier());
|
||||
if (height + rowHeight < maxHeight)
|
||||
height += rowHeight;
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue