示例#1
0
void TimeLineCells::mouseMoveEvent( QMouseEvent* event )
{
    if ( m_eType == TIMELINE_CELL_TYPE::Layers )
    {
        endY = event->pos().y();
        emit mouseMovedY( endY - startY );
    }
    int frameNumber = getFrameNumber( event->pos().x() );
    //int layerNumber = getLayerNumber( event->pos().y() );

    if ( m_eType == TIMELINE_CELL_TYPE::Tracks )
    {
        if ( timeLine->scrubbing )
        {
            mEditor->scrubTo( frameNumber );
        }
        else
        {
            if ( startLayerNumber != -1 && startLayerNumber < mEditor->object()->getLayerCount() )
            {
                Layer *currentLayer = mEditor->object()->getLayer(startLayerNumber);

                // Did we move to another frame ?
                //
                if ( frameNumber != lastFrameNumber ) {

                    // Check if the frame we clicked was selected
                    //
                    if ( canMoveFrame ) {

                        // If it is the case, we move the selected frames in the layer
                        //
                        movingFrames        = true;

                        int offset = frameNumber - lastFrameNumber;
                        currentLayer->moveSelectedFrames(offset);

                        mEditor->updateCurrentFrame();

                    }
                    else if ( canBoxSelect ){

                        // Otherwise, we do a box select
                        //
                        boxSelecting        = true;

                        currentLayer->deselectAll();
                        currentLayer->setFrameSelected(startFrameNumber, true);
                        currentLayer->extendSelectionTo(frameNumber);
                    }

                    lastFrameNumber = frameNumber;
                }

                currentLayer->mouseMove( event, frameNumber );
            }
        }
    }
    timeLine->update();
}
示例#2
0
void TimeLineCells::mouseReleaseEvent( QMouseEvent* event )
{
    qDebug( "TimeLineCell: mouse release event." );
    if ( event->button() != primaryButton ) return;

    primaryButton = Qt::NoButton;
    endY = startY;
    emit mouseMovedY( 0 );
    timeLine->scrubbing = false;
    int frameNumber = getFrameNumber( event->pos().x() );
    if ( frameNumber < 1 ) frameNumber = -1;
    int layerNumber = getLayerNumber( event->pos().y() );
    if ( m_eType == TIMELINE_CELL_TYPE::Tracks && primaryButton != Qt::MidButton && layerNumber != -1 && layerNumber < mEditor->object()->getLayerCount() )
    {
        Layer *currentLayer = mEditor->object()->getLayer(layerNumber);

        if (!timeLine->scrubbing && !movingFrames && !clickSelecting && !boxSelecting ) {

            // Deselecting if we didn't move, scrub nor select anything
            //
            if ( event->modifiers() == Qt::ControlModifier ) {
                // Add/remove from already selected
                currentLayer->toggleFrameSelected(frameNumber, true);
            }
            else {
                currentLayer->toggleFrameSelected(frameNumber, false);
            }
        }

        currentLayer->mouseRelease( event, frameNumber );
    }
    if ( m_eType == TIMELINE_CELL_TYPE::Layers && layerNumber != startLayerNumber && startLayerNumber != -1 && layerNumber != -1 )
    {
        mEditor->moveLayer( startLayerNumber, layerNumber );
    }
    timeLine->updateContent();
}