forked from trav/lintunes
v0.66.0: DJ mode's djay layout, loops, a sync that sets once, a real horn, a smooth slide
- Records in the top corners, each deck's controls beside them facing the middle, the zoomed A-over-B waveforms in the centre, and a whole-song overview per deck below (click to jump, drag to move) with the crossfader between them. - Loops per deck: Loop plus a 1/32 to 8 beat stepper; a loop starts on the next beat and shows on both waveforms. - Sync sets this deck to the other's tempo once, and stays lit only while that still holds. - The air horn plays like a real one: every press a fresh blast, held it carries the note, let go it stops. - Opening and closing DJ mode slides a picture over the final layout instead of re-laying-out the window every frame (the flicker). - Tests: garbage is collected on the main thread after each test, which stops a rare segfault in the full run.
This commit is contained in:
@@ -7,7 +7,7 @@ from PyQt6.QtWidgets import (
|
||||
QPlainTextEdit, QTextEdit, QAbstractSpinBox, QComboBox, QApplication,
|
||||
QLabel, QMessageBox, QFileDialog, QProgressBar, QPushButton,
|
||||
)
|
||||
from PyQt6.QtCore import Qt, QEvent, QObject, QTimer, pyqtSignal
|
||||
from PyQt6.QtCore import QRect, Qt, QEvent, QObject, QTimer, pyqtSignal
|
||||
from PyQt6.QtGui import QAction, QKeySequence
|
||||
|
||||
from lintunes import bpm_detect, device_sync, loudness, music_folder, theme, url_import
|
||||
@@ -2399,17 +2399,21 @@ class MainWindow(QMainWindow):
|
||||
track_table.deck_tag = self._deck_tag
|
||||
shelf.set_master(self._dj_master())
|
||||
shelf.set_layout_height(target) # laid out full size, revealed
|
||||
shelf.setFixedHeight(0)
|
||||
split, before = self._snapshot_below_boxes()
|
||||
shelf.setFixedHeight(target)
|
||||
shelf.show()
|
||||
shelf.start()
|
||||
shelf.set_visualizer(self._transport._visualizer)
|
||||
self._sidebar.art.hide() # room for the lists instead
|
||||
self._animate_shelf(0, target)
|
||||
self._slide(split, before, shift=target + self._row_gap(), opening=True)
|
||||
else:
|
||||
shelf = self._dj
|
||||
track_table.deck_tag = None
|
||||
shelf.set_layout_height(shelf.height()) # covered, not squeezed
|
||||
self._animate_shelf(shelf.height(), 0, done=self._dj_closed)
|
||||
split, before = self._snapshot_below_boxes(shelf)
|
||||
shift = shelf.height() + self._row_gap()
|
||||
self._dj_closed_now()
|
||||
self._slide(split, before, shift=shift, opening=False)
|
||||
self._refresh_tables()
|
||||
|
||||
def _ensure_dj(self):
|
||||
@@ -2473,6 +2477,68 @@ class MainWindow(QMainWindow):
|
||||
self._dj_anim = anim
|
||||
anim.start()
|
||||
|
||||
# ---- the slide (Round 96) ----
|
||||
# Animating the shelf's real height re-laid-out the whole window every
|
||||
# frame — the flicker. Instead the window goes straight to its final
|
||||
# layout and a picture of what was below the transport boxes slides
|
||||
# over it: opening, the old lists slide down off the decks (which are
|
||||
# live underneath); closing, a picture of the shelf stays put while the
|
||||
# lists' picture slides up over it. Only an image moves.
|
||||
|
||||
def _row_gap(self) -> int:
|
||||
from lintunes.gui.transport import ROW_GAP
|
||||
return ROW_GAP
|
||||
|
||||
def _snapshot_below_boxes(self, shelf=None):
|
||||
"""(y in the central widget where the window parts, a picture of
|
||||
everything from there down)."""
|
||||
central = self.centralWidget()
|
||||
anchor = shelf if shelf is not None and shelf.isVisible() else \
|
||||
self._transport._header_row
|
||||
split = anchor.mapTo(central, anchor.rect().topLeft()).y()
|
||||
picture = central.grab(QRect(0, split, central.width(), central.height() - split))
|
||||
return split, picture
|
||||
|
||||
def _slide(self, split: int, picture, shift: int, opening: bool):
|
||||
from PyQt6.QtCore import QEasingCurve, QVariantAnimation
|
||||
from lintunes.gui.dj_shelf import SlideOverlay
|
||||
if self._dj_anim is not None:
|
||||
self._dj_anim.stop()
|
||||
old = getattr(self, "_dj_overlay", None)
|
||||
if old is not None:
|
||||
old.deleteLater()
|
||||
central = self.centralWidget()
|
||||
overlay = SlideOverlay(central, picture, shift, opening)
|
||||
overlay.setGeometry(0, split, central.width(), central.height() - split)
|
||||
overlay.show()
|
||||
overlay.raise_()
|
||||
self._dj_overlay = overlay
|
||||
anim = QVariantAnimation(self)
|
||||
anim.setStartValue(0.0)
|
||||
anim.setEndValue(1.0)
|
||||
anim.setDuration(self.ANIMATE_MS)
|
||||
anim.setEasingCurve(QEasingCurve.Type.OutCubic if opening
|
||||
else QEasingCurve.Type.InOutCubic)
|
||||
anim.valueChanged.connect(overlay.set_progress)
|
||||
|
||||
def finished():
|
||||
overlay.hide()
|
||||
overlay.deleteLater()
|
||||
if getattr(self, "_dj_overlay", None) is overlay:
|
||||
self._dj_overlay = None
|
||||
anim.finished.connect(finished)
|
||||
self._dj_anim = anim
|
||||
anim.start()
|
||||
|
||||
def _dj_closed_now(self):
|
||||
"""Closing, for real (the slide only shows it)."""
|
||||
self._dj.set_visualizer(None)
|
||||
self._dj.stop()
|
||||
self._dj.hide()
|
||||
self._sidebar.art.show()
|
||||
self.player.set_suspended(False)
|
||||
self._transport.set_dj_mode(False)
|
||||
|
||||
def _dj_closed(self):
|
||||
if self._dj_on:
|
||||
return # reopened mid-close
|
||||
|
||||
Reference in New Issue
Block a user