Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions BlocksScreen/lib/panels/widgets/FilamentTab/amuWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self, parent=None):
self._text_rect: QtCore.QRect | None = None
self._strip_rect: QtCore.QRect | None = None
self._strip_path: QtGui.QPainterPath | None = None
self._selected_path: QtGui.QPainterPath | None = None

white = QtGui.QColor(255, 255, 255)
self._icons = {
Expand All @@ -51,6 +52,9 @@ def __init__(self, parent=None):
self._grid_border_pen = QtGui.QPen(self._GRID_GRAY)
self._grid_border_pen.setWidth(2)

self._selected_border_pen = QtGui.QPen(white)
self._selected_border_pen.setWidth(2)

self._grid_dark = self._GRID_GRAY.darker(150)
self._grid_brush = QtGui.QBrush(
self._GRID_GRAY.lighter(140), QtCore.Qt.BrushStyle.DiagCrossPattern
Expand Down Expand Up @@ -88,6 +92,11 @@ def _rebuild_geometry(self) -> None:
self._strip_path = QtGui.QPainterPath()
self._strip_path.addRoundedRect(QtCore.QRectF(self._strip_rect), 5, 5)

self._selected_path = QtGui.QPainterPath()
self._selected_path.addRoundedRect(
QtCore.QRectF(self.rect()).adjusted(1, 1, -1, -1), 8, 8
)

def update_entry(self, gate_info: GateInfo, fm: FilamentPos):
# color_rgb is Happy-Hare's parsed form, so w3c names like "red" work too.
has_color = bool(gate_info.color)
Expand Down Expand Up @@ -146,6 +155,11 @@ def paintEvent(self, a0: QtGui.QPaintEvent) -> None:
y = int((self.height() - icon.height()) // 1.1)
painter.drawPixmap(x, y, icon)

if self.isChecked():
painter.setPen(self._selected_border_pen)
painter.setBrush(QtCore.Qt.BrushStyle.NoBrush)
painter.drawPath(self._selected_path)

painter.end()


Expand Down