2017-09-14 20:31:25 +00:00
|
|
|
local Blitbuffer = require("ffi/blitbuffer")
|
2014-08-25 16:00:11 +00:00
|
|
|
local CenterContainer = require("ui/widget/container/centercontainer")
|
2017-09-14 20:31:25 +00:00
|
|
|
local Device = require("device")
|
|
|
|
local Font = require("ui/font")
|
|
|
|
local FrameContainer = require("ui/widget/container/framecontainer")
|
|
|
|
local Geom = require("ui/geometry")
|
2014-08-25 16:00:11 +00:00
|
|
|
local InputDialog = require("ui/widget/inputdialog")
|
|
|
|
local InputText = require("ui/widget/inputtext")
|
2017-09-13 14:56:20 +00:00
|
|
|
local Size = require("ui/size")
|
2017-09-14 20:31:25 +00:00
|
|
|
local TextBoxWidget = require("ui/widget/textboxwidget")
|
2014-08-25 16:00:11 +00:00
|
|
|
local UIManager = require("ui/uimanager")
|
2017-09-14 20:31:25 +00:00
|
|
|
local VerticalGroup = require("ui/widget/verticalgroup")
|
2017-10-08 15:53:25 +00:00
|
|
|
local VerticalSpan = require("ui/widget/verticalspan")
|
2014-08-25 16:00:11 +00:00
|
|
|
local _ = require("gettext")
|
2017-09-14 20:31:25 +00:00
|
|
|
local Screen = Device.screen
|
2014-08-25 16:00:11 +00:00
|
|
|
|
2017-09-14 20:31:25 +00:00
|
|
|
local input_field, input_description
|
2014-08-25 16:00:11 +00:00
|
|
|
|
|
|
|
local MultiInputDialog = InputDialog:extend{
|
|
|
|
field = {},
|
|
|
|
field_hint = {},
|
2014-09-05 13:05:20 +00:00
|
|
|
fields = {},
|
2017-09-13 14:56:20 +00:00
|
|
|
description_padding = Size.padding.default,
|
|
|
|
description_margin = Size.margin.small,
|
2014-08-25 16:00:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MultiInputDialog:init()
|
|
|
|
-- init title and buttons in base class
|
|
|
|
InputDialog.init(self)
|
|
|
|
local VerticalGroupData = VerticalGroup:new{
|
|
|
|
align = "left",
|
2018-08-06 19:16:30 +00:00
|
|
|
self.title_widget,
|
2014-08-25 16:00:11 +00:00
|
|
|
self.title_bar,
|
|
|
|
}
|
|
|
|
|
|
|
|
input_field = {}
|
2017-09-14 20:31:25 +00:00
|
|
|
input_description = {}
|
2014-08-25 16:00:11 +00:00
|
|
|
local k = 0
|
2014-09-05 13:05:20 +00:00
|
|
|
for i, field in ipairs(self.fields) do
|
2014-08-25 16:00:11 +00:00
|
|
|
k = k + 1
|
|
|
|
input_field[k] = InputText:new{
|
2014-09-05 13:05:20 +00:00
|
|
|
text = field.text or "",
|
|
|
|
hint = field.hint or "",
|
2015-09-07 17:06:17 +00:00
|
|
|
input_type = field.input_type or "string",
|
2018-09-18 18:21:14 +00:00
|
|
|
text_type = field.text_type,
|
2014-08-25 16:00:11 +00:00
|
|
|
face = self.input_face,
|
|
|
|
width = self.width * 0.9,
|
2014-09-05 13:05:20 +00:00
|
|
|
focused = k == 1 and true or false,
|
2014-08-25 16:00:11 +00:00
|
|
|
scroll = false,
|
|
|
|
parent = self,
|
2018-07-07 22:45:27 +00:00
|
|
|
padding = field.padding or nil,
|
|
|
|
margin = field.margin or nil,
|
2014-08-25 16:00:11 +00:00
|
|
|
}
|
A few graphics fixes after #4541 (#4554)
* Various FocusManager related tweaks to limit its usage to devices with a DPad, and prevent initial button highlights in Dialogs on devices where it makes no sense (i.e., those without a DPad. And even on DPad devices, I'm not even sure how we'd go about making one of those pop up anyway, because no Touch ;)!).
* One mysterious fix to text-only Buttons so that the flash_ui highlight always works, and always honors `FrameContainer`'s pill shape. (Before that, an unhighlight on a text button with a callback that didn't repaint anything [say, the find first/find last buttons in the Reader's search bar when you're already on the first/last match] would do a square black highlight, and a white pill-shaped unhighlight (leaving the black corners visible)).
The workaround makes *absolutely* no sense to me (as `self[1] -> self.frame`, AFAICT), but it works, and ensures all highlights/unhighlights are pill-shaped, so at least we're not doing maths for rounded corners for nothing ;).
2019-02-07 23:56:32 +00:00
|
|
|
if Device:hasDPad() then
|
|
|
|
-- little hack to piggyback on the layout of the button_table to handle the new InputText
|
2018-03-30 10:46:36 +00:00
|
|
|
table.insert(self.button_table.layout, #self.button_table.layout, {input_field[k]})
|
|
|
|
end
|
2017-09-14 20:31:25 +00:00
|
|
|
if field.description then
|
|
|
|
input_description[k] = FrameContainer:new{
|
|
|
|
padding = self.description_padding,
|
|
|
|
margin = self.description_margin,
|
|
|
|
bordersize = 0,
|
|
|
|
TextBoxWidget:new{
|
|
|
|
text = field.description,
|
|
|
|
face = Font:getFace("x_smallinfofont"),
|
|
|
|
width = self.width * 0.9,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
table.insert(VerticalGroupData, CenterContainer:new{
|
|
|
|
dimen = Geom:new{
|
|
|
|
w = self.title_bar:getSize().w,
|
|
|
|
h = input_description[k]:getSize().h ,
|
|
|
|
},
|
|
|
|
input_description[k],
|
|
|
|
})
|
|
|
|
end
|
2016-05-02 02:39:31 +00:00
|
|
|
table.insert(VerticalGroupData, CenterContainer:new{
|
2014-08-25 16:00:11 +00:00
|
|
|
dimen = Geom:new{
|
|
|
|
w = self.title_bar:getSize().w,
|
|
|
|
h = input_field[k]:getSize().h,
|
|
|
|
},
|
|
|
|
input_field[k],
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
A few graphics fixes after #4541 (#4554)
* Various FocusManager related tweaks to limit its usage to devices with a DPad, and prevent initial button highlights in Dialogs on devices where it makes no sense (i.e., those without a DPad. And even on DPad devices, I'm not even sure how we'd go about making one of those pop up anyway, because no Touch ;)!).
* One mysterious fix to text-only Buttons so that the flash_ui highlight always works, and always honors `FrameContainer`'s pill shape. (Before that, an unhighlight on a text button with a callback that didn't repaint anything [say, the find first/find last buttons in the Reader's search bar when you're already on the first/last match] would do a square black highlight, and a white pill-shaped unhighlight (leaving the black corners visible)).
The workaround makes *absolutely* no sense to me (as `self[1] -> self.frame`, AFAICT), but it works, and ensures all highlights/unhighlights are pill-shaped, so at least we're not doing maths for rounded corners for nothing ;).
2019-02-07 23:56:32 +00:00
|
|
|
if Device:hasDPad() then
|
|
|
|
-- remove the not needed hack in inputdialog
|
2018-03-30 10:46:36 +00:00
|
|
|
table.remove(self.button_table.layout, 1)
|
|
|
|
end
|
2017-10-08 15:53:25 +00:00
|
|
|
-- Add same vertical space after than before InputText
|
|
|
|
table.insert(VerticalGroupData,CenterContainer:new{
|
|
|
|
dimen = Geom:new{
|
|
|
|
w = self.title_bar:getSize().w,
|
|
|
|
h = self.description_padding + self.description_margin,
|
|
|
|
},
|
|
|
|
VerticalSpan:new{ width = self.description_padding + self.description_margin },
|
|
|
|
})
|
2014-08-25 16:00:11 +00:00
|
|
|
-- buttons
|
|
|
|
table.insert(VerticalGroupData,CenterContainer:new{
|
|
|
|
dimen = Geom:new{
|
|
|
|
w = self.title_bar:getSize().w,
|
|
|
|
h = self.button_table:getSize().h,
|
|
|
|
},
|
|
|
|
self.button_table,
|
|
|
|
})
|
|
|
|
|
|
|
|
self.dialog_frame = FrameContainer:new{
|
2017-09-13 14:56:20 +00:00
|
|
|
radius = Size.radius.window,
|
|
|
|
bordersize = Size.border.window,
|
2014-08-25 16:00:11 +00:00
|
|
|
padding = 0,
|
|
|
|
margin = 0,
|
2014-10-22 13:34:11 +00:00
|
|
|
background = Blitbuffer.COLOR_WHITE,
|
2014-08-25 16:00:11 +00:00
|
|
|
VerticalGroupData,
|
|
|
|
}
|
|
|
|
|
2016-02-21 15:30:06 +00:00
|
|
|
self._input_widget = input_field[1]
|
2014-08-25 16:00:11 +00:00
|
|
|
|
|
|
|
self[1] = CenterContainer:new{
|
|
|
|
dimen = Geom:new{
|
|
|
|
w = Screen:getWidth(),
|
2016-02-21 15:30:06 +00:00
|
|
|
h = Screen:getHeight() - self._input_widget:getKeyboardDimen().h,
|
2014-08-25 16:00:11 +00:00
|
|
|
},
|
|
|
|
self.dialog_frame,
|
|
|
|
}
|
Enable HW dithering in a few key places (#4541)
* Enable HW dithering on supported devices (Clara HD, Forma; Oasis 2, PW4)
* FileManager and co. (where appropriate, i.e., when covers are shown)
* Book Status
* Reader, where appropriate:
* CRe: on pages whith image content (for over 7.5% of the screen area, should hopefully leave stuff like bullet points or small scene breaks alone).
* Other engines: on user-request (in the gear tab of the bottom menu), via the new "Dithering" knob (will only appear on supported devices).
* ScreenSaver
* ImageViewer
* Minimize repaints when flash_ui is enabled (by, almost everywhere, only repainting the flashing element, and not the toplevel window which hosts it).
(The first pass of this involved fixing a few Button instances whose show_parent was wrong, in particular, chevrons in the FM & TopMenu).
* Hunted down a few redundant repaints (unneeded setDirty("all") calls),
either by switching the widget to nil when only a refresh was needed, and not a repaint,
or by passing the appropritate widget to setDirty.
(Note to self: Enable *verbose* debugging to catch broken setDirty calls via its post guard).
There were also a few instances of 'em right behind a widget close.
* Don't repaint the underlying widget when initially showing TopMenu & ConfigDialog.
We unfortunately do need to do it when switching tabs, because of their variable heights.
* On Kobo, disabled the extra and completely useless full refresh before suspend/reboot/poweroff, as well as on resume. No more double refreshes!
* Fix another debug guard in Kobo sysfs_light
* Switch ImageWidget & ImageViewer mostly to "ui" updates, which will be better suited to image content pretty much everywhere, REAGL or not.
PS: (Almost :100: commits! :D)
2019-02-07 00:14:37 +00:00
|
|
|
UIManager:setDirty(self, "ui")
|
2014-08-25 16:00:11 +00:00
|
|
|
end
|
|
|
|
|
2014-09-05 13:05:20 +00:00
|
|
|
function MultiInputDialog:getFields()
|
|
|
|
local fields = {}
|
|
|
|
for i=1, #input_field do
|
|
|
|
table.insert(fields, input_field[i].text)
|
2014-08-25 16:00:11 +00:00
|
|
|
end
|
2014-09-05 13:05:20 +00:00
|
|
|
return fields
|
2014-08-25 16:00:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function MultiInputDialog:onSwitchFocus(inputbox)
|
|
|
|
-- unfocus current inputbox
|
2016-02-21 15:30:06 +00:00
|
|
|
self._input_widget:unfocus()
|
|
|
|
self._input_widget:onCloseKeyboard()
|
2018-07-07 22:45:27 +00:00
|
|
|
UIManager:setDirty(nil, function()
|
|
|
|
return "ui", self.dialog_frame.dimen
|
|
|
|
end)
|
2014-08-25 16:00:11 +00:00
|
|
|
|
|
|
|
-- focus new inputbox
|
2016-02-21 15:30:06 +00:00
|
|
|
self._input_widget = inputbox
|
|
|
|
self._input_widget:focus()
|
|
|
|
self._input_widget:onShowKeyboard()
|
2014-08-25 16:00:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return MultiInputDialog
|
|
|
|
|