GUI: RTL: Radiobuttons and Checkboxes RTL layout
This commit is contained in:
parent
d968665110
commit
143b9fb13c
4 changed files with 130 additions and 22 deletions
|
@ -152,10 +152,19 @@ static const DrawDataInfo kDrawDataDefaults[] = {
|
||||||
{kDDCheckboxSelected, "checkbox_selected", kDrawLayerForeground, kDDCheckboxDefault},
|
{kDDCheckboxSelected, "checkbox_selected", kDrawLayerForeground, kDDCheckboxDefault},
|
||||||
{kDDCheckboxDisabledSelected, "checkbox_disabled_selected", kDrawLayerForeground, kDDCheckboxDisabled},
|
{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},
|
{kDDRadiobuttonDefault, "radiobutton_default", kDrawLayerBackground, kDDNone},
|
||||||
{kDDRadiobuttonDisabled, "radiobutton_disabled", kDrawLayerBackground, kDDNone},
|
{kDDRadiobuttonDisabled, "radiobutton_disabled", kDrawLayerBackground, kDDNone},
|
||||||
{kDDRadiobuttonSelected, "radiobutton_selected", kDrawLayerForeground, kDDRadiobuttonDefault},
|
{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},
|
{kDDTabActive, "tab_active", kDrawLayerForeground, kDDTabInactive},
|
||||||
{kDDTabInactive, "tab_inactive", kDrawLayerBackground, kDDNone},
|
{kDDTabInactive, "tab_inactive", kDrawLayerBackground, kDDNone},
|
||||||
{kDDTabBackground, "tab_background", kDrawLayerBackground, kDDNone},
|
{kDDTabBackground, "tab_background", kDrawLayerBackground, kDDNone},
|
||||||
|
@ -995,59 +1004,79 @@ void ThemeEngine::drawLineSeparator(const Common::Rect &r) {
|
||||||
drawDD(kDDSeparator, 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())
|
if (!ready())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Common::Rect r2 = r;
|
Common::Rect r2 = r;
|
||||||
DrawData dd = kDDCheckboxDefault;
|
DrawData dd = rtl ? kDDCheckboxDefaultRTL : kDDCheckboxDefault;
|
||||||
|
|
||||||
if (checked)
|
if (checked)
|
||||||
dd = kDDCheckboxSelected;
|
dd = rtl ? kDDCheckboxSelectedRTL : kDDCheckboxSelected;
|
||||||
|
|
||||||
if (state == kStateDisabled)
|
if (state == kStateDisabled)
|
||||||
dd = checked ? kDDCheckboxDisabledSelected : kDDCheckboxDisabled;
|
dd = checked ? rtl ? kDDCheckboxDisabledSelectedRTL : kDDCheckboxDisabledSelected : rtl ? kDDCheckboxDisabledRTL : kDDCheckboxDisabled;
|
||||||
|
|
||||||
const int checkBoxSize = MIN((int)r.height(), getFontHeight());
|
const int checkBoxSize = MIN((int)r.height(), getFontHeight());
|
||||||
|
|
||||||
r2.bottom = r2.top + checkBoxSize;
|
r2.bottom = r2.top + checkBoxSize;
|
||||||
|
|
||||||
|
if (rtl) {
|
||||||
|
r2.left = r.right - checkBoxSize;
|
||||||
|
r2.right = r.right;
|
||||||
|
} else {
|
||||||
r2.right = r2.left + checkBoxSize;
|
r2.right = r2.left + checkBoxSize;
|
||||||
|
}
|
||||||
|
|
||||||
drawDD(dd, r2);
|
drawDD(dd, r2);
|
||||||
|
|
||||||
|
if (rtl) {
|
||||||
|
r2.left = r.left;
|
||||||
|
r2.right = r.right - (checkBoxSize * 2);
|
||||||
|
} else {
|
||||||
r2.left = r2.right + checkBoxSize;
|
r2.left = r2.right + checkBoxSize;
|
||||||
r2.right = r.right;
|
r2.right = r.right;
|
||||||
|
}
|
||||||
|
|
||||||
if (r2.right > r2.left) {
|
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);
|
_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())
|
if (!ready())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Common::Rect r2 = r;
|
Common::Rect r2 = r;
|
||||||
DrawData dd = kDDRadiobuttonDefault;
|
DrawData dd = rtl ? kDDRadiobuttonDefaultRTL : kDDRadiobuttonDefault;
|
||||||
|
|
||||||
if (checked)
|
if (checked)
|
||||||
dd = kDDRadiobuttonSelected;
|
dd = rtl ? kDDRadiobuttonSelectedRTL : kDDRadiobuttonSelected;
|
||||||
|
|
||||||
if (state == kStateDisabled)
|
if (state == kStateDisabled)
|
||||||
dd = kDDRadiobuttonDisabled;
|
dd = rtl ? kDDRadiobuttonDisabledRTL : kDDRadiobuttonDisabled;
|
||||||
|
|
||||||
const int radioButtonSize = MIN((int)r.height(), getFontHeight());
|
const int radioButtonSize = MIN((int)r.height(), getFontHeight());
|
||||||
|
|
||||||
r2.bottom = r2.top + radioButtonSize;
|
r2.bottom = r2.top + radioButtonSize;
|
||||||
|
|
||||||
|
if (rtl) {
|
||||||
|
r2.left = r.right - radioButtonSize;
|
||||||
|
r2.right = r.right;
|
||||||
|
} else {
|
||||||
r2.right = r2.left + radioButtonSize;
|
r2.right = r2.left + radioButtonSize;
|
||||||
|
}
|
||||||
|
|
||||||
drawDD(dd, r2);
|
drawDD(dd, r2);
|
||||||
|
|
||||||
|
if (rtl) {
|
||||||
|
r2.left = r.left;
|
||||||
|
r2.right = r.right - (radioButtonSize * 2);
|
||||||
|
} else {
|
||||||
r2.left = r2.right + radioButtonSize;
|
r2.left = r2.right + radioButtonSize;
|
||||||
r2.right = MAX(r2.left, r.right);
|
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);
|
_widgets[dd]->_textAlignV);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,10 +102,19 @@ enum DrawData {
|
||||||
kDDCheckboxSelected,
|
kDDCheckboxSelected,
|
||||||
kDDCheckboxDisabledSelected,
|
kDDCheckboxDisabledSelected,
|
||||||
|
|
||||||
|
kDDCheckboxDefaultRTL,
|
||||||
|
kDDCheckboxDisabledRTL,
|
||||||
|
kDDCheckboxSelectedRTL,
|
||||||
|
kDDCheckboxDisabledSelectedRTL,
|
||||||
|
|
||||||
kDDRadiobuttonDefault,
|
kDDRadiobuttonDefault,
|
||||||
kDDRadiobuttonDisabled,
|
kDDRadiobuttonDisabled,
|
||||||
kDDRadiobuttonSelected,
|
kDDRadiobuttonSelected,
|
||||||
|
|
||||||
|
kDDRadiobuttonDefaultRTL,
|
||||||
|
kDDRadiobuttonDisabledRTL,
|
||||||
|
kDDRadiobuttonSelectedRTL,
|
||||||
|
|
||||||
kDDTabActive,
|
kDDTabActive,
|
||||||
kDDTabInactive,
|
kDDTabInactive,
|
||||||
kDDTabBackground,
|
kDDTabBackground,
|
||||||
|
@ -422,10 +431,10 @@ public:
|
||||||
void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled);
|
void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled);
|
||||||
|
|
||||||
void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked,
|
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,
|
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,
|
void drawTab(const Common::Rect &r, int tabHeight, const Common::Array<int> &tabWidths,
|
||||||
const Common::Array<Common::String> &tabs, int active);
|
const Common::Array<Common::String> &tabs, int active);
|
||||||
|
|
|
@ -1264,6 +1264,16 @@
|
||||||
file = 'checkbox_disabled.bmp'
|
file = 'checkbox_disabled.bmp'
|
||||||
/>
|
/>
|
||||||
</drawdata>
|
</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 -->
|
<!-- Disabled checkbox -->
|
||||||
<drawdata id = 'checkbox_disabled' cache = 'false'>
|
<drawdata id = 'checkbox_disabled' cache = 'false'>
|
||||||
|
@ -1276,6 +1286,16 @@
|
||||||
file = 'checkbox_empty.bmp'
|
file = 'checkbox_empty.bmp'
|
||||||
/>
|
/>
|
||||||
</drawdata>
|
</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 -->
|
<!-- Selected checkbox -->
|
||||||
<drawdata id = 'checkbox_selected' cache = 'false'>
|
<drawdata id = 'checkbox_selected' cache = 'false'>
|
||||||
|
@ -1288,6 +1308,16 @@
|
||||||
file = 'checkbox.bmp'
|
file = 'checkbox.bmp'
|
||||||
/>
|
/>
|
||||||
</drawdata>
|
</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 -->
|
<!-- Idle checkbox -->
|
||||||
<drawdata id = 'checkbox_default' cache = 'false'>
|
<drawdata id = 'checkbox_default' cache = 'false'>
|
||||||
|
@ -1300,6 +1330,16 @@
|
||||||
file = 'checkbox_empty.bmp'
|
file = 'checkbox_empty.bmp'
|
||||||
/>
|
/>
|
||||||
</drawdata>
|
</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 -->
|
<!-- Idle radiobutton -->
|
||||||
<drawdata id = 'radiobutton_default' cache = 'false'>
|
<drawdata id = 'radiobutton_default' cache = 'false'>
|
||||||
|
@ -1312,6 +1352,16 @@
|
||||||
file = 'radiobutton_empty.bmp'
|
file = 'radiobutton_empty.bmp'
|
||||||
/>
|
/>
|
||||||
</drawdata>
|
</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 -->
|
<!-- Selected radiobutton -->
|
||||||
<drawdata id = 'radiobutton_selected' cache = 'false'>
|
<drawdata id = 'radiobutton_selected' cache = 'false'>
|
||||||
|
@ -1324,6 +1374,16 @@
|
||||||
file = 'radiobutton.bmp'
|
file = 'radiobutton.bmp'
|
||||||
/>
|
/>
|
||||||
</drawdata>
|
</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 -->
|
<!-- Disabled radiobutton -->
|
||||||
<drawdata id = 'radiobutton_disabled' cache = 'false'>
|
<drawdata id = 'radiobutton_disabled' cache = 'false'>
|
||||||
|
@ -1336,6 +1396,16 @@
|
||||||
file = 'radiobutton_empty.bmp'
|
file = 'radiobutton_empty.bmp'
|
||||||
/>
|
/>
|
||||||
</drawdata>
|
</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) -->
|
<!-- 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) -->
|
<!-- 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() {
|
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 -
|
#pragma mark -
|
||||||
|
@ -718,7 +718,7 @@ void RadiobuttonWidget::setState(bool state, bool setGroup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RadiobuttonWidget::drawWidget() {
|
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 -
|
#pragma mark -
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue