Example #1
0
NotationSelector::FollowMode
NotationSelector::handleMouseMove(const NotationMouseEvent *e)
{
    if (!m_updateRect) return NoFollow;

//    std::cout << "NotationSelector::handleMouseMove: staff is " 
//              << m_selectedStaff << ", m_updateRect is " << m_updateRect
//              << std::endl;

    if (!m_selectedStaff) m_selectedStaff = e->staff;

    int w = int(e->sceneX - m_selectionRect->x());
    int h = int(e->sceneY - m_selectionRect->y());

    NOTATION_DEBUG << "NotationSelector::handleMouseMove:  w: " << w << " h: " << h << endl;

    if (m_clickedElement /* && !m_clickedElement->isRest() */) {

// Fine (micro-position) drag is BROKEN, and I'm bypassing its mangled corpse.        
//        if (m_startedFineDrag) {
//            dragFine(e->sceneX, e->sceneY, false);
//        } else if (m_clickedShift) {
//            if (w > 2 || w < -2 || h > 2 || h < -2) {
//                dragFine(e->sceneX, e->sceneY, false);
//           }
//        } else 
           
        if ((w > 3 || w < -3 || h > 3 || h < -3) &&
            !m_clickedShift) {
//            std::cout << "Dragging from Code Point Bravo: w: " << w << " h: " << h << std::endl;
            drag(e->sceneX, e->sceneY, false);
        }

    } else {

        // Qt rectangle dimensions appear to be 1-based
        if (w > 0) ++w;
        else --w;
        if (h > 0) ++h;
        else --h;

        QPointF p0(m_selectionOrigin);
        QPointF p1(e->sceneX, e->sceneY);
        QRectF r = QRectF(p0, p1).normalized();

        m_selectionRect->setRect(r.x() + 0.5, r.y() + 0.5, r.width(), r.height());
        m_selectionRect->show();

        setViewCurrentSelection(true);
    }

    return FollowMode(FollowHorizontal | FollowVertical);
}
Example #2
0
MatrixSelector::FollowMode
MatrixSelector::handleMouseMove(const MatrixMouseEvent *e)
{
    if (m_dispatchTool) {
        return m_dispatchTool->handleMouseMove(e);
    }

    if (!m_updateRect) {
        setContextHelpFor
            (e, getSnapGrid()->getSnapSetting() == SnapGrid::NoSnap);
        return NoFollow;
    } else {
        clearContextHelp();
    }

    QPointF p0(m_selectionOrigin);
    QPointF p1(e->sceneX, e->sceneY);
    QRectF r = QRectF(p0, p1).normalized();

    m_selectionRect->setRect(r.x() + 0.5, r.y() + 0.5, r.width(), r.height());
    m_selectionRect->show();

    setViewCurrentSelection(false);

    

/*
    int w = int(p.x() - m_selectionRect->x());
    int h = int(p.y() - m_selectionRect->y());

    // Qt rectangle dimensions appear to be 1-based
    if (w > 0)
        ++w;
    else
        --w;
    if (h > 0)
        ++h;
    else
        --h;

    // Workaround for #930420 Positional error in sweep-selection box boundary
    int wFix = (w > 0) ? 3 : 0;
    int hFix = (h > 0) ? 3 : 0;
    int xFix = (w < 0) ? 3 : 0;
    m_selectionRect->setSize(w - wFix, h - hFix);
    m_selectionRect->setX(m_selectionRect->x() + xFix);
    setViewCurrentSelection();
    m_selectionRect->setSize(w, h);
    m_selectionRect->setX(m_selectionRect->x() - xFix);
    m_widget->canvas()->update();
*/
    return FollowMode(FollowHorizontal | FollowVertical);
}
Example #3
0
void
MatrixSelector::handleMouseRelease(const MatrixMouseEvent *e)
{
    MATRIX_DEBUG << "MatrixSelector::handleMouseRelease";

    if (m_dispatchTool) {
        m_dispatchTool->handleMouseRelease(e);

        m_dispatchTool->stow();
        ready();

        // don't delete the tool as it's still part of the toolbox
        m_dispatchTool = 0;

        return;
    }

    m_updateRect = false;

    if (m_clickedElement) {
        m_scene->setSingleSelectedEvent(m_currentViewSegment,
                                        m_clickedElement,
                                        false);
//        m_widget->canvas()->update();
        m_clickedElement = 0;

    } else if (m_selectionRect) {
        setViewCurrentSelection(true);
        m_previousCollisions.clear();
        m_selectionRect->hide();
//        m_widget->canvas()->update();
    }

    // Tell anyone who's interested that the selection has changed
    emit gotSelection();

    setContextHelpFor(e);
}
Example #4
0
void NotationSelector::handleMouseRelease(const NotationMouseEvent *e)
{
    NOTATION_DEBUG << "NotationSelector::handleMouseRelease" << endl;
    m_updateRect = false;

    // We can lose m_selectionRect since the click under some
    // conditions.
    if (!m_selectionRect) { return; }

    // Test how far we've moved from the original click position -- not
    // how big the rectangle is (if we were dragging an event, the
    // rectangle size will still be zero).

    int w = int(e->sceneX - m_selectionRect->x());
    int h = int(e->sceneY - m_selectionRect->y());

//    std::cout << "e->sceneX: " << e->sceneX << " Y: " << e->sceneY 
//              << " m_selectionRect->x(): " << m_selectionRect->x()
//              << " y(): " << m_selectionRect->y() << std::endl
//              << "w: " << w << " h: " << h << " m_startedFineDrag == " << m_startedFineDrag << std::endl;

    //!!! Deeper bug here, surely.  The code commented out above revealed
    // m_selectionRect was always (0,0) in every situation where I could get this
    // code to fire.  This makes the above values for w and h above completely
    // meaningless nonsense as far as I can see.
     
    if ((w > -3 && w < 3 && h > -3 && h < 3 && !m_startedFineDrag) ||
        (m_clickedShift)) {
      
        //!!! Removing this test is necessary in order to make it possible for
        // the user to drag a note and drop it somewhere.  I think it's all tied
        // up in the broken "fine drag" mechanism.  I'm honestly not sure about
        // much after a day of whacking moles, but it's safe to say this next
        // test is very detrimental, so it has been removed once again.
        // || (m_selectionRect->x() == 0 && m_selectionRect->y() == 0 && !m_startedFineDrag)*/) {

        if (m_clickedElement != 0 && m_selectedStaff) {
            
            // If we didn't drag out a meaningful area, but _did_
            // click on an individual event, then select just that
            // event

            if (m_selectionToMerge &&
                m_selectionToMerge->getSegment() ==
                m_selectedStaff->getSegment()) {

                // if the event was already part of the selection, we want to
                // remove it
                if (m_selectionToMerge->contains(m_clickedElement->event())) {
                    m_selectionToMerge->removeEvent(m_clickedElement->event(),
                                                    m_ties);
                } else {
                    m_selectionToMerge->addEvent(m_clickedElement->event(),
                                                 m_ties);
                }
                
                m_scene->setSelection(m_selectionToMerge, true);
                m_selectionToMerge = 0;

            } else {

                m_scene->setSingleSelectedEvent(m_selectedStaff, m_clickedElement, true);
            }
            /*
                    } else if (m_selectedStaff) {
             
                        // If we clicked on no event but on a staff, move the
                        // insertion cursor to the point where we clicked. 
                        // Actually we only really want this to happen if
                        // we aren't double-clicking -- consider using a timer
                        // to establish whether a double-click is going to happen
             
                        m_nParentView->slotSetInsertCursorPosition(e->x(), (int)e->y());
            */
        } else {
            setViewCurrentSelection(false);
        }

    } else {

// Fine (micro-position) drag is BROKEN, and I'm bypassing its mangled corpse.        
//        if (m_startedFineDrag) {
//            dragFine(e->sceneX, e->sceneY, true);
//        } else

        // in a world without fine drag, we do _not_ want to begin any kind of
        // drag operation if Shift was pressed, because this modifier can only
        // be used to make additive selections
        if (m_clickedElement &&
            !m_clickedShift /* &&
            !m_clickedElement->isRest() */) {
//            std::cout << "Dragging from Code Point Foxtrot: w: " << w << " h: " << h << std::endl;
            // drag() must be called here from Foxtrot, whether attempting to
            // click to select a note head or to click and drag a note.  It's
            // required in both cases, and neither case works without this call
            // here:
            drag(e->sceneX, e->sceneY, true);
        } else {
            setViewCurrentSelection(false);
        }
    }

    m_clickedElement = 0;
    m_selectionRect->hide();
    m_wholeStaffSelectionComplete = false;
}