diff --git a/kivymd/uix/slider/slider.kv b/kivymd/uix/slider/slider.kv index a85ba8ded..b804ed955 100644 --- a/kivymd/uix/slider/slider.kv +++ b/kivymd/uix/slider/slider.kv @@ -87,11 +87,6 @@ points: self._active_points pointsize: self.step_point_size - size_hint_y: None - height: - handle_container.children[0].height \ - if handle_container.children else 0 - # Label container. BoxLayout: id: value_container @@ -185,13 +180,21 @@ pos: ( \ ( \ - self._slider.value_pos[0] - (self._slider._value_label.texture_size[0] / 2) + dp(10), \ + # X. + self._slider.value_pos[0] \ + - (self._slider._value_label.texture_size[0] / 2) + dp(10), \ + # Y. self._slider.center_y + dp(28) \ ) \ if self._slider.orientation == "horizontal" else \ ( \ - self._slider.center_x - self.width / 2, \ - self._slider.value_pos[1] - dp(0) \ + # X. + self._slider.center_x \ + - (self._slider._value_label.texture_size[0] / 2) - dp(2), \ + # Y. + self._slider.value_pos[1] + \ + self._slider._value_label.texture_size[1] \ + + self._slider._handle.state_layer_size[1] / 2, \ ) \ ) \ if self._slider and self._slider._value_label else (0, 0) @@ -200,7 +203,6 @@ if self._slider and self._slider._value_label else (0, 0) size_hint: None, None - # opacity: 0 size: self._slider._value_label.size \ if self._slider and self._slider._value_label else \ diff --git a/kivymd/uix/slider/slider.py b/kivymd/uix/slider/slider.py index 2552a731b..17629be60 100644 --- a/kivymd/uix/slider/slider.py +++ b/kivymd/uix/slider/slider.py @@ -272,12 +272,23 @@ def update_points(self, instance, step) -> None: """Draws the step points on the slider.""" def update_points(*args): - y = self.center_y - self.track_active_width / 2 - slider_length = self.width - (self.padding * 2) + y = ( + self.center_y + if self.orientation == "horizontal" + else self.center_x + ) - self.track_active_width / 2 + slider_length = ( + self.width if self.orientation == "horizontal" else self.height + ) - (self.padding * 2) slider_max_value = int(self.max) multiplier = slider_length / slider_max_value active_track_width = ( - self.width - self.padding * 2 + ( + self.width + if self.orientation == "horizontal" + else self.height + ) + - self.padding * 2 ) * self.value_normalized for i in range(0, slider_max_value + 1, step): @@ -288,8 +299,11 @@ def update_points(*args): else: points = self._active_points + if self.orientation == "vertical": + points.append(y) + points.append( - self.x + (self.x if self.orientation == "horizontal" else self.y) + x + self.padding + ( @@ -298,7 +312,8 @@ def update_points(*args): else 0 ) ) - points.append(y) + if self.orientation == "horizontal": + points.append(y) Clock.schedule_once(update_points) @@ -392,7 +407,6 @@ def on_handle_leave(self) -> None: Animation( scale_value_x=0, scale_value_y=0, - # opacity=1, d=self.value_container_hide_anim_duration, t=self.value_container_hide_anim_transition, ).start(self._value_container)