Exemplo n.º 1
0
void MuseScore::addTempo()
{
    ChordRest* cr = cs->getSelectedChordRest();
    if (!cr)
        return;
//      double bps = 2.0;

    SigEvent event = cs->sigmap()->timesig(cr->tick());
    Fraction f = event.nominal();

    QString text(QString("%1%2 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5f)));
    switch (f.denominator()) {
    case 1:
        text = QString("%1%2 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5d));
        break;
    case 2:
        text = QString("%1%2 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5e));
        break;
    case 4:
        text = QString("%1%2 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5f));
        break;
    case 8:
        if(f.numerator() % 3 == 0)
            text = QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5f)).arg(QChar(0xd834)).arg(QChar(0xdd6d));
        else
            text = QString("%1%2 = 80").arg(QChar(0xd834)).arg(QChar(0xdd60));
        break;
    case 16:
        if(f.numerator() % 3 == 0)
            text = QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd60)).arg(QChar(0xd834)).arg(QChar(0xdd6d));
        else
            text = text = QString("%1%2 = 80").arg(QChar(0xd834)).arg(QChar(0xdd61));
        break;
    case 32:
        if(f.numerator() % 3 == 0)
            text = QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd61)).arg(QChar(0xd834)).arg(QChar(0xdd6d));
        else
            text = text = QString("%1%2 = 80").arg(QChar(0xd834)).arg(QChar(0xdd62));
        break;
    case 64:
        if(f.numerator() % 3 == 0)
            text = QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd62)).arg(QChar(0xd834)).arg(QChar(0xdd6d));
        else
            text = text = QString("%1%2 = 80").arg(QChar(0xd834)).arg(QChar(0xdd63));
        break;
    default:
        break;
    }

    TempoText* tt = new TempoText(cs);
    tt->setParent(cr->segment());
    tt->setTrack(cr->track());
    tt->setText(text);
    tt->setFollowText(true);
    //tt->setTempo(bps);
    cs->undoAddElement(tt);
    cv->startEdit(tt);
}
Exemplo n.º 2
0
void MuseScore::addTempo()
      {
      ChordRest* cr = cs->getSelectedChordRest();
      if (!cr)
            return;
//      double bps = 2.0;

      SigEvent event = cs->sigmap()->timesig(cr->tick());
      Fraction f = event.nominal();
      QString text("<sym>noteQuarterUp</sym> = 80");
      switch (f.denominator()) {
            case 1:
                  text = "<sym>noteWhole</sym> = 80";
                  break;
            case 2:
                  text = "<sym>noteHalfUp</sym> = 80";
                  break;
            case 4:
                  text = "<sym>noteQuarterUp</sym> = 80";
                  break;
            case 8:
                  if(f.numerator() % 3 == 0)
                        text = "<sym>noteQuarterUp</sym><sym>textAugmentationDot</sym> = 80";
                  else
                        text = "<sym>note8thUp</sym> = 80";
                  break;
            case 16:
                  if(f.numerator() % 3 == 0)
                        text = text = "<sym>note8thUp</sym><sym>textAugmentationDot</sym> = 80";
                  else
                        text = "<sym>note16thUp</sym> = 80";
                  break;
            case 32:
                  if(f.numerator() % 3 == 0)
                        text = "<sym>note16thUp</sym><sym>textAugmentationDot</sym> = 80";
                  else
                        text = "<sym>note32thUp</sym> = 80";
                  break;
            case 64:
                  if(f.numerator() % 3 == 0)
                        text = "<sym>note32thUp</sym><sym>textAugmentationDot</sym> = 80";
                  else
                        text = "<sym>note64thUp</sym> = 80";
                  break;
            default:
                  break;
            }

      TempoText* tt = new TempoText(cs);
      tt->setParent(cr->segment());
      tt->setTrack(cr->track());
      tt->setText(text);
      tt->setFollowText(true);
      //tt->setTempo(bps);
      cs->undoAddElement(tt);
      cv->startEdit(tt);
      }
Exemplo n.º 3
0
void MuseScore::addTempo()
{
    ChordRest* cr = cs->getSelectedChordRest();
    if (!cr)
        return;
    if (editTempo == 0)
        editTempo = new EditTempo(0);
    int rv = editTempo->exec();
    if (rv == 1) {
        double bps = editTempo->bpm() / 60.0;
        TempoText* tt = new TempoText(cs);
        tt->setParent(cr->segment());
        tt->setTrack(cr->track());
        tt->setText(editTempo->text());
        tt->setTempo(bps);
        cs->undoAddElement(tt);
        cs->addRefresh(tt->abbox());  // ??
    }
}
Exemplo n.º 4
0
Element* ChordRest::drop(const DropData& data)
      {
      Element* e = data.element;
      Measure* m  = measure();
      switch (e->type()) {
            case Element::Type::BREATH:
                  {
                  Breath* b = static_cast<Breath*>(e);
                  b->setTrack(staffIdx() * VOICES);

                  // TODO: insert automatically in all staves?

                  Segment* seg = m->undoGetSegment(Segment::Type::Breath, tick());
                  b->setParent(seg);
                  score()->undoAddElement(b);
                  }
                  return e;

            case Element::Type::BAR_LINE:
                  {
                  BarLine* bl = static_cast<BarLine*>(e);
                  bl->setTrack(staffIdx() * VOICES);

                  if (tick() == m->tick())
                        return m->drop(data);

                  Segment* seg = m->undoGetSegment(Segment::Type::BarLine, tick());
                  bl->setParent(seg);
                  score()->undoAddElement(bl);
                  }
                  return e;

            case Element::Type::CLEF:
                  score()->cmdInsertClef(static_cast<Clef*>(e), this);
                  break;

            case Element::Type::TEMPO_TEXT:
                  {
                  TempoText* tt = static_cast<TempoText*>(e);
                  tt->setParent(segment());
                  TextStyleType st = tt->textStyleType();
                  tt->setTextStyleType(st);
                  score()->undoAddElement(tt);
                  }
                  return e;

            case Element::Type::DYNAMIC:
                  {
                  Dynamic* d = static_cast<Dynamic*>(e);
                  d->setTrack(track());
                  TextStyleType st = d->textStyleType();
                  d->setTextStyleType(st);
                  d->setParent(segment());
                  score()->undoAddElement(d);
                  }
                  return e;
            case Element::Type::FRET_DIAGRAM:
            case Element::Type::SYMBOL:
                  e->setTrack(track());
                  e->setParent(segment());
                  score()->undoAddElement(e);
                  return e;

            case Element::Type::NOTE:
                  {
                  Note* note = static_cast<Note*>(e);
                  NoteVal nval;
                  nval.pitch = note->pitch();
                  nval.headGroup = note->headGroup();
                  nval.fret = note->fret();
                  nval.string = note->string();
                  score()->setNoteRest(segment(), track(), nval, data.duration, MScore::Direction::AUTO);
                  delete e;
                  }
                  break;

            case Element::Type::HARMONY:
                  static_cast<Harmony*>(e)->render();
                  // fall through
            case Element::Type::TEXT:
            case Element::Type::STAFF_TEXT:
            case Element::Type::STAFF_STATE:
            case Element::Type::INSTRUMENT_CHANGE:
            case Element::Type::REHEARSAL_MARK:
                  e->setParent(segment());
                  e->setTrack((track() / VOICES) * VOICES);
                  {
                  Text* f = static_cast<Text*>(e);
                  TextStyleType st = f->textStyleType();
                  if (st >= TextStyleType::DEFAULT)
                        f->setTextStyleType(st);
                  }
                  score()->undoAddElement(e);
                  return e;

            case Element::Type::FIGURED_BASS:
                  {
                  bool bNew;
                  FiguredBass * fb = static_cast<FiguredBass *>(e);
                  fb->setParent( segment() );
                  fb->setTrack( (track() / VOICES) * VOICES );
                  fb->setTicks( duration().ticks() );
                  fb->setOnNote(true);
                  FiguredBass::addFiguredBassToSegment(segment(),
                        fb->track(), fb->ticks(), &bNew);
                  if (bNew)
                        score()->undoAddElement(e);
                  return e;
                  }

            case Element::Type::IMAGE:
                  e->setParent(segment());
                  score()->undoAddElement(e);
                  return e;

            case Element::Type::ICON:
                  {
                  switch(static_cast<Icon*>(e)->iconType()) {
                        case IconType::SBEAM:
                              score()->undoChangeProperty(this, P_ID::BEAM_MODE, int(Beam::Mode::BEGIN));
                              break;
                        case IconType::MBEAM:
                              score()->undoChangeProperty(this, P_ID::BEAM_MODE, int(Beam::Mode::MID));
                              break;
                        case IconType::NBEAM:
                              score()->undoChangeProperty(this, P_ID::BEAM_MODE, int(Beam::Mode::NONE));
                              break;
                        case IconType::BEAM32:
                              score()->undoChangeProperty(this, P_ID::BEAM_MODE, int(Beam::Mode::BEGIN32));
                              break;
                        case IconType::BEAM64:
                              score()->undoChangeProperty(this, P_ID::BEAM_MODE, int(Beam::Mode::BEGIN64));
                              break;
                        case IconType::AUTOBEAM:
                              score()->undoChangeProperty(this, P_ID::BEAM_MODE, int(Beam::Mode::AUTO));
                              break;
                        default:
                              break;
                        }
                  }
                  delete e;
                  break;

            default:
                  qDebug("cannot drop %s", e->name());
                  delete e;
                  return 0;
            }
      return 0;
      }