Skip to content

Commit

Permalink
change colour of progress bar from black to transparent grey
Browse files Browse the repository at this point in the history
  • Loading branch information
t0mpr1c3 committed Oct 18, 2023
1 parent 6072855 commit bd406ac
Showing 1 changed file with 31 additions and 18 deletions.
49 changes: 31 additions & 18 deletions src/main/python/ayab/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import logging

from PyQt5.QtCore import QRect
from PyQt5.QtGui import QImage, QPixmap, QBrush, QColor
from PyQt5.QtGui import QImage, QPixmap, QPen, QBrush, QColor
from PyQt5.QtWidgets import QGraphicsScene, QGraphicsRectItem, QGraphicsView

from .image import AyabImage
Expand All @@ -37,7 +37,6 @@ class Scene(QGraphicsView):
"""

BAR_HEIGHT = 5.0
LIMIT_BAR_WIDTH = 0.5

def __init__(self, parent):
super().__init__(parent.ui.graphics_splitter)
Expand Down Expand Up @@ -80,12 +79,16 @@ def refresh(self):

# draw "machine"
rect_orange = QGraphicsRectItem(
-machine_width / 2 - self.LIMIT_BAR_WIDTH, -self.BAR_HEIGHT,
machine_width / 2 + self.LIMIT_BAR_WIDTH, self.BAR_HEIGHT)
-machine_width / 2 - 0.5,
-self.BAR_HEIGHT - 0.5,
machine_width / 2 + 0.5,
self.BAR_HEIGHT)
rect_orange.setBrush(QBrush(QColor("orange")))
rect_green = QGraphicsRectItem(
0, -self.BAR_HEIGHT,
machine_width / 2 + self.LIMIT_BAR_WIDTH, self.BAR_HEIGHT)
0,
-self.BAR_HEIGHT - 0.5,
machine_width / 2 + 0.5,
self.BAR_HEIGHT)
rect_green.setBrush(QBrush(QColor("green")))

qscene.addItem(rect_orange)
Expand All @@ -94,22 +97,32 @@ def refresh(self):
# draw limiting lines (start/stop needle)
qscene.addItem(
QGraphicsRectItem(
self.__start_needle - machine_width / 2 - self.LIMIT_BAR_WIDTH,
-self.BAR_HEIGHT, self.LIMIT_BAR_WIDTH,
pixmap.height() + self.BAR_HEIGHT))
self.__start_needle - machine_width / 2 - 0.5,
-self.BAR_HEIGHT - 0.5,
0,
pixmap.height() + self.BAR_HEIGHT + 0.5))
qscene.addItem(
QGraphicsRectItem(
self.__stop_needle + 1 - machine_width / 2,
-self.BAR_HEIGHT, self.LIMIT_BAR_WIDTH,
pixmap.height() + self.BAR_HEIGHT))

# Draw knitting progress
self.__stop_needle - machine_width / 2 + 1.5,
-self.BAR_HEIGHT - 0.5,
0,
pixmap.height() + self.BAR_HEIGHT + 0.5))
qscene.addItem(
QGraphicsRectItem(
-machine_width / 2 - self.LIMIT_BAR_WIDTH,
pixmap.height() - self.__row_progress + self.LIMIT_BAR_WIDTH,
machine_width + 2 * self.LIMIT_BAR_WIDTH,
self.LIMIT_BAR_WIDTH))
self.__start_needle - machine_width / 2 - 1,
pixmap.height() + 0.5,
self.__stop_needle - self.__start_needle + 3,
0))

# Draw knitting progress
grey = QGraphicsRectItem(
self.__start_needle - machine_width / 2,
pixmap.height(),
self.__stop_needle - self.__start_needle + 1,
-self.__row_progress)
grey.setPen(QPen(QColor(127, 127, 127, 127), 0))
grey.setBrush(QBrush(QColor(127, 127, 127, 127)))
qscene.addItem(grey)

self.resetTransform()
self.scale(self.zoom, self.zoom)
Expand Down

0 comments on commit bd406ac

Please sign in to comment.