Merge pull request #868 from luuvish/master

value_pos of slider fix by padding
This commit is contained in:
Mathieu Virbel 2012-12-18 08:04:02 -08:00
commit 17ef016806
1 changed files with 5 additions and 4 deletions

View File

@ -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'))