Пример #1
0
void PedalSegment::layout()
      {
      if (autoplace())
            setUserOff(QPointF());
      TextLineBaseSegment::layout();
      if (parent()) {     // for palette
            rypos() += score()->styleP(pedal()->placeBelow() ? StyleIdx::pedalPosBelow : StyleIdx::pedalPosAbove);
            if (autoplace()) {
                  qreal minDistance = spatium() * .7;
                  Shape s1 = shape().translated(pos());

                  if (pedal()->placeBelow()) {
                        qreal d  = system()->bottomDistance(staffIdx(), s1);
                        if (d > -minDistance)
                              rUserYoffset() = d + minDistance;
                        }
                  else {
                        qreal d  = system()->topDistance(staffIdx(), s1);
                        if (d > -minDistance)
                              rUserYoffset() = -(d + minDistance);
                        }
                  }
            else
                  adjustReadPos();
            }
      }
Пример #2
0
void StaffText::layout()
      {
      if (autoplace())
            setUserOff(QPointF());
      QPointF p(textStyle().offset(spatium()));
      if (placement() == Element::Placement::BELOW)
            p.ry() =  - p.ry() + lineHeight();
      setPos(p);
      Text::layout1();
      if (!parent()) // palette & clone trick
          return;

      if (autoplace() && segment()) {
            qreal minDistance = score()->styleP(StyleIdx::dynamicsMinDistance);  // TODO
            Shape s1          = segment()->staffShape(staffIdx()).translated(segment()->pos());
            Shape s2          = shape().translated(segment()->pos());

            if (placement() == Element::Placement::ABOVE) {
                  qreal d = s2.minVerticalDistance(s1);
                  if (d > -minDistance)
                        rUserYoffset() = -d - minDistance;
                  }
            else {
                  qreal d = s1.minVerticalDistance(s2);
                  if (d > -minDistance)
                        rUserYoffset() = d + minDistance;
                  }
            }
      adjustReadPos();
      }
Пример #3
0
void TextLineSegment::layout()
      {
      if (autoplace())
            setUserOff(QPointF());

      TextLineBaseSegment::layout();
      if (parent()) {
            if (textLine()->placeBelow()) {
                  qreal sh = staff() ? staff()->height() : 0.0;
                  rypos() = sh + score()->styleP(StyleIdx::textLinePosBelow) * mag();
                  }
            else
                  rypos() = score()->styleP(StyleIdx::textLinePosAbove) * mag();
            if (autoplace()) {
                  qreal minDistance = spatium() * .7;
                  Shape s1 = shape().translated(pos());
                  if (textLine()->placeAbove()) {
                        qreal d  = system()->topDistance(staffIdx(), s1);
                        if (d > -minDistance)
                              rUserYoffset() = -d - minDistance;
                        }
                  else {
                        qreal d  = system()->bottomDistance(staffIdx(), s1);
                        if (d > -minDistance)
                              rUserYoffset() = d + minDistance;
                        }
                  }
            else
                  adjustReadPos();
            }
      }
Пример #4
0
void Jump::layout()
      {
      setPos(QPointF(0.0, score()->styleP(Sid::jumpPosAbove)));
      TextBase::layout1();

      if (parent() && autoplace()) {
            setUserOff(QPointF());
#if 0
            int si             = staffIdx();
            qreal minDistance  = 0.5 * spatium(); // score()->styleP(Sid::tempoMinDistance);
            Shape& s1          = measure()->staffShape(si);
            Shape s2           = shape().translated(pos());
            if (placeAbove()) {
                  qreal d = s2.minVerticalDistance(s1);
                  if (d > -minDistance) {
                        qreal yd       = -d - minDistance;
                        rUserYoffset() = yd;
                        s2.translate(QPointF(0.0, yd));
                        }
                  }
            else {
                  qreal d = s1.minVerticalDistance(s2);
                  if (d > -minDistance) {
                        qreal yd       = d + minDistance;
                        rUserYoffset() = yd;
                        s2.translate(QPointF(0.0, yd));
                        }
                  }
            s1.add(s2);
#endif
            }
      }
Пример #5
0
void OttavaSegment::layout()
      {
      TextLineBaseSegment::layout();
      if (parent()) {
            qreal y;
            if (placeAbove()) {
                  y = score()->styleP(Sid::ottavaPosAbove);
                  }
            else {
                  qreal sh = ottava()->staff() ? ottava()->staff()->height() : 0;
                  y = score()->styleP(Sid::ottavaPosBelow) + sh;
                  }
            rypos() = y;
            if (autoplace()) {
                  setUserOff(QPointF());
                  qreal minDistance = spatium() * .7;
                  Shape s1 = shape().translated(pos());
                  if (ottava()->placeAbove()) {
                        qreal d  = system()->topDistance(staffIdx(), s1);
                        if (d > -minDistance)
                              rUserYoffset() = -d - minDistance;
                        }
                  else {
                        qreal d  = system()->bottomDistance(staffIdx(), s1);
                        if (d > -minDistance)
                              rUserYoffset() = d + minDistance;
                        }
                  }
            }
      }
Пример #6
0
void OttavaSegment::layout()
      {
      if (autoplace())
            setUserOff(QPointF());

      TextLineSegment::layout();
      if (parent()) {
            qreal yo = score()->styleP(StyleIdx::ottavaY) * mag();
            if (ottava()->placement() == Element::Placement::BELOW)
                  yo = -yo + staff()->height();
            rypos() += yo;
            if (autoplace()) {
                  qreal minDistance = spatium() * .7;
                  Shape s1 = shape().translated(pos());
                  if (ottava()->placement() == Element::Placement::ABOVE) {
                        qreal d  = system()->topDistance(staffIdx(), s1);
                        if (d > -minDistance)
                              rUserYoffset() = -d - minDistance;
                        }
                  else {
                        qreal d  = system()->bottomDistance(staffIdx(), s1);
                        if (d > -minDistance)
                              rUserYoffset() = d + minDistance;
                        }
                  }
            else
                  adjustReadPos();
            }
      }
Пример #7
0
void TrillSegment::layout()
      {
      if (autoplace())
            setUserOff(QPointF());

      if (staff())
            setMag(staff()->mag(tick()));
      if (isSingleType() || isBeginType()) {
            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->setParent(this);
                  }
            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:
                              symbolLine(SymId::ornamentBottomLeftConcaveStroke,
                                 SymId::ornamentZigZagLineNoRightEnd, SymId::ornamentZigZagLineWithRightEnd);
                        break;
                  case Trill::Type::DOWNPRALL_LINE:
                              symbolLine(SymId::ornamentLeftVerticalStroke,
                                 SymId::ornamentZigZagLineNoRightEnd, SymId::ornamentZigZagLineWithRightEnd);
                        break;
                  }
            }
      else
            symbolLine(SymId::wiggleTrill, SymId::wiggleTrill);

      if (parent()) {
            qreal yo = score()->styleP(trill()->placeBelow() ? Sid::trillPosBelow : Sid::trillPosAbove);
            rypos() = yo;
            if (autoplace()) {
                  qreal minDistance = spatium();
                  Shape s1 = shape().translated(pos());
                  if (trill()->placeAbove()) {
                        qreal d  = system()->topDistance(staffIdx(), s1);
                        if (d > -minDistance)
                              rUserYoffset() = -d - minDistance;
                        }
                  else {
                        qreal d  = system()->bottomDistance(staffIdx(), s1);
                        if (d > -minDistance)
                              rUserYoffset() = d + minDistance;
                        }
                  }
            }
      }
Пример #8
0
void RehearsalMark::layout()
      {
      if (autoplace())
            setUserOff(QPointF());
      qreal y;
      if (placeAbove())
            y = score()->styleP(StyleIdx::rehearsalMarkPosAbove);
      else {
            qreal sh = staff() ? staff()->height() : 0;
            y = score()->styleP(StyleIdx::rehearsalMarkPosBelow) + sh + lineSpacing();
            }
      setPos(QPointF(0.0, y));
      Text::layout1();

      Segment* s = segment();
      if (s) {
            if (!s->rtick()) {
                  // first CR of measure, decide whether to align to barline
                  if (!s->prev() && align() & Align::CENTER) {
                        // measure with no clef / keysig / timesig
                        rxpos() -= s->x();
                        }
                  else if (align() & Align::RIGHT) {
                        // measure with clef / keysig / timesig, rehearsal mark right aligned
                        // align left edge of rehearsal to barline if that is further to left
                        qreal leftX = bbox().x();
                        qreal barlineX = -s->x();
                        rxpos() += qMin(leftX, barlineX) + width();
                        }
                  }
            if (autoplace()) {
                  int firstStaffIdx = s->measure()->system()->firstVisibleStaff();
                  qreal minDistance = score()->styleP(StyleIdx::rehearsalMarkMinDistance);
                  Shape s1 = s->measure()->staffShape(firstStaffIdx);
                  Shape s2 = shape().translated(s->pos() + pos());
                  if (placeAbove()) {
                        qreal d = s2.minVerticalDistance(s1);
                        if (d > -minDistance)
                              rUserYoffset() = -d - minDistance;
                        }
                  else {
                        qreal d = s1.minVerticalDistance(s2);
                        if (d > -minDistance)
                              rUserYoffset() = d + minDistance;
                        }
                  }
            }
      }
Пример #9
0
void Ottava::setYoff(qreal val)
      {
      qreal _spatium = spatium();
      qreal yo(score()->styleS(StyleIdx::ottavaY).val() * _spatium);
      if (placement() == Element::Placement::BELOW)
            yo = -yo + staff()->height();
      rUserYoffset() += val * _spatium - yo;
      }
Пример #10
0
void VoltaSegment::layout()
      {
      if (autoplace())
            setUserOff(QPointF());
      TextLineBaseSegment::layout();
      if (!parent())
            return;
      rypos() = score()->styleP(StyleIdx::voltaY) * mag();
      if (autoplace()) {
            qreal minDistance = spatium() * .7;
            Shape s1 = shape().translated(pos());
            qreal d  = system()->topDistance(staffIdx(), s1);
            if (d > -minDistance)
                  rUserYoffset() = -d - minDistance;
            }
      else
            adjustReadPos();
      }
Пример #11
0
void Hairpin::setYoff(qreal val)
      {
      rUserYoffset() += (val - score()->styleS(StyleIdx::hairpinY).val()) * spatium();
      }
Пример #12
0
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();
      }
Пример #13
0
void Trill::setYoff(qreal val)
      {
      rUserYoffset() += (val - score()->styleS(StyleIdx::trillY).val()) * spatium();
      }
Пример #14
0
void Pedal::setYoff(qreal val)
      {
      rUserYoffset() += val * spatium() - score()->styleP(placeAbove() ? Sid::pedalPosAbove : Sid::pedalPosBelow);
      }
Пример #15
0
void Volta::setYoff(qreal val)
      {
      rUserYoffset() += (val - score()->styleS(StyleIdx::voltaY).val()) * spatium();
      }
Пример #16
0
void Trill::setYoff(qreal val)
      {
      rUserYoffset() += val * spatium() - score()->styleP(Sid::trillPosAbove);
      }
Пример #17
0
void Pedal::setYoff(qreal val)
      {
      rUserYoffset() += (val - score()->styleS(ST_pedalY).val()) * spatium();
      }
Пример #18
0
void Ottava::setYoff(qreal val)
      {
      rUserYoffset() += val * spatium() - score()->styleP(placeAbove() ? Sid::ottavaPosAbove : Sid::ottavaPosBelow);
      }