Esempio n. 1
0
void InspectorNote::setElement()
      {
      Note* note = static_cast<Note*>(inspector->element());
      dot1->setEnabled(note->dot(0));
      dot2->setEnabled(note->dot(1));
      dot3->setEnabled(note->dot(2));
      stem->setEnabled(note->chord()->stem());
      hook->setEnabled(note->chord()->hook());
      beam->setEnabled(note->chord()->beam());
      InspectorBase::setElement();
      }
Esempio n. 2
0
void InspectorNote::setElement()
      {
      Note* note = static_cast<Note*>(inspector->element());

      int n = note->dots().size();
      dot1->setEnabled(n > 0);
      dot2->setEnabled(n > 1);
      dot3->setEnabled(n > 2);
      stem->setEnabled(note->chord()->stem());
      hook->setEnabled(note->chord()->hook());
      beam->setEnabled(note->chord()->beam());
      tuplet->setEnabled(note->chord()->tuplet());
      InspectorBase::setElement();
      bool nograce = !note->chord()->isGrace();
      s.leadingSpace->setEnabled(nograce);
      s.resetLeadingSpace->setEnabled(nograce && s.leadingSpace->value());
      }
Esempio n. 3
0
void InspectorNote::setElement()
      {
      Note* note = toNote(inspector->element());

      int i = note->dots().size();
      n.dot1->setEnabled(i > 0);
      n.dot2->setEnabled(i > 1);
      n.dot3->setEnabled(i > 2);
      n.dot4->setEnabled(i > 3);
      n.stem->setEnabled(note->chord()->stem());
      n.hook->setEnabled(note->chord()->hook());
      n.beam->setEnabled(note->chord()->beam());
      n.tuplet->setEnabled(note->chord()->tuplet());
      InspectorElementBase::setElement();
      bool nograce = !note->chord()->isGrace();
      s.leadingSpace->setEnabled(nograce);
      s.resetLeadingSpace->setEnabled(nograce && s.leadingSpace->value());
      }
Esempio n. 4
0
void InspectorNote::setElement(Element* e)
      {
      Note* note = static_cast<Note*>(e);
      Segment* segment = note->chord()->segment();

      iElement->setElement(e);
      iNote->setElement(note);
      iSegment->setElement(segment);
      }
Esempio n. 5
0
void InspectorNote::tupletClicked()
      {
      Note* note = toNote(inspector->element());
      if (note == 0)
            return;
      Tuplet* tuplet = note->chord()->tuplet();
      if (tuplet) {
            note->score()->select(tuplet);
            inspector->setElement(tuplet);
            note->score()->update();
            }
      }
Esempio n. 6
0
void InspectorNote::beamClicked()
      {
      Note* note = toNote(inspector->element());
      if (note == 0)
            return;
      Beam* beam = note->chord()->beam();
      if (beam) {
            note->score()->select(beam);
            inspector->setElement(beam);
            note->score()->update();
            }
      }
Esempio n. 7
0
void InspectorNote::stemClicked()
      {
      Note* note = toNote(inspector->element());
      if (note == 0)
            return;
      Stem* stem = note->chord()->stem();
      if (stem) {
            note->score()->select(stem);
            inspector->setElement(stem);
            note->score()->update();
            }
      }
Esempio n. 8
0
void InspectorNote::hookClicked()
      {
      Note* note = toNote(inspector->element());
      if (note == 0)
            return;
      Hook* hook = note->chord()->hook();
      if (hook) {
            note->score()->select(hook);
            inspector->setElement(hook);
            note->score()->update();
            }
      }
Esempio n. 9
0
void InspectorNote::tupletClicked()
      {
      Note* note = static_cast<Note*>(inspector->element());
      if (note == 0)
            return;
      Tuplet* tuplet = note->chord()->tuplet();
      if (tuplet) {
            note->score()->select(tuplet);
            inspector->setElement(tuplet);
            note->score()->end();
            }
      }
Esempio n. 10
0
void InspectorNote::beamClicked()
      {
      Note* note = static_cast<Note*>(inspector->element());
      if (note == 0)
            return;
      Beam* beam = note->chord()->beam();
      if (beam) {
            note->score()->select(beam);
            inspector->setElement(beam);
            note->score()->end();
            }
      }
Esempio n. 11
0
void InspectorNote::stemClicked()
      {
      Note* note = static_cast<Note*>(inspector->element());
      if (note == 0)
            return;
      Stem* stem = note->chord()->stem();
      if (stem) {
            note->score()->select(stem);
            inspector->setElement(stem);
            note->score()->end();
            }
      }
Esempio n. 12
0
void InspectorNote::hookClicked()
      {
      Note* note = static_cast<Note*>(inspector->element());
      if (note == 0)
            return;
      Hook* hook = note->chord()->hook();
      if (hook) {
            note->score()->select(hook);
            inspector->setElement(hook);
            note->score()->end();
            }
      }
Esempio n. 13
0
Placement Fingering::calculatePlacement() const
      {
      Note* n = note();
      if (!n)
            return Placement::ABOVE;
      Chord* chord = n->chord();
      Staff* staff = chord->staff();
      Part* part   = staff->part();
      int nstaves  = part->nstaves();
      bool voices  = chord->measure()->hasVoices(staff->idx());
      bool below   = voices ? !chord->up() : (nstaves > 1) && (staff->rstaff() == nstaves - 1);
      return below ? Placement::BELOW : Placement::ABOVE;
      }
Esempio n. 14
0
void InputState::update(Element* e)
      {
      if (e == 0)
            return;
      if (e && e->type() == Element::Type::CHORD)
            e = static_cast<Chord*>(e)->upNote();

      setDrumNote(-1);
      if (e->type() == Element::Type::NOTE) {
            Note* note    = static_cast<Note*>(e);
            Chord* chord  = note->chord();
            setDuration(chord->durationType());
            setRest(false);
            setTrack(note->track());
            setNoteType(note->noteType());
            setBeamMode(chord->beamMode());
            }
      else if (e->type() == Element::Type::REST) {
            Rest* rest   = static_cast<Rest*>(e);
            if (rest->durationType().type() == TDuration::DurationType::V_MEASURE)
                  setDuration(TDuration::DurationType::V_QUARTER);
            else
                  setDuration(rest->durationType());
            setRest(true);
            setTrack(rest->track());
            setBeamMode(rest->beamMode());
            setNoteType(NoteType::NORMAL);
            }
      if (e->type() == Element::Type::NOTE || e->type() == Element::Type::REST) {
            const Instrument* instr = e->part()->instrument();
            if (instr->useDrumset()) {
                  if (e->type() == Element::Type::NOTE)
                        setDrumNote(static_cast<Note*>(e)->pitch());
                  else
                        setDrumNote(-1);
                  }
            }
      }
Esempio n. 15
0
void Fingering::layout()
      {
      if (parent()) {
            Fraction tick = parent()->tick();
            const Staff* st = staff();
            if (st && st->isTabStaff(tick) && !st->staffType(tick)->showTabFingering()) {
                  setbbox(QRectF());
                  return;
                  }
            }

      TextBase::layout();
      rypos() = 0.0;    // handle placement below

      if (autoplace() && note()) {
            Note* n      = note();
            Chord* chord = n->chord();
            bool voices  = chord->measure()->hasVoices(chord->staffIdx());
            bool tight   = voices && chord->notes().size() == 1 && !chord->beam() && tid() != Tid::STRING_NUMBER;

            qreal headWidth = n->bboxRightPos();

            // update offset after drag
            qreal rebase = 0.0;
            if (offsetChanged() != OffsetChange::NONE)
                  rebase = rebaseOffset();

            // temporarily exclude self from chord shape
            setAutoplace(false);

            if (layoutType() == ElementType::CHORD) {
                  Stem* stem = chord->stem();
                  Segment* s = chord->segment();
                  Measure* m = s->measure();
                  qreal sp = spatium();
                  qreal md = minDistance().val() * sp;
                  SysStaff* ss = m->system()->staff(chord->vStaffIdx());
                  Staff* vStaff = chord->staff();     // TODO: use current height at tick

                  if (n->mirror())
                        rxpos() -= n->ipos().x();
                  rxpos() += headWidth * .5;
                  if (placeAbove()) {
                        if (tight) {
                              if (chord->stem())
                                    rxpos() -= 0.8 * sp;
                              rypos() -= 1.5 * sp;
                              }
                        else {
                              QRectF r = bbox().translated(m->pos() + s->pos() + chord->pos() + n->pos() + pos());
                              SkylineLine sk(false);
                              sk.add(r.x(), r.bottom(), r.width());
                              qreal d = sk.minDistance(ss->skyline().north());
                              qreal yd = 0.0;
                              if (d > 0.0 && isStyled(Pid::MIN_DISTANCE))
                                    yd -= d + height() * .25;
                              // force extra space above staff & chord (but not other fingerings)
                              qreal top;
                              if (chord->up() && chord->beam() && stem) {
                                    top = stem->y() + stem->bbox().top();
                                    }
                              else {
                                    Note* un = chord->upNote();
                                    top = qMin(0.0, un->y() + un->bbox().top());
                                    }
                              top -= md;
                              qreal diff = (bbox().bottom() + ipos().y() + yd + n->y()) - top;
                              if (diff > 0.0)
                                    yd -= diff;
                              if (offsetChanged() != OffsetChange::NONE) {
                                    // user moved element within the skyline
                                    // we may need to adjust minDistance, yd, and/or offset
                                    bool inStaff = placeAbove() ? r.bottom() + rebase > 0.0 : r.top() + rebase < staff()->height();
                                    rebaseMinDistance(md, yd, sp, rebase, inStaff);
                                    }
                              rypos() += yd;
                              }
                        }
                  else {
                        if (tight) {
                              if (chord->stem())
                                    rxpos() += 0.8 * sp;
                              rypos() += 1.5 * sp;
                              }
                        else {
                              QRectF r = bbox().translated(m->pos() + s->pos() + chord->pos() + n->pos() + pos());
                              SkylineLine sk(true);
                              sk.add(r.x(), r.top(), r.width());
                              qreal d = ss->skyline().south().minDistance(sk);
                              qreal yd = 0.0;
                              if (d > 0.0 && isStyled(Pid::MIN_DISTANCE))
                                    yd += d + height() * .25;
                              // force extra space below staff & chord (but not other fingerings)
                              qreal bottom;
                              if (!chord->up() && chord->beam() && stem) {
                                    bottom = stem->y() + stem->bbox().bottom();
                                    }
                              else {
                                    Note* dn = chord->downNote();
                                    bottom = qMax(vStaff->height(), dn->y() + dn->bbox().bottom());
                                    }
                              bottom += md;
                              qreal diff = bottom - (bbox().top() + ipos().y() + yd + n->y());
                              if (diff > 0.0)
                                    yd += diff;
                              if (offsetChanged() != OffsetChange::NONE) {
                                    // user moved element within the skyline
                                    // we may need to adjust minDistance, yd, and/or offset
                                    bool inStaff = placeAbove() ? r.bottom() + rebase > 0.0 : r.top() + rebase < staff()->height();
                                    rebaseMinDistance(md, yd, sp, rebase, inStaff);
                                    }
                              rypos() += yd;
                              }
                        }
                  }
            else if (tid() == Tid::LH_GUITAR_FINGERING) {
                  // place to left of note
                  qreal left = n->shape().left();
                  if (left - n->x() > 0.0)
                        rxpos() -= left;
                  else
                        rxpos() -= n->x();
                  }
            // for other fingering styles, do not autoplace

            // restore autoplace
            setAutoplace(true);
            }
      else if (offsetChanged() != OffsetChange::NONE) {
            // rebase horizontally too, as autoplace may have adjusted it
            rebaseOffset(false);
            }
      setOffsetChanged(false);
      }
Esempio n. 16
0
void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup)
      {
      if (e->type() == BAR_LINE) {
            genPropertyMenu1(e, popup);
            }
      else if (e->type() == ARTICULATION) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Articulation Properties..."))->setData("a-props");
            }
      else if (e->type() == BEAM) {
            popup->addAction(getAction("flip"));
            }
      else if (e->type() == STEM) {
            popup->addAction(getAction("flip"));
            }
      else if (e->type() == HOOK) {
            popup->addAction(getAction("flip"));
            }
      else if (e->type() == BEND) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Bend Properties..."))->setData("b-props");
            }
      else if (e->type() == TREMOLOBAR) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("TremoloBar Properties..."))->setData("tr-props");
            }
      else if (e->type() == HBOX) {
            QMenu* textMenu = popup->addMenu(tr("Add"));
            textMenu->addAction(getAction("frame-text"));
            textMenu->addAction(getAction("picture"));
            popup->addAction(tr("Frame Properties..."))->setData("f-props");
            }
      else if (e->type() == VBOX) {
            QMenu* textMenu = popup->addMenu(tr("Add"));
            textMenu->addAction(getAction("frame-text"));
            textMenu->addAction(getAction("title-text"));
            textMenu->addAction(getAction("subtitle-text"));
            textMenu->addAction(getAction("composer-text"));
            textMenu->addAction(getAction("poet-text"));
            textMenu->addAction(getAction("insert-hbox"));
            textMenu->addAction(getAction("picture"));
            popup->addAction(tr("Frame Properties..."))->setData("f-props");
            }
      else if (e->type() == TBOX) {
            popup->addAction(tr("Frame Properties..."))->setData("f-props");
            }
      else if (e->type() == TUPLET) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Tuplet Properties..."))->setData("tuplet-props");
            }
      else if (e->type() == VOLTA_SEGMENT) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Volta Properties..."))->setData("v-props");
            }
      else if (e->type() == TIMESIG) {
            genPropertyMenu1(e, popup);
            TimeSig* ts = static_cast<TimeSig*>(e);
            int _track = ts->track();
            // if the time sig. is not generated (= not courtesy) and is in track 0
            // add the specific menu item
            QAction* a;
            if (!ts->generated() && !_track) {
                  a = popup->addAction(ts->showCourtesySig()
                     ? QT_TRANSLATE_NOOP("TimeSig", "Hide Courtesy Time Signature")
                     : QT_TRANSLATE_NOOP("TimeSig", "Show Courtesy Time Signature") );
                  a->setData("ts-courtesy");
                  }
            popup->addSeparator();
            popup->addAction(tr("Time Signature Properties..."))->setData("ts-props");
            }
      else if (e->type() == ACCIDENTAL) {
            Accidental* acc = static_cast<Accidental*>(e);
            genPropertyMenu1(e, popup);
            QAction* a = popup->addAction(QT_TRANSLATE_NOOP("Properties", "small"));
            a->setCheckable(true);
            a->setChecked(acc->small());
            a->setData("smallAcc");
            }
      else if (e->type() == CLEF) {
            genPropertyMenu1(e, popup);
            // if the clef is not generated (= not courtesy) add the specific menu item
            if (!e->generated()) {
                  QAction* a = popup->addAction(static_cast<Clef*>(e)->showCourtesy()
                     ? QT_TRANSLATE_NOOP("Clef", "Hide courtesy clef")
                     : QT_TRANSLATE_NOOP("Clef", "Show courtesy clef") );
                        a->setData("clef-courtesy");
                  }
            }
      else if (e->type() == DYNAMIC) {
            popup->addSeparator();
            if (e->visible())
                  popup->addAction(tr("Set Invisible"))->setData("invisible");
            else
                  popup->addAction(tr("Set Visible"))->setData("invisible");
            popup->addAction(tr("MIDI Properties..."))->setData("d-dynamics");
            popup->addAction(tr("Text Properties..."))->setData("d-props");
            }
      else if (e->type() == TEXTLINE_SEGMENT || e->type() == OTTAVA_SEGMENT) {
            if (e->visible())
                  popup->addAction(tr("Set Invisible"))->setData("invisible");
            else
                  popup->addAction(tr("Set Visible"))->setData("invisible");
            popup->addAction(tr("Line Properties..."))->setData("l-props");
            }
      else if (e->type() == STAFF_TEXT) {
            genPropertyMenuText(e, popup);
            popup->addAction(tr("Staff Text Properties..."))->setData("st-props");
            }
      else if (e->type() == TEXT || e->type() == FINGERING || e->type() == LYRICS) {
            genPropertyMenuText(e, popup);
            }
      else if (e->type() == TEMPO_TEXT) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Tempo Properties..."))->setData("tempo-props");
            popup->addAction(tr("Text Properties..."))->setData("text-props");
            }
      else if (e->type() == KEYSIG) {
            genPropertyMenu1(e, popup);
            KeySig* ks = static_cast<KeySig*>(e);
            if (!e->generated()) {
                  QAction* a = popup->addAction(ks->showCourtesy()
                     ? QT_TRANSLATE_NOOP("KeySig", "Hide Courtesy Key Signature")
                     : QT_TRANSLATE_NOOP("KeySig", "Show Courtesy Key Signature") );
                  a->setData("key-courtesy");
                  a = popup->addAction(ks->showNaturals()
                     ? QT_TRANSLATE_NOOP("KeySig", "Hide Naturals")
                     : QT_TRANSLATE_NOOP("KeySig", "Show Naturals") );
                  a->setData("key-naturals");
                  }
            }
      else if (e->type() == STAFF_STATE && static_cast<StaffState*>(e)->subtype() == STAFF_STATE_INSTRUMENT) {
            popup->addAction(tr("Change Instrument Properties..."))->setData("ss-props");
            }
      else if (e->type() == SLUR_SEGMENT) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Edit Mode"))->setData("edit");
            popup->addAction(tr("Slur Properties..."))->setData("slur-props");
            }
      else if (e->type() == REST) {
            Rest* rest = static_cast<Rest*>(e);
            genPropertyMenu1(e, popup);
            if (rest->tuplet()) {
                  popup->addSeparator();
                  QMenu* menuTuplet = popup->addMenu(tr("Tuplet..."));
                  menuTuplet->addAction(tr("Tuplet Properties..."))->setData("tuplet-props");
                  menuTuplet->addAction(tr("Delete Tuplet"))->setData("tupletDelete");
                  }
            }
      else if (e->type() == NOTE) {
            Note* note = static_cast<Note*>(e);

            QAction* b = popup->actions()[0];
            QAction* a = popup->insertSeparator(b);
            a->setText(tr("Staff"));
            a = new QAction(tr("Staff Properties..."), 0);
            a->setData("staff-props");
            popup->insertAction(b, a);

            a = popup->insertSeparator(b);
            a->setText(tr("Measure"));
            a = new QAction(tr("Measure Properties..."), 0);
            a->setData("measure-props");
            popup->insertAction(b, a);

            genPropertyMenu1(e, popup);
            popup->addSeparator();

            popup->addAction(tr("Style..."))->setData("style");

            if (note->chord()->tuplet()) {
                  QMenu* menuTuplet = popup->addMenu(tr("Tuplet..."));
                  menuTuplet->addAction(tr("Tuplet Properties..."))->setData("tuplet-props");
                  menuTuplet->addAction(tr("Delete Tuplet"))->setData("tupletDelete");
                  }
            popup->addAction(tr("Chord Articulation..."))->setData("articulation");
            }
      else if (e->type() == MARKER) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Marker Properties..."))->setData("marker-props");
            }
      else if (e->type() == JUMP) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Jump Properties..."))->setData("jump-props");
            }
      else if (e->type() == LAYOUT_BREAK && static_cast<LayoutBreak*>(e)->subtype() == LAYOUT_BREAK_SECTION) {
            popup->addAction(tr("Section Break Properties..."))->setData("break-props");
            }
      else if (e->type() == INSTRUMENT_CHANGE) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Change Instrument..."))->setData("ch-instr");
            }
      else if (e->type() == FRET_DIAGRAM) {
            if (e->visible())
                  popup->addAction(tr("Set Invisible"))->setData("invisible");
            else
                  popup->addAction(tr("Set Visible"))->setData("invisible");
            popup->addAction(tr("Color..."))->setData("color");
            popup->addAction(tr("Fret Diagram Properties..."))->setData("fret-props");
            }
      else if (e->type() == GLISSANDO) {
            genPropertyMenu1(e, popup);
            popup->addAction(tr("Glissando Properties..."))->setData("gliss-props");
            }
      else if (e->type() == HAIRPIN_SEGMENT) {
            QAction* a = popup->addSeparator();
            a->setText(tr("Dynamics"));
            if (e->visible())
                  a = popup->addAction(tr("Set Invisible"));
            else
                  a = popup->addAction(tr("Set Visible"));
            a->setData("invisible");
            popup->addAction(tr("Hairpin Properties..."))->setData("hp-props");
            }
      else if (e->type() == HARMONY) {
            genPropertyMenu1(e, popup);
            popup->addSeparator();
            popup->addAction(tr("Harmony Properties..."))->setData("ha-props");
            popup->addAction(tr("Text Properties..."))->setData("text-props");
            }
      else if (e->type() == INSTRUMENT_NAME) {
            popup->addAction(tr("Staff Properties..."))->setData("staff-props");
            }
      else
            genPropertyMenu1(e, popup);
      }