From b0b172aeaa937acdff05e720eb78f1dafd10181b Mon Sep 17 00:00:00 2001 From: Qua-non Date: Wed, 19 Sep 2012 15:10:19 +0530 Subject: [PATCH] TextInput: introduce background_normal and background_active properties used to reffer to the background images depending on state --- kivy/data/style.kv | 4 ++-- kivy/uix/textinput.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/kivy/data/style.kv b/kivy/data/style.kv index 86af49c1f..2d4d773b4 100644 --- a/kivy/data/style.kv +++ b/kivy/data/style.kv @@ -119,10 +119,10 @@ Color: rgba: self.background_color BorderImage: - border: (16, 16, 16, 16) + border: self.border pos: self.pos size: self.size - source: 'atlas://data/images/defaulttheme/textinput%s' % ('_active' if self.focus else '') + source: self.background_active if self.focus else self.background_normal Color: rgba: (1, 0, 0, 1 if self.focus and not self.cursor_blink else 0) Rectangle: diff --git a/kivy/uix/textinput.py b/kivy/uix/textinput.py index 3839076c3..49cb41794 100644 --- a/kivy/uix/textinput.py +++ b/kivy/uix/textinput.py @@ -1472,6 +1472,38 @@ class TextInput(Widget): to [0.1843, 0.6549, 0.8313, .5] ''' + border = ListProperty([16, 16, 16, 16]) + '''Border used for :class:`~kivy.graphics.vertex_instructions.BorderImage` + graphics instruction. Used with :data:`background_normal` and + :data:`background_active`. Can be used for a custom background. + + It must be a list of four values: (top, right, bottom, left). Read the + BorderImage instruction for more information about how to use it. + + :data:`border` is a :class:`~kivy.properties.ListProperty`, default to (16, + 16, 16, 16) + ''' + + background_normal = StringProperty( + 'atlas://data/images/defaulttheme/textinput') + '''Background image of the TextInput when it's not in focus'. + + .. versionadded:: 1.4.1 + + :data:`background_normal` is a :class:`~kivy.properties.StringProperty`, + default to 'atlas://data/images/defaulttheme/textinput' + ''' + + background_active = StringProperty( + 'atlas://data/images/defaulttheme/textinput_active') + '''Background image of the TextInput when it's in focus'. + + .. versionadded:: 1.4.1 + + :data:`background_active` is a :class:`~kivy.properties.StringProperty`, + default to 'atlas://data/images/defaulttheme/textinput_active' + ''' + background_color = ListProperty([1, 1, 1, 1]) '''Current color of the background, in (r, g, b, a) format.