mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-08 01:31:49 +00:00
GUI: RTL: Radiobuttons and Checkboxes RTL layout
This commit is contained in:
parent
d968665110
commit
143b9fb13c
@ -152,10 +152,19 @@ static const DrawDataInfo kDrawDataDefaults[] = {
|
||||
{kDDCheckboxSelected, "checkbox_selected", kDrawLayerForeground, kDDCheckboxDefault},
|
||||
{kDDCheckboxDisabledSelected, "checkbox_disabled_selected", kDrawLayerForeground, kDDCheckboxDisabled},
|
||||
|
||||
{kDDCheckboxDefaultRTL, "checkbox_default_rtl", kDrawLayerBackground, kDDNone},
|
||||
{kDDCheckboxDisabledRTL, "checkbox_disabled_rtl", kDrawLayerBackground, kDDNone},
|
||||
{kDDCheckboxSelectedRTL, "checkbox_selected_rtl", kDrawLayerForeground, kDDCheckboxDefaultRTL},
|
||||
{kDDCheckboxDisabledSelectedRTL, "checkbox_disabled_selected_rtl", kDrawLayerForeground, kDDCheckboxDisabledRTL},
|
||||
|
||||
{kDDRadiobuttonDefault, "radiobutton_default", kDrawLayerBackground, kDDNone},
|
||||
{kDDRadiobuttonDisabled, "radiobutton_disabled", kDrawLayerBackground, kDDNone},
|
||||
{kDDRadiobuttonSelected, "radiobutton_selected", kDrawLayerForeground, kDDRadiobuttonDefault},
|
||||
|
||||
{kDDRadiobuttonDefaultRTL, "radiobutton_default_rtl", kDrawLayerBackground, kDDNone},
|
||||
{kDDRadiobuttonDisabledRTL, "radiobutton_disabled_rtl", kDrawLayerBackground, kDDNone},
|
||||
{kDDRadiobuttonSelectedRTL, "radiobutton_selected_rtl", kDrawLayerForeground, kDDRadiobuttonDefaultRTL},
|
||||
|
||||
{kDDTabActive, "tab_active", kDrawLayerForeground, kDDTabInactive},
|
||||
{kDDTabInactive, "tab_inactive", kDrawLayerBackground, kDDNone},
|
||||
{kDDTabBackground, "tab_background", kDrawLayerBackground, kDDNone},
|
||||
@ -995,59 +1004,79 @@ void ThemeEngine::drawLineSeparator(const Common::Rect &r) {
|
||||
drawDD(kDDSeparator, r);
|
||||
}
|
||||
|
||||
void ThemeEngine::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) {
|
||||
void ThemeEngine::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state, bool rtl) {
|
||||
if (!ready())
|
||||
return;
|
||||
|
||||
Common::Rect r2 = r;
|
||||
DrawData dd = kDDCheckboxDefault;
|
||||
DrawData dd = rtl ? kDDCheckboxDefaultRTL : kDDCheckboxDefault;
|
||||
|
||||
if (checked)
|
||||
dd = kDDCheckboxSelected;
|
||||
dd = rtl ? kDDCheckboxSelectedRTL : kDDCheckboxSelected;
|
||||
|
||||
if (state == kStateDisabled)
|
||||
dd = checked ? kDDCheckboxDisabledSelected : kDDCheckboxDisabled;
|
||||
dd = checked ? rtl ? kDDCheckboxDisabledSelectedRTL : kDDCheckboxDisabledSelected : rtl ? kDDCheckboxDisabledRTL : kDDCheckboxDisabled;
|
||||
|
||||
const int checkBoxSize = MIN((int)r.height(), getFontHeight());
|
||||
|
||||
r2.bottom = r2.top + checkBoxSize;
|
||||
r2.right = r2.left + checkBoxSize;
|
||||
|
||||
if (rtl) {
|
||||
r2.left = r.right - checkBoxSize;
|
||||
r2.right = r.right;
|
||||
} else {
|
||||
r2.right = r2.left + checkBoxSize;
|
||||
}
|
||||
|
||||
drawDD(dd, r2);
|
||||
|
||||
r2.left = r2.right + checkBoxSize;
|
||||
r2.right = r.right;
|
||||
if (rtl) {
|
||||
r2.left = r.left;
|
||||
r2.right = r.right - (checkBoxSize * 2);
|
||||
} else {
|
||||
r2.left = r2.right + checkBoxSize;
|
||||
r2.right = r.right;
|
||||
}
|
||||
|
||||
if (r2.right > r2.left) {
|
||||
drawDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, _widgets[kDDCheckboxDefault]->_textAlignH,
|
||||
drawDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, _widgets[dd]->_textAlignH,
|
||||
_widgets[dd]->_textAlignV);
|
||||
}
|
||||
}
|
||||
|
||||
void ThemeEngine::drawRadiobutton(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) {
|
||||
void ThemeEngine::drawRadiobutton(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state, bool rtl) {
|
||||
if (!ready())
|
||||
return;
|
||||
|
||||
Common::Rect r2 = r;
|
||||
DrawData dd = kDDRadiobuttonDefault;
|
||||
DrawData dd = rtl ? kDDRadiobuttonDefaultRTL : kDDRadiobuttonDefault;
|
||||
|
||||
if (checked)
|
||||
dd = kDDRadiobuttonSelected;
|
||||
dd = rtl ? kDDRadiobuttonSelectedRTL : kDDRadiobuttonSelected;
|
||||
|
||||
if (state == kStateDisabled)
|
||||
dd = kDDRadiobuttonDisabled;
|
||||
dd = rtl ? kDDRadiobuttonDisabledRTL : kDDRadiobuttonDisabled;
|
||||
|
||||
const int radioButtonSize = MIN((int)r.height(), getFontHeight());
|
||||
|
||||
r2.bottom = r2.top + radioButtonSize;
|
||||
r2.right = r2.left + radioButtonSize;
|
||||
|
||||
if (rtl) {
|
||||
r2.left = r.right - radioButtonSize;
|
||||
r2.right = r.right;
|
||||
} else {
|
||||
r2.right = r2.left + radioButtonSize;
|
||||
}
|
||||
|
||||
drawDD(dd, r2);
|
||||
|
||||
r2.left = r2.right + radioButtonSize;
|
||||
r2.right = MAX(r2.left, r.right);
|
||||
if (rtl) {
|
||||
r2.left = r.left;
|
||||
r2.right = r.right - (radioButtonSize * 2);
|
||||
} else {
|
||||
r2.left = r2.right + radioButtonSize;
|
||||
r2.right = MAX(r2.left, r.right);
|
||||
}
|
||||
|
||||
drawDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, _widgets[kDDRadiobuttonDefault]->_textAlignH,
|
||||
drawDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, _widgets[dd]->_textAlignH,
|
||||
_widgets[dd]->_textAlignV);
|
||||
}
|
||||
|
||||
|
@ -102,10 +102,19 @@ enum DrawData {
|
||||
kDDCheckboxSelected,
|
||||
kDDCheckboxDisabledSelected,
|
||||
|
||||
kDDCheckboxDefaultRTL,
|
||||
kDDCheckboxDisabledRTL,
|
||||
kDDCheckboxSelectedRTL,
|
||||
kDDCheckboxDisabledSelectedRTL,
|
||||
|
||||
kDDRadiobuttonDefault,
|
||||
kDDRadiobuttonDisabled,
|
||||
kDDRadiobuttonSelected,
|
||||
|
||||
kDDRadiobuttonDefaultRTL,
|
||||
kDDRadiobuttonDisabledRTL,
|
||||
kDDRadiobuttonSelectedRTL,
|
||||
|
||||
kDDTabActive,
|
||||
kDDTabInactive,
|
||||
kDDTabBackground,
|
||||
@ -422,10 +431,10 @@ public:
|
||||
void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled);
|
||||
|
||||
void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked,
|
||||
WidgetStateInfo state = kStateEnabled);
|
||||
WidgetStateInfo state = kStateEnabled, bool rtl = false);
|
||||
|
||||
void drawRadiobutton(const Common::Rect &r, const Common::String &str, bool checked,
|
||||
WidgetStateInfo state = kStateEnabled);
|
||||
WidgetStateInfo state = kStateEnabled, bool rtl = false);
|
||||
|
||||
void drawTab(const Common::Rect &r, int tabHeight, const Common::Array<int> &tabWidths,
|
||||
const Common::Array<Common::String> &tabs, int active);
|
||||
|
@ -1264,6 +1264,16 @@
|
||||
file = 'checkbox_disabled.bmp'
|
||||
/>
|
||||
</drawdata>
|
||||
<drawdata id = 'checkbox_disabled_selected_rtl' cache = 'false'>
|
||||
<drawstep func = 'bitmap'
|
||||
file = 'checkbox_disabled.bmp'
|
||||
/>
|
||||
<text font = 'text_default'
|
||||
text_color = 'color_normal_disabled'
|
||||
vertical_align = 'top'
|
||||
horizontal_align = 'right'
|
||||
/>
|
||||
</drawdata>
|
||||
|
||||
<!-- Disabled checkbox -->
|
||||
<drawdata id = 'checkbox_disabled' cache = 'false'>
|
||||
@ -1276,6 +1286,16 @@
|
||||
file = 'checkbox_empty.bmp'
|
||||
/>
|
||||
</drawdata>
|
||||
<drawdata id = 'checkbox_disabled_rtl' cache = 'false'>
|
||||
<drawstep func = 'bitmap'
|
||||
file = 'checkbox_empty.bmp'
|
||||
/>
|
||||
<text font = 'text_default'
|
||||
text_color = 'color_normal_disabled'
|
||||
vertical_align = 'top'
|
||||
horizontal_align = 'right'
|
||||
/>
|
||||
</drawdata>
|
||||
|
||||
<!-- Selected checkbox -->
|
||||
<drawdata id = 'checkbox_selected' cache = 'false'>
|
||||
@ -1288,6 +1308,16 @@
|
||||
file = 'checkbox.bmp'
|
||||
/>
|
||||
</drawdata>
|
||||
<drawdata id = 'checkbox_selected_rtl' cache = 'false'>
|
||||
<drawstep func = 'bitmap'
|
||||
file = 'checkbox.bmp'
|
||||
/>
|
||||
<text font = 'text_default'
|
||||
text_color = 'color_normal'
|
||||
vertical_align = 'top'
|
||||
horizontal_align = 'right'
|
||||
/>
|
||||
</drawdata>
|
||||
|
||||
<!-- Idle checkbox -->
|
||||
<drawdata id = 'checkbox_default' cache = 'false'>
|
||||
@ -1300,6 +1330,16 @@
|
||||
file = 'checkbox_empty.bmp'
|
||||
/>
|
||||
</drawdata>
|
||||
<drawdata id = 'checkbox_default_rtl' cache = 'false'>
|
||||
<drawstep func = 'bitmap'
|
||||
file = 'checkbox_empty.bmp'
|
||||
/>
|
||||
<text font = 'text_default'
|
||||
text_color = 'color_normal'
|
||||
vertical_align = 'top'
|
||||
horizontal_align = 'right'
|
||||
/>
|
||||
</drawdata>
|
||||
|
||||
<!-- Idle radiobutton -->
|
||||
<drawdata id = 'radiobutton_default' cache = 'false'>
|
||||
@ -1312,6 +1352,16 @@
|
||||
file = 'radiobutton_empty.bmp'
|
||||
/>
|
||||
</drawdata>
|
||||
<drawdata id = 'radiobutton_default_rtl' cache = 'false'>
|
||||
<drawstep func = 'bitmap'
|
||||
file = 'radiobutton_empty.bmp'
|
||||
/>
|
||||
<text font = 'text_default'
|
||||
text_color = 'color_normal'
|
||||
vertical_align = 'center'
|
||||
horizontal_align = 'right'
|
||||
/>
|
||||
</drawdata>
|
||||
|
||||
<!-- Selected radiobutton -->
|
||||
<drawdata id = 'radiobutton_selected' cache = 'false'>
|
||||
@ -1324,6 +1374,16 @@
|
||||
file = 'radiobutton.bmp'
|
||||
/>
|
||||
</drawdata>
|
||||
<drawdata id = 'radiobutton_selected_rtl' cache = 'false'>
|
||||
<drawstep func = 'bitmap'
|
||||
file = 'radiobutton.bmp'
|
||||
/>
|
||||
<text font = 'text_default'
|
||||
text_color = 'color_normal'
|
||||
vertical_align = 'center'
|
||||
horizontal_align = 'right'
|
||||
/>
|
||||
</drawdata>
|
||||
|
||||
<!-- Disabled radiobutton -->
|
||||
<drawdata id = 'radiobutton_disabled' cache = 'false'>
|
||||
@ -1336,6 +1396,16 @@
|
||||
file = 'radiobutton_empty.bmp'
|
||||
/>
|
||||
</drawdata>
|
||||
<drawdata id = 'radiobutton_disabled_rtl' cache = 'false'>
|
||||
<drawstep func = 'bitmap'
|
||||
file = 'radiobutton_empty.bmp'
|
||||
/>
|
||||
<text font = 'text_default'
|
||||
text_color = 'color_normal_disabled'
|
||||
vertical_align = 'center'
|
||||
horizontal_align = 'right'
|
||||
/>
|
||||
</drawdata>
|
||||
|
||||
<!-- Background of the list widget (the games list and the list in the choosers) -->
|
||||
<!-- TODO: Have separate options for the games list (with gradient background) and the list in the choosers (without gradient) -->
|
||||
|
@ -649,7 +649,7 @@ void CheckboxWidget::setState(bool state) {
|
||||
}
|
||||
|
||||
void CheckboxWidget::drawWidget() {
|
||||
g_gui.theme()->drawCheckbox(Common::Rect(_x, _y, _x + _w, _y + _h), _label, _state, Widget::_state);
|
||||
g_gui.theme()->drawCheckbox(Common::Rect(_x, _y, _x + _w, _y + _h), _label, _state, Widget::_state, (g_gui.useRTL() && _useRTL));
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
@ -718,7 +718,7 @@ void RadiobuttonWidget::setState(bool state, bool setGroup) {
|
||||
}
|
||||
|
||||
void RadiobuttonWidget::drawWidget() {
|
||||
g_gui.theme()->drawRadiobutton(Common::Rect(_x, _y, _x + _w, _y + _h), _label, _state, Widget::_state);
|
||||
g_gui.theme()->drawRadiobutton(Common::Rect(_x, _y, _x + _w, _y + _h), _label, _state, Widget::_state, (g_gui.useRTL() && _useRTL));
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
Loading…
x
Reference in New Issue
Block a user