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

TimingView.cc

Blame
  • TimingView.cc 1,21 Kio
    #include "TimingView.hh"
    
    using namespace Vivy;
    
    TimingView::TimingView(QGraphicsScene *scene, QImage img, AudioContext::StreamPtr stream,
                           QWidget *parent) noexcept
        : QGraphicsView(scene, parent)
        , audioStream(stream)
    {
        setMouseTracking(true);
        int interestingViewHeight = int(scene->height() + horizontalScrollBar()->height());
        setFixedHeight(interestingViewHeight);
        setMaximumHeight(interestingViewHeight);
    
        setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
        setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum);
        QObject::connect(verticalScrollBar(), &QScrollBar::rangeChanged, this,
                         &TimingView::moveScrollBarToBottom);
    
        // We want to see the bottom part of the spectrum, the top is less important if a few pixels get trimmed
        centerOn(0, interestingViewHeight);
    }
    
    void
    TimingView::wheelEvent(QWheelEvent *event) noexcept
    {
        horizontalScrollBar()->setValue(horizontalScrollBar()->value() -
                                        event->angleDelta().y() * wheelAngleToScrollRatio);
    }
    
    void
    TimingView::moveScrollBarToBottom(int, int max) noexcept
    {
        verticalScrollBar()->setValue(max);
    }