From 4699880c99dc14cb39a553b36953877bc4b312a3 Mon Sep 17 00:00:00 2001 From: aryanrawlani28 Date: Fri, 22 May 2020 02:00:17 +0530 Subject: [PATCH] GUI: RTL: Support internal flipping of Sliders --- gui/ThemeEngine.cpp | 7 ++++++- gui/ThemeEngine.h | 2 +- gui/widget.cpp | 8 +------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index b668ec942ef..818adb7de7b 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1085,7 +1085,7 @@ void ThemeEngine::drawRadiobutton(const Common::Rect &r, const Common::String &s _widgets[dd]->_textAlignV); } -void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state) { +void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state, bool rtl) { if (!ready()) return; @@ -1100,6 +1100,11 @@ void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo s r2.setWidth(MIN((int16)width, r.width())); // r2.top++; r2.bottom--; r2.left++; r2.right--; + if (rtl) { + r2.left = r.right - r2.width(); + r2.right = r.right; + } + drawWidgetBackground(r, kWidgetBackgroundSlider); drawDD(dd, r2); diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index ad5344937a7..48f9452054b 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -433,7 +433,7 @@ public: void drawSurface(const Common::Point &p, const Graphics::Surface &surface, bool themeTrans = false); - void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled); + void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled, bool rtl = false); void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state = kStateEnabled, bool rtl = false); diff --git a/gui/widget.cpp b/gui/widget.cpp index 01183f99502..7e601218c4d 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -787,13 +787,7 @@ void SliderWidget::handleMouseWheel(int x, int y, int direction) { void SliderWidget::drawWidget() { Common::Rect r1(_x, _y, _x + _w, _y + _h); - - if (g_gui.useRTL() && _useRTL) { - // GUI TODO: This currently draws the numbers okay (Rightmost is 0, left goes high value), but renders incorrectly (colors should be inverted). - g_gui.theme()->drawSlider(r1, valueToBarWidth(getMaxValue() - _value), _state); - } else { - g_gui.theme()->drawSlider(r1, valueToBarWidth(_value), _state); - } + g_gui.theme()->drawSlider(r1, valueToBarWidth(_value), _state, (g_gui.useRTL() && _useRTL)); } int SliderWidget::valueToBarWidth(int value) {