Skip to content

Commit

Permalink
fixed issue with vertical slider
Browse files Browse the repository at this point in the history
  • Loading branch information
YektaY committed May 23, 2024
1 parent aeee048 commit 8e3bf5f
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions pydm/widgets/slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,29 @@ def mousePressEvent(self, event):
handle_pos = self.value() * (self.width() - self.handleWidth()) / (self.maximum() - self.minimum())
click_pos = event.pos().x()
else:
handle_pos = self.value() * (self.height() - self.handleWidth()) / (self.maximum() - self.minimum())
handle_pos = (
(self.maximum() - self.value())
* (self.height() - self.handleWidth())
/ (self.maximum() - self.minimum())
)
click_pos = event.pos().y()

if click_pos > handle_pos:
self.setValue(self.value() + self.singleStep())
if self.orientation() == Qt.Horizontal:
if click_pos > handle_pos + self.handleWidth() / 2:
self.setValue(self.value() + self.singleStep())
else:
self.setValue(self.value() - self.singleStep())
else:
self.setValue(self.value() - self.singleStep())
if click_pos < handle_pos + self.handleWidth() / 2:
self.setValue(self.value() + self.singleStep())
else:
self.setValue(self.value() - self.singleStep())

def handleWidth(self):
if self.orientation() == Qt.Horizontal:
return self.style().pixelMetric(self.style().PM_SliderThickness, None, self)
else:
return self.style().pixelMetric(self.style().PM_SliderLength, None, self)
else:
return self.style().pixelMetric(self.style().PM_SliderThickness, None, self)


class PyDMSlider(QFrame, TextFormatter, PyDMWritableWidget, new_properties=_step_size_properties):
Expand Down

0 comments on commit 8e3bf5f

Please sign in to comment.