📄 matrixview.cpp
字号:
icon = QIconSet(NotePixmapFactory::toQPixmap(NotePixmapFactory::makeToolbarPixmap ("transport-ffwd"))); new KAction(i18n("&Fast Forward"), icon, Key_PageDown, this, SIGNAL(fastForwardPlayback()), actionCollection(), "playback_pointer_forward_bar"); icon = QIconSet(NotePixmapFactory::toQPixmap(NotePixmapFactory::makeToolbarPixmap ("transport-rewind-end"))); new KAction(i18n("Rewind to &Beginning"), icon, 0, this, SIGNAL(rewindPlaybackToBeginning()), actionCollection(), "playback_pointer_start"); icon = QIconSet(NotePixmapFactory::toQPixmap(NotePixmapFactory::makeToolbarPixmap ("transport-ffwd-end"))); new KAction(i18n("Fast Forward to &End"), icon, 0, this, SIGNAL(fastForwardPlaybackToEnd()), actionCollection(), "playback_pointer_end"); icon = QIconSet(NotePixmapFactory::toQPixmap(NotePixmapFactory::makeToolbarPixmap ("transport-pointer-to-cursor"))); new KAction(i18n("Playback Pointer to &Cursor"), icon, 0, this, SLOT(slotJumpPlaybackToCursor()), actionCollection(), "playback_pointer_to_cursor"); icon = QIconSet(NotePixmapFactory::toQPixmap(NotePixmapFactory::makeToolbarPixmap ("transport-solo"))); new KToggleAction(i18n("&Solo"), icon, 0, this, SLOT(slotToggleSolo()), actionCollection(), "toggle_solo"); icon = QIconSet(NotePixmapFactory::toQPixmap(NotePixmapFactory::makeToolbarPixmap ("transport-tracking"))); (new KToggleAction(i18n("Scro&ll to Follow Playback"), icon, Key_Pause, this, SLOT(slotToggleTracking()), actionCollection(), "toggle_tracking"))->setChecked(m_playTracking); icon = QIconSet(NotePixmapFactory::toQPixmap(NotePixmapFactory::makeToolbarPixmap ("transport-panic"))); new KAction(i18n("Panic"), icon, Key_P + CTRL + ALT, this, SIGNAL(panic()), actionCollection(), "panic"); new KAction(i18n("Set Loop to Selection"), Key_Semicolon + CTRL, this, SLOT(slotPreviewSelection()), actionCollection(), "preview_selection"); new KAction(i18n("Clear L&oop"), Key_Colon + CTRL, this, SLOT(slotClearLoop()), actionCollection(), "clear_loop"); new KAction(i18n("Clear Selection"), Key_Escape, this, SLOT(slotClearSelection()), actionCollection(), "clear_selection"); // icon = QIconSet(QCanvasPixmap(pixmapDir + "/toolbar/eventfilter.xpm")); new KAction(i18n("&Filter Selection"), "filter", Key_F + CTRL, this, SLOT(slotFilterSelection()), actionCollection(), "filter_selection"); timeT crotchetDuration = Note(Note::Crotchet).getDuration(); m_snapValues.push_back(SnapGrid::NoSnap); m_snapValues.push_back(SnapGrid::SnapToUnit); m_snapValues.push_back(crotchetDuration / 16); m_snapValues.push_back(crotchetDuration / 12); m_snapValues.push_back(crotchetDuration / 8); m_snapValues.push_back(crotchetDuration / 6); m_snapValues.push_back(crotchetDuration / 4); m_snapValues.push_back(crotchetDuration / 3); m_snapValues.push_back(crotchetDuration / 2); m_snapValues.push_back(crotchetDuration); m_snapValues.push_back((crotchetDuration * 3) / 2); m_snapValues.push_back(crotchetDuration * 2); m_snapValues.push_back(SnapGrid::SnapToBeat); m_snapValues.push_back(SnapGrid::SnapToBar); for (unsigned int i = 0; i < m_snapValues.size(); i++) { timeT d = m_snapValues[i]; if (d == SnapGrid::NoSnap) { new KAction(i18n("&No Snap"), 0, this, SLOT(slotSetSnapFromAction()), actionCollection(), "snap_none"); } else if (d == SnapGrid::SnapToUnit) { } else if (d == SnapGrid::SnapToBeat) { new KAction(i18n("Snap to Bea&t"), Key_1, this, SLOT(slotSetSnapFromAction()), actionCollection(), "snap_beat"); } else if (d == SnapGrid::SnapToBar) { new KAction(i18n("Snap to &Bar"), Key_5, this, SLOT(slotSetSnapFromAction()), actionCollection(), "snap_bar"); } else { timeT err = 0; QString label = NotationStrings::makeNoteMenuLabel(d, true, err); QPixmap pixmap = NotePixmapFactory::toQPixmap (NotePixmapFactory::makeNoteMenuPixmap(d, err)); KShortcut cut = 0; if (d == crotchetDuration / 16) cut = Key_0; else if (d == crotchetDuration / 8) cut = Key_3; else if (d == crotchetDuration / 4) cut = Key_6; else if (d == crotchetDuration / 2) cut = Key_8; else if (d == crotchetDuration) cut = Key_4; else if (d == crotchetDuration * 2) cut = Key_2; QString actionName = QString("snap_%1").arg(int((crotchetDuration * 4) / d)); if (d == (crotchetDuration * 3) / 2) actionName = "snap_3"; new KAction(i18n("Snap to %1").arg(label), pixmap, cut, this, SLOT(slotSetSnapFromAction()), actionCollection(), actionName); } } // // Settings menu // new KAction(i18n("Show Instrument Parameters"), 0, this, SLOT(slotDockParametersBack()), actionCollection(), "show_inst_parameters"); new KToggleAction(i18n("Show Ch&ord Name Ruler"), 0, this, SLOT(slotToggleChordsRuler()), actionCollection(), "show_chords_ruler"); new KToggleAction(i18n("Show &Tempo Ruler"), 0, this, SLOT(slotToggleTempoRuler()), actionCollection(), "show_tempo_ruler"); createGUI(getRCFileName(), false); if (getSegmentsOnlyRestsAndClefs()) actionCollection()->action("draw")->activate(); else actionCollection()->action("select")->activate();}boolMatrixView::isInChordMode(){ return ((KToggleAction *)actionCollection()->action("chord_mode"))-> isChecked();}void MatrixView::slotDockParametersBack(){ m_dockLeft->dockBack();}void MatrixView::slotParametersClosed(){ stateChanged("parametersbox_closed"); m_dockVisible = false;}void MatrixView::slotParametersDockedBack(KDockWidget* dw, KDockWidget::DockPosition){ if (dw == m_dockLeft) { stateChanged("parametersbox_closed", KXMLGUIClient::StateReverse); m_dockVisible = true; }}void MatrixView::slotCheckTrackAssignments(){ Track *track = m_staffs[0]->getSegment().getComposition()-> getTrackById(m_staffs[0]->getSegment().getTrack()); Instrument *instr = getDocument()->getStudio(). getInstrumentById(track->getInstrument()); m_parameterBox->useInstrument(instr);}void MatrixView::initStatusBar(){ KStatusBar* sb = statusBar(); m_hoveredOverAbsoluteTime = new QLabel(sb); m_hoveredOverNoteName = new QLabel(sb); m_hoveredOverAbsoluteTime->setMinimumWidth(175); m_hoveredOverNoteName->setMinimumWidth(65); sb->addWidget(m_hoveredOverAbsoluteTime); sb->addWidget(m_hoveredOverNoteName); m_insertModeLabel = new QLabel(sb); m_insertModeLabel->setMinimumWidth(20); sb->addWidget(m_insertModeLabel); sb->insertItem(KTmpStatusMsg::getDefaultMsg(), KTmpStatusMsg::getDefaultId(), 1); sb->setItemAlignment(KTmpStatusMsg::getDefaultId(), AlignLeft | AlignVCenter); m_selectionCounter = new QLabel(sb); sb->addWidget(m_selectionCounter);}void MatrixView::slotToolHelpChanged(const QString &s){ QString msg = " " + s; if (m_toolContextHelp == msg) return; m_toolContextHelp = msg; m_config->setGroup(GeneralOptionsConfigGroup); if (!m_config->readBoolEntry("toolcontexthelp", true)) return; if (m_mouseInCanvasView) statusBar()->changeItem(m_toolContextHelp, 1);}void MatrixView::slotMouseEnteredCanvasView(){ m_config->setGroup(GeneralOptionsConfigGroup); if (!m_config->readBoolEntry("toolcontexthelp", true)) return; m_mouseInCanvasView = true; statusBar()->changeItem(m_toolContextHelp, 1);}void MatrixView::slotMouseLeftCanvasView(){ m_mouseInCanvasView = false; statusBar()->changeItem(KTmpStatusMsg::getDefaultMsg(), 1);}bool MatrixView::applyLayout(int staffNo, timeT startTime, timeT endTime){ Profiler profiler("MatrixView::applyLayout", true); m_hlayout.reset(); m_vlayout.reset(); for (unsigned int i = 0; i < m_staffs.size(); ++i) { if (staffNo >= 0 && (int)i != staffNo) continue; m_hlayout.scanStaff(*m_staffs[i], startTime, endTime); m_vlayout.scanStaff(*m_staffs[i], startTime, endTime); } m_hlayout.finishLayout(); m_vlayout.finishLayout(); if (m_staffs[0]->getSegment().getEndMarkerTime() != m_lastEndMarkerTime || m_lastEndMarkerTime == 0 || isCompositionModified()) { readjustCanvasSize(); m_lastEndMarkerTime = m_staffs[0]->getSegment().getEndMarkerTime(); } return true;}void MatrixView::refreshSegment(Segment *segment, timeT startTime, timeT endTime){ Profiler profiler("MatrixView::refreshSegment", true); MATRIX_DEBUG << "MatrixView::refreshSegment(" << startTime << ", " << endTime << ")\n"; applyLayout( -1, startTime, endTime); if (!segment) segment = m_segments[0]; if (endTime == 0) endTime = segment->getEndTime(); else if (startTime == endTime) { startTime = segment->getStartTime(); endTime = segment->getEndTime(); } m_staffs[0]->positionElements(startTime, endTime); repaintRulers();}QSize MatrixView::getViewSize(){ return canvas()->size();}void MatrixView::setViewSize(QSize s){ MATRIX_DEBUG << "MatrixView::setViewSize() w = " << s.width() << endl; canvas()->resize(getXbyInverseWorldMatrix(s.width()), s.height()); getCanvasView()->resizeContents(s.width(), s.height()); MATRIX_DEBUG << "MatrixView::setViewSize() contentsWidth = " << getCanvasView()->contentsWidth() << endl;}void MatrixView::repaintRulers(){ for (unsigned int i = 0; i != m_propertyViewRulers.size(); i++) m_propertyViewRulers[i].first->repaint();}void MatrixView::updateView(){ canvas()->update();}void MatrixView::setCurrentSelection(EventSelection* s, bool preview, bool redrawNow){ //!!! rather too much here shared with notationview -- could much of // this be in editview? if (m_currentEventSelection == s) { updateQuantizeCombo(); return ; } if (m_currentEventSelection) { getStaff(0)->positionElements(m_currentEventSelection->getStartTime(), m_currentEventSelection->getEndTime()); } EventSelection *oldSelection = m_currentEventSelection; m_currentEventSelection = s; timeT startA, endA, startB, endB; if (oldSelection) { startA = oldSelection->getStartTime(); endA = oldSelection->getEndTime(); startB = s ? s->getStartTime() : startA; endB = s ? s->getEndTime() : endA; } else { // we know they can't both be null -- first thing we tested above startA = startB = s->getStartTime(); endA = endB = s->getEndTime(); } // refreshSegment takes start==end to mean refresh everything if (startA == endA) ++endA; if (startB == endB) ++endB; bool updateRequired = true; if (s) { bool foundNewEvent = false; for (EventSelection::eventcontainer::iterator i = s->getSegmentEvents().begin(); i != s->getSegmentEvents().end(); ++i) { if (oldSelection && oldSelection->getSegment() == s->getSegment() && oldSelection->contains(*i)) continue; foundNewEvent = true; if (preview) { long pitch; if ((*i)->get<Int>(BaseProperties::PITCH, pitch)) { long velocity = -1; (void)((*i)->get<Int>(BaseProperties::VELOCITY, velocity)); if (!((*i)->has(BaseProperties::TIED_BACKWARD) && (*i)->get<Bool>(BaseProperties::TIED_BACKWARD))) playNote(s->getSegment(), pitch, velocity); } } } if (!foundNewEvent) { if (oldSelection && oldSelection->getSegment() == s->getSegment() && oldSelection->getSegmentEvents().size() == s->getSegmentEvents().size()) updateRequired = false; } } if (updateRequired) { if ((endA >= startB && endB >= startA) && (!s || !oldSelection || oldSelection->getSegment() == s->getSegment())) { Segment &segment(s ? s->getSegment() : oldSelection->getSegment()); if (redrawNow) { // recolour the events now
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -