v0.91.2: the window's emboss rims fade across their width, pixel by pixel, instead of two flat pixels and a fade
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
"""LinTunes — iTunes-style music library manager and player for Linux."""
|
||||
|
||||
__version__ = "0.91.1"
|
||||
__version__ = "0.91.2"
|
||||
|
||||
+31
-13
@@ -175,6 +175,19 @@ def paint_window_background(window: QWidget):
|
||||
painter.end()
|
||||
|
||||
|
||||
def _rim_gradient(bg: QColor, height: int, strength: float) -> QLinearGradient:
|
||||
"""The rims' light-from-above gradient, at `strength` (0–1) of full."""
|
||||
light, dark = bg.lighter(112), bg.darker(112)
|
||||
light.setAlphaF(strength)
|
||||
dark.setAlphaF(strength)
|
||||
rims = QLinearGradient(0, 0, 0, height)
|
||||
rims.setColorAt(0, light)
|
||||
rims.setColorAt(0.06, QColor(255, 255, 255, 0))
|
||||
rims.setColorAt(0.94, QColor(0, 0, 0, 0))
|
||||
rims.setColorAt(1, dark)
|
||||
return rims
|
||||
|
||||
|
||||
class _Frame(QWidget):
|
||||
"""The window's edge, over everything in it: clears what lies outside
|
||||
the rounded corners, then the soft emboss and the outline. Masked to a
|
||||
@@ -212,20 +225,25 @@ class _Frame(QWidget):
|
||||
painter.setCompositionMode(
|
||||
QPainter.CompositionMode.CompositionMode_SourceOver)
|
||||
bg = self.palette().color(QPalette.ColorRole.Window)
|
||||
rims = QLinearGradient(0, 0, 0, self.height())
|
||||
rims.setColorAt(0, bg.lighter(112))
|
||||
rims.setColorAt(0.06, QColor(255, 255, 255, 0))
|
||||
rims.setColorAt(0.94, QColor(0, 0, 0, 0))
|
||||
rims.setColorAt(1, bg.darker(112))
|
||||
inner = QPainterPath()
|
||||
# The rims start just inside the outline and run RIM_WIDTH in.
|
||||
inset = 1 + RIM_WIDTH / 2
|
||||
inner.addRoundedRect(
|
||||
QRectF(self.rect()).adjusted(inset, inset, -inset, -inset),
|
||||
max(0.0, r - inset + 0.5), max(0.0, r - inset + 0.5))
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.setPen(QPen(QBrush(rims), RIM_WIDTH))
|
||||
painter.drawPath(inner)
|
||||
# The rims start just inside the outline and run RIM_WIDTH in, and
|
||||
# fade across that band too: full strength in the pixel against the
|
||||
# outline, each pixel further in fainter, so none of it is flat.
|
||||
# One ring per whole pixel (the last one the leftover fraction):
|
||||
# thinner rings blend at their seams and dim the brightest pixel.
|
||||
offset = 0.0
|
||||
while offset < RIM_WIDTH:
|
||||
width = min(1.0, RIM_WIDTH - offset)
|
||||
strength = 1 - offset / RIM_WIDTH
|
||||
painter.setPen(QPen(QBrush(_rim_gradient(
|
||||
bg, self.height(), strength)), width))
|
||||
inset = 1 + offset + width / 2
|
||||
ring = QPainterPath()
|
||||
ring.addRoundedRect(
|
||||
QRectF(self.rect()).adjusted(inset, inset, -inset, -inset),
|
||||
max(0.0, r - inset + 0.5), max(0.0, r - inset + 0.5))
|
||||
painter.drawPath(ring)
|
||||
offset += width
|
||||
painter.setPen(QPen(bg.darker(128), 1))
|
||||
painter.drawPath(path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user