Exemplo n.º 1
0
void Ottava::setSubtype(int val)
      {
      setEndHook(true);
      Element::setSubtype(val);
      switch(val) {
            case 0:
                  setBeginText("8va", TEXT_STYLE_OTTAVA);
                  setContinueText("(8va)", TEXT_STYLE_OTTAVA);
                  setEndHookHeight(Spatium(1.5));
                  _pitchShift = 12;
                  break;
            case 1:
                  setBeginText("15ma", TEXT_STYLE_OTTAVA);
                  setContinueText("(15ma)", TEXT_STYLE_OTTAVA);
                  setEndHookHeight(Spatium(1.5));
                  _pitchShift = 24;
                  break;
            case 2:
                  setBeginText("8vb", TEXT_STYLE_OTTAVA);
                  setContinueText("(8vb)", TEXT_STYLE_OTTAVA);
                  setEndHookHeight(Spatium(-1.5));
                  _pitchShift = -12;
                  break;
            case 3:
                  setBeginText("15mb", TEXT_STYLE_OTTAVA);
                  setContinueText("(15mb)", TEXT_STYLE_OTTAVA);
                  setEndHookHeight(Spatium(-1.5));
                  _pitchShift = -24;
                  break;
            }
      }
Exemplo n.º 2
0
void Ottava::read(XmlReader& e)
      {
      qDeleteAll(spannerSegments());
      spannerSegments().clear();
      e.addSpanner(e.intAttribute("id", -1), this);
      while (e.readNextStartElement()) {
            const QStringRef& tag(e.name());
            if (tag == "subtype") {
                  QString s = e.readElementText();
                  bool ok;
                  int idx = s.toInt(&ok);
                  if (!ok) {
                        idx = int(Type::OTTAVA_8VA);
                        for (unsigned i = 0; i < sizeof(ottavaDefault)/sizeof(*ottavaDefault); ++i) {
                              if (s == ottavaDefault[i].name) {
                                    idx = i;
                                    break;
                                    }
                              }
                        }
                  else if (score()->mscVersion() <= 114) {
                        //subtype are now in a different order...
                        if (idx == 1)
                              idx = 2;
                        else if (idx == 2)
                              idx = 1;
                        }
                  setOttavaType(Type(idx));
                  }
            else if (tag == "numbersOnly") {
                  _numbersOnly = e.readInt();
                  numbersOnlyStyle = PropertyStyle::UNSTYLED;
                  }
            else if (tag == "lineWidth") {
                  setLineWidth(Spatium(e.readDouble()));
                  lineWidthStyle = PropertyStyle::UNSTYLED;
                  }
            else if (tag == "lineStyle") {
                  setLineStyle(Qt::PenStyle(e.readInt()));
                  lineStyleStyle = PropertyStyle::UNSTYLED;
                  }
            else if (tag == "beginSymbol") {                      // obsolete
                  beginTextStyle = PropertyStyle::UNSTYLED;
                  QString text(e.readElementText());
                  setBeginText(QString("<sym>%1</sym>").arg(text[0].isNumber() ? Sym::id2name(SymId(text.toInt())) : text));
                  }
            else if (tag == "continueSymbol") {                   // obsolete
                  continueTextStyle = PropertyStyle::UNSTYLED;
                  QString text(e.readElementText());
                  setContinueText(QString("<sym>%1</sym>").arg(text[0].isNumber() ? Sym::id2name(SymId(text.toInt())) : text));
                  }
            else if (!TextLine::readProperties(e))
                  e.unknown();
            }
      if (beginText() != propertyDefault(P_ID::BEGIN_TEXT))
            beginTextStyle = PropertyStyle::UNSTYLED;
      if (continueText() != propertyDefault(P_ID::CONTINUE_TEXT))
            continueTextStyle = PropertyStyle::UNSTYLED;
      }
Exemplo n.º 3
0
void Ottava::setOttavaType(OttavaType val)
      {
      if (val == _ottavaType)
            return;
      setEndHook(true);
      _ottavaType = val;

      Spatium hook(score()->styleS(ST_ottavaHook));

      const TextStyle& ts = score()->textStyle(TEXT_STYLE_OTTAVA);

      switch(val) {
            case OTTAVA_8VA:
                  setBeginText("8va", ts);
                  setContinueText("(8va)", ts);
                  setEndHookHeight(hook);
                  _pitchShift = 12;
                  break;
            case OTTAVA_15MA:
                  setBeginText("15ma", ts);
                  setContinueText("(15ma)", ts);
                  setEndHookHeight(hook);
                  _pitchShift = 24;
                  break;
            case OTTAVA_8VB:
                  setBeginText("8vb", ts);
                  setContinueText("(8vb)", ts);
                  _pitchShift = -12;
                  setEndHookHeight(-hook);
                  break;
            case OTTAVA_15MB:
                  setBeginText("15mb", ts);
                  setContinueText("(15mb)", ts);
                  _pitchShift = -24;
                  setEndHookHeight(-hook);
                  break;
            }
      foreach(SpannerSegment* s, spannerSegments()) {
            OttavaSegment* os = static_cast<OttavaSegment*>(s);
            os->clearText();
            }
Exemplo n.º 4
0
void Ottava::setOttavaType(Type val)
      {
      setEndHook(true);
      _ottavaType = val;

      const OttavaDefault* def = &ottavaDefault[int(_ottavaType)];
      if (beginTextStyle == PropertyStyle::STYLED)
            setBeginText(propertyDefault(P_ID::BEGIN_TEXT).toString(), TextStyleType::OTTAVA);
      if (continueTextStyle == PropertyStyle::STYLED)
            setContinueText(propertyDefault(P_ID::CONTINUE_TEXT).toString(), TextStyleType::OTTAVA);

      setEndHookHeight(score()->styleS(StyleIdx::ottavaHook) * def->hookDirection);
      setPlacement(def->place);
      _pitchShift = def->shift;
      }
Exemplo n.º 5
0
void Hairpin::setHairpinType(Type val)
      {
      if (_hairpinType == val)
            return;
      _hairpinType = val;
      switch (_hairpinType) {
            case Type::CRESC_HAIRPIN:
            case Type::DECRESC_HAIRPIN:
                  setBeginText("");
                  setContinueText("");
                  setLineStyle(Qt::SolidLine);
                  break;
            case Type::CRESC_LINE:
                  setBeginText("cresc.");
                  setContinueText("(cresc.)");
                  setLineStyle(Qt::CustomDashLine);
                  break;
            case Type::DECRESC_LINE:
                  setBeginText("dim.");
                  setContinueText("(dim.)");
                  setLineStyle(Qt::CustomDashLine);
                  break;
            };
      }
Exemplo n.º 6
0
void Hairpin::read(XmlReader& e)
      {
      foreach(SpannerSegment* seg, spannerSegments())
            delete seg;
      spannerSegments().clear();

      int id = e.intAttribute("id", -1);
      e.addSpanner(id, this);

      while (e.readNextStartElement()) {
            const QStringRef& tag(e.name());
            if (tag == "subtype")
                  _hairpinType = Type(e.readInt());
            else if (tag == "lineWidth") {
                  setLineWidth(Spatium(e.readDouble()));
                  lineWidthStyle = PropertyStyle::UNSTYLED;
                  }
            else if (tag == "hairpinHeight") {
                  setHairpinHeight(Spatium(e.readDouble()));
                  hairpinHeightStyle = PropertyStyle::UNSTYLED;
                  }
            else if (tag == "hairpinContHeight") {
                  setHairpinContHeight(Spatium(e.readDouble()));
                  hairpinContHeightStyle = PropertyStyle::UNSTYLED;
                  }
            else if (tag == "hairpinCircledTip")
                  _hairpinCircledTip = e.readInt();
            else if (tag == "veloChange")
                  _veloChange = e.readInt();
            else if (tag == "dynType")
                  _dynRange = Dynamic::Range(e.readInt());
            else if (tag == "useTextLine")
                  _useTextLine = e.readInt();
            else if (!TextLine::readProperties(e))
                  e.unknown();
            }

      // add default text to legacy hairpins
      if (score()->mscVersion() <= 206 && !_useTextLine) {
            bool cresc = _hairpinType == Hairpin::Type::CRESCENDO;
            if (!_beginText)
                  setBeginText(cresc ? "cresc." : "dim.");

            if (!_continueText)
                  setContinueText(cresc ? "(cresc.)" : "(dim.)");
            }
      }
Exemplo n.º 7
0
TextLine::TextLine(Score* s)
   : TextLineBase(s)
      {
      initElementStyle(&textLineStyle);

      setPlacement(Placement::ABOVE);
      setBeginText("");
      setContinueText("");
      setEndText("");
      setBeginTextOffset(QPointF(0,0));
      setContinueTextOffset(QPointF(0,0));
      setEndTextOffset(QPointF(0,0));
      setLineVisible(true);

      setBeginHookType(HookType::NONE);
      setEndHookType(HookType::NONE);
      setBeginHookHeight(Spatium(1.5));
      setEndHookHeight(Spatium(1.5));

      resetProperty(Pid::BEGIN_TEXT_PLACE);
      resetProperty(Pid::CONTINUE_TEXT_PLACE);
      resetProperty(Pid::END_TEXT_PLACE);
      }
Exemplo n.º 8
0
bool TextLineBase::setProperty(P_ID id, const QVariant& v)
      {
      switch (id) {
            case P_ID::BEGIN_TEXT_PLACE:
                  _beginTextPlace = PlaceText(v.toInt());
                  break;
            case P_ID::BEGIN_TEXT_ALIGN:
                  _beginTextAlign = Align(v.toInt());
                  break;
            case P_ID::CONTINUE_TEXT_ALIGN:
                  _continueTextAlign = Align(v.toInt());
                  break;
            case P_ID::END_TEXT_ALIGN:
                  _endTextAlign = Align(v.toInt());
                  break;
            case P_ID::CONTINUE_TEXT_PLACE:
                  _continueTextPlace = PlaceText(v.toInt());
                  break;
            case P_ID::END_TEXT_PLACE:
                  _endTextPlace = PlaceText(v.toInt());
                  break;
            case P_ID::BEGIN_HOOK_HEIGHT:
                  _beginHookHeight = v.value<Spatium>();
                  break;
            case P_ID::END_HOOK_HEIGHT:
                  _endHookHeight = v.value<Spatium>();
                  break;
            case P_ID::BEGIN_HOOK_TYPE:
                  _beginHookType = HookType(v.toInt());
                  break;
            case P_ID::END_HOOK_TYPE:
                  _endHookType = HookType(v.toInt());
                  break;
            case P_ID::BEGIN_TEXT:
                  setBeginText(v.toString());
                  break;
            case P_ID::BEGIN_TEXT_OFFSET:
                  setBeginTextOffset(v.toPointF());
                  break;
            case P_ID::CONTINUE_TEXT_OFFSET:
                  setContinueTextOffset(v.toPointF());
                  break;
            case P_ID::END_TEXT_OFFSET:
                  setEndTextOffset(v.toPointF());
                  break;
            case P_ID::CONTINUE_TEXT:
                  setContinueText(v.toString());
                  break;
            case P_ID::END_TEXT:
                  setEndText(v.toString());
                  break;
            case P_ID::LINE_VISIBLE:
                  setLineVisible(v.toBool());
                  break;
            case P_ID::BEGIN_FONT_FACE:
                  setBeginFontFamily(v.toString());
                  break;
            case P_ID::BEGIN_FONT_SIZE:
                  if (v.toReal() <= 0)
                        qDebug("font size is %f", v.toReal());
                  setBeginFontSize(v.toReal());
                  break;
            case P_ID::BEGIN_FONT_BOLD:
                  setBeginFontBold(v.toBool());
                  break;
            case P_ID::BEGIN_FONT_ITALIC:
                  setBeginFontItalic(v.toBool());
                  break;
            case P_ID::BEGIN_FONT_UNDERLINE:
                  setBeginFontUnderline(v.toBool());
                  break;
            case P_ID::CONTINUE_FONT_FACE:
                  setContinueFontFamily(v.toString());
                  break;
            case P_ID::CONTINUE_FONT_SIZE:
                  setContinueFontSize(v.toReal());
                  break;
            case P_ID::CONTINUE_FONT_BOLD:
                  setContinueFontBold(v.toBool());
                  break;
            case P_ID::CONTINUE_FONT_ITALIC:
                  setContinueFontItalic(v.toBool());
                  break;
            case P_ID::CONTINUE_FONT_UNDERLINE:
                  setContinueFontUnderline(v.toBool());
                  break;
            case P_ID::END_FONT_FACE:
                  setEndFontFamily(v.toString());
                  break;
            case P_ID::END_FONT_SIZE:
                  setEndFontSize(v.toReal());
                  break;
            case P_ID::END_FONT_BOLD:
                  setEndFontBold(v.toBool());
                  break;
            case P_ID::END_FONT_ITALIC:
                  setEndFontItalic(v.toBool());
                  break;
            case P_ID::END_FONT_UNDERLINE:
                  setEndFontUnderline(v.toBool());
                  break;

            default:
                  return SLine::setProperty(id, v);
            }
      triggerLayout();
      return true;
      }