void TrillSegment::draw(Painter* painter) const { qreal mag = magS(); int idx = score()->symIdx(); qreal w2 = symbols[idx][trillelementSym].width(mag); QRectF b2(symbols[idx][trillelementSym].bbox(mag)); if (spannerSegmentType() == SEGMENT_SINGLE || spannerSegmentType() == SEGMENT_BEGIN) { QRectF b1(symbols[idx][trillSym].bbox(mag)); QRectF b2(symbols[idx][trillelementSym].bbox(mag)); qreal x0 = -b1.x(); qreal x1 = x0 + b1.width(); qreal x2 = pos2().x(); int n = int(floor((x2-x1) / w2)); symbols[idx][trillSym].draw(painter, mag, x0, 0.0); symbols[idx][trillelementSym].draw(painter, mag, x1, b2.y() * .9, n); if (trill()->accidental()) { painter->save(); painter->translate(trill()->accidental()->pagePos()); trill()->accidental()->draw(painter); painter->restore(); } } else { qreal x1 = 0.0; qreal x2 = pos2().x(); int n = int(floor((x2-x1) / w2)); symbols[idx][trillelementSym].draw(painter, mag, x1, b2.y() * .9, n); } }
void TrillSegment::scanElements(void* data, void (*func)(void*, Element*), bool /*all*/) { func(data, this); if (spannerSegmentType() == SpannerSegmentType::SINGLE || spannerSegmentType() == SpannerSegmentType::BEGIN) { Accidental* a = trill()->accidental(); if (a) func(data, a); } }
void HairpinSegment::layout() { QTransform t; qreal _spatium = spatium(); qreal h1 = score()->styleS(ST_hairpinHeight).val() * _spatium * .5; qreal h2 = score()->styleS(ST_hairpinContHeight).val() * _spatium * .5; rypos() = 0.0; qreal len; qreal x = pos2().x(); if (x < _spatium) // minimum size of hairpin x = _spatium; qreal y = pos2().y(); len = sqrt(x * x + y * y); t.rotateRadians(asin(y/len)); if (hairpin()->hairpinType() == 0) { // crescendo switch (spannerSegmentType()) { case SEGMENT_SINGLE: case SEGMENT_BEGIN: l1.setLine(.0, .0, len, h1); l2.setLine(.0, .0, len, - h1); break; case SEGMENT_MIDDLE: case SEGMENT_END: l1.setLine(.0, h2, len, h1); l2.setLine(.0, -h2, len, - h1); break; } } else { // decrescendo switch(spannerSegmentType()) { case SEGMENT_SINGLE: case SEGMENT_END: l1.setLine(.0, h1, len, 0.0); l2.setLine(.0, -h1, len, 0.0); break; case SEGMENT_BEGIN: case SEGMENT_MIDDLE: l1.setLine(.0, h1, len, + h2); l2.setLine(.0, -h1, len, - h2); break; } } l1 = t.map(l1); l2 = t.map(l2); QRectF r = QRectF(l1.p1(), l1.p2()).normalized() | QRectF(l2.p1(), l2.p2()).normalized(); qreal w = point(score()->styleS(ST_hairpinWidth)); setbbox(r.adjusted(-w*.5, -w*.5, w, w)); if (parent()) rypos() += score()->styleS(ST_hairpinY).val() * _spatium; adjustReadPos(); }
void TextLineSegment::setSelected(bool f) { Element::setSelected(f); if (_text) { if (spannerSegmentType() == SEGMENT_SINGLE || spannerSegmentType() == SEGMENT_BEGIN) { if (textLine()->beginText()) _text->setSelected(f); } else if (textLine()->continueText()) _text->setSelected(f); } }
void TrillSegment::layout() { qreal mag = magS(); int idx = score()->symIdx(); QRectF b1(symbols[idx][trillSym].bbox(mag)); QRectF rr(b1.translated(-b1.x(), 0.0)); rr |= QRectF(0.0, rr.y(), pos2().x(), rr.height()); if (spannerSegmentType() == SEGMENT_SINGLE || spannerSegmentType() == SEGMENT_BEGIN) { if (trill()->accidental()) { rr |= trill()->accidental()->bbox().translated(trill()->accidental()->pos()); } } setbbox(rr); }
void TrillSegment::layout() { if (parent()) rypos() += score()->styleS(StyleIdx::trillY).val() * spatium(); if (staff()) setMag(staff()->mag()); if (spannerSegmentType() == SpannerSegmentType::SINGLE || spannerSegmentType() == SpannerSegmentType::BEGIN) { Accidental* a = trill()->accidental(); if (a) { a->layout(); a->setMag(a->mag() * .6); qreal _spatium = spatium(); a->setPos(_spatium * 1.3, -2.2 * _spatium); a->adjustReadPos(); } switch (trill()->trillType()) { case Trill::Type::TRILL_LINE: symbolLine(SymId::ornamentTrill, SymId::wiggleTrill); break; case Trill::Type::PRALLPRALL_LINE: symbolLine(SymId::wiggleTrill, SymId::wiggleTrill); break; case Trill::Type::UPPRALL_LINE: if (score()->scoreFont()->isValid(SymId::ornamentBottomLeftConcaveStroke)) symbolLine(SymId::ornamentBottomLeftConcaveStroke, SymId::ornamentZigZagLineNoRightEnd, SymId::ornamentZigZagLineWithRightEnd); else symbolLine(SymId::ornamentUpPrall, // SymId::ornamentZigZagLineNoRightEnd, SymId::ornamentZigZagLineWithRightEnd); SymId::ornamentZigZagLineNoRightEnd); break; case Trill::Type::DOWNPRALL_LINE: if (score()->scoreFont()->isValid(SymId::ornamentLeftVerticalStroke)) symbolLine(SymId::ornamentLeftVerticalStroke, SymId::ornamentZigZagLineNoRightEnd, SymId::ornamentZigZagLineWithRightEnd); else symbolLine(SymId::ornamentDownPrall, // SymId::ornamentZigZagLineNoRightEnd, SymId::ornamentZigZagLineWithRightEnd); SymId::ornamentZigZagLineNoRightEnd); break; } } else symbolLine(SymId::wiggleTrill, SymId::wiggleTrill); adjustReadPos(); }
void TrillSegment::layout() { QRectF b1(symBbox(SymId::ornamentTrill)); QRectF rr(b1.translated(-b1.x(), 0.0)); rr |= QRectF(0.0, rr.y(), pos2().x(), rr.height()); setbbox(rr); if (parent()) rypos() += score()->styleS(ST_trillY).val() * spatium(); if (spannerSegmentType() == SEGMENT_SINGLE || spannerSegmentType() == SEGMENT_BEGIN) { Accidental* a = trill()->accidental(); if (a) { a->layout(); a->setMag(a->mag() * .6); qreal _spatium = spatium(); a->setPos(_spatium*1.3, -2.2*_spatium); a->adjustReadPos(); } } adjustReadPos(); }
void HairpinSegment::layout() { if (hairpin()->useTextLine()) { if (parent()) rypos() += score()->styleS(StyleIdx::hairpinY).val() * spatium(); TextLineSegment::layout(); return; } QTransform t; qreal _spatium = spatium(); qreal h1 = hairpin()->hairpinHeight().val() * spatium() * .5; qreal h2 = hairpin()->hairpinContHeight().val() * spatium() * .5; qreal len; qreal x = pos2().x(); if (x < _spatium) // minimum size of hairpin x = _spatium; qreal y = pos2().y(); len = sqrt(x * x + y * y); t.rotateRadians(asin(y/len)); drawCircledTip = hairpin()->hairpinCircledTip(); circledTipRadius = 0; if( drawCircledTip ) circledTipRadius = 0.6 * _spatium * .5; if (hairpin()->hairpinType() == Hairpin::Type::CRESCENDO) { // crescendo switch (spannerSegmentType()) { case SpannerSegmentType::SINGLE: case SpannerSegmentType::BEGIN: l1.setLine(.0 + circledTipRadius*2, .0, len, h1); l2.setLine(.0 + circledTipRadius*2, .0, len, -h1); circledTip.setX( 0 + circledTipRadius ); circledTip.setY( 0 ); break; case SpannerSegmentType::MIDDLE: case SpannerSegmentType::END: drawCircledTip = false; l1.setLine(.0, h2, len, h1); l2.setLine(.0, -h2, len, -h1); break; } } else { // decrescendo switch(spannerSegmentType()) { case SpannerSegmentType::SINGLE: case SpannerSegmentType::END: l1.setLine(.0, h1, len - circledTipRadius*2, 0.0); l2.setLine(.0, -h1, len - circledTipRadius*2, 0.0); circledTip.setX( len - circledTipRadius ); circledTip.setY( 0 ); break; case SpannerSegmentType::BEGIN: case SpannerSegmentType::MIDDLE: drawCircledTip = false; l1.setLine(.0, h1, len, + h2); l2.setLine(.0, -h1, len, - h2); break; } } // Do Coord rotation l1 = t.map(l1); l2 = t.map(l2); if( drawCircledTip ) circledTip = t.map(circledTip); QRectF r = QRectF(l1.p1(), l1.p2()).normalized() | QRectF(l2.p1(), l2.p2()).normalized(); qreal w = point(score()->styleS(StyleIdx::hairpinLineWidth)); setbbox(r.adjusted(-w*.5, -w*.5, w, w)); if (parent()) rypos() += score()->styleS(StyleIdx::hairpinY).val() * _spatium; adjustReadPos(); }
void TrillSegment::draw(QPainter* painter) const { qreal mag = magS(); int idx = score()->symIdx(); QRectF b2(symbols[idx][trillelementSym].bbox(mag)); qreal w2 = symbols[idx][trillelementSym].width(mag); qreal x2 = pos2().x(); painter->setPen(curColor()); if (spannerSegmentType() == SEGMENT_SINGLE || spannerSegmentType() == SEGMENT_BEGIN) { int sym = 0; qreal x0 = 0.0, x1 = 0.0, y = 0.0; int n = 0; QRectF b1; switch(trill()->trillType()) { case Trill::TRILL_LINE: sym = trillSym; b1 = symbols[idx][sym].bbox(mag); x0 = -b1.x(); x1 = x0 + b1.width(); n = int(floor((x2-x1) / w2)); y = 0.0; break; case Trill::UPPRALL_LINE: sym = upprallSym; b1 = symbols[idx][sym].bbox(mag); x0 = -b1.x(); x1 = b1.width(); n = int(floor((x2-x1) / w2)); y = -b1.height(); break; case Trill::DOWNPRALL_LINE: sym = downprallSym; b1 = symbols[idx][sym].bbox(mag); x0 = -b1.x(); x1 = b1.width(); n = int(floor((x2-x1) / w2)); y = -b1.height(); break; case Trill::PRALLPRALL_LINE: sym = prallprallSym; b1 = symbols[idx][sym].bbox(mag); x0 = -b1.x(); x1 = b1.width(); n = int(floor((x2-x1) / w2)); y = -b1.height(); break; case Trill::PURE_LINE: sym = noSym; x0 = 0; x1 = 0; n = int(floor((x2-x1) / w2)); y = 0.0; } if (n <= 0) n = 1; if (sym != noSym) symbols[idx][sym].draw(painter, mag, QPointF(x0, y)); symbols[idx][trillelementSym].draw(painter, mag, QPointF(x1, b2.y() * .9), n); } else { qreal x1 = 0.0; int n = int(floor((x2-x1) / w2)); symbols[idx][trillelementSym].draw(painter, mag, QPointF(x1, b2.y() * .9), n); } }
void HairpinSegment::layout() { Dynamic* sd = 0; Dynamic* ed = 0; qreal _spatium = spatium(); if (autoplace()) { setUserOff(QPointF()); setUserOff2(QPointF()); } if (isSingleType() || isBeginType()) { sd = lookupDynamic(hairpin()->startElement()); if (sd) { if (autoplace()) { qreal dx = sd->bbox().right() + sd->pos().x() + sd->segment()->pos().x() + sd->measure()->pos().x(); // hardcoded distance between Dynamic and Hairpin: 0.5sp qreal dist = dx - pos().x() + score()->styleP(StyleIdx::autoplaceHairpinDynamicsDistance); rUserXoffset() = dist; rUserXoffset2() = -dist; } else sd->doAutoplace(); } } if (isSingleType() || isEndType()) { ed = lookupDynamic(hairpin()->endElement()); if (ed) { if (autoplace()) { rUserXoffset2() -= ed->bbox().width(); qreal dx = ed->bbox().left() + ed->pos().x() + ed->segment()->pos().x() + ed->measure()->pos().x(); // hardcoded distance between Hairpin and Dynamic: 0.5sp ed->rUserXoffset() = pos2().x() + pos().x() - dx + score()->styleP(StyleIdx::autoplaceHairpinDynamicsDistance); } else ed->doAutoplace(); } } Hairpin::Type type = hairpin()->hairpinType(); if (type == Hairpin::Type::DECRESC_LINE || type == Hairpin::Type::CRESC_LINE) { twoLines = false; TextLineSegment::layout(); drawCircledTip = false; if (parent()) rypos() += score()->styleP(StyleIdx::hairpinY); } else { delete _text; delete _endText; _text = 0; _endText = 0; QTransform t; qreal h1 = hairpin()->hairpinHeight().val() * spatium() * .5; qreal h2 = hairpin()->hairpinContHeight().val() * spatium() * .5; qreal len; qreal x = pos2().x(); if (x < _spatium) // minimum size of hairpin x = _spatium; qreal y = pos2().y(); len = sqrt(x * x + y * y); t.rotateRadians(asin(y/len)); drawCircledTip = hairpin()->hairpinCircledTip(); circledTipRadius = drawCircledTip ? 0.6 * _spatium * .5 : 0.0; QLine l1, l2; twoLines = true; switch (type) { case Hairpin::Type::CRESC_HAIRPIN: { switch (spannerSegmentType()) { case SpannerSegmentType::SINGLE: case SpannerSegmentType::BEGIN: l1.setLine(circledTipRadius * 2.0, 0.0, len, h1); l2.setLine(circledTipRadius * 2.0, 0.0, len, -h1); circledTip.setX(circledTipRadius ); circledTip.setY(0.0); break; case SpannerSegmentType::MIDDLE: case SpannerSegmentType::END: drawCircledTip = false; l1.setLine(.0, h2, len, h1); l2.setLine(.0, -h2, len, -h1); break; } } break; case Hairpin::Type::DECRESC_HAIRPIN: { switch(spannerSegmentType()) { case SpannerSegmentType::SINGLE: case SpannerSegmentType::END: l1.setLine(0.0, h1, len - circledTipRadius * 2, 0.0); l2.setLine(0.0, -h1, len - circledTipRadius * 2, 0.0); circledTip.setX(len - circledTipRadius); circledTip.setY(0.0); break; case SpannerSegmentType::BEGIN: case SpannerSegmentType::MIDDLE: drawCircledTip = false; l1.setLine(.0, h1, len, + h2); l2.setLine(.0, -h1, len, - h2); break; } } break; default: break; } // Do Coord rotation l1 = t.map(l1); l2 = t.map(l2); if (drawCircledTip ) circledTip = t.map(circledTip); points[0] = l1.p1(); points[1] = l1.p2(); points[2] = l2.p1(); points[3] = l2.p2(); npoints = 4; QRectF r = QRectF(l1.p1(), l1.p2()).normalized() | QRectF(l2.p1(), l2.p2()).normalized(); qreal w = score()->styleP(StyleIdx::hairpinLineWidth); setbbox(r.adjusted(-w*.5, -w*.5, w, w)); if (parent()) rypos() += score()->styleP(StyleIdx::hairpinY); } if (autoplace() && parent()) { qreal minDistance = spatium() * .7; Shape s1 = shape().translated(pos()); qreal d = system()->bottomDistance(staffIdx(), s1); qreal ymax = pos().y(); if (d > -minDistance) ymax += d + minDistance; qreal sdy; if (sd) { sdy = -sd->bbox().top() * .4; sd->doAutoplace(); if (sd->pos().y() - sdy > ymax) ymax = sd->pos().y() - sdy; } qreal edy; if (ed) { edy = -ed->bbox().top() * .4; ed->doAutoplace(); if (ed->pos().y() - edy > ymax) ymax = ed->pos().y() - edy; } rUserYoffset() = ymax - pos().y(); if (sd) moveDynamic(sd, ymax - sd->ipos().y() + sdy); if (ed) moveDynamic(ed, ymax - ed->ipos().y() + edy); } else adjustReadPos(); }
void TextLineBaseSegment::layout() { npoints = 0; TextLineBase* tl = textLineBase(); qreal _spatium = spatium(); if (!tl->diagonal()) _userOff2.setY(0); switch (spannerSegmentType()) { case SpannerSegmentType::SINGLE: case SpannerSegmentType::BEGIN: _text->setXmlText(tl->beginText()); _text->setFamily(tl->beginFontFamily()); _text->setSize(tl->beginFontSize()); _text->setOffset(tl->beginTextOffset()); _text->setAlign(tl->beginTextAlign()); break; case SpannerSegmentType::MIDDLE: case SpannerSegmentType::END: _text->setXmlText(tl->continueText()); _text->setFamily(tl->continueFontFamily()); _text->setSize(tl->continueFontSize()); _text->setOffset(tl->continueTextOffset()); _text->setAlign(tl->continueTextAlign()); break; } _text->setTrack(track()); _text->layout(); if ((isSingleType() || isEndType())) { _endText->setXmlText(tl->endText()); _endText->setFamily(tl->endFontFamily()); _endText->setSize(tl->endFontSize()); _endText->setOffset(tl->endTextOffset()); _endText->setAlign(tl->endTextAlign()); _endText->setTrack(track()); _endText->layout(); } else { _endText->setXmlText(""); } QPointF pp1; QPointF pp2(pos2()); // diagonal line with no text - just use the basic rectangle for line (ignore hooks) if (_text->empty() && _endText->empty() && pp2.y() != 0) { npoints = 2; points[0] = pp1; points[1] = pp2; setbbox(QRectF(pp1, pp2).normalized()); return; } // line has text or is not diagonal - calculate reasonable bbox qreal x1 = qMin(0.0, pp2.x()); qreal x2 = qMax(0.0, pp2.x()); qreal y0 = point(-textLineBase()->lineWidth()); qreal y1 = qMin(0.0, pp2.y()) + y0; qreal y2 = qMax(0.0, pp2.y()) - y0; qreal l = 0.0; if (!_text->empty()) { qreal textlineTextDistance = _spatium * .5; if (((isSingleType() || isBeginType()) && (tl->beginTextPlace() == PlaceText::LEFT)) || ((isMiddleType() || isEndType()) && (tl->continueTextPlace() == PlaceText::LEFT))) l = _text->pos().x() + _text->bbox().width() + textlineTextDistance; qreal h = _text->height(); if (textLineBase()->beginTextPlace() == PlaceText::ABOVE) y1 = qMin(y1, -h); else if (textLineBase()->beginTextPlace() == PlaceText::BELOW) y2 = qMax(y2, h); else { y1 = qMin(y1, -h * .5); y2 = qMax(y2, h * .5); } x2 = qMax(x2, _text->width()); } if (textLineBase()->endHookType() != HookType::NONE) { qreal h = pp2.y() + point(textLineBase()->endHookHeight()); if (h > y2) y2 = h; else if (h < y1) y1 = h; } if (textLineBase()->beginHookType() != HookType::NONE) { qreal h = point(textLineBase()->beginHookHeight()); if (h > y2) y2 = h; else if (h < y1) y1 = h; } bbox().setRect(x1, y1, x2 - x1, y2 - y1); if (!_text->empty()) bbox() |= _text->bbox().translated(_text->pos()); // DEBUG // set end text position and extend bbox if (!_endText->empty()) { _endText->setPos(bbox().right(), 0); bbox() |= _endText->bbox().translated(_endText->pos()); } if (!(tl->lineVisible() || score()->showInvisible())) return; if (tl->lineVisible() || !score()->printing()) { QPointF pp1(l, 0.0); qreal beginHookWidth; qreal endHookWidth; if (tl->beginHookType() == HookType::HOOK_45) { beginHookWidth = fabs(tl->beginHookHeight().val() * _spatium * .4); pp1.rx() += beginHookWidth; } else beginHookWidth = 0; if (tl->endHookType() == HookType::HOOK_45) { endHookWidth = fabs(tl->endHookHeight().val() * _spatium * .4); pp2.rx() -= endHookWidth; } else endHookWidth = 0; // don't draw backwards lines (or hooks) if text is longer than nominal line length bool backwards = !_text->empty() && pp1.x() > pp2.x() && !tl->diagonal(); if ((tl->beginHookType() != HookType::NONE) && (isSingleType() || isBeginType())) { qreal hh = tl->beginHookHeight().val() * _spatium; points[npoints] = QPointF(pp1.x() - beginHookWidth, pp1.y() + hh); ++npoints; points[npoints] = pp1; } if (!backwards) { points[npoints] = pp1; ++npoints; points[npoints] = pp2; // painter->drawLine(QLineF(pp1.x(), pp1.y(), pp2.x(), pp2.y())); if ((tl->endHookType() != HookType::NONE) && (isSingleType() || isEndType())) { ++npoints; qreal hh = tl->endHookHeight().val() * _spatium; // painter->drawLine(QLineF(pp2.x(), pp2.y(), pp2.x() + endHookWidth, pp2.y() + hh)); points[npoints] = QPointF(pp2.x() + endHookWidth, pp2.y() + hh); } } } }
void TextLineSegment::draw(QPainter* painter) const { TextLine* tl = textLine(); qreal _spatium = spatium(); qreal textlineLineWidth = tl->lineWidth().val() * _spatium; qreal textlineTextDistance = _spatium * .5; QPointF pp2(pos2()); QColor color; bool normalColor = false; if (selected() && !(score() && score()->printing())) color = MScore::selectColor[0]; else if (!visible()) color = Qt::gray; else { color = curColor(); normalColor = true; } qreal l = 0.0; int sym = spannerSegmentType() == SEGMENT_MIDDLE ? tl->continueSymbol() : tl->beginSymbol(); if (_text) { SpannerSegmentType st = spannerSegmentType(); if ( ((st == SEGMENT_SINGLE || st == SEGMENT_BEGIN) && (tl->beginTextPlace() == PLACE_LEFT)) || ((st == SEGMENT_MIDDLE || st == SEGMENT_END) && (tl->continueTextPlace() == PLACE_LEFT)) ) { QRectF bb(_text->bbox()); l = _text->pos().x() + bb.width() + textlineTextDistance; } painter->translate(_text->pos()); painter->setPen(normalColor ? _text->curColor() : color); _text->draw(painter); painter->translate(-_text->pos()); } else if (sym != -1) { const QRectF& bb = symbols[score()->symIdx()][sym].bbox(magS()); qreal h = bb.height() * .5; QPointF o = tl->beginSymbolOffset() * _spatium; painter->setPen(color); symbols[score()->symIdx()][sym].draw(painter, 1.0, QPointF(o.x(), h + o.y())); l = bb.width() + textlineTextDistance; } QPen pen(normalColor ? tl->lineColor() : color, textlineLineWidth); pen.setStyle(tl->lineStyle()); painter->setPen(pen); if (spannerSegmentType() == SEGMENT_SINGLE || spannerSegmentType() == SEGMENT_END) { if (tl->endSymbol() != -1) { int sym = tl->endSymbol(); const QRectF& bb = symbols[score()->symIdx()][sym].bbox(magS()); qreal h = bb.height() * .5; QPointF o = tl->endSymbolOffset() * _spatium; pp2.setX(pp2.x() - bb.width() + textlineTextDistance); symbols[score()->symIdx()][sym].draw(painter, 1.0, QPointF(pp2.x() + textlineTextDistance + o.x(), h + o.y())); } } QPointF pp1(l, 0.0); if (tl->beginHook() && tl->beginHookType() == HOOK_45) pp1.rx() += fabs(tl->beginHookHeight().val() * _spatium * .4); if (tl->endHook() && tl->endHookType() == HOOK_45) pp2.rx() -= fabs(tl->endHookHeight().val() * _spatium * .4); painter->drawLine(QLineF(pp1.x(), pp1.y(), pp2.x(), pp2.y())); if (tl->beginHook()) { qreal hh = tl->beginHookHeight().val() * _spatium; if (spannerSegmentType() == SEGMENT_SINGLE || spannerSegmentType() == SEGMENT_BEGIN) { if (tl->beginHookType() == HOOK_45) painter->drawLine(QLineF(pp1.x(), pp1.y(), pp1.x() - fabs(hh * .4), pp1.y() + hh)); else painter->drawLine(QLineF(pp1.x(), pp1.y(), pp1.x(), pp1.y() + hh)); } } if (tl->endHook()) { qreal hh = tl->endHookHeight().val() * _spatium; if (spannerSegmentType() == SEGMENT_SINGLE || spannerSegmentType() == SEGMENT_END) { if (tl->endHookType() == HOOK_45) painter->drawLine(QLineF(pp2.x(), pp2.y(), pp2.x() + fabs(hh * .4), pp2.y() + hh)); else painter->drawLine(QLineF(pp2.x(), pp2.y(), pp2.x(), pp2.y() + hh)); } } }
void TextLineSegment::layout1() { TextLine* tl = textLine(); if (!tl->diagonal()) _userOff2.setY(0); switch (spannerSegmentType()) { case SEGMENT_SINGLE: case SEGMENT_BEGIN: if (tl->beginText()) { if (_text == 0) { _text = new Text(*tl->beginText()); _text->setFlag(ELEMENT_MOVABLE, false); _text->setParent(this); } } else { delete _text; _text = 0; } break; case SEGMENT_MIDDLE: case SEGMENT_END: if (tl->continueText()) { if (_text == 0) { _text = new Text(*tl->continueText()); _text->setFlag(ELEMENT_MOVABLE, false); _text->setParent(this); } } else { delete _text; _text = 0; } break; } if (_text) _text->layout(); QPointF pp1; QPointF pp2(pos2()); if (!_text && pp2.y() != 0) { setbbox(QRectF(pp1, pp2).normalized()); return; } qreal y1 = point(-textLine()->lineWidth()); qreal y2 = -y1; int sym = textLine()->beginSymbol(); if (_text) { qreal h = _text->height(); if (textLine()->beginTextPlace() == PLACE_ABOVE) y1 = -h; else if (textLine()->beginTextPlace() == PLACE_BELOW) y2 = h; else { y1 = -h * .5; y2 = h * .5; } } else if (sym != -1) { qreal hh = symbols[score()->symIdx()][sym].height(magS()) * .5; y1 = -hh; y2 = hh; } if (textLine()->endHook()) { qreal h = point(textLine()->endHookHeight()); if (h > y2) y2 = h; else if (h < y1) y1 = h; } if (textLine()->beginHook()) { qreal h = point(textLine()->beginHookHeight()); if (h > y2) y2 = h; else if (h < y1) y1 = h; } bbox().setRect(.0, y1, pp2.x(), y2 - y1); }
void TrillSegment::draw(QPainter* painter) const { QRectF b2(symBbox(SymId::wiggleTrill)); qreal w2 = symWidth(SymId::wiggleTrill); qreal x2 = pos2().x(); QColor color; if (flag(ELEMENT_DROP_TARGET)) color = MScore::dropColor; else if (selected() && !(score() && score()->printing())) color = MScore::selectColor[0]; else if (!visible()) color = Qt::gray; else { color = trill()->curColor(); } painter->setPen(color); if (spannerSegmentType() == SEGMENT_SINGLE || spannerSegmentType() == SEGMENT_BEGIN) { SymId sym = SymId::noSym; qreal x0 = 0.0, x1 = 0.0, y = 0.0; int n = 0; QRectF b1; switch(trill()->trillType()) { case Trill::TRILL_LINE: sym = SymId::ornamentTrill; b1 = symBbox(sym); x0 = -b1.x(); x1 = x0 + b1.width(); n = int(floor((x2-x1) / w2)); y = 0.0; break; #if 0 // TODO-smufl case Trill::UPPRALL_LINE: sym = SymId(upprallSym); b1 = score()->sym(sym).bbox(mag); x0 = -b1.x(); x1 = b1.width(); n = int(floor((x2-x1) / w2)); y = -b1.height(); break; case Trill::DOWNPRALL_LINE: sym = SymId(downprallSym); b1 = score()->sym(sym).bbox(mag); x0 = -b1.x(); x1 = b1.width(); n = int(floor((x2-x1) / w2)); y = -b1.height(); break; case Trill::PRALLPRALL_LINE: sym = SymId(prallprallSym); b1 = score()->sym(sym).bbox(mag); x0 = -b1.x(); x1 = b1.width(); n = int(floor((x2-x1) / w2)); y = -b1.height(); break; #endif case Trill::PURE_LINE: sym = SymId::noSym; x0 = 0; x1 = 0; n = int(floor((x2-x1) / w2)); y = 0.0; } if (n <= 0) n = 1; if (sym != SymId::noSym) drawSymbol(sym, painter, QPointF(x0, y)); drawSymbol(SymId::wiggleTrill, painter, QPointF(x1, b2.y() * .9), n); } else { qreal x1 = 0.0; int n = int(floor((x2-x1) / w2)); drawSymbol(SymId::wiggleTrill, painter, QPointF(x1, b2.y() * .9), n); } }
void HairpinSegment::layout() { if (hairpin()->useTextLine()) { // layout as textline rather than true hairpin // use dynamics text style for position, so the text aligns with dynamics // TODO: new style setting specifically for vertical offset of textline hairpins? // or, use hairpinY but adjust by 0.5sp, which currently yields same vertical position as dynamics if (parent()) rypos() += score()->textStyle(TextStyleType::DYNAMICS).offset(spatium()).y(); TextLineSegment::layout(); return; } QTransform t; qreal _spatium = spatium(); qreal h1 = hairpin()->hairpinHeight().val() * spatium() * .5; qreal h2 = hairpin()->hairpinContHeight().val() * spatium() * .5; qreal len; qreal x = pos2().x(); if (x < _spatium) // minimum size of hairpin x = _spatium; qreal y = pos2().y(); len = sqrt(x * x + y * y); t.rotateRadians(asin(y/len)); drawCircledTip = hairpin()->hairpinCircledTip(); circledTipRadius = 0; if( drawCircledTip ) circledTipRadius = 0.6 * _spatium * .5; if (hairpin()->hairpinType() == Hairpin::Type::CRESCENDO) { // crescendo switch (spannerSegmentType()) { case SpannerSegmentType::SINGLE: case SpannerSegmentType::BEGIN: l1.setLine(.0 + circledTipRadius*2, .0, len, h1); l2.setLine(.0 + circledTipRadius*2, .0, len, -h1); circledTip.setX( 0 + circledTipRadius ); circledTip.setY( 0 ); break; case SpannerSegmentType::MIDDLE: case SpannerSegmentType::END: drawCircledTip = false; l1.setLine(.0, h2, len, h1); l2.setLine(.0, -h2, len, -h1); break; } } else { // decrescendo switch(spannerSegmentType()) { case SpannerSegmentType::SINGLE: case SpannerSegmentType::END: l1.setLine(.0, h1, len - circledTipRadius*2, 0.0); l2.setLine(.0, -h1, len - circledTipRadius*2, 0.0); circledTip.setX( len - circledTipRadius ); circledTip.setY( 0 ); break; case SpannerSegmentType::BEGIN: case SpannerSegmentType::MIDDLE: drawCircledTip = false; l1.setLine(.0, h1, len, + h2); l2.setLine(.0, -h1, len, - h2); break; } } // Do Coord rotation l1 = t.map(l1); l2 = t.map(l2); if( drawCircledTip ) circledTip = t.map(circledTip); QRectF r = QRectF(l1.p1(), l1.p2()).normalized() | QRectF(l2.p1(), l2.p2()).normalized(); qreal w = point(score()->styleS(StyleIdx::hairpinLineWidth)); setbbox(r.adjusted(-w*.5, -w*.5, w, w)); if (parent()) rypos() += score()->styleS(StyleIdx::hairpinY).val() * _spatium; adjustReadPos(); }