add floating punctuation option for crereader

Luckily after disabling floating punctuation left/right margin
are able to be same now (with large enough margins, should be
more than 1em). So I also changed the default page margins for
crereader and removed the dirty hack.
pull/429/head
chrox 11 years ago
parent f1b5c439dd
commit 210293b561

@ -82,9 +82,9 @@ DCREREADER_CONFIG_FONT_SIZES = {16, 20, 22, 24, 28, 32, 38, 44} -- range from 1
-- crereader margin sizes
-- margin {left, top, right, bottom} in pixels
DCREREADER_CONFIG_MARGIN_SIZES_SMALL = {6, 5, 2, 5}
DCREREADER_CONFIG_MARGIN_SIZES_MEDIUM = {15, 10, 10, 10}
DCREREADER_CONFIG_MARGIN_SIZES_LARGE = {25, 10, 20, 10}
DCREREADER_CONFIG_MARGIN_SIZES_SMALL = {5, 5, 5, 5}
DCREREADER_CONFIG_MARGIN_SIZES_MEDIUM = {15, 10, 15, 10}
DCREREADER_CONFIG_MARGIN_SIZES_LARGE = {25, 10, 25, 10}
-- gesture detector defaults
DGESDETECT_DISABLE_DOUBLE_TAP = true

@ -273,6 +273,10 @@ function CreDocument:setPageMargins(left, top, right, bottom)
self._document:setIntProperty("crengine.page.margin.bottom", bottom)
end
function CreDocument:setFloatingPunctuation(enabled)
self._document:setIntProperty("crengine.style.floating.punctuation.enabled", enabled)
end
function CreDocument:setVisiblePageCount(new_count)
self._document:setVisiblePageCount(new_count)
end

@ -32,11 +32,19 @@ function ReaderTypeset:onReadSettings(config)
if not self.embedded_css then
self.ui.document:setEmbeddedStyleSheet(0)
end
self.floating_punctuation = config:readSetting("floating_punctuation")
-- default to no floating punctuation
if self.floating_punctuation == nil then
self.floating_punctuation = 0
end
self.ui.document:setFloatingPunctuation(self.floating_punctuation)
end
function ReaderTypeset:onSaveSettings()
self.ui.doc_settings:saveSetting("css", self.css)
self.ui.doc_settings:saveSetting("embedded_css", self.embedded_css)
self.ui.doc_settings:saveSetting("floating_punctuation", self.floating_punctuation)
end
function ReaderTypeset:onToggleEmbeddedStyleSheet(toggle)
@ -107,12 +115,22 @@ function ReaderTypeset:toggleEmbeddedStyleSheet(toggle)
self.ui:handleEvent(Event:new("UpdatePos"))
end
function ReaderTypeset:toggleFloatingPunctuation()
self.floating_punctuation = self.floating_punctuation == 0 and 1 or 0
self.ui.document:setFloatingPunctuation(self.floating_punctuation)
self.ui:handleEvent(Event:new("UpdatePos"))
end
function ReaderTypeset:addToMainMenu(tab_item_table)
-- insert table to main reader menu
table.insert(tab_item_table.typeset, {
text = self.css_menu_title,
sub_item_table = self:genStyleSheetMenu(),
})
table.insert(tab_item_table.typeset, {
text = _("Toggle floating punctuation"),
callback = function () self:toggleFloatingPunctuation() end,
})
end
return ReaderTypeset

Loading…
Cancel
Save