Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 0d135d43f0afc128b28e2f66512afe8796a32459
  • master par défaut
  • script
  • new-devel
  • devel
  • timingView-edit
  • fix-mpv
7 résultats

AudioVisualizer.hh

Blame
  • TimingAxis.hh 1,47 Kio
    #ifndef VIVY_TIMING_AXIS_H
    #define VIVY_TIMING_AXIS_H
    
    #ifndef __cplusplus
    #error "This is a C++ header"
    #endif
    
    #include <QGraphicsWidget>
    #include <QPainter>
    #include <QGraphicsScene>
    #include <cmath>
    #include "../../../Lib/Audio.hh"
    
    namespace Vivy
    {
    class TimingAxis final : public QGraphicsObject {
        Q_OBJECT
    
    public:
        explicit TimingAxis(AudioContext::StreamPtr stream, int x0, int x1, int y) noexcept;
        ~TimingAxis() noexcept override = default;
    
        QRectF boundingRect() const override;
        void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
    
    private:
        static inline constexpr QColor axisColour = QColor(0, 0, 127);
    
        qreal penWidth{ 1 };
        AudioContext::StreamPtr audioStream;
    
        /*
         * We use ints here because
         * qPainter->drawLine() and qPainter->drawText()
         * restrict us to ints anyways
         */
        QVector<quint64> availableTicks = { 10, 100, 1000, 10000, 60000, 3600000, 86400000 };
        quint64 minBetweenMinor{ 10 };
        quint64 minorTicks;
        quint64 majorTicks;
    
        int minorTicksHeight { 3  };
        int majorTicksHeight { 7  };
        int timeDigitsHeight { 20 };
        int timeDigitsMargin { 3  };
        int ticksBase        { 30 };
    
        int x0{ 0 };
        int x1{ 0 };
        int y{ 0 };
    
        QString msToString(quint64 i) const noexcept;
        inline quint64 posFromMs(quint64 t, quint64 width, quint64 length) const noexcept;
    
    protected:
    public slots:
        void refreshTicks();
    };
    
    }
    
    #endif // VIVY_TIMING_AXIS_H