Esempio n. 1
0
void Stem::draw(QPainter* painter) const
      {
      bool useTab = false;
      Staff* st = staff();
      if (st && st->isTabStaff()) {     // stems used in palette do not have a staff
            if (st->staffType()->slashStyle())
                  return;
            useTab = true;
            }
      qreal lw = point(score()->styleS(ST_stemWidth));
      painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap));
      painter->drawLine(line);

      // NOT THE BEST PLACE FOR THIS?
      // with tablatures, dots are not drawn near 'notes', but near stems
      // TODO: adjust bounding rectangle in layout()
      if (useTab) {
            int nDots = chord()->dots();
            if (nDots > 0) {
                  qreal sp = spatium();
                  qreal y = stemLen() - ( ((StaffTypeTablature*)st->staffType())->stemsDown() ?
                              (STAFFTYPE_TAB_DEFAULTSTEMLEN_DN - 0.75) * sp : 0.0 );
                  symbols[score()->symIdx()][dotSym].draw(painter, magS(),
                              QPointF(STAFFTYPE_TAB_DEFAULTDOTDIST_X * sp, y), nDots);
                  }
            }
      }
Esempio n. 2
0
void OttavaSegment::layout()
      {
      if (autoplace())
            setUserOff(QPointF());

      TextLineBaseSegment::layout();
      if (parent()) {
            qreal yo = score()->styleP(StyleIdx::ottavaY) * mag();
            if (ottava()->placeBelow())
                  yo = -yo + staff()->height();
            rypos() += yo;
            if (autoplace()) {
                  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;
                        }
                  }
            else
                  adjustReadPos();
            }
      }
Esempio n. 3
0
void BarLine::read(XmlReader& e)
      {
      // if bar line belongs to a staff, span values default to staff values
      if (staff()) {
            _span     = staff()->barLineSpan();
            _spanFrom = staff()->barLineFrom();
            _spanTo   = staff()->barLineTo();
            }
      while (e.readNextStartElement()) {
            const QStringRef& tag(e.name());
            if (tag == "subtype") {
                  bool ok;
                  const QString& val(e.readElementText());
                  int i = val.toInt(&ok);
                  if (!ok)
                        setBarLineType(val);
                  else {
                        BarLineType ct = NORMAL_BAR;
                        switch (i) {
                              default:
                              case  0: ct = NORMAL_BAR; break;
                              case  1: ct = DOUBLE_BAR; break;
                              case  2: ct = START_REPEAT; break;
                              case  3: ct = END_REPEAT; break;
                              case  4: ct = BROKEN_BAR; break;
                              case  5: ct = END_BAR; break;
                              case  6: ct = END_START_REPEAT; break;
                              case  7: ct = DOTTED_BAR; break;
                              }
                        setBarLineType(ct);
                        }
                  if (parent() && parent()->type() == SEGMENT) {
                        Measure* m = static_cast<Segment*>(parent())->measure();
                        if (barLineType() != m->endBarLineType())
                              _customSubtype = true;
                        }
                  }
            else if (tag == "customSubtype")
                  _customSubtype = e.readInt();
            else if (tag == "span") {
                  _span       = e.readInt();
                  _spanFrom   = e.intAttribute("from", _spanFrom);
                  _spanTo     = e.intAttribute("to", _spanTo);
                  // WARNING: following statements assume staff and staff bar line spans are correctly set
                  if (staff() && (_span != staff()->barLineSpan()
                     || _spanFrom != staff()->barLineFrom() || _spanTo != staff()->barLineTo()))
                        _customSpan = true;
                  }
            else if (tag == "Articulation") {
                  Articulation* a = new Articulation(score());
                  a->read(e);
                  add(a);
                  }
            else if (!Element::readProperties(e))
                  e.unknown();
            }
      }
Esempio n. 4
0
void BarLine::read(const QDomElement& de)
      {
      // if bar line belongs to a staff, span values default to staff values
      if(staff()) {
            _span       = staff()->barLineSpan();
            _spanFrom   = staff()->barLineFrom();
            _spanTo     = staff()->barLineTo();
      }
      for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {
            const QString& tag(e.tagName());
            const QString& val(e.text());
            if (tag == "subtype") {
                  bool ok;
                  int i = val.toInt(&ok);
                  if (!ok)
                        setSubtype(val);
                  else {
                        BarLineType ct = NORMAL_BAR;
                        switch (i) {
                              default:
                              case  0: ct = NORMAL_BAR; break;
                              case  1: ct = DOUBLE_BAR; break;
                              case  2: ct = START_REPEAT; break;
                              case  3: ct = END_REPEAT; break;
                              case  4: ct = BROKEN_BAR; break;
                              case  5: ct = END_BAR; break;
                              case  6: ct = END_START_REPEAT; break;
                              case  7: ct = DOTTED_BAR; break;
                              }
                        setSubtype(ct);
                        }
                  if(parent() && parent()->type() == SEGMENT) {
                        Measure* m = static_cast<Segment*>(parent())->measure();
                        if(subtype() != m->endBarLineType())
                              setCustomSubtype(true);
                        }
                  }
            else if (tag == "customSubtype")
                  setCustomSubtype(val.toInt() != 0);
            else if (tag == "span") {
                  _span       = val.toInt();
                  _spanFrom   = e.attribute("from", QString::number(_spanFrom)).toInt();
                  _spanTo     = e.attribute("to", QString::number(_spanTo)).toInt();
                  // WARNING: following statements assume staff and staff bar line spans are correctly set
                  if(staff() && (_span != staff()->barLineSpan()
                              || _spanFrom != staff()->barLineFrom() || _spanTo != staff()->barLineTo()))
                        _customSpan = true;
                  }
            else if (tag == "Articulation") {
                  Articulation* a = new Articulation(score());
                  a->read(e);
                  add(a);
                  }
            else if (!Element::readProperties(e))
                  domError(e);
            }
      }
Esempio n. 5
0
void Articulation::draw(Painter* painter) const
      {
      SymId sym = _up ? articulationList[subtype()].upSym : articulationList[subtype()].downSym;
      int flags = articulationList[subtype()].flags;
      if (staff()) {
            bool tab = staff()->useTablature();
            if (tab) {
                  if (!(flags & ARTICULATION_SHOW_IN_TABLATURE))
                        return;
                  }
            else {
                  if (!(flags & ARTICULATION_SHOW_IN_PITCHED_STAFF))
                        return;
                  }
            }
      symbols[score()->symIdx()][sym].draw(painter, magS());
      }
Esempio n. 6
0
void KeySig::layout()
      {
      qreal _spatium = spatium();
      setbbox(QRectF());

      if (staff() && !staff()->genKeySig()) {     // no key sigs on TAB staves
            qDeleteAll(keySymbols);
            return;
            }

      if (isCustom()) {
            foreach(KeySym* ks, keySymbols) {
                  ks->pos = ks->spos * _spatium;
                  addbbox(symBbox(ks->sym).translated(ks->pos));
                  }
            return;
            }
Esempio n. 7
0
void Articulation::draw(QPainter* painter) const
      {
      SymId sym = _up ? articulationList[articulationType()].upSym : articulationList[articulationType()].downSym;
      int flags = articulationList[articulationType()].flags;
      if (staff()) {
            if (staff()->staffGroup() == TAB_STAFF_GROUP) {
                  if (!(flags & ARTICULATION_SHOW_IN_TABLATURE))
                        return;
                  }
            else {
                  if (!(flags & ARTICULATION_SHOW_IN_PITCHED_STAFF))
                        return;
                  }
            }
      painter->setPen(curColor());
      drawSymbol(sym, painter, QPointF(-0.5 * width(), _up ? 0.0 : height()));
      }
Esempio n. 8
0
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();
}
Esempio n. 9
0
void Harmony::write(Xml& xml) const
      {
      if (!xml.canWrite(this)) return;
      xml.stag("Harmony");
      if (_leftParen)
            xml.tagE("leftParen");
      if (_rootTpc != Tpc::TPC_INVALID || _baseTpc != Tpc::TPC_INVALID) {
            int rRootTpc = _rootTpc;
            int rBaseTpc = _baseTpc;
            if (staff()) {
                  const Interval& interval = staff()->part()->instr()->transpose();
                  if (xml.clipboardmode && !score()->styleB(StyleIdx::concertPitch) && interval.chromatic) {
                        rRootTpc = transposeTpc(_rootTpc, interval, false);
                        rBaseTpc = transposeTpc(_baseTpc, interval, false);
                        }
                  }
            if (rRootTpc != Tpc::TPC_INVALID)
                  xml.tag("root", rRootTpc);
            if (_id > 0)
                  xml.tag("extension", _id);
            if (_textName != "")
                  xml.tag("name", _textName);
            if (rBaseTpc != Tpc::TPC_INVALID)
                  xml.tag("base", rBaseTpc);
            foreach(const HDegree& hd, _degreeList) {
                  HDegreeType tp = hd.type();
                  if (tp == HDegreeType::ADD || tp == HDegreeType::ALTER || tp == HDegreeType::SUBTRACT) {
                        xml.stag("degree");
                        xml.tag("degree-value", hd.value());
                        xml.tag("degree-alter", hd.alter());
                        switch (tp) {
                              case HDegreeType::ADD:
                                    xml.tag("degree-type", "add");
                                    break;
                              case HDegreeType::ALTER:
                                    xml.tag("degree-type", "alter");
                                    break;
                              case HDegreeType::SUBTRACT:
                                    xml.tag("degree-type", "subtract");
                                    break;
                              default:
                                    break;
                              }
                        xml.etag();
                        }
                  }
/// Tests the Constructors
/// @return True if all tests were executed, false if not
bool StaffTestSuite::TestCaseConstructor()
{
    //------Last Checked------//
    // - Jan 5, 2005
    
    // TEST CASE: Default Constructor
    {
        Staff staff;
        TEST(wxT("Default Constructor"),
            (staff.GetClef() == Staff::DEFAULT_CLEF) &&
            (staff.GetTablatureStaffType() == Staff::DEFAULT_TABLATURE_STAFF_TYPE) &&
            (staff.GetStandardNotationStaffAboveSpacing() == Staff::DEFAULT_STANDARD_NOTATION_STAFF_ABOVE_SPACING) &&
            (staff.GetStandardNotationStaffBelowSpacing() == Staff::DEFAULT_STANDARD_NOTATION_STAFF_BELOW_SPACING) &&
            (staff.GetSymbolSpacing() == Staff::DEFAULT_SYMBOL_SPACING) &&
            (staff.GetTablatureStaffBelowSpacing() == Staff::DEFAULT_TABLATURE_STAFF_BELOW_SPACING)
        );
    }
    
    // TEST CASE: Primary Constructor
    {
        Staff staff(4, Staff::BASS_CLEF);
        staff.m_positionArray[0].Add(new Position);
        staff.m_positionArray[1].Add(new Position);
        
        TEST(wxT("Copy Constructor"),
            (staff.GetClef() == Staff::BASS_CLEF) &&
            (staff.GetTablatureStaffType() == 4) &&
            (staff.GetStandardNotationStaffAboveSpacing() == Staff::DEFAULT_STANDARD_NOTATION_STAFF_ABOVE_SPACING) &&
            (staff.GetStandardNotationStaffBelowSpacing() == Staff::DEFAULT_STANDARD_NOTATION_STAFF_BELOW_SPACING) &&
            (staff.GetSymbolSpacing() == Staff::DEFAULT_SYMBOL_SPACING) &&
            (staff.GetTablatureStaffBelowSpacing() == Staff::DEFAULT_TABLATURE_STAFF_BELOW_SPACING)
        );
    }
    
    // TEST CASE: Copy Constructor
    {
        Staff staff(4, Staff::BASS_CLEF);
        staff.m_positionArray[0].Add(new Position);
        staff.m_positionArray[1].Add(new Position);
        Staff staff2(staff);
        
        TEST(wxT("Copy Constructor"), staff == staff2);
    }
    
    return (true);
}
Esempio n. 11
0
void Articulation::draw(QPainter* painter) const
      {
      SymId sym = _up ? articulationList[articulationType()].upSym : articulationList[articulationType()].downSym;
      int flags = articulationList[articulationType()].flags;
      if (staff()) {
            if (staff()->staffGroup() == TAB_STAFF) {
                  if (!(flags & ARTICULATION_SHOW_IN_TABLATURE))
                        return;
                  }
            else {
                  if (!(flags & ARTICULATION_SHOW_IN_PITCHED_STAFF))
                        return;
                  }
            }
      painter->setPen(curColor());
      symbols[score()->symIdx()][sym].draw(painter, magS());
      }
Esempio n. 12
0
void Articulation::draw(QPainter* painter) const
      {
      SymId sym = _up ? articulationList[int(articulationType())].upSym : articulationList[int(articulationType())].downSym;
      ArticulationShowIn flags = articulationList[int(articulationType())].flags;
      if (staff()) {
            if (staff()->staffGroup() == StaffGroup::TAB) {
                  if (!(flags & ArticulationShowIn::TABLATURE))
                        return;
                  }
            else {
                  if (!(flags & ArticulationShowIn::PITCHED_STAFF))
                        return;
                  }
            }
      painter->setPen(curColor());
      drawSymbol(sym, painter, QPointF(-0.5 * width(), 0.0));
      }
Esempio n. 13
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;
      }
Esempio n. 14
0
void StaffTextBase::layout()
      {
      Staff* s = staff();
      qreal y = placeAbove() ? styleP(Sid::staffTextPosAbove) : styleP(Sid::staffTextPosBelow) + (s ? s->height() : 0.0);
      setPos(QPointF(0.0, y));
      TextBase::layout1();
      autoplaceSegmentElement(styleP(Sid::staffTextMinDistance));
      }
Esempio n. 15
0
/**  In record mode  add new 'empty' note segment at the end off the staff when index is on its last note
 * but ignore last possible note on the staff - new staff is already created with a new single note */
void TmultiScore::checkAndAddNote(TscoreStaff* sendStaff, int noteIndex) {
  if (insertMode() == e_record && noteIndex == sendStaff->count() - 1 && noteIndex != sendStaff->maxNoteCount() - 1) {
      Tnote nn(0, 0, 0);
      m_addNoteAnim = false; // do not show adding note animation when note is added here
      sendStaff->addNote(nn);
      if (staff()->noteSegment(0)->noteName())
        sendStaff->noteSegment(sendStaff->count() - 1)->showNoteName();
  }
}
Esempio n. 16
0
Tnote TmultiScore::getNote(int index) {
  if (index >= 0 && index < notesCount()) {
    if (insertMode() == e_single)
      return *staff()->getNote(index);
    else
      return *noteFromId(index)->note();
  } else
      return Tnote();
}
Esempio n. 17
0
void TmultiScore::setInsertMode(TmultiScore::EinMode mode) {
  if (mode != m_inMode) {
    bool ignoreThat = false;
    if ((mode == e_record && m_inMode == e_multi) || (mode == e_multi && m_inMode == e_record))
      ignoreThat = true;
    m_inMode = mode;
    if (ignoreThat)
      return;
    if (mode == e_single) {
        scoreScene()->left()->enableToAddNotes(false); // It has to be invoked before deleteNotes() to hide 'enter note' text
        scoreScene()->right()->enableToAddNotes(false);
        deleteNotes();
        staff()->noteSegment(0)->setBackgroundColor(-1); // unset background
        staff()->setStafNumber(-1);
        staff()->setViewWidth(0.0);
        staff()->setSelectableNotes(false);
        m_addNoteAnim = false;
        staff()->insertNote(1, true);
        m_addNoteAnim = false;
        staff()->insertNote(2, true);
        setControllersEnabled(true, false);
        setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        m_currentIndex = 0;
        m_selectReadOnly = false;
        if (!m_fakeLines.isEmpty()) {
          for (int i = 0 ; i < m_fakeLines.size(); ++i)
            delete m_fakeLines[i];
          m_fakeLines.clear();
        }
    } else {
        staff()->setStafNumber(0);
        staff()->removeNote(2);
        staff()->removeNote(1);
        staff()->setSelectableNotes(true);
        setControllersEnabled(true, true);
        scoreScene()->left()->enableToAddNotes(true);
        scoreScene()->right()->enableToAddNotes(true);
        setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
        setMaximumWidth(QWIDGETSIZE_MAX); // revert what TsimpleScore 'broke'
        setNote(0, Tnote());
    }
    resizeEvent(0);
  }
}
Esempio n. 18
0
void Ottava::endEdit()
      {
      if (editTick != tick() || editTick2 != tick2()) {
            Staff* s = staff();
            s->updateOttava();
            score()->addLayoutFlags(LayoutFlag::FIX_PITCH_VELO);
            score()->setPlaylistDirty(true);
            }
      TextLine::endEdit();
      }
Esempio n. 19
0
void TsimpleScore::onClefChanged(Tclef clef) {
  if (isPianoStaff())
    emit clefChanged(Tclef(Tclef::e_pianoStaff));
  else
    emit clefChanged(staff()->scoreClef()->clef());
  if ((m_clefType == Tclef::e_pianoStaff && clef.type() != Tclef::e_pianoStaff) ||
      (m_clefType != Tclef::e_pianoStaff && clef.type() == Tclef::e_pianoStaff)  )
          resizeEvent(0);
  m_clefType = clef.type();
}
Esempio n. 20
0
void TsimpleScore::addBGglyph(int instr) {
  if (instr < 0 || instr > 3)
      return;
  m_prevBGglyph = instr;
  if (m_bgGlyph)
    delete m_bgGlyph;
  m_bgGlyph = new QGraphicsSimpleTextItem(instrumentToGlyph(Einstrument(instr)));
  m_bgGlyph->setParentItem(staff());
  m_bgGlyph->setFont(TnooFont());
  QColor bgColor = palette().highlight().color();
  bgColor.setAlpha(50);
  m_bgGlyph->setBrush(bgColor);
  qreal factor = (staff()->height() / m_bgGlyph->boundingRect().height());
  m_bgGlyph->setScale(factor);
  m_bgGlyph->setPos((staff()->width() - m_bgGlyph->boundingRect().width() * factor) / 2 ,
                  (staff()->height() - m_bgGlyph->boundingRect().height() * factor) / 2);
  m_bgGlyph->setZValue(1);

}
Esempio n. 21
0
void KeySig::layout()
{
    qreal _spatium = spatium();
    setbbox(QRectF());

    if (staff() && !staff()->genKeySig()) {     // no key sigs on TAB staves
        foreach(KeySym* ks, keySymbols)
            delete ks;
        keySymbols.clear();
        return;
    }

    if (isCustom()) {
        foreach(KeySym* ks, keySymbols) {
            ks->pos = ks->spos * _spatium;
            addbbox(symbols[score()->symIdx()][ks->sym].bbox(magS()).translated(ks->pos));
        }
        return;
    }
Esempio n. 22
0
void Symbol::draw(QPainter* p) const
      {
      if (!isNoteDot() || !staff()->isTabStaff(tick())) {
            p->setPen(curColor());
            if (_scoreFont)
                  _scoreFont->draw(_sym, p, magS(), QPointF());
            else
                  drawSymbol(_sym, p);
            }
      }
Esempio n. 23
0
void Symbol::draw(QPainter* p) const
{
    if (type() != NOTEDOT || !staff()->isTabStaff()) {
        p->setPen(curColor());
        if (_scoreFont)
            _scoreFont->draw(_sym, p, magS(), QPointF());
        else
            drawSymbol(_sym, p);
    }
}
Esempio n. 24
0
void InstrumentChange::write(Xml& xml) const
      {
      xml.stag("InstrumentChange");
      if (segment())
            staff()->part()->instr(segment()->tick())->write(xml); // _instrument may not reflect mixer changes
      else
            _instrument.write(xml);
      Text::writeProperties(xml);
      xml.etag();
      }
Esempio n. 25
0
void TmultiScore::setNote(const Tnote& note) {
  if (insertMode() != e_single) {
      if (currentIndex() == -1)
        changeCurrentIndex(0);
      TscoreStaff *thisStaff = currentStaff();
      if (insertMode() == e_record) {
          if (m_clickedOff > 0)
            checkAndAddNote(thisStaff, currentIndex() % staff()->maxNoteCount());
          changeCurrentIndex(currentIndex() + m_clickedOff);
          thisStaff = currentStaff();
          m_clickedOff = 1;
      }
      thisStaff->setNote(currentIndex() % staff()->maxNoteCount(), note);
      if (staffCount() > 1)
        QTimer::singleShot(5, this, SLOT(ensureNoteIsVisible()));
  } else {
      TsimpleScore::setNote(0, note);
  }
}
Esempio n. 26
0
void Fermata::draw(QPainter* painter) const
      {
#if 0
      SymId sym = symId();
      FermataShowIn flags = articulationList[int(articulationType())].flags;
      if (staff()) {
            if (staff()->staffGroup() == StaffGroup::TAB) {
                  if (!(flags & FermataShowIn::TABLATURE))
                        return;
                  }
            else {
                  if (!(flags & FermataShowIn::PITCHED_STAFF))
                        return;
                  }
            }
#endif
      painter->setPen(curColor());
      drawSymbol(_symId, painter, QPointF(-0.5 * width(), 0.0));
      }
Esempio n. 27
0
bool Ottava::setProperty(P_ID propertyId, const QVariant& val)
      {
      switch (propertyId) {
            case P_ID::OTTAVA_TYPE:
                  setOttavaType(OttavaType(val.toInt()));
                  break;

            case P_ID::LINE_WIDTH:
                  lineWidthStyle = PropertyStyle::UNSTYLED;
                  TextLine::setProperty(propertyId, val);
                  break;

            case P_ID::LINE_STYLE:
                  lineStyleStyle = PropertyStyle::UNSTYLED;
                  TextLine::setProperty(propertyId, val);
                  break;

            case P_ID::NUMBERS_ONLY:
                  setNumbersOnly(val.toBool());
                  setOttavaType(_ottavaType);
                  numbersOnlyStyle = PropertyStyle::UNSTYLED;
                  break;

            case P_ID::SPANNER_TICK2:
                  staff()->pitchOffsets().remove(tick2());
                  setTick2(val.toInt());
                  staff()->updateOttava(this);
                  break;

            case P_ID::SPANNER_TICK:
                  staff()->pitchOffsets().remove(tick());
                  setTick(val.toInt());
                  staff()->updateOttava(this);
                  break;

            default:
                  if (!TextLine::setProperty(propertyId, val))
                        return false;
                  break;
            }
      score()->setLayoutAll(true);
      return true;
      }
Esempio n. 28
0
void Stem::draw(QPainter* painter) const
      {
      Staff* st = staff();
      bool useTab = st && st->isTabStaff();

      if (useTab && st->staffType()->slashStyle())
            return;
      qreal lw = lineWidth();
      painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap));
      painter->drawLine(line);
      if (!useTab)
            return;

      // TODO: adjust bounding rectangle in layout() for dots and for slash
      StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st->staffType());
      qreal sp = spatium();

      // slashed half note stem
      if (chord() && chord()->durationType().type() == TDuration::V_HALF
         && stt->minimStyle() == TAB_MINIM_SLASHED) {
            qreal wdt   = sp * STAFFTYPE_TAB_SLASH_WIDTH;
            qreal sln   = sp * STAFFTYPE_TAB_SLASH_SLANTY;
            qreal thk   = sp * STAFFTYPE_TAB_SLASH_THICK;
            qreal displ = sp * STAFFTYPE_TAB_SLASH_DISPL;
            QPainterPath path;

            qreal y = stt->stemsDown() ?
                         _len - STAFFTYPE_TAB_SLASH_2STARTY_DN*sp :
                        -_len + STAFFTYPE_TAB_SLASH_2STARTY_UP*sp;
            for (int i = 0; i < 2; ++i) {
                  path.moveTo( wdt*0.5-lw, y);        // top-right corner
                  path.lineTo( wdt*0.5-lw, y+thk);    // bottom-right corner
                  path.lineTo(-wdt*0.5,    y+thk+sln);// bottom-left corner
                  path.lineTo(-wdt*0.5,    y+sln);    // top-left corner
                  path.closeSubpath();
                  y += displ;
                  }
//            setbbox(path.boundingRect());
            painter->setBrush(QBrush(curColor()));
            painter->setPen(Qt::NoPen);
            painter->drawPath(path);
            }

      // dots
      // NOT THE BEST PLACE FOR THIS?
      // with tablatures, dots are not drawn near 'notes', but near stems
      int nDots = chord()->dots();
      if (nDots > 0) {
            qreal y = stemLen() - (stt->stemsDown() ?
                        (STAFFTYPE_TAB_DEFAULTSTEMLEN_DN - 0.75) * sp : 0.0 );
            symbols[score()->symIdx()][dotSym].draw(painter, magS(),
                        QPointF(STAFFTYPE_TAB_DEFAULTDOTDIST_X * sp, y), nDots);
            }
      }
Esempio n. 29
0
void TmultiScore::addStaff(TscoreStaff* st) {
  if (st == 0) { // create new staff at the end of a list
    m_staves << new TscoreStaff(scoreScene(), 0);
    lastStaff()->onClefChanged(m_staves.first()->scoreClef()->clef());
    lastStaff()->scoreClef()->setReadOnly(m_staves.first()->scoreClef()->readOnly());
    lastStaff()->setEnableKeySign(staff()->scoreKey());
    if (lastStaff()->scoreKey())
      lastStaff()->scoreKey()->setKeySignature(m_staves.first()->scoreKey()->keySignature());
    connect(lastStaff(), SIGNAL(hiNoteChanged(int,qreal)), this, SLOT(staffHiNoteChanged(int,qreal))); // ignore for first
    lastStaff()->setDisabled(m_isDisabled);
  } else { // staff of TsimpleScore is added this way
Esempio n. 30
0
void OttavaSegment::layout()
      {
      TextLineSegment::layout1();
      if (parent()) {     // for palette
            qreal yo(score()->styleS(StyleIdx::ottavaY).val() * spatium());
            if (ottava()->placement() == Placement::BELOW)
                  yo = -yo + staff()->height();
            rypos() += yo;
            }
      adjustReadPos();
      }