📄 matrixview.cpp
字号:
getStaff(segment)->positionElements(std::min(startA, startB), std::max(endA, endB)); } else { // mark refresh status and then request a repaint segment.getRefreshStatus (m_segmentsRefreshStatusIds [getStaff(segment)->getId()]). push(std::min(startA, startB), std::max(endA, endB)); } } else { // do two refreshes, one for each -- here we know neither is null if (redrawNow) { // recolour the events now getStaff(oldSelection->getSegment())->positionElements(startA, endA); getStaff(s->getSegment())->positionElements(startB, endB); } else { // mark refresh status and then request a repaint oldSelection->getSegment().getRefreshStatus (m_segmentsRefreshStatusIds [getStaff(oldSelection->getSegment())->getId()]). push(startA, endA); s->getSegment().getRefreshStatus (m_segmentsRefreshStatusIds [getStaff(s->getSegment())->getId()]). push(startB, endB); } } } delete oldSelection; if (s) { int eventsSelected = s->getSegmentEvents().size(); m_selectionCounter->setText (i18n(" 1 event selected ", " %n events selected ", eventsSelected)); } else { m_selectionCounter->setText(i18n(" No selection ")); } m_selectionCounter->update(); slotSetCurrentVelocityFromSelection(); // Clear states first, then enter only those ones that apply // (so as to avoid ever clearing one after entering another, in // case the two overlap at all) stateChanged("have_selection", KXMLGUIClient::StateReverse); stateChanged("have_notes_in_selection", KXMLGUIClient::StateReverse); stateChanged("have_rests_in_selection", KXMLGUIClient::StateReverse); if (s) { stateChanged("have_selection", KXMLGUIClient::StateNoReverse); if (s->contains(Note::EventType)) { stateChanged("have_notes_in_selection", KXMLGUIClient::StateNoReverse); } if (s->contains(Note::EventRestType)) { stateChanged("have_rests_in_selection", KXMLGUIClient::StateNoReverse); } } updateQuantizeCombo(); if (redrawNow) updateView(); else update();}void MatrixView::updateQuantizeCombo(){ timeT unit = 0; if (m_currentEventSelection) { unit = BasicQuantizer::getStandardQuantization (m_currentEventSelection); } else { unit = BasicQuantizer::getStandardQuantization (&(m_staffs[0]->getSegment())); } for (unsigned int i = 0; i < m_quantizations.size(); ++i) { if (unit == m_quantizations[i]) { m_quantizeCombo->setCurrentItem(i); return ; } } m_quantizeCombo->setCurrentItem(m_quantizeCombo->count() - 1); // "Off"}void MatrixView::slotPaintSelected(){ EditTool* painter = m_toolBox->getTool(MatrixPainter::ToolName); setTool(painter);}void MatrixView::slotEraseSelected(){ EditTool* eraser = m_toolBox->getTool(MatrixEraser::ToolName); setTool(eraser);}void MatrixView::slotSelectSelected(){ EditTool* selector = m_toolBox->getTool(MatrixSelector::ToolName); connect(selector, SIGNAL(gotSelection()), this, SLOT(slotNewSelection())); connect(selector, SIGNAL(editTriggerSegment(int)), this, SIGNAL(editTriggerSegment(int))); setTool(selector);}void MatrixView::slotMoveSelected(){ EditTool* mover = m_toolBox->getTool(MatrixMover::ToolName); setTool(mover);}void MatrixView::slotResizeSelected(){ EditTool* resizer = m_toolBox->getTool(MatrixResizer::ToolName); setTool(resizer);}void MatrixView::slotTransformsQuantize(){ if (!m_currentEventSelection) return ; QuantizeDialog dialog(this); if (dialog.exec() == QDialog::Accepted) { KTmpStatusMsg msg(i18n("Quantizing..."), this); addCommandToHistory(new EventQuantizeCommand (*m_currentEventSelection, dialog.getQuantizer())); }}void MatrixView::slotTransformsRepeatQuantize(){ if (!m_currentEventSelection) return ; KTmpStatusMsg msg(i18n("Quantizing..."), this); addCommandToHistory(new EventQuantizeCommand (*m_currentEventSelection, "Quantize Dialog Grid", false)); // no i18n (config group name)}void MatrixView::slotTransformsCollapseNotes(){ if (!m_currentEventSelection) return ; KTmpStatusMsg msg(i18n("Collapsing notes..."), this); addCommandToHistory(new CollapseNotesCommand (*m_currentEventSelection));}void MatrixView::slotTransformsLegato(){ if (!m_currentEventSelection) return ; KTmpStatusMsg msg(i18n("Making legato..."), this); addCommandToHistory(new EventQuantizeCommand (*m_currentEventSelection, new LegatoQuantizer(0))); // no quantization}void MatrixView::slotMousePressed(timeT time, int pitch, QMouseEvent* e, MatrixElement* el){ MATRIX_DEBUG << "MatrixView::mousePressed at pitch " << pitch << ", time " << time << endl; // Don't allow moving/insertion before the beginning of the // segment timeT curSegmentStartTime = getCurrentSegment()->getStartTime(); if (curSegmentStartTime > time) time = curSegmentStartTime; m_tool->handleMousePress(time, pitch, 0, e, el); if (e->button() != RightButton) { getCanvasView()->startAutoScroll(); } // play a preview //playPreview(pitch);}void MatrixView::slotMouseMoved(timeT time, int pitch, QMouseEvent* e){ // Don't allow moving/insertion before the beginning of the // segment timeT curSegmentStartTime = getCurrentSegment()->getStartTime(); if (curSegmentStartTime > time) time = curSegmentStartTime; if (activeItem()) { activeItem()->handleMouseMove(e); updateView(); } else { int follow = m_tool->handleMouseMove(time, pitch, e); getCanvasView()->setScrollDirectionConstraint(follow); // if (follow != RosegardenCanvasView::NoFollow) { // getCanvasView()->doAutoScroll(); // } // play a preview if (pitch != m_previousEvPitch) { //playPreview(pitch); m_previousEvPitch = pitch; } }}void MatrixView::slotMouseReleased(timeT time, int pitch, QMouseEvent* e){ // Don't allow moving/insertion before the beginning of the // segment timeT curSegmentStartTime = getCurrentSegment()->getStartTime(); if (curSegmentStartTime > time) time = curSegmentStartTime; if (activeItem()) { activeItem()->handleMouseRelease(e); setActiveItem(0); updateView(); } // send the real event time now (not adjusted for beginning of bar) m_tool->handleMouseRelease(time, pitch, e); m_previousEvPitch = 0; getCanvasView()->stopAutoScroll();}voidMatrixView::slotHoveredOverNoteChanged(int evPitch, bool haveEvent, timeT evTime){ MidiPitchLabel label(evPitch); if (haveEvent) { m_haveHoveredOverNote = true; int bar, beat, fraction, remainder; getDocument()->getComposition().getMusicalTimeForAbsoluteTime (evTime, bar, beat, fraction, remainder); RealTime rt = getDocument()->getComposition().getElapsedRealTime(evTime); long ms = rt.msec(); QString msg = i18n("Note: %1 (%2.%3s)") .arg(QString("%1-%2-%3-%4") .arg(QString("%1").arg(bar + 1).rightJustify(3, '0')) .arg(QString("%1").arg(beat).rightJustify(2, '0')) .arg(QString("%1").arg(fraction).rightJustify(2, '0')) .arg(QString("%1").arg(remainder).rightJustify(2, '0'))) .arg(rt.sec) .arg(QString("%1").arg(ms).rightJustify(3, '0')); m_hoveredOverAbsoluteTime->setText(msg); } m_haveHoveredOverNote = false; m_hoveredOverNoteName->setText(i18n("%1 (%2)") .arg(label.getQString()) .arg(evPitch)); m_pitchRuler->drawHoverNote(evPitch);}voidMatrixView::slotHoveredOverKeyChanged(unsigned int y){ MatrixStaff& staff = *(m_staffs[0]); int evPitch = staff.getHeightAtCanvasCoords( -1, y); if (evPitch != m_previousEvPitch) { MidiPitchLabel label(evPitch); m_hoveredOverNoteName->setText(QString("%1 (%2)"). arg(label.getQString()).arg(evPitch)); m_previousEvPitch = evPitch; }}voidMatrixView::slotHoveredOverAbsoluteTimeChanged(unsigned int time){ if (m_haveHoveredOverNote) return; timeT t = time; int bar, beat, fraction, remainder; getDocument()->getComposition().getMusicalTimeForAbsoluteTime (t, bar, beat, fraction, remainder); RealTime rt = getDocument()->getComposition().getElapsedRealTime(t); long ms = rt.msec(); // At the advice of doc.trolltech.com/3.0/qstring.html#sprintf // we replaced this QString format("%ld (%ld.%03lds)"); // to support Unicode QString message = i18n("Time: %1 (%2.%3s)") .arg(QString("%1-%2-%3-%4") .arg(QString("%1").arg(bar + 1).rightJustify(3, '0')) .arg(QString("%1").arg(beat).rightJustify(2, '0')) .arg(QString("%1").arg(fraction).rightJustify(2, '0')) .arg(QString("%1").arg(remainder).rightJustify(2, '0'))) .arg(rt.sec) .arg(QString("%1").arg(ms).rightJustify(3, '0')); m_hoveredOverAbsoluteTime->setText(message);}voidMatrixView::slotSetPointerPosition(timeT time){ slotSetPointerPosition(time, m_playTracking);}voidMatrixView::slotSetPointerPosition(timeT time, bool scroll){ Composition &comp = getDocument()->getComposition(); int barNo = comp.getBarNumber(time); if (barNo >= m_hlayout.getLastVisibleBarOnStaff(*m_staffs[0])) { Segment &seg = m_staffs[0]->getSegment(); if (seg.isRepeating() && time < seg.getRepeatEndTime()) { time = seg.getStartTime() + ((time - seg.getStartTime()) % (seg.getEndMarkerTime() - seg.getStartTime())); m_staffs[0]->setPointerPosition(m_hlayout, time); } else { m_staffs[0]->hidePointer(); scroll = false; } } else if (barNo < m_hlayout.getFirstVisibleBarOnStaff(*m_staffs[0])) { m_staffs[0]->hidePointer(); scroll = false; } else { m_staffs[0]->setPointerPosition(m_hlayout, time); } if (scroll && !getCanvasView()->isAutoScrolling()) getCanvasView()->slotScrollHoriz(static_cast<int>(getXbyWorldMatrix(m_hlayout.getXForTime(time)))); updateView();}voidMatrixView::slotSetInsertCursorPosition(timeT time, bool scroll){ //!!! For now. Probably unlike slotSetPointerPosition this one // should snap to the nearest event or grid line. m_staffs[0]->setInsertCursorPosition(m_hlayout, time); if (scroll && !getCanvasView()->isAutoScrolling()) { getCanvasView()->slotScrollHoriz (static_cast<int>(getXbyWorldMatrix(m_hlayout.getXForTime(time))));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -