Ejemplo n.º 1
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();
            }
      }
Ejemplo n.º 2
0
QLineF Text::dragAnchor() const
      {
      QPointF p1;

      if (parent()->type() == MEASURE) {
            Measure* m     = static_cast<Measure*>(parent());
            System* system = m->system();
            qreal yp       = system->staff(staffIdx())->y() + system->y() + system->page()->pos().x();
            qreal xp       = m->canvasPos().x(); // m->tick2pos(tick()) + m->canvasPos().x();
            p1 = QPointF(xp, yp);
            }
      else {
            p1 = QPointF(parent()->canvasBoundingRect().topLeft());
            if (parent()->type() == SEGMENT) {
                  Segment* s = static_cast<Segment*>(parent());
                  p1.ry() += s ? s->measure()->system()->staff(staffIdx())->y() : 0.0;
                  }
            }
      qreal tw = width();
      qreal th = height();
      qreal x  = 0.0;
      qreal y  = 0.0;
      if (align() & ALIGN_BOTTOM)
            y = th;
      else if (align() & ALIGN_VCENTER)
            y = (th * .5);
      else if (align() & ALIGN_BASELINE)
            y = baseLine();
      if (align() & ALIGN_RIGHT)
            x = tw;
      else if (align() & ALIGN_HCENTER)
            x = (tw * .5);
      return QLineF(p1, canvasBoundingRect().topLeft() + QPointF(x, y));
      }
Ejemplo n.º 3
0
void BarLine::getY(qreal* y1, qreal* y2) const
      {
      if (parent() && parent()->type() == SEGMENT) {
            int staffIdx1    = staffIdx();
            int staffIdx2    = staffIdx1 + _span - 1;
            if (staffIdx2 >= score()->nstaves()) {
                  qDebug("BarLine: bad _span %d\n", _span);
                  staffIdx2 = score()->nstaves() - 1;
                  }
            Segment* segment = static_cast<Segment*>(parent());
            Measure* measure = segment->measure();
            System* system   = measure->system();
            StaffLines* l1   = measure->staffLines(staffIdx1);
            StaffLines* l2   = measure->staffLines(staffIdx2);

            qreal yp = system ? system->staff(staffIdx())->y() : 0.0;
            *y1 = l1->y1() - yp;
            *y2 = l2->y2() - yp;
            }
      else {
            // for use in palette
            *y1 = 0.0;
            *y2 = 4.0 * spatium();
            }

      *y2 += yoff;
      }
Ejemplo n.º 4
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;
                        }
                  }
            }
      }
Ejemplo n.º 5
0
void BarLine::endEdit()
      {
      if (staff()->barLineSpan() == _span)
            return;

      int idx1 = staffIdx();

      if (_span > staff()->barLineSpan()) {
            // if span increased, set span to 0 for all newly spanned staves
            int idx2 = idx1 + _span;
            for (int idx = idx1 + 1; idx < idx2; ++idx)
                  score()->undoChangeBarLineSpan(score()->staff(idx), 0);
            }
      else {
            // if span decreased, set span to 1 (the default) for all staves no longer spanned
            int idx1 = staffIdx() + _span;
            int idx2 = staffIdx() + staff()->barLineSpan();
            for (int idx = idx1; idx < idx2; ++idx)
                  score()->undoChangeBarLineSpan(score()->staff(idx), 1);
            }
      // update span for the staff the edited bar line belongs to
      score()->undoChangeBarLineSpan(staff(), _span);
      // added "_score->setLayoutAll(true);" to ChangeBarLineSpan::flip()
      // otherwise no measure bar line update occurs
      }
Ejemplo n.º 6
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();
            }
      }
Ejemplo n.º 7
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();
            }
      }
Ejemplo n.º 8
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;
                        }
                  }
            }
      }
Ejemplo n.º 9
0
void BarLine::endEdit()
      {
      shiftDrag = false;

      if (ctrlDrag) {                      // if single bar line edit
            ctrlDrag = false;
            _customSpan       = true;           // mark bar line as custom spanning
            int newSpan       = _span;          // copy edited span values
            int newSpanFrom   = _spanFrom;
            int newSpanTo     = _spanTo;
            _span             = _origSpan;      // restore original span values
            _spanFrom         = _origSpanFrom;
            _spanTo           = _origSpanTo;
            score()->undoChangeSingleBarLineSpan(this, newSpan, newSpanFrom, newSpanTo);
            return;
            }

      // if same as staff settings, do nothing
      if (staff()->barLineSpan() == _span && staff()->barLineFrom() == _spanFrom && staff()->barLineTo() == _spanTo)
            return;

      int idx1 = staffIdx();

      if(_span != staff()->barLineSpan()) {
            // if now bar lines span more staves
            if (_span > staff()->barLineSpan()) {
                  int idx2 = idx1 + _span;
                  // set span 0 to all additional staves
                  for (int idx = idx1 + 1; idx < idx2; ++idx)
                        // mensurstrich special case:
                        // if line spans to top line of a stave AND current staff is
                        //    the last spanned staff BUT NOT the last score staff
                        //          keep its bar lines
                        // otherwise remove them
                        if(_spanTo > 0 || !(idx == idx2-1 && idx != score()->nstaves()-1) )
                              score()->undoChangeBarLineSpan(score()->staff(idx), 0, 0,
                                          (score()->staff(idx)->lines()-1)*2);
                  }
            // if now bar lines span fewer staves
            else {
                  int idx1 = staffIdx() + _span;
                  int idx2 = staffIdx() + staff()->barLineSpan();
                  // set standard span for each no-longer-spanned staff
                  for (int idx = idx1; idx < idx2; ++idx)
                        score()->undoChangeBarLineSpan(score()->staff(idx), 1, 0, (score()->staff(idx)->lines()-1)*2);
                  }
            }

      // update span for the staff the edited bar line belongs to
      score()->undoChangeBarLineSpan(staff(), _span, _spanFrom, _spanTo);
      }
Ejemplo n.º 10
0
Element* Marker::nextSegmentElement()
      {
      Segment* seg;
      if (markerType() == Marker::Type::FINE) {
            seg = measure()->last();
            return seg->firstElement(staffIdx());
            }
      Measure* prevMeasure = measure()->prevMeasureMM();
      if (prevMeasure) {
            seg = prevMeasure->last();
            return seg->firstElement(staffIdx());
            }
      return Element::nextSegmentElement();
      }
Ejemplo n.º 11
0
void BarLine::drawDots(QPainter* painter, qreal x) const
      {
      const Sym& dotsym = symbols[score()->symIdx()][dotSym];
      qreal mags = magS();
      qreal _spatium = spatium();

      if (parent() == 0) {    // for use in palette
            dotsym.draw(painter, mags, QPointF(x, 1.5 * _spatium));
            dotsym.draw(painter, mags, QPointF(x, 2.5 * _spatium));
            }
      else {
            System* s = measure()->system();
            int _staffIdx = staffIdx();
            qreal dy  = s->staff(_staffIdx)->y();
            for (int i = 0; i < _span; ++i) {
                  Staff* staff  = score()->staff(_staffIdx + i);
                  StaffType* st = staff->staffType();
                  qreal doty1   = st->doty1() * _spatium;
                  qreal doty2   = st->doty2() * _spatium;

                  qreal staffy  = s->staff(_staffIdx + i)->y() - dy;

                  dotsym.draw(painter, mags, QPointF(x, staffy + doty1));
                  dotsym.draw(painter, mags, QPointF(x, staffy + doty2));
                  }
            }
      }
Ejemplo n.º 12
0
QLineF FretDiagram::dragAnchor() const
      {
      Measure* m     = measure();
      System* system = m->system();
      qreal yp      = system->staff(staffIdx())->y() + system->y();
      qreal xp      = m->tick2pos(segment()->tick()) + m->pagePos().x();
      QPointF p1(xp, yp);

      qreal x  = 0.0;
      qreal y  = 0.0;
#if 0 // TODOxx
      qreal tw = width();
      qreal th = height();
      if (_align & ALIGN_BOTTOM)
            y = th;
      else if (_align & ALIGN_VCENTER)
            y = (th * .5);
      else if (_align & ALIGN_BASELINE)
            y = baseLine();
      if (_align & ALIGN_RIGHT)
            x = tw;
      else if (_align & ALIGN_HCENTER)
            x = (tw * .5);
#endif
      return QLineF(p1, abbox().topLeft() + QPointF(x, y));
      }
Ejemplo n.º 13
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();
      }
Ejemplo n.º 14
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
            }
      }
Ejemplo n.º 15
0
void Bracket::endEditDrag()
{
    qreal ay1 = pagePos().y();
    qreal ay2 = ay1 + h2 * 2;

    int staffIdx1 = staffIdx();
    int staffIdx2;
    int n = system()->staves()->size();
    if (staffIdx1 + 1 >= n)
        staffIdx2 = staffIdx1;
    else {
        qreal ay  = parent()->pagePos().y();
        System* s = system();
        qreal y   = s->staff(staffIdx1)->y() + ay;
        qreal h1  = staff()->height();

        for (staffIdx2 = staffIdx1 + 1; staffIdx2 < n; ++staffIdx2) {
            qreal h = s->staff(staffIdx2)->y() + ay - y;
            if (ay2 < (y + (h + h1) * .5))
                break;
            y += h;
        }
        staffIdx2 -= 1;
    }

    qreal sy = system()->staff(staffIdx1)->y();
    qreal ey = system()->staff(staffIdx2)->y() + score()->staff(staffIdx2)->height();
    h2 = (ey - sy) * .5;
    score()->undoChangeBracketSpan(staff(), _column, staffIdx2 - staffIdx1 + 1);
}
Ejemplo n.º 16
0
QRectF Dynamic::drag(EditData* ed)
      {
      QRectF f = Element::drag(ed);

      //
      // move anchor
      //
      Qt::KeyboardModifiers km = qApp->keyboardModifiers();
      if (km != (Qt::ShiftModifier | Qt::ControlModifier)) {
            int si;
            Segment* seg = 0;
            if (score()->pos2measure(ed->pos, &si, 0, &seg, 0) == nullptr)
                  return f;
            if (seg && (seg != segment() || staffIdx() != si)) {
                  QPointF pos1(canvasPos());
                  score()->undo(new ChangeParent(this, seg, si));
                  setUserOff(QPointF());
                  layout();
                  QPointF pos2(canvasPos());
                  setUserOff(pos1 - pos2);
                  ed->startMove = pos2;
                  }
            }
      return f;
      }
Ejemplo n.º 17
0
void RehearsalMark::layout()
      {
      if (autoplace())
            setUserOff(QPointF());
      setPos(textStyle().offset(spatium()));
      Text::layout1();
      Segment* s = segment();
      if (s) {
            if (!s->rtick()) {
                  // first CR of measure, decide whether to align to barline
                  if (!s->prev() && align() & AlignmentFlags::CENTER) {
                        // measure with no clef / keysig / timesig
                        rxpos() -= s->x();
                        }
                  else if (align() & AlignmentFlags::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()) {
                  Shape s1 = s->staffShape(staffIdx()).translated(s->pos());
                  Shape s2 = shape().translated(s->pos());
                  qreal d  = s2.minVerticalDistance(s1);
                  if (d > 0)
                        setUserOff(QPointF(0.0, -d));
                  }
            }
      }
Ejemplo n.º 18
0
void BarLine::drawDots(QPainter* painter, qreal x) const
      {
      const Sym& dotsym = symbols[score()->symIdx()][dotSym];
      qreal mags = magS();
      qreal _spatium = spatium();

      if (parent() == 0) {    // for use in palette
            dotsym.draw(painter, mags, QPointF(x, 1.5 * _spatium));
            dotsym.draw(painter, mags, QPointF(x, 2.5 * _spatium));
            }
      else if (parent()->type() == SEGMENT) {
            System* s = static_cast<Segment*>(parent())->measure()->system();
            int staffIdx1    = staffIdx();
            int staffIdx2    = staffIdx1 + _span - 1;
            int sp = _span;
            if (staffIdx2 >= score()->nstaves()) {
                  qDebug("BarLine: bad _span %d", _span);
                  staffIdx2 = score()->nstaves() - 1;
                  sp = staffIdx2 - staffIdx1 + 1;
                  }
            qreal dy  = s->staff(staffIdx1)->y();
            for (int i = 0; i < sp; ++i) {
                  Staff* staff  = score()->staff(staffIdx1 + i);
                  StaffType* st = staff->staffType();
                  qreal doty1   = st->doty1() * _spatium;
                  qreal doty2   = st->doty2() * _spatium;

                  qreal staffy  = s->staff(staffIdx1 + i)->y() - dy;

                  dotsym.draw(painter, mags, QPointF(x, staffy + doty1));
                  dotsym.draw(painter, mags, QPointF(x, staffy + doty2));
                  }
            }
      }
Ejemplo n.º 19
0
QLineF FretDiagram::dragAnchor() const
      {
      if (parent()->type() == Element::Type::SEGMENT) {
            Segment* s     = static_cast<Segment*>(parent());
            Measure* m     = s->measure();
            System* system = m->system();
            qreal yp      = system->staff(staffIdx())->y() + system->y();
            qreal xp      = m->tick2pos(s->tick()) + m->pagePos().x();
            QPointF p1(xp, yp);

            qreal x  = 0.0;
            qreal y  = 0.0;
#if 0 // TODOxx
            qreal tw = width();
            qreal th = height();
            if (_align & AlignmentFlags::BOTTOM)
                  y = th;
            else if (_align & AlignmentFlags::VCENTER)
                  y = (th * .5);
            else if (_align & AlignmentFlags::BASELINE)
                  y = baseLine();
            if (_align & AlignmentFlags::RIGHT)
                  x = tw;
            else if (_align & AlignmentFlags::HCENTER)
                  x = (tw * .5);
#endif
            return QLineF(p1, abbox().topLeft() + QPointF(x, y));
            }
      return QLineF(parent()->pagePos(), abbox().topLeft());
      }
Ejemplo n.º 20
0
QPointF LineSegment::gripAnchor(int grip) const
      {
      if (subtype() == SEGMENT_MIDDLE) {
            qreal y = system()->staffY(staffIdx());
            qreal x;
            switch(grip) {
                  case GRIP_LINE_START:
                        x = system()->firstMeasure()->abbox().left();
                        break;
                  case GRIP_LINE_END:
                        x = system()->lastMeasure()->abbox().right();
                        break;
                  default:
                  case GRIP_LINE_MIDDLE:
                        x = 0; // No Anchor
                        y = 0;
                        break;
                  }
            return QPointF(x, y);
            }
      else {
            if (grip == GRIP_LINE_MIDDLE) // center grip
                  return QPointF(0, 0);
            else {
                  System* s;
                  QPointF pt(line()->linePos(grip, &s));
                  return pt + s->pagePos();
                  }
            }
      }
Ejemplo n.º 21
0
void Ambitus::draw(QPainter* p) const
      {
      qreal _spatium = spatium();
      qreal lw = lineWidth().val() * _spatium;
      p->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap));
      drawSymbol(noteHead(), p, _topPos);
      drawSymbol(noteHead(), p, _bottomPos);
      if (_hasLine)
            p->drawLine(_line);

      // draw ledger lines (if not in a palette)
      if (segment() && track() > -1) {
            int tick          = segment()->tick();
            Staff* stf        = score()->staff(staffIdx());
            qreal lineDist    = stf->lineDistance(tick);
            int numOfLines    = stf->lines(tick);
            qreal step        = lineDist * _spatium;
            qreal stepTolerance = step * 0.1;
            qreal ledgerOffset = score()->styleS(Sid::ledgerLineLength).val() * 0.5 * _spatium;
            p->setPen(QPen(curColor(), score()->styleS(Sid::ledgerLineWidth).val() * _spatium,
                        Qt::SolidLine, Qt::RoundCap) );
            if (_topPos.y()-stepTolerance <= -step) {
                  qreal xMin = _topPos.x() - ledgerOffset;
                  qreal xMax = _topPos.x() + headWidth() + ledgerOffset;
                  for (qreal y = -step; y >= _topPos.y()-stepTolerance; y -= step)
                        p->drawLine(QPointF(xMin, y), QPointF(xMax, y));
                  }
            if (_bottomPos.y()+stepTolerance >= numOfLines * step) {
                  qreal xMin = _bottomPos.x() - ledgerOffset;
                  qreal xMax = _bottomPos.x() + headWidth() + ledgerOffset;
                  for (qreal y = numOfLines*step; y <= _bottomPos.y()+stepTolerance; y += step)
                        p->drawLine(QPointF(xMin, y), QPointF(xMax, y));
                  }
            }
      }
Ejemplo n.º 22
0
void Bracket::endEditDrag()
      {
      h2 += yoff * .5;
      yoff = 0.0;

      qreal ay1 = pagePos().y();
      qreal ay2 = ay1 + h2 * 2;

      int staffIdx1 = staffIdx();
      int staffIdx2;
      int n = system()->staves()->size();
      if (staffIdx1 + 1 >= n)
            staffIdx2 = staffIdx1;
      else {
            qreal ay  = parent()->pagePos().y();
            System* s = system();
            qreal y   = s->staff(staffIdx1)->y() + ay;
            qreal h1  = staff()->height();

            for (staffIdx2 = staffIdx1 + 1; staffIdx2 < n; ++staffIdx2) {
                  qreal h = s->staff(staffIdx2)->y() + ay - y;
                  if (ay2 < (y + (h + h1) * .5))
                        break;
                  y += h;
                  }
            staffIdx2 -= 1;
            }

      qreal sy = system()->staff(staffIdx1)->y();
      qreal ey = system()->staff(staffIdx2)->y() + score()->staff(staffIdx2)->height();
      h2 = (ey - sy) * .5 + score()->styleS(ST_bracketDistance).val() * spatium();

      int span = staffIdx2 - staffIdx1 + 1;
      staff()->setBracketSpan(_column, span);
      }
Ejemplo n.º 23
0
QPointF BarLine::pagePos() const
      {
      if (parent() == 0)
            return pos();
      System* system;
      if (parent()->type() != Element::Type::SEGMENT)
            system = static_cast<System*>(parent());
      else
            system = static_cast<Segment*>(parent())->measure()->system();

      qreal yp = y();
      if (system) {
            // get first not hidden staff
            int staffIdx1 = staffIdx();
            Staff* staff1 = score()->staff(staffIdx1);
            SysStaff* sysStaff1 = system->staff(staffIdx1);
            while ( staff1 && sysStaff1 && !(sysStaff1->show() && staff1->show()) ) {
                  staffIdx1++;
                  staff1 = score()->staff(staffIdx1);
                  sysStaff1 = system->staff(staffIdx1);
                  }
            yp += system->staffYpage(staffIdx1);
            }
      return QPointF(pageX(), yp);
      }
Ejemplo n.º 24
0
void BarLine::drawDots(QPainter* painter, qreal x) const
      {
      qreal _spatium = spatium();

      if (parent() == 0) {    // for use in palette
            drawSymbol(SymId::repeatDot, painter, QPointF(x, 2.0 * _spatium));
            drawSymbol(SymId::repeatDot, painter, QPointF(x, 3.0 * _spatium));
            }
      else if (parent()->type() == Element::Type::SEGMENT) {
            System* s = static_cast<Segment*>(parent())->measure()->system();
            int staffIdx1    = staffIdx();
            int staffIdx2    = staffIdx1 + _span - 1;
            int sp = _span;
            if (staffIdx2 >= score()->nstaves()) {
                  qDebug("BarLine: bad _span %d", _span);
                  staffIdx2 = score()->nstaves() - 1;
                  sp = staffIdx2 - staffIdx1 + 1;
                  }
            qreal dy  = s->staff(staffIdx1)->y();
            for (int i = 0; i < sp; ++i) {
                  Staff* staff  = score()->staff(staffIdx1 + i);
                  StaffType* st = staff->staffType();
                  qreal doty1   = (st->doty1() + .5) * _spatium;
                  qreal doty2   = (st->doty2() + .5) * _spatium;

                  qreal staffy  = s->staff(staffIdx1 + i)->y() - dy;

                  drawSymbol(SymId::repeatDot, painter, QPointF(x, staffy + doty1));
                  drawSymbol(SymId::repeatDot, painter, QPointF(x, staffy + doty2));
                  }
            }
      }
Ejemplo n.º 25
0
QString ChordRest::accessibleExtraInfo()
      {
      QString rez = "";
      foreach (Articulation* a, articulations())
            rez = QString("%1 %2").arg(rez).arg(a->screenReaderInfo());

      foreach (Element* l, lyricsList()) {
            if (!l)
                  continue;
            rez = QString("%1 %2").arg(rez).arg(l->screenReaderInfo());
            }

      if (segment()) {
            foreach (Element* e, segment()->annotations()) {
                  if (e->staffIdx() == staffIdx() )
                        rez = QString("%1 %2").arg(rez).arg(e->screenReaderInfo());
                  }

            SpannerMap& smap = score()->spannerMap();
            auto spanners = smap.findOverlapping(tick(), tick());
            for (auto i = spanners.begin(); i < spanners.end(); i++) {
                  const ::Interval<Spanner*> interval = *i;
                  Spanner* s = interval.value;
                  if (s->type() == Element::Type::VOLTA || //voltas are added for barlines
                      s->type() == Element::Type::TIE    ) //ties are added in notes
                        continue;

                  Segment* seg = 0;
                  if (s->type() == Element::Type::SLUR) {
                        if (s->tick() == tick() && s->track() == track())
                              rez = tr("%1 Start of %2").arg(rez).arg(s->screenReaderInfo());
                        if (s->tick2() == tick() && s->track2() == track())
                              rez = tr("%1 End of %2").arg(rez).arg(s->screenReaderInfo());
                        }
                  else  {
                        if (s->tick() == tick() && s->staffIdx() == staffIdx())
                              rez = tr("%1 Start of %2").arg(rez).arg(s->screenReaderInfo());
                        seg = segment()->next1MM(Segment::Type::ChordRest);
                        if (!seg)
                              continue;
                        if (s->tick2() == seg->tick() && s->staffIdx() == staffIdx())
                              rez = tr("%1 End of %2").arg(rez).arg(s->screenReaderInfo());
                        }
                  }
            }
      return rez;
      }
Ejemplo n.º 26
0
QLineF Dynamic::dragAnchor() const
      {
      qreal xp = 0.0;
      for (Element* e = parent(); e; e = e->parent())
            xp += e->x();
      qreal yp = measure()->system()->staffYpage(staffIdx());
      QPointF p(xp, yp);
      return QLineF(p, canvasPos());
      }
Ejemplo n.º 27
0
void Text::layout()
      {
      if (styled() && !_editMode) {
            SimpleText::layout();
            }
      else {
            _doc->setDefaultFont(textStyle().font(spatium()));
            qreal w = -1.0;
            qreal x = 0.0;
            qreal y = 0.0;
            if (parent() && layoutToParentWidth()) {
                  w = parent()->width();
                  if (parent()->type() == HBOX || parent()->type() == VBOX || parent()->type() == TBOX) {
                        Box* box = static_cast<Box*>(parent());
                        x += box->leftMargin() * MScore::DPMM;
                        y += box->topMargin() * MScore::DPMM;
                        w = box->width()   - ((box->leftMargin() + box->rightMargin()) * MScore::DPMM);
                        }
                  }

            QTextOption to = _doc->defaultTextOption();
            to.setUseDesignMetrics(true);
            to.setWrapMode(w <= 0.0 ? QTextOption::NoWrap : QTextOption::WrapAtWordBoundaryOrAnywhere);
            _doc->setDefaultTextOption(to);

            if (w < 0.0)
                  w = _doc->idealWidth();
            _doc->setTextWidth(w);

            setbbox(QRectF(QPointF(0.0, 0.0), _doc->size()));
            if (hasFrame())
                  layoutFrame();
            _doc->setModified(false);
            textStyle().layout(this);      // process alignment

#if 0 // TODO  TEXT_STYLE_TEXTLINE
            if ((textStyle().align() & ALIGN_VCENTER) && (textStyle() == TEXT_STYLE_TEXTLINE)) {
                  // special case: vertically centered text with TextLine needs to
                  // take into account the line width
                  TextLineSegment* tls = static_cast<TextLineSegment*>(parent());
                  TextLine* tl = tls->textLine();
                  if (tl) {
                        qreal textlineLineWidth = point(tl->lineWidth());
                        rypos() -= textlineLineWidth * .5;
                        }
                  }
#endif
            rxpos() += x;
            rypos() += y;
            }
      if (parent() && parent()->type() == SEGMENT) {
            Segment* s = static_cast<Segment*>(parent());
            rypos() += s ? s->measure()->system()->staff(staffIdx())->y() : 0.0;
            }
      adjustReadPos();
      }
Ejemplo n.º 28
0
QPointF Breath::pagePos() const
      {
      if (parent() == 0)
            return pos();
      System* system = segment()->measure()->system();
      qreal yp = y();
      if (system)
            yp += system->staff(staffIdx())->y() + system->y();
      return QPointF(pageX(), yp);
      }
Ejemplo n.º 29
0
QPointF BarLine::pagePos() const
      {
      if (parent() == 0)
            return pos();
      System* system = measure()->system();
      qreal yp = y();
      if (system)
            yp += system->staffY(staffIdx());
      return QPointF(pageX(), yp);
      }
Ejemplo n.º 30
0
QPointF SLine::linePos(int grip, System** sys)
      {
      qreal _spatium = spatium();

      qreal x = 0.0;

      if (anchor() == ANCHOR_SEGMENT) {
            Segment* seg = static_cast<Segment*>(grip == 0 ? startElement() : endElement());
            Measure* m   = seg->measure();
            *sys         = m->system();
            if (*sys == 0)
                  return QPointF(x, 0.0);
            x            = seg->pos().x() + m->pos().x();
            if (grip == GRIP_LINE_END) {
                  if (((*sys)->firstMeasure() == m) && (seg->tick() == m->tick())) {
                        m = m->prevMeasure();
                        if (m) {
                              *sys = m->system();
                              x = m->pos().x() + m->width();
                              }
                        }
                  }
            }
      else {
            // anchor() == ANCHOR_MEASURE
            Measure* m;
            if (grip == GRIP_LINE_START) {
                  m = static_cast<Measure*>(startElement());
                  x = m->pos().x();
                  }
            else {
                  m = static_cast<Measure*>(endElement());
                  x = m->pos().x() + m->bbox().right();
                  if (type() == VOLTA) {
                        Segment* seg = m->last();
                        if (seg->subtype() == SegEndBarLine) {
                              Element* e = seg->element(0);
                              if (e && e->type() == BAR_LINE) {
                                    if (static_cast<BarLine*>(e)->subtype() == START_REPEAT)
                                          x -= e->width() - _spatium * .5;
                                    else
                                          x -= _spatium * .5;
                                    }
                              }
                        }
                  }
            *sys = m->system();
            }
      //DEBUG:
      if ((*sys)->staves()->isEmpty())
            return QPointF(x, 0.0);

      qreal y = (*sys)->staff(staffIdx())->y();
      return QPointF(x, y);
      }