CRE: fix to Top/Bottom margins fine tuning

Rework eb66856d so that "Sync T/B Margins" is disabled
when set Top and Bottom margins differ (previously,
the bottom one was taking over the top one when
it was enabled).
reviewable/pr7137/r1
poire-z 3 years ago
parent 8f79c662cf
commit 4043ba27b0

@ -455,6 +455,17 @@ function ReaderTypeset:onSetPageBottomMargin(b_margin, refresh_callback)
self.ui:handleEvent(Event:new("SetPageMargins", self.unscaled_margins, refresh_callback))
end
function ReaderTypeset:onSetPageTopAndBottomMargin(t_b_margins, refresh_callback)
local t_margin, b_margin = t_b_margins[1], t_b_margins[2]
self.unscaled_margins = { self.unscaled_margins[1], t_margin, self.unscaled_margins[3], b_margin }
if t_margin ~= b_margin then
-- Set Sync T/B Margins toggle to off, as user explicitly made them differ
self.sync_t_b_page_margins = false
self.ui.document.configurable.sync_t_b_page_margins = 0
end
self.ui:handleEvent(Event:new("SetPageMargins", self.unscaled_margins, refresh_callback))
end
function ReaderTypeset:onSyncPageTopBottomMargins(toggle, refresh_callback)
self.sync_t_b_page_margins = not self.sync_t_b_page_margins
if self.sync_t_b_page_margins then

@ -155,13 +155,12 @@ In the top menu → Settings → Status bar, you can choose whether the bottom m
name_text_hold_callback = optionsutil.showValues,
more_options = true,
more_options_param = {
-- Allow this to tune both top and bottom margins,
-- handling 2 setting names and sending 2 events
-- (we'll get the exact same DoubleSpinWidget in
-- the b_page_margin setting just below)
-- Allow this to tune both top and bottom margins, handling
-- 2 setting names (we'll get the exact same DoubleSpinWidget
-- in the b_page_margin setting just below)
name_text = _("Top/Bottom Margins"),
names = { "t_page_margin", "b_page_margin" },
events = { "SetPageTopMargin", "SetPageBottomMargin" },
event = "SetPageTopAndBottomMargin",
left_text = _("Top"),
left_min = 0,
left_max = 140,
@ -211,7 +210,7 @@ In the top menu → Settings → Status bar, you can choose whether the bottom m
-- Similar as for t_page_margin above
name_text = _("Top/Bottom Margins"),
names = { "t_page_margin", "b_page_margin" },
events = { "SetPageTopMargin", "SetPageBottomMargin" },
event = "SetPageTopAndBottomMargin",
left_text = _("Top"),
left_min = 0,
left_max = 140,

@ -1172,11 +1172,7 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, d
else
self:onConfigChoice(name, value_tables)
end
if more_options_param.events then
self:onConfigEvent(more_options_param.events[1], left_value, nil)
self:onConfigEvent(more_options_param.events[2], right_value, refresh_callback)
self:update()
elseif event then
if event then
args = args or {}
self:onConfigEvent(event, value_tables, refresh_callback)
self:update()

Loading…
Cancel
Save