From a0eb91d6aba449ff51a49b9396bd98c52e3b89ff Mon Sep 17 00:00:00 2001 From: poire-z Date: Thu, 10 Dec 2020 23:53:33 +0100 Subject: [PATCH] Some RTL UI fix up after #6885 (#6975) Avoid crash with RTL UI after options we moved. Swap Zoom direction items when RTL UI. Also don't check show_func when sizing the names on the bottom menu, to avoid icons moving or resizing when toggling options. --- frontend/ui/data/koptoptions.lua | 13 ++++++++++++- frontend/ui/widget/configdialog.lua | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/frontend/ui/data/koptoptions.lua b/frontend/ui/data/koptoptions.lua index 833e85bfb..ec0353d20 100644 --- a/frontend/ui/data/koptoptions.lua +++ b/frontend/ui/data/koptoptions.lua @@ -1,6 +1,7 @@ local BD = require("ui/bidi") local Device = require("device") local optionsutil = require("ui/data/optionsutil") +local util = require("util") local _ = require("gettext") local C_ = _.pgettext local Screen = Device.screen @@ -551,11 +552,21 @@ if BD.mirroredUILayout() then -- be mirrored - but that's not enough: we need to swap LEFT and RIGHT, -- so they appear in a more expected and balanced order to RTL users: -- {JUSTIFY, LEFT, CENTER, RIGHT, AUTO} - local j = KoptOptions[3].options[5] + local j = KoptOptions[4].options[5] assert(j.name == "justification") j.item_icons[2], j.item_icons[4] = j.item_icons[4], j.item_icons[2] j.values[2], j.values[4] = j.values[4], j.values[2] j.labels[2], j.labels[4] = j.labels[4], j.labels[2] + -- The zoom direction items will be mirrored, but we want them to + -- stay as is, as the RTL diretions are at the end of the arrays. + -- By reverting the mirroring, RTL directions will be on the right, + -- so, at the start of the options for a RTL reader. + j = KoptOptions[3].options[7] + assert(j.name == "zoom_direction") + util.arrayReverse(j.item_icons) + util.arrayReverse(j.values) + util.arrayReverse(j.args) + j.default_value = 0 end return KoptOptions diff --git a/frontend/ui/widget/configdialog.lua b/frontend/ui/widget/configdialog.lua index 52021eb10..aa9586c51 100644 --- a/frontend/ui/widget/configdialog.lua +++ b/frontend/ui/widget/configdialog.lua @@ -198,9 +198,14 @@ function ConfigOption:init() local show_default = not self.options[c].advanced or show_advanced local show = self.options[c].show -- Prefer show_func over show if there's one + -- Or may be not, as show_func is always used to show/hide some widget depending + -- on the value of another widget: it's best to keep it accounted for the names + -- max width, and avoid stuff moving when toggling options. + --[[ if self.options[c].show_func then show = self.options[c].show_func(self.config.configurable, self.config.document) end + ]]-- if show ~= false and show_default then local name_font_face = self.options[c].name_font_face and self.options[c].name_font_face or "cfont" local name_font_size = self.options[c].name_font_size and self.options[c].name_font_size or default_name_font_size