Browse Source

Port's border-to-pixel alignment

tags/v1.9.9
Nikita Zlobin Filipe Coelho <falktx@falktx.com> 7 years ago
parent
commit
5d341b36ff
1 changed files with 28 additions and 24 deletions
  1. +28
    -24
      source/patchcanvas.py

+ 28
- 24
source/patchcanvas.py View File

@@ -2089,6 +2089,9 @@ class CanvasPort(QGraphicsItem):
def paint(self, painter, option, widget):
painter.save()
painter.setRenderHint(QPainter.Antialiasing, bool(options.antialiasing == ANTIALIASING_FULL))
lineHinting = canvas.theme.port_audio_jack_pen.widthF() / 2
# FIXME: would be more correct is to take line width from Pen, loaded to painter,
# but this needs some code rearrangement

poly_locx = [0, 0, 0, 0, 0]

@@ -2096,17 +2099,17 @@ class CanvasPort(QGraphicsItem):
text_pos = QPointF(3, canvas.theme.port_text_ypos)

if canvas.theme.port_mode == Theme.THEME_PORT_POLYGON:
poly_locx[0] = 0
poly_locx[1] = self.m_port_width + 5
poly_locx[2] = self.m_port_width + 12
poly_locx[3] = self.m_port_width + 5
poly_locx[4] = 0
poly_locx[0] = lineHinting
poly_locx[1] = self.m_port_width + 5 - lineHinting
poly_locx[2] = self.m_port_width + 12 - lineHinting
poly_locx[3] = self.m_port_width + 5 - lineHinting
poly_locx[4] = lineHinting
elif canvas.theme.port_mode == Theme.THEME_PORT_SQUARE:
poly_locx[0] = 0
poly_locx[1] = self.m_port_width + 5
poly_locx[2] = self.m_port_width + 5
poly_locx[3] = self.m_port_width + 5
poly_locx[4] = 0
poly_locx[0] = lineHinting
poly_locx[1] = self.m_port_width + 5 - lineHinting
poly_locx[2] = self.m_port_width + 5 - lineHinting
poly_locx[3] = self.m_port_width + 5 - lineHinting
poly_locx[4] = lineHinting
else:
qCritical("PatchCanvas::CanvasPort.paint() - invalid theme port mode '%s'" % canvas.theme.port_mode)
return
@@ -2115,17 +2118,17 @@ class CanvasPort(QGraphicsItem):
text_pos = QPointF(9, canvas.theme.port_text_ypos)

if canvas.theme.port_mode == Theme.THEME_PORT_POLYGON:
poly_locx[0] = self.m_port_width + 12
poly_locx[1] = 7
poly_locx[2] = 0
poly_locx[3] = 7
poly_locx[4] = self.m_port_width + 12
poly_locx[0] = self.m_port_width + 12 - lineHinting
poly_locx[1] = 7 + lineHinting
poly_locx[2] = 0 + lineHinting
poly_locx[3] = 7 + lineHinting
poly_locx[4] = self.m_port_width + 12 - lineHinting
elif canvas.theme.port_mode == Theme.THEME_PORT_SQUARE:
poly_locx[0] = self.m_port_width + 12
poly_locx[1] = 5
poly_locx[2] = 5
poly_locx[3] = 5
poly_locx[4] = self.m_port_width + 12
poly_locx[0] = self.m_port_width + 12 - lineHinting
poly_locx[1] = 5 + lineHinting
poly_locx[2] = 5 + lineHinting
poly_locx[3] = 5 + lineHinting
poly_locx[4] = self.m_port_width + 12 - lineHinting
else:
qCritical("PatchCanvas::CanvasPort.paint() - invalid theme port mode '%s'" % canvas.theme.port_mode)
return
@@ -2165,11 +2168,12 @@ class CanvasPort(QGraphicsItem):
#conn_pen.setColor(conn_pen.color()) #.darker(150))

polygon = QPolygonF()
polygon += QPointF(poly_locx[0], 0)
polygon += QPointF(poly_locx[1], 0)
polygon += QPointF(poly_locx[0], lineHinting)
polygon += QPointF(poly_locx[1], lineHinting)
polygon += QPointF(poly_locx[2], float(canvas.theme.port_height)/2)
polygon += QPointF(poly_locx[3], canvas.theme.port_height)
polygon += QPointF(poly_locx[4], canvas.theme.port_height)
polygon += QPointF(poly_locx[3], canvas.theme.port_height - lineHinting)
polygon += QPointF(poly_locx[4], canvas.theme.port_height - lineHinting)
polygon += QPointF(poly_locx[0], lineHinting)

if canvas.theme.port_bg_pixmap:
portRect = polygon.boundingRect()


Loading…
Cancel
Save