switch direction of the range start/end icons
With the old direction they were overlapping each other, which made it impossible to move the end slider.
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 16 16">
|
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 16 16">
|
||||||
|
|
||||||
<path style="fill: #dddddd; stroke: black; stroke-linejoin:round;"
|
<path style="fill: #dddddd; stroke: black; stroke-linejoin:round;"
|
||||||
d="M8,13
|
d="M8,3
|
||||||
L1,3
|
L1,13
|
||||||
L15,3
|
L15,13
|
||||||
z
|
z
|
||||||
"/>
|
"/>
|
||||||
<line x1="0.5" y1="13.5" x2="15.5" y2="13.5" style="stroke:black;"/>
|
<line x1="0.5" y1="2.5" x2="15.5" y2="2.5" style="stroke:black;"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 287 B After Width: | Height: | Size: 286 B |
@@ -1,10 +1,10 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 16 16">
|
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 16 16">
|
||||||
|
|
||||||
<path style="fill: #dddddd; stroke: black; stroke-linejoin:round;"
|
<path style="fill: #dddddd; stroke: black; stroke-linejoin:round;"
|
||||||
d="M8,3
|
d="M8,13
|
||||||
L1,13
|
L1,3
|
||||||
L15,13
|
L15,3
|
||||||
z
|
z
|
||||||
"/>
|
"/>
|
||||||
<line x1="0.5" y1="2.5" x2="15.5" y2="2.5" style="stroke:black;"/>
|
<line x1="0.5" y1="13.5" x2="15.5" y2="13.5" style="stroke:black;"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 286 B After Width: | Height: | Size: 287 B |
@@ -12,6 +12,7 @@ from src.util import conversion
|
|||||||
from src.util.color import to_qcolor
|
from src.util.color import to_qcolor
|
||||||
from src.i18n import _
|
from src.i18n import _
|
||||||
|
|
||||||
|
|
||||||
class RangeSliderHandle():
|
class RangeSliderHandle():
|
||||||
def __init__(self, value: int):
|
def __init__(self, value: int):
|
||||||
self.value = value
|
self.value = value
|
||||||
@@ -74,26 +75,29 @@ class RangeSlider(QWidget):
|
|||||||
painter = QPainter(self)
|
painter = QPainter(self)
|
||||||
self._draw_background(painter)
|
self._draw_background(painter)
|
||||||
self._draw_hits(painter)
|
self._draw_hits(painter)
|
||||||
self._draw_handle(painter, self.lower_value)
|
self._draw_handle(painter, self.lower_value, direction=-1)
|
||||||
self._draw_handle(painter, self.upper_value, direction=-1)
|
self._draw_handle(painter, self.upper_value)
|
||||||
painter.end()
|
painter.end()
|
||||||
|
|
||||||
def _draw_background(self, painter: QPainter) -> None:
|
def _draw_background(self, painter: QPainter) -> None:
|
||||||
painter.setBrush(to_qcolor("50ade8"))
|
painter.setBrush(to_qcolor("50ade8"))
|
||||||
painter.setPen(to_qcolor("dddddd"))
|
painter.setPen(to_qcolor("dddddd"))
|
||||||
|
|
||||||
|
# the 1px wide grey center line
|
||||||
rect = QRect(round(10), self._handle_width, round(1),
|
rect = QRect(round(10), self._handle_width, round(1),
|
||||||
self.height() - 2 * self._handle_width)
|
self.height() - 2 * self._handle_width)
|
||||||
painter.drawRoundedRect(rect, 3.0, 3.0)
|
painter.drawRoundedRect(rect, 3.0, 3.0)
|
||||||
|
|
||||||
|
# the blue line
|
||||||
rect = QRect(round(7),
|
rect = QRect(round(7),
|
||||||
self._value_to_pixel(self.lower_value.value) + self._handle_width,
|
self._value_to_pixel(self.lower_value.value),
|
||||||
round(6),
|
round(6),
|
||||||
self._value_to_pixel(self.upper_value.value - self.lower_value.value) - 2 * self._handle_width)
|
self._value_to_pixel(self.upper_value.value - self.lower_value.value) - 1 * self._handle_width)
|
||||||
painter.drawRoundedRect(rect, 3.0, 3.0)
|
painter.drawRoundedRect(rect, 3.0, 3.0)
|
||||||
|
|
||||||
def _draw_handle(self, painter: QPainter, handle: RangeSliderHandle, direction=1) -> None:
|
def _draw_handle(self, painter: QPainter, handle: RangeSliderHandle, direction=1) -> None:
|
||||||
y_pixel = self._value_to_pixel(handle.value)
|
y_pixel = self._value_to_pixel(handle.value)
|
||||||
|
h = self._handle_width - 1 # height of the handle
|
||||||
|
|
||||||
painter.setBrush(to_qcolor("dddddd"))
|
painter.setBrush(to_qcolor("dddddd"))
|
||||||
painter.setPen(to_qcolor("444444"))
|
painter.setPen(to_qcolor("444444"))
|
||||||
@@ -101,15 +105,7 @@ class RangeSlider(QWidget):
|
|||||||
painter.drawLine(2, y_pixel, 18, y_pixel)
|
painter.drawLine(2, y_pixel, 18, y_pixel)
|
||||||
painter.setRenderHint(PySide6.QtGui.QPainter.RenderHint.Antialiasing, True)
|
painter.setRenderHint(PySide6.QtGui.QPainter.RenderHint.Antialiasing, True)
|
||||||
painter.drawPolygon(
|
painter.drawPolygon(
|
||||||
(QPoint(10, y_pixel), QPoint(18, y_pixel + 12 * direction), QPoint(2, y_pixel + 12 * direction)))
|
(QPoint(10, y_pixel), QPoint(18, y_pixel + h * direction), QPoint(2, y_pixel + h * direction)))
|
||||||
|
|
||||||
def _draw_handle_circle(self, painter: QPainter, handle: RangeSliderHandle) -> None:
|
|
||||||
y_pixel = self._value_to_pixel(handle.value)
|
|
||||||
|
|
||||||
painter.setBrush(to_qcolor("dddddd"))
|
|
||||||
painter.setPen(to_qcolor("444444"))
|
|
||||||
painter.setRenderHint(PySide6.QtGui.QPainter.RenderHint.Antialiasing, True)
|
|
||||||
painter.drawEllipse(QPoint(self._width / 2, y_pixel), self._handle_width / 2 - 1, self._handle_width / 2 - 1)
|
|
||||||
|
|
||||||
def _value_to_pixel(self, value: int) -> int:
|
def _value_to_pixel(self, value: int) -> int:
|
||||||
value_percent = value / self.max_value
|
value_percent = value / self.max_value
|
||||||
@@ -149,11 +145,11 @@ class RangeSlider(QWidget):
|
|||||||
def mousePressEvent(self, e: QtGui.QMouseEvent) -> None:
|
def mousePressEvent(self, e: QtGui.QMouseEvent) -> None:
|
||||||
if e.buttons() == Qt.MouseButton.LeftButton and e.modifiers() == Qt.KeyboardModifier.NoModifier:
|
if e.buttons() == Qt.MouseButton.LeftButton and e.modifiers() == Qt.KeyboardModifier.NoModifier:
|
||||||
pos: QPoint = e.pos()
|
pos: QPoint = e.pos()
|
||||||
if self._is_on_handle(self.lower_value, pos.y(), direction=1):
|
if self._is_on_handle(self.lower_value, pos.y(), direction=-1):
|
||||||
self.selected_handle = self.lower_value
|
self.selected_handle = self.lower_value
|
||||||
self.selection_drag_range = (self.min_value, self.upper_value.value)
|
self.selection_drag_range = (self.min_value, self.upper_value.value)
|
||||||
self.drag_y_offset_in_handle = self.selected_handle.value - self._pixel_to_value(pos.y())
|
self.drag_y_offset_in_handle = self.selected_handle.value - self._pixel_to_value(pos.y())
|
||||||
if self._is_on_handle(self.upper_value, pos.y(), direction=-1):
|
if self._is_on_handle(self.upper_value, pos.y(), direction=1):
|
||||||
self.selected_handle = self.upper_value
|
self.selected_handle = self.upper_value
|
||||||
self.selection_drag_range = (self.lower_value.value, self.max_value)
|
self.selection_drag_range = (self.lower_value.value, self.max_value)
|
||||||
self.drag_y_offset_in_handle = self.selected_handle.value - self._pixel_to_value(pos.y())
|
self.drag_y_offset_in_handle = self.selected_handle.value - self._pixel_to_value(pos.y())
|
||||||
|
|||||||
Reference in New Issue
Block a user