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