ported #6461: Better handling of Clefs Barlines on ossias and cutaway
This commit is contained in:
parent
0f01722a88
commit
dadecc070a
5 changed files with 122 additions and 2 deletions
|
@ -1284,7 +1284,7 @@ void BarLine::endEditDrag(EditData& ed)
|
|||
newSpanTo = 0;
|
||||
}
|
||||
|
||||
bool localDrag = ed.control() || segment()->isBarLine();
|
||||
bool localDrag = ed.control() || segment()->isBarLineType();
|
||||
if (localDrag) {
|
||||
Segment* s = segment();
|
||||
for (int staffIdx = staffIdx1; staffIdx < staffIdx2; ++staffIdx) {
|
||||
|
|
|
@ -215,8 +215,16 @@ Measure::Measure(const Measure& m)
|
|||
|
||||
void Measure::layoutStaffLines()
|
||||
{
|
||||
int staffIdx = 0;
|
||||
for (MStaff* ms : m_mstaves) {
|
||||
ms->lines()->layout();
|
||||
if (isCutawayClef(staffIdx) && (score()->staff(staffIdx)->cutaway() || !visible(staffIdx))) {
|
||||
// draw short staff lines for a courtesy clef on a hidden measure
|
||||
ms->lines()->layoutPartialWidth(width(), 4.0, true);
|
||||
} else {
|
||||
// normal staff lines
|
||||
ms->lines()->layout();
|
||||
}
|
||||
staffIdx += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2795,6 +2803,7 @@ bool Measure::isEmpty(int staffIdx) const
|
|||
{
|
||||
int strack;
|
||||
int etrack;
|
||||
bool hasStaves = score()->staff(staffIdx)->part()->staves()->size() > 1;
|
||||
if (staffIdx < 0) {
|
||||
strack = 0;
|
||||
etrack = score()->nstaves() * VOICES;
|
||||
|
@ -2808,6 +2817,21 @@ bool Measure::isEmpty(int staffIdx) const
|
|||
if (e && !e->isRest()) {
|
||||
return false;
|
||||
}
|
||||
// Check for cross-staff chords
|
||||
if (hasStaves) {
|
||||
if (strack >= VOICES) {
|
||||
e = s->element(track - VOICES);
|
||||
if (e && !e->isRest() && e->vStaffIdx() == staffIdx) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (etrack < score()->nstaves() * VOICES) {
|
||||
e = s->element(track + VOICES);
|
||||
if (e && !e->isRest() && e->vStaffIdx() == staffIdx) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Element* a : s->annotations()) {
|
||||
if (!a || a->systemFlag() || !a->visible() || a->isFermata()) {
|
||||
|
@ -2822,6 +2846,53 @@ bool Measure::isEmpty(int staffIdx) const
|
|||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// isCutawayClef
|
||||
/// Check for empty measure with only
|
||||
/// a Courtesy Clef before End Bar Line
|
||||
//---------------------------------------------------------
|
||||
|
||||
bool Measure::isCutawayClef(int staffIdx) const
|
||||
{
|
||||
if (!score()->staff(staffIdx) || !m_mstaves[staffIdx]) {
|
||||
return false;
|
||||
}
|
||||
bool empty = (score()->staff(staffIdx)->cutaway() && isEmpty(staffIdx)) || !m_mstaves[staffIdx]->visible();
|
||||
if (!empty) {
|
||||
return false;
|
||||
}
|
||||
int strack;
|
||||
int etrack;
|
||||
if (staffIdx < 0) {
|
||||
strack = 0;
|
||||
etrack = score()->nstaves() * VOICES;
|
||||
} else {
|
||||
strack = staffIdx * VOICES;
|
||||
etrack = strack + VOICES;
|
||||
}
|
||||
// find segment before EndBarLine
|
||||
Segment* s = nullptr;
|
||||
for (Segment* ls = last(); ls; ls = ls->prev()) {
|
||||
if (ls->segmentType() == SegmentType::EndBarLine) {
|
||||
s = ls->prev();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!s) {
|
||||
return false;
|
||||
}
|
||||
for (int track = strack; track < etrack; ++track) {
|
||||
Element* e = s->element(track);
|
||||
if (!e || !e->isClef()) {
|
||||
continue;
|
||||
}
|
||||
if ((nextMeasure() && (nextMeasure()->system() == system())) || toClef(e)->showCourtesy()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// isFullMeasureRest
|
||||
// Check for an empty measure, filled with full measure
|
||||
|
|
|
@ -252,6 +252,7 @@ public:
|
|||
void checkMultiVoices(int staffIdx);
|
||||
bool hasVoice(int track) const;
|
||||
bool isEmpty(int staffIdx) const;
|
||||
bool isCutawayClef(int staffIdx) const;
|
||||
bool isFullMeasureRest() const;
|
||||
bool visible(int staffIdx) const;
|
||||
bool stemless(int staffIdx) const;
|
||||
|
|
|
@ -122,6 +122,53 @@ void StaffLines::layoutForWidth(qreal w)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// layoutPartialWidth
|
||||
/// Layout staff lines for the specified width only, aligned
|
||||
/// to the left or right of the measure
|
||||
//---------------------------------------------------------
|
||||
|
||||
void StaffLines::layoutPartialWidth(qreal w, qreal wPartial, bool alignRight)
|
||||
{
|
||||
const Staff* s = staff();
|
||||
qreal _spatium = spatium();
|
||||
wPartial *= spatium();
|
||||
qreal dist = _spatium;
|
||||
setPos(QPointF(0.0, 0.0));
|
||||
int _lines;
|
||||
if (s) {
|
||||
setMag(s->staffMag(measure()->tick()));
|
||||
setColor(s->color(measure()->tick()));
|
||||
const StaffType* st = s->staffType(measure()->tick());
|
||||
dist *= st->lineDistance().val();
|
||||
_lines = st->lines();
|
||||
rypos() = st->yoffset().val() * _spatium;
|
||||
} else {
|
||||
_lines = 5;
|
||||
setColor(MScore::defaultColor);
|
||||
}
|
||||
lw = score()->styleS(Sid::staffLineWidth).val() * _spatium;
|
||||
qreal x1 = pos().x();
|
||||
qreal x2 = x1 + w;
|
||||
qreal y = pos().y();
|
||||
bbox().setRect(x1, -lw * .5 + y, w, (_lines - 1) * dist + lw);
|
||||
|
||||
if (_lines == 1) {
|
||||
qreal extraSize = _spatium;
|
||||
bbox().adjust(0, -extraSize, 0, extraSize);
|
||||
}
|
||||
|
||||
lines.clear();
|
||||
for (int i = 0; i < _lines; ++i) {
|
||||
if (alignRight) {
|
||||
lines.push_back(QLineF(x2 - wPartial, y, x2, y));
|
||||
} else {
|
||||
lines.push_back(QLineF(x1, y, x1 + wPartial, y));
|
||||
}
|
||||
y += dist;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// draw
|
||||
//---------------------------------------------------------
|
||||
|
|
|
@ -40,5 +40,6 @@ public:
|
|||
Measure* measure() const { return (Measure*)parent(); }
|
||||
qreal y1() const;
|
||||
void layoutForWidth(qreal width);
|
||||
void layoutPartialWidth(qreal w, qreal wPartial, bool alignLeft);
|
||||
};
|
||||
} // namespace Ms
|
||||
|
|
Loading…
Reference in a new issue