Checkbutton: ensure max width, multiline if needed (#8066)

pull/8072/head
hius07 3 years ago committed by GitHub
parent b622d6edd8
commit c8a7f52672
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -168,6 +168,7 @@ function FileSearcher:onShowFileSearch()
text = _("Case sensitive"),
checked = self.case_sensitive,
parent = self.search_dialog,
max_width = self.search_dialog._input_widget.width,
callback = function()
if not self.check_button_case.checked then
self.check_button_case:check()

@ -140,6 +140,7 @@ function ReaderSearch:onShowFulltextSearchInput()
text = _("Case sensitive"),
checked = not self.case_insensitive,
parent = self.input_dialog,
max_width = self.input_dialog._input_widget.width,
callback = function()
if not self.check_button_case.checked then
self.check_button_case:check()
@ -152,6 +153,7 @@ function ReaderSearch:onShowFulltextSearchInput()
text = _("Regular expression (hold for help)"),
checked = self.use_regex,
parent = self.input_dialog,
max_width = self.input_dialog._input_widget.width,
callback = function()
if not self.check_button_regex.checked then
self.check_button_regex:check()

@ -22,8 +22,10 @@ local FrameContainer = require("ui/widget/container/framecontainer")
local GestureRange = require("ui/gesturerange")
local HorizontalGroup = require("ui/widget/horizontalgroup")
local InputContainer = require("ui/widget/container/inputcontainer")
local TextWidget = require("ui/widget/textwidget")
local TextBoxWidget = require("ui/widget/textboxwidget")
local UIManager = require("ui/uimanager")
local VerticalGroup = require("ui/widget/verticalgroup")
local VerticalSpan = require("ui/widget/verticalspan")
local Screen = Device.screen
local CheckButton = InputContainer:new{
@ -36,7 +38,7 @@ local CheckButton = InputContainer:new{
overlap_align = "right",
text = nil,
toggle_text = nil,
max_width = nil,
max_width = nil, -- must be set by the caller
window = nil,
padding = Screen:scaleBySize(5),
@ -56,15 +58,23 @@ function CheckButton:initCheckButton(checked)
parent = self.parent or self,
show_parent = self.show_parent or self,
}
self._textwidget = TextWidget:new{
self._textwidget = TextBoxWidget:new{
text = self.text,
face = self.face,
max_width = self.max_width,
width = self.max_width - self._checkmark.dimen.w,
fgcolor = self.enabled and Blitbuffer.COLOR_BLACK or Blitbuffer.COLOR_DARK_GRAY,
}
self._verticalgroup = VerticalGroup:new{
align = "left",
VerticalSpan:new{
width = self.face.size * 0.18,
},
self._textwidget,
}
self._horizontalgroup = HorizontalGroup:new{
align = "top",
self._checkmark,
self._textwidget,
self._verticalgroup,
}
self._frame = FrameContainer:new{
bordersize = 0,

@ -399,6 +399,7 @@ function FrontLightWidget:addWarmthWidgets(num_warmth, step, vertical_group)
local checkbutton_auto_nl = CheckButton:new({
text = _("Auto"),
checked = self.powerd.auto_warmth,
max_width = math.floor(self.screen_width * 0.3),
callback = function()
if self.powerd.auto_warmth then
self.powerd.auto_warmth = false

@ -476,7 +476,9 @@ function InputDialog:onTap()
if self.deny_keyboard_hiding then
return
end
self._input_widget:onCloseKeyboard()
if self._input_widget.onCloseKeyboard then
self._input_widget:onCloseKeyboard()
end
end
function InputDialog:getInputText()
@ -816,6 +818,7 @@ function InputDialog:_addScrollButtons(nav_bar)
text = _("Case sensitive"),
checked = self.case_sensitive,
parent = input_dialog,
max_width = input_dialog._input_widget.width,
callback = function()
if not self.check_button_case.checked then
self.check_button_case:check()

@ -376,6 +376,7 @@ function InputText:initTextBox(text, char_added)
if self.is_password_type and self.show_password_toggle then
self._check_button = self._check_button or CheckButton:new{
text = _("Show password"),
max_width = self.width,
callback = function()
if self.text_type == "text" then
self.text_type = "password"

Loading…
Cancel
Save