fix bounding rectangle of Bend

Bend layout was distorted by way to large bounding rectangle.
This commit is contained in:
ws 2018-11-29 13:35:34 +01:00
parent 5fadc466bd
commit d3353c4e4a
4 changed files with 13 additions and 15 deletions

View file

@ -76,14 +76,13 @@ void Bend::layout()
qreal _spatium = spatium();
if (staff() && !staff()->isTabStaff(tick())) {
setbbox(QRectF());
if (!parent()) {
noteWidth = -_spatium*2;
notePos = QPointF(0.0, _spatium*3);
}
}
qreal _lw = _lineWidth.val() * _spatium;
qreal _lw = _lineWidth;
Note* note = toNote(parent());
if (note == 0) {
noteWidth = 0.0;
@ -95,7 +94,7 @@ void Bend::layout()
}
QRectF bb;
QFontMetricsF fm(font(_spatium));
QFontMetricsF fm(font(_spatium), MScore::paintDevice());
int n = _points.size();
qreal x = noteWidth;
@ -143,7 +142,6 @@ void Bend::layout()
path.moveTo(x, y);
path.cubicTo(x+dx/2, y, x2, y+dy/4, x2, y2);
bb |= path.boundingRect();
bb |= arrowUp.translated(x2, y2 + _spatium * .2).boundingRect();
int idx = (_points[pt+1].pitch + 12)/25;
@ -181,7 +179,7 @@ void Bend::layout()
void Bend::draw(QPainter* painter) const
{
qreal _spatium = spatium();
qreal _lw = _lineWidth.val();
qreal _lw = _lineWidth;
QPen pen(curColor(), _lw, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
painter->setPen(pen);
@ -189,7 +187,7 @@ void Bend::draw(QPainter* painter) const
QFont f = font(_spatium * MScore::pixelRatio);
painter->setFont(f);
QFontMetrics fm(f);
QFontMetrics fm(f, MScore::paintDevice());
qreal x = noteWidth + _spatium * .2;
qreal y = -_spatium * .8;
@ -356,7 +354,7 @@ bool Bend::setProperty(Pid id, const QVariant& v)
setPlayBend(v.toBool());
break;
case Pid::LINE_WIDTH:
_lineWidth = v.value<Spatium>();
_lineWidth = v.toReal();
break;
default:
return Element::setProperty(id, v);

View file

@ -28,7 +28,7 @@ class Bend final : public Element {
M_PROPERTY(QString, fontFace, setFontFace)
M_PROPERTY(qreal, fontSize, setFontSize)
M_PROPERTY(FontStyle, fontStyle, setFontStyle)
M_PROPERTY(Spatium, lineWidth, setLineWidth)
M_PROPERTY(qreal, lineWidth, setLineWidth)
bool _playBend { true };
QList<PitchValue> _points;

View file

@ -4487,14 +4487,14 @@ Movements::~Movements()
//---------------------------------------------------------
// ScoreLoad::_loading
// If the _loading flag is set pushes and pops to
// If the _loading > 0 then pushes and pops to
// the undo stack do not emit a warning.
// Usually pushes and pops to the undo stack are only
// valid inside a startCmd() - endCmd(). Exceptions
// occure during score loading.
//---------------------------------------------------------
bool ScoreLoad::_loading = false;
int ScoreLoad::_loading = 0;
}

View file

@ -1304,7 +1304,7 @@ class MasterScore : public Score {
void enqueueMidiEvent(MidiInputEvent ev) { _midiInputQueue.enqueue(ev); }
void updateChannel();
void setSoloMute();
void addExcerpt(Excerpt*);
void removeExcerpt(Excerpt*);
void deleteExcerpt(Excerpt*);
@ -1331,12 +1331,12 @@ class MasterScore : public Score {
//---------------------------------------------------------
class ScoreLoad {
static bool _loading;
static int _loading;
public:
ScoreLoad() { _loading = true; }
~ScoreLoad() { _loading = false; }
static bool loading() { return _loading; }
ScoreLoad() { ++_loading; }
~ScoreLoad() { --_loading; }
static bool loading() { return _loading > 0; }
};
inline UndoStack* Score::undoStack() const { return _masterScore->undoStack(); }