Esempio n. 1
0
void TestBarline::barline04()
      {
      Score* score = readScore(DIR + "barline04.mscx");
      QVERIFY(score);
      score->doLayout();

      score->startCmd();
      // 'go' to 5th measure
      Measure* msr = score->firstMeasure();
      for (int i=0; i < 4; i++)
            msr = msr->nextMeasure();
      // check span data of measure-initial start-repeat bar line
      Segment* seg = msr->findSegment(SegmentType::StartRepeatBarLine, msr->tick());
      QVERIFY2(seg != nullptr, "No SegStartRepeatBarLine segment in measure 5.");

      BarLine* bar = static_cast<BarLine*>(seg->element(0));
      QVERIFY2(bar != nullptr, "No start-repeat barline in measure 5.");

      bar->undoChangeProperty(Pid::BARLINE_SPAN, 2);
      bar->undoChangeProperty(Pid::BARLINE_SPAN_FROM, 2);
      bar->undoChangeProperty(Pid::BARLINE_SPAN_TO, 6);
      score->endCmd();

      QVERIFY2(bar->spanStaff() && bar->spanFrom() == 2 && bar->spanTo() == 6,
            "Wrong span data in start-repeat barline of measure 5.");

      // check start-repeat bar ine in second staff is gone
      QVERIFY2(seg->element(1) == nullptr, "Extra start-repeat barline in 2nd staff of measure 5.");

//      QVERIFY(saveCompareScore(score, "barline04.mscx", DIR + "barline04-ref.mscx"));
      delete score;
      }
Esempio n. 2
0
void InspectorBarLine::manageSpanData()
      {
#if 0
      BarLine* bl = toBarLine(inspector->element());

      // determine MIN and MAX for SPANFROM and SPANTO
      Staff* staffFrom  = bl->staff();
      Staff* staffTo    = bl->score()->staff(bl->staffIdx() + bl->span() - 1);
      int staffFromLines= (staffFrom ? staffFrom->lines(bl->tick()) : 5);
      int staffToLines  = (staffTo   ? staffTo->lines(bl->tick())   : 5);

      // From:    min = minimum possible according to number of staff lines
      //          max = if same as To, at least 1sp (2 units) above To; if not, max possible according to num.of lines

      int min     = staffFromLines == 1 ? BARLINE_SPAN_1LINESTAFF_FROM : MIN_BARLINE_SPAN_FROMTO;
      int max     = bl->span() < 2 ? bl->spanTo() - MIN_BARLINE_FROMTO_DIST
                        : (staffFromLines == 1 ? BARLINE_SPAN_1LINESTAFF_TO : (staffFromLines-1) * 2 + 2);
      b.spanFrom->setMinimum(min);
      b.spanFrom->setMaximum(max);

      // To:      min = if same as From, at least 1sp (2 units) below From; if not, min possible according to num.of lines
      //          max = max possible according to number of staff lines
      min   = bl->span() < 2 ? bl->spanFrom() + MIN_BARLINE_FROMTO_DIST
                  : (staffToLines == 1 ? BARLINE_SPAN_1LINESTAFF_FROM : MIN_BARLINE_SPAN_FROMTO);
      max   = staffToLines == 1 ? BARLINE_SPAN_1LINESTAFF_TO : (staffToLines-1) * 2 + 2;

      b.spanTo->setMinimum(min);
      b.spanTo->setMaximum(max);

      // determine MAX for SPAN
      max = bl->score()->nstaves() - bl->staffIdx();
      b.span->setMaximum(max);
#endif
      }
Esempio n. 3
0
bool BarLine::acceptDrop(MuseScoreView*, const QPointF&, Element* e) const
      {
      int type = e->type();
      if (type == BAR_LINE) {
            if (parent() && parent()->type() == SEGMENT)
                  return true;
            if (parent() && parent()->type() == SYSTEM) {
                  BarLine* b = static_cast<BarLine*>(e);
                  return (b->barLineType() == BROKEN_BAR || b->barLineType() == DOTTED_BAR
                     || b->barLineType() == NORMAL_BAR || b->barLineType() == DOUBLE_BAR
                     || b->spanFrom() != 0 || b->spanTo() != DEFAULT_BARLINE_TO);
                  }
            }
      else {
            return (type == ARTICULATION
               && parent()
               && parent()->type() == SEGMENT
               && static_cast<Segment*>(parent())->segmentType() == Segment::SegEndBarLine);
            }
      return false;
      }
Esempio n. 4
0
bool BarLine::acceptDrop(const DropData& data) const
      {
      Element::Type type = data.element->type();
      if (type == Element::Type::BAR_LINE) {
            if (parent() && parent()->type() == Element::Type::SEGMENT)
                  return true;
            if (parent() && parent()->type() == Element::Type::SYSTEM) {
                  BarLine* b = static_cast<BarLine*>(data.element);
                  return (b->barLineType() == BarLineType::BROKEN || b->barLineType() == BarLineType::DOTTED
                     || b->barLineType() == BarLineType::NORMAL || b->barLineType() == BarLineType::DOUBLE
                     || b->spanFrom() != 0 || b->spanTo() != DEFAULT_BARLINE_TO);
                  }
            }
      else {
            return (type == Element::Type::ARTICULATION
               && parent()
               && parent()->type() == Element::Type::SEGMENT
               && static_cast<Segment*>(parent())->segmentType() == Segment::Type::EndBarLine);
            }
      return false;
      }
Esempio n. 5
0
Element* BarLine::drop(const DropData& data)
      {
      Element* e = data.element;
      int type = e->type();
      if (type == BAR_LINE) {
            BarLine* bl = static_cast<BarLine*>(e);
            BarLineType st = bl->barLineType();
            // if no change in subtype or no change in span, do nothing
            if (st == barLineType() && bl->spanFrom() == 0 && bl->spanTo() == DEFAULT_BARLINE_TO) {
                  delete e;
                  return 0;
                  }
            // system left-side bar line
            if (parent()->type() == SYSTEM) {
                  BarLine* b = static_cast<System*>(parent())->barLine();
                  score()->undoChangeProperty(b, P_SUBTYPE, int(bl->barLineType()));
                  delete e;
                  return 0;
                  }

            // check if the new property can apply to this single bar line
            bool oldRepeat = (barLineType() == START_REPEAT || barLineType() == END_REPEAT
                        || barLineType() == END_START_REPEAT);
            bool newRepeat = (bl->barLineType() == START_REPEAT || bl->barLineType() == END_REPEAT
                        || bl->barLineType() == END_START_REPEAT);
            // if repeats are not involved or drop refers to span rather than subtype =>
            // single bar line drop
            if( (!oldRepeat && !newRepeat) || (bl->spanFrom() != 0 || bl->spanTo() != DEFAULT_BARLINE_TO) ) {
                  // if drop refers to span, update this bar line span
                  if(bl->spanFrom() != 0 || bl->spanTo() != DEFAULT_BARLINE_TO) {
                        // if dropped spanFrom or spanTo are below the middle of standard staff (5 lines)
                        // adjust to the number of syaff lines
                        int bottomSpan = (staff()->lines()-1) * 2;
                        int spanFrom   = bl->spanFrom() > 4 ? bottomSpan - (8 - bl->spanFrom()) : bl->spanFrom();
                        int spanTo     = bl->spanTo() > 4 ? bottomSpan - (8 - bl->spanTo()) : bl->spanTo();
                        score()->undoChangeSingleBarLineSpan(this, 1, spanFrom, spanTo);
                        }
                  // if drop refer to subtype, update this bar line subtype
                  else {
                        score()->undoChangeProperty(this, P_SUBTYPE, int(bl->barLineType()));
//                        setCustomSubtype(true);
                        }
                  delete e;
                  return 0;
                  }

            // drop applies to all bar lines of the measure
            Measure* m = static_cast<Segment*>(parent())->measure();
            if (st == START_REPEAT) {
                  m = m->nextMeasure();
                  if (m == 0) {
                        delete e;
                        return 0;
                        }
                  }
            m->drop(data);
            }
      else if (type == ARTICULATION) {
            Articulation* atr = static_cast<Articulation*>(e);
            atr->setParent(this);
            atr->setTrack(track());
            score()->undoAddElement(atr);
            return atr;
            }
      return 0;
      }