https://wiki.scummvm.org/index.php?title=RTL_(Right-to-Left)_based_GUI&feed=atom&action=historyRTL (Right-to-Left) based GUI - Revision history2024-03-28T09:46:47ZRevision history for this page on the wikiMediaWiki 1.36.0https://wiki.scummvm.org/index.php?title=RTL_(Right-to-Left)_based_GUI&diff=28601&oldid=prevAryanrawlani28: Aryanrawlani28 moved page RTL based GUI to RTL (Right-to-Left) based GUI: add fullform to the title2020-06-24T20:51:43Z<p>Aryanrawlani28 moved page <a href="/index.php?title=RTL_based_GUI" class="mw-redirect" title="RTL based GUI">RTL based GUI</a> to <a href="/index.php?title=RTL_(Right-to-Left)_based_GUI" title="RTL (Right-to-Left) based GUI">RTL (Right-to-Left) based GUI</a>: add fullform to the title</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 20:51, 24 June 2020</td>
</tr>
<!-- diff cache key wiki-wiki_:diff::1.12:old-28599:rev-28601 -->
</table>Aryanrawlani28https://wiki.scummvm.org/index.php?title=RTL_(Right-to-Left)_based_GUI&diff=28599&oldid=prevAryanrawlani28: Added RTL GUI contents. (picture demonstrations remain to be added)2020-06-24T20:48:41Z<p>Added RTL GUI contents. (picture demonstrations remain to be added)</p>
<p><b>New page</b></p><div>==RTL GUI Overview==<br />
<br />
'''What is this about?'''<br><br />
The latest developmental build of ScummVM now supports an RTL based GUI. The main purpose of this is to adapt to RTL languages such as Hebrew, Arabic, etc.<br><br />
RTL means Right-To-Left. RTL users read their content beginning from the right and then moving towards the left.<br />
<br />
<br>'''In ScummVM'''<br><br />
If you want to preview how it looks (keep in mind that these will work on the latest developmental branch), you can add a "guiRTL = true" key in the scummvm.ini configuration file to force RTL. Or, you can switch a native RTL language. (Currently, it is only enabled for Hebrew)<br />
<br />
<br>'''How does it work?'''<br><br />
The main constructs to enable RTL, within the code are:<br><br />
# Main GUI-RTL, which you can check via g_gui.useRTL(). This is currently only enabled for Hebrew, but more languages can be added in GuiManager::setLanguageRTL() (located in gui/gui-manager.cpp) <br />
# RTL for an individual widget, which is checked via _useRTL (for each GUI object). <br>_useRTL is true by default. This shouldn't be a concern, because it always checks g_gui.useRTL() whenever working in an RTL based GUI.<br />
# Overlaying Offset - this is used in the context of a stacked dialog. More information below.<br />
<br />
<br>'''I am adding some things to GUI, I would also like them to support RTL.'''<br><br />
The following section has some notes that are needed to be kept in mind when designing new items or additions to the GUI - to adapt to RTL also.<br />
<br />
<br />
==RTL based GUI in code:==<br />
===General notes===<br />
- The mouse coordinates are not calculated differently for RTL based GUI. They are just flipped from the normal GUI, so this shouldn't be a problem when creating new things within the GUI.<br><br />
- Everything in the normal GUI will basically be flipped around, by calculating the reverse coordinates on the go.<br><br />
<br />
===Stacked Dialogs===<br />
If you are creating a stacked dialog, you will need to do the following things to adapt it for the RTL counterpart:<br><br />
<br />
# Navigate to ThemeLayout.cpp, in <code>ThemeLayoutMain::reflowLayout()</code><br><br />
# Within there, you'll see a check like <code>if (g_gui.useRTL) then if (_name......)</code><br><br />
# Simply add the name of the stacked dialog here like:<br />
<code>this->_name == "stacked-dialog-name"</code><br><br />
<br />
This sets the left+right coordinates of the stacked dialog.<br />
(Picture below)<br><br><br />
<br />
# Navigate to Widget.cpp, in <code>Widget::draw()</code>. <br><br />
# Within there, you'll see a check like <code>if (g_gui.useRTL()) then if (_name.....) </code><br><br />
# Simply add the name of the stacked dialog here like:<br />
<code>this->_name.contains("stacked-dialog-name")</code> <br><br />
<br />
<br>'''Why do I need to add these things for stacked dialogs?'''<br><br />
The reason why we make this modification in Widget::draw(), is to shift the widgets when a stacked dialog is opened. This shift is added by calling g_gui.getOverlayOffset(), which is set when the name of the stacked dialog is added in ThemeLayout.cpp. This is set to 0 when the stacked dialog is closed.<br />
<br />
<br />
==RTL Widgets:==<br />
<br />
Some widgets are supposed to look differently for RTL. Here is an example:<br />
<br />
If you're adding in support for a new widget, and also want to add in support for it's RTL counterpart - but wish to keep it disabled by default:<br />
Navigate to the ..._layout.stx and set<br />
<code>rtl = 'no'</code><br />
<br />
This will disable _useRTL, effectively disabling it by default. One such example currently is SliderWidgets.</div>Aryanrawlani28