From 1f994f8ede420de9140e8a64fc4de7443b8b15a2 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sat, 13 Jun 2020 01:56:36 +0200 Subject: [PATCH] Floor dimension computations (mul/div). (#6264) * floor most every dimension computations involving MUL or DIV Should avoid passing nonsensical floating point coordinates/dimensions to the UI code. * Update base * https://github.com/koreader/koreader-base/pull/1113 * https://github.com/koreader/koreader-base/pull/1114 * https://github.com/koreader/koreader-base/pull/1115 * Bump android-luajit-launcher https://github.com/koreader/android-luajit-launcher/pull/230 https://github.com/koreader/android-luajit-launcher/pull/231 --- base | 2 +- frontend/apps/cloudstorage/dropbox.lua | 4 +- frontend/apps/cloudstorage/ftp.lua | 4 +- frontend/apps/cloudstorage/webdav.lua | 4 +- .../filemanager/filemanagerfilesearcher.lua | 2 +- frontend/apps/filemanager/filemanagermenu.lua | 4 +- .../apps/filemanager/filemanagersearch.lua | 4 +- .../filemanager/filemanagersetdefaults.lua | 8 ++-- .../apps/reader/modules/readercropping.lua | 6 +-- .../reader/modules/readerdevicestatus.lua | 2 +- .../apps/reader/modules/readerdictionary.lua | 2 +- frontend/apps/reader/modules/readerfooter.lua | 14 +++--- .../apps/reader/modules/readergesture.lua | 10 ++-- frontend/apps/reader/modules/readerlink.lua | 2 +- .../apps/reader/modules/readerpagemap.lua | 2 +- .../apps/reader/modules/readerrolling.lua | 2 +- .../apps/reader/modules/readertypography.lua | 2 +- frontend/apps/reader/skimtowidget.lua | 12 ++--- frontend/ui/elements/refresh_menu_table.lua | 2 +- .../ui/elements/screen_dpi_menu_table.lua | 2 +- frontend/ui/widget/bookstatuswidget.lua | 8 ++-- frontend/ui/widget/buttondialog.lua | 2 +- frontend/ui/widget/buttondialogtitle.lua | 4 +- frontend/ui/widget/configdialog.lua | 4 +- frontend/ui/widget/datewidget.lua | 16 +++---- frontend/ui/widget/dictquicklookup.lua | 6 +-- frontend/ui/widget/doublespinwidget.lua | 6 +-- frontend/ui/widget/footnotewidget.lua | 2 +- frontend/ui/widget/frontlightwidget.lua | 48 +++++++++---------- frontend/ui/widget/inputdialog.lua | 4 +- frontend/ui/widget/keyboardlayoutdialog.lua | 4 +- frontend/ui/widget/logindialog.lua | 4 +- frontend/ui/widget/multiinputdialog.lua | 4 +- frontend/ui/widget/naturallightwidget.lua | 14 +++--- frontend/ui/widget/numberpickerwidget.lua | 4 +- frontend/ui/widget/opdsbrowser.lua | 12 ++--- frontend/ui/widget/openwithdialog.lua | 16 +++---- frontend/ui/widget/sortwidget.lua | 2 +- frontend/ui/widget/spinwidget.lua | 8 ++-- frontend/ui/widget/timewidget.lua | 14 +++--- frontend/ui/widget/touchmenu.lua | 10 ++-- frontend/ui/wikipedia.lua | 4 +- platform/android/luajit-launcher | 2 +- plugins/autosuspend.koplugin/main.lua | 4 +- plugins/autoturn.koplugin/main.lua | 4 +- plugins/coverbrowser.koplugin/main.lua | 2 +- plugins/evernote.koplugin/main.lua | 4 +- plugins/goodreads.koplugin/goodreadsbook.lua | 12 ++--- plugins/goodreads.koplugin/main.lua | 4 +- plugins/kosync.koplugin/main.lua | 4 +- plugins/perceptionexpander.koplugin/main.lua | 8 ++-- plugins/statistics.koplugin/main.lua | 2 +- .../statistics.koplugin/readerprogress.lua | 10 ++-- plugins/terminal.koplugin/main.lua | 2 +- plugins/texteditor.koplugin/main.lua | 2 +- plugins/wallabag.koplugin/main.lua | 8 ++-- spec/unit/widget_inputcontainer_spec.lua | 2 +- 57 files changed, 178 insertions(+), 178 deletions(-) mode change 100755 => 100644 plugins/perceptionexpander.koplugin/main.lua diff --git a/base b/base index 7b5568a3c..3c3b7ca24 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 7b5568a3c44179fbcedafa22ee03701171539727 +Subproject commit 3c3b7ca24bb7ac56a0b03d61a1e791edd377b088 diff --git a/frontend/apps/cloudstorage/dropbox.lua b/frontend/apps/cloudstorage/dropbox.lua index 013b84b25..40b3ffbe0 100644 --- a/frontend/apps/cloudstorage/dropbox.lua +++ b/frontend/apps/cloudstorage/dropbox.lua @@ -130,8 +130,8 @@ function DropBox:config(item, callback) }, }, }, - width = Screen:getWidth() * 0.95, - height = Screen:getHeight() * 0.2, + width = math.floor(Screen:getWidth() * 0.95), + height = math.floor(Screen:getHeight() * 0.2), input_type = "text", } UIManager:show(self.settings_dialog) diff --git a/frontend/apps/cloudstorage/ftp.lua b/frontend/apps/cloudstorage/ftp.lua index ca025c81a..2167c971f 100644 --- a/frontend/apps/cloudstorage/ftp.lua +++ b/frontend/apps/cloudstorage/ftp.lua @@ -146,8 +146,8 @@ function Ftp:config(item, callback) }, }, }, - width = Screen:getWidth() * 0.95, - height = Screen:getHeight() * 0.2, + width = math.floor(Screen:getWidth() * 0.95), + height = math.floor(Screen:getHeight() * 0.2), input_type = "text", } UIManager:show(self.settings_dialog) diff --git a/frontend/apps/cloudstorage/webdav.lua b/frontend/apps/cloudstorage/webdav.lua index 1a8cec8a4..61102406f 100644 --- a/frontend/apps/cloudstorage/webdav.lua +++ b/frontend/apps/cloudstorage/webdav.lua @@ -139,8 +139,8 @@ The start folder is appended to the server path.]]) }, }, }, - width = Screen:getWidth() * 0.95, - height = Screen:getHeight() * 0.2, + width = math.floor(Screen:getWidth() * 0.95), + height = math.floor(Screen:getHeight() * 0.2), input_type = "text", } UIManager:show(self.settings_dialog) diff --git a/frontend/apps/filemanager/filemanagerfilesearcher.lua b/frontend/apps/filemanager/filemanagerfilesearcher.lua index c143c424a..0ba21859c 100644 --- a/frontend/apps/filemanager/filemanagerfilesearcher.lua +++ b/frontend/apps/filemanager/filemanagerfilesearcher.lua @@ -114,7 +114,7 @@ function FileSearcher:onShowFileSearch(search_path) self.search_dialog = InputDialog:new{ title = _("Search for books by filename"), input = self.search_value, - width = Screen:getWidth() * 0.9, + width = math.floor(Screen:getWidth() * 0.9), buttons = { { { diff --git a/frontend/apps/filemanager/filemanagermenu.lua b/frontend/apps/filemanager/filemanagermenu.lua index 527844116..b4a4b22c2 100644 --- a/frontend/apps/filemanager/filemanagermenu.lua +++ b/frontend/apps/filemanager/filemanagermenu.lua @@ -143,7 +143,7 @@ function FileManagerMenu:setUpdateItemTable() local SpinWidget = require("ui/widget/spinwidget") local curr_items = G_reader_settings:readSetting("items_per_page") or 14 local items = SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = curr_items, value_min = 6, value_max = 24, @@ -166,7 +166,7 @@ function FileManagerMenu:setUpdateItemTable() local default_font_size = math.floor(24 - ((curr_items - 6)/ 18) * 10 ) local curr_font_size = G_reader_settings:readSetting("items_font_size") or default_font_size local items_font = SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = curr_font_size, value_min = 10, value_max = 72, diff --git a/frontend/apps/filemanager/filemanagersearch.lua b/frontend/apps/filemanager/filemanagersearch.lua index 853ccbed6..de420722c 100644 --- a/frontend/apps/filemanager/filemanagersearch.lua +++ b/frontend/apps/filemanager/filemanagersearch.lua @@ -206,8 +206,8 @@ function Search:ShowSearch() }, }, }, - width = Screen:getWidth() * 0.8, - height = Screen:getHeight() * 0.2, + width = math.floor(Screen:getWidth() * 0.8), + height = math.floor(Screen:getHeight() * 0.2), } UIManager:show(self.search_dialog) self.search_dialog:onShowKeyboard() diff --git a/frontend/apps/filemanager/filemanagersetdefaults.lua b/frontend/apps/filemanager/filemanagersetdefaults.lua index 83362aa3e..c2693c657 100644 --- a/frontend/apps/filemanager/filemanagersetdefaults.lua +++ b/frontend/apps/filemanager/filemanagersetdefaults.lua @@ -157,7 +157,7 @@ function SetDefaults:init() }, }, input_type = setting_type, - width = Screen:getWidth() * 0.95, + width = math.floor(Screen:getWidth() * 0.95), } UIManager:show(self.set_dialog) self.set_dialog:onShowKeyboard() @@ -208,8 +208,8 @@ function SetDefaults:init() }, }, }, - width = Screen:getWidth() * 0.95, - height = Screen:getHeight() * 0.2, + width = math.floor(Screen:getWidth() * 0.95), + height = math.floor(Screen:getHeight() * 0.2), } UIManager:show(self.set_dialog) self.set_dialog:onShowKeyboard() @@ -247,7 +247,7 @@ function SetDefaults:init() }, }, input_type = setting_type, - width = Screen:getWidth() * 0.95, + width = math.floor(Screen:getWidth() * 0.95), } UIManager:show(self.set_dialog) self.set_dialog:onShowKeyboard() diff --git a/frontend/apps/reader/modules/readercropping.lua b/frontend/apps/reader/modules/readercropping.lua index fb2de6c97..c29636ecd 100644 --- a/frontend/apps/reader/modules/readercropping.lua +++ b/frontend/apps/reader/modules/readercropping.lua @@ -42,15 +42,15 @@ function PageCropDialog:init() show_parent = self, } local ok_container = RightContainer:new{ - dimen = Geom:new{ w = Screen:getWidth()*0.33, h = Screen:getHeight()/12}, + dimen = Geom:new{ w = math.floor(Screen:getWidth()*0.33), h = math.floor(Screen:getHeight()/12)}, ok_button, } local cancel_container = LeftContainer:new{ - dimen = Geom:new{ w = Screen:getWidth()*0.33, h = Screen:getHeight()/12}, + dimen = Geom:new{ w = math.floor(Screen:getWidth()*0.33), h = math.floor(Screen:getHeight()/12)}, cancel_button, } table.insert(horizontal_group, ok_container) - table.insert(horizontal_group, HorizontalSpan:new{ width = Screen:getWidth()*0.34}) + table.insert(horizontal_group, HorizontalSpan:new{ width = math.floor(Screen:getWidth()*0.34)}) table.insert(horizontal_group, cancel_container) self[2] = FrameContainer:new{ horizontal_group, diff --git a/frontend/apps/reader/modules/readerdevicestatus.lua b/frontend/apps/reader/modules/readerdevicestatus.lua index 4e5801f1b..f07c1d0a9 100644 --- a/frontend/apps/reader/modules/readerdevicestatus.lua +++ b/frontend/apps/reader/modules/readerdevicestatus.lua @@ -79,7 +79,7 @@ function ReaderDeviceStatus:addToMainMenu(menu_items) local SpinWidget = require("ui/widget/spinwidget") local curr_items = G_reader_settings:readSetting("low_battery_threshold") or 20 local battery_spin = SpinWidget:new { - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = curr_items, value_min = 5, value_max = 90, diff --git a/frontend/apps/reader/modules/readerdictionary.lua b/frontend/apps/reader/modules/readerdictionary.lua index ccddeb73c..0c56dcb1c 100644 --- a/frontend/apps/reader/modules/readerdictionary.lua +++ b/frontend/apps/reader/modules/readerdictionary.lua @@ -308,7 +308,7 @@ If you'd like to change the order in which dictionaries are queried (and their r local SpinWidget = require("ui/widget/spinwidget") local font_size = G_reader_settings:readSetting("dict_font_size") or 20 local items_font = SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = font_size, value_min = 8, value_max = 32, diff --git a/frontend/apps/reader/modules/readerfooter.lua b/frontend/apps/reader/modules/readerfooter.lua index 76421cee5..7c08bb324 100644 --- a/frontend/apps/reader/modules/readerfooter.lua +++ b/frontend/apps/reader/modules/readerfooter.lua @@ -897,7 +897,7 @@ function ReaderFooter:addToMainMenu(menu_items) local SpinWidget = require("ui/widget/spinwidget") local font_size = self.settings.text_font_size local items_font = SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = font_size, value_min = 8, value_max = 36, @@ -951,7 +951,7 @@ function ReaderFooter:addToMainMenu(menu_items) local SpinWidget = require("ui/widget/spinwidget") local container_height = self.settings.container_height local items_font = SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = container_height, value_min = 7, value_max = 98, @@ -978,7 +978,7 @@ function ReaderFooter:addToMainMenu(menu_items) local SpinWidget = require("ui/widget/spinwidget") local container_bottom_padding = self.settings.container_bottom_padding local items_font = SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = container_bottom_padding, value_min = 0, value_max = 49, @@ -1007,7 +1007,7 @@ function ReaderFooter:addToMainMenu(menu_items) callback = function(touchmenu_instance) local SpinWidget = require("ui/widget/spinwidget") local items = SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = self.settings.book_title_max_width_pct, value_min = 10, value_step = 5, @@ -1033,7 +1033,7 @@ function ReaderFooter:addToMainMenu(menu_items) callback = function(touchmenu_instance) local SpinWidget = require("ui/widget/spinwidget") local items = SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = self.settings.book_chapter_max_width_pct, value_min = 10, value_step = 5, @@ -1409,7 +1409,7 @@ function ReaderFooter:addToMainMenu(menu_items) end local SpinWidget = require("ui/widget/spinwidget") local items = SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = value, value_min = value_min, value_step = 1, @@ -1585,7 +1585,7 @@ function ReaderFooter:addToMainMenu(menu_items) callback = function(touchmenu_instance) local SpinWidget = require("ui/widget/spinwidget") local items = SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = self.settings.progress_bar_min_width_pct, value_min = 5, value_step = 5, diff --git a/frontend/apps/reader/modules/readergesture.lua b/frontend/apps/reader/modules/readergesture.lua index 5a533db83..a691b760e 100644 --- a/frontend/apps/reader/modules/readergesture.lua +++ b/frontend/apps/reader/modules/readergesture.lua @@ -489,7 +489,7 @@ function ReaderGesture:addToMainMenu(menu_items) Set double tap interval in milliseconds. The interval value can range from 100 (0.1 seconds) to 2000 (2 seconds). Default value: %1]]), GestureDetector.DOUBLE_TAP_INTERVAL/1000), - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = GestureDetector:getInterval("ges_double_tap_interval")/1000, value_min = 100, value_max = 2000, @@ -516,7 +516,7 @@ Default value: %1]]), GestureDetector.DOUBLE_TAP_INTERVAL/1000), Set two finger tap duration in milliseconds. The duration value can range from 100 (0.1 seconds) to 2000 (2 seconds). Default value: %1]]), GestureDetector.TWO_FINGER_TAP_DURATION/1000), - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = GestureDetector:getInterval("ges_two_finger_tap_duration")/1000, value_min = 100, value_max = 2000, @@ -543,7 +543,7 @@ Default value: %1]]), GestureDetector.TWO_FINGER_TAP_DURATION/1000), Set hold interval in milliseconds. The interval value can range from 100 (0.1 seconds) to 2000 (2 seconds). Default value: %1]]), GestureDetector.HOLD_INTERVAL/1000), - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = GestureDetector:getInterval("ges_hold_interval")/1000, value_min = 100, value_max = 2000, @@ -570,7 +570,7 @@ Default value: %1]]), GestureDetector.HOLD_INTERVAL/1000), Set pan delay interval in milliseconds. The interval value can range from 100 (0.1 seconds) to 2000 (2 seconds). Default value: %1]]), GestureDetector.PAN_DELAYED_INTERVAL/1000), - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = GestureDetector:getInterval("ges_pan_delayed_interval")/1000, value_min = 100, value_max = 2000, @@ -597,7 +597,7 @@ Default value: %1]]), GestureDetector.PAN_DELAYED_INTERVAL/1000), Set swipe interval in milliseconds. The interval value can range from 100 (0.1 seconds) to 2000 (2 seconds). Default value: %1]]), GestureDetector.SWIPE_INTERVAL/1000), - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = GestureDetector:getInterval("ges_swipe_interval")/1000, value_min = 100, value_max = 2000, diff --git a/frontend/apps/reader/modules/readerlink.lua b/frontend/apps/reader/modules/readerlink.lua index 9e6d6535c..9b1d49c36 100644 --- a/frontend/apps/reader/modules/readerlink.lua +++ b/frontend/apps/reader/modules/readerlink.lua @@ -250,7 +250,7 @@ From the footnote popup, you can jump to the footnote location in the book by sw callback = function() local SpinWidget = require("ui/widget/spinwidget") UIManager:show(SpinWidget:new{ - width = Screen:getWidth() * 0.75, + width = math.floor(Screen:getWidth() * 0.75), value = G_reader_settings:readSetting("footnote_popup_relative_font_size") or -2, value_min = -10, value_max = 5, diff --git a/frontend/apps/reader/modules/readerpagemap.lua b/frontend/apps/reader/modules/readerpagemap.lua index 6e523940a..316b7fed7 100644 --- a/frontend/apps/reader/modules/readerpagemap.lua +++ b/frontend/apps/reader/modules/readerpagemap.lua @@ -392,7 +392,7 @@ function ReaderPageMap:addToMainMenu(menu_items) callback = function(touchmenu_instance) local SpinWidget = require("ui/widget/spinwidget") local spin_w = SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = self.label_font_size, value_min = 8, value_max = 20, diff --git a/frontend/apps/reader/modules/readerrolling.lua b/frontend/apps/reader/modules/readerrolling.lua index 5c8b8db6e..4d6402243 100644 --- a/frontend/apps/reader/modules/readerrolling.lua +++ b/frontend/apps/reader/modules/readerrolling.lua @@ -453,7 +453,7 @@ You can set how many lines are shown.]]) callback = function(touchmenu_instance) local SpinWidget = require("ui/widget/spinwidget") UIManager:show(SpinWidget:new{ - width = Screen:getWidth() * 0.75, + width = math.floor(Screen:getWidth() * 0.75), value = G_reader_settings:readSetting("copt_overlap_lines") or 1, value_min = 1, value_max = 10, diff --git a/frontend/apps/reader/modules/readertypography.lua b/frontend/apps/reader/modules/readertypography.lua index e3da0a4fb..f45395380 100644 --- a/frontend/apps/reader/modules/readertypography.lua +++ b/frontend/apps/reader/modules/readertypography.lua @@ -412,7 +412,7 @@ When the book's language tag is not among our presets, no specific features will right_default = alg_right_hyphen_min, -- let room on the widget sides so we can see -- the hyphenation changes happening - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), default_values = true, default_text = _("Use language defaults"), title_text = _("Hyphenation limits"), diff --git a/frontend/apps/reader/skimtowidget.lua b/frontend/apps/reader/skimtowidget.lua index f69270987..d05b2a8c1 100644 --- a/frontend/apps/reader/skimtowidget.lua +++ b/frontend/apps/reader/skimtowidget.lua @@ -37,12 +37,12 @@ function SkimToWidget:init() self.screen_width = Screen:getWidth() self.screen_height = Screen:getHeight() self.span = math.ceil(self.screen_height * 0.01) - self.width = self.screen_width * 0.95 + self.width = math.floor(self.screen_width * 0.95) self.button_bordersize = Size.border.button -- the buttons need some kind of separation but maybe I should just implement -- margin_left and margin_right… self.button_margin = self.button_bordersize - self.button_width = self.screen_width * 0.16 - (2*self.button_margin) + self.button_width = math.floor(self.screen_width * 0.16) - (2*self.button_margin) if Device:hasKeys() then self.key_events = { Close = { {"Back"}, doc = "close skimto page" } @@ -93,12 +93,12 @@ function SkimToWidget:init() text = dialog_title, face = self.title_face, bold = true, - max_width = self.screen_width * 0.95, + max_width = math.floor(self.screen_width * 0.95), }, } self.progress_bar = ProgressWidget:new{ - width = self.screen_width * 0.9, + width = math.floor(self.screen_width * 0.9), height = Size.item.height_big, percentage = self.curr_page / self.page_count, ticks = self.ticks_candidates, @@ -181,7 +181,7 @@ function SkimToWidget:init() radius = 0, padding = 0, enabled = true, - width = self.screen_width * 0.2 - (2*self.button_margin), + width = math.floor(self.screen_width * 0.2) - (2*self.button_margin), show_parent = self, callback = function() self.callback_switch_to_goto() @@ -268,7 +268,7 @@ function SkimToWidget:init() end, } - local horizontal_span_up = HorizontalSpan:new{ width = self.screen_width * 0.2 } + local horizontal_span_up = HorizontalSpan:new{ width = math.floor(self.screen_width * 0.2) } local button_table_up = HorizontalGroup:new{ align = "center", button_chapter_prev, diff --git a/frontend/ui/elements/refresh_menu_table.lua b/frontend/ui/elements/refresh_menu_table.lua index c0728d534..f30210b1c 100644 --- a/frontend/ui/elements/refresh_menu_table.lua +++ b/frontend/ui/elements/refresh_menu_table.lua @@ -19,7 +19,7 @@ end local function spinWidgetSetRefresh(touchmenu_instance, refresh_rate_num) local SpinWidget = require("ui/widget/spinwidget") local items = SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = custom(refresh_rate_num), value_min = 0, value_max = 200, diff --git a/frontend/ui/elements/screen_dpi_menu_table.lua b/frontend/ui/elements/screen_dpi_menu_table.lua index f622c308a..d8510b1d7 100644 --- a/frontend/ui/elements/screen_dpi_menu_table.lua +++ b/frontend/ui/elements/screen_dpi_menu_table.lua @@ -24,7 +24,7 @@ local function spinWidgetSetDPI(touchmenu_instance) local SpinWidget = require("ui/widget/spinwidget") local UIManager = require("ui/uimanager") local items = SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = custom() or dpi(), value_min = 90, value_max = 900, diff --git a/frontend/ui/widget/bookstatuswidget.lua b/frontend/ui/widget/bookstatuswidget.lua index 17dfd4e2d..2a0599d83 100644 --- a/frontend/ui/widget/bookstatuswidget.lua +++ b/frontend/ui/widget/bookstatuswidget.lua @@ -280,7 +280,7 @@ end function BookStatusWidget:genBookInfoGroup() local screen_width = Screen:getWidth() - local split_span_width = screen_width * 0.05 + local split_span_width = math.floor(screen_width * 0.05) local img_width, img_height if Screen:getScreenMode() == "landscape" then @@ -330,7 +330,7 @@ function BookStatusWidget:genBookInfoGroup() -- progress bar local read_percentage = self.view.state.page / self.total_pages local progress_bar = ProgressWidget:new{ - width = width * 0.7, + width = math.floor(width * 0.7), height = Screen:scaleBySize(10), percentage = read_percentage, ticks = nil, @@ -478,7 +478,7 @@ function BookStatusWidget:genSummaryGroup(width) text = self.summary.note, face = self.medium_font_face, width = width - self.padding * 3, - height = height * 0.75, + height = math.floor(height * 0.75), scroll = true, bordersize = Size.border.default, focused = false, @@ -547,7 +547,7 @@ function BookStatusWidget:generateSwitchGroup(width) end local switch = ToggleSwitch:new{ - width = width * 0.6, + width = math.floor(width * 0.6), default_value = config.default_value, name = config.name, name_text = config.name_text, diff --git a/frontend/ui/widget/buttondialog.lua b/frontend/ui/widget/buttondialog.lua index 09c219a43..e152d57a7 100644 --- a/frontend/ui/widget/buttondialog.lua +++ b/frontend/ui/widget/buttondialog.lua @@ -43,7 +43,7 @@ function ButtonDialog:init() alpha = self.alpha, FrameContainer:new{ ButtonTable:new{ - width = Screen:getWidth()*0.9, + width = math.floor(Screen:getWidth() * 0.9), buttons = self.buttons, show_parent = self, }, diff --git a/frontend/ui/widget/buttondialogtitle.lua b/frontend/ui/widget/buttondialogtitle.lua index 63ac84279..bdb76eec6 100644 --- a/frontend/ui/widget/buttondialogtitle.lua +++ b/frontend/ui/widget/buttondialogtitle.lua @@ -65,14 +65,14 @@ function ButtonDialogTitle:init() bordersize = 0, TextBoxWidget:new{ text = self.title, - width = Screen:getWidth() * 0.8 , + width = math.floor(Screen:getWidth() * 0.8), face = self.use_info_style and self.info_face or self.title_face, alignment = self.title_align or "left", }, }, VerticalSpan:new{ width = Size.span.vertical_default }, ButtonTable:new{ - width = Screen:getWidth() * 0.9, + width = math.floor(Screen:getWidth() * 0.9), buttons = self.buttons, zero_sep = true, show_parent = self, diff --git a/frontend/ui/widget/configdialog.lua b/frontend/ui/widget/configdialog.lua index ac08e9d60..b31855095 100644 --- a/frontend/ui/widget/configdialog.lua +++ b/frontend/ui/widget/configdialog.lua @@ -1103,7 +1103,7 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, d -- (No support for value_table - add it if needed) local curr_values = self.configurable[name] widget = DoubleSpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), left_text = more_options_param.left_text, right_text = more_options_param.right_text, left_value = curr_values[1], @@ -1181,7 +1181,7 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, d end end widget = SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = curr_items, value_index = value_index, value_table = more_options_param.value_table, diff --git a/frontend/ui/widget/datewidget.lua b/frontend/ui/widget/datewidget.lua index 58c95cd04..3f8cf68c7 100644 --- a/frontend/ui/widget/datewidget.lua +++ b/frontend/ui/widget/datewidget.lua @@ -37,7 +37,7 @@ function DateWidget:init() self.light_bar = {} self.screen_width = Screen:getWidth() self.screen_height = Screen:getHeight() - self.width = self.screen_width * 0.95 + self.width = math.floor(self.screen_width * 0.95) if Device:hasKeys() then self.key_events = { Close = { {"Back"}, doc = "close date widget" } @@ -62,7 +62,7 @@ end function DateWidget:update() local year_widget = NumberPickerWidget:new{ show_parent = self, - width = self.screen_width * 0.2, + width = math.floor(self.screen_width * 0.2), value = self.year, value_min = 2017, value_max = 2037, @@ -71,7 +71,7 @@ function DateWidget:update() } local month_widget = NumberPickerWidget:new{ show_parent = self, - width = self.screen_width * 0.2, + width = math.floor(self.screen_width * 0.2), value = self.month, value_min = 1, value_max = 12, @@ -80,7 +80,7 @@ function DateWidget:update() } local day_widget = NumberPickerWidget:new{ show_parent = self, - width = self.screen_width * 0.2, + width = math.floor(self.screen_width * 0.2), value = self.day, value_min = 1, value_max = 31, @@ -94,7 +94,7 @@ function DateWidget:update() alignment = "center", face = self.title_face, bold = true, - width = self.screen_width * 0.1, + width = math.floor(self.screen_width * 0.1), } local date_group = HorizontalGroup:new{ align = "center", @@ -113,7 +113,7 @@ function DateWidget:update() text = self.title_text, face = self.title_face, bold = true, - width = self.screen_width * 0.95, + width = math.floor(self.screen_width * 0.95), }, } local date_line = LineWidget:new{ @@ -172,8 +172,8 @@ function DateWidget:update() date_line, CenterContainer:new{ dimen = Geom:new{ - w = self.screen_width * 0.95, - h = date_group:getSize().h * 1.2, + w = math.floor(self.screen_width * 0.95), + h = math.floor(date_group:getSize().h * 1.2), }, date_group }, diff --git a/frontend/ui/widget/dictquicklookup.lua b/frontend/ui/widget/dictquicklookup.lua index 0cb2f7493..c0a32c1aa 100644 --- a/frontend/ui/widget/dictquicklookup.lua +++ b/frontend/ui/widget/dictquicklookup.lua @@ -247,7 +247,7 @@ function DictQuickLookup:update() self.align = "bottom" end end - self.height = math.min(self.region.h*0.7, Screen:getHeight()*0.5) + self.height = math.floor(math.min(self.region.h*0.7, Screen:getHeight()*0.5)) end -- dictionary title local close_button = CloseButton:new{ window = self, padding_top = self.title_margin, } @@ -310,7 +310,7 @@ function DictQuickLookup:update() css = self:getHtmlDictionaryCss(), default_font_size = Screen:scaleBySize(G_reader_settings:readSetting("dict_font_size") or 20), width = self.width, - height = self.is_fullpage and self.height*0.75 or self.height*0.7, + height = self.is_fullpage and math.floor(self.height*0.75) or math.floor(self.height*0.7), dialog = self, html_link_tapped_callback = function(link) self.html_dictionary_link_tapped_callback(self.dictionary, link) @@ -322,7 +322,7 @@ function DictQuickLookup:update() face = self.content_face, width = self.width, -- get a bit more height for definition as wiki has one less button raw - height = self.is_fullpage and self.height*0.75 or self.height*0.7, + height = self.is_fullpage and math.floor(self.height*0.75) or math.floor(self.height*0.7), dialog = self, -- allow for disabling justification justified = G_reader_settings:nilOrTrue("dict_justify"), diff --git a/frontend/ui/widget/doublespinwidget.lua b/frontend/ui/widget/doublespinwidget.lua index 31a6f19f4..f60e5a71d 100644 --- a/frontend/ui/widget/doublespinwidget.lua +++ b/frontend/ui/widget/doublespinwidget.lua @@ -54,8 +54,8 @@ function DoubleSpinWidget:init() self.medium_font_face = Font:getFace("ffont") self.screen_width = Screen:getWidth() self.screen_height = Screen:getHeight() - self.width = self.width or self.screen_width * 0.8 - self.picker_width = self.screen_width * 0.25 + self.width = self.width or math.floor(self.screen_width * 0.8) + self.picker_width = math.floor(self.screen_width * 0.25) if Device:hasKeys() then self.key_events = { Close = { {"Back"}, doc = "close time widget" } @@ -174,7 +174,7 @@ function DoubleSpinWidget:update() TextBoxWidget:new{ text = self.info_text or "", face = Font:getFace("x_smallinfofont"), - width = self.width * 0.9, + width = math.floor(self.width * 0.9), } } local buttons = { diff --git a/frontend/ui/widget/footnotewidget.lua b/frontend/ui/widget/footnotewidget.lua index dacdcdaa0..4d341461b 100644 --- a/frontend/ui/widget/footnotewidget.lua +++ b/frontend/ui/widget/footnotewidget.lua @@ -291,7 +291,7 @@ function FootnoteWidget:init() local added_bottom_pad = 0 -- See if needed: -- Add a bit to bottom padding, as getSinglePageHeight() cut can be rough - -- added_bottom_pad = font_size * 0.2 + -- added_bottom_pad = math.floor(font_size * 0.2) local reduced_height = single_page_height + top_border_size + padding_top + padding_bottom + added_bottom_pad vgroup = CenterContainer:new{ dimen = Geom:new{ diff --git a/frontend/ui/widget/frontlightwidget.lua b/frontend/ui/widget/frontlightwidget.lua index 3fe9864f7..f37eccaca 100644 --- a/frontend/ui/widget/frontlightwidget.lua +++ b/frontend/ui/widget/frontlightwidget.lua @@ -46,7 +46,7 @@ function FrontLightWidget:init() self.screen_width = Screen:getWidth() self.screen_height = Screen:getHeight() self.span = math.ceil(self.screen_height * 0.01) - self.width = self.screen_width * 0.95 + self.width = math.floor(self.screen_width * 0.95) self.powerd = Device:getPowerDevice() self.fl_min = self.powerd.fl_min self.fl_max = self.powerd.fl_max @@ -155,7 +155,7 @@ function FrontLightWidget:setProgress(num, step, num_warmth) end self.fl_group = ProgressWidget:new{ - width = self.screen_width * 0.9, + width = math.floor(self.screen_width * 0.9), height = Size.item.height_big, percentage = self.fl_cur / self.fl_max, ticks = ticks, @@ -167,14 +167,14 @@ function FrontLightWidget:setProgress(num, step, num_warmth) face = self.medium_font_face, bold = true, alignment = "center", - width = self.screen_width * 0.95 + width = math.floor(self.screen_width * 0.95), } local button_minus = Button:new{ text = "-1", margin = Size.margin.small, radius = 0, enabled = enable_button_minus and not self.light_fallback, - width = self.screen_width * 0.20, + width = math.floor(self.screen_width * 0.2), show_parent = self, callback = function() self:setProgress(self.fl_cur - 1, step) end, } @@ -183,7 +183,7 @@ function FrontLightWidget:setProgress(num, step, num_warmth) margin = Size.margin.small, radius = 0, enabled = enable_button_plus and not self.light_fallback, - width = self.screen_width * 0.20, + width = math.floor(self.screen_width * 0.2), show_parent = self, callback = function() self:setProgress(self.fl_cur + 1, step) end, } @@ -191,14 +191,14 @@ function FrontLightWidget:setProgress(num, step, num_warmth) text = self.fl_cur, face = self.medium_font_face, alignment = "center", - width = self.screen_width * 0.95 - 1.275 * button_minus.width - 1.275 * button_plus.width, + width = math.floor(self.screen_width * 0.95 - 1.275 * button_minus.width - 1.275 * button_plus.width), } local button_min = Button:new{ text = _("Min"), margin = Size.margin.small, radius = 0, enabled = not self.light_fallback, - width = self.screen_width * 0.20, + width = math.floor(self.screen_width * 0.2), show_parent = self, callback = function() self:setProgress(self.fl_min+1, step) end, -- min is 1 (use toggle for 0) } @@ -207,7 +207,7 @@ function FrontLightWidget:setProgress(num, step, num_warmth) margin = Size.margin.small, radius = 0, enabled = not self.light_fallback, - width = self.screen_width * 0.20, + width = math.floor(self.screen_width * 0.2), show_parent = self, callback = function() self:setProgress(self.fl_max, step) end, } @@ -216,14 +216,14 @@ function FrontLightWidget:setProgress(num, step, num_warmth) margin = Size.margin.small, radius = 0, enabled = not self.light_fallback, - width = self.screen_width * 0.20, + width = math.floor(self.screen_width * 0.2), show_parent = self, callback = function() self:setProgress(self.fl_min, step) end, } local empty_space = HorizontalSpan:new{ - width = (self.screen_width * 0.95 - 1.2 * button_minus.width - 1.2 * button_plus.width - 1.2 * button_toggle.width) / 2, + width = math.floor((self.screen_width * 0.95 - 1.2 * button_minus.width - 1.2 * button_plus.width - 1.2 * button_toggle.width) / 2), } local button_table_up = HorizontalGroup:new{ align = "center", @@ -280,7 +280,7 @@ function FrontLightWidget:setProgress(num, step, num_warmth) text = _("Configure"), margin = Size.margin.small, radius = 0, - width = self.screen_width * 0.20, + width = math.floor(self.screen_width * 0.2), enabled = not self.nl_configure_open, show_parent = self, callback = function() @@ -357,14 +357,14 @@ function FrontLightWidget:addWarmthWidgets(num_warmth, step, vertical_group) face = self.medium_font_face, bold = true, alignment = "center", - width = self.screen_width * 0.95 + width = math.floor(self.screen_width * 0.95), } local button_minus = Button:new{ text = "-" .. (1 * self.nl_scale), margin = Size.margin.small, radius = 0, enabled = enable_button_minus, - width = self.screen_width * 0.20, + width = math.floor(self.screen_width * 0.2), show_parent = self, callback = function() self:setProgress(self.fl_cur, step, (num_warmth - (1 * self.nl_scale))) end, } @@ -373,7 +373,7 @@ function FrontLightWidget:addWarmthWidgets(num_warmth, step, vertical_group) margin = Size.margin.small, radius = 0, enabled = enable_button_plus, - width = self.screen_width * 0.20, + width = math.floor(self.screen_width * 0.2), show_parent = self, callback = function() self:setProgress(self.fl_cur, step, (num_warmth + (1 * self.nl_scale))) end, } @@ -381,14 +381,14 @@ function FrontLightWidget:addWarmthWidgets(num_warmth, step, vertical_group) text = num_warmth, face = self.medium_font_face, alignment = "center", - width = self.screen_width * 0.95 - 1.275 * button_minus.width - 1.275 * button_plus.width, + width = math.floor(self.screen_width * 0.95 - 1.275 * button_minus.width - 1.275 * button_plus.width), } local button_min = Button:new{ text = _("Min"), margin = Size.margin.small, radius = 0, enabled = not self.powerd.auto_warmth, - width = self.screen_width * 0.20, + width = math.floor(self.screen_width * 0.2), show_parent = self, callback = function() self:setProgress(self.fl_cur, step, self.nl_min) end, } @@ -397,12 +397,12 @@ function FrontLightWidget:addWarmthWidgets(num_warmth, step, vertical_group) margin = Size.margin.small, radius = 0, enabled = not self.powerd.auto_warmth, - width = self.screen_width * 0.20, + width = math.floor(self.screen_width * 0.2), show_parent = self, callback = function() self:setProgress(self.fl_cur, step, (self.nl_max * self.nl_scale)) end, } local empty_space = HorizontalSpan:new{ - width = (self.screen_width * 0.95 - 1.2 * button_minus.width - 1.2 * button_plus.width) / 2, + width = math.floor((self.screen_width * 0.95 - 1.2 * button_minus.width - 1.2 * button_plus.width) / 2), } local button_table_up = HorizontalGroup:new{ align = "center", @@ -437,7 +437,7 @@ function FrontLightWidget:addWarmthWidgets(num_warmth, step, vertical_group) alignment = "right", fgcolor = self.powerd.auto_warmth and Blitbuffer.COLOR_BLACK or Blitbuffer.COLOR_DARK_GRAY, - width = self.screen_width * 0.3 + width = math.floor(self.screen_width * 0.3), } local text_hour = TextBoxWidget:new{ text = " " .. math.floor(self.powerd.max_warmth_hour) .. ":" .. @@ -446,14 +446,14 @@ function FrontLightWidget:addWarmthWidgets(num_warmth, step, vertical_group) alignment = "center", fgcolor =self.powerd.auto_warmth and Blitbuffer.COLOR_BLACK or Blitbuffer.COLOR_DARK_GRAY, - width = self.screen_width * 0.15 + width = math.floor(self.screen_width * 0.15), } local button_minus_one_hour = Button:new{ text = "−", margin = Size.margin.small, radius = 0, enabled = self.powerd.auto_warmth, - width = self.screen_width * 0.1, + width = math.floor(self.screen_width * 0.1), show_parent = self, callback = function() self.powerd.max_warmth_hour = @@ -473,7 +473,7 @@ function FrontLightWidget:addWarmthWidgets(num_warmth, step, vertical_group) margin = Size.margin.small, radius = 0, enabled = self.powerd.auto_warmth, - width = self.screen_width * 0.1, + width = math.floor(self.screen_width * 0.1), show_parent = self, callback = function() self.powerd.max_warmth_hour = @@ -542,14 +542,14 @@ function FrontLightWidget:update() text = _("Frontlight"), face = self.title_face, bold = true, - width = self.screen_width * 0.95, + width = math.floor(self.screen_width * 0.95), }, } local light_level = FrameContainer:new{ padding = Size.padding.button, margin = Size.margin.small, bordersize = 0, - self:generateProgressGroup(self.screen_width * 0.95, self.screen_height * 0.20, + self:generateProgressGroup(math.floor(self.screen_width * 0.95), math.floor(self.screen_height * 0.2), self.fl_cur, self.one_step) } local light_line = LineWidget:new{ diff --git a/frontend/ui/widget/inputdialog.lua b/frontend/ui/widget/inputdialog.lua index c21ca9329..6c6faeba6 100644 --- a/frontend/ui/widget/inputdialog.lua +++ b/frontend/ui/widget/inputdialog.lua @@ -207,12 +207,12 @@ function InputDialog:init() self.width = Screen:getWidth() - 2*self.border_size self.covers_fullscreen = true -- hint for UIManager:_repaint() else - self.width = self.width or Screen:getWidth() * 0.8 + self.width = self.width or math.floor(Screen:getWidth() * 0.8) end if self.condensed then self.text_width = self.width - 2*(self.border_size + self.input_padding + self.input_margin) else - self.text_width = self.text_width or self.width * 0.9 + self.text_width = self.text_width or math.floor(self.width * 0.9) end if self.readonly then -- hide keyboard if we can't edit self.keyboard_hidden = true diff --git a/frontend/ui/widget/keyboardlayoutdialog.lua b/frontend/ui/widget/keyboardlayoutdialog.lua index ef58d8889..a585e48c4 100644 --- a/frontend/ui/widget/keyboardlayoutdialog.lua +++ b/frontend/ui/widget/keyboardlayoutdialog.lua @@ -25,7 +25,7 @@ local KeyboardLayoutDialog = InputContainer:new{ is_always_active = true, title = _("Keyboard layout"), modal = true, - width = Screen:getWidth() * 0.8, + width = math.floor(Screen:getWidth() * 0.8), face = Font:getFace("cfont", 22), title_face = Font:getFace("x_smalltfont"), title_padding = Size.padding.default, @@ -86,7 +86,7 @@ function KeyboardLayoutDialog:init() self.radio_button_table = RadioButtonTable:new{ radio_buttons = radio_buttons, - width = self.width * 0.9, + width = math.floor(self.width * 0.9), focused = true, scroll = false, parent = self, diff --git a/frontend/ui/widget/logindialog.lua b/frontend/ui/widget/logindialog.lua index 2c69991d5..5f6fcf91b 100644 --- a/frontend/ui/widget/logindialog.lua +++ b/frontend/ui/widget/logindialog.lua @@ -28,7 +28,7 @@ function LoginDialog:init() text = self.username, hint = self.username_hint, face = self.input_face, - width = self.width * 0.9, + width = math.floor(self.width * 0.9), focused = true, scroll = false, parent = self, @@ -38,7 +38,7 @@ function LoginDialog:init() text = self.password, hint = self.password_hint, face = self.input_face, - width = self.width * 0.9, + width = math.floor(self.width * 0.9), text_type = "password", focused = false, scroll = false, diff --git a/frontend/ui/widget/multiinputdialog.lua b/frontend/ui/widget/multiinputdialog.lua index af3a1f775..3b84702f1 100644 --- a/frontend/ui/widget/multiinputdialog.lua +++ b/frontend/ui/widget/multiinputdialog.lua @@ -42,7 +42,7 @@ function MultiInputDialog:init() input_type = field.input_type or "string", text_type = field.text_type, face = self.input_face, - width = self.width * 0.9, + width = math.floor(self.width * 0.9), focused = k == 1 and true or false, scroll = false, parent = self, @@ -68,7 +68,7 @@ function MultiInputDialog:init() TextBoxWidget:new{ text = field.description, face = Font:getFace("x_smallinfofont"), - width = self.width * 0.9, + width = math.floor(self.width * 0.9), } } table.insert(VerticalGroupData, CenterContainer:new{ diff --git a/frontend/ui/widget/naturallightwidget.lua b/frontend/ui/widget/naturallightwidget.lua index 92b20a270..30054ea52 100644 --- a/frontend/ui/widget/naturallightwidget.lua +++ b/frontend/ui/widget/naturallightwidget.lua @@ -46,7 +46,7 @@ function NaturalLightWidget:init() self.screen_width = Screen:getWidth() self.screen_height = Screen:getHeight() self.span = math.ceil(self.screen_height * 0.01) - self.width = self.screen_width*0.95 + self.width = math.floor(self.screen_width * 0.95) self.button_width = 0.08 * self.width self.textbox_width = 0.1 * self.width self.text_width = 0.2 * self.width @@ -149,15 +149,15 @@ function NaturalLightWidget:createFrame() text = _("Natural light configuration"), face = self.title_face, bold = true, - width = self.screen_width * 0.95, + width = math.floor(self.screen_width * 0.95), }, } local main_content = FrameContainer:new{ padding = Size.padding.button, margin = Size.margin.small, bordersize = 0, - self:createMainContent(self.screen_width * 0.95, - self.screen_height * 0.201) + self:createMainContent(math.floor(self.screen_width * 0.95), + math.floor(self.screen_height * 0.2)) } local nl_line = LineWidget:new{ dimen = Geom:new{ @@ -272,7 +272,7 @@ function NaturalLightWidget:createMainContent(width, height) text = "Restore Defaults", margin = Size.margin.small, radius = 0, - width = self.width * 0.35, + width = math.floor(self.width * 0.35), show_parent = self, callback = function() self:setAllValues({white_gain = 25, @@ -288,7 +288,7 @@ function NaturalLightWidget:createMainContent(width, height) text = "Cancel", margin = Size.margin.small, radius = 0, - width = self.width * 0.2, + width = math.floor(self.width * 0.2), show_parent = self, callback = function() self:setAllValues(self.old_values) @@ -299,7 +299,7 @@ function NaturalLightWidget:createMainContent(width, height) text = "Save", margin = Size.margin.small, radius = 0, - width = self.width * 0.2, + width = math.floor(self.width * 0.2), show_parent = self, callback = function() G_reader_settings:saveSetting("natural_light_config", diff --git a/frontend/ui/widget/numberpickerwidget.lua b/frontend/ui/widget/numberpickerwidget.lua index b88df2c73..09973cdef 100644 --- a/frontend/ui/widget/numberpickerwidget.lua +++ b/frontend/ui/widget/numberpickerwidget.lua @@ -56,7 +56,7 @@ function NumberPickerWidget:init() self.screen_width = Screen:getWidth() self.screen_height = Screen:getHeight() if self.width == nil then - self.width = self.screen_width * 0.2 + self.width = math.floor(self.screen_width * 0.2) end if self.value_table then self.value_index = self.value_index or 1 @@ -116,7 +116,7 @@ function NumberPickerWidget:paintWidget() } local empty_space = VerticalSpan:new{ - width = self.screen_height * 0.01 + width = math.ceil(self.screen_height * 0.01) } local value = self.value if not self.value_table then diff --git a/frontend/ui/widget/opdsbrowser.lua b/frontend/ui/widget/opdsbrowser.lua index 44e6516a9..232b6d4a3 100644 --- a/frontend/ui/widget/opdsbrowser.lua +++ b/frontend/ui/widget/opdsbrowser.lua @@ -195,8 +195,8 @@ function OPDSBrowser:addNewCatalog() }, }, }, - width = Screen:getWidth() * 0.95, - height = Screen:getHeight() * 0.2, + width = math.floor(Screen:getWidth() * 0.95), + height = math.floor(Screen:getHeight() * 0.2), } UIManager:show(self.add_server_dialog) self.add_server_dialog:onShowKeyboard() @@ -245,8 +245,8 @@ function OPDSBrowser:editCalibreServer() }, }, }, - width = Screen:getWidth() * 0.95, - height = Screen:getHeight() * 0.2, + width = math.floor(Screen:getWidth() * 0.95), + height = math.floor(Screen:getHeight() * 0.2), } UIManager:show(self.add_server_dialog) self.add_server_dialog:onShowKeyboard() @@ -792,8 +792,8 @@ function OPDSBrowser:editOPDSServer(item) }, }, }, - width = Screen:getWidth() * 0.95, - height = Screen:getHeight() * 0.2, + width = math.floor(Screen:getWidth() * 0.95), + height = math.floor(Screen:getHeight() * 0.2), } UIManager:show(self.edit_server_dialog) self.edit_server_dialog:onShowKeyboard() diff --git a/frontend/ui/widget/openwithdialog.lua b/frontend/ui/widget/openwithdialog.lua index cfd93d5ae..afa52de76 100644 --- a/frontend/ui/widget/openwithdialog.lua +++ b/frontend/ui/widget/openwithdialog.lua @@ -28,7 +28,7 @@ function OpenWithDialog:init() self.radio_button_table = RadioButtonTable:new{ radio_buttons = self.radio_buttons, - width = self.width * 0.9, + width = math.floor(self.width * 0.9), focused = true, scroll = false, parent = self, @@ -45,8 +45,8 @@ function OpenWithDialog:init() end end, - width = self.width * 0.9, - max_width = self.width * 0.9 - 2*Size.border.window, + width = math.floor(self.width * 0.9), + max_width = math.floor(self.width * 0.9 - 2 * Size.border.window), height = self.height, face = self.face, @@ -55,7 +55,7 @@ function OpenWithDialog:init() self._always_file_toggle = LeftContainer:new{ bordersize = 0, dimen = Geom:new{ - w = self.width * 0.9, + w = math.floor(self.width * 0.9), h = self._check_file_button:getSize().h, }, self._check_file_button, @@ -71,8 +71,8 @@ function OpenWithDialog:init() end end, - width = self.width * 0.9, - max_width = self.width * 0.9 - 2*Size.border.window, + width = math.floor(self.width * 0.9), + max_width = math.floor(self.width * 0.9 - 2 * Size.border.window), height = self.height, face = self.face, @@ -81,7 +81,7 @@ function OpenWithDialog:init() self._always_global_toggle = LeftContainer:new{ bordersize = 0, dimen = Geom:new{ - w = self.width * 0.9, + w = math.floor(self.width * 0.9), h = self._check_global_button:getSize().h, }, self._check_global_button, @@ -115,7 +115,7 @@ function OpenWithDialog:init() LineWidget:new{ background = Blitbuffer.COLOR_DARK_GRAY, dimen = Geom:new{ - w = self.width * 0.9, + w = math.floor(self.width * 0.9), h = Size.line.medium, } }, diff --git a/frontend/ui/widget/sortwidget.lua b/frontend/ui/widget/sortwidget.lua index da9317e20..8379d955f 100644 --- a/frontend/ui/widget/sortwidget.lua +++ b/frontend/ui/widget/sortwidget.lua @@ -280,7 +280,7 @@ function SortWidget:init() width = self.width_widget * 22 / 100, } local button_vertical_line = LineWidget:new{ - dimen = Geom:new{ w = Size.line.thick, h = self.item_height * 1.25 }, + dimen = Geom:new{ w = Size.line.thick, h = math.floor(self.item_height * 1.25) }, background = Blitbuffer.COLOR_DARK_GRAY, style = "solid", } diff --git a/frontend/ui/widget/spinwidget.lua b/frontend/ui/widget/spinwidget.lua index c36712b6b..23f3d6dbe 100644 --- a/frontend/ui/widget/spinwidget.lua +++ b/frontend/ui/widget/spinwidget.lua @@ -26,7 +26,7 @@ local SpinWidget = InputContainer:new{ title_text = "", title_face = Font:getFace("x_smalltfont"), info_text = nil, - width = Screen:getWidth() * 0.95, + width = math.floor(Screen:getWidth() * 0.95), height = Screen:getHeight(), value_table = nil, value_index = nil, @@ -80,7 +80,7 @@ function SpinWidget:update() local picker_update_callback = function() end local value_widget = NumberPickerWidget:new{ show_parent = self, - width = self.screen_width * 0.2, + width = math.floor(self.screen_width * 0.2), value = self.value, value_table = self.value_table, value_index = self.value_index, @@ -199,14 +199,14 @@ function SpinWidget:update() TextBoxWidget:new{ text = self.info_text, face = Font:getFace("x_smallinfofont"), - width = self.width * 0.9, + width = math.floor(self.width * 0.9), } }) end table.insert(vgroup, CenterContainer:new{ dimen = Geom:new{ w = self.width, - h = value_group:getSize().h + self.screen_height * 0.1, + h = value_group:getSize().h + math.floor(self.screen_height * 0.1), }, value_group }) diff --git a/frontend/ui/widget/timewidget.lua b/frontend/ui/widget/timewidget.lua index 9ba9c0a4b..e078046d3 100644 --- a/frontend/ui/widget/timewidget.lua +++ b/frontend/ui/widget/timewidget.lua @@ -37,7 +37,7 @@ function TimeWidget:init() self.light_bar = {} self.screen_width = Screen:getWidth() self.screen_height = Screen:getHeight() - self.width = self.screen_width * 0.95 + self.width = math.floor(self.screen_width * 0.95) if Device:hasKeys() then self.key_events = { Close = { {"Back"}, doc = "close time widget" } @@ -62,7 +62,7 @@ end function TimeWidget:update() local hour_widget = NumberPickerWidget:new{ show_parent = self, - width = self.screen_width * 0.2, + width = math.floor(self.screen_width * 0.2), value = self.hour, value_min = 0, value_max = self.hour_max, @@ -71,7 +71,7 @@ function TimeWidget:update() } local min_widget = NumberPickerWidget:new{ show_parent = self, - width = self.screen_width * 0.2, + width = math.floor(self.screen_width * 0.2), value = self.min, value_min = 0, value_max = 59, @@ -83,7 +83,7 @@ function TimeWidget:update() alignment = "center", face = self.title_face, bold = true, - width = self.screen_width * 0.2, + width = math.floor(self.screen_width * 0.2), } local time_group = HorizontalGroup:new{ align = "center", @@ -101,7 +101,7 @@ function TimeWidget:update() text = self.title_text, face = self.title_face, bold = true, - max_width = self.screen_width * 0.95 - closebutton:getSize().w, + max_width = math.floor(self.screen_width * 0.95) - closebutton:getSize().w, }, } local time_line = LineWidget:new{ @@ -158,8 +158,8 @@ function TimeWidget:update() time_line, CenterContainer:new{ dimen = Geom:new{ - w = self.screen_width * 0.95, - h = time_group:getSize().h * 1.2, + w = math.floor(self.screen_width * 0.95), + h = math.floor(time_group:getSize().h * 1.2), }, time_group }, diff --git a/frontend/ui/widget/touchmenu.lua b/frontend/ui/widget/touchmenu.lua index 42fc1b676..d8391316f 100644 --- a/frontend/ui/widget/touchmenu.lua +++ b/frontend/ui/widget/touchmenu.lua @@ -484,8 +484,8 @@ function TouchMenu:init() local up_button = IconButton:new{ icon_file = "resources/icons/appbar.chevron.up.png", show_parent = self.show_parent, - padding_left = footer_width*0.33*0.1, - padding_right = footer_width*0.33*0.1, + padding_left = math.floor(footer_width*0.33*0.1), + padding_right = math.floor(footer_width*0.33*0.1), callback = function() self:backToUpperMenu() end, @@ -493,15 +493,15 @@ function TouchMenu:init() local footer_height = up_button:getSize().h + Size.line.thick self.footer = HorizontalGroup:new{ LeftContainer:new{ - dimen = Geom:new{ w = footer_width*0.33, h = footer_height}, + dimen = Geom:new{ w = math.floor(footer_width*0.33), h = footer_height}, up_button, }, CenterContainer:new{ - dimen = Geom:new{ w = footer_width*0.33, h = footer_height}, + dimen = Geom:new{ w = math.floor(footer_width*0.33), h = footer_height}, self.page_info, }, RightContainer:new{ - dimen = Geom:new{ w = footer_width*0.33, h = footer_height}, + dimen = Geom:new{ w = math.floor(footer_width*0.33), h = footer_height}, self.device_info, } } diff --git a/frontend/ui/wikipedia.lua b/frontend/ui/wikipedia.lua index 8a5eb9f2a..b7b87578a 100644 --- a/frontend/ui/wikipedia.lua +++ b/frontend/ui/wikipedia.lua @@ -536,8 +536,8 @@ function Wikipedia:addImages(page, lang, more_images, image_size_factor, hi_imag local height = wimage.height or 100 -- Give a little boost in size to thin images if width < height / 2 or height < width / 2 then - width = width * 1.3 - height = height * 1.3 + width = math.floor(width * 1.3) + height = math.floor(height * 1.3) end width = math.ceil(width * image_size_factor) height = math.ceil(height * image_size_factor) diff --git a/platform/android/luajit-launcher b/platform/android/luajit-launcher index 5cd2962aa..8cb68727e 160000 --- a/platform/android/luajit-launcher +++ b/platform/android/luajit-launcher @@ -1 +1 @@ -Subproject commit 5cd2962aae063b3d522196244a997e56f4d958ec +Subproject commit 8cb68727e2b723759c468f25472191e3415676ec diff --git a/plugins/autosuspend.koplugin/main.lua b/plugins/autosuspend.koplugin/main.lua index bf7e1384c..9abfea016 100644 --- a/plugins/autosuspend.koplugin/main.lua +++ b/plugins/autosuspend.koplugin/main.lua @@ -141,7 +141,7 @@ function AutoSuspend:addToMainMenu(menu_items) local SpinWidget = require("ui/widget/spinwidget") local curr_items = G_reader_settings:readSetting("auto_suspend_timeout_seconds") or 60*60 local autosuspend_spin = SpinWidget:new { - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = curr_items / 60, value_min = 5, value_max = 240, @@ -173,7 +173,7 @@ function AutoSuspend:addToMainMenu(menu_items) local SpinWidget = require("ui/widget/spinwidget") local curr_items = self.autoshutdown_timeout_seconds local autosuspend_spin = SpinWidget:new { - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = curr_items / 60 / 60, -- About a minute, good for testing and battery life fanatics. -- Just high enough to avoid an instant shutdown death scenario. diff --git a/plugins/autoturn.koplugin/main.lua b/plugins/autoturn.koplugin/main.lua index 432e8656a..38ece19f0 100644 --- a/plugins/autoturn.koplugin/main.lua +++ b/plugins/autoturn.koplugin/main.lua @@ -120,7 +120,7 @@ function AutoTurn:addToMainMenu(menu_items) local SpinWidget = require("ui/widget/spinwidget") local curr_items = G_reader_settings:readSetting("autoturn_timeout_seconds") or 30 local autoturn_spin = SpinWidget:new { - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = curr_items, value_min = 0, value_max = 240, @@ -151,7 +151,7 @@ function AutoTurn:addToMainMenu(menu_items) local SpinWidget = require("ui/widget/spinwidget") local curr_items = G_reader_settings:readSetting("autoturn_distance") or 1 local autoturn_spin = SpinWidget:new { - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = curr_items, value_min = -20, value_max = 20, diff --git a/plugins/coverbrowser.koplugin/main.lua b/plugins/coverbrowser.koplugin/main.lua index f97bb6f64..d7151ea4f 100644 --- a/plugins/coverbrowser.koplugin/main.lua +++ b/plugins/coverbrowser.koplugin/main.lua @@ -422,7 +422,7 @@ function CoverBrowser:addToMainMenu(menu_items) -- value of 10 if it hasn't. local curr_items = BookInfoManager:getSetting("files_per_page") or 10 local items = SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = curr_items, value_min = 4, value_max = 20, diff --git a/plugins/evernote.koplugin/main.lua b/plugins/evernote.koplugin/main.lua index c892df98b..fe1c7ec6b 100644 --- a/plugins/evernote.koplugin/main.lua +++ b/plugins/evernote.koplugin/main.lua @@ -377,8 +377,8 @@ function EvernoteExporter:login() }, }, }, - width = Screen:getWidth() * 0.8, - height = Screen:getHeight() * 0.4, + width = math.floor(Screen:getWidth() * 0.8), + height = math.floor(Screen:getHeight() * 0.4), } UIManager:show(self.login_dialog) diff --git a/plugins/goodreads.koplugin/goodreadsbook.lua b/plugins/goodreads.koplugin/goodreadsbook.lua index facc632af..337d212d4 100644 --- a/plugins/goodreads.koplugin/goodreadsbook.lua +++ b/plugins/goodreads.koplugin/goodreadsbook.lua @@ -97,7 +97,7 @@ function GoodreadsBook:genHeader(title) end function GoodreadsBook:genBookInfoGroup() - local split_span_width = self.screen_width * 0.05 + local split_span_width = math.floor(self.screen_width * 0.05) local img_width, img_height if Screen:getScreenMode() == "landscape" then img_width = Screen:scaleBySize(132) @@ -133,7 +133,7 @@ function GoodreadsBook:genBookInfoGroup() } ) --span - local span_author = VerticalSpan:new{ width = height * 0.1 } + local span_author = VerticalSpan:new{ width = math.floor(height * 0.1) } table.insert(book_meta_info_group, CenterContainer:new{ dimen = Geom:new{ w = width, h = Screen:scaleBySize(10) }, @@ -218,7 +218,7 @@ function GoodreadsBook:genBookInfoGroup() book_meta_info_group, }) return CenterContainer:new{ - dimen = Geom:new{ w = self.screen_width, h = self.screen_height * 0.35 }, + dimen = Geom:new{ w = self.screen_width, h = math.floor(self.screen_height * 0.35) }, book_info_group, } end @@ -244,13 +244,13 @@ function GoodreadsBook:bookReview() ScrollHtmlWidget:new{ html_body = self.dates.description, css = css, - width = self.screen_width * 0.9, - height = self.screen_height * 0.48, + width = math.floor(self.screen_width * 0.9), + height = math.floor(self.screen_height * 0.48), dialog = self, } } return CenterContainer:new{ - dimen = Geom:new{ w = self.screen_width, h = self.screen_height * 0.50 }, + dimen = Geom:new{ w = self.screen_width, h = math.floor(self.screen_height * 0.5) }, book_meta_info_group, } end diff --git a/plugins/goodreads.koplugin/main.lua b/plugins/goodreads.koplugin/main.lua index 753639eb6..225d86659 100644 --- a/plugins/goodreads.koplugin/main.lua +++ b/plugins/goodreads.koplugin/main.lua @@ -146,8 +146,8 @@ How to generate a key and a secret key: }, }, }, - width = Screen:getWidth() * 0.95, - height = Screen:getHeight() * 0.2, + width = math.floor(Screen:getWidth() * 0.95), + height = math.floor(Screen:getHeight() * 0.2), input_type = "text", } UIManager:show(self.settings_dialog) diff --git a/plugins/kosync.koplugin/main.lua b/plugins/kosync.koplugin/main.lua index 63510b41b..c12640feb 100644 --- a/plugins/kosync.koplugin/main.lua +++ b/plugins/kosync.koplugin/main.lua @@ -361,8 +361,8 @@ function KOSync:login() }, }, }, - width = Screen:getWidth() * 0.8, - height = Screen:getHeight() * 0.4, + width = math.floor(Screen:getWidth() * 0.8), + height = math.floor(Screen:getHeight() * 0.4), } UIManager:show(self.login_dialog) diff --git a/plugins/perceptionexpander.koplugin/main.lua b/plugins/perceptionexpander.koplugin/main.lua old mode 100755 new mode 100644 index 335600daf..4b9e009dc --- a/plugins/perceptionexpander.koplugin/main.lua +++ b/plugins/perceptionexpander.koplugin/main.lua @@ -52,8 +52,8 @@ function PerceptionExpander:createUI(readSettings) self.screen_width = Screen:getWidth() local screen_height = Screen:getHeight() - local line_height = screen_height * 0.9 - local line_top_position = screen_height * 0.05 + local line_height = math.floor(screen_height * 0.9) + local line_top_position = math.floor(screen_height * 0.05) self.last_screen_mode = Screen:getScreenMode() if self.last_screen_mode == "landscape" then @@ -152,8 +152,8 @@ function PerceptionExpander:showSettingsDialog() }, }, }, - width = Screen:getWidth() * 0.8, - height = Screen:getHeight() * 0.3, + width = math.floor(Screen:getWidth() * 0.8), + height = math.floor(Screen:getHeight() * 0.3), } UIManager:show(self.settings_dialog) self.settings_dialog:onShowKeyboard() diff --git a/plugins/statistics.koplugin/main.lua b/plugins/statistics.koplugin/main.lua index 8403df6f5..8c022d233 100644 --- a/plugins/statistics.koplugin/main.lua +++ b/plugins/statistics.koplugin/main.lua @@ -789,7 +789,7 @@ The max value ensures a page you stay on for a long time (because you fell aslee callback = function(touchmenu_instance) local SpinWidget = require("ui/widget/spinwidget") UIManager:show(SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = self.calendar_nb_book_spans, value_min = 1, value_max = 5, diff --git a/plugins/statistics.koplugin/readerprogress.lua b/plugins/statistics.koplugin/readerprogress.lua index 58272d1fe..84c3650a0 100644 --- a/plugins/statistics.koplugin/readerprogress.lua +++ b/plugins/statistics.koplugin/readerprogress.lua @@ -47,7 +47,7 @@ function ReaderProgress:init() self.large_font_face = Font:getFace("largeffont") self.screen_width = Screen:getWidth() self.screen_height = Screen:getHeight() - if Screen:getWidth() < Screen:getHeight() then + if self.screen_width < self.screen_height then self.header_span = 25 self.stats_span = 20 else @@ -256,7 +256,7 @@ function ReaderProgress:genWeekStats(stats_day) LeftContainer:new{ dimen = Geom:new{ w = self.screen_width , h = height / 3 }, ProgressWidget:new{ - width = (self.screen_width * 0.005) + (self.screen_width * 0.9 * select_day_time / max_week_time), + width = math.floor((self.screen_width * 0.005) + (self.screen_width * 0.9 * select_day_time / max_week_time)), height = Screen:scaleBySize(14), percentage = 1.0, ticks = nil, @@ -272,7 +272,7 @@ function ReaderProgress:genWeekStats(stats_day) end --for i=1 table.insert(statistics_container, statistics_group) return CenterContainer:new{ - dimen = Geom:new{ w = self.screen_width * 1.1 , h = self.screen_height * 0.50 }, + dimen = Geom:new{ w = math.floor(self.screen_width * 1.1), h = math.floor(self.screen_height * 0.5) }, statistics_container, } end @@ -365,7 +365,7 @@ function ReaderProgress:genSummaryDay(width) table.insert(statistics_group, span_group) table.insert(statistics_container, statistics_group) return CenterContainer:new{ - dimen = Geom:new{ w = self.screen_width , h = self.screen_height * 0.13 }, + dimen = Geom:new{ w = self.screen_width , h = math.floor(self.screen_height * 0.13) }, statistics_container, } end @@ -490,7 +490,7 @@ function ReaderProgress:genSummaryWeek(width) table.insert(statistics_group, data_group) table.insert(statistics_container, statistics_group) return CenterContainer:new{ - dimen = Geom:new{ w = self.screen_width , h = self.screen_height * 0.10 }, + dimen = Geom:new{ w = self.screen_width , h = math.floor(self.screen_height * 0.10) }, statistics_container, } end diff --git a/plugins/terminal.koplugin/main.lua b/plugins/terminal.koplugin/main.lua index f281cf82d..d74ead149 100644 --- a/plugins/terminal.koplugin/main.lua +++ b/plugins/terminal.koplugin/main.lua @@ -26,7 +26,7 @@ function Terminal:start() title = _("Enter a command and press \"Execute\""), input = self.command, para_direction_rtl = false, -- force LTR - text_height = Screen:getHeight() * 0.4, + text_height = math.floor(Screen:getHeight() * 0.4), input_type = "string", buttons = {{{ text = _("Cancel"), diff --git a/plugins/texteditor.koplugin/main.lua b/plugins/texteditor.koplugin/main.lua index 77bff2370..439cc4bfb 100644 --- a/plugins/texteditor.koplugin/main.lua +++ b/plugins/texteditor.koplugin/main.lua @@ -95,7 +95,7 @@ function TextEditor:getSubMenuItems() local SpinWidget = require("ui/widget/spinwidget") local font_size = self.font_size UIManager:show(SpinWidget:new{ - width = Screen:getWidth() * 0.6, + width = math.floor(Screen:getWidth() * 0.6), value = font_size, value_min = 8, value_max = 26, diff --git a/plugins/wallabag.koplugin/main.lua b/plugins/wallabag.koplugin/main.lua index 1e78abb92..b99587fcc 100644 --- a/plugins/wallabag.koplugin/main.lua +++ b/plugins/wallabag.koplugin/main.lua @@ -936,8 +936,8 @@ Restart KOReader after editing the config file.]]), BD.dirpath(DataStorage:getSe }, }, }, - width = Screen:getWidth() * 0.95, - height = Screen:getHeight() * 0.2, + width = math.floor(Screen:getWidth() * 0.95), + height = math.floor(Screen:getHeight() * 0.2), input_type = "string", } UIManager:show(self.settings_dialog) @@ -976,8 +976,8 @@ function Wallabag:editClientSettings() }, }, }, - width = Screen:getWidth() * 0.95, - height = Screen:getHeight() * 0.2, + width = math.floor(Screen:getWidth() * 0.95), + height = math.floor(Screen:getHeight() * 0.2), input_type = "string", } UIManager:show(self.client_settings_dialog) diff --git a/spec/unit/widget_inputcontainer_spec.lua b/spec/unit/widget_inputcontainer_spec.lua index c907f90a4..bbb9dd5dd 100644 --- a/spec/unit/widget_inputcontainer_spec.lua +++ b/spec/unit/widget_inputcontainer_spec.lua @@ -36,7 +36,7 @@ describe("InputContainer widget", function() assert.is.same("bar", ic._ordered_touch_zones[2].def.id) assert.is.same("tap", ic._ordered_touch_zones[2].gs_range.ges) assert.is.same(0, ic._ordered_touch_zones[2].gs_range.range.x) - assert.is.same(screen_height * 0.1, ic._ordered_touch_zones[2].gs_range.range.y) + assert.is.same(math.floor(screen_height * 0.1), ic._ordered_touch_zones[2].gs_range.range.y) assert.is.same(screen_width / 2, ic._ordered_touch_zones[2].gs_range.range.w) assert.is.same(screen_height, ic._ordered_touch_zones[2].gs_range.range.h) end)