From bf26fbcd25977ed359f225d5446600a8699ea4fa Mon Sep 17 00:00:00 2001 From: aryanrawlani28 Date: Mon, 11 May 2020 16:29:44 +0530 Subject: [PATCH] GUI: RTL: Make tooltip messages rtl friendly --- gui/Tooltip.cpp | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/gui/Tooltip.cpp b/gui/Tooltip.cpp index 62ec9703e89..0b3441e6733 100644 --- a/gui/Tooltip.cpp +++ b/gui/Tooltip.cpp @@ -75,21 +75,39 @@ void Tooltip::drawDialog(DrawLayer layerToDraw) { Dialog::drawDialog(layerToDraw); - int16 textX = _x + 3; // including 2px padding and 1px original code shift + int16 textX = g_gui.useRTL() ? _x - 3 : _x + 3; // including 2px padding and 1px original code shift int16 textY = _y + 3; - for (Common::StringArray::const_iterator i = _wrappedLines.begin(); i != _wrappedLines.end(); ++i, ++num) { - g_gui.theme()->drawText( - Common::Rect(textX, textY + num * h, textX + _w, textY + (num + 1) * h), - *i, - ThemeEngine::kStateEnabled, - Graphics::kTextAlignLeft, - ThemeEngine::kTextInversionNone, - 0, - false, - ThemeEngine::kFontStyleTooltip, - ThemeEngine::kFontColorNormal, - false - ); + + if (g_gui.useRTL()) { + for (Common::StringArray::const_iterator i = _wrappedLines.begin(); i != _wrappedLines.end(); ++i, ++num) { + g_gui.theme()->drawText( + Common::Rect(textX, textY + num * h, textX + _w, textY + (num + 1) * h), + *i, + ThemeEngine::kStateEnabled, + Graphics::kTextAlignRight, + ThemeEngine::kTextInversionNone, + 0, + false, + ThemeEngine::kFontStyleTooltip, + ThemeEngine::kFontColorNormal, + false + ); + } + }else{ + for (Common::StringArray::const_iterator i = _wrappedLines.begin(); i != _wrappedLines.end(); ++i, ++num) { + g_gui.theme()->drawText( + Common::Rect(textX, textY + num * h, textX + _w, textY + (num + 1) * h), + *i, + ThemeEngine::kStateEnabled, + Graphics::kTextAlignLeft, + ThemeEngine::kTextInversionNone, + 0, + false, + ThemeEngine::kFontStyleTooltip, + ThemeEngine::kFontColorNormal, + false + ); + } } }