Ejemplo n.º 1
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->subtype();
            if (st == subtype()) {
                  delete e;
                  return 0;
                  }
            Measure* m = segment()->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()->select(atr, SELECT_SINGLE, 0);
            score()->undoAddElement(atr);
            }
      return 0;
      }
Ejemplo n.º 2
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->subtype() == BROKEN_BAR || b->subtype() == DOTTED_BAR
                      || b->subtype() == NORMAL_BAR || b->subtype() == DOUBLE_BAR
                      || b->spanFrom() != 0 || b->spanTo() != DEFAULT_BARLINE_TO);
              } 
      }else {
            return (type == ARTICULATION
                && parent()
                && parent()->type() == SEGMENT
                && static_cast<Segment*>(parent())->subtype() == Segment::SegEndBarLine);
            }
      return false;
      }
Ejemplo n.º 3
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->subtype();
            // if no change in subtype or no change in span, do nothing
            if (st == subtype() && 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->subtype()));
                  delete e;
                  return 0;
                  }

            // check if the new property can apply to this single bar line
            bool oldRepeat = (subtype() == START_REPEAT || subtype() == END_REPEAT
                        || subtype() == END_START_REPEAT);
            bool newRepeat = (bl->subtype() == START_REPEAT || bl->subtype() == END_REPEAT
                        || bl->subtype() == 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->subtype()));
//                        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;
      }