Tweak how scroll offsets are calculated for smoother scrolling

This commit is contained in:
Andrew Lanzone 2025-07-06 22:39:13 -07:00
parent abe0467915
commit e349fa248a
2 changed files with 12 additions and 22 deletions

View File

@ -944,12 +944,8 @@ 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 = 0; i < static_cast<int>(index) - 6; i++)
for (int i = 6; i < static_cast<int>(index); i++)
{
const std::string& keyword = mTopicsList->getItemNameAt(i);
if (keyword.empty())
@ -960,7 +956,6 @@ namespace MWGui
mTopicsList->setViewOffset(-offset);
}
}
}
bool DialogueWindow::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
{

View File

@ -971,17 +971,12 @@ 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;
for (int i = 3; i < static_cast<int>(mSelectedQuest); i++)
offset += mButtons[i]->getHeight();
list->setViewOffset(-offset);
}
}
}
};
}