From a587624cb35935af14e45bfebd6865a96cade089 Mon Sep 17 00:00:00 2001 From: aryanrawlani28 Date: Mon, 18 May 2020 02:56:10 +0530 Subject: [PATCH] GUI: RTL: Internal flipping for DropDownButton --- gui/ThemeEngine.cpp | 19 ++- gui/ThemeEngine.h | 8 +- gui/themes/scummremastered/remastered_gfx.stx | 116 ++++++++++++++++++ gui/widget.cpp | 5 +- 4 files changed, 138 insertions(+), 10 deletions(-) diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 506b1034662..dffb0414078 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -137,6 +137,12 @@ static const DrawDataInfo kDrawDataDefaults[] = { {kDDDropDownButtonPressedLeft, "dropdown_button_pressed_left", kDrawLayerForeground, kDDDropDownButtonIdle}, {kDDDropDownButtonPressedRight, "dropdown_button_pressed_right", kDrawLayerForeground, kDDDropDownButtonIdle}, + {kDDDropDownButtonIdleRTL, "dropdown_button_idle_rtl", kDrawLayerBackground, kDDNone}, + {kDDDropDownButtonHoverLeftRTL, "dropdown_button_hover_left_rtl", kDrawLayerForeground, kDDDropDownButtonIdleRTL}, + {kDDDropDownButtonHoverRightRTL, "dropdown_button_hover_right_rtl", kDrawLayerForeground, kDDDropDownButtonIdleRTL}, + {kDDDropDownButtonPressedLeftRTL, "dropdown_button_pressed_left_rtl", kDrawLayerForeground, kDDDropDownButtonIdleRTL}, + {kDDDropDownButtonPressedRightRTL, "dropdown_button_pressed_right_rtl", kDrawLayerForeground, kDDDropDownButtonIdleRTL}, + {kDDSliderFull, "slider_full", kDrawLayerForeground, kDDNone}, {kDDSliderHover, "slider_hover", kDrawLayerForeground, kDDNone}, {kDDSliderDisabled, "slider_disabled", kDrawLayerForeground, kDDNone}, @@ -953,23 +959,24 @@ void ThemeEngine::drawButton(const Common::Rect &r, const Common::String &str, W } void ThemeEngine::drawDropDownButton(const Common::Rect &r, uint32 dropdownWidth, const Common::String &str, - ThemeEngine::WidgetStateInfo buttonState, bool inButton, bool inDropdown) { + ThemeEngine::WidgetStateInfo buttonState, bool inButton, bool inDropdown, bool rtl) { if (!ready()) return; DrawData dd; + if (buttonState == kStateHighlight && inButton) - dd = kDDDropDownButtonHoverLeft; + dd = rtl ? kDDDropDownButtonHoverLeftRTL : kDDDropDownButtonHoverLeft; else if (buttonState == kStateHighlight && inDropdown) - dd = kDDDropDownButtonHoverRight; + dd = rtl ? kDDDropDownButtonHoverRightRTL : kDDDropDownButtonHoverRight; else if (buttonState == kStateDisabled) dd = kDDDropDownButtonDisabled; else if (buttonState == kStatePressed && inButton) - dd = kDDDropDownButtonPressedLeft; + dd = rtl ? kDDDropDownButtonPressedLeftRTL : kDDDropDownButtonPressedLeft; else if (buttonState == kStatePressed && inDropdown) - dd = kDDDropDownButtonPressedRight; + dd = rtl ? kDDDropDownButtonPressedRightRTL : kDDDropDownButtonPressedRight; else - dd = kDDDropDownButtonIdle; + dd = rtl ? kDDDropDownButtonIdleRTL : kDDDropDownButtonIdle; drawDD(dd, r); diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index 14c3bc56eb3..46cdbfdcdc1 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -87,6 +87,12 @@ enum DrawData { kDDDropDownButtonPressedLeft, kDDDropDownButtonPressedRight, + kDDDropDownButtonIdleRTL, + kDDDropDownButtonHoverLeftRTL, + kDDDropDownButtonHoverRightRTL, + kDDDropDownButtonPressedLeftRTL, + kDDDropDownButtonPressedRightRTL, + kDDSliderFull, kDDSliderHover, kDDSliderDisabled, @@ -409,7 +415,7 @@ public: uint16 hints = 0); void drawDropDownButton(const Common::Rect &r, uint32 dropdownWidth, const Common::String &str, - WidgetStateInfo buttonState, bool inButton, bool inDropdown); + WidgetStateInfo buttonState, bool inButton, bool inDropdown, bool rtl = false); void drawSurface(const Common::Point &p, const Graphics::Surface &surface, bool themeTrans = false); diff --git a/gui/themes/scummremastered/remastered_gfx.stx b/gui/themes/scummremastered/remastered_gfx.stx index 5f7cbd572ce..2aa9a28c48c 100644 --- a/gui/themes/scummremastered/remastered_gfx.stx +++ b/gui/themes/scummremastered/remastered_gfx.stx @@ -880,6 +880,30 @@ orientation = 'bottom' /> + + + + + + + + + + + + + + + + + + + + + + + + + getOverlayWidth() - _x - _w; - // if (g_gui.isWindowOverlayed()) { - // Can i use something better below? + // Can i use something better below instead of hardcoding the values? if (this->_name.contains("GameOptions") || this->_name.contains("GlobalOptions")){ _x = _x + g_gui.getOverlayOffset(); @@ -533,7 +532,7 @@ void DropdownButtonWidget::drawWidget() { // These are okay, no need to flip a g_gui.theme()->drawButton(Common::Rect(_x, _y, _x + _w, _y + _h), _label, _state); } else { g_gui.theme()->drawDropDownButton(Common::Rect(_x, _y, _x + _w, _y + _h), _dropdownWidth, _label, - _state, _inButton, _inDropdown); + _state, _inButton, _inDropdown, (g_gui.useRTL() && _useRTL)); } }