2017-09-13 14:56:20 +00:00
|
|
|
|
--[[--
|
|
|
|
|
Widget that displays a shortcut icon for menu item.
|
|
|
|
|
--]]
|
|
|
|
|
|
2019-12-06 21:55:39 +00:00
|
|
|
|
local BD = require("ui/bidi")
|
2017-04-29 08:38:09 +00:00
|
|
|
|
local Blitbuffer = require("ffi/blitbuffer")
|
2013-10-18 20:38:07 +00:00
|
|
|
|
local BottomContainer = require("ui/widget/container/bottomcontainer")
|
|
|
|
|
local Button = require("ui/widget/button")
|
2017-04-29 08:38:09 +00:00
|
|
|
|
local CenterContainer = require("ui/widget/container/centercontainer")
|
|
|
|
|
local Device = require("device")
|
2020-07-20 18:58:39 +00:00
|
|
|
|
local FFIUtil = require("ffi/util")
|
2017-04-29 08:38:09 +00:00
|
|
|
|
local FocusManager = require("ui/widget/focusmanager")
|
2013-10-18 20:38:07 +00:00
|
|
|
|
local Font = require("ui/font")
|
2017-04-29 08:38:09 +00:00
|
|
|
|
local FrameContainer = require("ui/widget/container/framecontainer")
|
2013-10-18 20:38:07 +00:00
|
|
|
|
local Geom = require("ui/geometry")
|
2017-04-29 08:38:09 +00:00
|
|
|
|
local GestureRange = require("ui/gesturerange")
|
|
|
|
|
local HorizontalGroup = require("ui/widget/horizontalgroup")
|
|
|
|
|
local HorizontalSpan = require("ui/widget/horizontalspan")
|
2013-10-22 15:11:31 +00:00
|
|
|
|
local InfoMessage = require("ui/widget/infomessage")
|
2017-04-29 08:38:09 +00:00
|
|
|
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
|
|
|
|
local LeftContainer = require("ui/widget/container/leftcontainer")
|
2019-07-19 19:43:05 +00:00
|
|
|
|
local Math = require("optmath")
|
2017-04-29 08:38:09 +00:00
|
|
|
|
local OverlapGroup = require("ui/widget/overlapgroup")
|
|
|
|
|
local RightContainer = require("ui/widget/container/rightcontainer")
|
2017-09-13 14:56:20 +00:00
|
|
|
|
local Size = require("ui/size")
|
2018-01-13 22:38:53 +00:00
|
|
|
|
local TextBoxWidget = require("ui/widget/textboxwidget")
|
2017-04-29 08:38:09 +00:00
|
|
|
|
local TextWidget = require("ui/widget/textwidget")
|
|
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
|
local UnderlineContainer = require("ui/widget/container/underlinecontainer")
|
|
|
|
|
local VerticalGroup = require("ui/widget/verticalgroup")
|
|
|
|
|
local VerticalSpan = require("ui/widget/verticalspan")
|
|
|
|
|
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
2016-12-29 08:10:38 +00:00
|
|
|
|
local logger = require("logger")
|
2013-10-18 20:38:07 +00:00
|
|
|
|
local _ = require("gettext")
|
2017-04-29 08:38:09 +00:00
|
|
|
|
local Input = Device.input
|
|
|
|
|
local Screen = Device.screen
|
2012-04-15 00:28:48 +00:00
|
|
|
|
|
2013-10-18 20:38:07 +00:00
|
|
|
|
local ItemShortCutIcon = WidgetContainer:new{
|
2017-09-11 08:32:39 +00:00
|
|
|
|
dimen = Geom:new{ w = Screen:scaleBySize(22), h = Screen:scaleBySize(22) },
|
2014-03-13 13:52:43 +00:00
|
|
|
|
key = nil,
|
2017-09-13 14:56:20 +00:00
|
|
|
|
bordersize = Size.border.default,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
radius = 0,
|
2014-07-30 07:00:02 +00:00
|
|
|
|
style = "square",
|
2012-04-29 15:53:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ItemShortCutIcon:init()
|
2014-03-13 13:52:43 +00:00
|
|
|
|
if not self.key then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local radius = 0
|
2014-10-22 13:34:11 +00:00
|
|
|
|
local background = Blitbuffer.COLOR_WHITE
|
2014-03-13 13:52:43 +00:00
|
|
|
|
if self.style == "rounded_corner" then
|
[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
|
|
|
|
radius = math.floor(self.width / 2)
|
2014-03-13 13:52:43 +00:00
|
|
|
|
elseif self.style == "grey_square" then
|
2019-03-14 19:58:45 +00:00
|
|
|
|
background = Blitbuffer.COLOR_LIGHT_GRAY
|
2014-03-13 13:52:43 +00:00
|
|
|
|
end
|
|
|
|
|
|
2019-08-26 13:49:50 +00:00
|
|
|
|
--- @todo Calculate font size by icon size 01.05 2012 (houqp).
|
2016-01-03 07:44:23 +00:00
|
|
|
|
local sc_face
|
2014-03-13 13:52:43 +00:00
|
|
|
|
if self.key:len() > 1 then
|
|
|
|
|
sc_face = Font:getFace("ffont", 14)
|
|
|
|
|
else
|
|
|
|
|
sc_face = Font:getFace("scfont", 22)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self[1] = FrameContainer:new{
|
|
|
|
|
padding = 0,
|
|
|
|
|
bordersize = self.bordersize,
|
|
|
|
|
radius = radius,
|
|
|
|
|
background = background,
|
|
|
|
|
dimen = self.dimen,
|
|
|
|
|
CenterContainer:new{
|
|
|
|
|
dimen = self.dimen,
|
|
|
|
|
TextWidget:new{
|
|
|
|
|
text = self.key,
|
|
|
|
|
face = sc_face,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
2012-04-29 15:53:48 +00:00
|
|
|
|
end
|
|
|
|
|
|
2012-12-07 15:30:15 +00:00
|
|
|
|
--[[
|
|
|
|
|
NOTICE:
|
|
|
|
|
@menu entry must be provided in order to close the menu
|
|
|
|
|
--]]
|
2013-10-18 20:38:07 +00:00
|
|
|
|
local MenuCloseButton = InputContainer:new{
|
2016-02-14 21:47:36 +00:00
|
|
|
|
overlap_align = "right",
|
2017-10-10 20:23:25 +00:00
|
|
|
|
padding_right = 0,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
menu = nil,
|
2021-04-15 00:46:44 +00:00
|
|
|
|
dimen = nil,
|
2012-12-07 15:30:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function MenuCloseButton:init()
|
2019-12-06 21:55:39 +00:00
|
|
|
|
local text_widget = TextWidget:new{
|
2014-03-13 13:52:43 +00:00
|
|
|
|
text = "×",
|
2017-10-10 20:23:25 +00:00
|
|
|
|
face = Font:getFace("cfont", 30), -- this font size align nicely with title
|
2014-03-13 13:52:43 +00:00
|
|
|
|
}
|
2019-12-06 21:55:39 +00:00
|
|
|
|
-- The text box height is greater than its width, and we want this × to be
|
|
|
|
|
-- diagonally aligned with the top right corner (assuming padding_right=0,
|
|
|
|
|
-- or padding_right = padding_top so the diagonal aligment is preserved).
|
|
|
|
|
local text_size = text_widget:getSize()
|
[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 text_width_pad = math.floor((text_size.h - text_size.w) / 2)
|
2019-12-06 21:55:39 +00:00
|
|
|
|
|
|
|
|
|
self[1] = FrameContainer:new{
|
|
|
|
|
bordersize = 0,
|
|
|
|
|
padding = 0,
|
|
|
|
|
padding_top = self.padding_top,
|
|
|
|
|
padding_bottom = self.padding_bottom,
|
|
|
|
|
padding_left = self.padding_left,
|
|
|
|
|
padding_right = self.padding_right + text_width_pad,
|
|
|
|
|
text_widget,
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-14 21:47:36 +00:00
|
|
|
|
self.dimen = Geom:new{
|
2017-10-10 20:23:25 +00:00
|
|
|
|
w = text_size.w + text_width_pad + self.padding_right,
|
|
|
|
|
h = text_size.h,
|
2016-02-14 21:47:36 +00:00
|
|
|
|
}
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self.ges_events.Close = {
|
|
|
|
|
GestureRange:new{
|
|
|
|
|
ges = "tap",
|
|
|
|
|
range = self.dimen,
|
|
|
|
|
},
|
|
|
|
|
doc = "Close menu",
|
|
|
|
|
}
|
2012-12-07 15:30:15 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function MenuCloseButton:onClose()
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self.menu:onClose()
|
|
|
|
|
return true
|
2012-12-07 15:30:15 +00:00
|
|
|
|
end
|
2012-04-29 15:53:48 +00:00
|
|
|
|
|
|
|
|
|
--[[
|
|
|
|
|
Widget that displays an item for menu
|
2012-12-07 15:30:15 +00:00
|
|
|
|
--]]
|
2013-10-18 20:38:07 +00:00
|
|
|
|
local MenuItem = InputContainer:new{
|
2014-03-13 13:52:43 +00:00
|
|
|
|
text = nil,
|
2019-12-17 12:00:37 +00:00
|
|
|
|
bidi_wrap_func = nil,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
show_parent = nil,
|
|
|
|
|
detail = nil,
|
2018-01-13 22:38:53 +00:00
|
|
|
|
font = "cfont",
|
|
|
|
|
font_size = 24,
|
|
|
|
|
infont = "infont",
|
|
|
|
|
infont_size = 18,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
dimen = nil,
|
|
|
|
|
shortcut = nil,
|
|
|
|
|
shortcut_style = "square",
|
|
|
|
|
_underline_container = nil,
|
2018-01-13 22:38:53 +00:00
|
|
|
|
linesize = Size.line.medium,
|
2019-07-19 19:43:05 +00:00
|
|
|
|
single_line = false,
|
2021-02-04 16:43:52 +00:00
|
|
|
|
multilines_show_more_text = false,
|
2019-07-19 19:43:05 +00:00
|
|
|
|
-- Align text & mandatory baselines (only when single_line=true)
|
|
|
|
|
align_baselines = false,
|
2012-04-29 15:53:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function MenuItem:init()
|
2017-10-10 20:23:25 +00:00
|
|
|
|
self.content_width = self.dimen.w - 2 * Size.padding.fullscreen
|
2014-03-13 13:52:43 +00:00
|
|
|
|
local shortcut_icon_dimen = Geom:new()
|
|
|
|
|
if self.shortcut then
|
[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
|
|
|
|
shortcut_icon_dimen.w = math.floor(self.dimen.h * 4/5)
|
2014-03-13 13:52:43 +00:00
|
|
|
|
shortcut_icon_dimen.h = shortcut_icon_dimen.w
|
2017-10-10 20:23:25 +00:00
|
|
|
|
self.content_width = self.content_width - shortcut_icon_dimen.w - Size.span.horizontal_default
|
2014-03-13 13:52:43 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self.detail = self.text
|
|
|
|
|
|
|
|
|
|
-- we need this table per-instance, so we declare it here
|
|
|
|
|
if Device:isTouchDevice() then
|
|
|
|
|
self.ges_events = {
|
|
|
|
|
TapSelect = {
|
|
|
|
|
GestureRange:new{
|
|
|
|
|
ges = "tap",
|
|
|
|
|
range = self.dimen,
|
|
|
|
|
},
|
|
|
|
|
doc = "Select Menu Item",
|
|
|
|
|
},
|
|
|
|
|
HoldSelect = {
|
|
|
|
|
GestureRange:new{
|
|
|
|
|
ges = "hold",
|
|
|
|
|
range = self.dimen,
|
|
|
|
|
},
|
|
|
|
|
doc = "Hold Menu Item",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
2019-11-15 14:14:42 +00:00
|
|
|
|
local max_item_height = self.dimen.h - 2 * self.linesize
|
|
|
|
|
|
|
|
|
|
-- We want to show at least one line, so cap the provided font sizes
|
|
|
|
|
local max_font_size = TextBoxWidget:getFontSizeToFitHeight(max_item_height, 1)
|
|
|
|
|
if self.font_size > max_font_size then
|
|
|
|
|
self.font_size = max_font_size
|
|
|
|
|
end
|
|
|
|
|
if self.infont_size > max_font_size then
|
|
|
|
|
self.infont_size = max_font_size
|
|
|
|
|
end
|
2021-02-04 16:43:52 +00:00
|
|
|
|
if not self.single_line and not self.multilines_show_more_text then
|
2019-11-15 14:14:42 +00:00
|
|
|
|
-- For non single line menus (File browser, Bookmarks), if the
|
|
|
|
|
-- user provided font size is large and would not allow showing
|
|
|
|
|
-- more than one line in our item height, just switch to single
|
|
|
|
|
-- line mode. This allows, when truncating, to take the full
|
|
|
|
|
-- width and cut inside a word to add the ellipsis - while in
|
|
|
|
|
-- multilines modes, with TextBoxWidget, words are wrapped to
|
|
|
|
|
-- follow line breaking rules, and the ellipsis might be placed
|
|
|
|
|
-- way earlier than the full width.
|
|
|
|
|
local min_font_size_2_lines = TextBoxWidget:getFontSizeToFitHeight(max_item_height, 2)
|
|
|
|
|
if self.font_size > min_font_size_2_lines then
|
|
|
|
|
self.single_line = true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2019-10-21 13:20:40 +00:00
|
|
|
|
-- State button and indentation for tree expand/collapse (for TOC)
|
|
|
|
|
local state_button_width = self.state_size.w or 0
|
|
|
|
|
local state_button = self.state or HorizontalSpan:new{
|
|
|
|
|
width = state_button_width,
|
|
|
|
|
}
|
|
|
|
|
local state_indent = self.state and self.state.indent or ""
|
|
|
|
|
local state_container = LeftContainer:new{
|
[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
|
|
|
|
dimen = Geom:new{w = math.floor(self.content_width / 2), h = self.dimen.h},
|
2019-10-21 13:20:40 +00:00
|
|
|
|
HorizontalGroup:new{
|
|
|
|
|
TextWidget:new{
|
|
|
|
|
text = state_indent,
|
|
|
|
|
face = Font:getFace(self.font, self.font_size),
|
|
|
|
|
},
|
|
|
|
|
state_button,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 14:14:42 +00:00
|
|
|
|
-- Font for main text (may have its size decreased to make text fit)
|
|
|
|
|
self.face = Font:getFace(self.font, self.font_size)
|
|
|
|
|
-- Font for "mandatory" on the right
|
|
|
|
|
self.info_face = Font:getFace(self.infont, self.infont_size)
|
|
|
|
|
|
2019-10-21 13:20:40 +00:00
|
|
|
|
-- "mandatory" is the text on the right: file size, page number...
|
|
|
|
|
-- Padding before mandatory
|
2017-10-13 12:42:08 +00:00
|
|
|
|
local text_mandatory_padding = 0
|
|
|
|
|
local text_ellipsis_mandatory_padding = 0
|
2020-08-29 16:25:36 +00:00
|
|
|
|
local mandatory = self.mandatory_func and self.mandatory_func() or self.mandatory
|
|
|
|
|
if mandatory then
|
2017-10-13 12:42:08 +00:00
|
|
|
|
text_mandatory_padding = Size.span.horizontal_default
|
|
|
|
|
-- Smaller padding when ellipsis for better visual feeling
|
|
|
|
|
text_ellipsis_mandatory_padding = Size.span.horizontal_small
|
|
|
|
|
end
|
2020-08-29 16:25:36 +00:00
|
|
|
|
mandatory = mandatory and ""..mandatory or ""
|
2019-11-15 14:14:42 +00:00
|
|
|
|
local mandatory_widget = TextWidget:new{
|
|
|
|
|
text = mandatory,
|
|
|
|
|
face = self.info_face,
|
|
|
|
|
bold = self.bold,
|
|
|
|
|
fgcolor = self.dim and Blitbuffer.COLOR_DARK_GRAY or nil,
|
|
|
|
|
}
|
|
|
|
|
local mandatory_w = mandatory_widget:getWidth()
|
2014-10-14 13:33:13 +00:00
|
|
|
|
|
2019-11-15 14:14:42 +00:00
|
|
|
|
local available_width = self.content_width - state_button_width - text_mandatory_padding - mandatory_w
|
2018-01-13 22:38:53 +00:00
|
|
|
|
local item_name
|
2019-11-15 14:14:42 +00:00
|
|
|
|
|
|
|
|
|
-- Whether we show text on a single or multiple lines, we don't want it shortened
|
|
|
|
|
-- because of some \n that would push the following text on another line that would
|
|
|
|
|
-- overflow and not be displayed, or show a tofu char when displayed by TextWidget:
|
|
|
|
|
-- get rid of any \n (which could be found in highlighted text in bookmarks).
|
|
|
|
|
local text = self.text:gsub("\n", " ")
|
2018-01-13 22:38:53 +00:00
|
|
|
|
|
2019-12-17 12:00:37 +00:00
|
|
|
|
-- Wrap text with provided bidi_wrap_func (only provided by FileChooser,
|
|
|
|
|
-- to correctly display filenames and directories)
|
|
|
|
|
if self.bidi_wrap_func then
|
|
|
|
|
text = self.bidi_wrap_func(text)
|
|
|
|
|
end
|
|
|
|
|
|
2018-01-13 22:38:53 +00:00
|
|
|
|
if self.single_line then -- items only in single line
|
2019-10-21 13:20:40 +00:00
|
|
|
|
-- No font size change: text will be truncated if it overflows
|
|
|
|
|
item_name = TextWidget:new{
|
2019-11-15 14:14:42 +00:00
|
|
|
|
text = text,
|
2019-10-21 13:20:40 +00:00
|
|
|
|
face = self.face,
|
|
|
|
|
bold = self.bold,
|
|
|
|
|
fgcolor = self.dim and Blitbuffer.COLOR_DARK_GRAY or nil,
|
|
|
|
|
}
|
|
|
|
|
local w = item_name:getWidth()
|
2019-11-15 14:14:42 +00:00
|
|
|
|
if w > available_width then
|
|
|
|
|
-- We give it a little more room if truncated for better visual
|
|
|
|
|
-- feeling (which might make it no more truncated, but well...)
|
|
|
|
|
local text_max_width_if_ellipsis = available_width + text_mandatory_padding - text_ellipsis_mandatory_padding
|
2019-10-21 13:20:40 +00:00
|
|
|
|
item_name:setMaxWidth(text_max_width_if_ellipsis)
|
|
|
|
|
end
|
|
|
|
|
if self.align_baselines then -- Align baselines of text and mandatory
|
2019-07-19 19:43:05 +00:00
|
|
|
|
local name_baseline = item_name:getBaseline()
|
|
|
|
|
local mandatory_baseline = mandatory_widget:getBaseline()
|
|
|
|
|
local baselines_diff = Math.round(name_baseline - mandatory_baseline)
|
|
|
|
|
if baselines_diff > 0 then
|
|
|
|
|
mandatory_widget = VerticalGroup:new{
|
|
|
|
|
VerticalSpan:new{width = baselines_diff},
|
|
|
|
|
mandatory_widget,
|
|
|
|
|
}
|
|
|
|
|
elseif baselines_diff < 0 then
|
|
|
|
|
item_name = VerticalGroup:new{
|
|
|
|
|
VerticalSpan:new{width = -baselines_diff},
|
|
|
|
|
item_name,
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|
2018-01-13 22:38:53 +00:00
|
|
|
|
|
2021-02-04 16:43:52 +00:00
|
|
|
|
elseif self.multilines_show_more_text then
|
2019-11-15 14:14:42 +00:00
|
|
|
|
-- Multi-lines, with font size decrease if needed to show more of the text.
|
|
|
|
|
-- It would be costly/slow with use_xtext if we were to try all
|
|
|
|
|
-- font sizes from self.font_size to min_font_size (12).
|
|
|
|
|
-- So, we try to optimize the search of the best font size.
|
|
|
|
|
logger.dbg("multilines_show_more_text menu item font sizing start")
|
|
|
|
|
local function make_item_name(font_size)
|
2018-01-13 22:38:53 +00:00
|
|
|
|
if item_name then
|
|
|
|
|
item_name:free()
|
|
|
|
|
end
|
2019-11-15 14:14:42 +00:00
|
|
|
|
logger.dbg("multilines_show_more_text trying font size", font_size)
|
2018-01-13 22:38:53 +00:00
|
|
|
|
item_name = TextBoxWidget:new {
|
2019-11-15 14:14:42 +00:00
|
|
|
|
text = text,
|
|
|
|
|
face = Font:getFace(self.font, font_size),
|
|
|
|
|
width = available_width,
|
2018-01-13 22:38:53 +00:00
|
|
|
|
alignment = "left",
|
|
|
|
|
bold = self.bold,
|
2019-03-14 19:58:45 +00:00
|
|
|
|
fgcolor = self.dim and Blitbuffer.COLOR_DARK_GRAY or nil,
|
2018-01-13 22:38:53 +00:00
|
|
|
|
}
|
2019-11-15 14:14:42 +00:00
|
|
|
|
-- return true if we fit
|
|
|
|
|
return item_name:getSize().h <= max_item_height
|
2019-10-22 10:48:47 +00:00
|
|
|
|
end
|
2019-11-15 14:14:42 +00:00
|
|
|
|
local min_font_size = 12
|
|
|
|
|
-- First, try with specified font size: short text might fit
|
|
|
|
|
if not make_item_name(self.font_size) then
|
|
|
|
|
-- It doesn't, try with min font size: very long text might not fit
|
|
|
|
|
if not make_item_name(min_font_size) then
|
|
|
|
|
-- Does not fit with min font size: keep widget with min_font_size, but
|
|
|
|
|
-- impose a max height to show only the first lines up to where it fits
|
2019-10-22 10:48:47 +00:00
|
|
|
|
item_name:free()
|
2019-11-15 14:14:42 +00:00
|
|
|
|
item_name.height = max_item_height
|
|
|
|
|
item_name.height_adjust = true
|
|
|
|
|
item_name.height_overflow_show_ellipsis = true
|
|
|
|
|
item_name:init()
|
2019-10-22 10:48:47 +00:00
|
|
|
|
else
|
2019-11-15 14:14:42 +00:00
|
|
|
|
-- Text fits with min font size: try to find some larger
|
|
|
|
|
-- font size in between that make text fit, with some
|
|
|
|
|
-- binary search to limit the number of checks.
|
|
|
|
|
local bad_font_size = self.font_size
|
|
|
|
|
local good_font_size = min_font_size
|
|
|
|
|
local item_name_is_good = true
|
|
|
|
|
while true do
|
|
|
|
|
local test_font_size = math.floor((good_font_size + bad_font_size) / 2)
|
|
|
|
|
if test_font_size == good_font_size then -- +1 would be bad_font_size
|
|
|
|
|
if not item_name_is_good then
|
|
|
|
|
make_item_name(good_font_size)
|
|
|
|
|
end
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
if make_item_name(test_font_size) then
|
|
|
|
|
good_font_size = test_font_size
|
|
|
|
|
item_name_is_good = true
|
|
|
|
|
else
|
|
|
|
|
bad_font_size = test_font_size
|
|
|
|
|
item_name_is_good = false
|
|
|
|
|
end
|
2018-02-04 18:48:39 +00:00
|
|
|
|
end
|
2019-10-22 10:48:47 +00:00
|
|
|
|
end
|
2018-01-13 22:38:53 +00:00
|
|
|
|
end
|
2019-11-15 14:14:42 +00:00
|
|
|
|
else
|
|
|
|
|
-- Multi-lines, with fixed user provided font size
|
|
|
|
|
item_name = TextBoxWidget:new {
|
|
|
|
|
text = text,
|
|
|
|
|
face = self.face,
|
|
|
|
|
width = available_width,
|
|
|
|
|
height = max_item_height,
|
|
|
|
|
height_adjust = true,
|
|
|
|
|
height_overflow_show_ellipsis = true,
|
|
|
|
|
alignment = "left",
|
|
|
|
|
bold = self.bold,
|
|
|
|
|
fgcolor = self.dim and Blitbuffer.COLOR_DARK_GRAY or nil,
|
|
|
|
|
}
|
2018-01-13 22:38:53 +00:00
|
|
|
|
end
|
|
|
|
|
|
2014-03-13 13:52:43 +00:00
|
|
|
|
local text_container = LeftContainer:new{
|
|
|
|
|
dimen = Geom:new{w = self.content_width, h = self.dimen.h},
|
2014-10-14 13:33:13 +00:00
|
|
|
|
HorizontalGroup:new{
|
|
|
|
|
HorizontalSpan:new{
|
|
|
|
|
width = self.state_size.w,
|
|
|
|
|
},
|
2018-01-13 22:38:53 +00:00
|
|
|
|
item_name,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-04-04 15:02:29 +00:00
|
|
|
|
|
2014-03-13 13:52:43 +00:00
|
|
|
|
local mandatory_container = RightContainer:new{
|
|
|
|
|
dimen = Geom:new{w = self.content_width, h = self.dimen.h},
|
2018-01-13 22:38:53 +00:00
|
|
|
|
mandatory_widget,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self._underline_container = UnderlineContainer:new{
|
2018-01-13 22:38:53 +00:00
|
|
|
|
color = self.line_color,
|
|
|
|
|
linesize = self.linesize,
|
2014-10-14 13:33:13 +00:00
|
|
|
|
vertical_align = "center",
|
2018-01-13 22:38:53 +00:00
|
|
|
|
padding = 0,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
dimen = Geom:new{
|
|
|
|
|
w = self.content_width,
|
|
|
|
|
h = self.dimen.h
|
|
|
|
|
},
|
|
|
|
|
HorizontalGroup:new{
|
|
|
|
|
align = "center",
|
|
|
|
|
OverlapGroup:new{
|
|
|
|
|
dimen = Geom:new{w = self.content_width, h = self.dimen.h},
|
2014-10-14 13:33:13 +00:00
|
|
|
|
state_container,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
text_container,
|
|
|
|
|
mandatory_container,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-10-10 20:23:25 +00:00
|
|
|
|
local hgroup = HorizontalGroup:new{
|
|
|
|
|
align = "center",
|
2021-04-15 17:07:34 +00:00
|
|
|
|
HorizontalSpan:new{ width = self.items_padding or Size.padding.fullscreen },
|
2017-10-10 20:23:25 +00:00
|
|
|
|
}
|
|
|
|
|
if self.shortcut then
|
|
|
|
|
table.insert(hgroup, ItemShortCutIcon:new{
|
|
|
|
|
dimen = shortcut_icon_dimen,
|
|
|
|
|
key = self.shortcut,
|
|
|
|
|
style = self.shortcut_style,
|
|
|
|
|
})
|
|
|
|
|
table.insert(hgroup, HorizontalSpan:new{ width = Size.span.horizontal_default })
|
|
|
|
|
end
|
|
|
|
|
table.insert(hgroup, self._underline_container)
|
2019-12-06 21:55:39 +00:00
|
|
|
|
table.insert(hgroup, HorizontalSpan:new{ width = Size.padding.fullscreen })
|
2017-10-10 20:23:25 +00:00
|
|
|
|
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self[1] = FrameContainer:new{
|
|
|
|
|
bordersize = 0,
|
|
|
|
|
padding = 0,
|
2017-10-10 20:23:25 +00:00
|
|
|
|
hgroup,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
}
|
2012-04-29 15:53:48 +00:00
|
|
|
|
end
|
|
|
|
|
|
2018-02-05 14:42:26 +00:00
|
|
|
|
function MenuItem:onFocus(initial_focus)
|
|
|
|
|
if Device:isTouchDevice() then
|
|
|
|
|
-- Devices which are Keys capable will get this onFocus called by
|
|
|
|
|
-- updateItems(), which will toggle the underline color of first item.
|
|
|
|
|
-- If the device is also Touch capable, let's not show the initial
|
|
|
|
|
-- underline for a prettier display (it will be shown only when keys
|
|
|
|
|
-- are used).
|
|
|
|
|
if not initial_focus or self.menu.did_focus_with_keys then
|
|
|
|
|
self._underline_container.color = Blitbuffer.COLOR_BLACK
|
|
|
|
|
self.menu.did_focus_with_keys = true
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
self._underline_container.color = Blitbuffer.COLOR_BLACK
|
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
|
return true
|
2012-04-29 15:53:48 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function MenuItem:onUnfocus()
|
2018-01-13 22:38:53 +00:00
|
|
|
|
self._underline_container.color = self.line_color
|
2014-03-13 13:52:43 +00:00
|
|
|
|
return true
|
2012-04-29 15:53:48 +00:00
|
|
|
|
end
|
|
|
|
|
|
2012-05-28 16:59:16 +00:00
|
|
|
|
function MenuItem:onShowItemDetail()
|
2017-05-08 07:26:01 +00:00
|
|
|
|
UIManager:show(InfoMessage:new{ text = self.detail, })
|
2014-03-13 13:52:43 +00:00
|
|
|
|
return true
|
2012-04-29 15:53:48 +00:00
|
|
|
|
end
|
|
|
|
|
|
2014-10-21 14:18:07 +00:00
|
|
|
|
function MenuItem:getGesPosition(ges)
|
|
|
|
|
local dimen = self[1].dimen
|
|
|
|
|
return {
|
2021-03-03 18:39:22 +00:00
|
|
|
|
x = (ges.pos.x - dimen.x) / dimen.w,
|
|
|
|
|
y = (ges.pos.y - dimen.y) / dimen.h,
|
2014-10-21 14:18:07 +00:00
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function MenuItem:onTapSelect(arg, ges)
|
|
|
|
|
local pos = self:getGesPosition(ges)
|
2017-10-10 21:50:45 +00:00
|
|
|
|
if G_reader_settings:isFalse("flash_ui") then
|
2016-12-29 08:10:38 +00:00
|
|
|
|
logger.dbg("creating coroutine for menu select")
|
2015-09-14 16:59:00 +00:00
|
|
|
|
local co = coroutine.create(function()
|
|
|
|
|
self.menu:onMenuSelect(self.table, pos)
|
|
|
|
|
end)
|
|
|
|
|
coroutine.resume(co)
|
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
|
|
|
|
|
--
|
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
|
|
|
|
logger.dbg("creating coroutine for menu select")
|
|
|
|
|
local co = coroutine.create(function()
|
|
|
|
|
self.menu:onMenuSelect(self.table, pos)
|
|
|
|
|
end)
|
|
|
|
|
coroutine.resume(co)
|
Tame some ButtonTable users into re-using Buttontable instances if possible (#7166)
* QuickDictLookup, ImageViewer, NumberPicker: Smarter `update` that will re-use most of the widget's layout instead of re-instantiating all the things.
* SpinWidget/DoubleSpinWidget: The NumberPicker change above renders a hack to preserve alpha on these widgets almost unnecessary. Also fixed said hack to also apply to the center, value button.
* Button: Don't re-instantiate the frame in setText/setIcon when unnecessary (e.g., no change at all, or no layout change).
* Button: Add a refresh method that repaints and refreshes a *specific* Button (provided it's been painted once) all on its lonesome.
* ConfigDialog: Free everything that's going to be re-instatiated on update
* A few more post #7118 fixes:
* SkimTo: Always flag the chapter nav buttons as vsync
* Button: Fix the highlight on rounded buttons when vsync is enabled (e.g., it's now entirely visible, instead of showing a weird inverted corner glitch).
* Some more heuristic tweaks in Menu/TouchMenu/Button/IconButton
* ButtonTable: fix the annoying rounding issue I'd noticed in #7054 ;).
* Enable dithering in TextBoxWidget (e.g., in the Wikipedia full view). This involved moving the HW dithering align fixup to base, where it always ought to have been ;).
* Switch a few widgets that were using "partial" on close to "ui", or, more rarely, "flashui". The intent being to limit "partial" purely to the Reader, because it has a latency cost when mixed with other refreshes, which happens often enough in UI ;).
* Minor documentation tweaks around UIManager's `setDirty` to reflect that change.
* ReaderFooter: Force a footer repaint on resume if it is visible (otherwise, just update it).
* ReaderBookmark: In the same vein, don't repaint an invisible footer on bookmark count changes.
2021-01-28 23:20:15 +00:00
|
|
|
|
|
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:forceRePaint()
|
2017-10-10 21:50:45 +00:00
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
|
return true
|
2012-11-11 06:00:52 +00:00
|
|
|
|
end
|
|
|
|
|
|
2014-10-21 14:18:07 +00:00
|
|
|
|
function MenuItem:onHoldSelect(arg, ges)
|
|
|
|
|
local pos = self:getGesPosition(ges)
|
2017-10-10 21:50:45 +00:00
|
|
|
|
if G_reader_settings:isFalse("flash_ui") then
|
2014-10-21 14:18:07 +00:00
|
|
|
|
self.menu:onMenuHold(self.table, pos)
|
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 (#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
|
|
|
|
|
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
|
|
|
|
|
--
|
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[1].invert = false
|
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:widgetInvert(self[1], self[1].dimen.x, self[1].dimen.y)
|
|
|
|
|
UIManager:setDirty(nil, "ui", self[1].dimen)
|
Tame some ButtonTable users into re-using Buttontable instances if possible (#7166)
* QuickDictLookup, ImageViewer, NumberPicker: Smarter `update` that will re-use most of the widget's layout instead of re-instantiating all the things.
* SpinWidget/DoubleSpinWidget: The NumberPicker change above renders a hack to preserve alpha on these widgets almost unnecessary. Also fixed said hack to also apply to the center, value button.
* Button: Don't re-instantiate the frame in setText/setIcon when unnecessary (e.g., no change at all, or no layout change).
* Button: Add a refresh method that repaints and refreshes a *specific* Button (provided it's been painted once) all on its lonesome.
* ConfigDialog: Free everything that's going to be re-instatiated on update
* A few more post #7118 fixes:
* SkimTo: Always flag the chapter nav buttons as vsync
* Button: Fix the highlight on rounded buttons when vsync is enabled (e.g., it's now entirely visible, instead of showing a weird inverted corner glitch).
* Some more heuristic tweaks in Menu/TouchMenu/Button/IconButton
* ButtonTable: fix the annoying rounding issue I'd noticed in #7054 ;).
* Enable dithering in TextBoxWidget (e.g., in the Wikipedia full view). This involved moving the HW dithering align fixup to base, where it always ought to have been ;).
* Switch a few widgets that were using "partial" on close to "ui", or, more rarely, "flashui". The intent being to limit "partial" purely to the Reader, because it has a latency cost when mixed with other refreshes, which happens often enough in UI ;).
* Minor documentation tweaks around UIManager's `setDirty` to reflect that change.
* ReaderFooter: Force a footer repaint on resume if it is visible (otherwise, just update it).
* ReaderBookmark: In the same vein, don't repaint an invisible footer on bookmark count changes.
2021-01-28 23:20:15 +00:00
|
|
|
|
|
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
|
|
|
|
-- Callback
|
|
|
|
|
--
|
|
|
|
|
self.menu:onMenuHold(self.table, pos)
|
|
|
|
|
|
|
|
|
|
UIManager:forceRePaint()
|
2017-10-10 21:50:45 +00:00
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
|
return true
|
2014-01-18 15:15:44 +00:00
|
|
|
|
end
|
|
|
|
|
|
2012-04-29 15:53:48 +00:00
|
|
|
|
--[[
|
|
|
|
|
Widget that displays menu
|
2012-12-07 15:30:15 +00:00
|
|
|
|
--]]
|
2013-10-18 20:38:07 +00:00
|
|
|
|
local Menu = FocusManager:new{
|
2014-03-13 13:52:43 +00:00
|
|
|
|
show_parent = nil,
|
|
|
|
|
|
|
|
|
|
title = "No Title",
|
|
|
|
|
-- default width and height
|
2017-09-11 08:32:39 +00:00
|
|
|
|
width = nil,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
-- height will be calculated according to item number if not given
|
|
|
|
|
height = nil,
|
2017-09-13 14:56:20 +00:00
|
|
|
|
header_padding = Size.padding.large,
|
2021-04-15 00:46:44 +00:00
|
|
|
|
dimen = nil,
|
|
|
|
|
item_table = nil, -- NOT mandatory (will be empty)
|
2014-03-13 13:52:43 +00:00
|
|
|
|
item_shortcuts = {
|
|
|
|
|
"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P",
|
|
|
|
|
"A", "S", "D", "F", "G", "H", "J", "K", "L", "Del",
|
2018-03-30 21:22:18 +00:00
|
|
|
|
"Z", "X", "C", "V", "B", "N", "M", ".", "Sym",
|
2014-03-13 13:52:43 +00:00
|
|
|
|
},
|
|
|
|
|
item_table_stack = nil,
|
|
|
|
|
is_enable_shortcut = true,
|
|
|
|
|
|
|
|
|
|
item_dimen = nil,
|
|
|
|
|
page = 1,
|
|
|
|
|
|
|
|
|
|
item_group = nil,
|
|
|
|
|
page_info = nil,
|
2014-09-05 13:07:21 +00:00
|
|
|
|
page_return = nil,
|
|
|
|
|
|
2021-02-04 16:43:52 +00:00
|
|
|
|
items_per_page_default = 14,
|
|
|
|
|
items_per_page = nil,
|
|
|
|
|
items_font_size = nil,
|
|
|
|
|
items_mandatory_font_size = nil,
|
|
|
|
|
multilines_show_more_text = nil,
|
|
|
|
|
-- Global settings or default values will be used if not provided
|
|
|
|
|
|
2014-03-13 13:52:43 +00:00
|
|
|
|
-- set this to true to not paint as popup menu
|
|
|
|
|
is_borderless = false,
|
|
|
|
|
-- if you want to embed the menu widget into another widget, set
|
|
|
|
|
-- this to false
|
|
|
|
|
is_popout = true,
|
|
|
|
|
-- set this to true to add close button
|
|
|
|
|
has_close_button = true,
|
|
|
|
|
-- close_callback is a function, which is executed when menu is closed
|
|
|
|
|
-- it is usually set by the widget which creates the menu
|
2018-01-13 22:38:53 +00:00
|
|
|
|
close_callback = nil,
|
|
|
|
|
linesize = Size.line.medium,
|
2019-03-14 19:58:45 +00:00
|
|
|
|
line_color = Blitbuffer.COLOR_DARK_GRAY,
|
2012-04-29 15:53:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-08 17:18:40 +00:00
|
|
|
|
function Menu:_recalculateDimen()
|
2021-02-04 16:43:52 +00:00
|
|
|
|
self.perpage = self.items_per_page or G_reader_settings:readSetting("items_per_page") or self.items_per_page_default
|
2018-01-13 22:38:53 +00:00
|
|
|
|
self.span_width = 0
|
|
|
|
|
local height_dim
|
|
|
|
|
local bottom_height = 0
|
|
|
|
|
local top_height = 0
|
|
|
|
|
if self.page_return_arrow and self.page_info_text then
|
|
|
|
|
bottom_height = math.max(self.page_return_arrow:getSize().h, self.page_info_text:getSize().h)
|
|
|
|
|
+ 2 * Size.padding.button
|
2014-10-25 08:01:23 +00:00
|
|
|
|
end
|
2018-01-13 22:38:53 +00:00
|
|
|
|
if self.menu_title and not self.no_title then
|
[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
|
|
|
|
top_height = self.menu_title_group:getSize().h + self.header_padding
|
2018-01-13 22:38:53 +00:00
|
|
|
|
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
|
|
|
|
height_dim = self.inner_dimen.h - bottom_height - top_height
|
2018-01-13 22:38:53 +00:00
|
|
|
|
self.item_dimen.h = math.floor(height_dim / self.perpage)
|
[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.span_width = math.floor((height_dim - (self.perpage * (self.item_dimen.h ))) / 2 - 1)
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self.page_num = math.ceil(#self.item_table / self.perpage)
|
2017-10-21 17:53:56 +00:00
|
|
|
|
-- fix current page if out of range
|
|
|
|
|
if self.page_num > 0 and self.page > self.page_num then self.page = self.page_num end
|
2012-12-08 17:18:40 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Menu:init()
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self.show_parent = self.show_parent or self
|
2021-04-15 00:46:44 +00:00
|
|
|
|
self.item_table = self.item_table or {}
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self.item_table_stack = {}
|
2021-04-15 00:46:44 +00:00
|
|
|
|
self.dimen = Geom:new{ w = self.width, h = self.height or Screen:getHeight() }
|
2018-01-13 22:38:53 +00:00
|
|
|
|
if self.dimen.h > Screen:getHeight() or self.dimen.h == nil then
|
|
|
|
|
self.dimen.h = Screen:getHeight()
|
|
|
|
|
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.border_size = self.is_borderless and 0 or Size.border.window
|
|
|
|
|
self.inner_dimen = Geom:new{
|
|
|
|
|
w = self.dimen.w - 2 * self.border_size,
|
|
|
|
|
h = self.dimen.h - 2 * self.border_size,
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-25 23:48:05 +00:00
|
|
|
|
self.item_dimen = Geom:new{
|
|
|
|
|
w = self.inner_dimen.w,
|
|
|
|
|
h = Screen:scaleBySize(46),
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self.page = 1
|
|
|
|
|
|
2020-12-22 23:24:16 +00:00
|
|
|
|
self.paths = {} -- per instance table to trace navigation path
|
|
|
|
|
|
2014-03-13 13:52:43 +00:00
|
|
|
|
-----------------------------------
|
|
|
|
|
-- start to set up widget layout --
|
|
|
|
|
-----------------------------------
|
|
|
|
|
self.menu_title = TextWidget:new{
|
2016-02-14 21:47:36 +00:00
|
|
|
|
overlap_align = "center",
|
2014-03-13 13:52:43 +00:00
|
|
|
|
text = self.title,
|
2021-02-04 16:43:52 +00:00
|
|
|
|
face = Font:getFace("tfont"),
|
2014-03-13 13:52:43 +00:00
|
|
|
|
}
|
2018-08-01 15:02:34 +00:00
|
|
|
|
local menu_title_container = CenterContainer:new{
|
|
|
|
|
dimen = Geom:new{
|
[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
|
|
|
|
w = self.inner_dimen.w,
|
2018-08-01 15:02:34 +00:00
|
|
|
|
h = self.menu_title:getSize().h,
|
|
|
|
|
},
|
|
|
|
|
self.menu_title,
|
|
|
|
|
}
|
|
|
|
|
local path_text_container
|
|
|
|
|
|
|
|
|
|
if self.show_path then
|
|
|
|
|
self.path_text = TextWidget:new{
|
|
|
|
|
face = Font:getFace("xx_smallinfofont"),
|
2020-01-04 00:18:51 +00:00
|
|
|
|
text = BD.directory(self.path),
|
[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
|
|
|
|
max_width = self.inner_dimen.w - 2*Size.padding.small,
|
2019-10-21 13:20:40 +00:00
|
|
|
|
truncate_left = true,
|
2018-08-01 15:02:34 +00:00
|
|
|
|
}
|
|
|
|
|
path_text_container = CenterContainer:new{
|
|
|
|
|
dimen = Geom:new{
|
[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
|
|
|
|
w = self.inner_dimen.w,
|
2018-08-01 15:02:34 +00:00
|
|
|
|
h = self.path_text:getSize().h,
|
|
|
|
|
},
|
|
|
|
|
self.path_text,
|
|
|
|
|
}
|
|
|
|
|
self.menu_title_group = VerticalGroup:new{
|
|
|
|
|
align = "center",
|
|
|
|
|
menu_title_container,
|
|
|
|
|
path_text_container,
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
self.menu_title_group = VerticalGroup:new{
|
|
|
|
|
align = "center",
|
|
|
|
|
menu_title_container
|
|
|
|
|
}
|
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
|
-- group for title bar
|
|
|
|
|
self.title_bar = OverlapGroup:new{
|
[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
|
|
|
|
dimen = {w = self.inner_dimen.w, h = self.menu_title_group:getSize().h},
|
2018-08-01 15:02:34 +00:00
|
|
|
|
self.menu_title_group,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
}
|
|
|
|
|
-- group for items
|
|
|
|
|
self.item_group = VerticalGroup:new{}
|
|
|
|
|
-- 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,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
callback = function() self:onPrevPage() end,
|
|
|
|
|
bordersize = 0,
|
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
|
|
|
|
show_parent = self.show_parent,
|
2014-03-13 13:52:43 +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,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
callback = function() self:onNextPage() end,
|
|
|
|
|
bordersize = 0,
|
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
|
|
|
|
show_parent = self.show_parent,
|
2014-03-13 13:52:43 +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,
|
2014-07-30 07:00:02 +00:00
|
|
|
|
callback = function() self:onFirstPage() end,
|
|
|
|
|
bordersize = 0,
|
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
|
|
|
|
show_parent = self.show_parent,
|
2014-07-30 07:00:02 +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,
|
2014-07-30 07:00:02 +00:00
|
|
|
|
callback = function() self:onLastPage() end,
|
|
|
|
|
bordersize = 0,
|
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
|
|
|
|
show_parent = self.show_parent,
|
2014-08-05 15:41:36 +00:00
|
|
|
|
}
|
2014-09-05 13:07:21 +00:00
|
|
|
|
self.page_info_spacer = HorizontalSpan:new{
|
2014-11-20 22:07:39 +00:00
|
|
|
|
width = Screen:scaleBySize(32),
|
2014-07-30 07:00:02 +00:00
|
|
|
|
}
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self.page_info_left_chev:hide()
|
|
|
|
|
self.page_info_right_chev:hide()
|
2014-07-30 07:00:02 +00:00
|
|
|
|
self.page_info_first_chev:hide()
|
|
|
|
|
self.page_info_last_chev:hide()
|
|
|
|
|
|
2018-02-09 21:33:15 +00:00
|
|
|
|
local title_goto, type_goto, hint_func
|
|
|
|
|
local buttons = {
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
text = _("Cancel"),
|
|
|
|
|
callback = function()
|
|
|
|
|
self.page_info_text:closeInputDialog()
|
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text = _("Go to page"),
|
|
|
|
|
is_enter_default = true,
|
|
|
|
|
callback = function()
|
|
|
|
|
local page = tonumber(self.page_info_text.input_dialog:getInputText())
|
|
|
|
|
if page and page >= 1 and page <= self.page_num then
|
|
|
|
|
self:onGotoPage(page)
|
2021-04-10 22:08:29 +00:00
|
|
|
|
self.page_info_text:closeInputDialog()
|
2018-02-09 21:33:15 +00:00
|
|
|
|
end
|
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if self.goto_letter then
|
2019-03-01 11:59:39 +00:00
|
|
|
|
title_goto = _("Enter page number or letter")
|
2018-02-09 21:33:15 +00:00
|
|
|
|
type_goto = "string"
|
|
|
|
|
hint_func = function()
|
|
|
|
|
return string.format("(1 - %s) or (a - z)", self.page_num)
|
|
|
|
|
end
|
|
|
|
|
table.insert(buttons[1], {
|
|
|
|
|
text = _("Go to letter"),
|
|
|
|
|
is_enter_default = true,
|
|
|
|
|
callback = function()
|
|
|
|
|
for k, v in ipairs(self.item_table) do
|
2019-08-26 13:49:50 +00:00
|
|
|
|
--- @todo Support utf8 lowercase.
|
2020-09-15 18:39:32 +00:00
|
|
|
|
local filename = FFIUtil.basename(v.path):lower()
|
2018-02-09 21:33:15 +00:00
|
|
|
|
local search_string = self.page_info_text.input_dialog:getInputText():lower()
|
2021-04-10 22:08:29 +00:00
|
|
|
|
if search_string == "" then return end
|
2018-02-09 21:33:15 +00:00
|
|
|
|
local i, _ = filename:find(search_string)
|
|
|
|
|
if i == 1 and not v.is_go_up then
|
|
|
|
|
self:onGotoPage(math.ceil(k / self.perpage))
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
self.page_info_text:closeInputDialog()
|
|
|
|
|
end,
|
|
|
|
|
})
|
|
|
|
|
else
|
2019-03-01 11:59:39 +00:00
|
|
|
|
title_goto = _("Enter page number")
|
2018-02-09 21:33:15 +00:00
|
|
|
|
type_goto = "number"
|
|
|
|
|
hint_func = function()
|
|
|
|
|
return string.format("(1 - %s)", self.page_num)
|
|
|
|
|
end
|
|
|
|
|
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_text = self.page_info_text or Button:new{
|
2014-03-13 13:52:43 +00:00
|
|
|
|
text = "",
|
2015-04-13 06:45:02 +00:00
|
|
|
|
hold_input = {
|
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
|
|
|
|
title = title_goto,
|
2018-02-09 21:33:15 +00:00
|
|
|
|
type = type_goto,
|
|
|
|
|
hint_func = hint_func,
|
|
|
|
|
buttons = buttons,
|
2015-04-13 06:45:02 +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,
|
2015-04-13 06:45:02 +00:00
|
|
|
|
bordersize = 0,
|
|
|
|
|
text_font_face = "cfont",
|
|
|
|
|
text_font_size = 20,
|
|
|
|
|
text_font_bold = false,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
}
|
|
|
|
|
self.page_info = HorizontalGroup:new{
|
2014-07-30 07:00:02 +00:00
|
|
|
|
self.page_info_first_chev,
|
2014-08-05 15:41:36 +00:00
|
|
|
|
self.page_info_spacer,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
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,
|
2014-03-13 13:52:43 +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,
|
2014-07-30 07:00:02 +00:00
|
|
|
|
self.page_info_right_chev,
|
2014-08-05 15:41:36 +00:00
|
|
|
|
self.page_info_spacer,
|
2014-07-30 07:00:02 +00:00
|
|
|
|
self.page_info_last_chev,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-05 13:07:21 +00:00
|
|
|
|
-- return button
|
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{
|
2020-12-19 11:18:30 +00:00
|
|
|
|
icon = "back.top",
|
2018-11-14 19:58:56 +00:00
|
|
|
|
callback = function()
|
|
|
|
|
if self.onReturn then self:onReturn() end
|
|
|
|
|
end,
|
2014-09-05 13:07:21 +00:00
|
|
|
|
bordersize = 0,
|
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
|
|
|
|
show_parent = self.show_parent,
|
2018-09-29 21:15:57 +00:00
|
|
|
|
readonly = self.return_arrow_propagation,
|
2014-09-05 13:07:21 +00:00
|
|
|
|
}
|
|
|
|
|
self.page_return_arrow:hide()
|
|
|
|
|
self.return_button = HorizontalGroup:new{
|
|
|
|
|
HorizontalSpan:new{
|
2017-09-13 14:56:20 +00:00
|
|
|
|
width = Size.span.horizontal_small,
|
2014-09-05 13:07:21 +00:00
|
|
|
|
},
|
|
|
|
|
self.page_return_arrow,
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-04 15:37:50 +00:00
|
|
|
|
local header = VerticalGroup:new{
|
|
|
|
|
VerticalSpan:new{width = self.header_padding},
|
|
|
|
|
self.title_bar,
|
|
|
|
|
}
|
2014-03-13 13:52:43 +00:00
|
|
|
|
local body = self.item_group
|
|
|
|
|
local footer = BottomContainer:new{
|
[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
|
|
|
|
dimen = self.inner_dimen:copy(),
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self.page_info,
|
|
|
|
|
}
|
2014-09-05 13:07:21 +00:00
|
|
|
|
local page_return = BottomContainer:new{
|
[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
|
|
|
|
dimen = self.inner_dimen:copy(),
|
2014-09-05 13:07:21 +00:00
|
|
|
|
WidgetContainer:new{
|
|
|
|
|
dimen = Geom:new{
|
|
|
|
|
w = Screen:getWidth(),
|
|
|
|
|
h = self.page_return_arrow:getSize().h,
|
|
|
|
|
},
|
|
|
|
|
self.return_button,
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-13 13:52:43 +00:00
|
|
|
|
|
2018-01-13 22:38:53 +00:00
|
|
|
|
self:_recalculateDimen()
|
|
|
|
|
self.vertical_span = HorizontalGroup:new{
|
|
|
|
|
VerticalSpan:new{ width = self.span_width }
|
|
|
|
|
}
|
2014-03-13 13:52:43 +00:00
|
|
|
|
if self.no_title then
|
2018-01-13 22:38:53 +00:00
|
|
|
|
self.content_group = VerticalGroup:new{
|
|
|
|
|
align = "left",
|
|
|
|
|
self.vertical_span,
|
|
|
|
|
body,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2018-01-13 22:38:53 +00:00
|
|
|
|
self.content_group = VerticalGroup:new{
|
|
|
|
|
align = "left",
|
|
|
|
|
header,
|
|
|
|
|
self.vertical_span,
|
|
|
|
|
body,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
}
|
|
|
|
|
end
|
2018-01-13 22:38:53 +00:00
|
|
|
|
local content = OverlapGroup:new{
|
2019-12-06 21:55:39 +00:00
|
|
|
|
-- This unique allow_mirroring=false looks like it's enough
|
|
|
|
|
-- to have this complex Menu, and all widgets based on it,
|
|
|
|
|
-- be mirrored correctly with RTL languages
|
|
|
|
|
allow_mirroring = false,
|
[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
|
|
|
|
dimen = self.inner_dimen:copy(),
|
2018-01-13 22:38:53 +00:00
|
|
|
|
self.content_group,
|
|
|
|
|
page_return,
|
|
|
|
|
footer,
|
|
|
|
|
}
|
2014-03-13 13:52:43 +00:00
|
|
|
|
|
|
|
|
|
self[1] = FrameContainer:new{
|
2014-10-22 13:34:11 +00:00
|
|
|
|
background = Blitbuffer.COLOR_WHITE,
|
[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
|
|
|
|
bordersize = self.border_size,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
padding = 0,
|
|
|
|
|
margin = 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
|
|
|
|
radius = self.is_popout and math.floor(self.dimen.w / 20) or 0,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
content
|
|
|
|
|
}
|
2021-04-15 17:07:34 +00:00
|
|
|
|
|
2014-03-13 13:52:43 +00:00
|
|
|
|
------------------------------------------
|
|
|
|
|
-- start to set up input event callback --
|
|
|
|
|
------------------------------------------
|
|
|
|
|
if Device:isTouchDevice() then
|
|
|
|
|
if self.has_close_button then
|
2017-10-10 20:23:25 +00:00
|
|
|
|
table.insert(self.title_bar, MenuCloseButton:new{
|
|
|
|
|
menu = self,
|
|
|
|
|
padding_right = self.header_padding,
|
|
|
|
|
})
|
2014-03-13 13:52:43 +00:00
|
|
|
|
end
|
|
|
|
|
-- watch for outer region if it's a self contained widget
|
|
|
|
|
if self.is_popout then
|
|
|
|
|
self.ges_events.TapCloseAllMenus = {
|
|
|
|
|
GestureRange:new{
|
|
|
|
|
ges = "tap",
|
|
|
|
|
range = Geom:new{
|
|
|
|
|
x = 0, y = 0,
|
|
|
|
|
w = Screen:getWidth(),
|
|
|
|
|
h = Screen:getHeight(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
end
|
2019-08-04 17:59:20 +00:00
|
|
|
|
-- delegate swipe gesture to GestureManager in filemanager
|
|
|
|
|
if self.is_file_manager ~= true then
|
|
|
|
|
self.ges_events.Swipe = {
|
|
|
|
|
GestureRange:new{
|
|
|
|
|
ges = "swipe",
|
|
|
|
|
range = self.dimen,
|
|
|
|
|
}
|
2014-03-13 13:52:43 +00:00
|
|
|
|
}
|
2019-08-04 17:59:20 +00:00
|
|
|
|
end
|
2014-06-10 13:12:11 +00:00
|
|
|
|
self.ges_events.Close = self.on_close_ges
|
2014-03-13 13:52:43 +00:00
|
|
|
|
end
|
2014-09-03 04:09:25 +00:00
|
|
|
|
|
2014-10-30 18:42:18 +00:00
|
|
|
|
if not Device:hasKeyboard() then
|
2014-09-03 04:09:25 +00:00
|
|
|
|
-- remove menu item shortcut for K4
|
|
|
|
|
self.is_enable_shortcut = false
|
|
|
|
|
end
|
|
|
|
|
|
2014-06-10 07:57:10 +00:00
|
|
|
|
if Device:hasKeys() then
|
2014-03-13 13:52:43 +00:00
|
|
|
|
-- set up keyboard events
|
2014-06-05 06:58:53 +00:00
|
|
|
|
self.key_events.Close = { {"Back"}, doc = "close menu" }
|
2020-06-04 11:26:18 +00:00
|
|
|
|
if Device:hasFewKeys() then
|
|
|
|
|
self.key_events.Close = { {"Left"}, doc = "close menu" }
|
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self.key_events.NextPage = {
|
2014-06-05 06:58:53 +00:00
|
|
|
|
{Input.group.PgFwd}, doc = "goto next page of the menu"
|
2014-03-13 13:52:43 +00:00
|
|
|
|
}
|
|
|
|
|
self.key_events.PrevPage = {
|
2014-06-05 06:58:53 +00:00
|
|
|
|
{Input.group.PgBack}, doc = "goto previous page of the menu"
|
2014-03-13 13:52:43 +00:00
|
|
|
|
}
|
A few graphics fixes after #4541 (#4554)
* Various FocusManager related tweaks to limit its usage to devices with a DPad, and prevent initial button highlights in Dialogs on devices where it makes no sense (i.e., those without a DPad. And even on DPad devices, I'm not even sure how we'd go about making one of those pop up anyway, because no Touch ;)!).
* One mysterious fix to text-only Buttons so that the flash_ui highlight always works, and always honors `FrameContainer`'s pill shape. (Before that, an unhighlight on a text button with a callback that didn't repaint anything [say, the find first/find last buttons in the Reader's search bar when you're already on the first/last match] would do a square black highlight, and a white pill-shaped unhighlight (leaving the black corners visible)).
The workaround makes *absolutely* no sense to me (as `self[1] -> self.frame`, AFAICT), but it works, and ensures all highlights/unhighlights are pill-shaped, so at least we're not doing maths for rounded corners for nothing ;).
2019-02-07 23:56:32 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if Device:hasDPad() then
|
2014-03-13 13:52:43 +00:00
|
|
|
|
-- we won't catch presses to "Right", leave that to MenuItem.
|
|
|
|
|
self.key_events.FocusRight = nil
|
|
|
|
|
-- shortcut icon is not needed for touch device
|
|
|
|
|
if self.is_enable_shortcut then
|
|
|
|
|
self.key_events.SelectByShortCut = { {self.item_shortcuts} }
|
|
|
|
|
end
|
|
|
|
|
self.key_events.Select = {
|
2014-06-05 06:58:53 +00:00
|
|
|
|
{"Press"}, doc = "select current menu item"
|
2014-03-13 13:52:43 +00:00
|
|
|
|
}
|
2018-03-18 10:42:35 +00:00
|
|
|
|
self.key_events.Right = {
|
|
|
|
|
{"Right"}, doc = "hold menu item"
|
|
|
|
|
}
|
2014-03-13 13:52:43 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if #self.item_table > 0 then
|
|
|
|
|
-- if the table is not yet initialized, this call
|
|
|
|
|
-- must be done manually:
|
2014-04-04 15:02:29 +00:00
|
|
|
|
self.page = math.ceil((self.item_table.current or 1) / self.perpage)
|
2014-03-13 13:52:43 +00:00
|
|
|
|
end
|
2017-01-10 18:02:46 +00:00
|
|
|
|
if self.path_items then
|
|
|
|
|
self:refreshPath()
|
|
|
|
|
else
|
2017-02-01 15:34:12 +00:00
|
|
|
|
self:updateItems()
|
2017-01-10 18:02:46 +00:00
|
|
|
|
end
|
2012-04-29 15:53:48 +00:00
|
|
|
|
end
|
|
|
|
|
|
ReaderUI: Saner FM/RD lifecycle
* Ensure that going from one to the other tears down the former and
its plugins before instantiating the latter and its plugins.
UIManager: Unify Event sending & broadcasting
* Make the two behave the same way (walk the widget stack from top to
bottom), and properly handle the window stack shrinking shrinking
*and* growing.
Previously, broadcasting happened bottom-to-top and didn't really
handle the list shrinking/growing, while sending only handled the list
shrinking by a single element, and hopefully that element being the one
the event was just sent to.
These two items combined allowed us to optimize suboptimal
refresh behavior with Menu and other Menu classes when
opening/closing a document.
e.g., the "opening document" Notification is now properly regional,
and the "open last doc" option no longer flashes like a crazy person
anymore.
Plugins: Allow optimizing Menu refresh with custom menus, too.
Requires moving Menu's close_callback *after* onMenuSelect, which, eh,
probably makes sense, and is probably harmless in the grand scheme of
things.
2021-05-01 16:53:04 +00:00
|
|
|
|
function Menu:onShowingReader()
|
|
|
|
|
-- Clear the dither flag to prevent it from infecting the queue and re-inserting a full-screen refresh...
|
|
|
|
|
self.dithered = nil
|
|
|
|
|
end
|
|
|
|
|
Menu.onSetupShowReader = Menu.onShowingReader
|
|
|
|
|
|
2014-12-01 16:21:42 +00:00
|
|
|
|
function Menu:onCloseWidget()
|
2019-08-23 17:53:53 +00:00
|
|
|
|
--- @fixme
|
2014-12-04 02:09:09 +00:00
|
|
|
|
-- we cannot refresh regionally using the dimen field
|
|
|
|
|
-- because some menus without menu title use VerticalGroup to include
|
|
|
|
|
-- a text widget which is not calculated into the dimen.
|
Tame some ButtonTable users into re-using Buttontable instances if possible (#7166)
* QuickDictLookup, ImageViewer, NumberPicker: Smarter `update` that will re-use most of the widget's layout instead of re-instantiating all the things.
* SpinWidget/DoubleSpinWidget: The NumberPicker change above renders a hack to preserve alpha on these widgets almost unnecessary. Also fixed said hack to also apply to the center, value button.
* Button: Don't re-instantiate the frame in setText/setIcon when unnecessary (e.g., no change at all, or no layout change).
* Button: Add a refresh method that repaints and refreshes a *specific* Button (provided it's been painted once) all on its lonesome.
* ConfigDialog: Free everything that's going to be re-instatiated on update
* A few more post #7118 fixes:
* SkimTo: Always flag the chapter nav buttons as vsync
* Button: Fix the highlight on rounded buttons when vsync is enabled (e.g., it's now entirely visible, instead of showing a weird inverted corner glitch).
* Some more heuristic tweaks in Menu/TouchMenu/Button/IconButton
* ButtonTable: fix the annoying rounding issue I'd noticed in #7054 ;).
* Enable dithering in TextBoxWidget (e.g., in the Wikipedia full view). This involved moving the HW dithering align fixup to base, where it always ought to have been ;).
* Switch a few widgets that were using "partial" on close to "ui", or, more rarely, "flashui". The intent being to limit "partial" purely to the Reader, because it has a latency cost when mixed with other refreshes, which happens often enough in UI ;).
* Minor documentation tweaks around UIManager's `setDirty` to reflect that change.
* ReaderFooter: Force a footer repaint on resume if it is visible (otherwise, just update it).
* ReaderBookmark: In the same vein, don't repaint an invisible footer on bookmark count changes.
2021-01-28 23:20:15 +00:00
|
|
|
|
-- For example, it's a dirty hack to use two menus (one being this menu and
|
|
|
|
|
-- the other touch menu) in the filemanager in order to capture tap gesture to popup
|
2014-12-04 02:09:09 +00:00
|
|
|
|
-- the filemanager menu.
|
2018-06-02 16:10:55 +00:00
|
|
|
|
-- NOTE: For the same reason, don't make it flash,
|
|
|
|
|
-- because that'll trigger when we close the FM and open a book...
|
ReaderUI: Saner FM/RD lifecycle
* Ensure that going from one to the other tears down the former and
its plugins before instantiating the latter and its plugins.
UIManager: Unify Event sending & broadcasting
* Make the two behave the same way (walk the widget stack from top to
bottom), and properly handle the window stack shrinking shrinking
*and* growing.
Previously, broadcasting happened bottom-to-top and didn't really
handle the list shrinking/growing, while sending only handled the list
shrinking by a single element, and hopefully that element being the one
the event was just sent to.
These two items combined allowed us to optimize suboptimal
refresh behavior with Menu and other Menu classes when
opening/closing a document.
e.g., the "opening document" Notification is now properly regional,
and the "open last doc" option no longer flashes like a crazy person
anymore.
Plugins: Allow optimizing Menu refresh with custom menus, too.
Requires moving Menu's close_callback *after* onMenuSelect, which, eh,
probably makes sense, and is probably harmless in the grand scheme of
things.
2021-05-01 16:53:04 +00:00
|
|
|
|
|
|
|
|
|
-- Don't do anything if we're in the process of tearing down FM or RD, or if we don't actually have a live instance of 'em...
|
|
|
|
|
local FileManager = require("apps/filemanager/filemanager")
|
|
|
|
|
local ReaderUI = require("apps/reader/readerui")
|
|
|
|
|
local reader_ui = ReaderUI:_getRunningInstance()
|
|
|
|
|
if (FileManager.instance and not FileManager.instance.tearing_down) or (reader_ui and not reader_ui.tearing_down) then
|
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
|
end
|
2014-12-01 16:21:42 +00:00
|
|
|
|
end
|
|
|
|
|
|
2018-04-06 09:53:11 +00:00
|
|
|
|
function Menu:updatePageInfo(select_number)
|
|
|
|
|
if self.item_group[1] then
|
A few graphics fixes after #4541 (#4554)
* Various FocusManager related tweaks to limit its usage to devices with a DPad, and prevent initial button highlights in Dialogs on devices where it makes no sense (i.e., those without a DPad. And even on DPad devices, I'm not even sure how we'd go about making one of those pop up anyway, because no Touch ;)!).
* One mysterious fix to text-only Buttons so that the flash_ui highlight always works, and always honors `FrameContainer`'s pill shape. (Before that, an unhighlight on a text button with a callback that didn't repaint anything [say, the find first/find last buttons in the Reader's search bar when you're already on the first/last match] would do a square black highlight, and a white pill-shaped unhighlight (leaving the black corners visible)).
The workaround makes *absolutely* no sense to me (as `self[1] -> self.frame`, AFAICT), but it works, and ensures all highlights/unhighlights are pill-shaped, so at least we're not doing maths for rounded corners for nothing ;).
2019-02-07 23:56:32 +00:00
|
|
|
|
if Device:hasDPad() then
|
2018-04-06 09:53:11 +00:00
|
|
|
|
-- reset focus manager accordingly
|
|
|
|
|
self.selected = { x = 1, y = select_number }
|
|
|
|
|
end
|
|
|
|
|
-- update page information
|
[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:setText(FFIUtil.template(_("Page %1 of %2"), self.page, self.page_num))
|
2019-10-21 12:24:29 +00:00
|
|
|
|
if self.page_num > 1 then
|
2021-02-20 17:35:57 +00:00
|
|
|
|
self.page_info_text:enable()
|
2019-10-21 12:24:29 +00:00
|
|
|
|
else
|
[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()
|
2019-10-21 12:24:29 +00:00
|
|
|
|
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.page_info_left_chev:show()
|
|
|
|
|
self.page_info_right_chev:show()
|
|
|
|
|
self.page_info_first_chev:show()
|
|
|
|
|
self.page_info_last_chev:show()
|
2018-04-06 09:53:11 +00:00
|
|
|
|
self.page_return_arrow:showHide(self.onReturn ~= nil)
|
|
|
|
|
|
|
|
|
|
self.page_info_left_chev:enableDisable(self.page > 1)
|
|
|
|
|
self.page_info_right_chev:enableDisable(self.page < self.page_num)
|
|
|
|
|
self.page_info_first_chev:enableDisable(self.page > 1)
|
|
|
|
|
self.page_info_last_chev:enableDisable(self.page < self.page_num)
|
|
|
|
|
self.page_return_arrow:enableDisable(#self.paths > 0)
|
|
|
|
|
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()
|
|
|
|
|
self.page_return_arrow:showHide(self.onReturn ~= nil)
|
2018-04-06 09:53:11 +00:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2012-06-10 18:14:29 +00:00
|
|
|
|
function Menu:updateItems(select_number)
|
2014-11-30 12:04:33 +00:00
|
|
|
|
local old_dimen = self.dimen and self.dimen:copy()
|
2014-03-13 13:52:43 +00:00
|
|
|
|
-- self.layout must be updated for focusmanager
|
|
|
|
|
self.layout = {}
|
|
|
|
|
self.item_group:clear()
|
|
|
|
|
self.page_info:resetLayout()
|
2014-09-05 13:07:21 +00:00
|
|
|
|
self.return_button:resetLayout()
|
2018-01-13 22:38:53 +00:00
|
|
|
|
self.vertical_span:clear()
|
|
|
|
|
self.content_group:resetLayout()
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self:_recalculateDimen()
|
|
|
|
|
|
|
|
|
|
-- default to select the first item
|
|
|
|
|
if not select_number then
|
|
|
|
|
select_number = 1
|
|
|
|
|
end
|
2021-02-04 16:43:52 +00:00
|
|
|
|
|
|
|
|
|
local font_size = self.items_font_size or G_reader_settings:readSetting("items_font_size")
|
|
|
|
|
or Menu.getItemFontSize(self.perpage)
|
|
|
|
|
local infont_size = self.items_mandatory_font_size or Menu.getItemMandatoryFontSize(self.perpage)
|
|
|
|
|
local multilines_show_more_text = self.multilines_show_more_text
|
|
|
|
|
if multilines_show_more_text == nil then
|
|
|
|
|
multilines_show_more_text = G_reader_settings:isTrue("items_multilines_show_more_text")
|
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
|
|
2014-12-18 08:16:11 +00:00
|
|
|
|
for c = 1, math.min(self.perpage, #self.item_table) do
|
2014-03-13 13:52:43 +00:00
|
|
|
|
-- calculate index in item_table
|
|
|
|
|
local i = (self.page - 1) * self.perpage + c
|
|
|
|
|
if i <= #self.item_table then
|
|
|
|
|
local item_shortcut = nil
|
|
|
|
|
local shortcut_style = "square"
|
|
|
|
|
if self.is_enable_shortcut then
|
|
|
|
|
-- give different shortcut_style to keys in different
|
|
|
|
|
-- lines of keyboard
|
|
|
|
|
if c >= 11 and c <= 20 then
|
|
|
|
|
--shortcut_style = "rounded_corner"
|
|
|
|
|
shortcut_style = "grey_square"
|
|
|
|
|
end
|
|
|
|
|
item_shortcut = self.item_shortcuts[c]
|
|
|
|
|
end
|
2016-02-14 21:47:36 +00:00
|
|
|
|
local item_tmp = MenuItem:new{
|
|
|
|
|
show_parent = self.show_parent,
|
|
|
|
|
state = self.item_table[i].state,
|
|
|
|
|
state_size = self.state_size or {},
|
2019-12-06 21:55:39 +00:00
|
|
|
|
text = Menu.getMenuText(self.item_table[i]),
|
2019-12-17 12:00:37 +00:00
|
|
|
|
bidi_wrap_func = self.item_table[i].bidi_wrap_func,
|
2016-02-14 21:47:36 +00:00
|
|
|
|
mandatory = self.item_table[i].mandatory,
|
2020-08-29 16:25:36 +00:00
|
|
|
|
mandatory_func = self.item_table[i].mandatory_func,
|
2016-12-03 13:19:35 +00:00
|
|
|
|
bold = self.item_table.current == i or self.item_table[i].bold == true,
|
2017-09-22 16:24:38 +00:00
|
|
|
|
dim = self.item_table[i].dim,
|
2018-01-13 22:38:53 +00:00
|
|
|
|
font = "smallinfofont",
|
|
|
|
|
font_size = font_size,
|
|
|
|
|
infont = "infont",
|
|
|
|
|
infont_size = infont_size,
|
2016-02-14 21:47:36 +00:00
|
|
|
|
dimen = self.item_dimen:new(),
|
|
|
|
|
shortcut = item_shortcut,
|
|
|
|
|
shortcut_style = shortcut_style,
|
|
|
|
|
table = self.item_table[i],
|
|
|
|
|
menu = self,
|
2018-01-13 22:38:53 +00:00
|
|
|
|
linesize = self.linesize,
|
|
|
|
|
single_line = self.single_line,
|
2021-02-04 16:43:52 +00:00
|
|
|
|
multilines_show_more_text = multilines_show_more_text,
|
2019-07-19 19:43:05 +00:00
|
|
|
|
align_baselines = self.align_baselines,
|
2018-01-13 22:38:53 +00:00
|
|
|
|
line_color = self.line_color,
|
2021-04-15 17:07:34 +00:00
|
|
|
|
items_padding = self.items_padding,
|
2016-02-14 21:47:36 +00:00
|
|
|
|
}
|
2014-03-13 13:52:43 +00:00
|
|
|
|
table.insert(self.item_group, item_tmp)
|
|
|
|
|
-- this is for focus manager
|
|
|
|
|
table.insert(self.layout, {item_tmp})
|
|
|
|
|
end -- if i <= self.items
|
|
|
|
|
end -- for c=1, self.perpage
|
2014-07-30 07:00:02 +00:00
|
|
|
|
|
2018-04-06 09:53:11 +00:00
|
|
|
|
self:updatePageInfo(select_number)
|
2018-08-01 15:02:34 +00:00
|
|
|
|
if self.show_path then
|
2020-01-04 00:18:51 +00:00
|
|
|
|
self.path_text:setText(BD.directory(self.path))
|
2018-08-01 15:02:34 +00:00
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
|
|
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(self.show_parent, function()
|
2014-11-30 12:04:33 +00:00
|
|
|
|
local refresh_dimen =
|
|
|
|
|
old_dimen and old_dimen:combine(self.dimen)
|
|
|
|
|
or self.dimen
|
2015-04-26 18:10:18 +00:00
|
|
|
|
return "ui", refresh_dimen
|
2014-11-30 12:04:33 +00:00
|
|
|
|
end)
|
2012-04-29 15:53:48 +00:00
|
|
|
|
end
|
|
|
|
|
|
2014-09-13 06:00:57 +00:00
|
|
|
|
--[[
|
|
|
|
|
the itemnumber paramter determines menu page number after switching item table
|
|
|
|
|
1. itemnumber >= 0
|
|
|
|
|
the page number is calculated with items per page
|
|
|
|
|
2. itemnumber == nil
|
|
|
|
|
the page number is 1
|
|
|
|
|
3. itemnumber is negative number
|
|
|
|
|
the page number is not changed, used when item_table is appended with
|
|
|
|
|
new entries
|
2017-10-21 17:53:56 +00:00
|
|
|
|
|
|
|
|
|
alternatively, itemmatch may be provided as a {key = value} table,
|
|
|
|
|
and the page number will be the page containing the first item for
|
|
|
|
|
which item.key = value
|
2014-09-13 06:00:57 +00:00
|
|
|
|
--]]
|
2017-10-21 17:53:56 +00:00
|
|
|
|
function Menu:switchItemTable(new_title, new_item_table, itemnumber, itemmatch)
|
2014-09-05 13:07:21 +00:00
|
|
|
|
if self.menu_title and new_title then
|
2019-10-21 13:20:40 +00:00
|
|
|
|
self.menu_title:setText(new_title)
|
2014-03-13 13:52:43 +00:00
|
|
|
|
end
|
2014-07-30 07:00:02 +00:00
|
|
|
|
|
2014-09-13 06:00:57 +00:00
|
|
|
|
if itemnumber == nil then
|
|
|
|
|
self.page = 1
|
|
|
|
|
elseif itemnumber >= 0 then
|
2014-08-12 07:36:23 +00:00
|
|
|
|
self.page = math.ceil(itemnumber / self.perpage)
|
|
|
|
|
end
|
|
|
|
|
|
2017-10-21 17:53:56 +00:00
|
|
|
|
if type(itemmatch) == "table" then
|
|
|
|
|
local key, value = next(itemmatch)
|
|
|
|
|
for num, item in ipairs(new_item_table) do
|
|
|
|
|
if item[key] == value then
|
|
|
|
|
self.page = math.floor((num-1) / self.perpage) + 1
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2014-11-23 10:06:20 +00:00
|
|
|
|
-- make sure current page is in right page range
|
|
|
|
|
local max_pages = math.ceil(#new_item_table / self.perpage)
|
|
|
|
|
if self.page > max_pages then
|
|
|
|
|
self.page = max_pages
|
|
|
|
|
end
|
|
|
|
|
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self.item_table = new_item_table
|
2017-02-01 15:34:12 +00:00
|
|
|
|
self:updateItems()
|
2012-06-11 05:46:19 +00:00
|
|
|
|
end
|
|
|
|
|
|
2018-03-19 15:18:20 +00:00
|
|
|
|
function Menu:onScreenResize(dimen)
|
2019-08-23 17:53:53 +00:00
|
|
|
|
--- @todo Investigate: could this cause minor memory leaks?
|
2018-03-19 15:18:20 +00:00
|
|
|
|
self:init()
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
2012-04-29 15:53:48 +00:00
|
|
|
|
function Menu:onSelectByShortCut(_, keyevent)
|
2014-03-13 13:52:43 +00:00
|
|
|
|
for k,v in ipairs(self.item_shortcuts) do
|
|
|
|
|
if k > self.perpage then
|
|
|
|
|
break
|
|
|
|
|
elseif v == keyevent.key then
|
|
|
|
|
if self.item_table[(self.page-1)*self.perpage + k] then
|
|
|
|
|
self:onMenuSelect(self.item_table[(self.page-1)*self.perpage + k])
|
|
|
|
|
end
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return true
|
2012-04-29 15:53:48 +00:00
|
|
|
|
end
|
|
|
|
|
|
2019-03-01 11:59:39 +00:00
|
|
|
|
function Menu:onShowGotoDialog()
|
|
|
|
|
if self.page_info_text and self.page_info_text.hold_input then
|
|
|
|
|
self.page_info_text:onInput(self.page_info_text.hold_input)
|
|
|
|
|
end
|
2019-03-08 20:52:45 +00:00
|
|
|
|
return true
|
2019-03-01 11:59:39 +00:00
|
|
|
|
end
|
|
|
|
|
|
2012-06-10 18:14:29 +00:00
|
|
|
|
function Menu:onWrapFirst()
|
2014-03-13 13:52:43 +00:00
|
|
|
|
if self.page > 1 then
|
|
|
|
|
self.page = self.page - 1
|
|
|
|
|
local end_position = self.perpage
|
|
|
|
|
if self.page == self.page_num then
|
|
|
|
|
end_position = #self.item_table % self.perpage
|
|
|
|
|
end
|
|
|
|
|
self:updateItems(end_position)
|
|
|
|
|
end
|
|
|
|
|
return false
|
2012-06-10 18:14:29 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Menu:onWrapLast()
|
2014-03-13 13:52:43 +00:00
|
|
|
|
if self.page < self.page_num then
|
|
|
|
|
self:onNextPage()
|
|
|
|
|
end
|
|
|
|
|
return false
|
2012-06-10 18:14:29 +00:00
|
|
|
|
end
|
|
|
|
|
|
2012-06-10 15:36:19 +00:00
|
|
|
|
--[[
|
|
|
|
|
override this function to process the item selected in a different manner
|
|
|
|
|
]]--
|
|
|
|
|
function Menu:onMenuSelect(item)
|
2014-03-13 13:52:43 +00:00
|
|
|
|
if item.sub_item_table == nil then
|
2021-02-20 18:05:10 +00:00
|
|
|
|
if item.select_enabled == false then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
if item.select_enabled_func then
|
|
|
|
|
if not item.select_enabled_func() then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
ReaderUI: Saner FM/RD lifecycle
* Ensure that going from one to the other tears down the former and
its plugins before instantiating the latter and its plugins.
UIManager: Unify Event sending & broadcasting
* Make the two behave the same way (walk the widget stack from top to
bottom), and properly handle the window stack shrinking shrinking
*and* growing.
Previously, broadcasting happened bottom-to-top and didn't really
handle the list shrinking/growing, while sending only handled the list
shrinking by a single element, and hopefully that element being the one
the event was just sent to.
These two items combined allowed us to optimize suboptimal
refresh behavior with Menu and other Menu classes when
opening/closing a document.
e.g., the "opening document" Notification is now properly regional,
and the "open last doc" option no longer flashes like a crazy person
anymore.
Plugins: Allow optimizing Menu refresh with custom menus, too.
Requires moving Menu's close_callback *after* onMenuSelect, which, eh,
probably makes sense, and is probably harmless in the grand scheme of
things.
2021-05-01 16:53:04 +00:00
|
|
|
|
self:onMenuChoice(item)
|
2017-08-18 08:02:11 +00:00
|
|
|
|
if self.close_callback then
|
|
|
|
|
self.close_callback()
|
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
|
else
|
|
|
|
|
-- save menu title for later resume
|
|
|
|
|
self.item_table.title = self.title
|
|
|
|
|
table.insert(self.item_table_stack, self.item_table)
|
2017-02-01 14:24:21 +00:00
|
|
|
|
self:switchItemTable(item.text, item.sub_item_table)
|
2014-03-13 13:52:43 +00:00
|
|
|
|
end
|
|
|
|
|
return true
|
2012-06-10 15:36:19 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--[[
|
2014-03-13 13:52:43 +00:00
|
|
|
|
default to call item callback
|
|
|
|
|
override this function to handle the choice
|
2013-02-02 19:35:25 +00:00
|
|
|
|
--]]
|
2012-06-10 15:36:19 +00:00
|
|
|
|
function Menu:onMenuChoice(item)
|
2014-03-13 13:52:43 +00:00
|
|
|
|
if item.callback then
|
|
|
|
|
item.callback()
|
|
|
|
|
end
|
|
|
|
|
return true
|
2012-06-10 15:36:19 +00:00
|
|
|
|
end
|
|
|
|
|
|
2014-01-18 15:15:44 +00:00
|
|
|
|
--[[
|
|
|
|
|
override this function to process the item hold in a different manner
|
|
|
|
|
]]--
|
|
|
|
|
function Menu:onMenuHold(item)
|
2014-03-13 13:52:43 +00:00
|
|
|
|
return true
|
2014-01-18 15:15:44 +00:00
|
|
|
|
end
|
|
|
|
|
|
2012-04-29 15:53:48 +00:00
|
|
|
|
function Menu:onNextPage()
|
2014-09-05 13:07:21 +00:00
|
|
|
|
if self.onNext and self.page == self.page_num - 1 then
|
|
|
|
|
self:onNext()
|
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
|
if self.page < self.page_num then
|
|
|
|
|
self.page = self.page + 1
|
2017-02-01 15:34:12 +00:00
|
|
|
|
self:updateItems()
|
2014-03-13 13:52:43 +00:00
|
|
|
|
elseif self.page == self.page_num then
|
|
|
|
|
-- on the last page, we check if we're on the last item
|
|
|
|
|
local end_position = #self.item_table % self.perpage
|
|
|
|
|
if end_position == 0 then
|
|
|
|
|
end_position = self.perpage
|
|
|
|
|
end
|
|
|
|
|
if end_position ~= self.selected.y then
|
|
|
|
|
self:updateItems(end_position)
|
|
|
|
|
end
|
2015-08-01 09:44:40 +00:00
|
|
|
|
self.page = 1
|
2017-02-01 15:34:12 +00:00
|
|
|
|
self:updateItems()
|
2014-03-13 13:52:43 +00:00
|
|
|
|
end
|
|
|
|
|
return true
|
2012-04-29 15:53:48 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Menu:onPrevPage()
|
2014-03-13 13:52:43 +00:00
|
|
|
|
if self.page > 1 then
|
|
|
|
|
self.page = self.page - 1
|
2015-08-01 09:44:40 +00:00
|
|
|
|
elseif self.page == 1 then
|
2015-08-01 09:50:10 +00:00
|
|
|
|
self.page = self.page_num
|
2014-03-13 13:52:43 +00:00
|
|
|
|
end
|
2017-02-01 15:34:12 +00:00
|
|
|
|
self:updateItems()
|
2014-03-13 13:52:43 +00:00
|
|
|
|
return true
|
2012-04-29 15:53:48 +00:00
|
|
|
|
end
|
|
|
|
|
|
2014-07-30 07:00:02 +00:00
|
|
|
|
function Menu:onFirstPage()
|
|
|
|
|
self.page = 1
|
2017-02-01 15:34:12 +00:00
|
|
|
|
self:updateItems()
|
2014-07-30 07:00:02 +00:00
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Menu:onLastPage()
|
|
|
|
|
self.page = self.page_num
|
2017-02-01 15:34:12 +00:00
|
|
|
|
self:updateItems()
|
2014-07-30 07:00:02 +00:00
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
2015-04-13 06:45:02 +00:00
|
|
|
|
function Menu:onGotoPage(page)
|
|
|
|
|
self.page = page
|
2017-02-01 15:34:12 +00:00
|
|
|
|
self:updateItems()
|
2015-04-13 06:45:02 +00:00
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
2012-05-27 06:03:13 +00:00
|
|
|
|
function Menu:onSelect()
|
2016-06-27 16:45:01 +00:00
|
|
|
|
local item = self.item_table[(self.page-1)*self.perpage+self.selected.y]
|
|
|
|
|
if item then
|
|
|
|
|
self:onMenuSelect(item)
|
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
|
return true
|
2012-05-27 06:03:13 +00:00
|
|
|
|
end
|
|
|
|
|
|
2018-03-18 10:42:35 +00:00
|
|
|
|
function Menu:onRight()
|
|
|
|
|
local item = self.item_table[(self.page-1)*self.perpage+self.selected.y]
|
|
|
|
|
if item then
|
|
|
|
|
self:onMenuHold(item)
|
|
|
|
|
end
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
2012-04-29 15:53:48 +00:00
|
|
|
|
function Menu:onClose()
|
2014-03-13 13:52:43 +00:00
|
|
|
|
local table_length = #self.item_table_stack
|
|
|
|
|
if table_length == 0 then
|
|
|
|
|
self:onCloseAllMenus()
|
|
|
|
|
else
|
|
|
|
|
-- back to parent menu
|
2016-01-03 07:44:23 +00:00
|
|
|
|
local parent_item_table = table.remove(self.item_table_stack, table_length)
|
2017-02-01 14:24:21 +00:00
|
|
|
|
self:switchItemTable(parent_item_table.title, parent_item_table)
|
2014-03-13 13:52:43 +00:00
|
|
|
|
end
|
|
|
|
|
return true
|
2012-04-29 15:53:48 +00:00
|
|
|
|
end
|
2012-06-10 15:36:19 +00:00
|
|
|
|
|
2012-12-08 17:18:40 +00:00
|
|
|
|
function Menu:onCloseAllMenus()
|
2014-03-13 13:52:43 +00:00
|
|
|
|
UIManager:close(self)
|
|
|
|
|
if self.close_callback then
|
|
|
|
|
self.close_callback()
|
|
|
|
|
end
|
|
|
|
|
return true
|
2012-12-08 17:18:40 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Menu:onTapCloseAllMenus(arg, ges_ev)
|
2014-03-13 13:52:43 +00:00
|
|
|
|
if ges_ev.pos:notIntersectWith(self.dimen) then
|
|
|
|
|
self:onCloseAllMenus()
|
|
|
|
|
return true
|
|
|
|
|
end
|
2012-12-08 17:18:40 +00:00
|
|
|
|
end
|
|
|
|
|
|
2012-12-30 05:56:21 +00:00
|
|
|
|
function Menu: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:onNextPage()
|
2019-12-06 21:55:39 +00:00
|
|
|
|
elseif direction == "east" then
|
2016-02-14 21:47:36 +00:00
|
|
|
|
self:onPrevPage()
|
2019-12-06 21:55:39 +00:00
|
|
|
|
elseif direction == "south" then
|
2018-09-21 13:48:40 +00:00
|
|
|
|
if self.has_close_button and not self.no_title then
|
|
|
|
|
-- If there is a close button displayed (so, this Menu can be
|
|
|
|
|
-- closed), allow easier closing with swipe up/down
|
|
|
|
|
self:onClose()
|
|
|
|
|
end
|
|
|
|
|
-- If there is no close button, it's a top level Menu and swipe
|
|
|
|
|
-- up/down may hide/show top menu
|
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
|
2019-08-04 17:59:20 +00:00
|
|
|
|
-- trigger full refresh
|
|
|
|
|
UIManager:setDirty(nil, "full")
|
2014-03-13 13:52:43 +00:00
|
|
|
|
end
|
2012-12-30 05:56:21 +00:00
|
|
|
|
end
|
2013-10-18 20:38:07 +00:00
|
|
|
|
|
2019-12-06 21:55:39 +00:00
|
|
|
|
--- Adds > to touch menu items with a submenu
|
|
|
|
|
local arrow_left = "◂" -- U+25C2 BLACK LEFT-POINTING SMALL TRIANGLE
|
|
|
|
|
local arrow_right = "▸" -- U+25B8 BLACK RIGHT-POINTING SMALL TRIANGLE
|
|
|
|
|
local sub_item_format
|
|
|
|
|
-- Adjust arrow direction and position for menu with sub items
|
|
|
|
|
-- according to possible user choices
|
|
|
|
|
if BD.mirroredUILayout() then
|
|
|
|
|
if BD.rtlUIText() then -- normal case with RTL language
|
|
|
|
|
sub_item_format = "%s " .. BD.rtl(arrow_left)
|
|
|
|
|
else -- user reverted text direction, so LTR
|
|
|
|
|
sub_item_format = BD.ltr(arrow_left) .. " %s"
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if BD.rtlUIText() then -- user reverted text direction, so RTL
|
|
|
|
|
sub_item_format = BD.rtl(arrow_right) .. " %s"
|
|
|
|
|
else -- normal case with LTR language
|
|
|
|
|
sub_item_format = "%s " .. BD.ltr(arrow_right)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-02-04 16:43:52 +00:00
|
|
|
|
function Menu.getItemFontSize(perpage)
|
|
|
|
|
-- Get adjusted font size for the given nb of items per page:
|
|
|
|
|
-- item font size between 14 and 24 for better matching
|
[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
|
|
|
|
return math.floor(24 - ((perpage - 6) / 18) * 10)
|
2021-02-04 16:43:52 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Menu.getItemMandatoryFontSize(perpage)
|
|
|
|
|
-- Get adjusted font size for the given nb of items per page:
|
|
|
|
|
-- "mandatory" font size between 12 and 18 for better matching
|
|
|
|
|
return math.floor(18 - (perpage - 6) / 3)
|
|
|
|
|
end
|
|
|
|
|
|
2019-12-06 21:55:39 +00:00
|
|
|
|
function Menu.getMenuText(item)
|
|
|
|
|
local text
|
|
|
|
|
if item.text_func then
|
|
|
|
|
text = item.text_func()
|
|
|
|
|
else
|
|
|
|
|
text = item.text
|
|
|
|
|
end
|
|
|
|
|
if item.sub_item_table ~= nil or item.sub_item_table_func then
|
|
|
|
|
text = string.format(sub_item_format, text)
|
|
|
|
|
end
|
|
|
|
|
return text
|
|
|
|
|
end
|
|
|
|
|
|
2014-10-25 08:02:42 +00:00
|
|
|
|
function Menu.itemTableFromTouchMenu(t)
|
|
|
|
|
local item_t = {}
|
2020-07-20 18:58:39 +00:00
|
|
|
|
for k, v in FFIUtil.orderedPairs(t) do
|
2014-10-25 08:02:42 +00:00
|
|
|
|
local item = { text = k }
|
|
|
|
|
if v.callback then
|
|
|
|
|
item.callback = v.callback
|
|
|
|
|
else
|
|
|
|
|
item.sub_item_table = v
|
|
|
|
|
end
|
|
|
|
|
table.insert(item_t, item)
|
|
|
|
|
end
|
|
|
|
|
return item_t
|
|
|
|
|
end
|
|
|
|
|
|
2013-10-18 20:38:07 +00:00
|
|
|
|
return Menu
|