mirror of
https://github.com/OpenMW/openmw.git
synced 2025-10-26 18:26:41 +00:00
Make topic padding a const and use it when scrolling dialog topics
This commit is contained in:
parent
0f26270f66
commit
e577257ec4
2 changed files with 8 additions and 8 deletions
|
|
@ -653,13 +653,10 @@ namespace MWGui
|
||||||
if (mTopicsList->getItemCount() > 0)
|
if (mTopicsList->getItemCount() > 0)
|
||||||
mTopicsList->addSeparator();
|
mTopicsList->addSeparator();
|
||||||
|
|
||||||
// Morrowind uses 3 px invisible borders for padding topics
|
|
||||||
constexpr int verticalPadding = 3;
|
|
||||||
|
|
||||||
for (const auto& keyword : mKeywords)
|
for (const auto& keyword : mKeywords)
|
||||||
{
|
{
|
||||||
std::string topicId = Misc::StringUtils::lowerCase(keyword);
|
std::string topicId = Misc::StringUtils::lowerCase(keyword);
|
||||||
mTopicsList->addItem(keyword, verticalPadding);
|
mTopicsList->addItem(keyword, sVerticalPadding);
|
||||||
|
|
||||||
auto t = std::make_unique<Topic>(keyword);
|
auto t = std::make_unique<Topic>(keyword);
|
||||||
mKeywordSearch.seed(topicId, intptr_t(t.get()));
|
mKeywordSearch.seed(topicId, intptr_t(t.get()));
|
||||||
|
|
@ -947,18 +944,18 @@ namespace MWGui
|
||||||
if (focused)
|
if (focused)
|
||||||
{
|
{
|
||||||
// Scroll the side bar to keep the active item in view
|
// Scroll the side bar to keep the active item in view
|
||||||
if (index <= 8)
|
if (index <= 6)
|
||||||
mTopicsList->setViewOffset(0);
|
mTopicsList->setViewOffset(0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
for (int i = 0; i < static_cast<int>(index) - 8; i++)
|
for (int i = 0; i < static_cast<int>(index) - 6; i++)
|
||||||
{
|
{
|
||||||
const std::string& keyword = mTopicsList->getItemNameAt(i);
|
const std::string& keyword = mTopicsList->getItemNameAt(i);
|
||||||
if (keyword.empty())
|
if (keyword.empty())
|
||||||
offset += 21;
|
offset += 18 + sVerticalPadding * 2;
|
||||||
else
|
else
|
||||||
offset += mTopicsList->getItemWidget(keyword)->getHeight() + 3;
|
offset += mTopicsList->getItemWidget(keyword)->getHeight() + sVerticalPadding * 2;
|
||||||
}
|
}
|
||||||
mTopicsList->setViewOffset(-offset);
|
mTopicsList->setViewOffset(-offset);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -226,6 +226,9 @@ namespace MWGui
|
||||||
|
|
||||||
MyGUI::IntSize mCurrentWindowSize;
|
MyGUI::IntSize mCurrentWindowSize;
|
||||||
|
|
||||||
|
// Morrowind uses 3 px invisible borders for padding topics
|
||||||
|
static const int sVerticalPadding = 3;
|
||||||
|
|
||||||
std::unique_ptr<ResponseCallback> mCallback;
|
std::unique_ptr<ResponseCallback> mCallback;
|
||||||
std::unique_ptr<ResponseCallback> mGreetingCallback;
|
std::unique_ptr<ResponseCallback> mGreetingCallback;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue