rearrange class hierarchy
This commit is contained in:
parent
f553f4fcfb
commit
e6175c5dda
54 changed files with 395 additions and 403 deletions
|
@ -632,7 +632,8 @@ Element* Box::drop(EditData& data)
|
|||
|
||||
case ElementType::STAFF_TEXT:
|
||||
{
|
||||
Text* text = new Text(SubStyle::FRAME, score());
|
||||
Text* text = new Text(score());
|
||||
text->init(SubStyle::FRAME);
|
||||
text->setParent(this);
|
||||
text->setXmlText(toStaffText(e)->xmlText());
|
||||
score()->undoAddElement(text);
|
||||
|
|
|
@ -80,8 +80,9 @@ static Dyn dynList[] = {
|
|||
//---------------------------------------------------------
|
||||
|
||||
Dynamic::Dynamic(Score* s)
|
||||
: Text(SubStyle::DYNAMICS, s)
|
||||
: TextBase(s)
|
||||
{
|
||||
init(SubStyle::DYNAMICS);
|
||||
setFlags(ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF);
|
||||
_velocity = -1;
|
||||
_dynRange = Range::PART;
|
||||
|
@ -89,7 +90,7 @@ Dynamic::Dynamic(Score* s)
|
|||
}
|
||||
|
||||
Dynamic::Dynamic(const Dynamic& d)
|
||||
: Text(d)
|
||||
: TextBase(d)
|
||||
{
|
||||
_dynamicType = d._dynamicType;
|
||||
_velocity = d._velocity;
|
||||
|
@ -117,7 +118,7 @@ void Dynamic::write(XmlWriter& xml) const
|
|||
xml.tag("subtype", dynamicTypeName());
|
||||
writeProperty(xml, P_ID::VELOCITY);
|
||||
writeProperty(xml, P_ID::DYNAMIC_RANGE);
|
||||
Text::writeProperties(xml, dynamicType() == Type::OTHER);
|
||||
TextBase::writeProperties(xml, dynamicType() == Type::OTHER);
|
||||
xml.etag();
|
||||
}
|
||||
|
||||
|
@ -135,7 +136,7 @@ void Dynamic::read(XmlReader& e)
|
|||
_velocity = e.readInt();
|
||||
else if (tag == "dynType")
|
||||
_dynRange = Range(e.readInt());
|
||||
else if (!Text::readProperties(e))
|
||||
else if (!TextBase::readProperties(e))
|
||||
e.unknown();
|
||||
}
|
||||
if (subStyle() == SubStyle::DEFAULT)
|
||||
|
@ -159,7 +160,7 @@ void Dynamic::layout()
|
|||
y = score()->styleP(StyleIdx::dynamicsPosBelow) + sh + lineSpacing();
|
||||
}
|
||||
setPos(QPointF(0.0, y));
|
||||
Text::layout1();
|
||||
TextBase::layout1();
|
||||
|
||||
Segment* s = segment();
|
||||
if (s) {
|
||||
|
@ -256,7 +257,7 @@ QString Dynamic::dynamicTypeName() const
|
|||
|
||||
void Dynamic::startEdit(EditData& ed)
|
||||
{
|
||||
Text::startEdit(ed);
|
||||
TextBase::startEdit(ed);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -265,7 +266,7 @@ void Dynamic::startEdit(EditData& ed)
|
|||
|
||||
void Dynamic::endEdit(EditData& ed)
|
||||
{
|
||||
Text::endEdit(ed);
|
||||
TextBase::endEdit(ed);
|
||||
if (xmlText() != QString::fromUtf8(dynList[int(_dynamicType)].text))
|
||||
_dynamicType = Type::OTHER;
|
||||
}
|
||||
|
@ -276,7 +277,7 @@ void Dynamic::endEdit(EditData& ed)
|
|||
|
||||
void Dynamic::reset()
|
||||
{
|
||||
Text::reset();
|
||||
TextBase::reset();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -328,7 +329,7 @@ QVariant Dynamic::getProperty(P_ID propertyId) const
|
|||
case P_ID::VELOCITY: return velocity();
|
||||
case P_ID::SUBTYPE: return int(_dynamicType);
|
||||
default:
|
||||
return Text::getProperty(propertyId);
|
||||
return TextBase::getProperty(propertyId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -349,7 +350,7 @@ bool Dynamic::setProperty(P_ID propertyId, const QVariant& v)
|
|||
_dynamicType = Type(v.toInt());
|
||||
break;
|
||||
default:
|
||||
if (!Text::setProperty(propertyId, v))
|
||||
if (!TextBase::setProperty(propertyId, v))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
@ -371,7 +372,7 @@ QVariant Dynamic::propertyDefault(P_ID id) const
|
|||
case P_ID::VELOCITY:
|
||||
return -1;
|
||||
default:
|
||||
return Text::propertyDefault(id);
|
||||
return TextBase::propertyDefault(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class Segment;
|
|||
// @P range enum (Dynamic.STAFF, .PART, .SYSTEM)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class Dynamic final : public Text {
|
||||
class Dynamic final : public TextBase {
|
||||
public:
|
||||
enum class Type : char {
|
||||
OTHER,
|
||||
|
|
|
@ -639,84 +639,6 @@ void ElementList::write(XmlWriter& xml) const
|
|||
e->write(xml);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Line
|
||||
//---------------------------------------------------------
|
||||
|
||||
Line::Line(Score* s, bool v)
|
||||
: Element(s)
|
||||
{
|
||||
vertical = v;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// spatiumChanged
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Line::spatiumChanged(qreal oldValue, qreal newValue)
|
||||
{
|
||||
_width = (_width / oldValue) * newValue;
|
||||
_len = (_len / oldValue) * newValue;
|
||||
layout();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// layout
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Line::layout()
|
||||
{
|
||||
qreal w2 = _width * .5;
|
||||
if (vertical)
|
||||
bbox().setRect(-w2, -w2, _width, _len + _width);
|
||||
else
|
||||
bbox().setRect(-w2, -w2, _len + _width, _width);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// draw
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Line::draw(QPainter* painter) const
|
||||
{
|
||||
painter->setPen(QPen(curColor(), _width));
|
||||
if (vertical)
|
||||
painter->drawLine(QLineF(0.0, 0.0, 0.0, _len));
|
||||
else
|
||||
painter->drawLine(QLineF(0.0, 0.0, _len, 0.0));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// writeProperties
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Line::writeProperties(XmlWriter& xml) const
|
||||
{
|
||||
xml.tag("lineWidth", _width / spatium());
|
||||
xml.tag("lineLen", _len / spatium());
|
||||
if (!vertical)
|
||||
xml.tag("vertical", vertical);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// readProperties
|
||||
//---------------------------------------------------------
|
||||
|
||||
bool Line::readProperties(XmlReader& e)
|
||||
{
|
||||
const QStringRef& tag(e.name());
|
||||
|
||||
if (tag == "lineWidth")
|
||||
_width = e.readDouble() * spatium();
|
||||
else if (tag == "lineLen")
|
||||
_len = e.readDouble() * spatium();
|
||||
else if (tag == "vertical")
|
||||
vertical = e.readInt();
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Compound
|
||||
//---------------------------------------------------------
|
||||
|
@ -978,7 +900,6 @@ Element* Element::create(ElementType type, Score* score)
|
|||
case ElementType::SLUR_SEGMENT:
|
||||
case ElementType::TIE_SEGMENT:
|
||||
case ElementType::STEM_SLASH:
|
||||
case ElementType::LINE:
|
||||
case ElementType::TIE:
|
||||
case ElementType::PAGE:
|
||||
case ElementType::BEAM:
|
||||
|
|
|
@ -494,38 +494,6 @@ class ElementList : public std::vector<Element*> {
|
|||
void write(XmlWriter&, const char* name) const;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------
|
||||
// @@ Line
|
||||
//---------------------------------------------------------
|
||||
|
||||
class Line : public Element {
|
||||
qreal _width;
|
||||
qreal _len;
|
||||
|
||||
protected:
|
||||
bool vertical;
|
||||
|
||||
public:
|
||||
Line(Score*);
|
||||
Line(Score*, bool vertical);
|
||||
Line &operator=(const Line&);
|
||||
|
||||
virtual Line* clone() const override { return new Line(*this); }
|
||||
virtual ElementType type() const override { return ElementType::LINE; }
|
||||
virtual void layout() override;
|
||||
|
||||
virtual void draw(QPainter*) const override;
|
||||
void writeProperties(XmlWriter& xml) const;
|
||||
bool readProperties(XmlReader&);
|
||||
|
||||
qreal len() const { return _len; }
|
||||
qreal lineWidth() const { return _width; }
|
||||
void setLen(qreal v) { _len = v; }
|
||||
void setLineWidth(qreal v) { _width = v; }
|
||||
|
||||
virtual void spatiumChanged(qreal /*oldValue*/, qreal /*newValue*/) override;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------
|
||||
// @@ Compound
|
||||
//---------------------------------------------------------
|
||||
|
|
|
@ -202,7 +202,8 @@ void Excerpt::createExcerpt(Excerpt* excerpt)
|
|||
titleFramePart->copyValues(titleFrameScore);
|
||||
QString partLabel = excerpt->title(); // parts.front()->longName();
|
||||
if (!partLabel.isEmpty()) {
|
||||
Text* txt = new Text(SubStyle::INSTRUMENT_EXCERPT, score);
|
||||
Text* txt = new Text(score);
|
||||
txt->init(SubStyle::INSTRUMENT_EXCERPT);
|
||||
txt->setPlainText(partLabel);
|
||||
txt->setTrack(0);
|
||||
measure->add(txt);
|
||||
|
|
|
@ -956,8 +956,9 @@ bool FiguredBassItem::startsWithParenthesis() const
|
|||
//---------------------------------------------------------
|
||||
|
||||
FiguredBass::FiguredBass(Score* s)
|
||||
: Text(SubStyle::FIGURED_BASS, s)
|
||||
: TextBase(s)
|
||||
{
|
||||
init(SubStyle::FIGURED_BASS);
|
||||
setFlag(ElementFlag::ON_STAFF, true);
|
||||
setOnNote(true);
|
||||
#if 0 // TODO
|
||||
|
@ -978,7 +979,7 @@ FiguredBass::FiguredBass(Score* s)
|
|||
}
|
||||
|
||||
FiguredBass::FiguredBass(const FiguredBass& fb)
|
||||
: Text(fb)
|
||||
: TextBase(fb)
|
||||
{
|
||||
setOnNote(fb.onNote());
|
||||
setTicks(fb.ticks());
|
||||
|
@ -1011,7 +1012,7 @@ void FiguredBass::write(XmlWriter& xml) const
|
|||
xml.tag("ticks", ticks());
|
||||
// if unparseable items, write full text data
|
||||
if (items.size() < 1)
|
||||
Text::writeProperties(xml, true);
|
||||
TextBase::writeProperties(xml, true);
|
||||
else {
|
||||
// if (textStyleType() != StyledPropertyListIdx::FIGURED_BASS)
|
||||
// // if all items parsed and not unstiled, we simply have a special style: write it
|
||||
|
@ -1050,7 +1051,7 @@ void FiguredBass::read(XmlReader& e)
|
|||
}
|
||||
// else if (tag == "style")
|
||||
// setStyledPropertyListIdx(e.readElementText());
|
||||
else if (!Text::readProperties(e))
|
||||
else if (!TextBase::readProperties(e))
|
||||
e.unknown();
|
||||
}
|
||||
// if items could be parsed set normalized text
|
||||
|
@ -1080,7 +1081,7 @@ void FiguredBass::layout()
|
|||
// do nothing else, keeping default laying out and formatting
|
||||
// if (editMode() || items.size() < 1 || subStyle() != SubStyle::FIGURED_BASS) {
|
||||
if (items.size() < 1 || subStyle() != SubStyle::FIGURED_BASS) {
|
||||
Text::layout();
|
||||
TextBase::layout();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1207,10 +1208,10 @@ void FiguredBass::draw(QPainter* painter) const
|
|||
// if in edit mode or with custom style, use standard text drawing
|
||||
// if (editMode() || subStyle() != SubStyle::FIGURED_BASS)
|
||||
if (subStyle() != SubStyle::FIGURED_BASS)
|
||||
Text::draw(painter);
|
||||
TextBase::draw(painter);
|
||||
else { // not edit mode:
|
||||
if (items.size() < 1) // if not parseable into f.b. items
|
||||
Text::draw(painter); // draw as standard text
|
||||
TextBase::draw(painter); // draw as standard text
|
||||
else
|
||||
for (FiguredBassItem* item : items) { // if parseable into f.b. items
|
||||
painter->translate(item->pos()); // draw each item in its proper position
|
||||
|
@ -1231,15 +1232,15 @@ void FiguredBass::draw(QPainter* painter) const
|
|||
|
||||
void FiguredBass::startEdit(EditData& ed)
|
||||
{
|
||||
Text::layout(); // convert layout to standard Text conventions
|
||||
Text::startEdit(ed);
|
||||
TextBase::layout(); // convert layout to standard Text conventions
|
||||
TextBase::startEdit(ed);
|
||||
}
|
||||
|
||||
void FiguredBass::endEdit(EditData& ed)
|
||||
{
|
||||
int idx;
|
||||
|
||||
Text::endEdit(ed);
|
||||
TextBase::endEdit(ed);
|
||||
// as the standard text editor keeps inserting spurious HTML formatting and styles
|
||||
// retrieve and work only on the plain text
|
||||
QString txt = plainText();
|
||||
|
@ -1257,7 +1258,7 @@ void FiguredBass::endEdit(EditData& ed)
|
|||
FiguredBassItem* pItem = new FiguredBassItem(score(), idx++);
|
||||
if(!pItem->parse(str)) { // if any item fails parsing
|
||||
items.clear(); // clear item list
|
||||
Text::layout(); // keeping text as entered by user
|
||||
TextBase::layout(); // keeping text as entered by user
|
||||
return;
|
||||
}
|
||||
pItem->setTrack(track());
|
||||
|
@ -1363,7 +1364,7 @@ QVariant FiguredBass::getProperty(P_ID propertyId) const
|
|||
{
|
||||
switch(propertyId) {
|
||||
default:
|
||||
return Text::getProperty(propertyId);
|
||||
return TextBase::getProperty(propertyId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1372,7 +1373,7 @@ bool FiguredBass::setProperty(P_ID propertyId, const QVariant& v)
|
|||
score()->addRefresh(canvasBoundingRect());
|
||||
switch(propertyId) {
|
||||
default:
|
||||
return Text::setProperty(propertyId, v);
|
||||
return TextBase::setProperty(propertyId, v);
|
||||
}
|
||||
score()->setLayoutAll();
|
||||
return true;
|
||||
|
@ -1382,7 +1383,7 @@ QVariant FiguredBass::propertyDefault(P_ID id) const
|
|||
{
|
||||
switch(id) {
|
||||
default:
|
||||
return Text::propertyDefault(id);
|
||||
return TextBase::propertyDefault(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -229,7 +229,7 @@ struct FiguredBassFont {
|
|||
// @P ticks int duration in ticks
|
||||
//---------------------------------------------------------
|
||||
|
||||
class FiguredBass final : public Text {
|
||||
class FiguredBass final : public TextBase {
|
||||
std::vector<FiguredBassItem*> items; // the individual lines of the F.B.
|
||||
QVector<qreal> _lineLenghts; // lengths of duration indicator lines (in raster units)
|
||||
bool _onNote; // true if this element is on a staff note | false if it is betweee notes
|
||||
|
|
|
@ -27,8 +27,9 @@ namespace Ms {
|
|||
//---------------------------------------------------------
|
||||
|
||||
Fingering::Fingering(Score* s)
|
||||
: Text(SubStyle::FINGERING, s)
|
||||
: TextBase(s)
|
||||
{
|
||||
init(SubStyle::FINGERING);
|
||||
setFlag(ElementFlag::HAS_TAG, true); // this is a layered element
|
||||
}
|
||||
|
||||
|
@ -41,7 +42,7 @@ void Fingering::write(XmlWriter& xml) const
|
|||
if (!xml.canWrite(this))
|
||||
return;
|
||||
xml.stag(name());
|
||||
Text::writeProperties(xml);
|
||||
TextBase::writeProperties(xml);
|
||||
xml.etag();
|
||||
}
|
||||
|
||||
|
@ -52,7 +53,7 @@ void Fingering::write(XmlWriter& xml) const
|
|||
void Fingering::read(XmlReader& e)
|
||||
{
|
||||
while (e.readNextStartElement()) {
|
||||
if (!Text::readProperties(e))
|
||||
if (!TextBase::readProperties(e))
|
||||
e.unknown();
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +64,7 @@ void Fingering::read(XmlReader& e)
|
|||
|
||||
void Fingering::layout()
|
||||
{
|
||||
Text::layout();
|
||||
TextBase::layout();
|
||||
|
||||
if (autoplace() && note()) {
|
||||
Chord* chord = note()->chord();
|
||||
|
@ -124,7 +125,7 @@ void Fingering::layout()
|
|||
|
||||
void Fingering::draw(QPainter* painter) const
|
||||
{
|
||||
Text::draw(painter);
|
||||
TextBase::draw(painter);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -148,7 +149,7 @@ QVariant Fingering::getProperty(P_ID propertyId) const
|
|||
{
|
||||
switch (propertyId) {
|
||||
default:
|
||||
return Text::getProperty(propertyId);
|
||||
return TextBase::getProperty(propertyId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +161,7 @@ bool Fingering::setProperty(P_ID propertyId, const QVariant& v)
|
|||
{
|
||||
switch (propertyId) {
|
||||
default:
|
||||
return Text::setProperty(propertyId, v);
|
||||
return TextBase::setProperty(propertyId, v);
|
||||
}
|
||||
triggerLayout();
|
||||
return true;
|
||||
|
@ -176,7 +177,7 @@ QVariant Fingering::propertyDefault(P_ID id) const
|
|||
case P_ID::SUB_STYLE:
|
||||
return int(SubStyle::FINGERING);
|
||||
default:
|
||||
return Text::propertyDefault(id);
|
||||
return TextBase::propertyDefault(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,7 +189,7 @@ PropertyFlags& Fingering::propertyFlags(P_ID id)
|
|||
{
|
||||
switch (id) {
|
||||
default:
|
||||
return Text::propertyFlags(id);
|
||||
return TextBase::propertyFlags(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,7 +201,7 @@ void Fingering::resetProperty(P_ID id)
|
|||
{
|
||||
switch (id) {
|
||||
default:
|
||||
return Text::resetProperty(id);
|
||||
return TextBase::resetProperty(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,7 +213,7 @@ StyleIdx Fingering::getPropertyStyle(P_ID id) const
|
|||
{
|
||||
switch (id) {
|
||||
default:
|
||||
return Text::getPropertyStyle(id);
|
||||
return TextBase::getPropertyStyle(id);
|
||||
}
|
||||
return StyleIdx::NOSTYLE;
|
||||
}
|
||||
|
@ -224,7 +225,7 @@ StyleIdx Fingering::getPropertyStyle(P_ID id) const
|
|||
|
||||
void Fingering::styleChanged()
|
||||
{
|
||||
Text::styleChanged();
|
||||
TextBase::styleChanged();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -233,7 +234,7 @@ void Fingering::styleChanged()
|
|||
|
||||
void Fingering::reset()
|
||||
{
|
||||
Text::reset();
|
||||
TextBase::reset();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
|
|
@ -24,7 +24,7 @@ class Note;
|
|||
// @@ Fingering
|
||||
//---------------------------------------------------------
|
||||
|
||||
class Fingering final : public Text {
|
||||
class Fingering final : public TextBase {
|
||||
public:
|
||||
Fingering(Score* s);
|
||||
virtual Fingering* clone() const override { return new Fingering(*this); }
|
||||
|
|
|
@ -138,8 +138,9 @@ qDebug("ResolveDegreeList: not found in table");
|
|||
//---------------------------------------------------------
|
||||
|
||||
Harmony::Harmony(Score* s)
|
||||
: Text(SubStyle::HARMONY, s)
|
||||
: TextBase(s)
|
||||
{
|
||||
init(SubStyle::HARMONY);
|
||||
_rootTpc = Tpc::TPC_INVALID;
|
||||
_baseTpc = Tpc::TPC_INVALID;
|
||||
_rootCase = NoteCaseType::CAPITAL;
|
||||
|
@ -152,7 +153,7 @@ Harmony::Harmony(Score* s)
|
|||
}
|
||||
|
||||
Harmony::Harmony(const Harmony& h)
|
||||
: Text(h)
|
||||
: TextBase(h)
|
||||
{
|
||||
_rootTpc = h._rootTpc;
|
||||
_baseTpc = h._baseTpc;
|
||||
|
@ -252,7 +253,7 @@ void Harmony::write(XmlWriter& xml) const
|
|||
}
|
||||
else
|
||||
xml.tag("name", _textName);
|
||||
Text::writeProperties(xml, false, true);
|
||||
TextBase::writeProperties(xml, false, true);
|
||||
if (_rightParen)
|
||||
xml.tagE("rightParen");
|
||||
xml.etag();
|
||||
|
@ -329,7 +330,7 @@ void Harmony::read(XmlReader& e)
|
|||
_rightParen = true;
|
||||
e.readNext();
|
||||
}
|
||||
else if (!Text::readProperties(e))
|
||||
else if (!TextBase::readProperties(e))
|
||||
e.unknown();
|
||||
}
|
||||
|
||||
|
@ -708,7 +709,7 @@ void Harmony::startEdit(EditData& ed)
|
|||
{
|
||||
if (!textList.empty())
|
||||
setXmlText(harmonyName());
|
||||
Text::startEdit(ed);
|
||||
TextBase::startEdit(ed);
|
||||
layout();
|
||||
}
|
||||
|
||||
|
@ -720,7 +721,7 @@ bool Harmony::edit(EditData& ed)
|
|||
{
|
||||
if (ed.key == Qt::Key_Return)
|
||||
return true; // Harmony only single line
|
||||
bool rv = Text::edit(ed);
|
||||
bool rv = TextBase::edit(ed);
|
||||
QString str = xmlText();
|
||||
int root, base;
|
||||
bool badSpell = !str.isEmpty() && !parseHarmony(str, &root, &base, true);
|
||||
|
@ -734,7 +735,7 @@ bool Harmony::edit(EditData& ed)
|
|||
|
||||
void Harmony::endEdit(EditData& ed)
|
||||
{
|
||||
Text::endEdit(ed);
|
||||
TextBase::endEdit(ed);
|
||||
layout();
|
||||
if (links()) {
|
||||
foreach(ScoreElement* e, *links()) {
|
||||
|
@ -743,7 +744,7 @@ void Harmony::endEdit(EditData& ed)
|
|||
Harmony* h = toHarmony(e);
|
||||
// transpose if necessary
|
||||
// at this point chord will already have been rendered in same key as original
|
||||
// (as a result of Text::endEdit() calling setText() for linked elements)
|
||||
// (as a result of TextBase::endEdit() calling setText() for linked elements)
|
||||
// we may now need to change the TPC's and the text, and re-render
|
||||
if (score()->styleB(StyleIdx::concertPitch) != h->score()->styleB(StyleIdx::concertPitch)) {
|
||||
Part* partDest = h->part();
|
||||
|
@ -804,7 +805,7 @@ void Harmony::setHarmony(const QString& s)
|
|||
|
||||
qreal Harmony::baseLine() const
|
||||
{
|
||||
return (textList.empty()) ? Text::baseLine() : 0.0;
|
||||
return (textList.empty()) ? TextBase::baseLine() : 0.0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -1036,7 +1037,7 @@ void Harmony::layout()
|
|||
}
|
||||
yy += offset().y(); // yy += offset(_spatium).y();
|
||||
|
||||
qreal hb = lineHeight() - Text::baseLine();
|
||||
qreal hb = lineHeight() - TextBase::baseLine();
|
||||
if (align() & Align::BOTTOM)
|
||||
yy -= hb;
|
||||
else if (align() & Align::VCENTER) {
|
||||
|
@ -1096,7 +1097,7 @@ void Harmony::layout()
|
|||
void Harmony::calculateBoundingRect()
|
||||
{
|
||||
if (textList.empty()) {
|
||||
Text::layout1();
|
||||
TextBase::layout1();
|
||||
setbboxtight(bbox());
|
||||
}
|
||||
else {
|
||||
|
@ -1119,7 +1120,7 @@ void Harmony::draw(QPainter* painter) const
|
|||
{
|
||||
// painter->setPen(curColor());
|
||||
if (textList.empty()) {
|
||||
Text::draw(painter);
|
||||
TextBase::draw(painter);
|
||||
return;
|
||||
}
|
||||
if (hasFrame()) {
|
||||
|
@ -1411,7 +1412,7 @@ void Harmony::render()
|
|||
|
||||
void Harmony::spatiumChanged(qreal oldValue, qreal newValue)
|
||||
{
|
||||
Text::spatiumChanged(oldValue, newValue);
|
||||
TextBase::spatiumChanged(oldValue, newValue);
|
||||
render();
|
||||
}
|
||||
|
||||
|
@ -1421,7 +1422,7 @@ void Harmony::spatiumChanged(qreal oldValue, qreal newValue)
|
|||
|
||||
void Harmony::localSpatiumChanged(qreal oldValue, qreal newValue)
|
||||
{
|
||||
Text::localSpatiumChanged(oldValue, newValue);
|
||||
TextBase::localSpatiumChanged(oldValue, newValue);
|
||||
render();
|
||||
}
|
||||
|
||||
|
@ -1624,7 +1625,7 @@ QVariant Harmony::propertyDefault(P_ID id) const
|
|||
case P_ID::SUB_STYLE:
|
||||
return int(SubStyle::HARMONY);
|
||||
default:
|
||||
return Text::propertyDefault(id);
|
||||
return TextBase::propertyDefault(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ struct TextSegment {
|
|||
struct RenderAction;
|
||||
class HDegree;
|
||||
|
||||
class Harmony final : public Text {
|
||||
class Harmony final : public TextBase {
|
||||
int _rootTpc; // root note for chord
|
||||
int _baseTpc; // bass note or chord base; used for "slash" chords
|
||||
// or notation of base note in chord
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Ms {
|
|||
//---------------------------------------------------------
|
||||
|
||||
InstrumentName::InstrumentName(Score* s)
|
||||
: Text(s)
|
||||
: TextBase(s)
|
||||
{
|
||||
setInstrumentNameType(InstrumentNameType::SHORT);
|
||||
setSelectable(false);
|
||||
|
@ -72,7 +72,7 @@ QVariant InstrumentName::getProperty(P_ID id) const
|
|||
case P_ID::INAME_LAYOUT_POSITION:
|
||||
return _layoutPos;
|
||||
default:
|
||||
return Text::getProperty(id);
|
||||
return TextBase::getProperty(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ bool InstrumentName::setProperty(P_ID id, const QVariant& v)
|
|||
_layoutPos = v.toInt();
|
||||
break;
|
||||
default:
|
||||
rv = Text::setProperty(id, v);
|
||||
rv = TextBase::setProperty(id, v);
|
||||
break;
|
||||
}
|
||||
StyleIdx sidx = getPropertyStyle(id);
|
||||
|
@ -109,7 +109,7 @@ QVariant InstrumentName::propertyDefault(P_ID id) const
|
|||
case P_ID::INAME_LAYOUT_POSITION:
|
||||
return 0;
|
||||
default:
|
||||
return Text::propertyDefault(id);
|
||||
return TextBase::propertyDefault(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ enum class InstrumentNameType : char {
|
|||
// InstrumentName
|
||||
//---------------------------------------------------------
|
||||
|
||||
class InstrumentName final : public Text {
|
||||
class InstrumentName final : public TextBase {
|
||||
InstrumentNameType _instrumentNameType;
|
||||
int _layoutPos { 0 };
|
||||
|
||||
|
|
|
@ -28,21 +28,23 @@ namespace Ms {
|
|||
//---------------------------------------------------------
|
||||
|
||||
InstrumentChange::InstrumentChange(Score* s)
|
||||
: Text(SubStyle::INSTRUMENT_CHANGE, s)
|
||||
: TextBase(s)
|
||||
{
|
||||
init(SubStyle::INSTRUMENT_CHANGE);
|
||||
setFlags(ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF);
|
||||
_instrument = new Instrument();
|
||||
}
|
||||
|
||||
InstrumentChange::InstrumentChange(const Instrument& i, Score* s)
|
||||
: Text(SubStyle::INSTRUMENT_CHANGE, s)
|
||||
: TextBase(s)
|
||||
{
|
||||
init(SubStyle::INSTRUMENT_CHANGE);
|
||||
setFlags(ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF);
|
||||
_instrument = new Instrument(i);
|
||||
}
|
||||
|
||||
InstrumentChange::InstrumentChange(const InstrumentChange& is)
|
||||
: Text(is)
|
||||
: TextBase(is)
|
||||
{
|
||||
_instrument = new Instrument(*is._instrument);
|
||||
}
|
||||
|
@ -66,7 +68,7 @@ void InstrumentChange::write(XmlWriter& xml) const
|
|||
{
|
||||
xml.stag(name());
|
||||
_instrument->write(xml, part());
|
||||
Text::writeProperties(xml);
|
||||
TextBase::writeProperties(xml);
|
||||
xml.etag();
|
||||
}
|
||||
|
||||
|
@ -80,7 +82,7 @@ void InstrumentChange::read(XmlReader& e)
|
|||
const QStringRef& tag(e.name());
|
||||
if (tag == "Instrument")
|
||||
_instrument->read(e, part());
|
||||
else if (!Text::readProperties(e))
|
||||
else if (!TextBase::readProperties(e))
|
||||
e.unknown();
|
||||
}
|
||||
if (score()->mscVersion() <= 206) {
|
||||
|
@ -105,7 +107,7 @@ QVariant InstrumentChange::getProperty(P_ID propertyId) const
|
|||
{
|
||||
switch (propertyId) {
|
||||
default:
|
||||
return Text::getProperty(propertyId);
|
||||
return TextBase::getProperty(propertyId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +121,7 @@ QVariant InstrumentChange::propertyDefault(P_ID propertyId) const
|
|||
case P_ID::SUB_STYLE:
|
||||
return int(SubStyle::INSTRUMENT_CHANGE);
|
||||
default:
|
||||
return Text::propertyDefault(propertyId);
|
||||
return TextBase::propertyDefault(propertyId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,7 +133,7 @@ bool InstrumentChange::setProperty(P_ID propertyId, const QVariant& v)
|
|||
{
|
||||
switch (propertyId) {
|
||||
default:
|
||||
return Text::setProperty(propertyId, v);
|
||||
return TextBase::setProperty(propertyId, v);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Ms {
|
|||
// @@ InstrumentChange
|
||||
//---------------------------------------------------------
|
||||
|
||||
class InstrumentChange final : public Text {
|
||||
class InstrumentChange final : public TextBase {
|
||||
Instrument* _instrument; // Staff holds ownership if part of score
|
||||
|
||||
public:
|
||||
|
|
|
@ -40,8 +40,9 @@ int jumpTypeTableSize()
|
|||
//---------------------------------------------------------
|
||||
|
||||
Jump::Jump(Score* s)
|
||||
: Text(SubStyle::REPEAT_RIGHT, s)
|
||||
: TextBase(s)
|
||||
{
|
||||
init(SubStyle::REPEAT_RIGHT);
|
||||
setFlags(ElementFlag::MOVABLE | ElementFlag::SELECTABLE);
|
||||
setLayoutToParentWidth(true);
|
||||
_playRepeats = false;
|
||||
|
@ -93,7 +94,7 @@ QString Jump::jumpTypeUserName() const
|
|||
void Jump::layout()
|
||||
{
|
||||
setPos(QPointF(0.0, score()->styleP(StyleIdx::jumpPosAbove)));
|
||||
Text::layout1();
|
||||
TextBase::layout1();
|
||||
adjustReadPos();
|
||||
}
|
||||
|
||||
|
@ -113,7 +114,7 @@ void Jump::read(XmlReader& e)
|
|||
_continueAt = e.readElementText();
|
||||
else if (tag == "playRepeats")
|
||||
_playRepeats = e.readBool();
|
||||
else if (!Text::readProperties(e))
|
||||
else if (!TextBase::readProperties(e))
|
||||
e.unknown();
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +126,7 @@ void Jump::read(XmlReader& e)
|
|||
void Jump::write(XmlWriter& xml) const
|
||||
{
|
||||
xml.stag(name());
|
||||
Text::writeProperties(xml);
|
||||
TextBase::writeProperties(xml);
|
||||
xml.tag("jumpTo", _jumpTo);
|
||||
xml.tag("playUntil", _playUntil);
|
||||
xml.tag("continueAt", _continueAt);
|
||||
|
@ -178,7 +179,7 @@ QVariant Jump::getProperty(P_ID propertyId) const
|
|||
default:
|
||||
break;
|
||||
}
|
||||
return Text::getProperty(propertyId);
|
||||
return TextBase::getProperty(propertyId);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -201,7 +202,7 @@ bool Jump::setProperty(P_ID propertyId, const QVariant& v)
|
|||
setPlayRepeats(v.toInt());
|
||||
break;
|
||||
default:
|
||||
if (!Text::setProperty(propertyId, v))
|
||||
if (!TextBase::setProperty(propertyId, v))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
@ -228,7 +229,7 @@ QVariant Jump::propertyDefault(P_ID propertyId) const
|
|||
default:
|
||||
break;
|
||||
}
|
||||
return Text::propertyDefault(propertyId);
|
||||
return TextBase::propertyDefault(propertyId);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
|
|
@ -30,7 +30,7 @@ enum class SubStyle;
|
|||
// @P playUntil string
|
||||
//---------------------------------------------------------
|
||||
|
||||
class Jump final : public Text {
|
||||
class Jump final : public TextBase {
|
||||
QString _jumpTo;
|
||||
QString _playUntil;
|
||||
QString _continueAt;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "staff.h"
|
||||
#include "system.h"
|
||||
#include "score.h"
|
||||
#include "xml.h"
|
||||
|
||||
namespace Ms {
|
||||
|
||||
|
@ -24,7 +25,7 @@ namespace Ms {
|
|||
//---------------------------------------------------------
|
||||
|
||||
LedgerLine::LedgerLine(Score* s)
|
||||
: Line(s, false)
|
||||
: Element(s)
|
||||
{
|
||||
setSelectable(false);
|
||||
_next = 0;
|
||||
|
@ -62,7 +63,11 @@ void LedgerLine::layout()
|
|||
setLineWidth(score()->styleP(StyleIdx::ledgerLineWidth) * chord()->mag());
|
||||
if (staff())
|
||||
setColor(staff()->color());
|
||||
Line::layout();
|
||||
qreal w2 = _width * .5;
|
||||
if (vertical)
|
||||
bbox().setRect(-w2, -w2, _width, _len + _width);
|
||||
else
|
||||
bbox().setRect(-w2, -w2, _len + _width, _width);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -73,7 +78,53 @@ void LedgerLine::draw(QPainter* painter) const
|
|||
{
|
||||
if (chord()->crossMeasure() == CrossMeasure::SECOND)
|
||||
return;
|
||||
Line::draw(painter);
|
||||
painter->setPen(QPen(curColor(), _width));
|
||||
if (vertical)
|
||||
painter->drawLine(QLineF(0.0, 0.0, 0.0, _len));
|
||||
else
|
||||
painter->drawLine(QLineF(0.0, 0.0, _len, 0.0));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// spatiumChanged
|
||||
//---------------------------------------------------------
|
||||
|
||||
void LedgerLine::spatiumChanged(qreal oldValue, qreal newValue)
|
||||
{
|
||||
_width = (_width / oldValue) * newValue;
|
||||
_len = (_len / oldValue) * newValue;
|
||||
layout();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// writeProperties
|
||||
//---------------------------------------------------------
|
||||
|
||||
void LedgerLine::writeProperties(XmlWriter& xml) const
|
||||
{
|
||||
xml.tag("lineWidth", _width / spatium());
|
||||
xml.tag("lineLen", _len / spatium());
|
||||
if (!vertical)
|
||||
xml.tag("vertical", vertical);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// readProperties
|
||||
//---------------------------------------------------------
|
||||
|
||||
bool LedgerLine::readProperties(XmlReader& e)
|
||||
{
|
||||
const QStringRef& tag(e.name());
|
||||
|
||||
if (tag == "lineWidth")
|
||||
_width = e.readDouble() * spatium();
|
||||
else if (tag == "lineLen")
|
||||
_len = e.readDouble() * spatium();
|
||||
else if (tag == "vertical")
|
||||
vertical = e.readInt();
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,8 +28,11 @@ class Chord;
|
|||
//! y-origin: SStaff
|
||||
//---------------------------------------------------------
|
||||
|
||||
class LedgerLine final : public Line {
|
||||
class LedgerLine final : public Element {
|
||||
qreal _width;
|
||||
qreal _len;
|
||||
LedgerLine* _next;
|
||||
bool vertical { false };
|
||||
|
||||
public:
|
||||
LedgerLine(Score*);
|
||||
|
@ -37,14 +40,24 @@ class LedgerLine final : public Line {
|
|||
virtual LedgerLine* clone() const override { return new LedgerLine(*this); }
|
||||
virtual ElementType type() const override { return ElementType::LEDGER_LINE; }
|
||||
virtual QPointF pagePos() const override; ///< position in page coordinates
|
||||
Chord* chord() const { return (Chord*)parent(); }
|
||||
Chord* chord() const { return toChord(parent()); }
|
||||
|
||||
qreal len() const { return _len; }
|
||||
qreal lineWidth() const { return _width; }
|
||||
void setLen(qreal v) { _len = v; }
|
||||
void setLineWidth(qreal v) { _width = v; }
|
||||
|
||||
virtual void layout() override;
|
||||
virtual void draw(QPainter*) const override;
|
||||
|
||||
qreal measureXPos() const;
|
||||
LedgerLine* next() const { return _next; }
|
||||
void setNext(LedgerLine* l) { _next = l; }
|
||||
};
|
||||
|
||||
virtual void writeProperties(XmlWriter& xml) const override;
|
||||
virtual bool readProperties(XmlReader&) override;
|
||||
virtual void spatiumChanged(qreal /*oldValue*/, qreal /*newValue*/) override;
|
||||
};
|
||||
|
||||
} // namespace Ms
|
||||
#endif
|
||||
|
|
|
@ -57,8 +57,9 @@ static Lyrics* searchNextLyrics(Segment* s, int staffIdx, int verse, Element::Pl
|
|||
//---------------------------------------------------------
|
||||
|
||||
Lyrics::Lyrics(Score* s)
|
||||
: Text(SubStyle::LYRIC1, s)
|
||||
: TextBase(s)
|
||||
{
|
||||
init(SubStyle::LYRIC1);
|
||||
_no = 0;
|
||||
_ticks = 0;
|
||||
_syllabic = Syllabic::SINGLE;
|
||||
|
@ -68,7 +69,7 @@ Lyrics::Lyrics(Score* s)
|
|||
}
|
||||
|
||||
Lyrics::Lyrics(const Lyrics& l)
|
||||
: Text(l)
|
||||
: TextBase(l)
|
||||
{
|
||||
_no = l._no;
|
||||
_ticks = l._ticks;
|
||||
|
@ -113,7 +114,7 @@ void Lyrics::write(XmlWriter& xml) const
|
|||
}
|
||||
writeProperty(xml, P_ID::LYRIC_TICKS);
|
||||
|
||||
Text::writeProperties(xml);
|
||||
TextBase::writeProperties(xml);
|
||||
xml.etag();
|
||||
}
|
||||
|
||||
|
@ -157,9 +158,9 @@ void Lyrics::read(XmlReader& e)
|
|||
}
|
||||
else if (tag == "placement") {
|
||||
placementStyle = PropertyFlags::UNSTYLED;
|
||||
Text::readProperties(e);
|
||||
TextBase::readProperties(e);
|
||||
}
|
||||
else if (!Text::readProperties(e))
|
||||
else if (!TextBase::readProperties(e))
|
||||
e.unknown();
|
||||
}
|
||||
// if any endTick, make it relative to current tick
|
||||
|
@ -180,11 +181,11 @@ void Lyrics::read(XmlReader& e)
|
|||
|
||||
void Lyrics::add(Element* el)
|
||||
{
|
||||
el->setParent(this);
|
||||
if (el->type() == ElementType::LINE)
|
||||
// el->setParent(this);
|
||||
// if (el->type() == ElementType::LINE)
|
||||
// _separator.append((Line*)el); // ignore! Internally managed
|
||||
;
|
||||
else
|
||||
// ;
|
||||
// else
|
||||
qDebug("Lyrics::add: unknown element %s", el->name());
|
||||
}
|
||||
|
||||
|
@ -262,7 +263,7 @@ void Lyrics::layout()
|
|||
void Lyrics::layout1()
|
||||
{
|
||||
setPos(QPointF());
|
||||
Text::layout1();
|
||||
TextBase::layout1();
|
||||
if (!parent()) // palette & clone trick
|
||||
return;
|
||||
|
||||
|
@ -297,6 +298,7 @@ void Lyrics::layout1()
|
|||
QRegularExpression punctuationPattern("(^[\\d\\W]*)([^\\d\\W].*?)([\\d\\W]*$)", QRegularExpression::UseUnicodePropertiesOption);
|
||||
QRegularExpressionMatch punctuationMatch = punctuationPattern.match(s);
|
||||
if (punctuationMatch.hasMatch()) {
|
||||
#if 0 // TODO::ws
|
||||
// leading and trailing punctuation
|
||||
QString lp = punctuationMatch.captured(1);
|
||||
QString tp = punctuationMatch.captured(3);
|
||||
|
@ -312,6 +314,7 @@ void Lyrics::layout1()
|
|||
centerAdjust = leading.width() - trailing.width();
|
||||
if (!lp.isEmpty() && lp[0].isDigit())
|
||||
hasNumber = true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -467,7 +470,7 @@ int Lyrics::endTick() const
|
|||
|
||||
bool Lyrics::acceptDrop(EditData& data) const
|
||||
{
|
||||
return data.element->isText() || Text::acceptDrop(data);
|
||||
return data.element->isText() || TextBase::acceptDrop(data);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -478,7 +481,7 @@ Element* Lyrics::drop(EditData& data)
|
|||
{
|
||||
ElementType type = data.element->type();
|
||||
if (type == ElementType::SYMBOL || type == ElementType::FSYMBOL) {
|
||||
Text::drop(data);
|
||||
TextBase::drop(data);
|
||||
return 0;
|
||||
}
|
||||
if (!data.element->isText()) {
|
||||
|
@ -514,7 +517,7 @@ void Lyrics::setNo(int n)
|
|||
|
||||
void Lyrics::endEdit(EditData& ed)
|
||||
{
|
||||
Text::endEdit(ed);
|
||||
TextBase::endEdit(ed);
|
||||
score()->setLayoutAll();
|
||||
}
|
||||
|
||||
|
@ -545,7 +548,7 @@ QVariant Lyrics::getProperty(P_ID propertyId) const
|
|||
case P_ID::VERSE:
|
||||
return _no;
|
||||
default:
|
||||
return Text::getProperty(propertyId);
|
||||
return TextBase::getProperty(propertyId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -570,7 +573,7 @@ bool Lyrics::setProperty(P_ID propertyId, const QVariant& v)
|
|||
_no = v.toInt();
|
||||
break;
|
||||
default:
|
||||
if (!Text::setProperty(propertyId, v))
|
||||
if (!TextBase::setProperty(propertyId, v))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
@ -594,7 +597,7 @@ QVariant Lyrics::propertyDefault(P_ID id) const
|
|||
case P_ID::LYRIC_TICKS:
|
||||
case P_ID::VERSE:
|
||||
return 0;
|
||||
default: return Text::propertyDefault(id);
|
||||
default: return TextBase::propertyDefault(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -932,7 +935,7 @@ PropertyFlags& Lyrics::propertyFlags(P_ID id)
|
|||
return ScoreElement::propertyFlags(id); // return PropertyFlags::NOSTYLE;
|
||||
|
||||
default:
|
||||
return Text::propertyFlags(id);
|
||||
return TextBase::propertyFlags(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -972,7 +975,7 @@ void Lyrics::styleChanged()
|
|||
{
|
||||
if (placementStyle == PropertyFlags::STYLED)
|
||||
setPlacement(Placement(score()->styleI(StyleIdx::lyricsPlacement)));
|
||||
Text::styleChanged();
|
||||
TextBase::styleChanged();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -982,7 +985,7 @@ void Lyrics::styleChanged()
|
|||
void Lyrics::reset()
|
||||
{
|
||||
undoResetProperty(P_ID::PLACEMENT);
|
||||
Text::reset();
|
||||
TextBase::reset();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -998,7 +1001,7 @@ void Lyrics::resetProperty(P_ID id)
|
|||
break;
|
||||
|
||||
default:
|
||||
return Text::resetProperty(id);
|
||||
return TextBase::resetProperty(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace Ms {
|
|||
|
||||
class LyricsLine;
|
||||
|
||||
class Lyrics final : public Text {
|
||||
class Lyrics final : public TextBase {
|
||||
public:
|
||||
enum class Syllabic : char { SINGLE, BEGIN, END, MIDDLE };
|
||||
// MELISMA FIRST UNDERSCORE:
|
||||
|
@ -124,7 +124,7 @@ class Lyrics final : public Text {
|
|||
#endif
|
||||
#endif
|
||||
|
||||
using Text::paste;
|
||||
using TextBase::paste;
|
||||
virtual void paste(EditData&) override;
|
||||
|
||||
virtual QVariant getProperty(P_ID propertyId) const override;
|
||||
|
|
|
@ -40,8 +40,9 @@ int markerTypeTableSize()
|
|||
//---------------------------------------------------------
|
||||
|
||||
Marker::Marker(Score* s)
|
||||
: Text(SubStyle::REPEAT_LEFT, s)
|
||||
: TextBase(s)
|
||||
{
|
||||
init(SubStyle::REPEAT_LEFT);
|
||||
_markerType = Type::FINE;
|
||||
setFlags(ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF);
|
||||
setLayoutToParentWidth(true);
|
||||
|
@ -175,7 +176,7 @@ Marker::Type Marker::markerType(const QString& s) const
|
|||
void Marker::layout()
|
||||
{
|
||||
setPos(QPointF(0.0, score()->styleP(StyleIdx::markerPosAbove)));
|
||||
Text::layout1();
|
||||
TextBase::layout1();
|
||||
// although normally laid out to parent (measure) width,
|
||||
// force to center over barline if left-aligned
|
||||
if (layoutToParentWidth() && !(align() & (Align::RIGHT | Align::HCENTER)))
|
||||
|
@ -198,7 +199,7 @@ void Marker::read(XmlReader& e)
|
|||
setLabel(s);
|
||||
mt = markerType(s);
|
||||
}
|
||||
else if (!Text::readProperties(e))
|
||||
else if (!TextBase::readProperties(e))
|
||||
e.unknown();
|
||||
}
|
||||
setMarkerType(mt);
|
||||
|
@ -211,7 +212,7 @@ void Marker::read(XmlReader& e)
|
|||
void Marker::write(XmlWriter& xml) const
|
||||
{
|
||||
xml.stag(name());
|
||||
Text::writeProperties(xml);
|
||||
TextBase::writeProperties(xml);
|
||||
xml.tag("label", _label);
|
||||
xml.etag();
|
||||
}
|
||||
|
@ -248,7 +249,7 @@ QVariant Marker::getProperty(P_ID propertyId) const
|
|||
default:
|
||||
break;
|
||||
}
|
||||
return Text::getProperty(propertyId);
|
||||
return TextBase::getProperty(propertyId);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -265,7 +266,7 @@ bool Marker::setProperty(P_ID propertyId, const QVariant& v)
|
|||
setMarkerType(Type(v.toInt()));
|
||||
break;
|
||||
default:
|
||||
if (!Text::setProperty(propertyId, v))
|
||||
if (!TextBase::setProperty(propertyId, v))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
@ -289,7 +290,7 @@ QVariant Marker::propertyDefault(P_ID propertyId) const
|
|||
default:
|
||||
break;
|
||||
}
|
||||
return Text::propertyDefault(propertyId);
|
||||
return TextBase::propertyDefault(propertyId);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Ms {
|
|||
// @P markerType enum (Marker.CODA, .CODETTA, .FINE, .SEGNO, .TOCODA, .USER, .VARCODA, .VARSEGNO)
|
||||
//---------------------------------------------------------
|
||||
|
||||
class Marker final : public Text {
|
||||
class Marker final : public TextBase {
|
||||
public:
|
||||
enum class Type : char {
|
||||
SEGNO,
|
||||
|
|
|
@ -548,7 +548,8 @@ void Measure::layout2()
|
|||
t->setTrack(staffIdx * VOICES);
|
||||
if (smn && ((staffIdx == nn) || nas)) {
|
||||
if (t == 0) {
|
||||
t = new Text(SubStyle::MEASURE_NUMBER, score());
|
||||
t = new Text(score());
|
||||
t->init(SubStyle::MEASURE_NUMBER);
|
||||
t->setFlag(ElementFlag::ON_STAFF, true);
|
||||
t->setTrack(staffIdx * VOICES);
|
||||
t->setGenerated(true);
|
||||
|
@ -2081,7 +2082,7 @@ void Measure::read(XmlReader& e, int staffIdx)
|
|||
}
|
||||
}
|
||||
else if (tag == "Text") {
|
||||
Text* t = new StaffText(score());
|
||||
StaffText* t = new StaffText(score());
|
||||
t->setTrack(e.track());
|
||||
t->read(e);
|
||||
if (t->empty()) {
|
||||
|
@ -2222,7 +2223,8 @@ void Measure::read(XmlReader& e, int staffIdx)
|
|||
else if (tag == "Segment")
|
||||
segment->read(e);
|
||||
else if (tag == "MeasureNumber") {
|
||||
Text* noText = new Text(SubStyle::MEASURE_NUMBER, score());
|
||||
Text* noText = new Text(score());
|
||||
noText->init(SubStyle::MEASURE_NUMBER);
|
||||
noText->read(e);
|
||||
noText->setFlag(ElementFlag::ON_STAFF, true);
|
||||
noText->setTrack(e.track());
|
||||
|
|
|
@ -156,7 +156,8 @@ void Page::drawHeaderFooter(QPainter* p, int area, const QString& ss) const
|
|||
if (area < 3) {
|
||||
text = score()->headerText();
|
||||
if (!text) {
|
||||
text = new Text(SubStyle::HEADER, score());
|
||||
text = new Text(score());
|
||||
text->init(SubStyle::HEADER);
|
||||
text->setLayoutToParentWidth(true);
|
||||
score()->setHeaderText(text);
|
||||
}
|
||||
|
@ -164,7 +165,8 @@ void Page::drawHeaderFooter(QPainter* p, int area, const QString& ss) const
|
|||
else {
|
||||
text = score()->footerText();
|
||||
if (!text) {
|
||||
text = new Text(SubStyle::FOOTER, score());
|
||||
text = new Text(score());
|
||||
text->init(SubStyle::FOOTER);
|
||||
text->setLayoutToParentWidth(true);
|
||||
score()->setFooterText(text);
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ static const PaperSize* getPaperSize114(const QString& name)
|
|||
// convertFromHtml
|
||||
//---------------------------------------------------------
|
||||
|
||||
QString convertFromHtml(Text* t, const QString& ss)
|
||||
QString convertFromHtml(TextBase* t, const QString& ss)
|
||||
{
|
||||
QTextDocument doc;
|
||||
doc.setHtml(ss.trimmed());
|
||||
|
@ -298,7 +298,7 @@ QString convertFromHtml(Text* t, const QString& ss)
|
|||
// readTextProperties
|
||||
//---------------------------------------------------------
|
||||
|
||||
static bool readTextProperties(XmlReader& e, Text* t, Element* be)
|
||||
static bool readTextProperties(XmlReader& e, TextBase* t, Element* be)
|
||||
{
|
||||
const QStringRef& tag(e.name());
|
||||
if (tag == "style") {
|
||||
|
|
|
@ -1011,7 +1011,7 @@ static void readChord(Chord* chord, XmlReader& e)
|
|||
// read
|
||||
//---------------------------------------------------------
|
||||
|
||||
static void readText(XmlReader& e, Text* t, Element* be)
|
||||
static void readText(XmlReader& e, TextBase* t, Element* be)
|
||||
{
|
||||
while (e.readNextStartElement()) {
|
||||
const QStringRef& tag(e.name());
|
||||
|
@ -1034,7 +1034,7 @@ static void readText(XmlReader& e, Text* t, Element* be)
|
|||
else if (val == "left")
|
||||
;
|
||||
else
|
||||
qDebug("readText: unknown alignment: <%s>", qPrintable(val));
|
||||
qDebug("unknown alignment: <%s>", qPrintable(val));
|
||||
t->setAlign(align);
|
||||
}
|
||||
else if (tag == "valign") {
|
||||
|
@ -1049,7 +1049,7 @@ static void readText(XmlReader& e, Text* t, Element* be)
|
|||
else if (val == "top")
|
||||
;
|
||||
else
|
||||
qDebug("Text::readProperties: unknown alignment: <%s>", qPrintable(val));
|
||||
qDebug("unknown alignment: <%s>", qPrintable(val));
|
||||
t->setAlign(align);
|
||||
}
|
||||
else if (!t->readProperties(e))
|
||||
|
@ -1766,7 +1766,7 @@ static void readMeasure(Measure* m, int staffIdx, XmlReader& e)
|
|||
}
|
||||
}
|
||||
else if (tag == "Text") {
|
||||
Text* t = new StaffText(score);
|
||||
StaffText* t = new StaffText(score);
|
||||
t->setTrack(e.track());
|
||||
readText(e, t, t);
|
||||
if (t->empty()) {
|
||||
|
|
|
@ -22,8 +22,10 @@ namespace Ms {
|
|||
//---------------------------------------------------------
|
||||
|
||||
RehearsalMark::RehearsalMark(Score* s)
|
||||
: SystemText(SubStyle::REHEARSAL_MARK, s)
|
||||
: TextBase(s)
|
||||
{
|
||||
init(SubStyle::REHEARSAL_MARK);
|
||||
setSystemFlag(true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -42,7 +44,7 @@ void RehearsalMark::layout()
|
|||
y = score()->styleP(StyleIdx::rehearsalMarkPosBelow) + sh + lineSpacing();
|
||||
}
|
||||
setPos(QPointF(0.0, y));
|
||||
Text::layout1();
|
||||
TextBase::layout1();
|
||||
|
||||
Segment* s = segment();
|
||||
if (s) {
|
||||
|
@ -91,7 +93,7 @@ QVariant RehearsalMark::propertyDefault(P_ID id) const
|
|||
case P_ID::PLACEMENT:
|
||||
return score()->styleV(StyleIdx::rehearsalMarkPlacement);
|
||||
default:
|
||||
return Text::propertyDefault(id);
|
||||
return TextBase::propertyDefault(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Ms {
|
|||
// @@ RehearsalMark
|
||||
//---------------------------------------------------------
|
||||
|
||||
class RehearsalMark final : public SystemText {
|
||||
class RehearsalMark final : public TextBase {
|
||||
public:
|
||||
RehearsalMark(Score* score);
|
||||
virtual RehearsalMark* clone() const override { return new RehearsalMark(*this); }
|
||||
|
|
|
@ -37,7 +37,6 @@ static const ElementName elementNames[] = {
|
|||
{ ElementType::BAR_LINE, "BarLine", QT_TRANSLATE_NOOP("elementName", "Barline") },
|
||||
{ ElementType::SYSTEM_DIVIDER, "SystemDivider", QT_TRANSLATE_NOOP("elementName", "System Divider") },
|
||||
{ ElementType::STEM_SLASH, "StemSlash", QT_TRANSLATE_NOOP("elementName", "Stem Slash") },
|
||||
{ ElementType::LINE, "Line", QT_TRANSLATE_NOOP("elementName", "Line") },
|
||||
{ ElementType::ARPEGGIO, "Arpeggio", QT_TRANSLATE_NOOP("elementName", "Arpeggio") },
|
||||
{ ElementType::ACCIDENTAL, "Accidental", QT_TRANSLATE_NOOP("elementName", "Accidental") },
|
||||
{ ElementType::LEDGER_LINE, "LedgerLine", QT_TRANSLATE_NOOP("elementName", "Ledger Line") },
|
||||
|
|
|
@ -24,16 +24,18 @@ namespace Ms {
|
|||
//---------------------------------------------------------
|
||||
|
||||
StaffText::StaffText(Score* s)
|
||||
: Text(SubStyle::STAFF, s)
|
||||
: TextBase(s)
|
||||
{
|
||||
init(SubStyle::STAFF);
|
||||
setFlags(ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF);
|
||||
setPlacement(Placement::ABOVE); // default
|
||||
setSwingParameters(MScore::division / 2, 60);
|
||||
}
|
||||
|
||||
StaffText::StaffText(SubStyle ss, Score* s)
|
||||
: Text(ss, s)
|
||||
: TextBase(s)
|
||||
{
|
||||
init(ss);
|
||||
setFlags(ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF);
|
||||
setPlacement(Placement::ABOVE); // default
|
||||
setSwingParameters(MScore::division / 2, 60);
|
||||
|
@ -69,7 +71,7 @@ void StaffText::writeProperties(XmlWriter& xml) const
|
|||
int swingRatio = swingParameters()->swingRatio;
|
||||
xml.tagE(QString("swing unit=\"%1\" ratio= \"%2\"").arg(swingUnit).arg(swingRatio));
|
||||
}
|
||||
Text::writeProperties(xml);
|
||||
TextBase::writeProperties(xml);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -163,7 +165,7 @@ bool StaffText::readProperties(XmlReader& e)
|
|||
setSwingParameters(unit, ratio);
|
||||
e.readNext();
|
||||
}
|
||||
else if (!Text::readProperties(e))
|
||||
else if (!TextBase::readProperties(e))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -213,7 +215,7 @@ void StaffText::layout()
|
|||
if (placement() == Element::Placement::BELOW)
|
||||
p.ry() = - p.ry() + lineHeight();
|
||||
setPos(p);
|
||||
Text::layout1();
|
||||
TextBase::layout1();
|
||||
if (!parent()) // palette & clone trick
|
||||
return;
|
||||
|
||||
|
@ -262,7 +264,7 @@ QVariant StaffText::propertyDefault(P_ID id) const
|
|||
case P_ID::PLACEMENT:
|
||||
return int(Placement::ABOVE);
|
||||
default:
|
||||
return Text::propertyDefault(id);
|
||||
return TextBase::propertyDefault(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ struct ChannelActions {
|
|||
// @@ StaffText
|
||||
//---------------------------------------------------------
|
||||
|
||||
class StaffText : public Text {
|
||||
class StaffText : public TextBase {
|
||||
QString _channelNames[4];
|
||||
QList<ChannelActions> _channelActions;
|
||||
SwingParameters _swingParameters;
|
||||
|
|
|
@ -1042,6 +1042,7 @@ const std::vector<StyledProperty> rehearsalMarkStyle {
|
|||
{ StyleIdx::rehearsalMarkFrameRound, P_ID::FRAME_ROUND },
|
||||
{ StyleIdx::rehearsalMarkFrameFgColor, P_ID::FRAME_FG_COLOR },
|
||||
{ StyleIdx::rehearsalMarkFrameBgColor, P_ID::FRAME_BG_COLOR },
|
||||
{ StyleIdx::rehearsalMarkPlacement, P_ID::PLACEMENT },
|
||||
};
|
||||
|
||||
const std::vector<StyledProperty> repeatLeftStyle {
|
||||
|
|
|
@ -19,14 +19,16 @@ namespace Ms {
|
|||
//---------------------------------------------------------
|
||||
|
||||
SystemText::SystemText(Score* s)
|
||||
: StaffText(SubStyle::SYSTEM, s)
|
||||
: TextBase(s)
|
||||
{
|
||||
init(SubStyle::SYSTEM);
|
||||
setSystemFlag(true);
|
||||
}
|
||||
|
||||
SystemText::SystemText(SubStyle ss, Score* s)
|
||||
: StaffText(ss, s)
|
||||
: TextBase(s)
|
||||
{
|
||||
init(ss);
|
||||
setSystemFlag(true);
|
||||
}
|
||||
|
||||
|
@ -40,7 +42,7 @@ QVariant SystemText::propertyDefault(P_ID id) const
|
|||
case P_ID::SUB_STYLE:
|
||||
return int(SubStyle::SYSTEM);
|
||||
default:
|
||||
return StaffText::propertyDefault(id);
|
||||
return TextBase::propertyDefault(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +55,7 @@ void SystemText::write(XmlWriter& xml) const
|
|||
if (!xml.canWrite(this))
|
||||
return;
|
||||
xml.stag(name());
|
||||
StaffText::writeProperties(xml);
|
||||
TextBase::writeProperties(xml);
|
||||
xml.etag();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Ms {
|
|||
// SystemText
|
||||
//---------------------------------------------------------
|
||||
|
||||
class SystemText : public StaffText {
|
||||
class SystemText : public TextBase {
|
||||
public:
|
||||
SystemText(Score* score);
|
||||
SystemText(SubStyle, Score* = 0);
|
||||
|
|
|
@ -28,8 +28,9 @@ namespace Ms {
|
|||
//---------------------------------------------------------
|
||||
|
||||
TempoText::TempoText(Score* s)
|
||||
: Text(SubStyle::TEMPO, s)
|
||||
: TextBase(s)
|
||||
{
|
||||
init(SubStyle::TEMPO);
|
||||
_tempo = 2.0; // propertyDefault(P_TEMPO).toDouble();
|
||||
_followText = false;
|
||||
_relative = 1.0;
|
||||
|
@ -47,7 +48,7 @@ void TempoText::write(XmlWriter& xml) const
|
|||
xml.tag("tempo", _tempo);
|
||||
if (_followText)
|
||||
xml.tag("followText", _followText);
|
||||
Text::writeProperties(xml);
|
||||
TextBase::writeProperties(xml);
|
||||
xml.etag();
|
||||
}
|
||||
|
||||
|
@ -63,7 +64,7 @@ void TempoText::read(XmlReader& e)
|
|||
setTempo(e.readDouble());
|
||||
else if (tag == "followText")
|
||||
_followText = e.readInt();
|
||||
else if (!Text::readProperties(e))
|
||||
else if (!TextBase::readProperties(e))
|
||||
e.unknown();
|
||||
}
|
||||
// check sanity
|
||||
|
@ -291,7 +292,7 @@ QVariant TempoText::getProperty(P_ID propertyId) const
|
|||
case P_ID::TEMPO_FOLLOW_TEXT:
|
||||
return _followText;
|
||||
default:
|
||||
return Text::getProperty(propertyId);
|
||||
return TextBase::getProperty(propertyId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,7 +312,7 @@ bool TempoText::setProperty(P_ID propertyId, const QVariant& v)
|
|||
_followText = v.toBool();
|
||||
break;
|
||||
default:
|
||||
if (!Text::setProperty(propertyId, v))
|
||||
if (!TextBase::setProperty(propertyId, v))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
@ -335,7 +336,7 @@ QVariant TempoText::propertyDefault(P_ID id) const
|
|||
case P_ID::PLACEMENT:
|
||||
return int(Element::Placement::ABOVE);
|
||||
default:
|
||||
return Text::propertyDefault(id);
|
||||
return TextBase::propertyDefault(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,7 +358,7 @@ void TempoText::layout()
|
|||
y = score()->styleP(StyleIdx::tempoPosBelow) + sh + lineSpacing();
|
||||
}
|
||||
setPos(QPointF(0.0, y));
|
||||
Text::layout1();
|
||||
TextBase::layout1();
|
||||
|
||||
// tempo text on first chordrest of measure should align over time sig if present
|
||||
//
|
||||
|
@ -445,7 +446,7 @@ QString TempoText::accessibleInfo() const
|
|||
return QString("%1: %2 %3 = %4").arg(Element::accessibleInfo()).arg(dots1).arg(QObject::tr("note")).arg(secondPart);
|
||||
}
|
||||
else
|
||||
return Text::accessibleInfo();
|
||||
return TextBase::accessibleInfo();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Ms {
|
|||
// @P followText bool determine tempo from text
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
class TempoText final : public Text {
|
||||
class TempoText final : public TextBase {
|
||||
qreal _tempo; // beats per second
|
||||
bool _followText; // parse text to determine tempo
|
||||
qreal _relative;
|
||||
|
|
|
@ -492,7 +492,7 @@ bool TextFragment::operator ==(const TextFragment& f) const
|
|||
// draw
|
||||
//---------------------------------------------------------
|
||||
|
||||
void TextFragment::draw(QPainter* p, const Text* t) const
|
||||
void TextFragment::draw(QPainter* p, const TextBase* t) const
|
||||
{
|
||||
QFont f(font(t));
|
||||
f.setPointSizeF(f.pointSizeF() * MScore::pixelRatio);
|
||||
|
@ -504,7 +504,7 @@ void TextFragment::draw(QPainter* p, const Text* t) const
|
|||
// font
|
||||
//---------------------------------------------------------
|
||||
|
||||
QFont TextFragment::font(const Text* t) const
|
||||
QFont TextFragment::font(const TextBase* t) const
|
||||
{
|
||||
QFont font;
|
||||
|
||||
|
@ -564,7 +564,7 @@ QFont TextFragment::font(const Text* t) const
|
|||
// draw
|
||||
//---------------------------------------------------------
|
||||
|
||||
void TextBlock::draw(QPainter* p, const Text* t) const
|
||||
void TextBlock::draw(QPainter* p, const TextBase* t) const
|
||||
{
|
||||
p->translate(0.0, _y);
|
||||
for (const TextFragment& f : _fragments)
|
||||
|
@ -576,7 +576,7 @@ void TextBlock::draw(QPainter* p, const Text* t) const
|
|||
// layout
|
||||
//---------------------------------------------------------
|
||||
|
||||
void TextBlock::layout(Text* t)
|
||||
void TextBlock::layout(TextBase* t)
|
||||
{
|
||||
_bbox = QRectF();
|
||||
qreal x = 0.0;
|
||||
|
@ -654,7 +654,7 @@ void TextBlock::layout(Text* t)
|
|||
// xpos
|
||||
//---------------------------------------------------------
|
||||
|
||||
qreal TextBlock::xpos(int column, const Text* t) const
|
||||
qreal TextBlock::xpos(int column, const TextBase* t) const
|
||||
{
|
||||
int col = 0;
|
||||
for (const TextFragment& f : _fragments) {
|
||||
|
@ -714,7 +714,7 @@ const CharFormat* TextBlock::formatAt(int column) const
|
|||
// boundingRect
|
||||
//---------------------------------------------------------
|
||||
|
||||
QRectF TextBlock::boundingRect(int col1, int col2, const Text* t) const
|
||||
QRectF TextBlock::boundingRect(int col1, int col2, const TextBase* t) const
|
||||
{
|
||||
qreal x1 = xpos(col1, t);
|
||||
qreal x2 = xpos(col2, t);
|
||||
|
@ -743,7 +743,7 @@ int TextBlock::columns() const
|
|||
// Text coordinate system
|
||||
//---------------------------------------------------------
|
||||
|
||||
int TextBlock::column(qreal x, Text* t) const
|
||||
int TextBlock::column(qreal x, TextBase* t) const
|
||||
{
|
||||
int col = 0;
|
||||
for (const TextFragment& f : _fragments) {
|
||||
|
@ -1074,15 +1074,7 @@ QString TextBlock::text(int col1, int len) const
|
|||
// Text
|
||||
//---------------------------------------------------------
|
||||
|
||||
Text::Text(Score* s)
|
||||
: Element(s)
|
||||
{
|
||||
_size = 10.0;
|
||||
initSubStyle(SubStyle::DEFAULT); // we assume all properties are set
|
||||
setFlag(ElementFlag::MOVABLE, true);
|
||||
}
|
||||
|
||||
Text::Text(SubStyle st, Score* s)
|
||||
TextBase::TextBase(Score* s)
|
||||
: Element(s)
|
||||
{
|
||||
_family = "FreeSerif";
|
||||
|
@ -1102,18 +1094,16 @@ Text::Text(SubStyle st, Score* s)
|
|||
_frameRound = 0;
|
||||
_offset = QPointF();
|
||||
_offsetType = OffsetType::SPATIUM;
|
||||
initSubStyle(st);
|
||||
setFlag(ElementFlag::MOVABLE, true);
|
||||
}
|
||||
|
||||
Text::Text(const Text& st)
|
||||
TextBase::TextBase(const TextBase& st)
|
||||
: Element(st)
|
||||
{
|
||||
_text = st._text;
|
||||
_layout = st._layout;
|
||||
textInvalid = st.textInvalid;
|
||||
layoutInvalid = st.layoutInvalid;
|
||||
|
||||
frame = st.frame;
|
||||
_subStyle = st._subStyle;
|
||||
_layoutToParentWidth = st._layoutToParentWidth;
|
||||
|
@ -1154,15 +1144,20 @@ Text::Text(const Text& st)
|
|||
_offsetTypeStyle = st._offsetTypeStyle;
|
||||
}
|
||||
|
||||
Text::~Text()
|
||||
//---------------------------------------------------------
|
||||
// init
|
||||
//---------------------------------------------------------
|
||||
|
||||
void TextBase::init(SubStyle st)
|
||||
{
|
||||
initSubStyle(st);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// drawSelection
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::drawSelection(QPainter* p, const QRectF& r) const
|
||||
void TextBase::drawSelection(QPainter* p, const QRectF& r) const
|
||||
{
|
||||
QBrush bg(QColor("steelblue"));
|
||||
p->setCompositionMode(QPainter::CompositionMode_HardLight);
|
||||
|
@ -1177,7 +1172,7 @@ void Text::drawSelection(QPainter* p, const QRectF& r) const
|
|||
// textColor
|
||||
//---------------------------------------------------------
|
||||
|
||||
QColor Text::textColor() const
|
||||
QColor TextBase::textColor() const
|
||||
{
|
||||
return curColor();
|
||||
}
|
||||
|
@ -1187,7 +1182,7 @@ QColor Text::textColor() const
|
|||
// insert character
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::insert(TextCursor* cursor, uint code)
|
||||
void TextBase::insert(TextCursor* cursor, uint code)
|
||||
{
|
||||
if (cursor->row() >= rows())
|
||||
_layout.append(TextBlock());
|
||||
|
@ -1234,7 +1229,7 @@ static qreal parseNumProperty(const QString& s)
|
|||
// create layout from text
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::createLayout()
|
||||
void TextBase::createLayout()
|
||||
{
|
||||
_layout.clear();
|
||||
TextCursor cursor((Text*)this);
|
||||
|
@ -1394,7 +1389,7 @@ void Text::createLayout()
|
|||
// layout
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::layout()
|
||||
void TextBase::layout()
|
||||
{
|
||||
QPointF o(_offset * (_offsetType == OffsetType::SPATIUM ? spatium() : DPI));
|
||||
|
||||
|
@ -1407,7 +1402,7 @@ void Text::layout()
|
|||
// layout1
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::layout1()
|
||||
void TextBase::layout1()
|
||||
{
|
||||
if (layoutInvalid)
|
||||
createLayout();
|
||||
|
@ -1484,7 +1479,7 @@ void Text::layout1()
|
|||
// layoutFrame
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::layoutFrame()
|
||||
void TextBase::layoutFrame()
|
||||
{
|
||||
frame = bbox();
|
||||
if (square()) {
|
||||
|
@ -1527,7 +1522,7 @@ void Text::layoutFrame()
|
|||
// lineSpacing
|
||||
//---------------------------------------------------------
|
||||
|
||||
qreal Text::lineSpacing() const
|
||||
qreal TextBase::lineSpacing() const
|
||||
{
|
||||
return fontMetrics().lineSpacing() * MScore::pixelRatio;
|
||||
}
|
||||
|
@ -1536,7 +1531,7 @@ qreal Text::lineSpacing() const
|
|||
// lineHeight
|
||||
//---------------------------------------------------------
|
||||
|
||||
qreal Text::lineHeight() const
|
||||
qreal TextBase::lineHeight() const
|
||||
{
|
||||
return fontMetrics().height();
|
||||
}
|
||||
|
@ -1545,7 +1540,7 @@ qreal Text::lineHeight() const
|
|||
// baseLine
|
||||
//---------------------------------------------------------
|
||||
|
||||
qreal Text::baseLine() const
|
||||
qreal TextBase::baseLine() const
|
||||
{
|
||||
return fontMetrics().ascent();
|
||||
}
|
||||
|
@ -1596,7 +1591,7 @@ class XmlNesting : public QStack<QString> {
|
|||
// genText
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::genText()
|
||||
void TextBase::genText()
|
||||
{
|
||||
_text.clear();
|
||||
bool _bold = false;
|
||||
|
@ -1657,7 +1652,7 @@ void Text::genText()
|
|||
if (format.fontSize() != fmt.fontSize())
|
||||
_text += QString("<font size=\"%1\"/>").arg(format.fontSize());
|
||||
if (format.fontFamily() != fmt.fontFamily())
|
||||
_text += QString("<font face=\"%1\"/>").arg(Text::escape(format.fontFamily()));
|
||||
_text += QString("<font face=\"%1\"/>").arg(TextBase::escape(format.fontFamily()));
|
||||
|
||||
VerticalAlignment va = format.valign();
|
||||
VerticalAlignment cva = fmt.valign();
|
||||
|
@ -1689,7 +1684,7 @@ void Text::genText()
|
|||
// startEdit
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::startEdit(EditData& ed)
|
||||
void TextBase::startEdit(EditData& ed)
|
||||
{
|
||||
ed.grips = 0;
|
||||
TextEditData* ted = new TextEditData();
|
||||
|
@ -1712,7 +1707,7 @@ void Text::startEdit(EditData& ed)
|
|||
// endEdit
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::endEdit(EditData&)
|
||||
void TextBase::endEdit(EditData&)
|
||||
{
|
||||
static const qreal w = 2.0;
|
||||
score()->addRefresh(canvasBoundingRect().adjusted(-w, -w, w, w));
|
||||
|
@ -1722,7 +1717,7 @@ void Text::endEdit(EditData&)
|
|||
// editInsertText
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::editInsertText(TextCursor* cursor, const QString& s)
|
||||
void TextBase::editInsertText(TextCursor* cursor, const QString& s)
|
||||
{
|
||||
textInvalid = true;
|
||||
|
||||
|
@ -1747,7 +1742,7 @@ void Text::editInsertText(TextCursor* cursor, const QString& s)
|
|||
// endHexState
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::endHexState()
|
||||
void TextBase::endHexState()
|
||||
{
|
||||
#if 0
|
||||
if (hexState >= 0) {
|
||||
|
@ -1776,7 +1771,7 @@ void Text::endHexState()
|
|||
// selectAll
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::selectAll(TextCursor* _cursor)
|
||||
void TextBase::selectAll(TextCursor* _cursor)
|
||||
{
|
||||
_cursor->setSelectLine(0);
|
||||
_cursor->setSelectColumn(0);
|
||||
|
@ -1788,7 +1783,7 @@ void Text::selectAll(TextCursor* _cursor)
|
|||
// deleteSelectedText
|
||||
//---------------------------------------------------------
|
||||
|
||||
bool Text::deleteSelectedText(EditData& ed)
|
||||
bool TextBase::deleteSelectedText(EditData& ed)
|
||||
{
|
||||
TextCursor* _cursor = cursor(ed);
|
||||
if (!_cursor->hasSelection())
|
||||
|
@ -1808,7 +1803,7 @@ bool Text::deleteSelectedText(EditData& ed)
|
|||
if (c1 > c2)
|
||||
qSwap(c1, c2);
|
||||
}
|
||||
int rows = Text::rows();
|
||||
int rows = TextBase::rows();
|
||||
|
||||
for (int row = 0; row < rows; ++row) {
|
||||
TextBlock& t = _layout[row];
|
||||
|
@ -1841,7 +1836,7 @@ bool Text::deleteSelectedText(EditData& ed)
|
|||
// write
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::write(XmlWriter& xml) const
|
||||
void TextBase::write(XmlWriter& xml) const
|
||||
{
|
||||
xml.stag(name());
|
||||
writeProperties(xml, true, true);
|
||||
|
@ -1852,7 +1847,7 @@ void Text::write(XmlWriter& xml) const
|
|||
// read
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::read(XmlReader& e)
|
||||
void TextBase::read(XmlReader& e)
|
||||
{
|
||||
while (e.readNextStartElement()) {
|
||||
if (!readProperties(e))
|
||||
|
@ -1885,7 +1880,7 @@ static const std::array<P_ID, 18> pids { {
|
|||
// writeProperties
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::writeProperties(XmlWriter& xml, bool writeText, bool /*writeStyle*/) const
|
||||
void TextBase::writeProperties(XmlWriter& xml, bool writeText, bool /*writeStyle*/) const
|
||||
{
|
||||
Element::writeProperties(xml);
|
||||
for (P_ID i :pids)
|
||||
|
@ -1898,7 +1893,7 @@ void Text::writeProperties(XmlWriter& xml, bool writeText, bool /*writeStyle*/)
|
|||
// readProperties
|
||||
//---------------------------------------------------------
|
||||
|
||||
bool Text::readProperties(XmlReader& e)
|
||||
bool TextBase::readProperties(XmlReader& e)
|
||||
{
|
||||
const QStringRef& tag(e.name());
|
||||
|
||||
|
@ -1926,7 +1921,7 @@ bool Text::readProperties(XmlReader& e)
|
|||
// insert text at cursor position and move cursor
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::insertText(EditData& ed, const QString& s)
|
||||
void TextBase::insertText(EditData& ed, const QString& s)
|
||||
{
|
||||
TextCursor* _cursor = cursor(ed);
|
||||
deleteSelectedText(ed);
|
||||
|
@ -1939,7 +1934,7 @@ void Text::insertText(EditData& ed, const QString& s)
|
|||
// insertSym
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::insertSym(EditData& ed, SymId id)
|
||||
void TextBase::insertSym(EditData& ed, SymId id)
|
||||
{
|
||||
deleteSelectedText(ed);
|
||||
QString s = score()->scoreFont()->toString(id);
|
||||
|
@ -1950,7 +1945,7 @@ void Text::insertSym(EditData& ed, SymId id)
|
|||
// pageRectangle
|
||||
//---------------------------------------------------------
|
||||
|
||||
QRectF Text::pageRectangle() const
|
||||
QRectF TextBase::pageRectangle() const
|
||||
{
|
||||
if (parent() && (parent()->isHBox() || parent()->isVBox() || parent()->isTBox())) {
|
||||
Box* box = toBox(parent());
|
||||
|
@ -1981,7 +1976,7 @@ QRectF Text::pageRectangle() const
|
|||
// dragTo
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::dragTo(EditData& ed)
|
||||
void TextBase::dragTo(EditData& ed)
|
||||
{
|
||||
TextEditData* ted = static_cast<TextEditData*>(ed.getData(this));
|
||||
TextCursor* _cursor = ted->cursor;
|
||||
|
@ -1994,7 +1989,7 @@ void Text::dragTo(EditData& ed)
|
|||
// dragAnchor
|
||||
//---------------------------------------------------------
|
||||
|
||||
QLineF Text::dragAnchor() const
|
||||
QLineF TextBase::dragAnchor() const
|
||||
{
|
||||
qreal xp = 0.0;
|
||||
for (Element* e = parent(); e; e = e->parent())
|
||||
|
@ -2017,14 +2012,14 @@ QLineF Text::dragAnchor() const
|
|||
// paste
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::paste(EditData& ed)
|
||||
void TextBase::paste(EditData& ed)
|
||||
{
|
||||
TextEditData* ted = static_cast<TextEditData*>(ed.getData(this));
|
||||
TextCursor* _cursor = ted->cursor;
|
||||
|
||||
QString txt = QApplication::clipboard()->text(QClipboard::Clipboard);
|
||||
if (MScore::debugMode)
|
||||
qDebug("Text::paste() <%s>", qPrintable(txt));
|
||||
qDebug("<%s>", qPrintable(txt));
|
||||
|
||||
int state = 0;
|
||||
QString token;
|
||||
|
@ -2115,7 +2110,7 @@ void Text::paste(EditData& ed)
|
|||
// set text cursor
|
||||
//---------------------------------------------------------
|
||||
|
||||
bool Text::mousePress(EditData& ed)
|
||||
bool TextBase::mousePress(EditData& ed)
|
||||
{
|
||||
bool shift = ed.modifiers & Qt::ShiftModifier;
|
||||
TextEditData* ted = static_cast<TextEditData*>(ed.getData(this));
|
||||
|
@ -2131,7 +2126,7 @@ bool Text::mousePress(EditData& ed)
|
|||
// layoutEdit
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::layoutEdit()
|
||||
void TextBase::layoutEdit()
|
||||
{
|
||||
layout();
|
||||
if (parent() && parent()->type() == ElementType::TBOX) {
|
||||
|
@ -2151,7 +2146,7 @@ void Text::layoutEdit()
|
|||
// acceptDrop
|
||||
//---------------------------------------------------------
|
||||
|
||||
bool Text::acceptDrop(EditData& data) const
|
||||
bool TextBase::acceptDrop(EditData& data) const
|
||||
{
|
||||
ElementType type = data.element->type();
|
||||
return type == ElementType::SYMBOL || type == ElementType::FSYMBOL;
|
||||
|
@ -2161,7 +2156,7 @@ bool Text::acceptDrop(EditData& data) const
|
|||
// drop
|
||||
//---------------------------------------------------------
|
||||
|
||||
Element* Text::drop(EditData& ed)
|
||||
Element* TextBase::drop(EditData& ed)
|
||||
{
|
||||
TextCursor* _cursor = cursor(ed);
|
||||
|
||||
|
@ -2197,7 +2192,7 @@ Element* Text::drop(EditData& ed)
|
|||
// setPlainText
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::setPlainText(const QString& s)
|
||||
void TextBase::setPlainText(const QString& s)
|
||||
{
|
||||
setXmlText(s.toHtmlEscaped());
|
||||
}
|
||||
|
@ -2206,7 +2201,7 @@ void Text::setPlainText(const QString& s)
|
|||
// setXmlText
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::setXmlText(const QString& s)
|
||||
void TextBase::setXmlText(const QString& s)
|
||||
{
|
||||
_text = s;
|
||||
layoutInvalid = true;
|
||||
|
@ -2219,7 +2214,7 @@ void Text::setXmlText(const QString& s)
|
|||
// return plain text with symbols
|
||||
//---------------------------------------------------------
|
||||
|
||||
QString Text::plainText() const
|
||||
QString TextBase::plainText() const
|
||||
{
|
||||
QString s;
|
||||
|
||||
|
@ -2239,7 +2234,7 @@ QString Text::plainText() const
|
|||
// xmlText
|
||||
//---------------------------------------------------------
|
||||
|
||||
QString Text::xmlText() const
|
||||
QString TextBase::xmlText() const
|
||||
{
|
||||
if (textInvalid)
|
||||
((Text*)(this))->genText(); // ugh!
|
||||
|
@ -2250,7 +2245,7 @@ QString Text::xmlText() const
|
|||
// convertFromHtml
|
||||
//---------------------------------------------------------
|
||||
|
||||
QString Text::convertFromHtml(const QString& ss) const
|
||||
QString TextBase::convertFromHtml(const QString& ss) const
|
||||
{
|
||||
QTextDocument doc;
|
||||
doc.setHtml(ss);
|
||||
|
@ -2319,7 +2314,7 @@ QString Text::convertFromHtml(const QString& ss) const
|
|||
// convert from internal html format to Qt
|
||||
//---------------------------------------------------------
|
||||
|
||||
QString Text::convertToHtml(const QString& s, const TextStyle& /*st*/)
|
||||
QString TextBase::convertToHtml(const QString& s, const TextStyle& /*st*/)
|
||||
{
|
||||
//TODO qreal size = st.size();
|
||||
// QString family = st.family();
|
||||
|
@ -2332,7 +2327,7 @@ QString Text::convertToHtml(const QString& s, const TextStyle& /*st*/)
|
|||
// tagEscape
|
||||
//---------------------------------------------------------
|
||||
|
||||
QString Text::tagEscape(QString s)
|
||||
QString TextBase::tagEscape(QString s)
|
||||
{
|
||||
QStringList tags = { "sym", "b", "i", "u", "sub", "sup" };
|
||||
for (QString tag : tags) {
|
||||
|
@ -2359,7 +2354,7 @@ QString Text::tagEscape(QString s)
|
|||
// unEscape
|
||||
//---------------------------------------------------------
|
||||
|
||||
QString Text::unEscape(QString s)
|
||||
QString TextBase::unEscape(QString s)
|
||||
{
|
||||
s.replace("<", "<");
|
||||
s.replace(">", ">");
|
||||
|
@ -2372,7 +2367,7 @@ QString Text::unEscape(QString s)
|
|||
// escape
|
||||
//---------------------------------------------------------
|
||||
|
||||
QString Text::escape(QString s)
|
||||
QString TextBase::escape(QString s)
|
||||
{
|
||||
s.replace("<", "<");
|
||||
s.replace(">", ">");
|
||||
|
@ -2385,7 +2380,7 @@ QString Text::escape(QString s)
|
|||
// accessibleInfo
|
||||
//---------------------------------------------------------
|
||||
|
||||
QString Text::accessibleInfo() const
|
||||
QString TextBase::accessibleInfo() const
|
||||
{
|
||||
QString rez;
|
||||
switch (subStyle()) {
|
||||
|
@ -2413,7 +2408,7 @@ QString Text::accessibleInfo() const
|
|||
// screenReaderInfo
|
||||
//---------------------------------------------------------
|
||||
|
||||
QString Text::screenReaderInfo() const
|
||||
QString TextBase::screenReaderInfo() const
|
||||
{
|
||||
QString rez;
|
||||
switch (subStyle()) {
|
||||
|
@ -2437,7 +2432,7 @@ QString Text::screenReaderInfo() const
|
|||
// subtype
|
||||
//---------------------------------------------------------
|
||||
|
||||
int Text::subtype() const
|
||||
int TextBase::subtype() const
|
||||
{
|
||||
switch (subStyle()) {
|
||||
case SubStyle::TITLE:
|
||||
|
@ -2455,7 +2450,7 @@ int Text::subtype() const
|
|||
// subtypeName
|
||||
//---------------------------------------------------------
|
||||
|
||||
QString Text::subtypeName() const
|
||||
QString TextBase::subtypeName() const
|
||||
{
|
||||
QString rez;
|
||||
switch (subStyle()) {
|
||||
|
@ -2481,7 +2476,7 @@ QString Text::subtypeName() const
|
|||
Used by the MusicXML formatted export to avoid parsing the xml text format
|
||||
*/
|
||||
|
||||
QList<TextFragment> Text::fragmentList() const
|
||||
QList<TextFragment> TextBase::fragmentList() const
|
||||
{
|
||||
QList<TextFragment> res;
|
||||
for (const TextBlock& block : _layout) {
|
||||
|
@ -2508,7 +2503,7 @@ QList<TextFragment> Text::fragmentList() const
|
|||
// (this is incomplete/experimental)
|
||||
//---------------------------------------------------------
|
||||
|
||||
bool Text::validateText(QString& s)
|
||||
bool TextBase::validateText(QString& s)
|
||||
{
|
||||
QString d;
|
||||
for (int i = 0; i < s.size(); ++i) {
|
||||
|
@ -2568,7 +2563,7 @@ bool Text::validateText(QString& s)
|
|||
// inputTransition
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::inputTransition(QInputMethodEvent* ie)
|
||||
void TextBase::inputTransition(QInputMethodEvent* ie)
|
||||
{
|
||||
#if 0
|
||||
// remove preedit string
|
||||
|
@ -2578,7 +2573,7 @@ void Text::inputTransition(QInputMethodEvent* ie)
|
|||
_cursor->deleteChar();
|
||||
}
|
||||
|
||||
qDebug("Text::inputTransition <%s><%s> len %d start %d, preEdit size %d",
|
||||
qDebug("TextBase::inputTransition <%s><%s> len %d start %d, preEdit size %d",
|
||||
qPrintable(ie->commitString()),
|
||||
qPrintable(ie->preeditString()),
|
||||
ie->replacementLength(), ie->replacementStart(), preEdit.size());
|
||||
|
@ -2621,7 +2616,7 @@ void Text::inputTransition(QInputMethodEvent* ie)
|
|||
// font
|
||||
//---------------------------------------------------------
|
||||
|
||||
QFont Text::font() const
|
||||
QFont TextBase::font() const
|
||||
{
|
||||
qreal m = _size;
|
||||
if (_sizeIsSpatiumDependent)
|
||||
|
@ -2636,7 +2631,7 @@ QFont Text::font() const
|
|||
// fontMetrics
|
||||
//---------------------------------------------------------
|
||||
|
||||
QFontMetricsF Text::fontMetrics() const
|
||||
QFontMetricsF TextBase::fontMetrics() const
|
||||
{
|
||||
return QFontMetricsF(font());
|
||||
}
|
||||
|
@ -2645,7 +2640,7 @@ QFontMetricsF Text::fontMetrics() const
|
|||
// initSubStyle
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::initSubStyle(SubStyle s)
|
||||
void TextBase::initSubStyle(SubStyle s)
|
||||
{
|
||||
_subStyle = s;
|
||||
Element::initSubStyle(s);
|
||||
|
@ -2655,7 +2650,7 @@ void Text::initSubStyle(SubStyle s)
|
|||
// getProperty
|
||||
//---------------------------------------------------------
|
||||
|
||||
QVariant Text::getProperty(P_ID propertyId) const
|
||||
QVariant TextBase::getProperty(P_ID propertyId) const
|
||||
{
|
||||
switch (propertyId) {
|
||||
case P_ID::FONT_FACE:
|
||||
|
@ -2705,7 +2700,7 @@ QVariant Text::getProperty(P_ID propertyId) const
|
|||
// setProperty
|
||||
//---------------------------------------------------------
|
||||
|
||||
bool Text::setProperty(P_ID propertyId, const QVariant& v)
|
||||
bool TextBase::setProperty(P_ID propertyId, const QVariant& v)
|
||||
{
|
||||
score()->addRefresh(canvasBoundingRect());
|
||||
bool rv = true;
|
||||
|
@ -2780,7 +2775,7 @@ bool Text::setProperty(P_ID propertyId, const QVariant& v)
|
|||
// propertyDefault
|
||||
//---------------------------------------------------------
|
||||
|
||||
QVariant Text::propertyDefault(P_ID id) const
|
||||
QVariant TextBase::propertyDefault(P_ID id) const
|
||||
{
|
||||
for (const StyledProperty& p : Ms::subStyle(_subStyle)) {
|
||||
if (p.propertyIdx == id)
|
||||
|
@ -2809,7 +2804,7 @@ QVariant Text::propertyDefault(P_ID id) const
|
|||
//---------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
void Text::resetProperty(P_ID id)
|
||||
void TextBase::resetProperty(P_ID id)
|
||||
{
|
||||
PropertyFlags* p = propertyFlagsP(id);
|
||||
if (p) {
|
||||
|
@ -2825,7 +2820,7 @@ void Text::resetProperty(P_ID id)
|
|||
// reset
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::reset()
|
||||
void TextBase::reset()
|
||||
{
|
||||
for (const StyledProperty& p : Ms::subStyle(_subStyle))
|
||||
undoResetProperty(p.propertyIdx);
|
||||
|
@ -2836,7 +2831,7 @@ void Text::reset()
|
|||
// getPropertyStyle
|
||||
//---------------------------------------------------------
|
||||
|
||||
StyleIdx Text::getPropertyStyle(P_ID id) const
|
||||
StyleIdx TextBase::getPropertyStyle(P_ID id) const
|
||||
{
|
||||
for (auto sp : Ms::subStyle(_subStyle)) {
|
||||
if (sp.propertyIdx == id)
|
||||
|
@ -2849,7 +2844,7 @@ StyleIdx Text::getPropertyStyle(P_ID id) const
|
|||
// styleChanged
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::styleChanged()
|
||||
void TextBase::styleChanged()
|
||||
{
|
||||
for (const StyledProperty& p : Ms::subStyle(_subStyle)) {
|
||||
if (propertyFlags(p.propertyIdx) == PropertyFlags::STYLED)
|
||||
|
@ -2863,7 +2858,7 @@ void Text::styleChanged()
|
|||
// setPropertyFlags
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::setPropertyFlags(P_ID id, PropertyFlags f)
|
||||
void TextBase::setPropertyFlags(P_ID id, PropertyFlags f)
|
||||
{
|
||||
PropertyFlags* p = propertyFlagsP(id);
|
||||
if (p)
|
||||
|
@ -2877,7 +2872,7 @@ void Text::setPropertyFlags(P_ID id, PropertyFlags f)
|
|||
// propertyFlags
|
||||
//---------------------------------------------------------
|
||||
|
||||
PropertyFlags& Text::propertyFlags(P_ID id)
|
||||
PropertyFlags& TextBase::propertyFlags(P_ID id)
|
||||
{
|
||||
switch (id) {
|
||||
case P_ID::FONT_FACE:
|
||||
|
@ -2921,7 +2916,7 @@ PropertyFlags& Text::propertyFlags(P_ID id)
|
|||
// editCut
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::editCut(EditData& ed)
|
||||
void TextBase::editCut(EditData& ed)
|
||||
{
|
||||
TextEditData* ted = static_cast<TextEditData*>(ed.getData(this));
|
||||
TextCursor* _cursor = ted->cursor;
|
||||
|
@ -2940,7 +2935,7 @@ void Text::editCut(EditData& ed)
|
|||
// editCopy
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::editCopy(EditData& ed)
|
||||
void TextBase::editCopy(EditData& ed)
|
||||
{
|
||||
//
|
||||
// store selection as plain text
|
||||
|
@ -2956,7 +2951,7 @@ void Text::editCopy(EditData& ed)
|
|||
// cursor
|
||||
//---------------------------------------------------------
|
||||
|
||||
TextCursor* Text::cursor(EditData& ed)
|
||||
TextCursor* TextBase::cursor(EditData& ed)
|
||||
{
|
||||
TextEditData* ted = static_cast<TextEditData*>(ed.getData(this));
|
||||
return ted->cursor;
|
||||
|
@ -2966,7 +2961,7 @@ TextCursor* Text::cursor(EditData& ed)
|
|||
// draw
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::draw(QPainter* p) const
|
||||
void TextBase::draw(QPainter* p) const
|
||||
{
|
||||
if (hasFrame()) {
|
||||
if (frameWidth().val() != 0.0) {
|
||||
|
@ -2999,7 +2994,7 @@ void Text::draw(QPainter* p) const
|
|||
// draw edit mode decorations
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Text::drawEditMode(QPainter* p, EditData& ed)
|
||||
void TextBase::drawEditMode(QPainter* p, EditData& ed)
|
||||
{
|
||||
QPointF pos(canvasPos());
|
||||
p->translate(pos);
|
||||
|
@ -3095,7 +3090,7 @@ bool TextCursor::deleteChar() const
|
|||
// edit
|
||||
//---------------------------------------------------------
|
||||
|
||||
bool Text::edit(EditData& ed)
|
||||
bool TextBase::edit(EditData& ed)
|
||||
{
|
||||
TextEditData* ted = static_cast<TextEditData*>(ed.getData(this));
|
||||
TextCursor* _cursor = ted->cursor;
|
||||
|
@ -3281,5 +3276,18 @@ bool Text::edit(EditData& ed)
|
|||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Text
|
||||
//---------------------------------------------------------
|
||||
|
||||
Text::Text(Score* s) : TextBase(s)
|
||||
{
|
||||
init(SubStyle::DEFAULT);
|
||||
}
|
||||
|
||||
Text::Text(SubStyle ss, Score* s) : TextBase(s)
|
||||
{
|
||||
init(ss);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,12 +16,13 @@
|
|||
#include "element.h"
|
||||
#include "elementlayout.h"
|
||||
#include "property.h"
|
||||
#include "style.h"
|
||||
|
||||
namespace Ms {
|
||||
|
||||
class MuseScoreView;
|
||||
struct SymCode;
|
||||
class Text;
|
||||
class TextBase;
|
||||
class TextBlock;
|
||||
class ChangeText;
|
||||
|
||||
|
@ -70,7 +71,7 @@ class CharFormat {
|
|||
//---------------------------------------------------------
|
||||
|
||||
class TextCursor {
|
||||
Text* _text;
|
||||
TextBase* _text;
|
||||
CharFormat _format;
|
||||
int _row { 0 };
|
||||
int _column { 0 };
|
||||
|
@ -78,9 +79,9 @@ class TextCursor {
|
|||
int _selectColumn { 0 };
|
||||
|
||||
public:
|
||||
TextCursor(Text* t) : _text(t) {}
|
||||
TextCursor(TextBase* t) : _text(t) {}
|
||||
|
||||
Text* text() const { return _text; }
|
||||
TextBase* text() const { return _text; }
|
||||
bool hasSelection() const { return (_selectLine != _row) || (_selectColumn != _column); }
|
||||
void clearSelection();
|
||||
|
||||
|
@ -96,7 +97,7 @@ class TextCursor {
|
|||
void setColumn(int val) { _column = val; }
|
||||
void setSelectLine(int val) { _selectLine = val; }
|
||||
void setSelectColumn(int val) { _selectColumn = val; }
|
||||
void setText(Text* t) { _text = t; }
|
||||
void setText(TextBase* t) { _text = t; }
|
||||
int columns() const;
|
||||
void init();
|
||||
|
||||
|
@ -114,8 +115,6 @@ class TextCursor {
|
|||
bool deleteChar() const;
|
||||
};
|
||||
|
||||
class Text;
|
||||
|
||||
//---------------------------------------------------------
|
||||
// TextFragment
|
||||
// contains a styled text
|
||||
|
@ -135,8 +134,8 @@ class TextFragment {
|
|||
TextFragment(const QString& s);
|
||||
TextFragment(TextCursor*, const QString&);
|
||||
TextFragment split(int column);
|
||||
void draw(QPainter*, const Text*) const;
|
||||
QFont font(const Text*) const;
|
||||
void draw(QPainter*, const TextBase*) const;
|
||||
QFont font(const TextBase*) const;
|
||||
int columns() const;
|
||||
void changeFormat(FormatId id, QVariant data);
|
||||
};
|
||||
|
@ -159,19 +158,19 @@ class TextBlock {
|
|||
TextBlock() {}
|
||||
bool operator ==(const TextBlock& x) { return _fragments == x._fragments; }
|
||||
bool operator !=(const TextBlock& x) { return _fragments != x._fragments; }
|
||||
void draw(QPainter*, const Text*) const;
|
||||
void layout(Text*);
|
||||
void draw(QPainter*, const TextBase*) const;
|
||||
void layout(TextBase*);
|
||||
const QList<TextFragment>& fragments() const { return _fragments; }
|
||||
QList<TextFragment>& fragments() { return _fragments; }
|
||||
const QRectF& boundingRect() const { return _bbox; }
|
||||
QRectF boundingRect(int col1, int col2, const Text*) const;
|
||||
QRectF boundingRect(int col1, int col2, const TextBase*) const;
|
||||
int columns() const;
|
||||
void insert(TextCursor*, const QString&);
|
||||
QString remove(int column);
|
||||
QString remove(int start, int n);
|
||||
int column(qreal x, Text*) const;
|
||||
int column(qreal x, TextBase*) const;
|
||||
TextBlock split(int column);
|
||||
qreal xpos(int col, const Text*) const;
|
||||
qreal xpos(int col, const TextBase*) const;
|
||||
const CharFormat* formatAt(int) const;
|
||||
const TextFragment* fragment(int col) const;
|
||||
QList<TextFragment>::iterator fragment(int column, int* rcol, int* ridx);
|
||||
|
@ -185,10 +184,10 @@ class TextBlock {
|
|||
};
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Text
|
||||
// TextBase
|
||||
//---------------------------------------------------------
|
||||
|
||||
class Text : public Element {
|
||||
class TextBase : public Element {
|
||||
M_PROPERTY(QString, family, setFamily)
|
||||
M_PROPERTY(qreal, size, setSize)
|
||||
M_PROPERTY(bool, bold, setBold)
|
||||
|
@ -236,17 +235,14 @@ class Text : public Element {
|
|||
void insertSym(EditData& ed, SymId id);
|
||||
|
||||
public:
|
||||
Text(Score* = 0);
|
||||
Text(SubStyle, Score* = 0);
|
||||
Text(const Text&);
|
||||
~Text();
|
||||
TextBase(Score* = 0);
|
||||
TextBase(const TextBase&);
|
||||
void init(SubStyle st = SubStyle::DEFAULT);
|
||||
|
||||
SubStyle subStyle() const { return _subStyle; }
|
||||
void setSubStyle(SubStyle ss) { _subStyle = ss; }
|
||||
virtual void initSubStyle(SubStyle) override;
|
||||
|
||||
virtual Text* clone() const override { return new Text(*this); }
|
||||
virtual ElementType type() const override { return ElementType::TEXT; }
|
||||
virtual bool mousePress(EditData&) override;
|
||||
|
||||
Text &operator=(const Text&) = delete;
|
||||
|
@ -333,9 +329,7 @@ class Text : public Element {
|
|||
virtual QVariant getProperty(P_ID propertyId) const override;
|
||||
virtual bool setProperty(P_ID propertyId, const QVariant& v) override;
|
||||
virtual QVariant propertyDefault(P_ID id) const override;
|
||||
// virtual void setPropertyFlags(P_ID, PropertyFlags) override;
|
||||
virtual PropertyFlags& propertyFlags(P_ID) override;
|
||||
// virtual void resetProperty(P_ID id) override;
|
||||
virtual StyleIdx getPropertyStyle(P_ID) const override;
|
||||
virtual void reset() override;
|
||||
|
||||
|
@ -352,7 +346,21 @@ class Text : public Element {
|
|||
friend class TextCursor;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Text
|
||||
//---------------------------------------------------------
|
||||
|
||||
class Text final : public TextBase {
|
||||
|
||||
public:
|
||||
Text(Score* s = 0);
|
||||
Text(SubStyle ss, Score* s = 0);
|
||||
|
||||
virtual ElementType type() const override { return ElementType::TEXT; }
|
||||
virtual Text* clone() const override { return new Text(*this); }
|
||||
};
|
||||
|
||||
} // namespace Ms
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -698,7 +698,7 @@ QVariant TextLineBase::propertyDefault(P_ID id) const
|
|||
case P_ID::BEGIN_FONT_SIZE:
|
||||
case P_ID::CONTINUE_FONT_SIZE:
|
||||
case P_ID::END_FONT_SIZE:
|
||||
return 10.0;
|
||||
return 12.0;
|
||||
case P_ID::BEGIN_FONT_BOLD:
|
||||
case P_ID::BEGIN_FONT_ITALIC:
|
||||
case P_ID::BEGIN_FONT_UNDERLINE:
|
||||
|
@ -716,7 +716,7 @@ QVariant TextLineBase::propertyDefault(P_ID id) const
|
|||
case P_ID::BEGIN_TEXT_ALIGN:
|
||||
case P_ID::CONTINUE_TEXT_ALIGN:
|
||||
case P_ID::END_TEXT_ALIGN:
|
||||
return QVariant::fromValue(Align::LEFT);
|
||||
return QVariant::fromValue(Align::VCENTER);
|
||||
case P_ID::LINE_VISIBLE:
|
||||
return true;
|
||||
default:
|
||||
|
|
|
@ -37,7 +37,6 @@ enum class ElementType {
|
|||
BAR_LINE,
|
||||
SYSTEM_DIVIDER,
|
||||
STEM_SLASH,
|
||||
LINE,
|
||||
ARPEGGIO,
|
||||
ACCIDENTAL,
|
||||
LEDGER_LINE,
|
||||
|
|
|
@ -2191,7 +2191,7 @@ void SplitText::undo(EditData* ed)
|
|||
void SplitText::redo(EditData* ed)
|
||||
{
|
||||
TextCursor tc = c;
|
||||
Text* t = tc.text();
|
||||
TextBase* t = tc.text();
|
||||
int line = tc.row();
|
||||
|
||||
CharFormat* charFmt = tc.format(); // take current format
|
||||
|
@ -2216,7 +2216,7 @@ void SplitText::redo(EditData* ed)
|
|||
|
||||
void JoinText::redo(EditData* ed)
|
||||
{
|
||||
Text* t = c.text();
|
||||
TextBase* t = c.text();
|
||||
int line = c.row();
|
||||
t->setTextInvalid();
|
||||
t->triggerLayout();
|
||||
|
@ -2239,7 +2239,7 @@ void JoinText::redo(EditData* ed)
|
|||
|
||||
void JoinText::undo(EditData* ed)
|
||||
{
|
||||
Text* t = c.text();
|
||||
TextBase* t = c.text();
|
||||
int line = c.row();
|
||||
t->setTextInvalid();
|
||||
t->triggerLayout();
|
||||
|
|
|
@ -326,7 +326,7 @@ static void processBasicDrawObj(QList<BasicDrawObj*> objects, Segment* s, int tr
|
|||
break;
|
||||
}
|
||||
}
|
||||
Text* text = new StaffText(score);
|
||||
TextBase* text = new StaffText(score);
|
||||
QFont f(st->font());
|
||||
text->setFamily(f.family());
|
||||
text->setItalic(f.italic());
|
||||
|
|
|
@ -3162,7 +3162,7 @@ static void beatUnit(XmlWriter& xml, const TDuration dur)
|
|||
}
|
||||
}
|
||||
|
||||
static void wordsMetrome(XmlWriter& xml, Score* s, Text const* const text)
|
||||
static void wordsMetrome(XmlWriter& xml, Score* s, TextBase const* const text)
|
||||
{
|
||||
//qDebug("wordsMetrome('%s')", qPrintable(text->xmlText()));
|
||||
const QList<TextFragment> list = text->fragmentList();
|
||||
|
|
|
@ -235,7 +235,7 @@ bool GuitarPro4::readNote(int string, int staffIdx, Note* note)
|
|||
if (noteBits & NOTE_FINGERING) { // 0x80
|
||||
int leftFinger = readUChar();
|
||||
int rightFinger = readUChar();
|
||||
Text* f = new Fingering(score);
|
||||
Fingering* f = new Fingering(score);
|
||||
QString finger;
|
||||
// if there is a valid left hand fingering
|
||||
if (leftFinger < 5) {
|
||||
|
@ -791,7 +791,7 @@ bool GuitarPro4::read(QFile* fp)
|
|||
break;
|
||||
const GpBar& gpbar = bars[bar];
|
||||
if (!gpbar.marker.isEmpty()) {
|
||||
Text* s = new RehearsalMark(score);
|
||||
RehearsalMark* s = new RehearsalMark(score);
|
||||
s->setPlainText(gpbar.marker.trimmed());
|
||||
s->setTrack(0);
|
||||
Segment* segment = measure->getSegment(SegmentType::ChordRest, measure->tick());
|
||||
|
|
|
@ -608,7 +608,7 @@ void GuitarPro5::readMeasures(int /*startingTempo*/)
|
|||
const GpBar& gpbar = bars[bar];
|
||||
|
||||
if (!gpbar.marker.isEmpty()) {
|
||||
Text* s = new RehearsalMark(score);
|
||||
RehearsalMark* s = new RehearsalMark(score);
|
||||
s->setPlainText(gpbar.marker.trimmed());
|
||||
s->setTrack(0);
|
||||
Segment* segment = measure->getSegment(SegmentType::ChordRest, measure->tick());
|
||||
|
|
|
@ -1997,7 +1997,7 @@ void GuitarPro6::readMasterBars(GPPartInfo* partInfo)
|
|||
const GpBar& gpbar = bars[bar];
|
||||
|
||||
if (!gpbar.marker.isEmpty()) {
|
||||
Text* s = new RehearsalMark(score);
|
||||
RehearsalMark* s = new RehearsalMark(score);
|
||||
s->setPlainText(gpbar.marker.trimmed());
|
||||
s->setTrack(0);
|
||||
Segment* segment = measure->getSegment(SegmentType::ChordRest, measure->tick());
|
||||
|
@ -2299,14 +2299,14 @@ void GuitarPro6::readMasterBars(GPPartInfo* partInfo)
|
|||
if (bars[measureCounter].section[0].length() || bars[measureCounter].section[1].length()) {
|
||||
Segment* s = measure->getSegment(SegmentType::ChordRest, measure->tick());
|
||||
if (bars[measureCounter].section[0].length()) {
|
||||
Text* t = new RehearsalMark(score);
|
||||
RehearsalMark* t = new RehearsalMark(score);
|
||||
t->setHasFrame(true);
|
||||
t->setPlainText(bars[measureCounter].section[0]);
|
||||
t->setTrack(0);
|
||||
s->add(t);
|
||||
}
|
||||
if (bars[measureCounter].section[1].length()) {
|
||||
Text* t = new RehearsalMark(score);
|
||||
RehearsalMark* t = new RehearsalMark(score);
|
||||
t->setHasFrame(false);
|
||||
t->setPlainText(bars[measureCounter].section[1]);
|
||||
t->setTrack(0);
|
||||
|
|
|
@ -1133,7 +1133,7 @@ bool GuitarPro1::read(QFile* fp)
|
|||
const GpBar& gpbar = bars[bar];
|
||||
|
||||
if (!gpbar.marker.isEmpty()) {
|
||||
Text* s = new RehearsalMark(score);
|
||||
RehearsalMark* s = new RehearsalMark(score);
|
||||
s->setPlainText(gpbar.marker.trimmed());
|
||||
s->setTrack(0);
|
||||
Segment* segment = measure->getSegment(SegmentType::ChordRest, measure->tick());
|
||||
|
@ -1620,7 +1620,7 @@ bool GuitarPro2::read(QFile* fp)
|
|||
const GpBar& gpbar = bars[bar];
|
||||
|
||||
if (!gpbar.marker.isEmpty()) {
|
||||
Text* s = new RehearsalMark(score);
|
||||
RehearsalMark* s = new RehearsalMark(score);
|
||||
s->setPlainText(gpbar.marker.trimmed());
|
||||
s->setTrack(0);
|
||||
Segment* segment = measure->getSegment(SegmentType::ChordRest, measure->tick());
|
||||
|
@ -2313,7 +2313,7 @@ bool GuitarPro3::read(QFile* fp)
|
|||
const GpBar& gpbar = bars[bar];
|
||||
|
||||
if (!gpbar.marker.isEmpty()) {
|
||||
Text* s = new RehearsalMark(score);
|
||||
RehearsalMark* s = new RehearsalMark(score);
|
||||
s->setPlainText(gpbar.marker.trimmed());
|
||||
s->setTrack(0);
|
||||
Segment* segment = measure->getSegment(SegmentType::ChordRest, measure->tick());
|
||||
|
|
|
@ -1379,7 +1379,7 @@ static void addTextToNote(int l, int c, QString txt, SubStyle style, Score* scor
|
|||
{
|
||||
if (note) {
|
||||
if (!txt.isEmpty()) {
|
||||
Text* t = new Fingering(score);
|
||||
TextBase* t = new Fingering(score);
|
||||
t->initSubStyle(style);
|
||||
t->setPlainText(txt);
|
||||
note->add(t);
|
||||
|
@ -2511,7 +2511,7 @@ void MusicXMLParserDirection::direction(const QString& partId,
|
|||
// create text if any text was found
|
||||
|
||||
if (_wordsText != "" || _rehearsalText != "" || _metroText != "") {
|
||||
Text* t = 0;
|
||||
TextBase* t = 0;
|
||||
if (_tpoSound > 0.1) {
|
||||
_tpoSound /= 60;
|
||||
t = new TempoText(_score);
|
||||
|
|
|
@ -1276,7 +1276,7 @@ void OveToMScore::convertMeasureMisc(Measure* measure, int part, int staff, int
|
|||
for(i=0; i<texts.size(); ++i){
|
||||
OVE::Text* textPtr = static_cast<OVE::Text*>(texts[i]);
|
||||
if(textPtr->getTextType() == OVE::Text::Type::Rehearsal){
|
||||
Text* text = new RehearsalMark(score_);
|
||||
RehearsalMark* text = new RehearsalMark(score_);
|
||||
text->setPlainText(textPtr->getText());
|
||||
//TODO:ws text->setAbove(true);
|
||||
text->setTrack(track);
|
||||
|
|
|
@ -824,7 +824,7 @@ void PowerTab::addToScore(ptSection& sec)
|
|||
}
|
||||
if (!sec.partName.empty() && lastPart != sec.partMarker) {
|
||||
lastPart = sec.partMarker;
|
||||
Text* t = new RehearsalMark(score);
|
||||
RehearsalMark* t = new RehearsalMark(score);
|
||||
t->setHasFrame(true);
|
||||
t->setPlainText(QString(sec.partMarker));
|
||||
t->setTrack(0);
|
||||
|
|
|
@ -1426,9 +1426,9 @@ Palette* MuseScore::newTextPalette()
|
|||
st->setSwing(true);
|
||||
sp->append(st, tr("Swing"));
|
||||
|
||||
st = new SystemText(gscore);
|
||||
st->setXmlText(tr("System Text"));
|
||||
sp->append(st, tr("System text"));
|
||||
SystemText* stxt = new SystemText(gscore);
|
||||
stxt->setXmlText(tr("System Text"));
|
||||
sp->append(stxt, tr("System text"));
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
|
|
@ -3728,7 +3728,7 @@ void ScoreView::cmdAddText(TEXT type)
|
|||
if (noteEntryMode()) // force out of entry mode
|
||||
changeState(ViewState::NORMAL);
|
||||
|
||||
Text* s = 0;
|
||||
TextBase* s = 0;
|
||||
_score->startCmd();
|
||||
switch(type) {
|
||||
case TEXT::TITLE:
|
||||
|
|
Loading…
Reference in a new issue