📄 linedstaff.cpp
字号:
for (int gridLine = hidden ? 0 : 1; gridLine < gridLines; ++gridLine) { rect = new QCanvasRectangle (0, 0, barThickness, getBarLineHeight(), m_canvas); rect->moveBy(x + gridLine * dx, y); double currentGrid = gridLines / double(timeSig.getBeatsPerBar()); rect->setPen(GUIPalette::getColour(GUIPalette::BeatLine)); rect->setBrush(GUIPalette::getColour(GUIPalette::BeatLine)); // Reset to SubBeatLine colour if we're not a beat line - avoid div by zero! // if (currentGrid > 1.0 && double(gridLine) / currentGrid != gridLine / int(currentGrid)) { rect->setPen(GUIPalette::getColour(GUIPalette::SubBeatLine)); rect->setBrush(GUIPalette::getColour(GUIPalette::SubBeatLine)); } rect->setZ( -1); rect->show(); // show beat lines even if the bar lines are hidden LineRec beatLine(layoutX + gridLine * dx, rect); m_beatLines.push_back(beatLine); } } if (m_connectingLineLength > 0) { rect = new QCanvasRectangle (0, 0, barThickness, m_connectingLineLength, m_canvas); rect->moveBy(x, y); rect->setPen(GUIPalette::getColour(GUIPalette::StaffConnectingLine)); rect->setBrush(GUIPalette::getColour(GUIPalette::StaffConnectingLine)); rect->setZ( -3); if (hidden) rect->hide(); else rect->show(); LineRec connectingLine(layoutX, rect); m_barConnectingLines.push_back(connectingLine); }}boolLinedStaff::compareBars(const BarLine *barLine1, const BarLine *barLine2){ return (barLine1->getLayoutX() < barLine2->getLayoutX());}boolLinedStaff::compareBarToLayoutX(const BarLine *barLine1, int x){ return (barLine1->getLayoutX() < x);}voidLinedStaff::deleteTimeSignatures(){ // default implementation is empty}voidLinedStaff::insertTimeSignature(double, const TimeSignature &){ // default implementation is empty}voidLinedStaff::deleteRepeatedClefsAndKeys(){ // default implementation is empty}voidLinedStaff::insertRepeatedClefAndKey(double, int){ // default implementation is empty}voidLinedStaff::drawStaffName(){ // default implementation is empty}voidLinedStaff::resizeStaffLines(){ int firstRow = getRowForLayoutX(m_startLayoutX); int lastRow = getRowForLayoutX(m_endLayoutX); RG_DEBUG << "LinedStaff::resizeStaffLines: firstRow " << firstRow << ", lastRow " << lastRow << " (startLayoutX " << m_startLayoutX << ", endLayoutX " << m_endLayoutX << ")" << endl; assert(lastRow >= firstRow); int i; while ((int)m_staffLines.size() <= lastRow) { m_staffLines.push_back(ItemList()); m_staffConnectingLines.push_back(0); } // Remove all the staff lines that precede the start of the staff for (i = 0; i < firstRow; ++i) clearStaffLineRow(i); // now i == firstRow while (i <= lastRow) { double x0; double x1; if (i == firstRow) { x0 = getCanvasXForLayoutX(m_startLayoutX); } else { x0 = getCanvasXForLeftOfRow(i); } if (i == lastRow) { x1 = getCanvasXForLayoutX(m_endLayoutX); } else { x1 = getCanvasXForRightOfRow(i); } resizeStaffLineRow(i, x0, x1 - x0); ++i; } // now i == lastRow + 1 while (i < (int)m_staffLines.size()) clearStaffLineRow(i++);}voidLinedStaff::clearStaffLineRow(int row){ for (int h = 0; h < (int)m_staffLines[row].size(); ++h) { delete m_staffLines[row][h]; } m_staffLines[row].clear(); delete m_staffConnectingLines[row]; m_staffConnectingLines[row] = 0;}voidLinedStaff::resizeStaffLineRow(int row, double x, double length){ // RG_DEBUG << "LinedStaff::resizeStaffLineRow: row " // << row << ", x " << x << ", length " // << length << endl; // If the resolution is 8 or less, we want to reduce the blackness // of the staff lines somewhat to make them less intrusive int level = 0; int z = 2; if (m_resolution < 6) { z = -1; level = (9 - m_resolution) * 32; if (level > 200) level = 200; } QColor lineColour(level, level, level); int h; /*!!! No longer really good enough. But we could potentially use the bar positions to sort this out if (m_pageMode && row > 0 && offset == 0.0) { offset = (double)m_npf->getBarMargin() / 2; length -= offset; } */ int y; delete m_staffConnectingLines[row]; if (m_pageMode != LinearMode && m_connectingLineLength > 0.1) { // rather arbitrary (dup in insertBar) int barThickness = m_resolution / 12 + 1; y = getCanvasYForTopLine(row); QCanvasRectangle *line = new QCanvasRectangle (int(x + length), y, barThickness, m_connectingLineLength, m_canvas); line->setPen(GUIPalette::getColour(GUIPalette::StaffConnectingTerminatingLine)); line->setBrush(GUIPalette::getColour(GUIPalette::StaffConnectingTerminatingLine)); line->setZ( -2); line->show(); m_staffConnectingLines[row] = line; } else { m_staffConnectingLines[row] = 0; } while ((int)m_staffLines[row].size() <= getLineCount() * m_lineThickness) { m_staffLines[row].push_back(0); } int lineIndex = 0; for (h = 0; h < getLineCount(); ++h) { y = getCanvasYForHeight (getBottomLineHeight() + getHeightPerLine() * h, x, getCanvasYForTopLine(row)); if (elementsInSpaces()) { y -= getLineSpacing() / 2 + 1; } // RG_DEBUG << "LinedStaff: drawing line from (" // << x << "," << y << ") to (" << (x+length-1) // << "," << y << ")" << endl; QCanvasItem *line; delete m_staffLines[row][lineIndex]; m_staffLines[row][lineIndex] = 0; if (m_lineThickness > 1) { QCanvasRectangle *rline = new QCanvasRectangle (int(x), y, int(length), m_lineThickness, m_canvas); rline->setPen(lineColour); rline->setBrush(lineColour); line = rline; } else { QCanvasLine *lline = new QCanvasLine(m_canvas); lline->setPoints(int(x), y, int(x + length), y); lline->setPen(lineColour); line = lline; } // if (j > 0) line->setSignificant(false); line->setZ(z); m_staffLines[row][lineIndex] = line; line->show(); ++lineIndex; } while (lineIndex < (int)m_staffLines[row].size()) { delete m_staffLines[row][lineIndex]; m_staffLines[row][lineIndex] = 0; ++lineIndex; }}voidLinedStaff::setCurrent(bool current){ m_current = current; if (m_current) { m_insertCursor->show(); } else { m_insertCursor->hide(); }}doubleLinedStaff::getLayoutXOfPointer() const{ double x = m_pointer->x(); int row = getRowForCanvasCoords(x, int(m_pointer->y())); return getLayoutCoordsForCanvasCoords(x, getCanvasYForTopLine(row)).first;}voidLinedStaff::getPointerPosition(double &cx, int &cy) const{ cx = m_pointer->x(); cy = getCanvasYForTopOfStaff(getRowForCanvasCoords(cx, int(m_pointer->y())));}doubleLinedStaff::getLayoutXOfInsertCursor() const{ if (!m_current) return -1; double x = m_insertCursor->x(); int row = getRowForCanvasCoords(x, int(m_insertCursor->y())); return getLayoutCoordsForCanvasCoords(x, getCanvasYForTopLine(row)).first;}timeTLinedStaff::getInsertCursorTime(HorizontalLayoutEngine &layout) const{ if (m_insertCursorTimeValid) return m_insertCursorTime; return layout.getTimeForX(getLayoutXOfInsertCursor());}voidLinedStaff::getInsertCursorPosition(double &cx, int &cy) const{ if (!m_current) { cx = -1; cy = -1; return ; } cx = m_insertCursor->x(); cy = getCanvasYForTopOfStaff(getRowForCanvasCoords(cx, int(m_insertCursor->y())));}voidLinedStaff::setPointerPosition(double canvasX, int canvasY){ int row = getRowForCanvasCoords(canvasX, canvasY); canvasY = getCanvasYForTopOfStaff(row); m_pointer->setX(int(canvasX)); m_pointer->setY(int(canvasY)); m_pointer->setZ( -30); // behind everything else m_pointer->setPoints(0, 0, 0, getHeightOfRow() /* - 1 */); m_pointer->show();}voidLinedStaff::setPointerPosition(HorizontalLayoutEngine &layout, timeT time){ setPointerPosition(layout.getXForTime(time));}voidLinedStaff::setPointerPosition(double layoutX){ LinedStaffCoords coords = getCanvasCoordsForLayoutCoords(layoutX, 0); setPointerPosition(coords.first, coords.second);}voidLinedStaff::hidePointer(){ m_pointer->hide();}voidLinedStaff::setInsertCursorPosition(double canvasX, int canvasY){ if (!m_current) return; int row = getRowForCanvasCoords(canvasX, canvasY); canvasY = getCanvasYForTopOfStaff(row); m_insertCursor->setX(canvasX); m_insertCursor->setY(canvasY); m_insertCursor->setZ( -28); // behind everything else except playback pointer m_insertCursor->setPoints(0, 0, 0, getHeightOfRow() - 1); m_insertCursor->show(); m_insertCursorTimeValid = false;}voidLinedStaff::setInsertCursorPosition(HorizontalLayoutEngine &layout, timeT time){ double x = layout.getXForTime(time); LinedStaffCoords coords = getCanvasCoordsForLayoutCoords(x, 0); setInsertCursorPosition(coords.first, coords.second); m_insertCursorTime = time; m_insertCursorTimeValid = true;}voidLinedStaff::hideInsertCursor(){ m_insertCursor->hide();}voidLinedStaff::renderElements(ViewElementList::iterator, ViewElementList::iterator){ // nothing -- we assume rendering will be done by the implementation // of positionElements}voidLinedStaff::renderAllElements(){ renderElements(getViewElementList()->begin(), getViewElementList()->end());}voidLinedStaff::positionAllElements(){ positionElements(getSegment().getStartTime(), getSegment().getEndTime());}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -