Fixed dot positions in TAB with down stems; renamed StaffTypeTab vars;
This commit is contained in:
parent
fb88a2718b
commit
2bc3fae814
7 changed files with 41 additions and 33 deletions
|
@ -464,7 +464,7 @@ void Beam::layout1()
|
|||
//TABULATURES: all beams (and related chords) are:
|
||||
// UP or DOWN according to TAB duration position
|
||||
// slope 0
|
||||
_up = !((StaffTypeTablature*)staff()->staffType())->durationBelow();
|
||||
_up = !((StaffTypeTablature*)staff()->staffType())->stemsDown();
|
||||
slope = 0.0;
|
||||
cross = isGrace = false;
|
||||
foreach(ChordRest* cr, _elements) {
|
||||
|
@ -1549,14 +1549,14 @@ void Beam::layout2(QList<ChordRest*>crl, SpannerSegmentType, int frag)
|
|||
|
||||
if (staff()->isTabStaff()) {
|
||||
qreal y;
|
||||
if( ((StaffTypeTablature*)staff()->staffType())->durationBelow() ) {
|
||||
if( ((StaffTypeTablature*)staff()->staffType())->stemsDown() ) {
|
||||
_up = false;
|
||||
y = (staff()->staffType()->lines() - 1) * staff()->staffType()->lineDistance().val()
|
||||
+ STAFFTYPE_TAB_DEFAULTSTEMLEN;
|
||||
+ STAFFTYPE_TAB_DEFAULTSTEMLEN_DN;
|
||||
}
|
||||
else {
|
||||
_up = true;
|
||||
y = STAFFTYPE_TAB_DEFAULTSTEMPOSY - STAFFTYPE_TAB_DEFAULTSTEMLEN;
|
||||
y = STAFFTYPE_TAB_DEFAULTSTEMPOSY_UP - STAFFTYPE_TAB_DEFAULTSTEMLEN_UP;
|
||||
}
|
||||
y *= _spatium;
|
||||
py1 = y;
|
||||
|
|
|
@ -300,8 +300,8 @@ QPointF Chord::stemPos() const
|
|||
if (staff() && staff()->isTabStaff()) {
|
||||
qreal sp = spatium();
|
||||
StaffTypeTablature* tab = static_cast<StaffTypeTablature*>( staff()->staffType() );
|
||||
qreal y = ( tab->durationBelow() ?
|
||||
upString() * tab->lineDistance().val() : STAFFTYPE_TAB_DEFAULTSTEMPOSY);
|
||||
qreal y = ( tab->stemsDown() ?
|
||||
upString() * tab->lineDistance().val() : STAFFTYPE_TAB_DEFAULTSTEMPOSY_UP);
|
||||
|
||||
return QPointF(STAFFTYPE_TAB_DEFAULTSTEMPOSX*sp, y*sp) + pagePos();
|
||||
}
|
||||
|
@ -319,8 +319,8 @@ QPointF Chord::stemPosBeam() const
|
|||
if (staff() && staff()->isTabStaff()) {
|
||||
qreal sp = spatium();
|
||||
StaffTypeTablature* tab = static_cast<StaffTypeTablature*>( staff()->staffType() );
|
||||
qreal y = ( tab->durationBelow() ?
|
||||
downString() * tab->lineDistance().val() : STAFFTYPE_TAB_DEFAULTSTEMPOSY);
|
||||
qreal y = ( tab->stemsDown() ?
|
||||
downString() * tab->lineDistance().val() : STAFFTYPE_TAB_DEFAULTSTEMPOSY_UP);
|
||||
|
||||
return QPointF(STAFFTYPE_TAB_DEFAULTSTEMPOSX*sp, y*sp) + pagePos();
|
||||
}
|
||||
|
@ -609,7 +609,7 @@ void Chord::computeUp()
|
|||
{
|
||||
// tablatures
|
||||
if (staff() && staff()->isTabStaff()) {
|
||||
_up = !((StaffTypeTablature*)staff()->staffType())->durationBelow();
|
||||
_up = !((StaffTypeTablature*)staff()->staffType())->stemsDown();
|
||||
return;
|
||||
}
|
||||
// pitched staves
|
||||
|
@ -1118,14 +1118,14 @@ void Chord::layoutStem()
|
|||
if (!tab->slashStyle() && _stem) {
|
||||
// process stems:
|
||||
QPointF pos = stemPos() - pagePos();
|
||||
qreal stemLen = tab->durationBelow() ?
|
||||
(tab->lines()-1 - upString()) * tab->lineDistance().val() + STAFFTYPE_TAB_DEFAULTSTEMLEN :
|
||||
STAFFTYPE_TAB_DEFAULTSTEMLEN;
|
||||
qreal stemLen = tab->stemsDown() ?
|
||||
(tab->lines()-1 - upString()) * tab->lineDistance().val() + STAFFTYPE_TAB_DEFAULTSTEMLEN_DN :
|
||||
STAFFTYPE_TAB_DEFAULTSTEMLEN_UP;
|
||||
_stem->setPos(pos);
|
||||
_stem->setLen(stemLen * spatium());
|
||||
// process hook
|
||||
int hookIdx = durationType().hooks();
|
||||
if (tab->durationBelow())
|
||||
if (tab->stemsDown())
|
||||
hookIdx = -hookIdx;
|
||||
if (hookIdx) {
|
||||
_hook->setSubtype(hookIdx);
|
||||
|
|
|
@ -1237,8 +1237,9 @@ bool Score::getPosition(Position* pos, const QPointF& p, int voice) const
|
|||
// TODO: restrict to reasonable values (pitch 0-127)
|
||||
//
|
||||
Staff* s = staff(pos->staffIdx);
|
||||
qreal mag = staff(pos->staffIdx)->mag();
|
||||
qreal lineDist = (s->isTabStaff() ? 1.5 : .5) * mag * spatium();
|
||||
qreal mag = s->mag();
|
||||
// in TABs, step from one string to another; in other staves, step on and between lines
|
||||
qreal lineDist = s->staffType()->lineDistance().val() * (s->isTabStaff() ? 1 : .5) * mag * spatium();
|
||||
|
||||
pos->line = lrint((pppp.y() - sstaff->bbox().y()) / lineDist);
|
||||
if (s->isTabStaff()) {
|
||||
|
|
|
@ -373,7 +373,6 @@ QList<TablatureDurationFont> StaffTypeTablature::_durationFonts = QList<Tablatu
|
|||
void StaffTypeTablature::init()
|
||||
{
|
||||
// set reasonable defaults for type-specific members */
|
||||
setDurationBelow(true);
|
||||
setDurationFontName(_durationFonts[0].displayName);
|
||||
setDurationFontSize(15.0);
|
||||
setDurationFontUserY(0.0);
|
||||
|
@ -386,6 +385,7 @@ void StaffTypeTablature::init()
|
|||
setLines(6);
|
||||
setLinesThrough(false);
|
||||
setOnLines(true);
|
||||
setStemsDown(true);
|
||||
setUpsideDown(false);
|
||||
setUseNumbers(true);
|
||||
// internal
|
||||
|
@ -428,8 +428,6 @@ void StaffTypeTablature::read(const QDomElement& de)
|
|||
|
||||
if (tag == "durations")
|
||||
setGenDurations(val.toInt() != 0);
|
||||
else if (tag == "durationBelow")
|
||||
setDurationBelow(val.toInt() != 0);
|
||||
else if (tag == "durationFontName")
|
||||
setDurationFontName(e.text());
|
||||
else if (tag == "durationFontSize")
|
||||
|
@ -446,6 +444,8 @@ void StaffTypeTablature::read(const QDomElement& de)
|
|||
setLinesThrough(val.toInt() != 0);
|
||||
else if (tag == "onLines")
|
||||
setOnLines(val.toInt() != 0);
|
||||
else if (tag == "stemsDown")
|
||||
setStemsDown(val.toInt() != 0);
|
||||
else if (tag == "upsideDown")
|
||||
setUpsideDown(val.toInt() != 0);
|
||||
else if (tag == "useNumbers")
|
||||
|
@ -465,7 +465,6 @@ void StaffTypeTablature::write(Xml& xml, int idx) const
|
|||
xml.stag(QString("StaffType idx=\"%1\" group=\"%2\"").arg(idx).arg(groupName()));
|
||||
StaffType::writeProperties(xml);
|
||||
xml.tag("durations", _genDurations);
|
||||
xml.tag("durationBelow", _durationsBelow);
|
||||
xml.tag("durationFontName", _durationFonts[_durationFontIdx].displayName);
|
||||
xml.tag("durationFontSize", _durationFontSize);
|
||||
xml.tag("durationFontY", _durationFontUserY);
|
||||
|
@ -474,6 +473,7 @@ void StaffTypeTablature::write(Xml& xml, int idx) const
|
|||
xml.tag("fretFontY", _fretFontUserY);
|
||||
xml.tag("linesThrough", _linesThrough);
|
||||
xml.tag("onLines", _onLines);
|
||||
xml.tag("stemsDown", _stemsDown);
|
||||
xml.tag("upsideDown", _upsideDown);
|
||||
xml.tag("useNumbers", _useNumbers);
|
||||
xml.etag();
|
||||
|
|
|
@ -19,10 +19,12 @@
|
|||
#include "mscore.h"
|
||||
#include "durationtype.h"
|
||||
|
||||
#define STAFFTYPE_TAB_DEFAULTSTEMLEN 3.0
|
||||
#define STAFFTYPE_TAB_DEFAULTSTEMDIST 1.0
|
||||
#define STAFFTYPE_TAB_DEFAULTSTEMLEN_UP 3.0
|
||||
#define STAFFTYPE_TAB_DEFAULTSTEMDIST_UP 1.0
|
||||
#define STAFFTYPE_TAB_DEFAULTSTEMPOSX 0.75
|
||||
#define STAFFTYPE_TAB_DEFAULTSTEMPOSY -STAFFTYPE_TAB_DEFAULTSTEMDIST
|
||||
#define STAFFTYPE_TAB_DEFAULTSTEMPOSY_UP -STAFFTYPE_TAB_DEFAULTSTEMDIST_UP
|
||||
#define STAFFTYPE_TAB_DEFAULTSTEMLEN_DN 3.0
|
||||
#define STAFFTYPE_TAB_DEFAULTDOTDIST_X 0.75
|
||||
|
||||
class Staff;
|
||||
class Xml;
|
||||
|
@ -186,7 +188,6 @@ class StaffTypeTablature : public StaffType {
|
|||
|
||||
protected:
|
||||
// configurable properties
|
||||
bool _durationsBelow; // durations are drawn below the staff (stem-and-beam durations only)
|
||||
qreal _durationFontSize; // the size (in points) for the duration symbol font
|
||||
qreal _durationFontUserY; // the vertical offset (spatium units) for the duration symb. font
|
||||
// user configurable
|
||||
|
@ -196,6 +197,7 @@ class StaffTypeTablature : public StaffType {
|
|||
bool _genDurations; // whether duration symbols are drawn or not
|
||||
bool _linesThrough; // whether lines for strings and stems may pass through fret marks or not
|
||||
bool _onLines; // whether fret marks are drawn on the string lines or between them
|
||||
bool _stemsDown; // stems are drawn downward (stem-and-beam durations only)
|
||||
bool _upsideDown; // whether lines are drwan with highest string at top (false) or at bottom (true)
|
||||
bool _useNumbers; // true: use numbers ('0' - ...) for frets | false: use letters ('a' - ...)
|
||||
|
||||
|
@ -247,7 +249,6 @@ class StaffTypeTablature : public StaffType {
|
|||
qreal durationBoxH();
|
||||
qreal durationBoxY();
|
||||
|
||||
bool durationBelow() const { return _durationsBelow; }
|
||||
const QFont& durationFont() { return _durationFont; }
|
||||
const QString durationFontName() const { return _durationFonts[_durationFontIdx].displayName; }
|
||||
qreal durationFontSize() const { return _durationFontSize; }
|
||||
|
@ -263,10 +264,10 @@ class StaffTypeTablature : public StaffType {
|
|||
bool genDurations() const { return _genDurations; }
|
||||
bool linesThrough() const { return _linesThrough; }
|
||||
bool onLines() const { return _onLines; }
|
||||
bool stemsDown() const { return _stemsDown; }
|
||||
bool upsideDown() const { return _upsideDown; }
|
||||
bool useNumbers() const { return _useNumbers; }
|
||||
// properties setters (setting some props invalidates metrics)
|
||||
void setDurationBelow(bool val) { _durationsBelow = val; }
|
||||
void setDurationFontName(QString name);
|
||||
void setDurationFontSize(qreal val);
|
||||
void setDurationFontUserY(qreal val) { _durationFontUserY = val; }
|
||||
|
@ -276,6 +277,7 @@ class StaffTypeTablature : public StaffType {
|
|||
void setGenDurations(bool val) { _genDurations = val; }
|
||||
void setLinesThrough(bool val) { _linesThrough = val; }
|
||||
void setOnLines(bool val);
|
||||
void setStemsDown(bool val) { _stemsDown = val; }
|
||||
void setUpsideDown(bool val) { _upsideDown = val; }
|
||||
void setUseNumbers(bool val) { _useNumbers = val; _fretMetricsValid = false; }
|
||||
|
||||
|
|
|
@ -161,8 +161,13 @@ void Stem::draw(QPainter* painter) const
|
|||
// TODO: adjust bounding rectangle in layout()
|
||||
if (useTab) {
|
||||
int nDots = chord()->dots();
|
||||
if (nDots > 0)
|
||||
symbols[score()->symIdx()][dotSym].draw(painter, magS(), QPointF(spatium(), stemLen()), nDots);
|
||||
if (nDots > 0) {
|
||||
qreal sp = spatium();
|
||||
qreal y = stemLen() - ( ((StaffTypeTablature*)st->staffType())->stemsDown() ?
|
||||
(STAFFTYPE_TAB_DEFAULTSTEMLEN_DN - 0.75) * sp : 0.0 );
|
||||
symbols[score()->symIdx()][dotSym].draw(painter, magS(),
|
||||
QPointF(STAFFTYPE_TAB_DEFAULTDOTDIST_X * sp, y), nDots);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -199,14 +199,14 @@ void EditStaffType::saveCurrent(QListWidgetItem* o)
|
|||
StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st);
|
||||
stt->setSlashStyle(true); // assume no note values
|
||||
stt->setGenDurations(false);
|
||||
stt->setDurationBelow(false);
|
||||
stt->setStemsDown(false);
|
||||
if (noteValues1->isChecked())
|
||||
stt->setGenDurations(true);
|
||||
if (noteValues2->isChecked())
|
||||
stt->setSlashStyle(false);
|
||||
if (noteValues3->isChecked()) {
|
||||
stt->setSlashStyle(false);
|
||||
stt->setDurationBelow(true);
|
||||
stt->setStemsDown(true);
|
||||
}
|
||||
stt->setDurationFontName(durFontName->currentText());
|
||||
stt->setDurationFontSize(durFontSize->value());
|
||||
|
@ -315,8 +315,8 @@ void EditStaffType::typeChanged(QListWidgetItem* n, QListWidgetItem* o)
|
|||
else {
|
||||
noteValues0->setChecked(false);
|
||||
noteValues1->setChecked(false);
|
||||
noteValues2->setChecked( !(tab->durationBelow()) );
|
||||
noteValues3->setChecked(tab->durationBelow());
|
||||
noteValues2->setChecked( !(tab->stemsDown()) );
|
||||
noteValues3->setChecked(tab->stemsDown());
|
||||
}
|
||||
}
|
||||
updateTabPreview();
|
||||
|
@ -526,11 +526,11 @@ void EditStaffType::updateTabPreview()
|
|||
stt->setGenDurations(true);
|
||||
if (noteValues2->isChecked()) {
|
||||
stt->setSlashStyle(false);
|
||||
stt->setDurationBelow(false);
|
||||
stt->setStemsDown(false);
|
||||
}
|
||||
if (noteValues3->isChecked()) {
|
||||
stt->setSlashStyle(false);
|
||||
stt->setDurationBelow(true);
|
||||
stt->setStemsDown(true);
|
||||
}
|
||||
stt->setDurationFontName(durFontName->currentText());
|
||||
stt->setDurationFontSize(durFontSize->value());
|
||||
|
|
Loading…
Reference in a new issue