JFLib

ui/rtl.rs#

Source: lib/ui/rtl.rs

rtl -- right-to-left layout: every window mirrored as a whole (as Windows' WS_EX_LAYOUTRTL)

  rtl() -> bool                    the windows are mirrored now
  set_rtl(Some(on) | None)         force it, or None: from the UI language (Arabic, Hebrew,
                                   Persian, Urdu, ...: i18n::rtl_language); command line
                                   --rtl / --ltr
  ltr_begin(x, w) / ltr_end()      a region of the window whose content keeps its reading
                                   order (text fields, canvases, colour pads): it moves to its
                                   mirrored place as a whole
  ltr_x(x) -> x                    a logical x (the pointer: wp.ctx.mx) inside the outermost
                                   open region, so the region's own maths stays LTR

Layout and hit testing stay in logical (LTR) coordinates: a box's first child is its
logical start.  Before a window is rendered, every recorded command is mirrored across
it (cmd_mirror): boxes, clips, lines and shapes flip; text, images and custom drawings
move but keep their direction; directional icons (chevrons, back / forward, undo / redo,
indent) are swapped for their mirror images.  Input comes back the same way: the pointer x
is mirrored, a horizontal wheel turns round, plain Left / Right swap (text fields swap
them back).  What leaves the UI is physical: sems (scripts, the agent), popup rects of OS
popup windows, the platform's hit tests, resize edges and the IME caret.

impl Ui

  • fn rtl(&self) -> bool the windows are mirrored now (right-to-left layout)
  • fn set_rtl(&mut self, on: Option<bool>) mirror the windows (Some(true)), never (Some(false)) or as the UI language reads (None)
  • fn ltr_begin(&mut self, x: i32, w: i32) ltr_begin(x, w): the following commands of this layer keep their LTR order inside the columns x .. x + w (px); pairs with ltr_end
  • fn ltr_end(&mut self) close the region of ltr_begin
  • fn ltr_x(&self, x: i32) -> i32 a logical x (the pointer) as the open ltr_begin region sees it: its content is not mirrored, so the pointer is mirrored back across the region
  • fn rtl_map(&self, x: i32, ix: i32, iw: i32) -> i32 rtl_map(x, ix, iw): a logical x as a region ix .. ix + iw that keeps its LTR content sees it (the same before its ltr_begin)

Source: docs/API.md in the JFLib repository.