⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrixselector.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    	QTimer::singleShot(QApplication::doubleClickInterval(), this,    			   SLOT(slotClickTimeout()));        } */}void MatrixSelector::handleMouseTripleClick(timeT t,        int height,        int staffNo,        QMouseEvent *ev,        ViewElement *element){    if (!m_justSelectedBar)        return ;    m_justSelectedBar = false;    MatrixStaff *staff = m_mParentView->getStaff(staffNo);    if (!staff)        return ;    if (m_clickedElement) {        // should be safe, as we've already set m_justSelectedBar false        handleLeftButtonPress(t, height, staffNo, ev, element);        return ;    } else {        m_selectionRect->setX(staff->getX());        m_selectionRect->setY(staff->getY());        m_selectionRect->setSize(int(staff->getTotalWidth()) - 1,                                 staff->getTotalHeight() - 1);        m_selectionRect->show();        m_updateRect = false;    }}int MatrixSelector::handleMouseMove(timeT time, int height,                                    QMouseEvent *e){    QPoint p = m_mParentView->inverseMapPoint(e->pos());    if (m_dispatchTool) {        return m_dispatchTool->handleMouseMove(time, height, e);    }    if (!m_updateRect) {        setContextHelpFor(e->pos(),                           getSnapGrid().getSnapSetting() == SnapGrid::NoSnap);        return RosegardenCanvasView::NoFollow;    } else {        clearContextHelp();    }    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_mParentView->canvas()->update();    return RosegardenCanvasView::FollowHorizontal | RosegardenCanvasView::FollowVertical;}void MatrixSelector::handleMouseRelease(timeT time, int height, QMouseEvent *e){    MATRIX_DEBUG << "MatrixSelector::handleMouseRelease" << endl;    if (m_dispatchTool) {        m_dispatchTool->handleMouseRelease(time, height, 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_mParentView->setSingleSelectedEvent(m_currentStaff->getSegment(),                                              m_clickedElement->event(),                                              false, true);        m_mParentView->canvas()->update();        m_clickedElement = 0;    } else if (m_selectionRect) {        setViewCurrentSelection();        m_selectionRect->hide();        m_mParentView->canvas()->update();    }    // Tell anyone who's interested that the selection has changed    emit gotSelection();    setContextHelpFor(e->pos());}void MatrixSelector::ready(){    if (m_mParentView) {        m_selectionRect = new QCanvasRectangle(m_mParentView->canvas());        m_selectionRect->hide();        m_selectionRect->setPen(QPen(GUIPalette::getColour(GUIPalette::SelectionRectangle), 2));        m_mParentView->setCanvasCursor(Qt::arrowCursor);        //m_mParentView->setPositionTracking(false);    }    connect(m_parentView->getCanvasView(), SIGNAL(contentsMoving (int, int)),            this, SLOT(slotMatrixScrolled(int, int)));    setContextHelp(i18n("Click and drag to select; middle-click and drag to draw new note"));}void MatrixSelector::stow(){    if (m_selectionRect) {        delete m_selectionRect;        m_selectionRect = 0;        m_mParentView->canvas()->update();    }    disconnect(m_parentView->getCanvasView(), SIGNAL(contentsMoving (int, int)),               this, SLOT(slotMatrixScrolled(int, int)));}void MatrixSelector::slotHideSelection(){    if (!m_selectionRect)        return ;    m_selectionRect->hide();    m_selectionRect->setSize(0, 0);    m_mParentView->canvas()->update();}void MatrixSelector::slotMatrixScrolled(int newX, int newY){    if (m_updateRect) {        int offsetX = newX - m_parentView->getCanvasView()->contentsX();        int offsetY = newY - m_parentView->getCanvasView()->contentsY();        int w = int(m_selectionRect->width() + offsetX);        int h = int(m_selectionRect->height() + offsetY);        // Qt rectangle dimensions appear to be 1-based        if (w > 0)            ++w;        else            --w;        if (h > 0)            ++h;        else            --h;        m_selectionRect->setSize(w, h);        setViewCurrentSelection();        m_mParentView->canvas()->update();    }}void MatrixSelector::setViewCurrentSelection(){    EventSelection* selection = getSelection();    if (m_selectionToMerge && selection &&        m_selectionToMerge->getSegment() == selection->getSegment()) {                selection->addFromSelection(m_selectionToMerge);        m_mParentView->setCurrentSelection(selection, true, true);    } else if (!m_selectionToMerge) {        m_mParentView->setCurrentSelection(selection, true, true);    }}EventSelection* MatrixSelector::getSelection(){    if (!m_selectionRect->visible()) return 0;    Segment& originalSegment = m_currentStaff->getSegment();    EventSelection* selection = new EventSelection(originalSegment);    // get the selections    //    QCanvasItemList l = m_selectionRect->collisions(true);    if (l.count())    {        for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it)        {            QCanvasItem *item = *it;            QCanvasMatrixRectangle *matrixRect = 0;            if ((matrixRect = dynamic_cast<QCanvasMatrixRectangle*>(item)))            {                MatrixElement *mE = &matrixRect->getMatrixElement();                selection->addEvent(mE->event());            }        }    }    if (selection->getAddedEvents() > 0) {        return selection;    } else {        delete selection;        return 0;    }}void MatrixSelector::setContextHelpFor(QPoint p, bool ctrlPressed){    kapp->config()->setGroup(GeneralOptionsConfigGroup);    if (!kapp->config()->readBoolEntry("toolcontexthelp", true)) return;    p = m_mParentView->inverseMapPoint(p);    // same logic as in MatrixCanvasView::contentsMousePressEvent    QCanvasItemList itemList = m_mParentView->canvas()->collisions(p);    QCanvasItemList::Iterator it;    MatrixElement* mel = 0;    QCanvasItem* activeItem = 0;    for (it = itemList.begin(); it != itemList.end(); ++it) {        QCanvasItem *item = *it;        QCanvasMatrixRectangle *mRect = 0;        if (item->active()) {            break;        }        if ((mRect = dynamic_cast<QCanvasMatrixRectangle*>(item))) {            if (! mRect->rect().contains(p, true)) continue;            mel = &(mRect->getMatrixElement());            break;        }    }    if (!mel) {        setContextHelp(i18n("Click and drag to select; middle-click and drag to draw new note"));    } else {                // same logic as in handleMouseButtonPress                int x = int(mel->getLayoutX());        int width = mel->getWidth();        int resizeStart = int(double(width) * 0.85) + x;        // max size of 10        if ((x + width ) - resizeStart > 10)            resizeStart = x + width - 10;        EventSelection *s = m_mParentView->getCurrentSelection();        if (p.x() > resizeStart) {            if (s && s->getAddedEvents() > 1) {                setContextHelp(i18n("Click and drag to resize selected notes"));            } else {                setContextHelp(i18n("Click and drag to resize note"));            }        } else {            if (s && s->getAddedEvents() > 1) {                if (!ctrlPressed) {                    setContextHelp(i18n("Click and drag to move selected notes; hold Ctrl as well to copy"));                } else {                    setContextHelp(i18n("Click and drag to copy selected notes"));                }            } else {                if (!ctrlPressed) {                    setContextHelp(i18n("Click and drag to move note; hold Ctrl as well to copy"));                } else {                    setContextHelp(i18n("Click and drag to copy note"));                }            }                        }    }}const QString MatrixSelector::ToolName  = "selector";}#include "MatrixSelector.moc"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -