From f55654f1bc7d914d86a2c2b55f503009b35577de Mon Sep 17 00:00:00 2001 From: aryanrawlani28 <aryanrawlani007@gmail.com> Date: Tue, 19 May 2020 05:13:33 +0530 Subject: [PATCH] GUI: RTL: Popup RTL Layout and Correctly draw them GUI: RTL: Correctly draw popups --- gui/ThemeEngine.cpp | 14 ++- gui/ThemeEngine.h | 6 +- gui/themes/scummremastered/remastered_gfx.stx | 114 ++++++++++++++++++ gui/widgets/popup.cpp | 5 +- 4 files changed, 129 insertions(+), 10 deletions(-) diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index b5ba735605b..a00e52a616c 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -181,6 +181,10 @@ static const DrawDataInfo kDrawDataDefaults[] = { {kDDPopUpHover, "popup_hover", kDrawLayerForeground, kDDPopUpIdle}, {kDDPopUpDisabled, "popup_disabled", kDrawLayerBackground, kDDNone}, + {kDDPopUpIdleRTL, "popup_idle_rtl", kDrawLayerBackground, kDDNone}, + {kDDPopUpHoverRTL, "popup_hover_rtl", kDrawLayerForeground, kDDPopUpIdleRTL}, + {kDDPopUpDisabledRTL, "popup_disabled_rtl", kDrawLayerBackground, kDDNone}, + {kDDCaret, "caret", kDrawLayerForeground, kDDNone}, {kDDSeparator, "separator", kDrawLayerBackground, kDDNone}, }; @@ -1168,18 +1172,18 @@ void ThemeEngine::drawCaret(const Common::Rect &r, bool erase) { drawDD(kDDCaret, r); } -void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state) { +void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, bool rtl) { if (!ready()) return; - DrawData dd = kDDPopUpIdle; + DrawData dd = rtl ? kDDPopUpIdleRTL : kDDPopUpIdle; if (state == kStateEnabled) - dd = kDDPopUpIdle; + dd = rtl ? kDDPopUpIdleRTL : kDDPopUpIdle; else if (state == kStateHighlight) - dd = kDDPopUpHover; + dd = rtl ? kDDPopUpHoverRTL : kDDPopUpHover; else if (state == kStateDisabled) - dd = kDDPopUpDisabled; + dd = rtl ? kDDPopUpDisabledRTL : kDDPopUpDisabled; drawDD(dd, r); diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index 965af5d04fc..4cbc2b38f6d 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -129,6 +129,10 @@ enum DrawData { kDDPopUpHover, kDDPopUpDisabled, + kDDPopUpIdleRTL, + kDDPopUpHoverRTL, + kDDPopUpDisabledRTL, + kDDCaret, kDDSeparator, kDrawDataMAX, @@ -442,7 +446,7 @@ public: void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scrollState); void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, - WidgetStateInfo state = kStateEnabled); + WidgetStateInfo state = kStateEnabled, bool rtl = false); void drawCaret(const Common::Rect &r, bool erase); diff --git a/gui/themes/scummremastered/remastered_gfx.stx b/gui/themes/scummremastered/remastered_gfx.stx index 6c0d7077a66..800ebea8ee0 100644 --- a/gui/themes/scummremastered/remastered_gfx.stx +++ b/gui/themes/scummremastered/remastered_gfx.stx @@ -524,6 +524,44 @@ horizontal_align = 'left' /> </drawdata> + <drawdata id = 'popup_idle_rtl' cache = 'false' resolution = 'y>399'> + <drawstep func = 'roundedsq' + radius = '5' + stroke = '1' + fg_color = 'lightgray2' + fill = 'background' + bg_color = 'dialog_background' + shadow = '1' + /> + + <drawstep func = 'triangle' + bg_color = 'shadowcolor' + fill = 'background' + width = '10' + height = '5' + xpos = 'left' + ypos = '10' + padding = '2, 0, 6, 0' + orientation = 'bottom' + /> + + <drawstep func = 'triangle' + bg_color = 'shadowcolor' + fill = 'background' + width = '10' + height = '5' + xpos = 'left' + ypos = '4' + padding = '2, 0, 6, 0' + orientation = 'top' + /> + + <text font = 'text_default' + text_color = 'color_normal' + vertical_align = 'center' + horizontal_align = 'right' + /> + </drawdata> <drawdata id = 'popup_idle' cache = 'false' resolution ='y<400'> <drawstep func = 'roundedsq' @@ -603,6 +641,44 @@ horizontal_align = 'left' /> </drawdata> + <drawdata id = 'popup_disabled_rtl' cache = 'false' resolution = 'y>399'> + <drawstep func = 'roundedsq' + stroke = '1' + fg_color = 'lightgray' + radius = '5' + fill = 'gradient' + gradient_start = 'dialog_background' + gradient_end = 'dialog_background' + shadow = '0' + /> + <drawstep func = 'triangle' + bg_color = 'shadowcolor' + fill = 'background' + width = '10' + height = '5' + xpos = 'left' + ypos = '10' + padding = '2, 0, 6, 0' + orientation = 'bottom' + /> + + <drawstep func = 'triangle' + bg_color = 'shadowcolor' + fill = 'background' + width = '10' + height = '5' + xpos = 'left' + ypos = '4' + padding = '2, 0, 6, 0' + orientation = 'top' + /> + + <text font = 'text_default' + text_color = 'color_normal_disabled' + vertical_align = 'center' + horizontal_align = 'right' + /> + </drawdata> <drawdata id = 'popup_disabled' cache = 'false' resolution = 'y<400'> <drawstep func = 'roundedsq' @@ -682,6 +758,44 @@ horizontal_align = 'left' /> </drawdata> + <drawdata id = 'popup_hover_rtl' cache = 'false' resolution = 'y>399'> + <drawstep func = 'roundedsq' + stroke = '1' + fg_color = 'lightgray' + radius = '5' + fill = 'gradient' + gradient_start = 'dialog_background' + gradient_end = 'dialog_background' + shadow = '0' + /> + <drawstep func = 'triangle' + bg_color = 'shadowcolor' + fill = 'background' + width = '10' + height = '5' + xpos = 'left' + ypos = '10' + padding = '2, 0, 6, 0' + orientation = 'bottom' + /> + + <drawstep func = 'triangle' + bg_color = 'shadowcolor' + fill = 'background' + width = '10' + height = '5' + xpos = 'left' + ypos = '4' + padding = '2, 0, 6, 0' + orientation = 'top' + /> + + <text font = 'text_default' + text_color = 'color_normal_hover' + vertical_align = 'center' + horizontal_align = 'right' + /> + </drawdata> <drawdata id = 'popup_hover' cache = 'false' resolution = 'y<400'> <drawstep func = 'roundedsq' diff --git a/gui/widgets/popup.cpp b/gui/widgets/popup.cpp index 018d57e328f..bebbf171bd0 100644 --- a/gui/widgets/popup.cpp +++ b/gui/widgets/popup.cpp @@ -528,10 +528,7 @@ void PopUpWidget::drawWidget() { if (_selectedItem >= 0) sel = _entries[_selectedItem].name; - if (g_gui.useRTL()) - _x = g_system->getOverlayWidth() - _x - _w; - - g_gui.theme()->drawPopUpWidget(Common::Rect(_x, _y, _x + _w, _y + _h), sel, _leftPadding, _state); + g_gui.theme()->drawPopUpWidget(Common::Rect(_x, _y, _x + _w, _y + _h), sel, _leftPadding, _state, (g_gui.useRTL() && _useRTL)); } } // End of namespace GUI