Browse Source

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.
reviewable/pr6979/r1
poire-z 11 months ago
committed by GitHub
parent
commit
a0eb91d6ab
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions
  1. +12
    -1
      frontend/ui/data/koptoptions.lua
  2. +5
    -0
      frontend/ui/widget/configdialog.lua

+ 12
- 1
frontend/ui/data/koptoptions.lua View File

@ -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

+ 5
- 0
frontend/ui/widget/configdialog.lua View File

@ -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

Loading…
Cancel
Save