-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to show measure number interval in mmrests
the MMRestRange is a new class derived from MeasureNumber. The logic is handled by layoutMeasureNumber, as if it was an usual measurenumber. MMRestRange may not be styled like MeasureNumber, so a new set of textstyles were added. There is 3 possible bracketing around the ranges: parentheses, brackets, or none (the default).
- Loading branch information
Showing
15 changed files
with
439 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
//============================================================================= | ||
// MuseScore | ||
// Music Composition & Notation | ||
// | ||
// Copyright (C) 2020 MuseScore BVBA and others | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License version 2. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program; if not, write to the Free Software | ||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
//============================================================================= | ||
|
||
#include "score.h" | ||
#include "mmrestrange.h" | ||
#include "measure.h" | ||
#include "staff.h" | ||
|
||
namespace Ms { | ||
|
||
//--------------------------------------------------------- | ||
// mmRestRangeStyle | ||
//--------------------------------------------------------- | ||
|
||
static const ElementStyle mmRestRangeStyle { | ||
{ Sid::mmRestRangeBracketType, Pid::MMREST_RANGE_BRACKET_TYPE }, | ||
{ Sid::mmRestRangeVPlacement, Pid::PLACEMENT }, | ||
{ Sid::mmRestRangeHPlacement, Pid::HPLACEMENT } | ||
}; | ||
|
||
//--------------------------------------------------------- | ||
// MMRestRange | ||
//--------------------------------------------------------- | ||
|
||
MMRestRange::MMRestRange(Score* s) : MeasureNumber(s, Tid::MMREST_RANGE) | ||
{ | ||
initElementStyle(&mmRestRangeStyle); | ||
} | ||
|
||
//--------------------------------------------------------- | ||
// getProperty | ||
//--------------------------------------------------------- | ||
|
||
QVariant MMRestRange::getProperty(Pid id) const | ||
{ | ||
switch (id) { | ||
case Pid::MMREST_RANGE_BRACKET_TYPE: | ||
return int(bracketType()); | ||
default: | ||
return MeasureNumber::getProperty(id); | ||
} | ||
} | ||
|
||
//--------------------------------------------------------- | ||
// setProperty | ||
//--------------------------------------------------------- | ||
|
||
bool MMRestRange::setProperty(Pid id, const QVariant& val) | ||
{ | ||
switch (id) { | ||
case Pid::MMREST_RANGE_BRACKET_TYPE: | ||
setBracketType(MMRestRangeBracketType(val.toInt())); | ||
setLayoutInvalid(); | ||
triggerLayout(); | ||
return true; | ||
default: | ||
return MeasureNumber::setProperty(id, val); | ||
} | ||
} | ||
|
||
//--------------------------------------------------------- | ||
// propertyDefault | ||
//--------------------------------------------------------- | ||
|
||
QVariant MMRestRange::propertyDefault(Pid id) const | ||
{ | ||
switch(id) { | ||
case Pid::SUB_STYLE: | ||
return int(Tid::MMREST_RANGE); | ||
default: | ||
return MeasureNumber::propertyDefault(id); | ||
} | ||
} | ||
|
||
//--------------------------------------------------------- | ||
// readProperties | ||
//--------------------------------------------------------- | ||
|
||
bool MMRestRange::readProperties(XmlReader& xml) | ||
{ | ||
if (readProperty(xml.name(), xml, Pid::MMREST_RANGE_BRACKET_TYPE)) | ||
return true; | ||
else | ||
return MeasureNumber::readProperties(xml); | ||
} | ||
|
||
//--------------------------------------------------------- | ||
// setXmlText | ||
/// This is reimplemented from TextBase::setXmlText to take care of the brackets | ||
//--------------------------------------------------------- | ||
|
||
void MMRestRange::setXmlText(const QString& s) | ||
{ | ||
switch (bracketType()) { | ||
case MMRestRangeBracketType::BRACKETS: | ||
TextBase::setXmlText("[" + s + "]"); | ||
break; | ||
case MMRestRangeBracketType::PARENTHESES: | ||
TextBase::setXmlText("(" + s + ")"); | ||
break; | ||
case MMRestRangeBracketType::NONE: | ||
TextBase::setXmlText(s); | ||
break; | ||
default: | ||
Q_UNREACHABLE(); | ||
break; | ||
} | ||
} | ||
|
||
} // namespace MS | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
//============================================================================= | ||
// MuseScore | ||
// Music Composition & Notation | ||
// | ||
// Copyright (C) 2020 MuseScore BVBA and others | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License version 2. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program; if not, write to the Free Software | ||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
//============================================================================= | ||
|
||
#ifndef __MMRESTRANGE_H__ | ||
#define __MMRESTRANGE_H__ | ||
|
||
#include "measurenumber.h" | ||
#include "property.h" | ||
|
||
namespace Ms { | ||
|
||
//--------------------------------------------------------- | ||
// MMRestRange | ||
//--------------------------------------------------------- | ||
|
||
class MMRestRange : public MeasureNumber { | ||
|
||
/// Bracketing: [18-24], (18-24) or 18-24 | ||
M_PROPERTY (MMRestRangeBracketType, bracketType, setBracketType) | ||
|
||
public: | ||
MMRestRange(Score* s = nullptr); | ||
|
||
virtual ElementType type() const override { return ElementType::MEASURE_NUMBER; } | ||
virtual MMRestRange* clone() const override { return new MMRestRange(*this); } | ||
|
||
virtual QVariant getProperty(Pid id) const override; | ||
virtual bool setProperty(Pid id, const QVariant& val) override; | ||
virtual QVariant propertyDefault(Pid id) const override; | ||
|
||
virtual bool readProperties(XmlReader&) override; | ||
|
||
virtual void setXmlText(const QString&) override; | ||
}; | ||
|
||
} // namespace Ms | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.