mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-27 14:10:46 -04:00
Tweak how scroll offsets are calculated for smoother scrolling
This commit is contained in:
parent
abe0467915
commit
e349fa248a
@ -944,21 +944,16 @@ namespace MWGui
|
||||
if (focused)
|
||||
{
|
||||
// Scroll the side bar to keep the active item in view
|
||||
if (index <= 6)
|
||||
mTopicsList->setViewOffset(0);
|
||||
else
|
||||
int offset = 0;
|
||||
for (int i = 6; i < static_cast<int>(index); i++)
|
||||
{
|
||||
int offset = 0;
|
||||
for (int i = 0; i < static_cast<int>(index) - 6; i++)
|
||||
{
|
||||
const std::string& keyword = mTopicsList->getItemNameAt(i);
|
||||
if (keyword.empty())
|
||||
offset += 18 + sVerticalPadding * 2;
|
||||
else
|
||||
offset += mTopicsList->getItemWidget(keyword)->getHeight() + sVerticalPadding * 2;
|
||||
}
|
||||
mTopicsList->setViewOffset(-offset);
|
||||
const std::string& keyword = mTopicsList->getItemNameAt(i);
|
||||
if (keyword.empty())
|
||||
offset += 18 + sVerticalPadding * 2;
|
||||
else
|
||||
offset += mTopicsList->getItemWidget(keyword)->getHeight() + sVerticalPadding * 2;
|
||||
}
|
||||
mTopicsList->setViewOffset(-offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -971,15 +971,10 @@ namespace
|
||||
|
||||
// Scroll the list to keep the active item in view
|
||||
Gui::MWList* list = getWidget<Gui::MWList>(mQuestMode ? QuestsList : TopicsList);
|
||||
if (mSelectedQuest <= 3)
|
||||
list->setViewOffset(0);
|
||||
else
|
||||
{
|
||||
int offset = 0;
|
||||
for (int i = 0; i < static_cast<int>(mSelectedQuest) - 3; i++)
|
||||
offset += mButtons[i]->getHeight() + 3;
|
||||
list->setViewOffset(-offset);
|
||||
}
|
||||
int offset = 0;
|
||||
for (int i = 3; i < static_cast<int>(mSelectedQuest); i++)
|
||||
offset += mButtons[i]->getHeight();
|
||||
list->setViewOffset(-offset);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user