Merge pull request #276 from hedge-dev/options-menu-info-scroll-annotation-fix

Implement proper scrolling for annotated text on options menu
This commit is contained in:
DeaTh-G 2025-02-04 17:06:33 +01:00 committed by GitHub
commit 41c6906f48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 6 deletions

View file

@ -624,7 +624,7 @@ ImVec2 MeasureCentredParagraph(const ImFont* font, float fontSize, float lineMar
x = std::max(x, textSize.x);
y += textSize.y + Scale(lineMargin);
if (paragraph.annotated)
if (paragraph.annotated && i != (annotationRemovedLines.size() - 1))
y += fontSize * ANNOTATION_FONT_SIZE_MODIFIER;
}
@ -633,7 +633,13 @@ ImVec2 MeasureCentredParagraph(const ImFont* font, float fontSize, float lineMar
ImVec2 MeasureCentredParagraph(const ImFont* font, float fontSize, float maxWidth, float lineMargin, const char* text)
{
return MeasureCentredParagraph(font, fontSize, lineMargin, Split(text, font, fontSize, maxWidth));
const auto input = RemoveRubyAnnotations(text);
auto lines = Split(input.first.c_str(), font, fontSize, maxWidth);
for (auto& line : lines)
line = ReAddRubyAnnotations(line, input.second);
return MeasureCentredParagraph(font, fontSize, lineMargin, lines);
}
void DrawRubyAnnotatedText(const ImFont* font, float fontSize, float maxWidth, const ImVec2& pos, float lineMargin, const char* text, std::function<void(const char*, ImVec2)> drawMethod, std::function<void(const char*, float, ImVec2)> annotationDrawMethod, bool isCentred)

View file

@ -292,9 +292,9 @@ void MessageWindow::Draw()
if (Config::Language == ELanguage::Japanese)
{
textMarginX -= Scale(2.5f);
textMarginY -= Scale(7.5f);
textMarginY -= Scale(2.0f);
textY += Scale(lines.size() % 2 == 0 ? 8.5f : 15.5f);
textY += Scale(lines.size() % 2 == 0 ? 1.5f : 8.0f);
}
bool isController = hid::IsInputDeviceController();

View file

@ -1373,7 +1373,11 @@ static void DrawInfoPanel(ImVec2 infoMin, ImVec2 infoMax)
desc = buf;
}
desc += "\n\n" + g_selectedItem->GetValueDescription(Config::Language);
const auto& valueDescription = g_selectedItem->GetValueDescription(Config::Language);
if (!valueDescription.empty())
{
desc += "\n\n" + valueDescription;
}
}
clipRectMin = { clipRectMin.x, thumbnailMax.y };
@ -1388,7 +1392,6 @@ static void DrawInfoPanel(ImVec2 infoMin, ImVec2 infoMax)
auto textX = clipRectMin.x - Scale(0.5f);
auto textY = thumbnailMax.y + offsetY;
auto textSize = MeasureCentredParagraph(g_seuratFont, fontSize, clipRectMax.x - clipRectMin.x, 5.0f, desc.c_str());
if (Config::Language == ELanguage::Japanese)
{
@ -1405,6 +1408,8 @@ static void DrawInfoPanel(ImVec2 infoMin, ImVec2 infoMax)
textY += annotationFontSize;
}
auto textSize = MeasureCentredParagraph(g_seuratFont, fontSize, clipRectMax.x - clipRectMin.x, 5.0f, desc.c_str());
drawList->PushClipRect(clipRectMin, clipRectMax, false);
static auto isScrolling = false;