2016-02-14 21:47:36 +00:00
|
|
|
--[[--
|
|
|
|
Widget that presents a multi-page to show key value pairs.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
local Foo = KeyValuePage:new{
|
|
|
|
title = "Statistics",
|
|
|
|
kv_pairs = {
|
|
|
|
{"Current period", "00:00:00"},
|
|
|
|
-- single or more "-" will generate a solid line
|
|
|
|
"----------------------------",
|
|
|
|
{"Page to read", "5"},
|
|
|
|
{"Time to read", "00:01:00"},
|
|
|
|
{"Press me", "will invoke the callback",
|
|
|
|
callback = function() print("hello") end },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
UIManager:show(Foo)
|
|
|
|
|
|
|
|
]]
|
|
|
|
|
2019-12-06 21:55:39 +00:00
|
|
|
local BD = require("ui/bidi")
|
2016-02-14 21:47:36 +00:00
|
|
|
local Blitbuffer = require("ffi/blitbuffer")
|
2017-08-02 17:17:56 +00:00
|
|
|
local BottomContainer = require("ui/widget/container/bottomcontainer")
|
|
|
|
local Button = require("ui/widget/button")
|
2017-04-25 16:49:39 +00:00
|
|
|
local Device = require("device")
|
|
|
|
local Font = require("ui/font")
|
2022-03-04 20:20:00 +00:00
|
|
|
local FocusManager = require("ui/widget/focusmanager")
|
2017-04-25 16:49:39 +00:00
|
|
|
local FrameContainer = require("ui/widget/container/framecontainer")
|
|
|
|
local Geom = require("ui/geometry")
|
2016-02-14 21:47:36 +00:00
|
|
|
local GestureRange = require("ui/gesturerange")
|
2017-04-25 16:49:39 +00:00
|
|
|
local HorizontalGroup = require("ui/widget/horizontalgroup")
|
2017-08-02 17:17:56 +00:00
|
|
|
local HorizontalSpan = require("ui/widget/horizontalspan")
|
2017-04-25 16:49:39 +00:00
|
|
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
|
|
|
local LeftContainer = require("ui/widget/container/leftcontainer")
|
|
|
|
local LineWidget = require("ui/widget/linewidget")
|
|
|
|
local OverlapGroup = require("ui/widget/overlapgroup")
|
2017-09-13 14:56:20 +00:00
|
|
|
local Size = require("ui/size")
|
2017-07-01 09:30:30 +00:00
|
|
|
local TextViewer = require("ui/widget/textviewer")
|
2017-04-25 16:49:39 +00:00
|
|
|
local TextWidget = require("ui/widget/textwidget")
|
2022-01-08 15:58:36 +00:00
|
|
|
local TitleBar = require("ui/widget/titlebar")
|
2017-04-25 16:49:39 +00:00
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
local VerticalGroup = require("ui/widget/verticalgroup")
|
|
|
|
local VerticalSpan = require("ui/widget/verticalspan")
|
2018-01-11 11:45:00 +00:00
|
|
|
local Input = Device.input
|
2016-02-14 21:47:36 +00:00
|
|
|
local Screen = Device.screen
|
2017-08-02 17:17:56 +00:00
|
|
|
local T = require("ffi/util").template
|
|
|
|
local _ = require("gettext")
|
2016-02-14 21:47:36 +00:00
|
|
|
|
Clarify our OOP semantics across the codebase (#9586)
Basically:
* Use `extend` for class definitions
* Use `new` for object instantiations
That includes some minor code cleanups along the way:
* Updated `Widget`'s docs to make the semantics clearer.
* Removed `should_restrict_JIT` (it's been dead code since https://github.com/koreader/android-luajit-launcher/pull/283)
* Minor refactoring of LuaSettings/LuaData/LuaDefaults/DocSettings to behave (mostly, they are instantiated via `open` instead of `new`) like everything else and handle inheritance properly (i.e., DocSettings is now a proper LuaSettings subclass).
* Default to `WidgetContainer` instead of `InputContainer` for stuff that doesn't actually setup key/gesture events.
* Ditto for explicit `*Listener` only classes, make sure they're based on `EventListener` instead of something uselessly fancier.
* Unless absolutely necessary, do not store references in class objects, ever; only values. Instead, always store references in instances, to avoid both sneaky inheritance issues, and sneaky GC pinning of stale references.
* ReaderUI: Fix one such issue with its `active_widgets` array, with critical implications, as it essentially pinned *all* of ReaderUI's modules, including their reference to the `Document` instance (i.e., that was a big-ass leak).
* Terminal: Make sure the shell is killed on plugin teardown.
* InputText: Fix Home/End/Del physical keys to behave sensibly.
* InputContainer/WidgetContainer: If necessary, compute self.dimen at paintTo time (previously, only InputContainers did, which might have had something to do with random widgets unconcerned about input using it as a baseclass instead of WidgetContainer...).
* OverlapGroup: Compute self.dimen at *init* time, because for some reason it needs to do that, but do it directly in OverlapGroup instead of going through a weird WidgetContainer method that it was the sole user of.
* ReaderCropping: Under no circumstances should a Document instance member (here, self.bbox) risk being `nil`ed!
* Kobo: Minor code cleanups.
2022-10-06 00:14:48 +00:00
|
|
|
local KeyValueItem = InputContainer:extend{
|
2022-11-01 18:22:03 +00:00
|
|
|
show_parent = nil,
|
2016-02-14 21:47:36 +00:00
|
|
|
key = nil,
|
|
|
|
value = nil,
|
2020-01-23 16:35:57 +00:00
|
|
|
value_lang = nil,
|
2021-02-20 19:15:43 +00:00
|
|
|
font_size = 20, -- will be adjusted depending on keyvalues_per_page
|
2022-10-25 19:50:40 +00:00
|
|
|
frame_padding = Size.padding.default,
|
|
|
|
middle_padding = Size.padding.default, -- min enforced padding between key and value
|
2021-02-20 19:15:43 +00:00
|
|
|
key_font_name = "smallinfofontbold",
|
|
|
|
value_font_name = "smallinfofont",
|
2016-02-14 21:47:36 +00:00
|
|
|
width = nil,
|
|
|
|
height = nil,
|
2017-07-01 09:30:30 +00:00
|
|
|
textviewer_width = nil,
|
|
|
|
textviewer_height = nil,
|
2017-10-23 19:30:06 +00:00
|
|
|
value_overflow_align = "left",
|
2020-05-29 12:22:27 +00:00
|
|
|
-- "right": only align right if value overflow 1/2 width
|
|
|
|
-- "right_always": align value right even when small and
|
|
|
|
-- only key overflows 1/2 width
|
Terminal emulator: full rewrite, real vt52 emulator (#8636)
New real terminal emulator, replacing the old plugin.
The emulator is basically a vt52 terminal (enriched with
some ANSI-sequences, as ash, vi and mksh don't behave well
on a vt52 term).
So far working: ash, mksh, bash, nano, vi, busybox, watch...
The input supports: tab-completion; cursor movement;
backspace; start of line, end of line (long press);
page up, page down (long press).
User scripts may be placed in the koterm.koplugin/scripts/
folder, aliases can be put in the file aliases and startup
command in the file profile.user in that folder.
2022-01-28 19:33:09 +00:00
|
|
|
close_callback = nil,
|
2016-02-14 21:47:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function KeyValueItem:init()
|
Clarify our OOP semantics across the codebase (#9586)
Basically:
* Use `extend` for class definitions
* Use `new` for object instantiations
That includes some minor code cleanups along the way:
* Updated `Widget`'s docs to make the semantics clearer.
* Removed `should_restrict_JIT` (it's been dead code since https://github.com/koreader/android-luajit-launcher/pull/283)
* Minor refactoring of LuaSettings/LuaData/LuaDefaults/DocSettings to behave (mostly, they are instantiated via `open` instead of `new`) like everything else and handle inheritance properly (i.e., DocSettings is now a proper LuaSettings subclass).
* Default to `WidgetContainer` instead of `InputContainer` for stuff that doesn't actually setup key/gesture events.
* Ditto for explicit `*Listener` only classes, make sure they're based on `EventListener` instead of something uselessly fancier.
* Unless absolutely necessary, do not store references in class objects, ever; only values. Instead, always store references in instances, to avoid both sneaky inheritance issues, and sneaky GC pinning of stale references.
* ReaderUI: Fix one such issue with its `active_widgets` array, with critical implications, as it essentially pinned *all* of ReaderUI's modules, including their reference to the `Document` instance (i.e., that was a big-ass leak).
* Terminal: Make sure the shell is killed on plugin teardown.
* InputText: Fix Home/End/Del physical keys to behave sensibly.
* InputContainer/WidgetContainer: If necessary, compute self.dimen at paintTo time (previously, only InputContainers did, which might have had something to do with random widgets unconcerned about input using it as a baseclass instead of WidgetContainer...).
* OverlapGroup: Compute self.dimen at *init* time, because for some reason it needs to do that, but do it directly in OverlapGroup instead of going through a weird WidgetContainer method that it was the sole user of.
* ReaderCropping: Under no circumstances should a Document instance member (here, self.bbox) risk being `nil`ed!
* Kobo: Minor code cleanups.
2022-10-06 00:14:48 +00:00
|
|
|
self.dimen = Geom:new{ x = 0, y = 0, w = self.width, h = self.height }
|
2016-02-14 21:47:36 +00:00
|
|
|
|
2018-01-21 21:33:40 +00:00
|
|
|
-- self.value may contain some control characters (\n \t...) that would
|
|
|
|
-- be rendered as a square. Replace them with a shorter and nicer '|'.
|
|
|
|
-- (Let self.value untouched, as with Hold, the original value can be
|
|
|
|
-- displayed correctly in TextViewer.)
|
|
|
|
local tvalue = tostring(self.value)
|
|
|
|
tvalue = tvalue:gsub("[\n\t]", "|")
|
|
|
|
|
2022-10-25 19:50:40 +00:00
|
|
|
local frame_padding = self.frame_padding
|
2017-04-26 12:55:35 +00:00
|
|
|
local frame_internal_width = self.width - frame_padding * 2
|
2022-10-25 19:50:40 +00:00
|
|
|
local middle_padding = self.middle_padding
|
2019-12-06 21:55:28 +00:00
|
|
|
local available_width = frame_internal_width - middle_padding
|
|
|
|
|
2019-10-21 13:20:40 +00:00
|
|
|
-- Default widths (and position of value widget) if each text fits in 1/2 screen width
|
2022-10-25 19:50:40 +00:00
|
|
|
local ratio = self.width_ratio or 0.5
|
|
|
|
local key_w = math.floor(frame_internal_width * ratio - middle_padding)
|
|
|
|
local value_w = math.floor(frame_internal_width * (1-ratio))
|
2019-10-21 13:20:40 +00:00
|
|
|
|
|
|
|
local key_widget = TextWidget:new{
|
|
|
|
text = self.key,
|
2019-12-06 21:55:28 +00:00
|
|
|
max_width = available_width,
|
2021-02-20 19:15:43 +00:00
|
|
|
face = Font:getFace(self.key_font_name, self.font_size),
|
2019-10-21 13:20:40 +00:00
|
|
|
}
|
|
|
|
local value_widget = TextWidget:new{
|
|
|
|
text = tvalue,
|
2019-12-06 21:55:28 +00:00
|
|
|
max_width = available_width,
|
2021-02-20 19:15:43 +00:00
|
|
|
face = Font:getFace(self.value_font_name, self.font_size),
|
2020-01-23 16:35:57 +00:00
|
|
|
lang = self.value_lang,
|
2019-10-21 13:20:40 +00:00
|
|
|
}
|
|
|
|
local key_w_rendered = key_widget:getWidth()
|
|
|
|
local value_w_rendered = value_widget:getWidth()
|
|
|
|
|
|
|
|
-- As both key_widget and value_width will be in a HorizontalGroup,
|
|
|
|
-- and key is always left aligned, we can just tweak the key width
|
|
|
|
-- to position the value_widget
|
|
|
|
local value_align_right = false
|
|
|
|
local fit_right_align = true -- by default, really right align
|
|
|
|
|
2017-04-25 16:49:39 +00:00
|
|
|
if key_w_rendered > key_w or value_w_rendered > value_w then
|
2019-10-21 13:20:40 +00:00
|
|
|
-- One (or both) does not fit in 1/2 width
|
2019-12-06 21:55:28 +00:00
|
|
|
if key_w_rendered + value_w_rendered > available_width then
|
2019-10-21 13:20:40 +00:00
|
|
|
-- Both do not fit: one has to be truncated so they fit
|
2017-04-25 16:49:39 +00:00
|
|
|
if key_w_rendered >= value_w_rendered then
|
2019-10-21 13:20:40 +00:00
|
|
|
-- Rare case: key larger than value.
|
|
|
|
-- We should have kept our keys small, smaller than 1/2 width.
|
|
|
|
-- If it is larger than value, it's that value is kinda small,
|
|
|
|
-- so keep the whole value, and truncate the key
|
2019-12-06 21:55:28 +00:00
|
|
|
key_w = available_width - value_w_rendered
|
2017-04-25 16:49:39 +00:00
|
|
|
else
|
2019-10-21 13:20:40 +00:00
|
|
|
-- Usual case: value larger than key.
|
2019-12-06 21:55:28 +00:00
|
|
|
-- Keep our small key, fit the value in the remaining width.
|
2019-10-21 13:20:40 +00:00
|
|
|
key_w = key_w_rendered
|
2017-04-25 16:49:39 +00:00
|
|
|
end
|
2019-10-21 13:20:40 +00:00
|
|
|
value_align_right = true -- so the ellipsis touches the screen right border
|
2020-05-29 12:22:27 +00:00
|
|
|
if self.value_align ~= "right" and self.value_overflow_align ~= "right"
|
|
|
|
and self.value_overflow_align ~= "right_always" then
|
2019-10-21 13:20:40 +00:00
|
|
|
-- Don't adjust the ellipsis to the screen right border,
|
|
|
|
-- so the left of text is aligned with other truncated texts
|
|
|
|
fit_right_align = false
|
|
|
|
end
|
2022-01-31 18:18:35 +00:00
|
|
|
-- Allow for displaying the non-truncated text with Tap or Hold if not already used
|
|
|
|
self.is_truncated = true
|
2016-02-16 01:56:13 +00:00
|
|
|
else
|
2019-10-21 13:20:40 +00:00
|
|
|
-- Both can fit: break the 1/2 widths
|
2020-05-29 12:22:27 +00:00
|
|
|
if self.value_align == "right" or self.value_overflow_align == "right_always"
|
2022-10-25 19:50:40 +00:00
|
|
|
or (self.value_overflow_align == "right" and value_w_rendered > value_w)
|
|
|
|
or key_w_rendered < key_w then -- it's the value that can't fit (longer), this way it stays closest to border
|
2019-12-06 21:55:28 +00:00
|
|
|
key_w = available_width - value_w_rendered
|
2019-10-21 13:20:40 +00:00
|
|
|
value_align_right = true
|
2017-10-23 19:30:06 +00:00
|
|
|
else
|
2019-10-21 13:20:40 +00:00
|
|
|
key_w = key_w_rendered
|
2017-10-23 19:30:06 +00:00
|
|
|
end
|
2016-02-16 01:56:13 +00:00
|
|
|
end
|
2019-10-21 13:20:40 +00:00
|
|
|
-- In all the above case, we set the right key_w to include any
|
2019-12-06 21:55:28 +00:00
|
|
|
-- needed additional in-between padding: value_w is what's left.
|
|
|
|
value_w = available_width - key_w
|
2016-02-16 01:56:13 +00:00
|
|
|
else
|
2017-12-17 21:08:13 +00:00
|
|
|
if self.value_align == "right" then
|
2019-12-06 21:55:28 +00:00
|
|
|
key_w = available_width - value_w_rendered
|
2019-10-21 13:20:40 +00:00
|
|
|
value_w = value_w_rendered
|
|
|
|
value_align_right = true
|
2017-12-17 21:08:13 +00:00
|
|
|
end
|
2016-02-16 01:56:13 +00:00
|
|
|
end
|
|
|
|
|
2019-12-06 21:55:28 +00:00
|
|
|
-- Adjust widgets' max widths if needed
|
2019-10-21 13:20:40 +00:00
|
|
|
value_widget:setMaxWidth(value_w)
|
|
|
|
if fit_right_align and value_align_right and value_widget:getWidth() < value_w then
|
|
|
|
-- Because of truncation at glyph boundaries, value_widget
|
|
|
|
-- may be a tad smaller than the specified value_w:
|
2022-01-08 15:58:36 +00:00
|
|
|
-- adjust key_w so value is pushed to the screen right border
|
|
|
|
value_w = value_widget:getWidth()
|
|
|
|
key_w = available_width - value_w
|
2019-10-21 13:20:40 +00:00
|
|
|
end
|
|
|
|
key_widget:setMaxWidth(key_w)
|
|
|
|
|
|
|
|
-- For debugging positioning:
|
|
|
|
-- value_widget = FrameContainer:new{ padding=0, margin=0, bordersize=1, value_widget }
|
|
|
|
|
2022-03-04 20:20:00 +00:00
|
|
|
self.ges_events.Tap = {
|
|
|
|
GestureRange:new{
|
|
|
|
ges = "tap",
|
|
|
|
range = self.dimen,
|
2020-05-29 12:22:27 +00:00
|
|
|
}
|
2022-03-04 20:20:00 +00:00
|
|
|
}
|
|
|
|
self.ges_events.Hold = {
|
|
|
|
GestureRange:new{
|
|
|
|
ges = "hold",
|
|
|
|
range = self.dimen,
|
2022-01-31 18:18:35 +00:00
|
|
|
}
|
2022-03-04 20:20:00 +00:00
|
|
|
}
|
|
|
|
local content_dimen = self.dimen:copy()
|
|
|
|
content_dimen.h = content_dimen.h - Size.border.thin * 2 -- reduced by 2 border sizes
|
|
|
|
content_dimen.w = content_dimen.w - Size.border.thin * 2 -- reduced by 2 border sizes
|
2016-02-16 01:56:13 +00:00
|
|
|
self[1] = FrameContainer:new{
|
2017-04-26 12:55:35 +00:00
|
|
|
padding = frame_padding,
|
2021-02-20 19:15:43 +00:00
|
|
|
padding_top = 0,
|
|
|
|
padding_bottom = 0,
|
2016-02-16 01:56:13 +00:00
|
|
|
bordersize = 0,
|
2022-03-04 20:20:00 +00:00
|
|
|
focusable = true,
|
|
|
|
focus_border_size = Size.border.thin,
|
Revamp "flash_ui" handling (#7118)
* Wherever possible, do an actual dumb invert on the Screen BB instead of repainting the widget, *then* inverting it (which is what the "invert" flag does).
* Instead of playing with nextTick/tickAfterNext delays, explicitly fence stuff with forceRePaint
* And, in the few cases where said Mk. 7 quirk kicks in, make the fences more marked by using a well-placed WAIT_FOR_UPDATE_COMPLETE
* Fix an issue in Button where show/hide & enable/disable where actually all toggles, which meant that duplicate calls or timing issues would do the wrong thing. (This broke dimming some icons, and mistakenly dropped the background from FM chevrons, for example).
* Speaking of, fix Button's hide/show to actually restore the background properly (there was a stupid typo in the variable name)
* Still in Button, fix the insanity of the double repaint on rounded buttons. Turns out it made sense, after all (and was related to said missing background, and bad interaction with invert & text with no background).
* KeyValuePage suffered from a similar issue with broken highlights (all black) because of missing backgrounds.
* In ConfigDialog, only instanciate IconButtons once (because every tab switch causes a full instantiation; and the initial display implies a full instanciation and an initial tab switch). Otherwise, both instances linger, and catch taps, and as such, double highlights.
* ConfigDialog: Restore the "don't repaint ReaderUI" when switching between similarly sized tabs (re #6131). I never could reproduce that on eInk, and I can't now on the emulator, so I'm assuming @poire-z fixed it during the swap to SVG icons.
* KeyValuePage: Only instanciate Buttons once (again, this is a widget that goes through a full init every page). Again, caused highlight/dimming issues because buttons were stacked.
* Menu: Ditto.
* TouchMenu: Now home of the gnarliest unhilight heuristics, because of the sheer amount of different things that can happen (and/or thanks to stuff not flagged covers_fullscreen properly ;p).
* Bump base
https://github.com/koreader/koreader-base/pull/1280
https://github.com/koreader/koreader-base/pull/1282
https://github.com/koreader/koreader-base/pull/1283
https://github.com/koreader/koreader-base/pull/1284
* Bump android-luajit-launcher
https://github.com/koreader/android-luajit-launcher/pull/284
https://github.com/koreader/android-luajit-launcher/pull/285
https://github.com/koreader/android-luajit-launcher/pull/286
https://github.com/koreader/android-luajit-launcher/pull/287
2021-01-10 00:51:09 +00:00
|
|
|
background = Blitbuffer.COLOR_WHITE,
|
2017-04-25 16:49:39 +00:00
|
|
|
HorizontalGroup:new{
|
2022-03-04 20:20:00 +00:00
|
|
|
dimen = content_dimen,
|
2016-02-16 01:56:13 +00:00
|
|
|
LeftContainer:new{
|
2017-04-25 16:49:39 +00:00
|
|
|
dimen = {
|
|
|
|
w = key_w,
|
2022-03-04 20:20:00 +00:00
|
|
|
h = content_dimen.h
|
2017-04-25 16:49:39 +00:00
|
|
|
},
|
2019-10-21 13:20:40 +00:00
|
|
|
key_widget,
|
2016-02-16 01:56:13 +00:00
|
|
|
},
|
2019-12-06 21:55:28 +00:00
|
|
|
HorizontalSpan:new{
|
|
|
|
width = middle_padding,
|
|
|
|
},
|
2017-04-25 16:49:39 +00:00
|
|
|
LeftContainer:new{
|
|
|
|
dimen = {
|
|
|
|
w = value_w,
|
2022-03-04 20:20:00 +00:00
|
|
|
h = content_dimen.h
|
2017-04-25 16:49:39 +00:00
|
|
|
},
|
2019-10-21 13:20:40 +00:00
|
|
|
value_widget,
|
2016-02-14 21:47:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function KeyValueItem:onTap()
|
2017-10-08 18:51:24 +00:00
|
|
|
if self.callback then
|
2017-10-10 21:50:45 +00:00
|
|
|
if G_reader_settings:isFalse("flash_ui") then
|
2022-01-31 18:18:35 +00:00
|
|
|
self.callback(self.kv_page, self)
|
2017-10-10 21:50:45 +00:00
|
|
|
else
|
Revamp flash_ui handling, once more, with feeling ;) (#7262)
* Simplify flash_ui handling (by handling the unhighlight pre-callback, c.f., #7262 for more details).
* UIManager: Handle translucent window-level widgets (and those wrapped in a translucent MovableContainer) properly in setDirty directly, making sure what's *underneath* them gets repainted to avoid alpha layering glitches. (This was previously handled via localized hacks).
* Update UIManager's documentation, and format it properly for ldoc parsing, making the HTML docs more useful.
* ReaderView: Reinitialize the various page areas when opening a new document, to prevent poisoning from the previous document.
* Event: Handle nils in an event's arguments.
* CheckButton/RadioButton: Switch to simple inversion to handle highlighting
* CheckButton: Make the highlight span the inner frame's width, instead of just the text's width, if possible.
* AlphaContainer: Fix & simplify, given the UIManager alpha handling.
* MovableContainer: When translucent, cache the canvas bb used for composition.
* Avoid spurious refreshes in a few widgets using various dummy *TextWidgets in order to first compute a text height.
* KeyValuePage: Avoid floats in size computations.
2021-02-20 17:22:48 +00:00
|
|
|
-- c.f., ui/widget/iconbutton for the canonical documentation about the flash_ui code flow
|
|
|
|
|
|
|
|
-- Highlight
|
|
|
|
--
|
2017-10-10 21:50:45 +00:00
|
|
|
self[1].invert = true
|
Revamp "flash_ui" handling (#7118)
* Wherever possible, do an actual dumb invert on the Screen BB instead of repainting the widget, *then* inverting it (which is what the "invert" flag does).
* Instead of playing with nextTick/tickAfterNext delays, explicitly fence stuff with forceRePaint
* And, in the few cases where said Mk. 7 quirk kicks in, make the fences more marked by using a well-placed WAIT_FOR_UPDATE_COMPLETE
* Fix an issue in Button where show/hide & enable/disable where actually all toggles, which meant that duplicate calls or timing issues would do the wrong thing. (This broke dimming some icons, and mistakenly dropped the background from FM chevrons, for example).
* Speaking of, fix Button's hide/show to actually restore the background properly (there was a stupid typo in the variable name)
* Still in Button, fix the insanity of the double repaint on rounded buttons. Turns out it made sense, after all (and was related to said missing background, and bad interaction with invert & text with no background).
* KeyValuePage suffered from a similar issue with broken highlights (all black) because of missing backgrounds.
* In ConfigDialog, only instanciate IconButtons once (because every tab switch causes a full instantiation; and the initial display implies a full instanciation and an initial tab switch). Otherwise, both instances linger, and catch taps, and as such, double highlights.
* ConfigDialog: Restore the "don't repaint ReaderUI" when switching between similarly sized tabs (re #6131). I never could reproduce that on eInk, and I can't now on the emulator, so I'm assuming @poire-z fixed it during the swap to SVG icons.
* KeyValuePage: Only instanciate Buttons once (again, this is a widget that goes through a full init every page). Again, caused highlight/dimming issues because buttons were stacked.
* Menu: Ditto.
* TouchMenu: Now home of the gnarliest unhilight heuristics, because of the sheer amount of different things that can happen (and/or thanks to stuff not flagged covers_fullscreen properly ;p).
* Bump base
https://github.com/koreader/koreader-base/pull/1280
https://github.com/koreader/koreader-base/pull/1282
https://github.com/koreader/koreader-base/pull/1283
https://github.com/koreader/koreader-base/pull/1284
* Bump android-luajit-launcher
https://github.com/koreader/android-luajit-launcher/pull/284
https://github.com/koreader/android-luajit-launcher/pull/285
https://github.com/koreader/android-luajit-launcher/pull/286
https://github.com/koreader/android-luajit-launcher/pull/287
2021-01-10 00:51:09 +00:00
|
|
|
UIManager:widgetInvert(self[1], self[1].dimen.x, self[1].dimen.y)
|
Revamp flash_ui handling, once more, with feeling ;) (#7262)
* Simplify flash_ui handling (by handling the unhighlight pre-callback, c.f., #7262 for more details).
* UIManager: Handle translucent window-level widgets (and those wrapped in a translucent MovableContainer) properly in setDirty directly, making sure what's *underneath* them gets repainted to avoid alpha layering glitches. (This was previously handled via localized hacks).
* Update UIManager's documentation, and format it properly for ldoc parsing, making the HTML docs more useful.
* ReaderView: Reinitialize the various page areas when opening a new document, to prevent poisoning from the previous document.
* Event: Handle nils in an event's arguments.
* CheckButton/RadioButton: Switch to simple inversion to handle highlighting
* CheckButton: Make the highlight span the inner frame's width, instead of just the text's width, if possible.
* AlphaContainer: Fix & simplify, given the UIManager alpha handling.
* MovableContainer: When translucent, cache the canvas bb used for composition.
* Avoid spurious refreshes in a few widgets using various dummy *TextWidgets in order to first compute a text height.
* KeyValuePage: Avoid floats in size computations.
2021-02-20 17:22:48 +00:00
|
|
|
UIManager:setDirty(nil, "fast", self[1].dimen)
|
Revamp "flash_ui" handling (#7118)
* Wherever possible, do an actual dumb invert on the Screen BB instead of repainting the widget, *then* inverting it (which is what the "invert" flag does).
* Instead of playing with nextTick/tickAfterNext delays, explicitly fence stuff with forceRePaint
* And, in the few cases where said Mk. 7 quirk kicks in, make the fences more marked by using a well-placed WAIT_FOR_UPDATE_COMPLETE
* Fix an issue in Button where show/hide & enable/disable where actually all toggles, which meant that duplicate calls or timing issues would do the wrong thing. (This broke dimming some icons, and mistakenly dropped the background from FM chevrons, for example).
* Speaking of, fix Button's hide/show to actually restore the background properly (there was a stupid typo in the variable name)
* Still in Button, fix the insanity of the double repaint on rounded buttons. Turns out it made sense, after all (and was related to said missing background, and bad interaction with invert & text with no background).
* KeyValuePage suffered from a similar issue with broken highlights (all black) because of missing backgrounds.
* In ConfigDialog, only instanciate IconButtons once (because every tab switch causes a full instantiation; and the initial display implies a full instanciation and an initial tab switch). Otherwise, both instances linger, and catch taps, and as such, double highlights.
* ConfigDialog: Restore the "don't repaint ReaderUI" when switching between similarly sized tabs (re #6131). I never could reproduce that on eInk, and I can't now on the emulator, so I'm assuming @poire-z fixed it during the swap to SVG icons.
* KeyValuePage: Only instanciate Buttons once (again, this is a widget that goes through a full init every page). Again, caused highlight/dimming issues because buttons were stacked.
* Menu: Ditto.
* TouchMenu: Now home of the gnarliest unhilight heuristics, because of the sheer amount of different things that can happen (and/or thanks to stuff not flagged covers_fullscreen properly ;p).
* Bump base
https://github.com/koreader/koreader-base/pull/1280
https://github.com/koreader/koreader-base/pull/1282
https://github.com/koreader/koreader-base/pull/1283
https://github.com/koreader/koreader-base/pull/1284
* Bump android-luajit-launcher
https://github.com/koreader/android-luajit-launcher/pull/284
https://github.com/koreader/android-luajit-launcher/pull/285
https://github.com/koreader/android-luajit-launcher/pull/286
https://github.com/koreader/android-luajit-launcher/pull/287
2021-01-10 00:51:09 +00:00
|
|
|
|
|
|
|
UIManager:forceRePaint()
|
2021-02-22 01:09:44 +00:00
|
|
|
UIManager:yieldToEPDC()
|
Revamp flash_ui handling, once more, with feeling ;) (#7262)
* Simplify flash_ui handling (by handling the unhighlight pre-callback, c.f., #7262 for more details).
* UIManager: Handle translucent window-level widgets (and those wrapped in a translucent MovableContainer) properly in setDirty directly, making sure what's *underneath* them gets repainted to avoid alpha layering glitches. (This was previously handled via localized hacks).
* Update UIManager's documentation, and format it properly for ldoc parsing, making the HTML docs more useful.
* ReaderView: Reinitialize the various page areas when opening a new document, to prevent poisoning from the previous document.
* Event: Handle nils in an event's arguments.
* CheckButton/RadioButton: Switch to simple inversion to handle highlighting
* CheckButton: Make the highlight span the inner frame's width, instead of just the text's width, if possible.
* AlphaContainer: Fix & simplify, given the UIManager alpha handling.
* MovableContainer: When translucent, cache the canvas bb used for composition.
* Avoid spurious refreshes in a few widgets using various dummy *TextWidgets in order to first compute a text height.
* KeyValuePage: Avoid floats in size computations.
2021-02-20 17:22:48 +00:00
|
|
|
|
|
|
|
-- Unhighlight
|
|
|
|
--
|
|
|
|
self[1].invert = false
|
|
|
|
UIManager:widgetInvert(self[1], self[1].dimen.x, self[1].dimen.y)
|
|
|
|
UIManager:setDirty(nil, "ui", self[1].dimen)
|
|
|
|
|
|
|
|
-- Callback
|
|
|
|
--
|
2022-01-31 18:18:35 +00:00
|
|
|
self.callback(self.kv_page, self)
|
Revamp flash_ui handling, once more, with feeling ;) (#7262)
* Simplify flash_ui handling (by handling the unhighlight pre-callback, c.f., #7262 for more details).
* UIManager: Handle translucent window-level widgets (and those wrapped in a translucent MovableContainer) properly in setDirty directly, making sure what's *underneath* them gets repainted to avoid alpha layering glitches. (This was previously handled via localized hacks).
* Update UIManager's documentation, and format it properly for ldoc parsing, making the HTML docs more useful.
* ReaderView: Reinitialize the various page areas when opening a new document, to prevent poisoning from the previous document.
* Event: Handle nils in an event's arguments.
* CheckButton/RadioButton: Switch to simple inversion to handle highlighting
* CheckButton: Make the highlight span the inner frame's width, instead of just the text's width, if possible.
* AlphaContainer: Fix & simplify, given the UIManager alpha handling.
* MovableContainer: When translucent, cache the canvas bb used for composition.
* Avoid spurious refreshes in a few widgets using various dummy *TextWidgets in order to first compute a text height.
* KeyValuePage: Avoid floats in size computations.
2021-02-20 17:22:48 +00:00
|
|
|
|
Revamp "flash_ui" handling (#7118)
* Wherever possible, do an actual dumb invert on the Screen BB instead of repainting the widget, *then* inverting it (which is what the "invert" flag does).
* Instead of playing with nextTick/tickAfterNext delays, explicitly fence stuff with forceRePaint
* And, in the few cases where said Mk. 7 quirk kicks in, make the fences more marked by using a well-placed WAIT_FOR_UPDATE_COMPLETE
* Fix an issue in Button where show/hide & enable/disable where actually all toggles, which meant that duplicate calls or timing issues would do the wrong thing. (This broke dimming some icons, and mistakenly dropped the background from FM chevrons, for example).
* Speaking of, fix Button's hide/show to actually restore the background properly (there was a stupid typo in the variable name)
* Still in Button, fix the insanity of the double repaint on rounded buttons. Turns out it made sense, after all (and was related to said missing background, and bad interaction with invert & text with no background).
* KeyValuePage suffered from a similar issue with broken highlights (all black) because of missing backgrounds.
* In ConfigDialog, only instanciate IconButtons once (because every tab switch causes a full instantiation; and the initial display implies a full instanciation and an initial tab switch). Otherwise, both instances linger, and catch taps, and as such, double highlights.
* ConfigDialog: Restore the "don't repaint ReaderUI" when switching between similarly sized tabs (re #6131). I never could reproduce that on eInk, and I can't now on the emulator, so I'm assuming @poire-z fixed it during the swap to SVG icons.
* KeyValuePage: Only instanciate Buttons once (again, this is a widget that goes through a full init every page). Again, caused highlight/dimming issues because buttons were stacked.
* Menu: Ditto.
* TouchMenu: Now home of the gnarliest unhilight heuristics, because of the sheer amount of different things that can happen (and/or thanks to stuff not flagged covers_fullscreen properly ;p).
* Bump base
https://github.com/koreader/koreader-base/pull/1280
https://github.com/koreader/koreader-base/pull/1282
https://github.com/koreader/koreader-base/pull/1283
https://github.com/koreader/koreader-base/pull/1284
* Bump android-luajit-launcher
https://github.com/koreader/android-luajit-launcher/pull/284
https://github.com/koreader/android-luajit-launcher/pull/285
https://github.com/koreader/android-luajit-launcher/pull/286
https://github.com/koreader/android-luajit-launcher/pull/287
2021-01-10 00:51:09 +00:00
|
|
|
UIManager:forceRePaint()
|
2017-10-10 21:50:45 +00:00
|
|
|
end
|
2022-01-31 18:18:35 +00:00
|
|
|
else
|
|
|
|
-- If no tap callback, allow for displaying the non-truncated
|
|
|
|
-- text with Tap too
|
|
|
|
if self.is_truncated then
|
|
|
|
self:onShowKeyValue()
|
|
|
|
end
|
2017-10-08 18:51:24 +00:00
|
|
|
end
|
2016-02-14 21:47:36 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2017-07-01 09:30:30 +00:00
|
|
|
function KeyValueItem:onHold()
|
2022-01-31 18:18:35 +00:00
|
|
|
if self.hold_callback then
|
|
|
|
self.hold_callback(self.kv_page, self)
|
|
|
|
else
|
|
|
|
if self.is_truncated then
|
|
|
|
self:onShowKeyValue()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
function KeyValueItem:onShowKeyValue()
|
2017-07-01 09:30:30 +00:00
|
|
|
local textviewer = TextViewer:new{
|
|
|
|
title = self.key,
|
2022-01-31 18:18:35 +00:00
|
|
|
title_multilines = true, -- in case it's key/title that is too long
|
2017-07-01 09:30:30 +00:00
|
|
|
text = self.value,
|
2021-05-31 19:50:44 +00:00
|
|
|
text_face = Font:getFace("x_smallinfofont", self.font_size),
|
2020-01-23 16:35:57 +00:00
|
|
|
lang = self.value_lang,
|
2017-07-01 09:30:30 +00:00
|
|
|
width = self.textviewer_width,
|
|
|
|
height = self.textviewer_height,
|
|
|
|
}
|
|
|
|
UIManager:show(textviewer)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2016-02-14 21:47:36 +00:00
|
|
|
|
Clarify our OOP semantics across the codebase (#9586)
Basically:
* Use `extend` for class definitions
* Use `new` for object instantiations
That includes some minor code cleanups along the way:
* Updated `Widget`'s docs to make the semantics clearer.
* Removed `should_restrict_JIT` (it's been dead code since https://github.com/koreader/android-luajit-launcher/pull/283)
* Minor refactoring of LuaSettings/LuaData/LuaDefaults/DocSettings to behave (mostly, they are instantiated via `open` instead of `new`) like everything else and handle inheritance properly (i.e., DocSettings is now a proper LuaSettings subclass).
* Default to `WidgetContainer` instead of `InputContainer` for stuff that doesn't actually setup key/gesture events.
* Ditto for explicit `*Listener` only classes, make sure they're based on `EventListener` instead of something uselessly fancier.
* Unless absolutely necessary, do not store references in class objects, ever; only values. Instead, always store references in instances, to avoid both sneaky inheritance issues, and sneaky GC pinning of stale references.
* ReaderUI: Fix one such issue with its `active_widgets` array, with critical implications, as it essentially pinned *all* of ReaderUI's modules, including their reference to the `Document` instance (i.e., that was a big-ass leak).
* Terminal: Make sure the shell is killed on plugin teardown.
* InputText: Fix Home/End/Del physical keys to behave sensibly.
* InputContainer/WidgetContainer: If necessary, compute self.dimen at paintTo time (previously, only InputContainers did, which might have had something to do with random widgets unconcerned about input using it as a baseclass instead of WidgetContainer...).
* OverlapGroup: Compute self.dimen at *init* time, because for some reason it needs to do that, but do it directly in OverlapGroup instead of going through a weird WidgetContainer method that it was the sole user of.
* ReaderCropping: Under no circumstances should a Document instance member (here, self.bbox) risk being `nil`ed!
* Kobo: Minor code cleanups.
2022-10-06 00:14:48 +00:00
|
|
|
local KeyValuePage = FocusManager:extend{
|
2022-11-01 18:22:03 +00:00
|
|
|
show_parent = nil,
|
|
|
|
kv_pairs = nil, -- not mandatory
|
2016-02-14 21:47:36 +00:00
|
|
|
title = "",
|
|
|
|
width = nil,
|
|
|
|
height = nil,
|
2020-01-23 16:35:57 +00:00
|
|
|
values_lang = nil,
|
2016-02-14 21:47:36 +00:00
|
|
|
-- index for the first item to show
|
|
|
|
show_page = 1,
|
2017-10-23 19:30:06 +00:00
|
|
|
-- aligment of value when key or value overflows its reserved width (for
|
|
|
|
-- now: 50%): "left" (stick to key), "right" (stick to scren right border)
|
|
|
|
value_overflow_align = "left",
|
2021-12-01 11:39:48 +00:00
|
|
|
single_page = nil, -- show all items on one single page (and make them small)
|
2022-11-01 18:22:03 +00:00
|
|
|
title_bar_align = "left",
|
|
|
|
title_bar_left_icon = nil,
|
|
|
|
title_bar_left_icon_tap_callback = nil,
|
|
|
|
title_bar_left_icon_hold_callback = nil,
|
2016-02-14 21:47:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function KeyValuePage:init()
|
2022-11-01 18:22:03 +00:00
|
|
|
self.show_parent = self.show_parent or self
|
2022-10-30 00:05:27 +00:00
|
|
|
self.kv_pairs = self.kv_pairs or {}
|
2016-02-14 21:47:36 +00:00
|
|
|
self.dimen = Geom:new{
|
Clarify our OOP semantics across the codebase (#9586)
Basically:
* Use `extend` for class definitions
* Use `new` for object instantiations
That includes some minor code cleanups along the way:
* Updated `Widget`'s docs to make the semantics clearer.
* Removed `should_restrict_JIT` (it's been dead code since https://github.com/koreader/android-luajit-launcher/pull/283)
* Minor refactoring of LuaSettings/LuaData/LuaDefaults/DocSettings to behave (mostly, they are instantiated via `open` instead of `new`) like everything else and handle inheritance properly (i.e., DocSettings is now a proper LuaSettings subclass).
* Default to `WidgetContainer` instead of `InputContainer` for stuff that doesn't actually setup key/gesture events.
* Ditto for explicit `*Listener` only classes, make sure they're based on `EventListener` instead of something uselessly fancier.
* Unless absolutely necessary, do not store references in class objects, ever; only values. Instead, always store references in instances, to avoid both sneaky inheritance issues, and sneaky GC pinning of stale references.
* ReaderUI: Fix one such issue with its `active_widgets` array, with critical implications, as it essentially pinned *all* of ReaderUI's modules, including their reference to the `Document` instance (i.e., that was a big-ass leak).
* Terminal: Make sure the shell is killed on plugin teardown.
* InputText: Fix Home/End/Del physical keys to behave sensibly.
* InputContainer/WidgetContainer: If necessary, compute self.dimen at paintTo time (previously, only InputContainers did, which might have had something to do with random widgets unconcerned about input using it as a baseclass instead of WidgetContainer...).
* OverlapGroup: Compute self.dimen at *init* time, because for some reason it needs to do that, but do it directly in OverlapGroup instead of going through a weird WidgetContainer method that it was the sole user of.
* ReaderCropping: Under no circumstances should a Document instance member (here, self.bbox) risk being `nil`ed!
* Kobo: Minor code cleanups.
2022-10-06 00:14:48 +00:00
|
|
|
x = 0,
|
|
|
|
y = 0,
|
2016-02-14 21:47:36 +00:00
|
|
|
w = self.width or Screen:getWidth(),
|
|
|
|
h = self.height or Screen:getHeight(),
|
|
|
|
}
|
2018-03-17 22:02:32 +00:00
|
|
|
if self.dimen.w == Screen:getWidth() and self.dimen.h == Screen:getHeight() then
|
|
|
|
self.covers_fullscreen = true -- hint for UIManager:_repaint()
|
|
|
|
end
|
2016-02-14 21:47:36 +00:00
|
|
|
|
2017-07-01 09:30:30 +00:00
|
|
|
if Device:hasKeys() then
|
2022-10-27 00:01:51 +00:00
|
|
|
self.key_events.Close = { { Input.group.Back } }
|
|
|
|
self.key_events.NextPage = { { Input.group.PgFwd } }
|
|
|
|
self.key_events.PrevPage = { { Input.group.PgBack } }
|
2017-07-01 09:30:30 +00:00
|
|
|
end
|
2016-02-14 21:47:36 +00:00
|
|
|
if Device:isTouchDevice() then
|
|
|
|
self.ges_events.Swipe = {
|
|
|
|
GestureRange:new{
|
|
|
|
ges = "swipe",
|
|
|
|
range = self.dimen,
|
|
|
|
}
|
|
|
|
}
|
2022-01-25 14:24:06 +00:00
|
|
|
self.ges_events.MultiSwipe = {
|
|
|
|
GestureRange:new{
|
|
|
|
ges = "multiswipe",
|
|
|
|
range = self.dimen,
|
|
|
|
}
|
|
|
|
}
|
2016-02-14 21:47:36 +00:00
|
|
|
end
|
|
|
|
|
2017-09-28 13:35:25 +00:00
|
|
|
-- return button
|
2019-12-06 21:55:39 +00:00
|
|
|
--- @todo: alternative icon if BD.mirroredUILayout()
|
Revamp "flash_ui" handling (#7118)
* Wherever possible, do an actual dumb invert on the Screen BB instead of repainting the widget, *then* inverting it (which is what the "invert" flag does).
* Instead of playing with nextTick/tickAfterNext delays, explicitly fence stuff with forceRePaint
* And, in the few cases where said Mk. 7 quirk kicks in, make the fences more marked by using a well-placed WAIT_FOR_UPDATE_COMPLETE
* Fix an issue in Button where show/hide & enable/disable where actually all toggles, which meant that duplicate calls or timing issues would do the wrong thing. (This broke dimming some icons, and mistakenly dropped the background from FM chevrons, for example).
* Speaking of, fix Button's hide/show to actually restore the background properly (there was a stupid typo in the variable name)
* Still in Button, fix the insanity of the double repaint on rounded buttons. Turns out it made sense, after all (and was related to said missing background, and bad interaction with invert & text with no background).
* KeyValuePage suffered from a similar issue with broken highlights (all black) because of missing backgrounds.
* In ConfigDialog, only instanciate IconButtons once (because every tab switch causes a full instantiation; and the initial display implies a full instanciation and an initial tab switch). Otherwise, both instances linger, and catch taps, and as such, double highlights.
* ConfigDialog: Restore the "don't repaint ReaderUI" when switching between similarly sized tabs (re #6131). I never could reproduce that on eInk, and I can't now on the emulator, so I'm assuming @poire-z fixed it during the swap to SVG icons.
* KeyValuePage: Only instanciate Buttons once (again, this is a widget that goes through a full init every page). Again, caused highlight/dimming issues because buttons were stacked.
* Menu: Ditto.
* TouchMenu: Now home of the gnarliest unhilight heuristics, because of the sheer amount of different things that can happen (and/or thanks to stuff not flagged covers_fullscreen properly ;p).
* Bump base
https://github.com/koreader/koreader-base/pull/1280
https://github.com/koreader/koreader-base/pull/1282
https://github.com/koreader/koreader-base/pull/1283
https://github.com/koreader/koreader-base/pull/1284
* Bump android-luajit-launcher
https://github.com/koreader/android-luajit-launcher/pull/284
https://github.com/koreader/android-luajit-launcher/pull/285
https://github.com/koreader/android-luajit-launcher/pull/286
https://github.com/koreader/android-luajit-launcher/pull/287
2021-01-10 00:51:09 +00:00
|
|
|
self.page_return_arrow = self.page_return_arrow or Button:new{
|
2022-01-10 18:14:40 +00:00
|
|
|
icon = BD.mirroredUILayout() and "back.top.rtl" or "back.top",
|
2017-09-28 13:35:25 +00:00
|
|
|
callback = function() self:onReturn() end,
|
|
|
|
bordersize = 0,
|
2022-11-01 18:22:03 +00:00
|
|
|
show_parent = self.show_parent,
|
2017-09-28 13:35:25 +00:00
|
|
|
}
|
2017-08-02 17:17:56 +00:00
|
|
|
-- group for page info
|
2020-12-19 11:18:30 +00:00
|
|
|
local chevron_left = "chevron.left"
|
|
|
|
local chevron_right = "chevron.right"
|
|
|
|
local chevron_first = "chevron.first"
|
|
|
|
local chevron_last = "chevron.last"
|
2019-12-06 21:55:39 +00:00
|
|
|
if BD.mirroredUILayout() then
|
|
|
|
chevron_left, chevron_right = chevron_right, chevron_left
|
|
|
|
chevron_first, chevron_last = chevron_last, chevron_first
|
|
|
|
end
|
Revamp "flash_ui" handling (#7118)
* Wherever possible, do an actual dumb invert on the Screen BB instead of repainting the widget, *then* inverting it (which is what the "invert" flag does).
* Instead of playing with nextTick/tickAfterNext delays, explicitly fence stuff with forceRePaint
* And, in the few cases where said Mk. 7 quirk kicks in, make the fences more marked by using a well-placed WAIT_FOR_UPDATE_COMPLETE
* Fix an issue in Button where show/hide & enable/disable where actually all toggles, which meant that duplicate calls or timing issues would do the wrong thing. (This broke dimming some icons, and mistakenly dropped the background from FM chevrons, for example).
* Speaking of, fix Button's hide/show to actually restore the background properly (there was a stupid typo in the variable name)
* Still in Button, fix the insanity of the double repaint on rounded buttons. Turns out it made sense, after all (and was related to said missing background, and bad interaction with invert & text with no background).
* KeyValuePage suffered from a similar issue with broken highlights (all black) because of missing backgrounds.
* In ConfigDialog, only instanciate IconButtons once (because every tab switch causes a full instantiation; and the initial display implies a full instanciation and an initial tab switch). Otherwise, both instances linger, and catch taps, and as such, double highlights.
* ConfigDialog: Restore the "don't repaint ReaderUI" when switching between similarly sized tabs (re #6131). I never could reproduce that on eInk, and I can't now on the emulator, so I'm assuming @poire-z fixed it during the swap to SVG icons.
* KeyValuePage: Only instanciate Buttons once (again, this is a widget that goes through a full init every page). Again, caused highlight/dimming issues because buttons were stacked.
* Menu: Ditto.
* TouchMenu: Now home of the gnarliest unhilight heuristics, because of the sheer amount of different things that can happen (and/or thanks to stuff not flagged covers_fullscreen properly ;p).
* Bump base
https://github.com/koreader/koreader-base/pull/1280
https://github.com/koreader/koreader-base/pull/1282
https://github.com/koreader/koreader-base/pull/1283
https://github.com/koreader/koreader-base/pull/1284
* Bump android-luajit-launcher
https://github.com/koreader/android-luajit-launcher/pull/284
https://github.com/koreader/android-luajit-launcher/pull/285
https://github.com/koreader/android-luajit-launcher/pull/286
https://github.com/koreader/android-luajit-launcher/pull/287
2021-01-10 00:51:09 +00:00
|
|
|
self.page_info_left_chev = self.page_info_left_chev or Button:new{
|
2019-12-06 21:55:39 +00:00
|
|
|
icon = chevron_left,
|
2017-08-02 17:17:56 +00:00
|
|
|
callback = function() self:prevPage() end,
|
|
|
|
bordersize = 0,
|
2022-11-01 18:22:03 +00:00
|
|
|
show_parent = self.show_parent,
|
2017-08-02 17:17:56 +00:00
|
|
|
}
|
Revamp "flash_ui" handling (#7118)
* Wherever possible, do an actual dumb invert on the Screen BB instead of repainting the widget, *then* inverting it (which is what the "invert" flag does).
* Instead of playing with nextTick/tickAfterNext delays, explicitly fence stuff with forceRePaint
* And, in the few cases where said Mk. 7 quirk kicks in, make the fences more marked by using a well-placed WAIT_FOR_UPDATE_COMPLETE
* Fix an issue in Button where show/hide & enable/disable where actually all toggles, which meant that duplicate calls or timing issues would do the wrong thing. (This broke dimming some icons, and mistakenly dropped the background from FM chevrons, for example).
* Speaking of, fix Button's hide/show to actually restore the background properly (there was a stupid typo in the variable name)
* Still in Button, fix the insanity of the double repaint on rounded buttons. Turns out it made sense, after all (and was related to said missing background, and bad interaction with invert & text with no background).
* KeyValuePage suffered from a similar issue with broken highlights (all black) because of missing backgrounds.
* In ConfigDialog, only instanciate IconButtons once (because every tab switch causes a full instantiation; and the initial display implies a full instanciation and an initial tab switch). Otherwise, both instances linger, and catch taps, and as such, double highlights.
* ConfigDialog: Restore the "don't repaint ReaderUI" when switching between similarly sized tabs (re #6131). I never could reproduce that on eInk, and I can't now on the emulator, so I'm assuming @poire-z fixed it during the swap to SVG icons.
* KeyValuePage: Only instanciate Buttons once (again, this is a widget that goes through a full init every page). Again, caused highlight/dimming issues because buttons were stacked.
* Menu: Ditto.
* TouchMenu: Now home of the gnarliest unhilight heuristics, because of the sheer amount of different things that can happen (and/or thanks to stuff not flagged covers_fullscreen properly ;p).
* Bump base
https://github.com/koreader/koreader-base/pull/1280
https://github.com/koreader/koreader-base/pull/1282
https://github.com/koreader/koreader-base/pull/1283
https://github.com/koreader/koreader-base/pull/1284
* Bump android-luajit-launcher
https://github.com/koreader/android-luajit-launcher/pull/284
https://github.com/koreader/android-luajit-launcher/pull/285
https://github.com/koreader/android-luajit-launcher/pull/286
https://github.com/koreader/android-luajit-launcher/pull/287
2021-01-10 00:51:09 +00:00
|
|
|
self.page_info_right_chev = self.page_info_right_chev or Button:new{
|
2019-12-06 21:55:39 +00:00
|
|
|
icon = chevron_right,
|
2017-08-02 17:17:56 +00:00
|
|
|
callback = function() self:nextPage() end,
|
|
|
|
bordersize = 0,
|
2022-11-01 18:22:03 +00:00
|
|
|
show_parent = self.show_parent,
|
2017-08-02 17:17:56 +00:00
|
|
|
}
|
Revamp "flash_ui" handling (#7118)
* Wherever possible, do an actual dumb invert on the Screen BB instead of repainting the widget, *then* inverting it (which is what the "invert" flag does).
* Instead of playing with nextTick/tickAfterNext delays, explicitly fence stuff with forceRePaint
* And, in the few cases where said Mk. 7 quirk kicks in, make the fences more marked by using a well-placed WAIT_FOR_UPDATE_COMPLETE
* Fix an issue in Button where show/hide & enable/disable where actually all toggles, which meant that duplicate calls or timing issues would do the wrong thing. (This broke dimming some icons, and mistakenly dropped the background from FM chevrons, for example).
* Speaking of, fix Button's hide/show to actually restore the background properly (there was a stupid typo in the variable name)
* Still in Button, fix the insanity of the double repaint on rounded buttons. Turns out it made sense, after all (and was related to said missing background, and bad interaction with invert & text with no background).
* KeyValuePage suffered from a similar issue with broken highlights (all black) because of missing backgrounds.
* In ConfigDialog, only instanciate IconButtons once (because every tab switch causes a full instantiation; and the initial display implies a full instanciation and an initial tab switch). Otherwise, both instances linger, and catch taps, and as such, double highlights.
* ConfigDialog: Restore the "don't repaint ReaderUI" when switching between similarly sized tabs (re #6131). I never could reproduce that on eInk, and I can't now on the emulator, so I'm assuming @poire-z fixed it during the swap to SVG icons.
* KeyValuePage: Only instanciate Buttons once (again, this is a widget that goes through a full init every page). Again, caused highlight/dimming issues because buttons were stacked.
* Menu: Ditto.
* TouchMenu: Now home of the gnarliest unhilight heuristics, because of the sheer amount of different things that can happen (and/or thanks to stuff not flagged covers_fullscreen properly ;p).
* Bump base
https://github.com/koreader/koreader-base/pull/1280
https://github.com/koreader/koreader-base/pull/1282
https://github.com/koreader/koreader-base/pull/1283
https://github.com/koreader/koreader-base/pull/1284
* Bump android-luajit-launcher
https://github.com/koreader/android-luajit-launcher/pull/284
https://github.com/koreader/android-luajit-launcher/pull/285
https://github.com/koreader/android-luajit-launcher/pull/286
https://github.com/koreader/android-luajit-launcher/pull/287
2021-01-10 00:51:09 +00:00
|
|
|
self.page_info_first_chev = self.page_info_first_chev or Button:new{
|
2019-12-06 21:55:39 +00:00
|
|
|
icon = chevron_first,
|
2017-08-02 17:17:56 +00:00
|
|
|
callback = function() self:goToPage(1) end,
|
|
|
|
bordersize = 0,
|
2022-11-01 18:22:03 +00:00
|
|
|
show_parent = self.show_parent,
|
2017-08-02 17:17:56 +00:00
|
|
|
}
|
Revamp "flash_ui" handling (#7118)
* Wherever possible, do an actual dumb invert on the Screen BB instead of repainting the widget, *then* inverting it (which is what the "invert" flag does).
* Instead of playing with nextTick/tickAfterNext delays, explicitly fence stuff with forceRePaint
* And, in the few cases where said Mk. 7 quirk kicks in, make the fences more marked by using a well-placed WAIT_FOR_UPDATE_COMPLETE
* Fix an issue in Button where show/hide & enable/disable where actually all toggles, which meant that duplicate calls or timing issues would do the wrong thing. (This broke dimming some icons, and mistakenly dropped the background from FM chevrons, for example).
* Speaking of, fix Button's hide/show to actually restore the background properly (there was a stupid typo in the variable name)
* Still in Button, fix the insanity of the double repaint on rounded buttons. Turns out it made sense, after all (and was related to said missing background, and bad interaction with invert & text with no background).
* KeyValuePage suffered from a similar issue with broken highlights (all black) because of missing backgrounds.
* In ConfigDialog, only instanciate IconButtons once (because every tab switch causes a full instantiation; and the initial display implies a full instanciation and an initial tab switch). Otherwise, both instances linger, and catch taps, and as such, double highlights.
* ConfigDialog: Restore the "don't repaint ReaderUI" when switching between similarly sized tabs (re #6131). I never could reproduce that on eInk, and I can't now on the emulator, so I'm assuming @poire-z fixed it during the swap to SVG icons.
* KeyValuePage: Only instanciate Buttons once (again, this is a widget that goes through a full init every page). Again, caused highlight/dimming issues because buttons were stacked.
* Menu: Ditto.
* TouchMenu: Now home of the gnarliest unhilight heuristics, because of the sheer amount of different things that can happen (and/or thanks to stuff not flagged covers_fullscreen properly ;p).
* Bump base
https://github.com/koreader/koreader-base/pull/1280
https://github.com/koreader/koreader-base/pull/1282
https://github.com/koreader/koreader-base/pull/1283
https://github.com/koreader/koreader-base/pull/1284
* Bump android-luajit-launcher
https://github.com/koreader/android-luajit-launcher/pull/284
https://github.com/koreader/android-luajit-launcher/pull/285
https://github.com/koreader/android-luajit-launcher/pull/286
https://github.com/koreader/android-luajit-launcher/pull/287
2021-01-10 00:51:09 +00:00
|
|
|
self.page_info_last_chev = self.page_info_last_chev or Button:new{
|
2019-12-06 21:55:39 +00:00
|
|
|
icon = chevron_last,
|
2017-08-02 17:17:56 +00:00
|
|
|
callback = function() self:goToPage(self.pages) end,
|
|
|
|
bordersize = 0,
|
2022-11-01 18:22:03 +00:00
|
|
|
show_parent = self.show_parent,
|
2017-08-02 17:17:56 +00:00
|
|
|
}
|
|
|
|
self.page_info_spacer = HorizontalSpan:new{
|
|
|
|
width = Screen:scaleBySize(32),
|
|
|
|
}
|
2017-09-28 13:35:25 +00:00
|
|
|
|
|
|
|
if self.callback_return == nil and self.return_button == nil then
|
|
|
|
self.page_return_arrow:hide()
|
|
|
|
elseif self.callback_return == nil then
|
|
|
|
self.page_return_arrow:disable()
|
|
|
|
end
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
self.return_button = HorizontalGroup:new{
|
|
|
|
HorizontalSpan:new{
|
|
|
|
width = Size.span.horizontal_small,
|
|
|
|
},
|
|
|
|
self.page_return_arrow,
|
2022-01-10 18:14:40 +00:00
|
|
|
HorizontalSpan:new{
|
|
|
|
width = self.dimen.w - self.page_return_arrow:getSize().w - Size.span.horizontal_small,
|
|
|
|
},
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
}
|
2017-09-28 13:35:25 +00:00
|
|
|
|
2017-08-02 17:17:56 +00:00
|
|
|
self.page_info_left_chev:hide()
|
|
|
|
self.page_info_right_chev:hide()
|
|
|
|
self.page_info_first_chev:hide()
|
|
|
|
self.page_info_last_chev:hide()
|
|
|
|
|
Revamp "flash_ui" handling (#7118)
* Wherever possible, do an actual dumb invert on the Screen BB instead of repainting the widget, *then* inverting it (which is what the "invert" flag does).
* Instead of playing with nextTick/tickAfterNext delays, explicitly fence stuff with forceRePaint
* And, in the few cases where said Mk. 7 quirk kicks in, make the fences more marked by using a well-placed WAIT_FOR_UPDATE_COMPLETE
* Fix an issue in Button where show/hide & enable/disable where actually all toggles, which meant that duplicate calls or timing issues would do the wrong thing. (This broke dimming some icons, and mistakenly dropped the background from FM chevrons, for example).
* Speaking of, fix Button's hide/show to actually restore the background properly (there was a stupid typo in the variable name)
* Still in Button, fix the insanity of the double repaint on rounded buttons. Turns out it made sense, after all (and was related to said missing background, and bad interaction with invert & text with no background).
* KeyValuePage suffered from a similar issue with broken highlights (all black) because of missing backgrounds.
* In ConfigDialog, only instanciate IconButtons once (because every tab switch causes a full instantiation; and the initial display implies a full instanciation and an initial tab switch). Otherwise, both instances linger, and catch taps, and as such, double highlights.
* ConfigDialog: Restore the "don't repaint ReaderUI" when switching between similarly sized tabs (re #6131). I never could reproduce that on eInk, and I can't now on the emulator, so I'm assuming @poire-z fixed it during the swap to SVG icons.
* KeyValuePage: Only instanciate Buttons once (again, this is a widget that goes through a full init every page). Again, caused highlight/dimming issues because buttons were stacked.
* Menu: Ditto.
* TouchMenu: Now home of the gnarliest unhilight heuristics, because of the sheer amount of different things that can happen (and/or thanks to stuff not flagged covers_fullscreen properly ;p).
* Bump base
https://github.com/koreader/koreader-base/pull/1280
https://github.com/koreader/koreader-base/pull/1282
https://github.com/koreader/koreader-base/pull/1283
https://github.com/koreader/koreader-base/pull/1284
* Bump android-luajit-launcher
https://github.com/koreader/android-luajit-launcher/pull/284
https://github.com/koreader/android-luajit-launcher/pull/285
https://github.com/koreader/android-luajit-launcher/pull/286
https://github.com/koreader/android-luajit-launcher/pull/287
2021-01-10 00:51:09 +00:00
|
|
|
self.page_info_text = self.page_info_text or Button:new{
|
2017-08-02 17:17:56 +00:00
|
|
|
text = "",
|
|
|
|
hold_input = {
|
2019-03-01 11:59:39 +00:00
|
|
|
title = _("Enter page number"),
|
2017-08-02 17:17:56 +00:00
|
|
|
type = "number",
|
|
|
|
hint_func = function()
|
|
|
|
return "(" .. "1 - " .. self.pages .. ")"
|
|
|
|
end,
|
2021-04-10 22:08:29 +00:00
|
|
|
deny_blank_input = true,
|
2017-08-02 17:17:56 +00:00
|
|
|
callback = function(input)
|
|
|
|
local page = tonumber(input)
|
2017-08-06 09:57:20 +00:00
|
|
|
if page and page >= 1 and page <= self.pages then
|
2017-08-02 17:17:56 +00:00
|
|
|
self:goToPage(page)
|
|
|
|
end
|
|
|
|
end,
|
2021-08-10 19:18:38 +00:00
|
|
|
ok_text = _("Go to page"),
|
2017-08-02 17:17:56 +00:00
|
|
|
},
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
call_hold_input_on_tap = true,
|
2017-08-02 17:17:56 +00:00
|
|
|
bordersize = 0,
|
|
|
|
text_font_face = "pgfont",
|
|
|
|
text_font_bold = false,
|
|
|
|
}
|
|
|
|
self.page_info = HorizontalGroup:new{
|
|
|
|
self.page_info_first_chev,
|
|
|
|
self.page_info_spacer,
|
|
|
|
self.page_info_left_chev,
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
self.page_info_spacer,
|
2017-08-02 17:17:56 +00:00
|
|
|
self.page_info_text,
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
self.page_info_spacer,
|
2017-08-02 17:17:56 +00:00
|
|
|
self.page_info_right_chev,
|
|
|
|
self.page_info_spacer,
|
|
|
|
self.page_info_last_chev,
|
|
|
|
}
|
|
|
|
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
local padding = Size.padding.large
|
2022-01-08 15:58:36 +00:00
|
|
|
self.item_width = self.dimen.w - 2 * padding
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
|
2017-08-02 17:17:56 +00:00
|
|
|
local footer = BottomContainer:new{
|
2022-01-08 15:58:36 +00:00
|
|
|
dimen = self.dimen:copy(),
|
2017-08-02 17:17:56 +00:00
|
|
|
self.page_info,
|
|
|
|
}
|
2021-12-01 11:39:48 +00:00
|
|
|
if self.single_page then
|
|
|
|
footer = nil
|
|
|
|
end
|
|
|
|
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
local page_return = BottomContainer:new{
|
2022-01-08 15:58:36 +00:00
|
|
|
dimen = self.dimen:copy(),
|
2022-01-10 18:14:40 +00:00
|
|
|
self.return_button,
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
}
|
2017-08-02 17:17:56 +00:00
|
|
|
|
2022-01-08 15:58:36 +00:00
|
|
|
self.title_bar = TitleBar:new{
|
2016-02-14 21:47:36 +00:00
|
|
|
title = self.title,
|
2022-01-10 18:14:40 +00:00
|
|
|
fullscreen = self.covers_fullscreen,
|
2022-01-08 15:58:36 +00:00
|
|
|
width = self.width,
|
2022-11-01 18:22:03 +00:00
|
|
|
align = self.title_bar_align,
|
2022-01-08 15:58:36 +00:00
|
|
|
with_bottom_line = true,
|
|
|
|
bottom_line_color = Blitbuffer.COLOR_DARK_GRAY,
|
|
|
|
bottom_line_h_padding = padding,
|
2022-11-01 18:22:03 +00:00
|
|
|
left_icon = self.title_bar_left_icon,
|
|
|
|
left_icon_tap_callback = self.title_bar_left_icon_tap_callback,
|
|
|
|
left_icon_hold_callback = self.title_bar_left_icon_hold_callback,
|
2022-01-08 15:58:36 +00:00
|
|
|
close_callback = function() self:onClose() end,
|
2022-11-01 18:22:03 +00:00
|
|
|
show_parent = self.show_parent or self,
|
2016-02-14 21:47:36 +00:00
|
|
|
}
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
|
2016-02-14 21:47:36 +00:00
|
|
|
-- setup main content
|
2022-01-08 15:58:36 +00:00
|
|
|
local available_height = self.dimen.h
|
|
|
|
- self.title_bar:getHeight()
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
- Size.span.vertical_large -- for above page_info (as title_bar adds one itself)
|
2021-12-01 11:39:48 +00:00
|
|
|
- (self.single_page and 0 or self.page_info:getSize().h)
|
2021-02-20 19:15:43 +00:00
|
|
|
- 2*Size.line.thick
|
|
|
|
-- account for possibly 2 separator lines added
|
|
|
|
|
2021-12-01 11:39:48 +00:00
|
|
|
local force_items_per_page
|
|
|
|
if self.single_page then
|
|
|
|
force_items_per_page = math.max(#self.kv_pairs,
|
|
|
|
G_reader_settings:readSetting("keyvalues_per_page") or self:getDefaultKeyValuesPerPage())
|
|
|
|
end
|
|
|
|
|
|
|
|
self.items_per_page = force_items_per_page or
|
|
|
|
G_reader_settings:readSetting("keyvalues_per_page") or self:getDefaultKeyValuesPerPage()
|
2021-02-20 19:15:43 +00:00
|
|
|
self.item_height = math.floor(available_height / self.items_per_page)
|
|
|
|
-- Put half of the pixels lost by floor'ing between title and content
|
2022-01-08 15:58:36 +00:00
|
|
|
local content_height = self.items_per_page * self.item_height
|
|
|
|
local span_height = math.floor((available_height - content_height) / 2)
|
2021-02-20 19:15:43 +00:00
|
|
|
|
|
|
|
-- Font size is not configurable: we can get a good one from the following
|
|
|
|
local TextBoxWidget = require("ui/widget/textboxwidget")
|
|
|
|
local line_extra_height = 1.0 -- ~ 2em -- unscaled_size_check: ignore
|
|
|
|
-- (gives a font size similar to the fixed one from former implementation at 14 items per page)
|
2022-10-25 19:50:40 +00:00
|
|
|
self.items_font_size = math.min(TextBoxWidget:getFontSizeToFitHeight(self.item_height, 1, line_extra_height), 22)
|
2021-02-20 19:15:43 +00:00
|
|
|
|
2016-02-14 21:47:36 +00:00
|
|
|
self.pages = math.ceil(#self.kv_pairs / self.items_per_page)
|
|
|
|
self.main_content = VerticalGroup:new{}
|
2017-07-01 09:30:30 +00:00
|
|
|
|
2022-01-08 15:58:36 +00:00
|
|
|
-- set textviewer height to let our title fully visible (but hide the bottom line)
|
2017-07-01 09:30:30 +00:00
|
|
|
self.textviewer_width = self.item_width
|
2022-01-08 15:58:36 +00:00
|
|
|
self.textviewer_height = self.dimen.h - 2 * (self.title_bar:getHeight() - Size.padding.default - Size.line.thick)
|
2017-07-01 09:30:30 +00:00
|
|
|
|
2016-02-14 21:47:36 +00:00
|
|
|
self:_populateItems()
|
2017-08-02 17:17:56 +00:00
|
|
|
|
|
|
|
local content = OverlapGroup:new{
|
2019-12-06 21:55:39 +00:00
|
|
|
allow_mirroring = false,
|
2022-01-08 15:58:36 +00:00
|
|
|
dimen = self.dimen:copy(),
|
2017-08-02 17:17:56 +00:00
|
|
|
VerticalGroup:new{
|
|
|
|
align = "left",
|
|
|
|
self.title_bar,
|
2021-02-20 19:15:43 +00:00
|
|
|
VerticalSpan:new{ width = span_height },
|
2022-01-08 15:58:36 +00:00
|
|
|
HorizontalGroup:new{
|
|
|
|
HorizontalSpan:new{ width = padding },
|
|
|
|
self.main_content,
|
|
|
|
}
|
2017-08-02 17:17:56 +00:00
|
|
|
},
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
page_return,
|
2017-08-02 17:17:56 +00:00
|
|
|
footer,
|
|
|
|
}
|
2016-02-14 21:47:36 +00:00
|
|
|
-- assemble page
|
|
|
|
self[1] = FrameContainer:new{
|
2022-01-08 15:58:36 +00:00
|
|
|
width = self.dimen.w,
|
2016-02-14 21:47:36 +00:00
|
|
|
height = self.dimen.h,
|
2022-01-08 15:58:36 +00:00
|
|
|
padding = 0,
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
margin = 0,
|
2016-02-14 21:47:36 +00:00
|
|
|
bordersize = 0,
|
|
|
|
background = Blitbuffer.COLOR_WHITE,
|
2021-12-01 11:39:48 +00:00
|
|
|
content,
|
2016-02-14 21:47:36 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2021-02-20 19:15:43 +00:00
|
|
|
function KeyValuePage:getDefaultKeyValuesPerPage()
|
|
|
|
-- Get a default according to Screen DPI (roughly following
|
|
|
|
-- the former implementation building logic)
|
|
|
|
local default_item_height = Size.item.height_default * 1.5 -- we were adding 1/2 as margin
|
|
|
|
local nb_items = math.floor(Screen:getHeight() / default_item_height)
|
|
|
|
nb_items = nb_items - 3 -- account for title and footer heights
|
|
|
|
return nb_items
|
|
|
|
end
|
|
|
|
|
2016-02-14 21:47:36 +00:00
|
|
|
function KeyValuePage:nextPage()
|
|
|
|
local new_page = math.min(self.show_page+1, self.pages)
|
|
|
|
if new_page > self.show_page then
|
|
|
|
self.show_page = new_page
|
|
|
|
self:_populateItems()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function KeyValuePage:prevPage()
|
|
|
|
local new_page = math.max(self.show_page-1, 1)
|
|
|
|
if new_page < self.show_page then
|
|
|
|
self.show_page = new_page
|
|
|
|
self:_populateItems()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-02 17:17:56 +00:00
|
|
|
function KeyValuePage:goToPage(page)
|
|
|
|
self.show_page = page
|
|
|
|
self:_populateItems()
|
|
|
|
end
|
|
|
|
|
2016-02-16 01:56:13 +00:00
|
|
|
-- make sure self.item_margin and self.item_height are set before calling this
|
2016-02-14 21:47:36 +00:00
|
|
|
function KeyValuePage:_populateItems()
|
2022-03-04 20:20:00 +00:00
|
|
|
self.layout = {}
|
2017-08-02 17:17:56 +00:00
|
|
|
self.page_info:resetLayout()
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
self.return_button:resetLayout()
|
2016-02-14 21:47:36 +00:00
|
|
|
self.main_content:clear()
|
|
|
|
local idx_offset = (self.show_page - 1) * self.items_per_page
|
2022-10-25 19:50:40 +00:00
|
|
|
|
|
|
|
-- for flexible middle ratio calculation
|
|
|
|
-- in sync with KeyValueItem actual computation
|
|
|
|
local frame_padding = KeyValueItem.frame_padding
|
|
|
|
local frame_internal_width = self.item_width - frame_padding * 2
|
|
|
|
local middle_padding = KeyValueItem.middle_padding
|
|
|
|
local available_width = frame_internal_width - middle_padding
|
|
|
|
-- Default widths (and position of value widget) if each text fits in 1/2 screen width
|
|
|
|
local key_w = math.floor(frame_internal_width / 2 - middle_padding)
|
|
|
|
local value_w = math.floor(frame_internal_width / 2)
|
|
|
|
|
|
|
|
local key_widget = TextWidget:new{
|
|
|
|
text = " ",
|
|
|
|
max_width = available_width,
|
|
|
|
face = Font:getFace("smallinfofontbold", self.items_font_size),
|
|
|
|
}
|
|
|
|
local value_widget = TextWidget:new{
|
|
|
|
text = " ",
|
|
|
|
max_width = available_width,
|
|
|
|
face = Font:getFace("smallinfofont", self.items_font_size),
|
|
|
|
lang = self.values_lang,
|
|
|
|
}
|
|
|
|
local key_widths = {}
|
|
|
|
local value_widths = {}
|
|
|
|
local tvalue
|
|
|
|
for idx=1, self.items_per_page do
|
|
|
|
local kv_pairs_idx = idx_offset + idx
|
|
|
|
local entry = self.kv_pairs[kv_pairs_idx]
|
|
|
|
if entry == nil then break end
|
2023-04-28 21:53:37 +00:00
|
|
|
if type(entry) == "table" and entry[2] ~= "" then
|
2022-10-25 19:50:40 +00:00
|
|
|
tvalue = tostring(entry[2])
|
|
|
|
tvalue = tvalue:gsub("[\n\t]", "|")
|
|
|
|
|
|
|
|
key_widget:setText(entry[1])
|
|
|
|
value_widget:setText(tvalue)
|
|
|
|
|
|
|
|
table.insert(key_widths, key_widget:getWidth())
|
|
|
|
table.insert(value_widths, value_widget:getWidth())
|
|
|
|
end
|
|
|
|
end
|
|
|
|
key_widget:free()
|
|
|
|
value_widget:free()
|
|
|
|
table.sort(key_widths)
|
|
|
|
table.sort(value_widths)
|
|
|
|
-- first we check if no unfit item at all
|
|
|
|
local width_ratio
|
2022-10-30 00:05:27 +00:00
|
|
|
if (#self.kv_pairs == 0) or
|
2022-12-29 15:36:53 +00:00
|
|
|
(#key_widths == 0) or
|
2022-10-30 00:05:27 +00:00
|
|
|
(key_widths[#key_widths] <= key_w and value_widths[#value_widths] <= value_w) then
|
2022-10-25 19:50:40 +00:00
|
|
|
width_ratio = 1/2
|
|
|
|
end
|
|
|
|
if not width_ratio then
|
|
|
|
-- has to adjust, not fitting 1/2 ratio
|
2023-04-28 21:53:37 +00:00
|
|
|
local least_cut_key_index = #key_widths; -- the key index from which there are least number of cuts
|
|
|
|
local least_cut_count = #key_widths; -- the nb of cuts
|
2022-10-25 19:50:40 +00:00
|
|
|
for vi = #value_widths, 1, -1 do
|
|
|
|
-- from longest to shortest
|
|
|
|
local key_width_limit = available_width - value_widths[vi]
|
|
|
|
|
|
|
|
-- if we were to draw a vertical line at the start of the value item,
|
|
|
|
-- i.e. the border between keys and values, we want the less items cross it the better,
|
|
|
|
-- as the keys/values that cross the line (being cut) make clean alignment impossible
|
|
|
|
-- we track their number and find the line that cuts the least key/value items
|
|
|
|
local key_cut_count = 0
|
2023-04-28 21:53:37 +00:00
|
|
|
local key_index
|
2022-10-25 19:50:40 +00:00
|
|
|
for ki = #key_widths, 1, -1 do
|
|
|
|
-- from longest to shortest for keys too
|
|
|
|
if key_widths[ki] > key_width_limit then
|
|
|
|
key_cut_count = key_cut_count + 1 -- got cut
|
|
|
|
else
|
2023-04-28 21:53:37 +00:00
|
|
|
key_index = ki
|
2022-10-25 19:50:40 +00:00
|
|
|
break -- others are all shorter so no more cut
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local total_cut_count = key_cut_count + (#value_widths - vi) -- latter is value_cut_count, as with each increased index, the previous one got cut
|
2023-04-28 21:53:37 +00:00
|
|
|
if total_cut_count == 0 then
|
2022-11-15 11:04:57 +00:00
|
|
|
-- no cross-over
|
|
|
|
if key_widths[#key_widths] >= key_w then
|
|
|
|
width_ratio = (key_widths[#key_widths] + middle_padding) / frame_internal_width
|
|
|
|
else
|
|
|
|
width_ratio = 1 - value_widths[#value_widths] / frame_internal_width
|
|
|
|
end
|
2022-10-25 19:50:40 +00:00
|
|
|
break
|
2023-04-28 21:53:37 +00:00
|
|
|
elseif total_cut_count < least_cut_count and key_index then
|
|
|
|
least_cut_count = total_cut_count
|
|
|
|
least_cut_key_index = key_index
|
2022-10-25 19:50:40 +00:00
|
|
|
end
|
|
|
|
end
|
2023-04-28 21:53:37 +00:00
|
|
|
if not width_ratio then
|
|
|
|
width_ratio = (key_widths[least_cut_key_index] + middle_padding) / frame_internal_width
|
|
|
|
end
|
2022-10-25 19:50:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
width_ratio = width_ratio or 0.5
|
|
|
|
|
2016-02-14 21:47:36 +00:00
|
|
|
for idx = 1, self.items_per_page do
|
2022-01-31 18:18:35 +00:00
|
|
|
local kv_pairs_idx = idx_offset + idx
|
|
|
|
local entry = self.kv_pairs[kv_pairs_idx]
|
2016-02-14 21:47:36 +00:00
|
|
|
if entry == nil then break end
|
|
|
|
|
|
|
|
if type(entry) == "table" then
|
2022-03-04 20:20:00 +00:00
|
|
|
local kv_item = KeyValueItem:new{
|
2021-02-20 19:15:43 +00:00
|
|
|
height = self.item_height,
|
|
|
|
width = self.item_width,
|
2022-10-25 19:50:40 +00:00
|
|
|
width_ratio = width_ratio,
|
2021-02-20 19:15:43 +00:00
|
|
|
font_size = self.items_font_size,
|
|
|
|
key = entry[1],
|
|
|
|
value = entry[2],
|
|
|
|
value_lang = self.values_lang,
|
|
|
|
callback = entry.callback,
|
2022-01-31 18:18:35 +00:00
|
|
|
hold_callback = entry.hold_callback,
|
2021-02-20 19:15:43 +00:00
|
|
|
textviewer_width = self.textviewer_width,
|
|
|
|
textviewer_height = self.textviewer_height,
|
|
|
|
value_overflow_align = self.value_overflow_align,
|
|
|
|
value_align = self.value_align,
|
2022-01-31 18:18:35 +00:00
|
|
|
kv_pairs_idx = kv_pairs_idx,
|
|
|
|
kv_page = self,
|
2022-11-01 18:22:03 +00:00
|
|
|
show_parent = self.show_parent,
|
2022-03-04 20:20:00 +00:00
|
|
|
}
|
|
|
|
table.insert(self.main_content, kv_item)
|
|
|
|
table.insert(self.layout, { kv_item })
|
2021-02-20 19:15:43 +00:00
|
|
|
if entry.separator then
|
|
|
|
table.insert(self.main_content, LineWidget:new{
|
|
|
|
background = Blitbuffer.COLOR_LIGHT_GRAY,
|
|
|
|
dimen = Geom:new{
|
|
|
|
w = self.item_width,
|
|
|
|
h = Size.line.thick
|
|
|
|
},
|
|
|
|
style = "solid",
|
|
|
|
})
|
|
|
|
end
|
2016-02-14 21:47:36 +00:00
|
|
|
elseif type(entry) == "string" then
|
2021-02-20 19:15:43 +00:00
|
|
|
-- deprecated, use separator=true on a regular k/v table
|
|
|
|
-- (kept in case some user plugins would use this)
|
2016-02-14 21:47:36 +00:00
|
|
|
local c = string.sub(entry, 1, 1)
|
|
|
|
if c == "-" then
|
|
|
|
table.insert(self.main_content, LineWidget:new{
|
2019-03-14 19:58:45 +00:00
|
|
|
background = Blitbuffer.COLOR_LIGHT_GRAY,
|
2016-02-14 21:47:36 +00:00
|
|
|
dimen = Geom:new{
|
|
|
|
w = self.item_width,
|
2017-09-13 14:56:20 +00:00
|
|
|
h = Size.line.thick
|
2016-02-14 21:47:36 +00:00
|
|
|
},
|
|
|
|
style = "solid",
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
|
|
|
|
-- update page information
|
2021-02-26 22:04:11 +00:00
|
|
|
if self.pages >= 1 then
|
|
|
|
self.page_info_text:setText(T(_("Page %1 of %2"), self.show_page, self.pages))
|
|
|
|
if self.pages > 1 then
|
|
|
|
self.page_info_text:enable()
|
|
|
|
else
|
|
|
|
self.page_info_text:disableWithoutDimming()
|
|
|
|
end
|
|
|
|
self.page_info_left_chev:show()
|
|
|
|
self.page_info_right_chev:show()
|
|
|
|
self.page_info_first_chev:show()
|
|
|
|
self.page_info_last_chev:show()
|
|
|
|
|
|
|
|
self.page_info_left_chev:enableDisable(self.show_page > 1)
|
|
|
|
self.page_info_right_chev:enableDisable(self.show_page < self.pages)
|
|
|
|
self.page_info_first_chev:enableDisable(self.show_page > 1)
|
|
|
|
self.page_info_last_chev:enableDisable(self.show_page < self.pages)
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
else
|
2021-02-26 22:04:11 +00:00
|
|
|
self.page_info_text:setText(_("No items"))
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
self.page_info_text:disableWithoutDimming()
|
2021-03-07 22:27:04 +00:00
|
|
|
|
|
|
|
self.page_info_left_chev:hide()
|
|
|
|
self.page_info_right_chev:hide()
|
|
|
|
self.page_info_first_chev:hide()
|
|
|
|
self.page_info_last_chev:hide()
|
[RFC] Pagination UI shenanigans (#7335)
* Menu/KeyValuePage/ReaderGoTo: Unify the dialogs. (Generally, "Enter page number" as title, and "Go to page" as OK button).
* Allow *tapping* on pagination buttons, too. Added spacers around the text to accommodate for that.
* Disable input handlers when <= 1 pages, while still printing the label in black.
* Always display both the label and the chevrons, even on single page content. (Menu being an exception, because it can handle showing no content at all, in which case we hide the chevrons).
* KVP: Tweak the pagination buttons layout in order to have consistent centering, regardless of whether the return arrow is enabled or not. (Also, match Menu's layout, more or less).
* Menu: Minor layout tweaks to follow the KVP tweaks above. Fixes, among possibly other things, buttons in (non-FM) "List" menus overlapping the final entry (e.g., OPDS), and popout menus with a border being misaligned (e.g., Calibre, Find a file).
* CalendarView: Minor layout tweaks to follow the KVP tweaks. Ensures the pagination buttons are laid out in the same way as everywhere else (they used to be a wee bit higher).
2021-02-25 04:15:23 +00:00
|
|
|
end
|
2022-03-04 20:20:00 +00:00
|
|
|
self:moveFocusTo(1, 1, FocusManager.NOT_UNFOCUS)
|
2016-02-14 21:47:36 +00:00
|
|
|
UIManager:setDirty(self, function()
|
|
|
|
return "ui", self.dimen
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
2022-01-31 18:18:35 +00:00
|
|
|
function KeyValuePage:removeKeyValueItem(kv_item)
|
|
|
|
if kv_item.kv_pairs_idx then
|
|
|
|
table.remove(self.kv_pairs, kv_item.kv_pairs_idx)
|
2022-12-29 15:36:53 +00:00
|
|
|
self.pages = math.ceil(#self.kv_pairs / self.items_per_page)
|
|
|
|
self.show_page = math.min(self.show_page, self.pages)
|
2022-01-31 18:18:35 +00:00
|
|
|
self:_populateItems()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-01-11 11:45:00 +00:00
|
|
|
function KeyValuePage:onNextPage()
|
|
|
|
self:nextPage()
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
function KeyValuePage:onPrevPage()
|
|
|
|
self:prevPage()
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2016-02-14 21:47:36 +00:00
|
|
|
function KeyValuePage:onSwipe(arg, ges_ev)
|
2019-12-06 21:55:39 +00:00
|
|
|
local direction = BD.flipDirectionIfMirroredUILayout(ges_ev.direction)
|
|
|
|
if direction == "west" then
|
2016-02-14 21:47:36 +00:00
|
|
|
self:nextPage()
|
|
|
|
return true
|
2019-12-06 21:55:39 +00:00
|
|
|
elseif direction == "east" then
|
2016-02-14 21:47:36 +00:00
|
|
|
self:prevPage()
|
|
|
|
return true
|
2019-12-06 21:55:39 +00:00
|
|
|
elseif direction == "south" then
|
2018-09-21 13:48:40 +00:00
|
|
|
-- Allow easier closing with swipe down
|
|
|
|
self:onClose()
|
2019-12-06 21:55:39 +00:00
|
|
|
elseif direction == "north" then
|
2018-09-21 13:48:40 +00:00
|
|
|
-- no use for now
|
|
|
|
do end -- luacheck: ignore 541
|
|
|
|
else -- diagonal swipe
|
2017-07-01 09:30:30 +00:00
|
|
|
-- trigger full refresh
|
|
|
|
UIManager:setDirty(nil, "full")
|
|
|
|
-- a long diagonal swipe may also be used for taking a screenshot,
|
|
|
|
-- so let it propagate
|
|
|
|
return false
|
2016-02-14 21:47:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-01-25 14:24:06 +00:00
|
|
|
function KeyValuePage:onMultiSwipe(arg, ges_ev)
|
|
|
|
-- For consistency with other fullscreen widgets where swipe south can't be
|
|
|
|
-- used to close and where we then allow any multiswipe to close, allow any
|
|
|
|
-- multiswipe to close this widget too.
|
|
|
|
self:onClose()
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2022-11-01 18:22:03 +00:00
|
|
|
function KeyValuePage:setTitleBarLeftIcon(icon)
|
|
|
|
self.title_bar:setLeftIcon(icon)
|
|
|
|
end
|
|
|
|
|
2016-02-14 21:47:36 +00:00
|
|
|
function KeyValuePage:onClose()
|
|
|
|
UIManager:close(self)
|
Terminal emulator: full rewrite, real vt52 emulator (#8636)
New real terminal emulator, replacing the old plugin.
The emulator is basically a vt52 terminal (enriched with
some ANSI-sequences, as ash, vi and mksh don't behave well
on a vt52 term).
So far working: ash, mksh, bash, nano, vi, busybox, watch...
The input supports: tab-completion; cursor movement;
backspace; start of line, end of line (long press);
page up, page down (long press).
User scripts may be placed in the koterm.koplugin/scripts/
folder, aliases can be put in the file aliases and startup
command in the file profile.user in that folder.
2022-01-28 19:33:09 +00:00
|
|
|
if self.close_callback then
|
|
|
|
self.close_callback()
|
|
|
|
end
|
2016-02-14 21:47:36 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2017-09-28 13:35:25 +00:00
|
|
|
function KeyValuePage:onReturn()
|
|
|
|
if self.callback_return then
|
|
|
|
self:callback_return()
|
|
|
|
UIManager:close(self)
|
Enable HW dithering in a few key places (#4541)
* Enable HW dithering on supported devices (Clara HD, Forma; Oasis 2, PW4)
* FileManager and co. (where appropriate, i.e., when covers are shown)
* Book Status
* Reader, where appropriate:
* CRe: on pages whith image content (for over 7.5% of the screen area, should hopefully leave stuff like bullet points or small scene breaks alone).
* Other engines: on user-request (in the gear tab of the bottom menu), via the new "Dithering" knob (will only appear on supported devices).
* ScreenSaver
* ImageViewer
* Minimize repaints when flash_ui is enabled (by, almost everywhere, only repainting the flashing element, and not the toplevel window which hosts it).
(The first pass of this involved fixing a few Button instances whose show_parent was wrong, in particular, chevrons in the FM & TopMenu).
* Hunted down a few redundant repaints (unneeded setDirty("all") calls),
either by switching the widget to nil when only a refresh was needed, and not a repaint,
or by passing the appropritate widget to setDirty.
(Note to self: Enable *verbose* debugging to catch broken setDirty calls via its post guard).
There were also a few instances of 'em right behind a widget close.
* Don't repaint the underlying widget when initially showing TopMenu & ConfigDialog.
We unfortunately do need to do it when switching tabs, because of their variable heights.
* On Kobo, disabled the extra and completely useless full refresh before suspend/reboot/poweroff, as well as on resume. No more double refreshes!
* Fix another debug guard in Kobo sysfs_light
* Switch ImageWidget & ImageViewer mostly to "ui" updates, which will be better suited to image content pretty much everywhere, REAGL or not.
PS: (Almost :100: commits! :D)
2019-02-07 00:14:37 +00:00
|
|
|
UIManager:setDirty(nil, "ui")
|
2017-09-28 13:35:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-02-14 21:47:36 +00:00
|
|
|
return KeyValuePage
|