Skip to content

Commit

Permalink
Add slip render and use stylesheet for stem color
Browse files Browse the repository at this point in the history
  • Loading branch information
acolombier committed May 10, 2024
1 parent f4170e9 commit c48bf15
Show file tree
Hide file tree
Showing 8 changed files with 330 additions and 114 deletions.
40 changes: 28 additions & 12 deletions res/skins/LateNight/style_palemoon.qss
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,7 @@ WLibraryTextBrowser QMenu,
WTrackMenu,
WTrackMenu QMenu,
WTrackMenu QMenu QCheckBox,
WTrackMenu WStarRating,
WEffectChainPresetButton QMenu,
WEffectChainPresetButton QMenu QCheckBox,
QLineEdit QMenu,
Expand Down Expand Up @@ -1359,7 +1360,7 @@ WEffectChainPresetSelector QAbstractScrollArea,
#KnobLabel,
#FxKnobLabel,
#FxButtonLabel,
#VinylButton[displayValue="0"],
WPushButton#VinylStatus[displayValue="0"],
#VinylCueButton[displayValue="0"],
#VinylModeButton,
#PassthroughButton[displayValue="0"],
Expand All @@ -1377,7 +1378,9 @@ WEffectChainPresetSelector QAbstractScrollArea,
color: #444;
}

#VinylButton[displayValue="1"],
WPushButton#VinylStatus[displayValue="1"], /* enabled (green bg) */
WPushButton#VinylStatus[displayValue="2"], /* end of record (blinking yellow bg) */
WPushButton#VinylStatus[displayValue="3"], /* needle skip detected (pink bg) */
#VinylCueButton[displayValue="1"],
#VinylCueButton[displayValue="2"],
#PassthroughButton[displayValue="1"],
Expand Down Expand Up @@ -1450,7 +1453,7 @@ QPushButton#pushButtonRecording:checked {
#BroadcastButton[displayValue="0"],
#SkinSettingsToggle[displayValue="0"],
#KeyMatchReset[displayValue="0"],
WPushButton#VinylButton[displayValue="0"],
WPushButton#VinylStatus[displayValue="0"],
#SyncDeck[displayValue="0"],
WPushButton#FxAssignButton1[displayValue="0"],
WEffectSelector:!editable,
Expand All @@ -1463,7 +1466,9 @@ WEffectSelector:!editable,
}
/*
WPushButton#BpmTap[displayValue="1"], */
WPushButton#VinylButton[displayValue="1"],
WPushButton#VinylStatus[displayValue="1"],
WPushButton#VinylStatus[displayValue="2"],
WPushButton#VinylStatus[displayValue="3"],
#SyncDeck[displayValue="1"],
WPushButton#FxAssignButton1[displayValue="1"],
#KeyMatchReset[pressed="true"],
Expand Down Expand Up @@ -1663,7 +1668,6 @@ WPushButton#Reverse[pressed="true"],
#MicTalk[value="1"], #AuxPlay[value="1"],
#MicDucking[value="1"],
#MicDucking[value="2"],
#VinylButton[displayValue="1"],
#PassthroughButton[displayValue="1"],
#BroadcastButton[displayValue="4"], /* warning */
QPushButton#pushButtonAutoDJ:checked,
Expand Down Expand Up @@ -1699,6 +1703,7 @@ QPushButton#pushButtonRecording:checked,
/* Green for Fx toggles, QuickEffect + Fx12 */
#FxUnit1 #FxToggleButton[displayValue="1"],
#FxUnit2 #FxToggleButton[displayValue="1"],
WPushButton#VinylStatus[displayValue="1"], /* enabled, OK */
#BroadcastButton[displayValue="2"] {
background-color: #438225;
}
Expand All @@ -1710,7 +1715,7 @@ QPushButton#pushButtonRecording:checked,
}
/* Blue for Fx buttons 3/4 */
#FxUnit3 #FxToggleButton[displayValue="1"],
#FxUnit4 #FxToggleButton[displayValue="1"],
#FxUnit4 #FxToggleButton[displayValue="1"]
WBeatSpinBox::up-button:pressed,
WBeatSpinBox::down-button:pressed,
#spinBoxTransition::up-button:pressed,
Expand Down Expand Up @@ -1799,17 +1804,19 @@ WPushButton#FxSuperLinkInvertButton[displayValue="0"] {

/* Yellow */
#RecFeedback[displayValue="1"], /* initialize recording */
#BroadcastButton[displayValue="1"] { /* connecting */
#BroadcastButton[displayValue="1"], /* connecting */
WPushButton#VinylStatus[displayValue="2"] { /* blinks when the needle reaches the end of the record */
background-color: #d09300;
}

#SpecialCueButton[value="1"] {
background-color: #395579;
}

/* pink */
#BroadcastButton[displayValue="3"], /* failure */
#RecFeedback[displayValue="3"] {
/* pink for error / failure / warning */
#BroadcastButton[displayValue="3"],
#RecFeedback[displayValue="3"],
WPushButton#VinylStatus[displayValue="3"] { /* needle skip detected */
background-color: #f856e7;
}

Expand Down Expand Up @@ -1849,7 +1856,14 @@ WPushButton#CrossfaderButton[displayValue="0"],
WPushButton#CrossfaderButton[displayValue="1"],
WPushButton#RecButton[displayValue="0"],
WPushButton#RecButton[displayValue="1"],
#RecDot {
#RecDot,
/* transparent buttons, 0-4 (max button state we have currently) */
/* currently used for VINYL overlay */
WPushButton#Blank[value="0"],
WPushButton#Blank[value="1"],
WPushButton#Blank[value="2"],
WPushButton#Blank[value="3"],
WPushButton#Blank[value="4"] {
background-color: transparent;
}

Expand Down Expand Up @@ -2957,6 +2971,7 @@ WTrackMenu::item,
WTrackMenu QMenu,
WTrackMenu QMenu::item,
WTrackMenu QMenu QCheckBox,
WTrackMenu WStarRating,
QLineEdit QMenu,
QLineEdit QMenu::item,
QPlainTextEdit QMenu,
Expand Down Expand Up @@ -3161,5 +3176,6 @@ WStemControl WLabel {
font-size: 14px;
}
WStemControl {
margin: 10px 15px 10px 15px;
border-radius: 7px;
opacity: 0.2;
}
25 changes: 15 additions & 10 deletions src/waveform/renderers/allshader/waveformrendererstem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "track/track.h"
#include "util/math.h"
#include "util/texture.h"
#include "waveform/renderers/allshader/matrixforwidgetgeometry.h"
#include "waveform/renderers/allshader/rgbdata.h"
#include "waveform/renderers/waveformwidgetrenderer.h"
Expand All @@ -19,8 +18,10 @@ constexpr int kMaxSupportedStem = 4;
namespace allshader {

WaveformRendererStem::WaveformRendererStem(
WaveformWidgetRenderer* waveformWidget)
: WaveformRendererSignalBase(waveformWidget) {
WaveformWidgetRenderer* waveformWidget,
::WaveformRendererAbstract::PositionSource type)
: WaveformRendererSignalBase(waveformWidget),
m_isSlipRenderer(type == ::WaveformRendererAbstract::Slip) {
}

void WaveformRendererStem::onSetup(const QDomNode& node) {
Expand All @@ -43,7 +44,7 @@ void WaveformRendererStem::initializeGL() {

void WaveformRendererStem::paintGL() {
TrackPointer pTrack = m_waveformRenderer->getTrackInfo();
if (!pTrack) {
if (!pTrack || (m_isSlipRenderer && !m_waveformRenderer->isSlipActive())) {
return;
}

Expand All @@ -52,6 +53,8 @@ void WaveformRendererStem::paintGL() {
if (stemInfo.isEmpty()) {
return;
}
auto positionType = m_isSlipRenderer ? ::WaveformRendererAbstract::Slip
: ::WaveformRendererAbstract::Play;

ConstWaveformPointer waveform = pTrack->getWaveform();
if (waveform.isNull()) {
Expand All @@ -74,9 +77,9 @@ void WaveformRendererStem::paintGL() {
// See waveformrenderersimple.cpp for a detailed explanation of the frame and index calculation
const int visualFramesSize = dataSize / 2;
const double firstVisualFrame =
m_waveformRenderer->getFirstDisplayedPosition() * visualFramesSize;
m_waveformRenderer->getFirstDisplayedPosition(positionType) * visualFramesSize;
const double lastVisualFrame =
m_waveformRenderer->getLastDisplayedPosition() * visualFramesSize;
m_waveformRenderer->getLastDisplayedPosition(positionType) * visualFramesSize;

// Represents the # of visual frames per horizontal pixel.
const double visualIncrementPerPixel =
Expand Down Expand Up @@ -108,7 +111,7 @@ void WaveformRendererStem::paintGL() {
m_vertices.addRectangle(0.f,
halfBreadth - 0.5f * devicePixelRatio,
static_cast<float>(length),
halfBreadth + 0.5f * devicePixelRatio);
m_isSlipRenderer ? halfBreadth : halfBreadth + 0.5f * devicePixelRatio);
m_colors.addForRectangle(0.f, 0.f, 0.f, 0.f);

const double maxSamplingRange = visualIncrementPerPixel / 2.0;
Expand All @@ -120,7 +123,7 @@ void WaveformRendererStem::paintGL() {
float color_r = stemColor.redF(),
color_g = stemColor.greenF(),
color_b = stemColor.blueF(),
color_a = stemColor.alphaF() * (z ? 0.75 : 0.15);
color_a = stemColor.alphaF() * (z ? 0.75f : 0.15f);
const int visualFrameStart = std::lround(xVisualFrame - maxSamplingRange);
const int visualFrameStop = std::lround(xVisualFrame + maxSamplingRange);

Expand All @@ -147,15 +150,17 @@ void WaveformRendererStem::paintGL() {

// Apply the gains
if (z) {
max *= m_pStemMute[s]->toBool() ? 0 : m_pStemGain[s]->get();
max *= m_pStemMute[s]->toBool()
? 0.f
: static_cast<float>(m_pStemGain[s]->get());
}

// Lines are thin rectangles
// shawdow
m_vertices.addRectangle(fpos - 0.5f,
halfBreadth - heightFactor * max,
fpos + 0.5f,
halfBreadth + heightFactor * max);
m_isSlipRenderer ? halfBreadth : halfBreadth + heightFactor * max);

m_colors.addForRectangle(color_r, color_g, color_b, color_a);
}
Expand Down
6 changes: 5 additions & 1 deletion src/waveform/renderers/allshader/waveformrendererstem.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ class WaveformRendererStem;

class allshader::WaveformRendererStem final : public allshader::WaveformRendererSignalBase {
public:
explicit WaveformRendererStem(WaveformWidgetRenderer* waveformWidget);
explicit WaveformRendererStem(WaveformWidgetRenderer* waveformWidget,
::WaveformRendererAbstract::PositionSource type =
::WaveformRendererAbstract::Play);

// override ::WaveformRendererSignalBase
void onSetup(const QDomNode& node) override;
Expand All @@ -31,6 +33,8 @@ class allshader::WaveformRendererStem final : public allshader::WaveformRenderer
VertexData m_vertices;
RGBAData m_colors;

bool m_isSlipRenderer;

std::vector<std::unique_ptr<ControlProxy>> m_pStemGain;
std::vector<std::unique_ptr<ControlProxy>> m_pStemMute;

Expand Down
Loading

0 comments on commit c48bf15

Please sign in to comment.