Merge pull request #4316 from dmitrio95/278940-glissando-spacing

fix #278940: restore chords spacing for glissando
This commit is contained in:
anatoly-os 2018-12-05 21:40:33 +02:00 committed by GitHub
commit 9eb907c20d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 1 deletions

View file

@ -3103,6 +3103,8 @@ Shape Chord::shape() const
shape.add(ChordRest::shape()); // add lyrics
for (LedgerLine* l = _ledgerLines; l; l = l->next())
shape.add(l->shape().translated(l->pos()));
if (_spaceLw || _spaceRw)
shape.addHorizontalSpacing(Shape::SPACING_GENERAL, -_spaceLw, _spaceRw);
return shape;
}

View file

@ -1164,6 +1164,7 @@ QString ChordRest::accessibleExtraInfo() const
Shape ChordRest::shape() const
{
Shape shape;
{
qreal x1 = 1000000.0;
qreal x2 = -1000000.0;
bool adjustWidth = false;
@ -1178,7 +1179,14 @@ Shape ChordRest::shape() const
x2 += spatium();
adjustWidth = true;
}
if (adjustWidth)
shape.addHorizontalSpacing(Shape::SPACING_LYRICS, x1, x2);
}
{
qreal x1 = 1000000.0;
qreal x2 = -1000000.0;
bool adjustWidth = false;
for (Element* e : segment()->annotations()) {
if (!e || !e->visible() || !e->autoplace())
continue;
@ -1191,7 +1199,8 @@ Shape ChordRest::shape() const
}
}
if (adjustWidth)
shape.add(QRectF(x1, 0.0, x2-x1, 0.0));
shape.addHorizontalSpacing(Shape::SPACING_HARMONY, x1, x2);
}
return shape;
}

View file

@ -15,6 +15,20 @@
namespace Ms {
//---------------------------------------------------------
// addHorizontalSpacing
// Currently implemented by adding rectangles of zero
// height to the Y position corresponding to the type.
// This is a simple solution but has its drawbacks too.
//---------------------------------------------------------
void Shape::addHorizontalSpacing(HorizontalSpacingType type, qreal leftEdge, qreal rightEdge)
{
constexpr qreal eps = 100 * std::numeric_limits<qreal>::epsilon();
const qreal y = eps * int(type);
add(QRectF(leftEdge, y, rightEdge - leftEdge, 0));
}
//---------------------------------------------------------
// translate
//---------------------------------------------------------

View file

@ -42,6 +42,12 @@ struct ShapeElement : public QRectF {
class Shape : public std::vector<ShapeElement> {
// class Shape : std::vector<ShapeElement> {
public:
enum HorizontalSpacingType {
SPACING_GENERAL = 0,
SPACING_LYRICS,
SPACING_HARMONY,
};
Shape() {}
#ifndef NDEBUG
Shape(const QRectF& r, const char* s = 0) { add(r, s); }
@ -57,6 +63,8 @@ class Shape : public std::vector<ShapeElement> {
void remove(const QRectF&);
void remove(const Shape&);
void addHorizontalSpacing(HorizontalSpacingType type, qreal left, qreal right);
void translate(const QPointF&);
void translateX(qreal);
void translateY(qreal);