Skip to content

Commit

Permalink
code style feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
acolombier committed Apr 8, 2024
1 parent 524eb44 commit 115ea94
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/shaders/slipmodeshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/renderers/allshader/waveformrenderbeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace allshader {

WaveformRenderBeat::WaveformRenderBeat(WaveformWidgetRenderer* waveformWidget,
::WaveformRendererAbstract::Type type)
::WaveformRendererAbstract::PositionSource type)
: WaveformRenderer(waveformWidget),
m_isSlipRenderer(type == ::WaveformRendererAbstract::Slip) {
}
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/renderers/allshader/waveformrenderbeat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace allshader {

WaveformRendererPreroll::WaveformRendererPreroll(
WaveformWidgetRenderer* waveformWidget,
::WaveformRendererAbstract::Type type)
::WaveformRendererAbstract::PositionSource type)
: WaveformRenderer(waveformWidget),
m_isSlipRenderer(type == ::WaveformRendererAbstract::Slip) {
}
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/renderers/allshader/waveformrendererpreroll.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/waveform/renderers/allshader/waveformrendererrgb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/renderers/allshader/waveformrendererrgb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 13 additions & 9 deletions src/waveform/renderers/allshader/waveformrendererslipmode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,38 @@
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 {

WaveformRendererSlipMode::WaveformRendererSlipMode(
WaveformWidgetRenderer* waveformWidget)
: WaveformRenderer(waveformWidget),
m_pSlipMode(nullptr),
m_slipBorderTopOutlineSize(10.f),
m_slipBorderBottomOutlineSize(10.f) {
}

bool WaveformRendererSlipMode::init() {
m_timer.restart();

m_pSlipMode.reset(new ControlProxy(
m_waveformRenderer->getGroup(), "slip_enabled"));
m_pSlipMode = std::make_unique<ControlProxy>(
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);
Expand All @@ -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<double>(2 * abs(elapsed - kBlinkingPeriodMillis / 2)) /
kBlinkingPeriodMillis;

const double alpha = 0.25 + 0.5 * blinkIntensity;
Expand Down Expand Up @@ -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<float>(m_waveformRenderer->getLength()) / 2,
static_cast<float>(m_waveformRenderer->getBreadth()) / 2);

glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

Expand Down
5 changes: 1 addition & 4 deletions src/waveform/renderers/allshader/waveformrendererslipmode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/renderers/allshader/waveformrendermark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/renderers/allshader/waveformrendermark.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/renderers/waveformrendererabstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
9 changes: 4 additions & 5 deletions src/waveform/renderers/waveformwidgetrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -168,7 +167,7 @@ void WaveformWidgetRenderer::onPreRender(VSyncThread* vsyncThread) {

m_totalVSamples = static_cast<int>(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.
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/waveform/renderers/waveformwidgetrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand All @@ -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
Expand All @@ -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];
}
Expand Down

0 comments on commit 115ea94

Please sign in to comment.