mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Checkbutton: ensure max width, multiline if needed (#8066)
This commit is contained in:
@@ -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,16 +58,24 @@ 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._horizontalgroup = HorizontalGroup:new{
|
||||
self._checkmark,
|
||||
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._verticalgroup,
|
||||
}
|
||||
self._frame = FrameContainer:new{
|
||||
bordersize = 0,
|
||||
background = self.background,
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user