mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Spinwidgets: can now get width or width_factor (#8269)
This commit is contained in:
@@ -25,6 +25,7 @@ local SpinWidget = InputContainer:new{
|
||||
title_face = Font:getFace("x_smalltfont"),
|
||||
info_text = nil,
|
||||
width = nil,
|
||||
width_factor = nil, -- number between 0 and 1, factor to the smallest of screen width and height
|
||||
height = nil,
|
||||
value_table = nil,
|
||||
value_index = nil,
|
||||
@@ -50,7 +51,12 @@ local SpinWidget = InputContainer:new{
|
||||
function SpinWidget:init()
|
||||
self.screen_width = Screen:getWidth()
|
||||
self.screen_height = Screen:getHeight()
|
||||
self.width = self.width or math.floor(math.min(self.screen_width, self.screen_height) * 0.6)
|
||||
if not self.width then
|
||||
if not self.width_factor then
|
||||
self.width_factor = 0.6 -- default if no width speficied
|
||||
end
|
||||
self.width = math.floor(math.min(self.screen_width, self.screen_height) * self.width_factor)
|
||||
end
|
||||
if Device:hasKeys() then
|
||||
self.key_events = {
|
||||
Close = { {"Back"}, doc = "close spin widget" }
|
||||
|
||||
Reference in New Issue
Block a user