diff options
Diffstat (limited to 'src/qml/qmlwaveformoverview.h')
-rw-r--r-- | src/qml/qmlwaveformoverview.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/src/qml/qmlwaveformoverview.h b/src/qml/qmlwaveformoverview.h new file mode 100644 index 0000000000..07f5602914 --- /dev/null +++ b/src/qml/qmlwaveformoverview.h @@ -0,0 +1,87 @@ +#pragma once + +#include <QPainter> +#include <QPointer> +#include <QQuickItem> +#include <QQuickPaintedItem> +#include <QtQml> + +#include "track/track.h" + +namespace mixxx { +namespace skin { +namespace qml { + +class QmlPlayerProxy; + +class QmlWaveformOverview : public QQuickPaintedItem { + Q_OBJECT + Q_FLAGS(Channels) + Q_PROPERTY(mixxx::skin::qml::QmlPlayerProxy* player READ getPlayer + WRITE setPlayer NOTIFY playerChanged) + Q_PROPERTY(Channels channels READ getChannels WRITE setChannels NOTIFY channelsChanged) + Q_PROPERTY(Renderer renderer MEMBER m_renderer NOTIFY rendererChanged) + Q_PROPERTY(QColor colorHigh MEMBER m_colorHigh NOTIFY colorHighChanged) + Q_PROPERTY(QColor colorMid MEMBER m_colorMid NOTIFY colorMidChanged) + Q_PROPERTY(QColor colorLow MEMBER m_colorLow NOTIFY colorLowChanged) + + public: + enum class ChannelFlag : int { + LeftChannel = 1, + RightChannel = 2, + BothChannels = LeftChannel | RightChannel, + }; + Q_DECLARE_FLAGS(Channels, ChannelFlag) + + enum class Renderer { + RGB = 1, + Filtered = 2, + }; + Q_ENUM(Renderer) + + QmlWaveformOverview(QQuickItem* parent = nullptr); + void paint(QPainter* painter); + + void setPlayer(QmlPlayerProxy* player); + QmlPlayerProxy* getPlayer() const; + + void setChannels(Channels channels); + Channels getChannels() const; + private slots: + void slotTrackLoaded(TrackPointer pLoadedTrack); + void slotTrackLoading(TrackPointer pNewTrack, TrackPointer pOldTrack); + void slotTrackUnloaded(); + void slotWaveformUpdated(); + + signals: + void playerChanged(); + void channelsChanged(mixxx::skin::qml::QmlWaveformOverview::Channels channels); + void rendererChanged(mixxx::skin::qml::QmlWaveformOverview::Renderer renderer); + void colorHighChanged(const QColor& color); + void colorMidChanged(const QColor& color); + void colorLowChanged(const QColor& color); + + private: + void setCurrentTrack(TrackPointer pTrack); + void drawFiltered(QPainter* pPainter, + Channels channels, + ConstWaveformPointer pWaveform, + int completion) const; + void drawRgb(QPainter* pPainter, + Channels channels, + ConstWaveformPointer pWaveform, + int completion) const; + QColor getRgbPenColor(ConstWaveformPointer pWaveform, int completion) const; + + QPointer<QmlPlayerProxy> m_pPlayer; + TrackPointer m_pCurrentTrack; + Channels m_channels; + Renderer m_renderer; + QColor m_colorHigh; + QColor m_colorMid; + QColor m_colorLow; +}; + +} // namespace qml +} // namespace skin +} // namespace mixxx |