Esempio n. 1
0
void
LoopRuler::mouseMoveEvent(QMouseEvent *mE)
{
    // If we are still using the default grid, that means we are being
    // used by the TrackEditor (instead of the MatrixEditor).
    if (m_grid == &m_defaultGrid) {
        // If the ctrl key is pressed, enable snap to beat
        if ((mE->modifiers() & Qt::ControlModifier) != 0)
            m_defaultGrid.setSnapTime(SnapGrid::SnapToBeat);
        else
            m_defaultGrid.setSnapTime(SnapGrid::NoSnap);
    }

    double x = mouseEventToSceneX(mE);
    if (x < 0)
        x = 0;

    if (m_loopingMode) {
        if (m_loopGrid->snapX(x) != m_endLoop) {
            m_endLoop = m_loopGrid->snapX(x);
            emit dragLoopToPosition(m_endLoop);
            update();
        }
    } else {
        emit dragPointerToPosition(m_grid->snapX(x));

        m_lastMouseXPos = x;

    }

    emit mouseMove();
}
Esempio n. 2
0
void StandardRuler::connectRulerToDocPointer(RosegardenDocument *doc)
{
    RG_DEBUG << "StandardRuler::connectRulerToDocPointer";

    Q_ASSERT(m_loopRuler);
    Q_ASSERT(m_markerRuler);

    // use the document as a hub for pointer and loop set related signals
    // pointer and loop drag signals are specific to the current view,
    // so they are re-emitted from the loop ruler by this widget
    //
    QObject::connect
    (m_loopRuler, SIGNAL(setPointerPosition(timeT)),
     doc, SLOT(slotSetPointerPosition(timeT)));

    QObject::connect
    (m_markerRuler, SIGNAL(setPointerPosition(timeT)),
     doc, SLOT(slotSetPointerPosition(timeT)));

    QObject::connect
    (m_loopRuler, SIGNAL(dragPointerToPosition(timeT)),
     this, SIGNAL(dragPointerToPosition(timeT)));

    QObject::connect
    (m_loopRuler, SIGNAL(dragLoopToPosition(timeT)),
     this, SIGNAL(dragLoopToPosition(timeT)));

    QObject::connect
    (m_markerRuler, SIGNAL(setLoop(timeT, timeT)),
     doc, SLOT(slotSetLoop(timeT, timeT)));

    QObject::connect
    (m_loopRuler, SIGNAL(setLoop(timeT, timeT)),
     doc, SLOT(slotSetLoop(timeT, timeT)));

    QObject::connect
    (doc, SIGNAL(loopChanged(timeT, timeT)),
     m_loopRuler,
     SLOT(slotSetLoopMarker(timeT, timeT)));

//    m_loopRuler->setBackgroundColor(GUIPalette::getColour(GUIPalette::PointerRuler));
}
Esempio n. 3
0
void
LoopRuler::mousePressEvent(QMouseEvent *mE)
{
    RG_DEBUG << "LoopRuler::mousePressEvent: x = " << mE->x() << endl;

    setLoopingMode((mE->modifiers() & Qt::ShiftModifier) != 0);

    if (mE->button() == Qt::LeftButton) {
        double x = mouseEventToSceneX(mE);

        if (m_loopingMode) {
            m_endLoop = m_startLoop = m_loopGrid->snapX(x);
        } else {
            // If we are still using the default grid, that means we are being
            // used by the TrackEditor (instead of the MatrixEditor).
            if (m_grid == &m_defaultGrid) {
                // If the ctrl key is pressed, enable snap to beat
                if ((mE->modifiers() & Qt::ControlModifier) != 0)
                    m_defaultGrid.setSnapTime(SnapGrid::SnapToBeat);
                else
                    m_defaultGrid.setSnapTime(SnapGrid::NoSnap);
            }
            
            // No -- now that we're emitting when the button is
            // released, we _don't_ want to emit here as well --
            // otherwise we get an irritating stutter when simply
            // clicking on the ruler during playback
//RG_DEBUG << "emitting setPointerPosition(" << 
//    m_rulerScale->getTimeForX(x) << ")" << endl;
//            emit setPointerPosition(m_rulerScale->getTimeForX(x));

            // But we want to see the pointer under the mouse as soon as the
            // button is pressed, before we begin to drag it.
            emit dragPointerToPosition(m_grid->snapX(x));

            m_lastMouseXPos = x;

        }

        m_activeMousePress = true;
        emit startMouseMove(RosegardenScrollView::FollowHorizontal);
    }
}