本文整理汇总了C++中TimeSig::layout方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeSig::layout方法的具体用法?C++ TimeSig::layout怎么用?C++ TimeSig::layout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeSig
的用法示例。
在下文中一共展示了TimeSig::layout方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void ContinuousPanel::draw(QPainter& painter, const QList<Element*>& el) {
painter.save();
painter.setRenderHint(QPainter::Antialiasing, preferences.antialiasedDrawing);
painter.setRenderHint(QPainter::TextAntialiasing, true);
// Draw colored rectangle
painter.setClipping(false);
QPointF pos(_offsetPanel, 0);
painter.translate(pos);
QPen pen;
pen.setWidthF(0.0);
pen.setStyle(Qt::NoPen);
painter.setPen(pen);
painter.setBrush(preferences.fgColor);
QRectF bg(_rect);
bg.setWidth(_widthClef + _widthKeySig + _widthTimeSig + _leftMarginTotal + _panelRightPadding);
QPixmap* fgPixmap = _sv->fgPixmap();
if (fgPixmap == 0 || fgPixmap->isNull())
painter.fillRect(bg, preferences.fgColor);
else {
painter.setMatrixEnabled(false);
painter.drawTiledPixmap(bg, *fgPixmap, bg.topLeft()
- QPoint(lrint(_sv->matrix().dx()), lrint(_sv->matrix().dy())));
painter.setMatrixEnabled(true);
}
painter.setClipRect(_rect);
painter.setClipping(true);
QColor color(MScore::layoutBreakColor);
// Draw measure text number
QString text = _mmRestCount ? QString("#%1-%2").arg(_currentMeasureNo+1).arg(_currentMeasureNo+_mmRestCount) : QString("#%1").arg(_currentMeasureNo+1);
Text* newElement = new Text(_score);
newElement->setTextStyleType(TextStyleType::DEFAULT);
newElement->setFlag(ElementFlag::MOVABLE, false);
newElement->setXmlText(text);
newElement->textStyle().setFamily("FreeSans");
newElement->textStyle().setSizeIsSpatiumDependent(true);
newElement->setColor(color);
newElement->sameLayout();
pos = QPointF(_score->styleP(StyleIdx::clefLeftMargin) + _widthClef, _y + newElement->height());
painter.translate(pos);
newElement->draw(&painter);
pos += QPointF(_offsetPanel, 0);
painter.translate(-pos);
delete newElement;
// This second pass draws the elements spaced evently using the width of the largest element
for (const Element* e : el) {
e->itemDiscovered = 0;
if (!e->visible()) {
if (_score->printing() || !_score->showInvisible())
continue;
}
if (e->type() == Element::Type::STAFF_LINES) {
Staff* currentStaff = _score->staff(e->staffIdx());
Segment* parent = _score->tick2segmentMM(_currentMeasureTick);
pos = QPointF (_offsetPanel, e->pagePos().y());
painter.translate(pos);
// Draw staff lines
StaffLines* newStaffLines = static_cast<StaffLines*>(e->clone());
newStaffLines->setWidth(bg.width());
newStaffLines->setParent(parent);
newStaffLines->setTrack(e->track());
newStaffLines->layout();
newStaffLines->setColor(color);
newStaffLines->draw(&painter);
delete newStaffLines;
// Draw barline
BarLine* newBarLine = new BarLine(_score);
newBarLine->setBarLineType(BarLineType::NORMAL);
newBarLine->setParent(parent);
newBarLine->setTrack(e->track());
newBarLine->setSpan(currentStaff->barLineSpan());
newBarLine->setSpanFrom(currentStaff->barLineFrom());
newBarLine->setSpanTo(currentStaff->barLineTo());
newBarLine->layout();
newBarLine->setColor(color);
newBarLine->draw(&painter);
delete newBarLine;
// Draw the current staff name
QList<StaffName>& staffNamesLong = currentStaff->part()->instrument()->longNames();
QString staffName = staffNamesLong.isEmpty() ? " " : staffNamesLong[0].name();
if (staffName == "") {
QList<StaffName>& staffNamesShort = currentStaff->part()->instrument()->shortNames();
staffName = staffNamesShort.isEmpty() ? "" : staffNamesShort[0].name();
}
Text* newName = new Text(_score);
newName->setXmlText(staffName);
newName->setParent(parent);
newName->setTrack(e->track());
newName->setColor(color);
newName->textStyle().setFamily("FreeSans");
//.........这里部分代码省略.........
示例2: paint
//.........这里部分代码省略.........
// The first pass serves to get the maximum width for each elements
qreal lineWidthName = 0;
qreal _widthClef = 0;
qreal _widthKeySig = 0;
qreal _widthTimeSig = 0;
qreal _xPosTimeSig = 0;
for (const Element* e : el) {
e->itemDiscovered = 0;
if (!e->visible() && !_score->showInvisible())
continue;
if (e->isRest() && toRest(e)->isGap())
continue;
if (e->isStaffLines()) {
Staff* currentStaff = _score->staff(e->staffIdx());
Segment* parent = _score->tick2segment(tick);
// Find maximum width for the staff name
QList<StaffName>& staffNamesLong = currentStaff->part()->instrument()->longNames();
QString staffName = staffNamesLong.isEmpty() ? " " : staffNamesLong[0].name();
if (staffName == "") {
QList<StaffName>& staffNamesShort = currentStaff->part()->instrument()->shortNames();
staffName = staffNamesShort.isEmpty() ? "" : staffNamesShort[0].name();
}
Text* newName = new Text(_score);
newName->setXmlText(staffName);
newName->setParent(parent);
newName->setTrack(e->track());
newName->textStyle().setFamily("FreeSans");
newName->textStyle().setSizeIsSpatiumDependent(true);
newName->layout();
newName->setPlainText(newName->plainText());
newName->layout();
// Find maximum width for the current Clef
Clef* newClef = new Clef(_score);
ClefType currentClef = currentStaff->clef(tick);
newClef->setClefType(currentClef);
newClef->setParent(parent);
newClef->setTrack(e->track());
newClef->layout();
if (newClef->width() > _widthClef)
_widthClef = newClef->width();
// Find maximum width for the current KeySignature
KeySig* newKs = new KeySig(_score);
KeySigEvent currentKeySigEvent = currentStaff->keySigEvent(tick);
newKs->setKeySigEvent(currentKeySigEvent);
// The Parent and the Track must be set to have the key signature layout adjusted to different clefs
// This also adds naturals to the key signature (if set in the score style)
newKs->setParent(parent);
newKs->setTrack(e->track());
newKs->setHideNaturals(true);
newKs->layout();
if (newKs->width() > _widthKeySig)
_widthKeySig = newKs->width();
// Find maximum width for the current TimeSignature
TimeSig* newTs = new TimeSig(_score);
// Try to get local time signature, if not, get the current measure one
TimeSig* currentTimeSig = currentStaff->timeSig(tick);
if (currentTimeSig)
示例3: findElementWidths
void ContinuousPanel::findElementWidths(const QList<Element*>& el) {
// The first pass serves to get the maximum width for each elements
qreal lineWidthName = 0;
_widthClef = 0;
_widthKeySig = 0;
_widthTimeSig = 0;
_xPosTimeSig = 0;
for (const Element* e : el) {
e->itemDiscovered = 0;
if (!e->visible()) {
if (_score->printing() || !_score->showInvisible())
continue;
}
if (e->type() == Element::Type::STAFF_LINES) {
Staff* currentStaff = _score->staff(e->staffIdx());
Segment* parent = _score->tick2segment(_currentMeasureTick);
// Find maximum width for the staff name
QList<StaffName>& staffNamesLong = currentStaff->part()->instrument()->longNames();
QString staffName = staffNamesLong.isEmpty() ? " " : staffNamesLong[0].name();
if (staffName == "") {
QList<StaffName>& staffNamesShort = currentStaff->part()->instrument()->shortNames();
staffName = staffNamesShort.isEmpty() ? "" : staffNamesShort[0].name();
}
Text* newName = new Text(_score);
newName->setXmlText(staffName);
newName->setParent(parent);
newName->setTrack(e->track());
newName->textStyle().setFamily("FreeSans");
newName->textStyle().setSizeIsSpatiumDependent(true);
newName->layout();
newName->setPlainText(newName->plainText());
newName->layout();
// Find maximum width for the current Clef
Clef* newClef = new Clef(_score);
ClefType currentClef = currentStaff->clef(_currentMeasureTick);
newClef->setClefType(currentClef);
newClef->setParent(parent);
newClef->setTrack(e->track());
newClef->layout();
// Find maximum width for the current KeySignature
KeySig* newKs = new KeySig(_score);
KeySigEvent currentKeySigEvent = currentStaff->keySigEvent(_currentMeasureTick);
newKs->setKeySigEvent(currentKeySigEvent);
// The Parent and the Track must be set to have the key signature layout adjusted to different clefs
// This also adds naturals to the key signature (if set in the score style)
newKs->setParent(parent);
newKs->setTrack(e->track());
newKs->setHideNaturals(true);
newKs->layout();
// Find maximum width for the current TimeSignature
TimeSig* newTs = new TimeSig(_score);
// Try to get local time signature, if not, get the current measure one
TimeSig* currentTimeSig = currentStaff->timeSig(_currentMeasureTick);
if (currentTimeSig)
newTs->setFrom(currentTimeSig);
else
newTs->setSig(_currentTimeSig.numerator(), _currentTimeSig.denominator(), TimeSigType::NORMAL);
newTs->setParent(parent);
newTs->setTrack(e->track());
newTs->layout();
if ((newName->width() > lineWidthName) && (newName->xmlText() != ""))
lineWidthName = newName->width();
if (newClef->width() > _widthClef)
_widthClef = newClef->width();
if (newKs->width() > _widthKeySig)
_widthKeySig = newKs->width();
if (newTs->width() > _widthTimeSig)
_widthTimeSig = newTs->width();
delete newClef;
delete newName;
delete newKs;
delete newTs;
}
}
_leftMarginTotal = _score->styleP(StyleIdx::clefLeftMargin);
_leftMarginTotal += _score->styleP(StyleIdx::keysigLeftMargin);
_leftMarginTotal += _score->styleP(StyleIdx::timesigLeftMargin);
_newWidth = _widthClef + _widthKeySig + _widthTimeSig + _leftMarginTotal + _panelRightPadding;
_xPosMeasure -= _offsetPanel;
lineWidthName += _score->spatium() + _score->styleP(StyleIdx::clefLeftMargin) + _widthClef;
if (_newWidth < lineWidthName) {
_newWidth = lineWidthName;
_oldWidth = 0;
}
if (_oldWidth == 0) {
_oldWidth = _newWidth;
//.........这里部分代码省略.........