forked from trav/lintunes
v0.80.0: visualizer settings sliders are twice as tall and jump where clicked; radial dot size reads as a share of the gap between dots
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
"""LinTunes — iTunes-style music library manager and player for Linux."""
|
||||
|
||||
__version__ = "0.79.2"
|
||||
__version__ = "0.80.0"
|
||||
|
||||
@@ -18,6 +18,7 @@ from lintunes.export import upload
|
||||
from lintunes.gui import visualizer_styles
|
||||
from lintunes.gui.range_slider import RangeSlider
|
||||
from lintunes.gui.scope_drawing import ScopeDrawing
|
||||
from lintunes.gui.transport import ClickJumpSlider
|
||||
from lintunes.gui import visualizer_presets as presets
|
||||
from lintunes.gui import sounds
|
||||
from lintunes.theme import HIGHLIGHT_COLORS
|
||||
@@ -41,6 +42,15 @@ _COLOR_ROWS = [
|
||||
_VALUE_WIDTH = 56
|
||||
|
||||
|
||||
def _viz_slider_widget() -> ClickJumpSlider:
|
||||
"""The visualizer page's sliders: as tall as the seek bar, so they're
|
||||
easy to hit, and a click puts the handle where it lands instead of
|
||||
paging toward it."""
|
||||
slider = ClickJumpSlider()
|
||||
slider.setProperty("tall", True)
|
||||
return slider
|
||||
|
||||
|
||||
HEADING_EXTRA_PX = 2 # section headings: this much over the text
|
||||
_EDIT_PRESETS = "\0edit" # the preset drop-down's last item
|
||||
_SPEAKER_KEYS = ("visualizer_laser_low_hz", "visualizer_laser_high_hz")
|
||||
@@ -80,6 +90,12 @@ def _fade_text(seconds: float) -> str:
|
||||
_VISUALIZER_STYLES = visualizer_styles.STYLE_NAMES
|
||||
|
||||
|
||||
def _dot_text(scale: float) -> str:
|
||||
"""The radial dot size as a share of the spacing between dots. The pref
|
||||
is a multiple of the automatic size, which is 70% of that spacing."""
|
||||
return f"{round(scale * visualizer_styles.RADIAL_DOT_SHARE * 100)}%"
|
||||
|
||||
|
||||
def _sync_text(ms: int) -> str:
|
||||
if ms < 0:
|
||||
return f"{-ms} ms sooner"
|
||||
@@ -674,8 +690,12 @@ class PreferencesDialog(QDialog):
|
||||
tip="How many positions each dot can take, center to rim")
|
||||
self._radial_dot_slider, _ = self._viz_slider(
|
||||
form, "Dot size:", "visualizer_radial_dot", config, scale=100,
|
||||
fmt=lambda v: f"{round(v * 100)}%",
|
||||
tip="100% is as big as the dots can be without touching")
|
||||
fmt=_dot_text,
|
||||
tip="How much of the space between neighbouring dots each dot "
|
||||
"fills: at 100% they touch, past it they overlap. A share "
|
||||
"of the spacing rather than pixels, because the spacing "
|
||||
"changes with the drawing's size (the panel or the big "
|
||||
"window) and with the bands and steps above")
|
||||
self._normalize = self._viz_check(
|
||||
form, "Even out bass and treble", "visualizer_radial_normalize",
|
||||
config, tip="Music is loudest in the bass. This learns the "
|
||||
@@ -910,7 +930,7 @@ class PreferencesDialog(QDialog):
|
||||
"""This style's sync delay — this machine's speakers' latency plus
|
||||
the style's own lag, so one per style, in config.json."""
|
||||
lo, hi = visualizer_styles.SYNC_DELAY_LIMITS
|
||||
slider = QSlider(Qt.Orientation.Horizontal)
|
||||
slider = _viz_slider_widget()
|
||||
slider.setRange(lo, hi)
|
||||
slider.setSingleStep(5)
|
||||
slider.setPageStep(25)
|
||||
@@ -961,7 +981,7 @@ class PreferencesDialog(QDialog):
|
||||
"""A slider over ``visualizer_styles.LIMITS[key]`` that previews live
|
||||
and saves once the drag settles, with its value beside it."""
|
||||
lo, hi = visualizer_styles.LIMITS[key]
|
||||
slider = QSlider(Qt.Orientation.Horizontal)
|
||||
slider = _viz_slider_widget()
|
||||
slider.setRange(round(lo * scale), round(hi * scale))
|
||||
slider.setToolTip(tip)
|
||||
slider.setValue(round(config[key] * scale)) # before connect
|
||||
|
||||
@@ -5,8 +5,8 @@ from PyQt6.QtWidgets import QWidget, QSizePolicy
|
||||
from PyQt6.QtCore import Qt, QRectF, QPointF, pyqtSignal
|
||||
from PyQt6.QtGui import QPainter, QPen
|
||||
|
||||
HANDLE = 16 # handle diameter, px
|
||||
GROOVE = 4 # groove thickness, px
|
||||
HANDLE = 24 # handle diameter, px (as tall as the tall sliders beside it)
|
||||
GROOVE = 8 # groove thickness, px
|
||||
|
||||
|
||||
class RangeSlider(QWidget):
|
||||
|
||||
@@ -2,7 +2,7 @@ import time
|
||||
|
||||
from PyQt6.QtWidgets import (
|
||||
QWidget, QFrame, QHBoxLayout, QVBoxLayout, QLabel, QToolButton, QSlider,
|
||||
QPushButton, QSizePolicy, QStyle, QLayout, QSpacerItem,
|
||||
QPushButton, QSizePolicy, QStyle, QStyleOptionSlider, QLayout, QSpacerItem,
|
||||
)
|
||||
from PyQt6.QtCore import Qt, QTimer, QEvent, QPoint, QPointF, QRect, QSize, pyqtSignal
|
||||
from PyQt6.QtGui import QColor, QFont, QIcon, QPainter, QPen, QPixmap
|
||||
@@ -276,8 +276,22 @@ class ClickJumpSlider(QSlider):
|
||||
super().__init__(Qt.Orientation.Horizontal, parent)
|
||||
|
||||
def _value_at(self, x: float) -> int:
|
||||
"""The value that puts the handle's centre under ``x``: the handle
|
||||
travels the groove less its own width, so a click at either end of
|
||||
the groove is the end value."""
|
||||
option = QStyleOptionSlider()
|
||||
self.initStyleOption(option)
|
||||
style = self.style()
|
||||
CC, SC = QStyle.ComplexControl.CC_Slider, QStyle.SubControl
|
||||
groove = style.subControlRect(CC, option, SC.SC_SliderGroove, self)
|
||||
handle = style.subControlRect(CC, option, SC.SC_SliderHandle, self)
|
||||
span = groove.width() - handle.width()
|
||||
if span <= 0:
|
||||
return QStyle.sliderValueFromPosition(
|
||||
self.minimum(), self.maximum(), int(x), self.width())
|
||||
pos = round(x - groove.left() - handle.width() / 2)
|
||||
return QStyle.sliderValueFromPosition(
|
||||
self.minimum(), self.maximum(), int(x), self.width())
|
||||
self.minimum(), self.maximum(), max(0, min(span, pos)), span)
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
if (event.button() == Qt.MouseButton.LeftButton
|
||||
|
||||
@@ -343,6 +343,7 @@ class BarsRenderer:
|
||||
|
||||
DOT_PITCH = 3.0 # px between neighbouring dots on the rim, at least
|
||||
HUB = 0.22 # the silent middle, as a share of the radius
|
||||
RADIAL_DOT_SHARE = 0.7 # the automatic dot: this share of the gap to its neighbours
|
||||
GHOST_BUCKETS = 8 # one drawPoints() per bucket of similar alpha
|
||||
NORMALIZE_S = 4.0 # how long the bass/treble balance takes to settle
|
||||
MAX_EVEN_DB = 24.0 # the most evening out may move a band
|
||||
@@ -493,7 +494,7 @@ class RadialRenderer:
|
||||
# Then the user's share of that: dot size is a percentage, because
|
||||
# the right size in pixels differs between the panel and the window.
|
||||
dot = max(1.0, max(1.5, min(2 * math.pi * radius / spokes, ring_step)
|
||||
* 0.7) * self.dot_scale)
|
||||
* RADIAL_DOT_SHARE) * self.dot_scale)
|
||||
sin, cos = np.sin(2 * math.pi * angle), np.cos(2 * math.pi * angle)
|
||||
|
||||
def points(spoke_idx, ring_idx):
|
||||
|
||||
Reference in New Issue
Block a user