mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Give more control over CRe margins (#4945)
Without having to resort to weird custom defaults. * Split the current margins setting in three: * Horizontal margins (because you generally want those two to be balanced). * Top margin & Bottom margin (because you may want to tweak those separately to deal with quirky status bar/final line shenanigans). * Also, add a "Reclaim bar height from bottom margin" toggle to the status bar menu, to optionally make sure the status bar won't eat into the bottom margin. * Includes a free fix to diacritics popup refresh handling in the keyboard ;).
This commit is contained in:
@@ -21,6 +21,7 @@ local ButtonProgressWidget = InputContainer:new{
|
||||
position = 1,
|
||||
default_position = nil,
|
||||
thin_grey_style = false, -- default to black
|
||||
fine_tune = false, -- no -/+ buttons on the extremities by default
|
||||
}
|
||||
|
||||
function ButtonProgressWidget:init()
|
||||
@@ -45,7 +46,43 @@ function ButtonProgressWidget:update()
|
||||
local button_margin = Size.margin.tiny
|
||||
local button_padding = Size.padding.button
|
||||
local button_bordersize = self.thin_grey_style and Size.border.thin or Size.border.button
|
||||
local button_width = math.floor(self.width / self.num_buttons) - 2*button_padding - 2*button_margin - 2*button_bordersize
|
||||
local buttons_count = self.num_buttons
|
||||
if self.fine_tune then
|
||||
buttons_count = buttons_count + 2
|
||||
end
|
||||
local button_width = math.floor(self.width / buttons_count) - 2*button_padding - 2*button_margin - 2*button_bordersize
|
||||
|
||||
-- Minus button on the left
|
||||
if self.fine_tune then
|
||||
local margin = button_margin * 2
|
||||
local extra_border_size = 0
|
||||
local button = Button:new{
|
||||
text = "-",
|
||||
radius = 0,
|
||||
margin = margin,
|
||||
padding = button_padding,
|
||||
bordersize = button_bordersize + extra_border_size,
|
||||
enabled = true,
|
||||
width = button_width - 2*extra_border_size,
|
||||
preselect = false,
|
||||
text_font_face = self.font_face,
|
||||
text_font_size = self.font_size,
|
||||
callback = function()
|
||||
self.callback("-")
|
||||
self:update()
|
||||
end,
|
||||
no_focus = true,
|
||||
hold_callback = function()
|
||||
self.hold_callback("-")
|
||||
end,
|
||||
}
|
||||
if self.thin_grey_style then
|
||||
button.frame.color = Blitbuffer.COLOR_DARK_GRAY
|
||||
end
|
||||
table.insert(self.buttonprogress_content, button)
|
||||
end
|
||||
|
||||
-- Actual progress bar
|
||||
for i = 1, self.num_buttons do
|
||||
local highlighted = i <= self.position
|
||||
local is_default = i == self.default_position
|
||||
@@ -103,6 +140,36 @@ function ButtonProgressWidget:update()
|
||||
table.insert(self.buttonprogress_content, button)
|
||||
end
|
||||
|
||||
-- Plus button on the right
|
||||
if self.fine_tune then
|
||||
local margin = button_margin * 2
|
||||
local extra_border_size = 0
|
||||
local button = Button:new{
|
||||
text = "+",
|
||||
radius = 0,
|
||||
margin = margin,
|
||||
padding = button_padding,
|
||||
bordersize = button_bordersize + extra_border_size,
|
||||
enabled = true,
|
||||
width = button_width - 2*extra_border_size,
|
||||
preselect = false,
|
||||
text_font_face = self.font_face,
|
||||
text_font_size = self.font_size,
|
||||
callback = function()
|
||||
self.callback("+")
|
||||
self:update()
|
||||
end,
|
||||
no_focus = true,
|
||||
hold_callback = function()
|
||||
self.hold_callback("+")
|
||||
end,
|
||||
}
|
||||
if self.thin_grey_style then
|
||||
button.frame.color = Blitbuffer.COLOR_DARK_GRAY
|
||||
end
|
||||
table.insert(self.buttonprogress_content, button)
|
||||
end
|
||||
|
||||
UIManager:setDirty(self.show_parrent, function()
|
||||
return "ui", self.dimen
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user