Preferences → Appearance → Visualizer picks Bars (as before), Radial dots (the EQ in a circle: angle is frequency, radius is volume, moving dots leave light-gray ghosts that fade over a set time), or Laser (a mirror on a speaker membrane bouncing a beam onto a screen: simulated membrane modes, D·tan(2θ) reflection, dwell-weighted brightness). Double-clicking the panel opens it big; a click closes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.2 KiB
Python
60 lines
2.2 KiB
Python
from PyQt6.QtWidgets import QWidget, QApplication
|
|
from PyQt6.QtCore import Qt, QSize, QRectF
|
|
from PyQt6.QtGui import QPainter
|
|
|
|
from lintunes.gui.art_window import fit_size
|
|
|
|
# The window takes a projection screen's shape.
|
|
SCREEN_SHAPE = QSize(16, 10)
|
|
|
|
|
|
class VisualizerWindow(QWidget):
|
|
"""The transport-bar visualizer, enlarged: opened by double-clicking the
|
|
panel, closed by a click (or Esc). It holds no state of its own — it
|
|
paints the panel's renderer, so both always show the same frame."""
|
|
|
|
def __init__(self, visualizer):
|
|
super().__init__(visualizer, Qt.WindowType.Window)
|
|
self._visualizer = visualizer
|
|
self.setWindowTitle("Visualizer")
|
|
self.setMinimumSize(160, 100)
|
|
self.setToolTip("Click to close")
|
|
|
|
def open(self, screen=None):
|
|
screen = screen or self.screen() or QApplication.primaryScreen()
|
|
if screen is not None:
|
|
geo = screen.availableGeometry()
|
|
size = fit_size(SCREEN_SHAPE, geo.size())
|
|
margins = self.contentsMargins() # the app-drawn title bar
|
|
self.resize(size.width(), size.height() + margins.top())
|
|
self.move(geo.x() + (geo.width() - size.width()) // 2,
|
|
geo.y() + (geo.height() - size.height()) // 2)
|
|
self.show()
|
|
self.raise_()
|
|
self.activateWindow()
|
|
|
|
def mouseReleaseEvent(self, event):
|
|
if (event.button() == Qt.MouseButton.LeftButton
|
|
and self.contentsRect().contains(event.position().toPoint())):
|
|
self.close()
|
|
return
|
|
super().mouseReleaseEvent(event)
|
|
|
|
def keyPressEvent(self, event):
|
|
if event.key() == Qt.Key.Key_Escape:
|
|
self.close()
|
|
return
|
|
super().keyPressEvent(event)
|
|
|
|
def hideEvent(self, event):
|
|
super().hideEvent(event)
|
|
self._visualizer.big_window_closed()
|
|
|
|
def paintEvent(self, event):
|
|
painter = QPainter(self)
|
|
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
|
|
area = self.contentsRect() # below our own title bar (titlebar.py)
|
|
painter.fillRect(area, self._visualizer.panel_color())
|
|
painter.setClipRect(area)
|
|
self._visualizer.paint_renderer(painter, QRectF(area), big=True)
|