manage minDistance when moving away from staff
This commit is contained in:
parent
66b30c3a81
commit
a27bc1f2f0
5 changed files with 37 additions and 27 deletions
|
@ -168,7 +168,7 @@ Element::Element(Score* s, ElementFlags f)
|
|||
_mag = 1.0;
|
||||
_tag = 1;
|
||||
_z = -1;
|
||||
_offsetChanged = 0;
|
||||
_offsetChanged = OffsetChange::NONE;
|
||||
_minDistance = Spatium(0.0);
|
||||
}
|
||||
|
||||
|
@ -2185,9 +2185,9 @@ void Element::autoplaceSegmentElement(qreal minDistance)
|
|||
void Element::setOffsetChanged(bool v, bool absolute, const QPointF& diff)
|
||||
{
|
||||
if (v)
|
||||
_offsetChanged = absolute ? 1 : -1;
|
||||
_offsetChanged = absolute ? OffsetChange::ABSOLUTE_OFFSET : OffsetChange::RELATIVE_OFFSET;
|
||||
else
|
||||
_offsetChanged = 0;
|
||||
_offsetChanged = OffsetChange::NONE;
|
||||
_changedPos = pos() + diff;
|
||||
}
|
||||
|
||||
|
@ -2204,7 +2204,7 @@ qreal Element::rebaseOffset(bool nox)
|
|||
QPointF p = _changedPos - pos();
|
||||
if (nox)
|
||||
p.rx() = 0.0;
|
||||
bool saveChangedValue = _offsetChanged;
|
||||
//OffsetChange saveChangedValue = _offsetChanged;
|
||||
|
||||
if (staff() && propertyFlags(Pid::PLACEMENT) != PropertyFlags::NOSTYLE) {
|
||||
// check if flipped
|
||||
|
@ -2218,7 +2218,7 @@ qreal Element::rebaseOffset(bool nox)
|
|||
if (flipped && !multi) {
|
||||
off.ry() += above ? -staffHeight : staffHeight;
|
||||
undoChangeProperty(Pid::OFFSET, off + p);
|
||||
_offsetChanged = saveChangedValue;
|
||||
_offsetChanged = OffsetChange::ABSOLUTE_OFFSET; //saveChangedValue;
|
||||
rypos() += above ? staffHeight : -staffHeight;
|
||||
PropertyFlags pf = e->propertyFlags(Pid::PLACEMENT);
|
||||
if (pf == PropertyFlags::STYLED)
|
||||
|
@ -2232,16 +2232,16 @@ qreal Element::rebaseOffset(bool nox)
|
|||
}
|
||||
}
|
||||
|
||||
if (offsetChanged() > 0) {
|
||||
if (offsetChanged() == OffsetChange::ABSOLUTE_OFFSET) {
|
||||
undoChangeProperty(Pid::OFFSET, off + p);
|
||||
_offsetChanged = saveChangedValue;
|
||||
// allow autoplace to manage min distance even when not needed?
|
||||
//undoResetProperty(Pid::MIN_DISTANCE);
|
||||
_offsetChanged = OffsetChange::ABSOLUTE_OFFSET; //saveChangedValue;
|
||||
// allow autoplace to manage min distance even when not needed
|
||||
undoResetProperty(Pid::MIN_DISTANCE);
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// allow autoplace to manage min distance even when not needed?
|
||||
//undoResetProperty(Pid::MIN_DISTANCE);
|
||||
// allow autoplace to manage min distance even when not needed
|
||||
undoResetProperty(Pid::MIN_DISTANCE);
|
||||
return p.y();
|
||||
}
|
||||
|
||||
|
@ -2275,7 +2275,7 @@ bool Element::rebaseMinDistance(qreal& md, qreal& yd, qreal sp, qreal rebase, bo
|
|||
// min distance still styled
|
||||
// user apparently moved element into skyline
|
||||
// but perhaps not really, if performing a relative adjustment
|
||||
if (_offsetChanged < 0) {
|
||||
if (_offsetChanged == OffsetChange::RELATIVE_OFFSET) {
|
||||
// relative movement (cursor): fix only if moving vertically into direction of skyline
|
||||
if ((above && diff > 0.0) || (!above && diff < 0.0)) {
|
||||
// rebase offset
|
||||
|
@ -2308,7 +2308,7 @@ void Element::autoplaceSegmentElement(bool add)
|
|||
{
|
||||
// rebase vertical offset on drag
|
||||
qreal rebase = 0.0;
|
||||
if (offsetChanged())
|
||||
if (offsetChanged() != OffsetChange::NONE)
|
||||
rebase = rebaseOffset();
|
||||
|
||||
if (autoplace() && parent()) {
|
||||
|
@ -2346,7 +2346,7 @@ void Element::autoplaceSegmentElement(bool add)
|
|||
qreal yd = d + minDistance;
|
||||
if (placeAbove())
|
||||
yd *= -1.0;
|
||||
if (offsetChanged()) {
|
||||
if (offsetChanged() != OffsetChange::NONE) {
|
||||
// user moved element within the skyline
|
||||
// we may need to adjust minDistance, yd, and/or offset
|
||||
bool inStaff = placeAbove() ? r.bottom() + rebase > 0.0 : r.top() + rebase < staff()->height();
|
||||
|
@ -2370,7 +2370,7 @@ void Element::autoplaceMeasureElement(bool add)
|
|||
{
|
||||
// rebase vertical offset on drag
|
||||
qreal rebase = 0.0;
|
||||
if (offsetChanged())
|
||||
if (offsetChanged() != OffsetChange::NONE)
|
||||
rebase = rebaseOffset();
|
||||
|
||||
if (autoplace() && parent()) {
|
||||
|
@ -2397,7 +2397,7 @@ void Element::autoplaceMeasureElement(bool add)
|
|||
qreal yd = d + minDistance;
|
||||
if (placeAbove())
|
||||
yd *= -1.0;
|
||||
if (offsetChanged()) {
|
||||
if (offsetChanged() != OffsetChange::NONE) {
|
||||
// user moved element within the skyline
|
||||
// we may need to adjust minDistance, yd, and/or offset
|
||||
bool inStaff = placeAbove() ? r.bottom() + rebase > 0.0 : r.top() + rebase < staff()->height();
|
||||
|
|
|
@ -51,6 +51,16 @@ enum class Grip {
|
|||
GRIPS = 6 // number of grips for slur
|
||||
};
|
||||
|
||||
//---------------------------------------------------------
|
||||
// OffsetChange
|
||||
//---------------------------------------------------------
|
||||
|
||||
enum class OffsetChange {
|
||||
RELATIVE_OFFSET = -1,
|
||||
NONE = 0,
|
||||
ABSOLUTE_OFFSET = 1
|
||||
};
|
||||
|
||||
//---------------------------------------------------------
|
||||
// ElementFlag
|
||||
//---------------------------------------------------------
|
||||
|
@ -155,8 +165,8 @@ class Element : public ScoreElement {
|
|||
qreal _mag; ///< standard magnification (derived value)
|
||||
QPointF _pos; ///< Reference position, relative to _parent, set by autoplace
|
||||
QPointF _offset; ///< offset from reference position, set by autoplace or user
|
||||
int _offsetChanged; ///< set by user actions that change offset, used by autoplace
|
||||
QPointF _changedPos; ///< position set when changing offset (valid when _offsetChanged)
|
||||
OffsetChange _offsetChanged; ///< set by user actions that change offset, used by autoplace
|
||||
QPointF _changedPos; ///< position set when changing offset
|
||||
Spatium _minDistance; ///< autoplace min distance
|
||||
int _track; ///< staffIdx * VOICES + voice
|
||||
mutable ElementFlags _flags;
|
||||
|
@ -211,7 +221,7 @@ class Element : public ScoreElement {
|
|||
|
||||
Spatium minDistance() const { return _minDistance; }
|
||||
void setMinDistance(Spatium v) { _minDistance = v; }
|
||||
int offsetChanged() const { return _offsetChanged; }
|
||||
OffsetChange offsetChanged() const { return _offsetChanged; }
|
||||
void setOffsetChanged(bool v, bool absolute = true, const QPointF& diff = QPointF());
|
||||
|
||||
const QPointF& ipos() const { return _pos; }
|
||||
|
|
|
@ -112,7 +112,7 @@ void Fingering::layout()
|
|||
|
||||
// update offset after drag
|
||||
qreal rebase = 0.0;
|
||||
if (offsetChanged())
|
||||
if (offsetChanged() != OffsetChange::NONE)
|
||||
rebase = rebaseOffset();
|
||||
|
||||
// temporarily exclude self from chord shape
|
||||
|
@ -157,7 +157,7 @@ void Fingering::layout()
|
|||
qreal diff = (bbox().bottom() + ipos().y() + yd + n->y()) - top;
|
||||
if (diff > 0.0)
|
||||
yd -= diff;
|
||||
if (offsetChanged()) {
|
||||
if (offsetChanged() != OffsetChange::NONE) {
|
||||
// user moved element within the skyline
|
||||
// we may need to adjust minDistance, yd, and/or offset
|
||||
bool inStaff = placeAbove() ? r.bottom() + rebase > 0.0 : r.top() + rebase < staff()->height();
|
||||
|
@ -193,7 +193,7 @@ void Fingering::layout()
|
|||
qreal diff = bottom - (bbox().top() + ipos().y() + yd + n->y());
|
||||
if (diff > 0.0)
|
||||
yd += diff;
|
||||
if (offsetChanged()) {
|
||||
if (offsetChanged() != OffsetChange::NONE) {
|
||||
// user moved element within the skyline
|
||||
// we may need to adjust minDistance, yd, and/or offset
|
||||
bool inStaff = placeAbove() ? r.bottom() + rebase > 0.0 : r.top() + rebase < staff()->height();
|
||||
|
@ -216,7 +216,7 @@ void Fingering::layout()
|
|||
// restore autoplace
|
||||
setAutoplace(true);
|
||||
}
|
||||
else if (offsetChanged()) {
|
||||
else if (offsetChanged() != OffsetChange::NONE) {
|
||||
// rebase horizontally too, as autoplace may have adjusted it
|
||||
rebaseOffset(false);
|
||||
}
|
||||
|
|
|
@ -252,7 +252,7 @@ void HairpinSegment::layout()
|
|||
|
||||
// rebase vertical offset on drag
|
||||
qreal rebase = 0.0;
|
||||
if (offsetChanged())
|
||||
if (offsetChanged() != OffsetChange::NONE)
|
||||
rebase = rebaseOffset();
|
||||
|
||||
if (autoplace()) {
|
||||
|
@ -283,7 +283,7 @@ void HairpinSegment::layout()
|
|||
}
|
||||
qreal yd = ymax - pos().y();
|
||||
if (yd != 0.0) {
|
||||
if (offsetChanged()) {
|
||||
if (offsetChanged() != OffsetChange::NONE) {
|
||||
// user moved element within the skyline
|
||||
// we may need to adjust minDistance, yd, and/or offset
|
||||
qreal adj = pos().y() + rebase;
|
||||
|
|
|
@ -1354,7 +1354,7 @@ void SpannerSegment::autoplaceSpannerSegment()
|
|||
|
||||
// rebase vertical offset on drag
|
||||
qreal rebase = 0.0;
|
||||
if (offsetChanged())
|
||||
if (offsetChanged() != OffsetChange::NONE)
|
||||
rebase = rebaseOffset();
|
||||
|
||||
if (autoplace()) {
|
||||
|
@ -1377,7 +1377,7 @@ void SpannerSegment::autoplaceSpannerSegment()
|
|||
yd = d + md;
|
||||
}
|
||||
if (yd != 0.0) {
|
||||
if (offsetChanged()) {
|
||||
if (offsetChanged() != OffsetChange::NONE) {
|
||||
// user moved element within the skyline
|
||||
// we may need to adjust minDistance, yd, and/or offset
|
||||
qreal adj = pos().y() + rebase;
|
||||
|
|
Loading…
Reference in a new issue