Module ui.bidi

Bidirectional text and UI mirroring setup and helpers.

There are 2 concepts we attempt to handle: - Text direction: Left-To-Right (LTR) or Right-To-Left (RTL) - UI elements mirroring: not-mirrored, or mirrored

These 2 concepts are somehow orthogonal to each other in their implementation, even if in the real world there are only 2 valid combinations: - LTR and not-mirrored: for western languages, CJK, Indic... - RTL and mirrored: for Arabic, Hebrew, Farsi and a few others.

Text direction is handled by the libkoreader-xtext.so C module, and the TextWidget and TextBoxWidget widgets that handle text aligment. We just need here to set the default global paragraph direction (that widgets can override if needed).

UI mirroring is to be handled by our widget themselves, with the help of a few functions defined here.

Fortunately, low level widgets like LeftContainer, RightContainer, FrameContainer, HorizontalGroup, OverlapGroup... will do most of the work. But some care must be taken in other widgets and apps when: - some arrow symbols are used (for next, previous, first, last...): they might need to be swapped, or some alternative symbols or images can be used. - some geometry arithmetic is done (e.g. detecting if a tap is on the right part of screen, to go forward), which need to be adapted/reversed. - handling left or right swipe, whose action might need to be reversed - some TextBoxWidget/InputText might need to be forced to be LTR (when showing HTML or CSS code, or entering URLs, path...)

Some overview at: https://material.io/design/usability/bidirectionality.html



generated by LDoc 1.4.6 Last updated 2020-10-26 12:15:37