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:
@@ -328,7 +328,12 @@ persistence) → GUI (Qt widgets that read the manager and connect to its signal
|
||||
built in and reserved. Applying one moves the dialog's *controls* (each
|
||||
registers a setter in `_viz_setters`), and their own handlers save the
|
||||
values, so controls and prefs can't disagree. The drop-down reads
|
||||
"Custom" whenever the settings match no preset. A setting added later
|
||||
"Custom" whenever the settings match no preset. The page's sliders
|
||||
(Round 111) are `transport.ClickJumpSlider`s with the `tall` property:
|
||||
twice Fusion's height, and a click puts the handle's centre where it
|
||||
lands. Radial's dot size is shown as a share of the gap between dots
|
||||
(100% = touching; the pref is × the automatic size, `RADIAL_DOT_SHARE`
|
||||
of the gap) — never pixels, since the gap moves with the drawing's size. A setting added later
|
||||
must join `STYLE_KEYS` and register a setter, or presets silently skip it
|
||||
(`test_every_style_key_has_a_control` pins that).
|
||||
**Dark mode** (Round 101, Preferences › Appearance): `theme.mode(prefs)`
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
"""Round 111: the visualizer page's sliders are tall and jump where clicked;
|
||||
the radial dot size reads as a share of the spacing between dots."""
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from PyQt6.QtCore import QPoint, Qt
|
||||
from PyQt6.QtTest import QTest
|
||||
|
||||
from lintunes.gui import preferences_dialog as pd
|
||||
from lintunes.gui.preferences_dialog import PreferencesDialog
|
||||
from lintunes.gui.transport import ClickJumpSlider
|
||||
from lintunes.preferences import Preferences
|
||||
|
||||
|
||||
def _dialog(tmp_path):
|
||||
dialog = PreferencesDialog(Preferences(tmp_path), MagicMock())
|
||||
dialog.resize(900, 700)
|
||||
dialog.pages_list.setCurrentRow(2)
|
||||
dialog._viz_radios["radial"].setChecked(True)
|
||||
dialog.show()
|
||||
QTest.qWait(20)
|
||||
return dialog
|
||||
|
||||
|
||||
def test_visualizer_sliders_are_tall_click_jump_sliders(qapp, tmp_path):
|
||||
dialog = _dialog(tmp_path)
|
||||
sliders = [dialog._radial_dot_slider, dialog._fade_slider,
|
||||
dialog._sync_sliders["radial"], dialog._dot_slider]
|
||||
for slider in sliders:
|
||||
assert isinstance(slider, ClickJumpSlider)
|
||||
assert slider.property("tall")
|
||||
dialog.close()
|
||||
|
||||
|
||||
def test_a_click_puts_the_handle_where_it_lands(qapp, tmp_path):
|
||||
dialog = _dialog(tmp_path)
|
||||
slider = dialog._radial_dot_slider
|
||||
y = slider.height() // 2
|
||||
QTest.mouseClick(slider, Qt.MouseButton.LeftButton, pos=QPoint(0, y))
|
||||
assert slider.value() == slider.minimum()
|
||||
QTest.mouseClick(slider, Qt.MouseButton.LeftButton,
|
||||
pos=QPoint(slider.width() - 1, y))
|
||||
assert slider.value() == slider.maximum()
|
||||
QTest.mouseClick(slider, Qt.MouseButton.LeftButton,
|
||||
pos=QPoint(slider.width() // 2, y))
|
||||
middle = (slider.minimum() + slider.maximum()) / 2
|
||||
assert abs(slider.value() - middle) <= 2 # not one page step from the end
|
||||
dialog.close()
|
||||
|
||||
|
||||
def test_dot_size_is_a_share_of_the_spacing():
|
||||
# The automatic size (1×) is 70% of the gap; dots touch at 100%.
|
||||
assert pd._dot_text(1.0) == "70%"
|
||||
assert pd._dot_text(1 / 0.7) == "100%"
|
||||
Reference in New Issue
Block a user