From 115ea94bdf4de77825f98c5dd140d42ec2d0abb2 Mon Sep 17 00:00:00 2001 From: Antoine C Date: Mon, 8 Apr 2024 15:05:05 +0100 Subject: [PATCH] code style feedback --- src/shaders/slipmodeshader.cpp | 4 ++-- .../allshader/waveformrenderbeat.cpp | 2 +- .../renderers/allshader/waveformrenderbeat.h | 2 +- .../allshader/waveformrendererpreroll.cpp | 2 +- .../allshader/waveformrendererpreroll.h | 2 +- .../allshader/waveformrendererrgb.cpp | 2 +- .../renderers/allshader/waveformrendererrgb.h | 2 +- .../allshader/waveformrendererslipmode.cpp | 22 +++++++++++-------- .../allshader/waveformrendererslipmode.h | 5 +---- .../allshader/waveformrendermark.cpp | 2 +- .../renderers/allshader/waveformrendermark.h | 2 +- .../renderers/waveformrendererabstract.h | 2 +- .../renderers/waveformwidgetrenderer.cpp | 9 ++++---- .../renderers/waveformwidgetrenderer.h | 8 +++---- 14 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/shaders/slipmodeshader.cpp b/src/shaders/slipmodeshader.cpp index b176e217840d..352d61c9ea90 100644 --- a/src/shaders/slipmodeshader.cpp +++ b/src/shaders/slipmodeshader.cpp @@ -27,8 +27,8 @@ in highp vec4 vposition; void main() { - float xBorder = abs(dimension.x*vposition.x); - float yBorder = dimension.y*vposition.y; + float xBorder = abs(dimension.x * vposition.x); + float yBorder = dimension.y * vposition.y; float upperBoard = borders.x; float lowerBoard = borders.y; diff --git a/src/waveform/renderers/allshader/waveformrenderbeat.cpp b/src/waveform/renderers/allshader/waveformrenderbeat.cpp index efc04efb6ae2..3f793efd706b 100644 --- a/src/waveform/renderers/allshader/waveformrenderbeat.cpp +++ b/src/waveform/renderers/allshader/waveformrenderbeat.cpp @@ -11,7 +11,7 @@ namespace allshader { WaveformRenderBeat::WaveformRenderBeat(WaveformWidgetRenderer* waveformWidget, - ::WaveformRendererAbstract::Type type) + ::WaveformRendererAbstract::PositionSource type) : WaveformRenderer(waveformWidget), m_isSlipRenderer(type == ::WaveformRendererAbstract::Slip) { } diff --git a/src/waveform/renderers/allshader/waveformrenderbeat.h b/src/waveform/renderers/allshader/waveformrenderbeat.h index 01912ae9083a..d3b2b79d1bce 100644 --- a/src/waveform/renderers/allshader/waveformrenderbeat.h +++ b/src/waveform/renderers/allshader/waveformrenderbeat.h @@ -17,7 +17,7 @@ class WaveformRenderBeat; class allshader::WaveformRenderBeat final : public allshader::WaveformRenderer { public: explicit WaveformRenderBeat(WaveformWidgetRenderer* waveformWidget, - ::WaveformRendererAbstract::Type type = + ::WaveformRendererAbstract::PositionSource type = ::WaveformRendererAbstract::Play); void setup(const QDomNode& node, const SkinContext& context) override; diff --git a/src/waveform/renderers/allshader/waveformrendererpreroll.cpp b/src/waveform/renderers/allshader/waveformrendererpreroll.cpp index 60beca4ee9ea..3fa00e6bd86e 100644 --- a/src/waveform/renderers/allshader/waveformrendererpreroll.cpp +++ b/src/waveform/renderers/allshader/waveformrendererpreroll.cpp @@ -62,7 +62,7 @@ namespace allshader { WaveformRendererPreroll::WaveformRendererPreroll( WaveformWidgetRenderer* waveformWidget, - ::WaveformRendererAbstract::Type type) + ::WaveformRendererAbstract::PositionSource type) : WaveformRenderer(waveformWidget), m_isSlipRenderer(type == ::WaveformRendererAbstract::Slip) { } diff --git a/src/waveform/renderers/allshader/waveformrendererpreroll.h b/src/waveform/renderers/allshader/waveformrendererpreroll.h index ec54b17c8c51..c764d68b3384 100644 --- a/src/waveform/renderers/allshader/waveformrendererpreroll.h +++ b/src/waveform/renderers/allshader/waveformrendererpreroll.h @@ -22,7 +22,7 @@ class allshader::WaveformRendererPreroll : public allshader::WaveformRenderer { public: explicit WaveformRendererPreroll( WaveformWidgetRenderer* waveformWidgetRenderer, - ::WaveformRendererAbstract::Type type = + ::WaveformRendererAbstract::PositionSource type = ::WaveformRendererAbstract::Play); ~WaveformRendererPreroll() override; diff --git a/src/waveform/renderers/allshader/waveformrendererrgb.cpp b/src/waveform/renderers/allshader/waveformrendererrgb.cpp index f83044b9e53c..20c4d12a4847 100644 --- a/src/waveform/renderers/allshader/waveformrendererrgb.cpp +++ b/src/waveform/renderers/allshader/waveformrendererrgb.cpp @@ -15,7 +15,7 @@ inline float math_pow2(float x) { } // namespace WaveformRendererRGB::WaveformRendererRGB(WaveformWidgetRenderer* waveformWidget, - ::WaveformRendererAbstract::Type type) + ::WaveformRendererAbstract::PositionSource type) : WaveformRendererSignalBase(waveformWidget), m_isSlipRenderer(type == ::WaveformRendererAbstract::Slip) { } diff --git a/src/waveform/renderers/allshader/waveformrendererrgb.h b/src/waveform/renderers/allshader/waveformrendererrgb.h index a7c1a1983fb3..d9b2d5a65d2c 100644 --- a/src/waveform/renderers/allshader/waveformrendererrgb.h +++ b/src/waveform/renderers/allshader/waveformrendererrgb.h @@ -13,7 +13,7 @@ class WaveformRendererRGB; class allshader::WaveformRendererRGB final : public allshader::WaveformRendererSignalBase { public: explicit WaveformRendererRGB(WaveformWidgetRenderer* waveformWidget, - ::WaveformRendererAbstract::Type type = + ::WaveformRendererAbstract::PositionSource type = ::WaveformRendererAbstract::Play); // override ::WaveformRendererSignalBase diff --git a/src/waveform/renderers/allshader/waveformrendererslipmode.cpp b/src/waveform/renderers/allshader/waveformrendererslipmode.cpp index 2f16f579b15e..79061fb53f46 100644 --- a/src/waveform/renderers/allshader/waveformrendererslipmode.cpp +++ b/src/waveform/renderers/allshader/waveformrendererslipmode.cpp @@ -11,8 +11,12 @@ namespace { constexpr int kBlinkingPeriodMillis = 1600; +// Position matrix passed to OpenGL when drawing the shader constexpr float positionArray[] = {-1.f, -1.f, 1.f, -1.f, -1.f, 1.f, 1.f, 1.f}; +// Used as default outline color in case no value is provided in the theme +constexpr QColor kDefaultColor = QColor(224, 224, 224); + } // anonymous namespace namespace allshader { @@ -20,7 +24,6 @@ namespace allshader { WaveformRendererSlipMode::WaveformRendererSlipMode( WaveformWidgetRenderer* waveformWidget) : WaveformRenderer(waveformWidget), - m_pSlipMode(nullptr), m_slipBorderTopOutlineSize(10.f), m_slipBorderBottomOutlineSize(10.f) { } @@ -28,18 +31,18 @@ WaveformRendererSlipMode::WaveformRendererSlipMode( bool WaveformRendererSlipMode::init() { m_timer.restart(); - m_pSlipMode.reset(new ControlProxy( - m_waveformRenderer->getGroup(), "slip_enabled")); + m_pSlipMode = std::make_unique( + m_waveformRenderer->getGroup(), "slip_enabled"); return true; } void WaveformRendererSlipMode::setup(const QDomNode& node, const SkinContext& context) { - m_color = QColor(224, 224, 224); const QString slipModeOutlineColorName = context.selectString(node, "SlipBorderOutlineColor"); if (!slipModeOutlineColorName.isNull()) { - m_color = QColor(slipModeOutlineColorName); - m_color = WSkinColor::getCorrectColor(m_color); + m_color = WSkinColor::getCorrectColor(QColor(slipModeOutlineColorName)); + } else { + m_color = kDefaultColor; } const float slipBorderTopOutlineSize = context.selectFloat( node, "SlipBorderTopOutlineSize", m_slipBorderTopOutlineSize); @@ -65,7 +68,8 @@ void WaveformRendererSlipMode::paintGL() { const int elapsed = m_timer.elapsed().toIntegerMillis() % kBlinkingPeriodMillis; - const double blinkIntensity = (double)(2 * abs(elapsed - kBlinkingPeriodMillis / 2)) / + const double blinkIntensity = + static_cast(2 * abs(elapsed - kBlinkingPeriodMillis / 2)) / kBlinkingPeriodMillis; const double alpha = 0.25 + 0.5 * blinkIntensity; @@ -94,8 +98,8 @@ void WaveformRendererSlipMode::paintGL() { positionLocation, GL_FLOAT, positionArray, 2); m_shader.setUniformValue(gradientLocation, - (float)m_waveformRenderer->getLength() / 2, - (float)m_waveformRenderer->getBreadth() / 2); + static_cast(m_waveformRenderer->getLength()) / 2, + static_cast(m_waveformRenderer->getBreadth()) / 2); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); diff --git a/src/waveform/renderers/allshader/waveformrendererslipmode.h b/src/waveform/renderers/allshader/waveformrendererslipmode.h index 5e7b189ca57a..e12f492ce085 100644 --- a/src/waveform/renderers/allshader/waveformrendererslipmode.h +++ b/src/waveform/renderers/allshader/waveformrendererslipmode.h @@ -13,10 +13,7 @@ class QDomNode; class SkinContext; namespace allshader { -class WaveformRendererSlipMode; -} - -class allshader::WaveformRendererSlipMode final : public allshader::WaveformRenderer { +class WaveformRendererSlipMode final : public WaveformRenderer { public: explicit WaveformRendererSlipMode( WaveformWidgetRenderer* waveformWidget); diff --git a/src/waveform/renderers/allshader/waveformrendermark.cpp b/src/waveform/renderers/allshader/waveformrendermark.cpp index c510cedc495b..064905ffe8f7 100644 --- a/src/waveform/renderers/allshader/waveformrendermark.cpp +++ b/src/waveform/renderers/allshader/waveformrendermark.cpp @@ -45,7 +45,7 @@ class TextureGraphics : public WaveformMark::Graphics { allshader::WaveformRenderMark::WaveformRenderMark( WaveformWidgetRenderer* waveformWidget, - ::WaveformRendererAbstract::Type type) + ::WaveformRendererAbstract::PositionSource type) : WaveformRenderMarkBase(waveformWidget, false), m_isSlipRenderer(type == ::WaveformRendererAbstract::Slip) { } diff --git a/src/waveform/renderers/allshader/waveformrendermark.h b/src/waveform/renderers/allshader/waveformrendermark.h index de8fefd2573a..60580f1e34c4 100644 --- a/src/waveform/renderers/allshader/waveformrendermark.h +++ b/src/waveform/renderers/allshader/waveformrendermark.h @@ -19,7 +19,7 @@ class allshader::WaveformRenderMark : public ::WaveformRenderMarkBase, public allshader::WaveformRendererAbstract { public: explicit WaveformRenderMark(WaveformWidgetRenderer* waveformWidget, - ::WaveformRendererAbstract::Type type = + ::WaveformRendererAbstract::PositionSource type = ::WaveformRendererAbstract::Play); void draw(QPainter* painter, QPaintEvent* event) override { diff --git a/src/waveform/renderers/waveformrendererabstract.h b/src/waveform/renderers/waveformrendererabstract.h index b17ec9b70cee..6c15dd523d5d 100644 --- a/src/waveform/renderers/waveformrendererabstract.h +++ b/src/waveform/renderers/waveformrendererabstract.h @@ -18,7 +18,7 @@ class WaveformRendererAbstract { /// The type of cursor for which the waveform is rendered /// Play: the play cursor is the area of focus for the renderer /// Slip: the slip cursor is the area of focus for the renderer - enum Type { + enum PositionSource { Play, Slip }; diff --git a/src/waveform/renderers/waveformwidgetrenderer.cpp b/src/waveform/renderers/waveformwidgetrenderer.cpp index 3b328f68c7fa..ffefe5d6d455 100644 --- a/src/waveform/renderers/waveformwidgetrenderer.cpp +++ b/src/waveform/renderers/waveformwidgetrenderer.cpp @@ -17,7 +17,6 @@ const double WaveformWidgetRenderer::s_defaultPlayMarkerPosition = 0.5; namespace { constexpr int kDefaultDimBrightThreshold = 127; -constexpr int kWaveformRendererAbstractTypeEnd = ::WaveformRendererAbstract::Slip + 1; } // namespace WaveformWidgetRenderer::WaveformWidgetRenderer(const QString& group) @@ -47,7 +46,7 @@ WaveformWidgetRenderer::WaveformWidgetRenderer(const QString& group) m_passthroughEnabled(false) { //qDebug() << "WaveformWidgetRenderer"; for (int type = ::WaveformRendererAbstract::Play; - type < kWaveformRendererAbstractTypeEnd; + type <= ::WaveformRendererAbstract::Slip; type++) { m_firstDisplayedPosition[type] = 0.0; m_lastDisplayedPosition[type] = 0.0; @@ -110,7 +109,7 @@ void WaveformWidgetRenderer::onPreRender(VSyncThread* vsyncThread) { if (m_passthroughEnabled) { // disables renderers in draw() for (int type = ::WaveformRendererAbstract::Play; - type < kWaveformRendererAbstractTypeEnd; + type <= ::WaveformRendererAbstract::Slip; type++) { m_pos[type] = -1.0; m_truePosSample[type] = -1.0; @@ -168,7 +167,7 @@ void WaveformWidgetRenderer::onPreRender(VSyncThread* vsyncThread) { m_totalVSamples = static_cast(m_trackPixelCount * m_visualSamplePerPixel); for (int type = ::WaveformRendererAbstract::Play; - type < kWaveformRendererAbstractTypeEnd; + type <= ::WaveformRendererAbstract::Slip; type++) { // Avoid pixel jitter in play position by rounding to the nearest track // pixel. @@ -181,7 +180,7 @@ void WaveformWidgetRenderer::onPreRender(VSyncThread* vsyncThread) { } else { for (int type = ::WaveformRendererAbstract::Play; - type < kWaveformRendererAbstractTypeEnd; + type <= ::WaveformRendererAbstract::Slip; type++) { m_pos[type] = -1.0; // disable renderers m_truePosSample[type] = -1.0; diff --git a/src/waveform/renderers/waveformwidgetrenderer.h b/src/waveform/renderers/waveformwidgetrenderer.h index 893705a680b6..a2b82dd5e539 100644 --- a/src/waveform/renderers/waveformwidgetrenderer.h +++ b/src/waveform/renderers/waveformwidgetrenderer.h @@ -58,12 +58,12 @@ class WaveformWidgetRenderer { CuePointer getCuePointerFromIndex(int cueIndex) const; double getFirstDisplayedPosition( - ::WaveformRendererAbstract::Type type = + ::WaveformRendererAbstract::PositionSource type = ::WaveformRendererAbstract::Play) const { return m_firstDisplayedPosition[type]; } double getLastDisplayedPosition( - ::WaveformRendererAbstract::Type type = + ::WaveformRendererAbstract::PositionSource type = ::WaveformRendererAbstract::Play) const { return m_lastDisplayedPosition[type]; } @@ -84,7 +84,7 @@ class WaveformWidgetRenderer { // stable and deterministic // Transform sample index to pixel in track. inline double transformSamplePositionInRendererWorld(double samplePosition, - ::WaveformRendererAbstract::Type type = + ::WaveformRendererAbstract::PositionSource type = ::WaveformRendererAbstract::Play) const { if (std::abs(samplePosition - m_truePosSample[type]) < 1.f) { // When asked for the sample position that corresponds with the play @@ -97,7 +97,7 @@ class WaveformWidgetRenderer { 2 / m_audioSamplePerPixel; } - int getPlayPosVSample(::WaveformRendererAbstract::Type type = + int getPlayPosVSample(::WaveformRendererAbstract::PositionSource type = ::WaveformRendererAbstract::Play) const { return m_posVSample[type]; }