Beispiel #1
0
Palette* MuseScore::newBarLinePalette()
      {
      Palette* sp = new Palette;
      sp->setName(QT_TRANSLATE_NOOP("Palette", "Barlines"));
      sp->setMag(0.8);
      sp->setGrid(42, 38);

      // bar line styles
      struct {
            BarLineType type;
            const char* name;
            } t[] = {
            { BarLineType::NORMAL,       QT_TRANSLATE_NOOP("Palette", "Normal") },
            { BarLineType::BROKEN,       QT_TRANSLATE_NOOP("Palette", "Dashed") },
            { BarLineType::DOTTED,       QT_TRANSLATE_NOOP("Palette", "Dotted") },
            { BarLineType::END,          QT_TRANSLATE_NOOP("Palette", "End Bar") },
            { BarLineType::DOUBLE,       QT_TRANSLATE_NOOP("Palette", "Double Bar") },
            { BarLineType::START_REPEAT,     QT_TRANSLATE_NOOP("Palette", "Start Repeat") },
            { BarLineType::END_REPEAT,       QT_TRANSLATE_NOOP("Palette", "End Repeat") },
            { BarLineType::END_START_REPEAT, QT_TRANSLATE_NOOP("Palette", "End-Start Repeat") },
            };
      for (unsigned i = 0; i < sizeof(t)/sizeof(*t); ++i) {
            BarLine* b  = new BarLine(gscore);
            b->setBarLineType(t[i].type);
            sp->append(b, t[i].name);
            }

      // bar line spans
      struct {
            int         from, to;
            const char* name;
            } span[] = {
            { -1, 1, QT_TRANSLATE_NOOP("Palette", "Tick 1") },
            { -2, 2, QT_TRANSLATE_NOOP("Palette", "Tick 2") },
            { 2,  6, QT_TRANSLATE_NOOP("Palette", "Short 1") },
            { 1,  7, QT_TRANSLATE_NOOP("Palette", "Short 2") },
            };
      for (unsigned i = 0; i < sizeof(span)/sizeof(*span); ++i) {
            BarLine* b  = new BarLine(gscore);
            b->setBarLineType(BarLineType::NORMAL);
            b->setSpanFrom(span[i].from);
            b->setSpanTo(span[i].to);
            sp->append(b, span[i].name);
            }
      return sp;
      }
Beispiel #2
0
Palette* MuseScore::newBarLinePalette()
      {
      Palette* sp = new Palette;
      sp->setName(qApp->translate("barlines", "Barlines"));
      sp->setMag(0.8);
      sp->setGrid(42, 38);

      // bar line styles
      struct {
            BarLineType type;
            const char* name;
            } t[] = {
            { NORMAL_BAR,       QT_TR_NOOP("Normal") },
            { BROKEN_BAR,       QT_TR_NOOP("Dashed") },
            { DOTTED_BAR,       QT_TR_NOOP("Dotted") },
            { END_BAR,          QT_TR_NOOP("End Bar") },
            { DOUBLE_BAR,       QT_TR_NOOP("Double Bar") },
            { START_REPEAT,     QT_TR_NOOP("Start Repeat") },
            { END_REPEAT,       QT_TR_NOOP("End Repeat") },
            { END_START_REPEAT, QT_TR_NOOP("End-Start Repeat") },
            };
      for (unsigned i = 0; i < sizeof(t)/sizeof(*t); ++i) {
            BarLine* b  = new BarLine(gscore);
            b->setSubtype(t[i].type);
            sp->append(b, qApp->translate("barlines", t[i].name));
            }

      // bar line spans
      struct {
            int         from, to;
            const char* name;
            } span[] = {
            { -1, 1, QT_TR_NOOP("Tick 1") },
            { -2, 2, QT_TR_NOOP("Tick 2") },
            { 2,  6, QT_TR_NOOP("Short 1") },
            { 1,  7, QT_TR_NOOP("Short 2") },
            };
      for (unsigned i = 0; i < sizeof(span)/sizeof(*span); ++i) {
            BarLine* b  = new BarLine(gscore);
            b->setSubtype(NORMAL_BAR);
            b->setSpanFrom(span[i].from);
            b->setSpanTo(span[i].to);
            sp->append(b, qApp->translate("barlines", span[i].name));
            }
      return sp;
      }
Beispiel #3
0
Palette* MuseScore::newBarLinePalette(bool basic)
      {
      Palette* sp = new Palette;
      sp->setName(QT_TRANSLATE_NOOP("Palette", "Barlines"));
      sp->setMag(0.8);
      sp->setGrid(42, 38);

      // bar line styles
      for (unsigned i = 0; i < BarLine::barLineTableSize(); ++i) {
            BarLine* b  = new BarLine(gscore);
            BarLineTableItem bti = BarLine::barLineTableItem(i);
            b->setBarLineType(bti.type);
            sp->append(b, qApp->translate("Palette", bti.name));
            }

      if (!basic) {
      // bar line spans
            struct {
                  int         from, to;
                  const char* name;
                  } span[] = {
                  { BARLINE_SPAN_TICK1_FROM, BARLINE_SPAN_TICK1_TO, QT_TRANSLATE_NOOP("Palette", "Tick 1 span") },
                  { BARLINE_SPAN_TICK2_FROM, BARLINE_SPAN_TICK2_TO, QT_TRANSLATE_NOOP("Palette", "Tick 2 span") },
                  { BARLINE_SPAN_SHORT1_FROM,BARLINE_SPAN_SHORT1_TO,QT_TRANSLATE_NOOP("Palette", "Short 1 span") },
                  { BARLINE_SPAN_SHORT2_FROM,BARLINE_SPAN_SHORT2_TO,QT_TRANSLATE_NOOP("Palette", "Short 2 span") },
                  };
            for (unsigned i = 0; i < sizeof(span)/sizeof(*span); ++i) {
                  BarLine* b  = new BarLine(gscore);
                  b->setBarLineType(BarLineType::NORMAL);
                  b->setSpanFrom(span[i].from);
                  b->setSpanTo(span[i].to);
                  sp->append(b, qApp->translate("Palette", span[i].name));
                  }
            }
      return sp;
      }
Beispiel #4
0
void ContinuousPanel::draw(QPainter& painter, const QList<Element*>& el) {
      painter.save();
      painter.setRenderHint(QPainter::Antialiasing, preferences.antialiasedDrawing);
      painter.setRenderHint(QPainter::TextAntialiasing, true);

      // Draw colored rectangle
      painter.setClipping(false);
      QPointF pos(_offsetPanel, 0);
      painter.translate(pos);
      QPen pen;
      pen.setWidthF(0.0);
      pen.setStyle(Qt::NoPen);
      painter.setPen(pen);
      painter.setBrush(preferences.fgColor);
      QRectF bg(_rect);
      bg.setWidth(_widthClef + _widthKeySig + _widthTimeSig + _leftMarginTotal + _panelRightPadding);
      QPixmap* fgPixmap = _sv->fgPixmap();
      if (fgPixmap == 0 || fgPixmap->isNull())
            painter.fillRect(bg, preferences.fgColor);
      else {
            painter.setMatrixEnabled(false);
            painter.drawTiledPixmap(bg, *fgPixmap, bg.topLeft()
               - QPoint(lrint(_sv->matrix().dx()), lrint(_sv->matrix().dy())));
            painter.setMatrixEnabled(true);
            }

      painter.setClipRect(_rect);
      painter.setClipping(true);

      QColor color(MScore::layoutBreakColor);

      // Draw measure text number
      QString text = _mmRestCount ? QString("#%1-%2").arg(_currentMeasureNo+1).arg(_currentMeasureNo+_mmRestCount) : QString("#%1").arg(_currentMeasureNo+1);
      Text* newElement = new Text(_score);
      newElement->setTextStyleType(TextStyleType::DEFAULT);
      newElement->setFlag(ElementFlag::MOVABLE, false);
      newElement->setXmlText(text);
      newElement->textStyle().setFamily("FreeSans");
      newElement->textStyle().setSizeIsSpatiumDependent(true);
      newElement->setColor(color);
      newElement->sameLayout();
      pos = QPointF(_score->styleP(StyleIdx::clefLeftMargin) + _widthClef, _y + newElement->height());
      painter.translate(pos);
      newElement->draw(&painter);
      pos += QPointF(_offsetPanel, 0);
      painter.translate(-pos);
      delete newElement;

      // This second pass draws the elements spaced evently using the width of the largest element
      for (const Element* e : el) {
            e->itemDiscovered = 0;
            if (!e->visible()) {
                  if (_score->printing() || !_score->showInvisible())
                        continue;
                  }

           if (e->type() == Element::Type::STAFF_LINES) {
                  Staff* currentStaff = _score->staff(e->staffIdx());
                  Segment* parent = _score->tick2segmentMM(_currentMeasureTick);

                  pos = QPointF (_offsetPanel, e->pagePos().y());
                  painter.translate(pos);

                  // Draw staff lines
                  StaffLines* newStaffLines = static_cast<StaffLines*>(e->clone());
                  newStaffLines->setWidth(bg.width());
                  newStaffLines->setParent(parent);
                  newStaffLines->setTrack(e->track());
                  newStaffLines->layout();
                  newStaffLines->setColor(color);
                  newStaffLines->draw(&painter);
                  delete newStaffLines;

                  // Draw barline
                  BarLine* newBarLine = new BarLine(_score);
                  newBarLine->setBarLineType(BarLineType::NORMAL);
                  newBarLine->setParent(parent);
                  newBarLine->setTrack(e->track());
                  newBarLine->setSpan(currentStaff->barLineSpan());
                  newBarLine->setSpanFrom(currentStaff->barLineFrom());
                  newBarLine->setSpanTo(currentStaff->barLineTo());
                  newBarLine->layout();
                  newBarLine->setColor(color);
                  newBarLine->draw(&painter);
                  delete newBarLine;

                  // Draw the current staff name
                  QList<StaffName>& staffNamesLong = currentStaff->part()->instrument()->longNames();
                  QString staffName = staffNamesLong.isEmpty() ? " " : staffNamesLong[0].name();
                  if (staffName == "") {
                        QList<StaffName>& staffNamesShort = currentStaff->part()->instrument()->shortNames();
                        staffName = staffNamesShort.isEmpty() ? "" : staffNamesShort[0].name();
                        }

                  Text* newName = new Text(_score);
                  newName->setXmlText(staffName);
                  newName->setParent(parent);
                  newName->setTrack(e->track());
                  newName->setColor(color);
                  newName->textStyle().setFamily("FreeSans");
                  newName->textStyle().setSizeIsSpatiumDependent(true);
                  newName->layout();
                  newName->setPlainText(newName->plainText());
                  newName->layout();
                  if (currentStaff->part()->staff(0) == currentStaff) {
                        double _spatium = _score->spatium();
                        pos = QPointF (_score->styleP(StyleIdx::clefLeftMargin) + _widthClef, 0 - _spatium * 2);
                        painter.translate(pos);
                        newName->draw(&painter);
                        painter.translate(-pos);
                        }
                  delete newName;

                  // Draw the current Clef
                  Clef* newClef = new Clef(_score);
                  ClefType currentClef = currentStaff->clef(_currentMeasureTick);
                  newClef->setClefType(currentClef);
                  newClef->setParent(parent);
                  newClef->setTrack(e->track());
                  newClef->setColor(color);
                  newClef->layout();
                  pos = QPointF(_score->styleP(StyleIdx::clefLeftMargin), 0);
                  painter.translate(pos);
                  newClef->draw(&painter);
                  pos = QPointF(_widthClef,0);
                  painter.translate(pos);
                  delete newClef;

                  // Draw the current KeySignature
                  KeySig* newKs = new KeySig(_score);
                  KeySigEvent currentKeySigEvent = currentStaff->keySigEvent(_currentMeasureTick);
                  newKs->setKeySigEvent(currentKeySigEvent);

                  // The Parent and the track must be set to have the key signature layout adjusted to different clefs
                  // This also adds naturals to the key signature (if set in the score style)
                  newKs->setParent(parent);
                  newKs->setTrack(e->track());
                  newKs->setColor(color);

                  newKs->setHideNaturals(true);
                  pos = QPointF(_score->styleP(StyleIdx::keysigLeftMargin),0);
                  painter.translate(pos);
                  newKs->layout();
                  newKs->draw(&painter);
                  delete newKs;

                  pos = QPointF(_widthKeySig + _xPosTimeSig, 0);
                  painter.translate(pos);

                  // Draw the current TimeSignature
                  TimeSig* newTs = new TimeSig(_score);

                  // Try to get local time signature, if not, get the current measure one
                  TimeSig* currentTimeSig = currentStaff->timeSig(_currentMeasureTick);
                  if (currentTimeSig) {
                        newTs->setFrom(currentTimeSig);
                        newTs->setParent(parent);
                        newTs->setTrack(e->track());
                        newTs->setColor(color);
                        newTs->layout();
                        pos = QPointF(_score->styleP(StyleIdx::timesigLeftMargin),0);
                        painter.translate(pos);
                        newTs->draw(&painter);
                        delete newTs;
                        }
                  pos = QPointF(_offsetPanel + _widthClef + _widthKeySig + _xPosTimeSig + _leftMarginTotal, e->pagePos().y());
                  painter.translate(-pos);
                  }
            }
      painter.restore();
      }