GUI: RTL: Internal flipping for DropDownButton

This commit is contained in:
aryanrawlani28 2020-05-18 02:56:10 +05:30 committed by Eugene Sandulenko
parent 37c5013ef4
commit a587624cb3
4 changed files with 138 additions and 10 deletions

View file

@ -137,6 +137,12 @@ static const DrawDataInfo kDrawDataDefaults[] = {
{kDDDropDownButtonPressedLeft, "dropdown_button_pressed_left", kDrawLayerForeground, kDDDropDownButtonIdle}, {kDDDropDownButtonPressedLeft, "dropdown_button_pressed_left", kDrawLayerForeground, kDDDropDownButtonIdle},
{kDDDropDownButtonPressedRight, "dropdown_button_pressed_right", 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}, {kDDSliderFull, "slider_full", kDrawLayerForeground, kDDNone},
{kDDSliderHover, "slider_hover", kDrawLayerForeground, kDDNone}, {kDDSliderHover, "slider_hover", kDrawLayerForeground, kDDNone},
{kDDSliderDisabled, "slider_disabled", 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, 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()) if (!ready())
return; return;
DrawData dd; DrawData dd;
if (buttonState == kStateHighlight && inButton) if (buttonState == kStateHighlight && inButton)
dd = kDDDropDownButtonHoverLeft; dd = rtl ? kDDDropDownButtonHoverLeftRTL : kDDDropDownButtonHoverLeft;
else if (buttonState == kStateHighlight && inDropdown) else if (buttonState == kStateHighlight && inDropdown)
dd = kDDDropDownButtonHoverRight; dd = rtl ? kDDDropDownButtonHoverRightRTL : kDDDropDownButtonHoverRight;
else if (buttonState == kStateDisabled) else if (buttonState == kStateDisabled)
dd = kDDDropDownButtonDisabled; dd = kDDDropDownButtonDisabled;
else if (buttonState == kStatePressed && inButton) else if (buttonState == kStatePressed && inButton)
dd = kDDDropDownButtonPressedLeft; dd = rtl ? kDDDropDownButtonPressedLeftRTL : kDDDropDownButtonPressedLeft;
else if (buttonState == kStatePressed && inDropdown) else if (buttonState == kStatePressed && inDropdown)
dd = kDDDropDownButtonPressedRight; dd = rtl ? kDDDropDownButtonPressedRightRTL : kDDDropDownButtonPressedRight;
else else
dd = kDDDropDownButtonIdle; dd = rtl ? kDDDropDownButtonIdleRTL : kDDDropDownButtonIdle;
drawDD(dd, r); drawDD(dd, r);

View file

@ -87,6 +87,12 @@ enum DrawData {
kDDDropDownButtonPressedLeft, kDDDropDownButtonPressedLeft,
kDDDropDownButtonPressedRight, kDDDropDownButtonPressedRight,
kDDDropDownButtonIdleRTL,
kDDDropDownButtonHoverLeftRTL,
kDDDropDownButtonHoverRightRTL,
kDDDropDownButtonPressedLeftRTL,
kDDDropDownButtonPressedRightRTL,
kDDSliderFull, kDDSliderFull,
kDDSliderHover, kDDSliderHover,
kDDSliderDisabled, kDDSliderDisabled,
@ -409,7 +415,7 @@ public:
uint16 hints = 0); uint16 hints = 0);
void drawDropDownButton(const Common::Rect &r, uint32 dropdownWidth, const Common::String &str, 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); void drawSurface(const Common::Point &p, const Graphics::Surface &surface, bool themeTrans = false);

View file

@ -880,6 +880,30 @@
orientation = 'bottom' orientation = 'bottom'
/> />
</drawdata> </drawdata>
<drawdata id = 'dropdown_button_idle_rtl' cache = 'false' resolution = 'y>399'>
<text font = 'text_button'
text_color = 'color_button'
vertical_align = 'center'
horizontal_align = 'center'
/>
<drawstep func = 'roundedsq'
radius = '5'
fill = 'foreground'
shadow = '2'
fg_color = 'button_idle'
clip = '0,0,0,0'
/>
<drawstep func = 'triangle'
fg_color = 'white'
fill = 'foreground'
width = '8'
height = '6'
xpos = 'left'
ypos = 'center'
padding = '2,0,2,0'
orientation = 'bottom'
/>
</drawdata>
<drawdata id = 'dropdown_button_idle' cache = 'false' resolution = 'y<400'> <drawdata id = 'dropdown_button_idle' cache = 'false' resolution = 'y<400'>
<text font = 'text_button' <text font = 'text_button'
text_color = 'color_button' text_color = 'color_button'
@ -927,6 +951,29 @@
orientation = 'bottom' orientation = 'bottom'
/> />
</drawdata> </drawdata>
<drawdata id = 'dropdown_button_hover_left_rtl' cache = 'false' resolution = 'y>399'>
<text font = 'text_button'
text_color = 'color_button'
vertical_align = 'center'
horizontal_align = 'center'
/>
<drawstep func = 'roundedsq'
radius = '5'
fill = 'foreground'
fg_color = 'button_hover'
clip = '13,0,0,0'
/>
<drawstep func = 'triangle'
fg_color = 'white'
fill = 'foreground'
width = '8'
height = '6'
xpos = 'left'
ypos = 'center'
padding = '2,0,2,0'
orientation = 'bottom'
/>
</drawdata>
<drawdata id = 'dropdown_button_hover_left' cache = 'false' resolution = 'y<400'> <drawdata id = 'dropdown_button_hover_left' cache = 'false' resolution = 'y<400'>
<text font = 'text_button' <text font = 'text_button'
text_color = 'color_button' text_color = 'color_button'
@ -974,6 +1021,29 @@
orientation = 'bottom' orientation = 'bottom'
/> />
</drawdata> </drawdata>
<drawdata id = 'dropdown_button_hover_right_rtl' cache = 'false' resolution = 'y>399'>
<text font = 'text_button'
text_color = 'color_button'
vertical_align = 'center'
horizontal_align = 'center'
/>
<drawstep func = 'roundedsq'
radius = '5'
fill = 'foreground'
fg_color = 'button_hover'
clip = '0,0,13,0'
/>
<drawstep func = 'triangle'
fg_color = 'white'
fill = 'foreground'
width = '8'
height = '6'
xpos = 'left'
ypos = 'center'
padding = '2,0,2,0'
orientation = 'bottom'
/>
</drawdata>
<drawdata id = 'dropdown_button_hover_right' cache = 'false' resolution = 'y<400'> <drawdata id = 'dropdown_button_hover_right' cache = 'false' resolution = 'y<400'>
<text font = 'text_button' <text font = 'text_button'
text_color = 'color_button' text_color = 'color_button'
@ -1066,6 +1136,29 @@
orientation = 'bottom' orientation = 'bottom'
/> />
</drawdata> </drawdata>
<drawdata id = 'dropdown_button_pressed_left_rtl' cache = 'false' resolution = 'y>399'>
<text font = 'text_button'
text_color = 'color_button'
vertical_align = 'center'
horizontal_align = 'center'
/>
<drawstep func = 'roundedsq'
radius = '5'
fill = 'foreground'
fg_color = 'button_pressed'
clip = '0,0,-13,0'
/>
<drawstep func = 'triangle'
fg_color = 'white'
fill = 'foreground'
width = '8'
height = '6'
xpos = 'left'
ypos = 'center'
padding = '2,0,2,0'
orientation = 'bottom'
/>
</drawdata>
<drawdata id = 'dropdown_button_pressed_left' cache = 'false' resolution = 'y<400'> <drawdata id = 'dropdown_button_pressed_left' cache = 'false' resolution = 'y<400'>
<text font = 'text_button' <text font = 'text_button'
text_color = 'color_button' text_color = 'color_button'
@ -1113,6 +1206,29 @@
orientation = 'bottom' orientation = 'bottom'
/> />
</drawdata> </drawdata>
<drawdata id = 'dropdown_button_pressed_right_rtl' cache = 'false' resolution = 'y>399'>
<text font = 'text_button'
text_color = 'color_button'
vertical_align = 'center'
horizontal_align = 'center'
/>
<drawstep func = 'roundedsq'
radius = '5'
fill = 'foreground'
fg_color = 'button_pressed'
clip = '0,0,13,0'
/>
<drawstep func = 'triangle'
fg_color = 'white'
fill = 'foreground'
width = '8'
height = '6'
xpos = 'left'
ypos = 'center'
padding = '2,0,2,0'
orientation = 'bottom'
/>
</drawdata>
<drawdata id = 'dropdown_button_pressed_right' cache = 'false' resolution = 'y<400'> <drawdata id = 'dropdown_button_pressed_right' cache = 'false' resolution = 'y<400'>
<text font = 'text_button' <text font = 'text_button'
text_color = 'color_button' text_color = 'color_button'

View file

@ -118,8 +118,7 @@ void Widget::draw() {
if (g_gui.useRTL()) { if (g_gui.useRTL()) {
_x = g_system->getOverlayWidth() - _x - _w; _x = g_system->getOverlayWidth() - _x - _w;
// if (g_gui.isWindowOverlayed()) { // Can i use something better below instead of hardcoding the values?
// Can i use something better below?
if (this->_name.contains("GameOptions") || this->_name.contains("GlobalOptions")){ if (this->_name.contains("GameOptions") || this->_name.contains("GlobalOptions")){
_x = _x + g_gui.getOverlayOffset(); _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); g_gui.theme()->drawButton(Common::Rect(_x, _y, _x + _w, _y + _h), _label, _state);
} else { } else {
g_gui.theme()->drawDropDownButton(Common::Rect(_x, _y, _x + _w, _y + _h), _dropdownWidth, _label, g_gui.theme()->drawDropDownButton(Common::Rect(_x, _y, _x + _w, _y + _h), _dropdownWidth, _label,
_state, _inButton, _inDropdown); _state, _inButton, _inDropdown, (g_gui.useRTL() && _useRTL));
} }
} }