2012-05-26 14:26:10 +02:00
|
|
|
//=============================================================================
|
|
|
|
// MuseScore
|
|
|
|
// Music Composition & Notation
|
|
|
|
//
|
2013-11-13 15:08:08 +01:00
|
|
|
// Copyright (C) 2002-2013 Werner Schweer
|
2012-05-26 14:26:10 +02:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License version 2
|
|
|
|
// as published by the Free Software Foundation and appearing in
|
|
|
|
// the file LICENCE.GPL
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
#include "articulation.h"
|
|
|
|
#include "score.h"
|
|
|
|
#include "chordrest.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "measure.h"
|
|
|
|
#include "staff.h"
|
|
|
|
#include "stafftype.h"
|
|
|
|
#include "undo.h"
|
|
|
|
#include "page.h"
|
|
|
|
#include "barline.h"
|
2013-11-11 16:53:03 +01:00
|
|
|
#include "sym.h"
|
2014-04-09 16:09:21 +02:00
|
|
|
#include "xml.h"
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
namespace Ms {
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Articulation::articulationList
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2014-05-26 21:55:26 +02:00
|
|
|
ArticulationInfo Articulation::articulationList[int(ArticulationType::ARTICULATIONS)] = {
|
2013-11-06 15:58:05 +01:00
|
|
|
{ SymId::fermataAbove, SymId::fermataBelow,
|
2012-05-26 14:26:10 +02:00
|
|
|
"fermata", QT_TRANSLATE_NOOP("articulation", "fermata"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-06 15:58:05 +01:00
|
|
|
{ SymId::fermataShortAbove, SymId::fermataShortBelow,
|
2013-11-28 22:00:09 +01:00
|
|
|
"shortfermata", QT_TRANSLATE_NOOP("articulation", "short fermata"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-06 15:58:05 +01:00
|
|
|
{ SymId::fermataLongAbove, SymId::fermataLongBelow,
|
2013-11-28 22:00:09 +01:00
|
|
|
"longfermata", QT_TRANSLATE_NOOP("articulation", "long fermata"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-06 15:58:05 +01:00
|
|
|
{ SymId::fermataVeryLongAbove, SymId::fermataVeryLongBelow,
|
2013-11-28 22:00:09 +01:00
|
|
|
"verylongfermata", QT_TRANSLATE_NOOP("articulation", "very long fermata"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-11 15:11:28 +01:00
|
|
|
{ SymId::stringsThumbPosition, SymId::stringsThumbPosition,
|
2012-05-26 14:26:10 +02:00
|
|
|
"thumb", QT_TRANSLATE_NOOP("articulation", "thumb"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2014-03-15 12:31:29 +01:00
|
|
|
{ SymId::articAccentAbove, SymId::articAccentBelow,
|
2012-05-26 14:26:10 +02:00
|
|
|
"sforzato", QT_TRANSLATE_NOOP("articulation", "sforzato"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-11 15:11:28 +01:00
|
|
|
// <> not available in smufl?
|
|
|
|
// { esprSym, esprSym ,
|
|
|
|
// "espressivo", QT_TRANSLATE_NOOP("articulation", "espressivo"),
|
2014-05-21 21:53:35 +02:00
|
|
|
// 1.0,ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2013-11-11 15:11:28 +01:00
|
|
|
// },
|
2014-03-15 12:31:29 +01:00
|
|
|
{ SymId::articStaccatoAbove, SymId::articStaccatoBelow,
|
2012-05-26 14:26:10 +02:00
|
|
|
"staccato", QT_TRANSLATE_NOOP("articulation", "staccato"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-11 15:11:28 +01:00
|
|
|
{ SymId::articStaccatissimoAbove, SymId::articStaccatissimoBelow,
|
2012-05-26 14:26:10 +02:00
|
|
|
"staccatissimo", QT_TRANSLATE_NOOP("articulation", "staccatissimo"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2014-03-15 12:31:29 +01:00
|
|
|
{ SymId::articTenutoAbove, SymId::articTenutoBelow,
|
2012-05-26 14:26:10 +02:00
|
|
|
"tenuto", QT_TRANSLATE_NOOP("articulation", "tenuto"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2014-04-18 18:55:33 +02:00
|
|
|
{ SymId::articTenutoStaccatoAbove, SymId::articTenutoStaccatoBelow,
|
2012-05-26 14:26:10 +02:00
|
|
|
"portato", QT_TRANSLATE_NOOP("articulation", "portato"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-11 15:11:28 +01:00
|
|
|
{ SymId::articMarcatoAbove, SymId::articMarcatoBelow,
|
2012-05-26 14:26:10 +02:00
|
|
|
"marcato", QT_TRANSLATE_NOOP("articulation", "marcato"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-13 15:08:08 +01:00
|
|
|
{ SymId::brassMuteOpen, SymId::brassMuteOpen,
|
|
|
|
"ouvert", QT_TRANSLATE_NOOP("articulation", "ouvert"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2013-11-13 15:08:08 +01:00
|
|
|
},
|
|
|
|
{ SymId::brassMuteClosed, SymId::brassMuteClosed,
|
2013-12-05 19:02:55 +01:00
|
|
|
"plusstop", QT_TRANSLATE_NOOP("articulation", "stopped/pizzicato left hand"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2013-11-13 15:08:08 +01:00
|
|
|
},
|
2013-11-11 15:11:28 +01:00
|
|
|
{ SymId::stringsUpBow, SymId::stringsUpBow,
|
2013-11-28 22:00:09 +01:00
|
|
|
"upbow", QT_TRANSLATE_NOOP("articulation", "up bow"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-11 15:11:28 +01:00
|
|
|
{ SymId::stringsDownBow, SymId::stringsDownBow,
|
2013-11-28 22:00:09 +01:00
|
|
|
"downbow", QT_TRANSLATE_NOOP("articulation", "down bow"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-11 15:11:28 +01:00
|
|
|
{ SymId::ornamentTurnInverted, SymId::ornamentTurnInverted,
|
2013-11-28 22:00:09 +01:00
|
|
|
"reverseturn", QT_TRANSLATE_NOOP("articulation", "reverse turn"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-06 15:58:05 +01:00
|
|
|
{ SymId::ornamentTurn, SymId::ornamentTurn,
|
2012-05-26 14:26:10 +02:00
|
|
|
"turn", QT_TRANSLATE_NOOP("articulation", "turn"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-11 15:11:28 +01:00
|
|
|
{ SymId::ornamentTrill, SymId::ornamentTrill,
|
2012-05-26 14:26:10 +02:00
|
|
|
"trill", QT_TRANSLATE_NOOP("articulation", "trill"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-11 15:11:28 +01:00
|
|
|
{ SymId::ornamentMordent, SymId::ornamentMordent,
|
2012-05-26 14:26:10 +02:00
|
|
|
"prall", QT_TRANSLATE_NOOP("articulation", "prall"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-11 15:11:28 +01:00
|
|
|
{ SymId::ornamentMordentInverted, SymId::ornamentMordentInverted,
|
2012-05-26 14:26:10 +02:00
|
|
|
"mordent", QT_TRANSLATE_NOOP("articulation", "mordent"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-11 15:11:28 +01:00
|
|
|
{ SymId::ornamentTremblement, SymId::ornamentTremblement,
|
2013-11-28 22:00:09 +01:00
|
|
|
"prallprall", QT_TRANSLATE_NOOP("articulation", "prall prall"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-11 15:11:28 +01:00
|
|
|
{ SymId::ornamentPrallMordent, SymId::ornamentPrallMordent,
|
2013-11-28 22:00:09 +01:00
|
|
|
"prallmordent", QT_TRANSLATE_NOOP("articulation", "prall mordent"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-11 15:11:28 +01:00
|
|
|
{ SymId::ornamentUpPrall, SymId::ornamentUpPrall,
|
2013-11-28 22:00:09 +01:00
|
|
|
"upprall", QT_TRANSLATE_NOOP("articulation", "up prall"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2014-05-30 13:35:44 +02:00
|
|
|
{ SymId::ornamentDownPrall, SymId::ornamentDownPrall,
|
2013-11-28 22:00:09 +01:00
|
|
|
"downprall", QT_TRANSLATE_NOOP("articulation", "down prall"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2014-05-30 13:35:44 +02:00
|
|
|
{ SymId::ornamentUpMordent, SymId::ornamentUpMordent,
|
2013-11-28 22:00:09 +01:00
|
|
|
"upmordent", QT_TRANSLATE_NOOP("articulation", "up mordent"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2014-05-30 13:35:44 +02:00
|
|
|
{ SymId::ornamentDownMordent, SymId::ornamentDownMordent,
|
2013-11-28 22:00:09 +01:00
|
|
|
"downmordent", QT_TRANSLATE_NOOP("articulation", "down mordent"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2014-05-30 13:35:44 +02:00
|
|
|
{ SymId::ornamentPrallDown, SymId::ornamentPrallDown,
|
2013-11-28 22:00:09 +01:00
|
|
|
"pralldown", QT_TRANSLATE_NOOP("articulation", "prall down"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2014-05-30 13:35:44 +02:00
|
|
|
{ SymId::ornamentPrallUp, SymId::ornamentPrallUp,
|
2013-11-28 22:00:09 +01:00
|
|
|
"prallup", QT_TRANSLATE_NOOP("articulation", "prall up"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2014-05-30 13:35:44 +02:00
|
|
|
{ SymId::ornamentLinePrall, SymId::ornamentLinePrall,
|
2013-11-28 22:00:09 +01:00
|
|
|
"lineprall", QT_TRANSLATE_NOOP("articulation", "line prall"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2014-05-30 13:35:44 +02:00
|
|
|
{ SymId::ornamentPrecompSlide, SymId::ornamentPrecompSlide,
|
2012-05-26 14:26:10 +02:00
|
|
|
"schleifer", QT_TRANSLATE_NOOP("articulation", "schleifer"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2014-03-29 20:09:00 +01:00
|
|
|
{ SymId::pluckedSnapPizzicatoAbove, SymId::pluckedSnapPizzicatoBelow,
|
2013-11-28 22:00:09 +01:00
|
|
|
"snappizzicato", QT_TRANSLATE_NOOP("articulation", "snap pizzicato"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::PITCHED_STAFF | ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-12 15:15:48 +01:00
|
|
|
|
|
|
|
#if 0
|
2012-05-26 14:26:10 +02:00
|
|
|
{ letterTSym, letterTSym,
|
|
|
|
"tapping", QT_TRANSLATE_NOOP("articulation", "tapping"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
|
|
|
{ letterSSym, letterSSym,
|
|
|
|
"slapping", QT_TRANSLATE_NOOP("articulation", "slapping"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
|
|
|
{ letterPSym, letterPSym,
|
|
|
|
"popping", QT_TRANSLATE_NOOP("articulation", "popping"),
|
2014-05-21 21:53:35 +02:00
|
|
|
1.0, ArticulationShowIn::TABLATURE
|
2012-05-26 14:26:10 +02:00
|
|
|
},
|
2013-11-06 15:58:05 +01:00
|
|
|
#endif
|
2014-05-30 13:35:44 +02:00
|
|
|
};
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// Articulation
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Articulation::Articulation(Score* s)
|
|
|
|
: Element(s)
|
|
|
|
{
|
2014-05-07 18:09:01 +02:00
|
|
|
_direction = Direction::AUTO;
|
2012-05-26 14:26:10 +02:00
|
|
|
_up = true;
|
2014-05-22 10:10:58 +02:00
|
|
|
setFlags(ElementFlag::MOVABLE | ElementFlag::SELECTABLE);
|
2014-05-26 21:55:26 +02:00
|
|
|
setArticulationType(ArticulationType::Fermata);
|
2013-11-12 15:15:48 +01:00
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2013-03-05 20:23:59 +01:00
|
|
|
// setArticulationType
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2013-03-05 20:23:59 +01:00
|
|
|
void Articulation::setArticulationType(ArticulationType idx)
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
2013-03-05 20:23:59 +01:00
|
|
|
_articulationType = idx;
|
2014-05-26 21:55:26 +02:00
|
|
|
_anchor = score()->style()->articulationAnchor(int(_articulationType));
|
2013-08-07 13:20:44 +02:00
|
|
|
anchorStyle = PropertyStyle::STYLED;
|
2014-05-26 21:55:26 +02:00
|
|
|
_timeStretch = articulationList[int(articulationType())].timeStretch;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// read
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2013-01-11 18:10:18 +01:00
|
|
|
void Articulation::read(XmlReader& e)
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
2014-05-26 21:55:26 +02:00
|
|
|
setArticulationType(ArticulationType::Fermata); // default // backward compatibility (no type = ufermata in 1.2)
|
2013-01-11 18:10:18 +01:00
|
|
|
while (e.readNextStartElement()) {
|
|
|
|
const QStringRef& tag(e.name());
|
2012-05-26 14:26:10 +02:00
|
|
|
if (tag == "subtype")
|
2013-01-11 18:10:18 +01:00
|
|
|
setSubtype(e.readElementText());
|
|
|
|
else if (tag == "channel") {
|
2012-05-26 14:26:10 +02:00
|
|
|
_channelName = e.attribute("name");
|
2013-01-11 18:10:18 +01:00
|
|
|
e.readNext();
|
|
|
|
}
|
2013-08-07 13:20:44 +02:00
|
|
|
else if (tag == "anchor") {
|
2013-01-11 18:10:18 +01:00
|
|
|
_anchor = ArticulationAnchor(e.readInt());
|
2013-08-07 13:20:44 +02:00
|
|
|
anchorStyle = PropertyStyle::UNSTYLED;
|
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
else if (tag == "direction") {
|
2014-05-26 18:18:01 +02:00
|
|
|
setProperty(P_ID::DIRECTION, Ms::getProperty(P_ID::DIRECTION, e));
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
2013-06-03 14:39:59 +02:00
|
|
|
else if (tag == "timeStretch")
|
|
|
|
_timeStretch = e.readDouble();
|
2014-05-06 17:05:27 +02:00
|
|
|
else if (tag == "offset") {
|
|
|
|
if (score()->mscVersion() > 114)
|
|
|
|
Element::readProperties(e);
|
|
|
|
else
|
|
|
|
e.skipCurrentElement(); // ignore manual layout in older scores
|
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
else if (!Element::readProperties(e))
|
2013-01-11 18:10:18 +01:00
|
|
|
e.unknown();
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// write
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Articulation::write(Xml& xml) const
|
|
|
|
{
|
|
|
|
xml.stag("Articulation");
|
|
|
|
if (!_channelName.isEmpty())
|
|
|
|
xml.tagE(QString("channel name=\"%1\"").arg(_channelName));
|
2014-05-26 18:18:01 +02:00
|
|
|
writeProperty(xml, P_ID::DIRECTION);
|
2013-07-17 09:41:06 +02:00
|
|
|
xml.tag("subtype", subtypeName());
|
2013-06-03 14:39:59 +02:00
|
|
|
if (_timeStretch != 1.0)
|
|
|
|
xml.tag("timeStretch", _timeStretch);
|
2012-05-26 14:26:10 +02:00
|
|
|
Element::writeProperties(xml);
|
2013-08-07 13:20:44 +02:00
|
|
|
if (anchorStyle == PropertyStyle::UNSTYLED)
|
2012-05-26 14:26:10 +02:00
|
|
|
xml.tag("anchor", int(_anchor));
|
|
|
|
xml.etag();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// subtypeName
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
QString Articulation::subtypeName() const
|
|
|
|
{
|
2014-05-26 21:55:26 +02:00
|
|
|
return articulationList[int(articulationType())].name;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// setSubtype
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Articulation::setSubtype(const QString& s)
|
|
|
|
{
|
2013-11-12 13:05:29 +01:00
|
|
|
if (s.isEmpty()) {
|
|
|
|
qDebug("Articulation::setSubtype: empty subtype");
|
2014-05-26 21:55:26 +02:00
|
|
|
setArticulationType(ArticulationType::Fermata); // something to debug...
|
2013-11-12 13:05:29 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
if (s[0].isDigit()) { // for backward compatibility
|
2013-03-05 20:23:59 +01:00
|
|
|
setArticulationType(ArticulationType(s.toInt()));
|
2012-05-26 14:26:10 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
int st;
|
2014-05-26 21:55:26 +02:00
|
|
|
for (st = 0; st < int(ArticulationType::ARTICULATIONS); ++st) {
|
2012-05-26 14:26:10 +02:00
|
|
|
if (articulationList[st].name == s)
|
|
|
|
break;
|
|
|
|
}
|
2014-05-26 21:55:26 +02:00
|
|
|
if (st == int(ArticulationType::ARTICULATIONS)) {
|
2012-05-26 14:26:10 +02:00
|
|
|
struct {
|
|
|
|
const char* name;
|
|
|
|
bool up;
|
|
|
|
ArticulationType type;
|
|
|
|
} al[] = {
|
2014-05-26 21:55:26 +02:00
|
|
|
{ "umarcato", true, ArticulationType::Marcato },
|
|
|
|
{ "dmarcato", false, ArticulationType::Marcato },
|
|
|
|
{ "ufermata", true, ArticulationType::Fermata },
|
|
|
|
{ "dfermata", false, ArticulationType::Fermata },
|
|
|
|
{ "ushortfermata", true, ArticulationType::Shortfermata },
|
|
|
|
{ "dshortfermata", false, ArticulationType::Shortfermata },
|
|
|
|
{ "ulongfermata", true, ArticulationType::Longfermata },
|
|
|
|
{ "dlongfermata", false, ArticulationType::Longfermata },
|
|
|
|
{ "uverylongfermata", true, ArticulationType::Verylongfermata },
|
|
|
|
{ "dverylongfermata", false, ArticulationType::Verylongfermata },
|
2012-06-22 16:25:19 +02:00
|
|
|
// watch out, bug in 1.2 uportato and dportato are reversed
|
2014-05-26 21:55:26 +02:00
|
|
|
{ "dportato", true, ArticulationType::Portato },
|
|
|
|
{ "uportato", false, ArticulationType::Portato },
|
|
|
|
{ "ustaccatissimo", true, ArticulationType::Staccatissimo },
|
|
|
|
{ "dstaccatissimo", false, ArticulationType::Staccatissimo }
|
2012-05-26 14:26:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
int i;
|
|
|
|
int n = sizeof(al) / sizeof(*al);
|
|
|
|
for (i = 0; i < n; ++i) {
|
|
|
|
if (s == al[i].name) {
|
|
|
|
_up = al[i].up;
|
2014-05-07 18:09:01 +02:00
|
|
|
_direction = (_up ? Direction::UP : Direction::DOWN);
|
2012-05-26 14:26:10 +02:00
|
|
|
st = int(al[i].type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == n) {
|
|
|
|
st = 0;
|
2013-11-06 15:58:05 +01:00
|
|
|
qDebug("Articulation: unknown <%s>", qPrintable(s));
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
}
|
2013-03-05 20:23:59 +01:00
|
|
|
setArticulationType(ArticulationType(st));
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// idx2name
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
QString Articulation::idx2name(int idx)
|
|
|
|
{
|
|
|
|
return articulationList[idx].name;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// pagePos
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
QPointF Articulation::pagePos() const
|
|
|
|
{
|
|
|
|
if (parent() == 0)
|
|
|
|
return pos();
|
|
|
|
return parent()->pagePos() + pos();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// canvasPos
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
QPointF Articulation::canvasPos() const
|
|
|
|
{
|
|
|
|
if (parent() == 0)
|
|
|
|
return pos();
|
|
|
|
return parent()->canvasPos() + pos();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// Symbol::draw
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Articulation::draw(QPainter* painter) const
|
|
|
|
{
|
2014-05-26 21:55:26 +02:00
|
|
|
SymId sym = _up ? articulationList[int(articulationType())].upSym : articulationList[int(articulationType())].downSym;
|
|
|
|
int flags = articulationList[int(articulationType())].flags;
|
2012-05-26 14:26:10 +02:00
|
|
|
if (staff()) {
|
2014-05-27 13:30:23 +02:00
|
|
|
if (staff()->staffGroup() == StaffGroup::TAB) {
|
2014-05-21 21:53:35 +02:00
|
|
|
if (!(flags & ArticulationShowIn::TABLATURE))
|
2012-05-26 14:26:10 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
2014-05-21 21:53:35 +02:00
|
|
|
if (!(flags & ArticulationShowIn::PITCHED_STAFF))
|
2012-05-26 14:26:10 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
painter->setPen(curColor());
|
2014-03-29 20:09:00 +01:00
|
|
|
drawSymbol(sym, painter, QPointF(-0.5 * width(), 0.0));
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// chordRest
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
ChordRest* Articulation::chordRest() const
|
|
|
|
{
|
|
|
|
if (parent() && parent()->isChordRest())
|
|
|
|
return static_cast<ChordRest*>(parent());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// subtypeUserName
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
QString Articulation::subtypeUserName() const
|
|
|
|
{
|
2014-05-26 21:55:26 +02:00
|
|
|
return articulationList[int(articulationType())].description;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// layout
|
|
|
|
// height() and width() should return sensible
|
|
|
|
// values when calling this method
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Articulation::layout()
|
|
|
|
{
|
2014-05-26 21:55:26 +02:00
|
|
|
SymId sym = _up ? articulationList[int(articulationType())].upSym : articulationList[int(articulationType())].downSym;
|
2013-11-11 15:11:28 +01:00
|
|
|
QRectF b(symBbox(sym));
|
2014-03-29 20:09:00 +01:00
|
|
|
setbbox(b.translated(-0.5 * b.width(), 0.0));
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// setDirection
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2014-05-07 18:09:01 +02:00
|
|
|
void Articulation::setDirection(Direction d)
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
|
|
|
_direction = d;
|
2014-05-07 18:09:01 +02:00
|
|
|
if (d != Direction::AUTO)
|
|
|
|
_up = (d == Direction::UP);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2012-11-19 10:08:15 +01:00
|
|
|
// reset
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2012-11-19 10:08:15 +01:00
|
|
|
void Articulation::reset()
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
2014-05-07 18:09:01 +02:00
|
|
|
if (_direction != Direction::AUTO)
|
2014-05-26 18:18:01 +02:00
|
|
|
score()->undoChangeProperty(this, P_ID::DIRECTION, int(Direction::AUTO));
|
2014-05-26 21:55:26 +02:00
|
|
|
ArticulationAnchor a = score()->style()->articulationAnchor(int(articulationType()));
|
2012-05-26 14:26:10 +02:00
|
|
|
if (_anchor != a)
|
2014-05-26 18:18:01 +02:00
|
|
|
score()->undoChangeProperty(this, P_ID::ARTICULATION_ANCHOR, int(a));
|
2012-11-19 10:08:15 +01:00
|
|
|
Element::reset();
|
2012-05-26 14:26:10 +02:00
|
|
|
if (chordRest())
|
|
|
|
chordRest()->layoutArticulations();
|
|
|
|
score()->addRefresh(canvasBoundingRect());
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// dragAnchor
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
QLineF Articulation::dragAnchor() const
|
|
|
|
{
|
|
|
|
return QLineF(canvasPos(), parent()->canvasPos());
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// getProperty
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
QVariant Articulation::getProperty(P_ID propertyId) const
|
|
|
|
{
|
|
|
|
switch(propertyId) {
|
2014-05-26 18:18:01 +02:00
|
|
|
case P_ID::DIRECTION: return int(direction());
|
|
|
|
case P_ID::ARTICULATION_ANCHOR: return int(anchor());
|
|
|
|
case P_ID::TIME_STRETCH: return timeStretch();
|
2012-05-26 14:26:10 +02:00
|
|
|
default:
|
|
|
|
return Element::getProperty(propertyId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// setProperty
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
bool Articulation::setProperty(P_ID propertyId, const QVariant& v)
|
|
|
|
{
|
|
|
|
score()->addRefresh(canvasBoundingRect());
|
2013-08-07 13:20:44 +02:00
|
|
|
switch (propertyId) {
|
2014-05-26 18:18:01 +02:00
|
|
|
case P_ID::DIRECTION:
|
2014-05-07 18:09:01 +02:00
|
|
|
setDirection(Direction(v.toInt()));
|
2013-08-07 13:20:44 +02:00
|
|
|
break;
|
2014-05-26 18:18:01 +02:00
|
|
|
case P_ID::ARTICULATION_ANCHOR:
|
2013-08-07 13:20:44 +02:00
|
|
|
anchorStyle = PropertyStyle::UNSTYLED;
|
|
|
|
setAnchor(ArticulationAnchor(v.toInt()));
|
|
|
|
break;
|
2014-05-26 18:18:01 +02:00
|
|
|
case P_ID::TIME_STRETCH:
|
2013-06-03 14:39:59 +02:00
|
|
|
setTimeStretch(v.toDouble());
|
|
|
|
score()->fixTicks();
|
|
|
|
break;
|
2012-05-26 14:26:10 +02:00
|
|
|
default:
|
|
|
|
return Element::setProperty(propertyId, v);
|
|
|
|
}
|
|
|
|
score()->addRefresh(canvasBoundingRect());
|
|
|
|
|
|
|
|
// layout:
|
|
|
|
if (chordRest())
|
|
|
|
chordRest()->layoutArticulations();
|
2014-05-22 19:49:51 +02:00
|
|
|
else if (parent() && parent()->type() == ElementType::BAR_LINE)
|
2012-05-26 14:26:10 +02:00
|
|
|
static_cast<BarLine*>(parent())->layout();
|
|
|
|
|
|
|
|
score()->addRefresh(canvasBoundingRect());
|
|
|
|
score()->setLayoutAll(false); //DEBUG
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-03 12:54:11 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// propertyDefault
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
QVariant Articulation::propertyDefault(P_ID propertyId) const
|
|
|
|
{
|
|
|
|
switch(propertyId) {
|
2014-05-26 18:18:01 +02:00
|
|
|
case P_ID::DIRECTION:
|
2014-05-07 18:09:01 +02:00
|
|
|
return int(Direction::AUTO);
|
2013-06-03 12:54:11 +02:00
|
|
|
|
2014-05-26 18:18:01 +02:00
|
|
|
case P_ID::ARTICULATION_ANCHOR:
|
2014-05-26 21:55:26 +02:00
|
|
|
return int(score()->style()->articulationAnchor(int(_articulationType)));
|
2013-06-03 12:54:11 +02:00
|
|
|
|
2014-05-26 18:18:01 +02:00
|
|
|
case P_ID::TIME_STRETCH:
|
2014-05-26 21:55:26 +02:00
|
|
|
return articulationList[int(articulationType())].timeStretch;
|
2013-06-03 14:39:59 +02:00
|
|
|
|
2013-06-03 12:54:11 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return Element::propertyDefault(propertyId);
|
|
|
|
}
|
|
|
|
|
2013-08-07 13:20:44 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// propertyStyle
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
PropertyStyle Articulation::propertyStyle(P_ID id) const
|
|
|
|
{
|
|
|
|
switch (id) {
|
2014-05-26 18:18:01 +02:00
|
|
|
case P_ID::DIRECTION:
|
|
|
|
case P_ID::TIME_STRETCH:
|
2013-08-07 13:20:44 +02:00
|
|
|
return PropertyStyle::NOSTYLE;
|
|
|
|
|
2014-05-26 18:18:01 +02:00
|
|
|
case P_ID::ARTICULATION_ANCHOR:
|
2013-08-07 13:20:44 +02:00
|
|
|
return anchorStyle;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return Element::propertyStyle(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// resetProperty
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Articulation::resetProperty(P_ID id)
|
|
|
|
{
|
|
|
|
switch (id) {
|
2014-05-26 18:18:01 +02:00
|
|
|
case P_ID::DIRECTION:
|
|
|
|
case P_ID::TIME_STRETCH:
|
2013-08-07 13:20:44 +02:00
|
|
|
return;
|
|
|
|
|
2014-05-26 18:18:01 +02:00
|
|
|
case P_ID::ARTICULATION_ANCHOR:
|
2013-08-07 13:20:44 +02:00
|
|
|
setProperty(id, propertyDefault(id));
|
|
|
|
anchorStyle = PropertyStyle::STYLED;
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Element::resetProperty(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// styleChanged
|
|
|
|
// reset all styled values to actual style
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Articulation::styleChanged()
|
|
|
|
{
|
|
|
|
if (anchorStyle == PropertyStyle::STYLED)
|
2014-05-26 21:55:26 +02:00
|
|
|
_anchor = score()->style()->articulationAnchor(int(_articulationType));
|
2013-08-07 13:20:44 +02:00
|
|
|
}
|
|
|
|
|
2013-08-24 19:43:02 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// mag
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
qreal Articulation::mag() const
|
|
|
|
{
|
2014-05-26 15:31:36 +02:00
|
|
|
return parent() ? parent()->mag() * score()->styleD(StyleIdx::articulationMag): 1.0;
|
2013-08-24 19:43:02 +02:00
|
|
|
}
|
2013-05-13 18:49:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-24 19:43:02 +02:00
|
|
|
|