Spinwidgets: can now get width or width_factor (#8269)

reviewable/pr8263/r3^2
hius07 3 years ago committed by GitHub
parent 2b87b1d8ed
commit 4c9d1ac3f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -164,6 +164,7 @@ This is disabled in scroll mode. Switching from page mode with two columns to sc
more_options = true,
more_options_param = {
name_text = _("Left/Right Margins"),
widget_width_factor = 0.6,
left_min = 0,
left_max = 140,
left_step = 1,
@ -230,6 +231,7 @@ In the top menu → Settings → Status bar, you can choose whether the bottom m
name_text = _("Top/Bottom Margins"),
names = { "t_page_margin", "b_page_margin" },
event = "SetPageTopAndBottomMargin",
widget_width_factor = 0.6,
left_text = _("Top"),
left_min = 0,
left_max = 140,
@ -280,6 +282,7 @@ In the top menu → Settings → Status bar, you can choose whether the bottom m
name_text = _("Top/Bottom Margins"),
names = { "t_page_margin", "b_page_margin" },
event = "SetPageTopAndBottomMargin",
widget_width_factor = 0.6,
left_text = _("Top"),
left_min = 0,
left_max = 140,

@ -1153,6 +1153,7 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, m
curr_values = self.configurable[name]
end
widget = DoubleSpinWidget:new{
width_factor = more_options_param.widget_width_factor,
title_text = name_text or _("Set values"),
info_text = more_options_param.info_text,
left_text = more_options_param.left_text,
@ -1250,6 +1251,7 @@ function ConfigDialog:onConfigMoreChoose(values, name, event, args, name_text, m
end
end
widget = SpinWidget:new{
width_factor = more_options_param.widget_width_factor,
title_text = name_text or _("Set value"),
info_text = more_options_param.info_text,
value = curr_items,

@ -26,6 +26,7 @@ local DoubleSpinWidget = 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,
left_min = 1,
left_max = 20,
@ -54,7 +55,12 @@ local DoubleSpinWidget = InputContainer:new{
function DoubleSpinWidget: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.8 -- 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 time widget" }

@ -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" }

Loading…
Cancel
Save