From 210293b561737242b71a7bd178d86240f8b6738c Mon Sep 17 00:00:00 2001 From: chrox Date: Fri, 3 Jan 2014 01:59:40 +0800 Subject: [PATCH] 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. --- defaults.lua | 6 +++--- frontend/document/credocument.lua | 4 ++++ frontend/ui/reader/readertypeset.lua | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/defaults.lua b/defaults.lua index 35b798f8f..ee28b2422 100644 --- a/defaults.lua +++ b/defaults.lua @@ -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 diff --git a/frontend/document/credocument.lua b/frontend/document/credocument.lua index 536732464..958058ddb 100644 --- a/frontend/document/credocument.lua +++ b/frontend/document/credocument.lua @@ -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 diff --git a/frontend/ui/reader/readertypeset.lua b/frontend/ui/reader/readertypeset.lua index 91a2688f5..e79cb3cfa 100644 --- a/frontend/ui/reader/readertypeset.lua +++ b/frontend/ui/reader/readertypeset.lua @@ -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