mirror of https://github.com/kivy/kivy.git
uix:TextInput add `minimum_height`, `line_spacing`,
make sure changes in password change the Text display.
This commit is contained in:
parent
1c5aa58939
commit
8a4317cd41
|
@ -64,7 +64,7 @@
|
||||||
auto_indent: True
|
auto_indent: True
|
||||||
lexer: KivyLexer()
|
lexer: KivyLexer()
|
||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
height: max(kr_scroll.height, (len(self._lines)+1) * (self.line_height + self._line_spacing))
|
height: max(kr_scroll.height, self.minimum_height)
|
||||||
font_name: "data/fonts/DroidSansMono.ttf"
|
font_name: "data/fonts/DroidSansMono.ttf"
|
||||||
valign: "top"
|
valign: "top"
|
||||||
text: "This box will display the kivy language for whatever has been selected"
|
text: "This box will display the kivy language for whatever has been selected"
|
||||||
|
|
|
@ -4,6 +4,7 @@ ShowcaseScreen:
|
||||||
TextInput
|
TextInput
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
height: '32dp'
|
height: '32dp'
|
||||||
|
multiline: False
|
||||||
text: 'Monoline textinput'
|
text: 'Monoline textinput'
|
||||||
|
|
||||||
TextInput
|
TextInput
|
||||||
|
|
|
@ -65,4 +65,4 @@ BoxLayout:
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
font_name: 'data/fonts/DroidSansMono.ttf'
|
font_name: 'data/fonts/DroidSansMono.ttf'
|
||||||
font_size: '12sp'
|
font_size: '12sp'
|
||||||
height: [len(sourcecode.text.splitlines()) * (sp(2) + self.line_height), sourcecode.text][0] + sp(40)
|
height: self.minimum_height
|
||||||
|
|
|
@ -284,7 +284,6 @@ class TextInput(Widget):
|
||||||
self._hint_text_flags = []
|
self._hint_text_flags = []
|
||||||
self._hint_text_labels = []
|
self._hint_text_labels = []
|
||||||
self._hint_text_rects = []
|
self._hint_text_rects = []
|
||||||
self._line_spacing = 0
|
|
||||||
self._label_cached = None
|
self._label_cached = None
|
||||||
self._line_options = None
|
self._line_options = None
|
||||||
self._keyboard = None
|
self._keyboard = None
|
||||||
|
@ -316,7 +315,8 @@ class TextInput(Widget):
|
||||||
tab_width=self._update_text_options,
|
tab_width=self._update_text_options,
|
||||||
font_size=self._update_text_options,
|
font_size=self._update_text_options,
|
||||||
font_name=self._update_text_options,
|
font_name=self._update_text_options,
|
||||||
size=self._update_text_options)
|
size=self._update_text_options,
|
||||||
|
password=self._update_text_options)
|
||||||
|
|
||||||
self.bind(pos=self._trigger_update_graphics)
|
self.bind(pos=self._trigger_update_graphics)
|
||||||
|
|
||||||
|
@ -685,7 +685,7 @@ class TextInput(Widget):
|
||||||
'''
|
'''
|
||||||
padding_top = self.padding[1]
|
padding_top = self.padding[1]
|
||||||
l = self._lines
|
l = self._lines
|
||||||
dy = self.line_height + self._line_spacing
|
dy = self.line_height + self.line_spacing
|
||||||
cx = x - self.x
|
cx = x - self.x
|
||||||
scrl_y = self.scroll_y
|
scrl_y = self.scroll_y
|
||||||
scrl_y = scrl_y / dy if scrl_y > 0 else 0
|
scrl_y = scrl_y / dy if scrl_y > 0 else 0
|
||||||
|
@ -936,7 +936,7 @@ class TextInput(Widget):
|
||||||
win_size = win.size
|
win_size = win.size
|
||||||
bubble.pos = (t_pos[0] - bubble_size[0] / 2., t_pos[1] + inch(.25))
|
bubble.pos = (t_pos[0] - bubble_size[0] / 2., t_pos[1] + inch(.25))
|
||||||
bubble_pos = bubble.pos
|
bubble_pos = bubble.pos
|
||||||
lh, ls = self.line_height, self._line_spacing
|
lh, ls = self.line_height, self.line_spacing
|
||||||
|
|
||||||
# FIXME found a way to have that feature available for everybody
|
# FIXME found a way to have that feature available for everybody
|
||||||
if bubble_pos[0] < 0:
|
if bubble_pos[0] < 0:
|
||||||
|
@ -1202,7 +1202,7 @@ class TextInput(Widget):
|
||||||
else:
|
else:
|
||||||
# with markup texture can be of height `1`
|
# with markup texture can be of height `1`
|
||||||
self.line_height = max(line_label.height, min_line_ht)
|
self.line_height = max(line_label.height, min_line_ht)
|
||||||
self._line_spacing = 2
|
#self.line_spacing = 2
|
||||||
# now, if the text change, maybe the cursor is not at the same place as
|
# now, if the text change, maybe the cursor is not at the same place as
|
||||||
# before. so, try to set the cursor on the good place
|
# before. so, try to set the cursor on the good place
|
||||||
row = self.cursor_row
|
row = self.cursor_row
|
||||||
|
@ -1269,7 +1269,7 @@ class TextInput(Widget):
|
||||||
add = self.canvas.add
|
add = self.canvas.add
|
||||||
|
|
||||||
lh = self.line_height
|
lh = self.line_height
|
||||||
dy = lh + self._line_spacing
|
dy = lh + self.line_spacing
|
||||||
|
|
||||||
# adjust view if the cursor is going outside the bounds
|
# adjust view if the cursor is going outside the bounds
|
||||||
sx = self.scroll_x
|
sx = self.scroll_x
|
||||||
|
@ -1359,7 +1359,7 @@ class TextInput(Widget):
|
||||||
if not self._selection:
|
if not self._selection:
|
||||||
return
|
return
|
||||||
self.canvas.remove_group('selection')
|
self.canvas.remove_group('selection')
|
||||||
dy = self.line_height + self._line_spacing
|
dy = self.line_height + self.line_spacing
|
||||||
rects = self._lines_rects
|
rects = self._lines_rects
|
||||||
padding_top = self.padding[1]
|
padding_top = self.padding[1]
|
||||||
padding_bottom = self.padding[3]
|
padding_bottom = self.padding[3]
|
||||||
|
@ -1432,7 +1432,7 @@ class TextInput(Widget):
|
||||||
|
|
||||||
def _get_cursor_pos(self):
|
def _get_cursor_pos(self):
|
||||||
# return the current cursor x/y from the row/col
|
# return the current cursor x/y from the row/col
|
||||||
dy = self.line_height + self._line_spacing
|
dy = self.line_height + self.line_spacing
|
||||||
padding_left = self.padding[0]
|
padding_left = self.padding[0]
|
||||||
padding_top = self.padding[1]
|
padding_top = self.padding[1]
|
||||||
x = self.x + padding_left
|
x = self.x + padding_left
|
||||||
|
@ -1752,7 +1752,7 @@ class TextInput(Widget):
|
||||||
|
|
||||||
# do the same for Y
|
# do the same for Y
|
||||||
# this algo try to center the cursor as much as possible
|
# this algo try to center the cursor as much as possible
|
||||||
dy = self.line_height + self._line_spacing
|
dy = self.line_height + self.line_spacing
|
||||||
offsety = cr * dy
|
offsety = cr * dy
|
||||||
sy = self.scroll_y
|
sy = self.scroll_y
|
||||||
padding_top = self.padding[1]
|
padding_top = self.padding[1]
|
||||||
|
@ -2129,6 +2129,30 @@ class TextInput(Widget):
|
||||||
.. versionadded:: 1.7.0
|
.. versionadded:: 1.7.0
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
def _get_min_height(self):
|
||||||
|
return (len(self._lines) * (self.line_height + self.line_spacing)
|
||||||
|
+ self.padding[0] + self.padding[2])
|
||||||
|
|
||||||
|
minimum_height = AliasProperty(_get_min_height, None,
|
||||||
|
bind=('_lines', 'line_spacing', 'padding',
|
||||||
|
'font_size', 'font_name', 'password',
|
||||||
|
'hint_text'))
|
||||||
|
'''minimum height of the content inside the TextInput.
|
||||||
|
|
||||||
|
.. versionadded:: 1.8.0
|
||||||
|
|
||||||
|
:data:`minimum_height` is a readonly :class:`~kivy.properties.AliasProperty`
|
||||||
|
'''
|
||||||
|
|
||||||
|
line_spacing = NumericProperty(0)
|
||||||
|
'''Space taken up between the lines.
|
||||||
|
|
||||||
|
.. versionadded:: 1.8.0
|
||||||
|
|
||||||
|
:data:`line_spacing` is a :class:`~kivy.properties.NumericProperty`,
|
||||||
|
default to '0'
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
|
|
Loading…
Reference in New Issue