mirror of https://github.com/kivy/kivy.git
Update kivy/uix/slider.py
mis-positioning when slider sets value_pos. value_pos is fixed by padding size.
This commit is contained in:
parent
9203179fed
commit
a0851a8336
|
@ -154,18 +154,19 @@ class Slider(Widget):
|
|||
return (x, y + padding + nval * (self.height - 2 * padding))
|
||||
|
||||
def set_value_pos(self, pos):
|
||||
x = min(self.right, max(pos[0], self.x))
|
||||
y = min(self.top, max(pos[1], self.y))
|
||||
padding = self.padding
|
||||
x = min(self.right - padding, max(pos[0], self.x + padding))
|
||||
y = min(self.top - padding, max(pos[1], self.y + padding))
|
||||
if self.orientation == 'horizontal':
|
||||
if self.width == 0:
|
||||
self.value_normalized = 0
|
||||
else:
|
||||
self.value_normalized = (x - self.x) / float(self.width)
|
||||
self.value_normalized = (x - self.x - padding) / float(self.width - 2 * padding)
|
||||
else:
|
||||
if self.height == 0:
|
||||
self.value_normalized = 0
|
||||
else:
|
||||
self.value_normalized = (y - self.y) / float(self.height)
|
||||
self.value_normalized = (y - self.y - padding) / float(self.height - 2 * padding)
|
||||
value_pos = AliasProperty(get_value_pos, set_value_pos,
|
||||
bind=('x', 'y', 'width', 'height', 'min',
|
||||
'max', 'value_normalized', 'orientation'))
|
||||
|
|
Loading…
Reference in New Issue