switch from scaleByDPI() to scaleBySize()

pull/1217/head
Hans-Werner Hilse 10 years ago
parent 63af71188a
commit 22697adf20

@ -36,7 +36,7 @@ function FileManager:init()
face = Font:getFace("tfont", 24),
text = self.title,
},
VerticalSpan:new{ width = Screen:scaleByDPI(10) }
VerticalSpan:new{ width = Screen:scaleBySize(10) }
}
local g_show_hidden = G_reader_settings:readSetting("show_hidden")

@ -20,7 +20,7 @@ local PageCropDialog = VerticalGroup:new{
cancel_text = "Cancel",
ok_callback = function() end,
cancel_callback = function() end,
button_width = math.floor(Screen:scaleByDPI(70)),
button_width = math.floor(Screen:scaleBySize(70)),
}
function PageCropDialog:init()

@ -96,7 +96,7 @@ function ReaderDictionary:showDict(word, results, box)
word = word,
results = results,
dictionary = self.default_dictionary,
width = Screen:getWidth() - Screen:scaleByDPI(80),
width = Screen:getWidth() - Screen:scaleBySize(80),
word_box = box,
-- differentiate between dict and wiki
wiki = self.wiki,

@ -81,7 +81,7 @@ function ReaderFont:onReadSettings(config)
self.font_size = config:readSetting("font_size")
or DCREREADER_CONFIG_DEFAULT_FONT_SIZE or 22
self.ui.document:setFontSize(Screen:scaleByDPI(self.font_size))
self.ui.document:setFontSize(Screen:scaleBySize(self.font_size))
self.font_embolden = config:readSetting("font_embolden")
or G_reader_settings:readSetting("copt_font_weight") or 0
@ -149,7 +149,7 @@ function ReaderFont:onSetFontSize(new_size)
text = _("Set font size to ")..self.font_size,
timeout = 1,
})
self.ui.document:setFontSize(Screen:scaleByDPI(new_size))
self.ui.document:setFontSize(Screen:scaleBySize(new_size))
self.ui:handleEvent(Event:new("UpdatePos"))
return true

@ -27,9 +27,9 @@ local ReaderFooter = InputContainer:new{
progress_text = nil,
text_font_face = "ffont",
text_font_size = DMINIBAR_FONT_SIZE,
bar_height = Screen:scaleByDPI(DMINIBAR_HEIGHT),
height = Screen:scaleByDPI(DMINIBAR_CONTAINER_HEIGHT),
padding = Screen:scaleByDPI(10),
bar_height = Screen:scaleBySize(DMINIBAR_HEIGHT),
height = Screen:scaleBySize(DMINIBAR_CONTAINER_HEIGHT),
padding = Screen:scaleBySize(10),
}
function ReaderFooter:init()

@ -17,7 +17,7 @@ local ReaderPaging = InputContainer:new{
visible_area = nil,
page_area = nil,
show_overlap_enable = nil,
overlap = Screen:scaleByDPI(DOVERLAPPIXELS),
overlap = Screen:scaleBySize(DOVERLAPPIXELS),
page_flipping_mode = false,
bookmark_flipping_mode = false,

@ -20,14 +20,14 @@ function ReaderScreenshot:init()
TapDiagonal = {
GestureRange:new{
ges = "two_finger_tap",
scale = {diagonal - Screen:scaleByDPI(200), diagonal},
scale = {diagonal - Screen:scaleBySize(200), diagonal},
rate = 1.0,
}
},
SwipeDiagonal = {
GestureRange:new{
ges = "swipe",
scale = {diagonal - Screen:scaleByDPI(200), diagonal},
scale = {diagonal - Screen:scaleBySize(200), diagonal},
rate = 1.0,
}
},

@ -244,14 +244,14 @@ function ReaderToc:onShowToc()
-- update collapsible state
self.expand_button = Button:new{
icon = "resources/icons/appbar.control.expand.png",
width = Screen:scaleByDPI(30),
width = Screen:scaleBySize(30),
bordersize = 0,
show_parent = self,
}
self.collapse_button = Button:new{
icon = "resources/icons/appbar.control.collapse.png",
width = Screen:scaleByDPI(30),
width = Screen:scaleBySize(30),
bordersize = 0,
show_parent = self,
}

@ -157,10 +157,10 @@ function ReaderTypeset:makeDefaultFloatingPunctuation()
end
function ReaderTypeset:onSetPageMargins(margins)
local left = Screen:scaleByDPI(margins[1])
local top = Screen:scaleByDPI(margins[2])
local right = Screen:scaleByDPI(margins[3])
local bottom = Screen:scaleByDPI(margins[4])
local left = Screen:scaleBySize(margins[1])
local top = Screen:scaleBySize(margins[2])
local right = Screen:scaleBySize(margins[3])
local bottom = Screen:scaleBySize(margins[4])
self.ui.document:setPageMargins(left, top, right, bottom)
self.ui:handleEvent(Event:new("UpdatePos"))
return true

@ -41,8 +41,8 @@ local ReaderView = OverlapGroup:new{
page_states = {},
scroll_mode = "vertical",
page_gap = {
width = Screen:scaleByDPI(8),
height = Screen:scaleByDPI(8),
width = Screen:scaleBySize(8),
height = Screen:scaleBySize(8),
color = Blitbuffer.gray(0.5),
},
-- DjVu page rendering mode (used in djvu.c:drawPage())

@ -919,10 +919,10 @@ function KoptInterface:getLinkFromPosition(doc, pageno, pos)
local link = page_links[i]
-- enlarge tappable link box
local lbox = Geom:new{
x = link.x0 - Screen:scaleByDPI(5),
y = link.y0 - Screen:scaleByDPI(5),
w = link.x1 - link.x0 + Screen:scaleByDPI(10),
h = link.y1 - link.y0 + Screen:scaleByDPI(10)
x = link.x0 - Screen:scaleBySize(5),
y = link.y0 - Screen:scaleBySize(5),
w = link.x1 - link.x0 + Screen:scaleBySize(10),
h = link.y1 - link.y0 + Screen:scaleBySize(10)
}
if inside_box(pos, lbox) and link.page then
return link, lbox

@ -56,7 +56,7 @@ function Font:getFace(font, size)
-- original size before scaling by screen DPI
local orig_size = size
local size = Screen:scaleByDPI(size)
local size = Screen:scaleBySize(size)
local face = self.faces[font..size]
-- build face if not found

@ -15,8 +15,8 @@ local ButtonTable = VerticalGroup:new{
{text="Cancel", enabled=false, callback=nil},
},
},
sep_width = Screen:scaleByDPI(1),
padding = Screen:scaleByDPI(2),
sep_width = Screen:scaleBySize(1),
padding = Screen:scaleBySize(2),
zero_sep = false,
button_font_face = "cfont",
@ -66,7 +66,7 @@ function ButtonTable:init()
end
function ButtonTable:addHorizontalSep()
table.insert(self, VerticalSpan:new{ width = Screen:scaleByDPI(2) })
table.insert(self, VerticalSpan:new{ width = Screen:scaleBySize(2) })
table.insert(self, LineWidget:new{
background = Blitbuffer.gray(0.5),
dimen = Geom:new{
@ -74,7 +74,7 @@ function ButtonTable:addHorizontalSep()
h = self.sep_width,
}
})
table.insert(self, VerticalSpan:new{ width = Screen:scaleByDPI(2) })
table.insert(self, VerticalSpan:new{ width = Screen:scaleBySize(2) })
end
return ButtonTable

@ -161,7 +161,7 @@ function ConfigOption:init()
-- fill vertical group of config tab
local vertical_group = VerticalGroup:new{}
table.insert(vertical_group, VerticalSpan:new{
width = Screen:scaleByDPI(default_option_padding),
width = Screen:scaleBySize(default_option_padding),
})
local show_advanced = G_reader_settings:readSetting("show_advanced") or false
for c = 1, #self.options do
@ -173,10 +173,10 @@ function ConfigOption:init()
local name_font_size = self.options[c].name_font_size and self.options[c].name_font_size or default_name_font_size
local item_font_face = self.options[c].item_font_face and self.options[c].item_font_face or "cfont"
local item_font_size = self.options[c].item_font_size and self.options[c].item_font_size or default_item_font_size
local option_height = Screen:scaleByDPI(self.options[c].height and self.options[c].height or default_option_height)
local option_height = Screen:scaleBySize(self.options[c].height and self.options[c].height or default_option_height)
local item_spacing_with = self.options[c].spacing and self.options[c].spacing or default_items_spacing
local items_spacing = HorizontalSpan:new{
width = Screen:scaleByDPI(item_spacing_with)
width = Screen:scaleBySize(item_spacing_with)
}
local horizontal_group = HorizontalGroup:new{}
if self.options[c].name_text then
@ -284,7 +284,7 @@ function ConfigOption:init()
local max_item_spacing = (Screen:getWidth() * item_align -
middle_item:getSize().w * items_count) / items_count
local items_spacing = HorizontalSpan:new{
width = math.min(max_item_spacing, Screen:scaleByDPI(item_spacing_with))
width = math.min(max_item_spacing, Screen:scaleBySize(item_spacing_with))
}
for d = 1, #self.options[c].item_text do
local option_item = nil
@ -334,7 +334,7 @@ function ConfigOption:init()
local max_item_spacing = (Screen:getWidth() * item_align -
first_item:getSize().w * items_count) / items_count
local items_spacing = HorizontalSpan:new{
width = math.min(max_item_spacing, Screen:scaleByDPI(item_spacing_with))
width = math.min(max_item_spacing, Screen:scaleBySize(item_spacing_with))
}
for d = 1, #self.options[c].item_icons do
local option_item = OptionIconItem:new{
@ -362,7 +362,7 @@ function ConfigOption:init()
if self.options[c].toggle then
local max_toggle_width = Screen:getWidth() / 2
local toggle_width = Screen:scaleByDPI(self.options[c].width or 216)
local toggle_width = Screen:scaleBySize(self.options[c].width or 216)
local switch = ToggleSwitch:new{
width = math.min(max_toggle_width, toggle_width),
font_face = item_font_face,

@ -41,13 +41,13 @@ local DictQuickLookup = InputContainer:new{
-- box of highlighted word, quick lookup window tries to not hide the word
word_box = nil,
title_padding = Screen:scaleByDPI(5),
title_margin = Screen:scaleByDPI(2),
word_padding = Screen:scaleByDPI(5),
word_margin = Screen:scaleByDPI(2),
definition_padding = Screen:scaleByDPI(2),
definition_margin = Screen:scaleByDPI(2),
button_padding = Screen:scaleByDPI(14),
title_padding = Screen:scaleBySize(5),
title_margin = Screen:scaleBySize(2),
word_padding = Screen:scaleBySize(5),
word_margin = Screen:scaleBySize(2),
definition_padding = Screen:scaleBySize(2),
definition_margin = Screen:scaleBySize(2),
button_padding = Screen:scaleBySize(14),
}
function DictQuickLookup:init()
@ -202,7 +202,7 @@ function DictQuickLookup:update()
--background = Blitbuffer.gray(0.5),
dimen = Geom:new{
w = button_table:getSize().w + self.button_padding,
h = Screen:scaleByDPI(2),
h = Screen:scaleBySize(2),
}
}
@ -252,7 +252,7 @@ function DictQuickLookup:update()
dimen = self.region,
FrameContainer:new{
bordersize = 0,
padding = Screen:scaleByDPI(5),
padding = Screen:scaleBySize(5),
self.dict_frame,
}
}

@ -27,11 +27,11 @@ local InputDialog = InputContainer:new{
title_face = Font:getFace("tfont", 22),
input_face = Font:getFace("cfont", 20),
title_padding = Screen:scaleByDPI(5),
title_margin = Screen:scaleByDPI(2),
input_padding = Screen:scaleByDPI(10),
input_margin = Screen:scaleByDPI(10),
button_padding = Screen:scaleByDPI(14),
title_padding = Screen:scaleBySize(5),
title_margin = Screen:scaleBySize(2),
input_padding = Screen:scaleBySize(10),
input_margin = Screen:scaleBySize(10),
button_padding = Screen:scaleBySize(14),
}
function InputDialog:init()
@ -76,7 +76,7 @@ function InputDialog:init()
--background = Blitbuffer.gray(0.5),
dimen = Geom:new{
w = self.button_table:getSize().w + self.button_padding,
h = Screen:scaleByDPI(2),
h = Screen:scaleBySize(2),
}
}

@ -323,7 +323,7 @@ local Menu = FocusManager:new{
width = 500,
-- height will be calculated according to item number if not given
height = nil,
header_padding = Screen:scaleByDPI(10),
header_padding = Screen:scaleBySize(10),
dimen = Geom:new{},
item_table = {},
item_shortcuts = {
@ -359,7 +359,7 @@ function Menu:_recalculateDimen()
self.dimen.w = self.width
self.item_dimen = Geom:new{
w = self.dimen.w,
h = Screen:scaleByDPI(46), -- hardcoded for now
h = Screen:scaleBySize(46), -- hardcoded for now
}
-- if height not given, dynamically calculate it
self.dimen.h = self.height or (#self.item_table + 2) * self.item_dimen.h
@ -418,7 +418,7 @@ function Menu:init()
show_parent = self,
}
self.page_info_spacer = HorizontalSpan:new{
width = Screen:scaleByDPI(32),
width = Screen:scaleBySize(32),
}
self.page_info_left_chev:hide()
self.page_info_right_chev:hide()
@ -449,7 +449,7 @@ function Menu:init()
self.page_return_arrow:hide()
self.return_button = HorizontalGroup:new{
HorizontalSpan:new{
width = Screen:scaleByDPI(5),
width = Screen:scaleBySize(5),
},
self.page_return_arrow,
}

@ -19,8 +19,8 @@ local ScrollTextWidget = InputContainer:new{
fgcolor = Blitbuffer.COLOR_BLACK,
width = 400,
height = 20,
scroll_bar_width = Screen:scaleByDPI(6),
text_scroll_span = Screen:scaleByDPI(6),
scroll_bar_width = Screen:scaleBySize(6),
text_scroll_span = Screen:scaleBySize(6),
dialog = nil,
}
@ -38,12 +38,12 @@ function ScrollTextWidget:init()
enable = visible_line_count < total_line_count,
low = 0,
high = visible_line_count/total_line_count,
width = Screen:scaleByDPI(6),
width = Screen:scaleBySize(6),
height = self.height,
}
local horizontal_group = HorizontalGroup:new{}
table.insert(horizontal_group, self.text_widget)
table.insert(horizontal_group, HorizontalSpan:new{width = Screen:scaleByDPI(6)})
table.insert(horizontal_group, HorizontalSpan:new{width = Screen:scaleBySize(6)})
table.insert(horizontal_group, self.v_scroll_bar)
self[1] = horizontal_group
self.dimen = Geom:new(self[1]:getSize())

@ -25,8 +25,8 @@ function ToggleLabel:paintTo(bb, x, y)
end
local ToggleSwitch = InputContainer:new{
width = Screen:scaleByDPI(216),
height = Screen:scaleByDPI(30),
width = Screen:scaleBySize(216),
height = Screen:scaleBySize(30),
bgcolor = Blitbuffer.COLOR_WHITE, -- unfoused item color
fgcolor = Blitbuffer.gray(0.5), -- focused item color
font_face = "cfont",

@ -149,16 +149,16 @@ local TouchMenuBar = InputContainer:new{
}
function TouchMenuBar:init()
local icon_sep_width = Screen:scaleByDPI(2)
local icon_sep_width = Screen:scaleBySize(2)
local icons_sep_width = icon_sep_width * (#self.icons + 1)
-- we assume all icons are of the same width
local ib = IconButton:new{icon_file = self.icons[1]}
local content_width = ib:getSize().w * #self.icons + icons_sep_width
local spacing_width = (self.width - content_width)/(#self.icons*2)
local spacing = HorizontalSpan:new{
width = math.min(spacing_width, Screen:scaleByDPI(20))
width = math.min(spacing_width, Screen:scaleBySize(20))
}
self.height = ib:getSize().h + Screen:scaleByDPI(10)
self.height = ib:getSize().h + Screen:scaleBySize(10)
self.show_parent = self.show_parent or self
self.bar_icon_group = HorizontalGroup:new{}
-- build up image widget for menu icon bar
@ -192,7 +192,7 @@ function TouchMenuBar:init()
self.bar_sep = LineWidget:new{
dimen = Geom:new{
w = self.width,
h = Screen:scaleByDPI(2),
h = Screen:scaleBySize(2),
},
empty_segments = {
{
@ -205,7 +205,7 @@ function TouchMenuBar:init()
local icon_sep = LineWidget:new{
style = k == 1 and "solid" or "none",
dimen = Geom:new{
w = Screen:scaleByDPI(2),
w = Screen:scaleBySize(2),
h = self.height,
}
}
@ -258,9 +258,9 @@ local TouchMenu = InputContainer:new{
-- for returnning in multi-level menus
item_table_stack = nil,
item_table = nil,
item_height = Screen:scaleByDPI(50),
bordersize = Screen:scaleByDPI(2),
padding = Screen:scaleByDPI(5),
item_height = Screen:scaleBySize(50),
bordersize = Screen:scaleBySize(2),
padding = Screen:scaleBySize(5),
fface = Font:getFace("ffont", 20),
width = nil,
height = nil,
@ -353,7 +353,7 @@ function TouchMenu:init()
end,
}
local footer_width = self.width - self.padding*2 - self.bordersize*2
local footer_height = up_button:getSize().h + Screen:scaleByDPI(2)
local footer_height = up_button:getSize().h + Screen:scaleBySize(2)
self.footer = HorizontalGroup:new{
LeftContainer:new{
dimen = Geom:new{ w = footer_width*0.33, h = footer_height},
@ -450,7 +450,7 @@ function TouchMenu:updateItems()
end -- if i <= self.items
end -- for c=1, self.perpage
table.insert(self.item_group, VerticalSpan:new{width = Screen:scaleByDPI(2)})
table.insert(self.item_group, VerticalSpan:new{width = Screen:scaleBySize(2)})
table.insert(self.item_group, self.footer)
self.page_info_text.text = util.template(_("Page %1 of %2"), self.page, self.page_num)
self.page_info_left_chev:showHide(self.page_num > 1)

@ -155,7 +155,7 @@ local VirtualKeyboard = InputContainer:new{
height = 256,
bordersize = 2,
padding = 2,
key_padding = Screen:scaleByDPI(6),
key_padding = Screen:scaleBySize(6),
}
function VirtualKeyboard:init()

Loading…
Cancel
Save