GUI: RTL: Support internal flipping of Sliders

This commit is contained in:
aryanrawlani28 2020-05-22 02:00:17 +05:30 committed by Eugene Sandulenko
parent 50aa421bf3
commit 4699880c99
3 changed files with 8 additions and 9 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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) {