Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/engraving/dom/fermata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "types/symnames.h"
#include "types/translatablestring.h"

#include "beam.h"
#include "chord.h"
#include "chordrest.h"
#include "measure.h"
Expand Down Expand Up @@ -258,6 +259,20 @@ double Fermata::mag() const
return m;
}

staff_idx_t Fermata::vStaffIdx() const
{
if (segment() && segment()->element(track())) {
if (segment()->isChordRestType()) {
const ChordRest* cr = toChordRest(segment()->element(track()));
if (cr->beam() && cr->beam()->cross() && (placeAbove() == cr->isBelowCrossBeam(cr->beam()))) {
return cr->staffIdx() + cr->beam()->crossStaffIdx() - placeAbove() ? 0 : 1;
}
}
return segment()->element(track())->vStaffIdx();
}
return staffIdx();
}

void Fermata::setSymIdAndTimeStretch(SymId id)
{
m_symId = id;
Expand Down
1 change: 1 addition & 0 deletions src/engraving/dom/fermata.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Fermata final : public EngravingItem
Fermata* clone() const override { return new Fermata(*this); }

double mag() const override;
staff_idx_t vStaffIdx() const override;

SymId symId() const { return m_symId; }
void setSymId(SymId id) { m_symId = id; }
Expand Down
30 changes: 19 additions & 11 deletions src/engraving/rendering/score/tlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,8 @@ void TLayout::layoutExpression(const Expression* item, Expression::LayoutData* l
void TLayout::layoutFermata(const Fermata* item, Fermata::LayoutData* ldata)
{
LAYOUT_CALL_ITEM(item);
const StaffType* stType = item->staffType();
const Staff* vStaff = item->score()->staff(item->vStaffIdx());
const StaffType* stType = vStaff->staffTypeForElement(item);
if (stType && stType->isHiddenElementOnTab(Sid::fermataShowTabCommon, Sid::fermataShowTabSimple)) {
ldata->setIsSkipDraw(true);
return;
Expand All @@ -2191,22 +2192,31 @@ void TLayout::layoutFermata(const Fermata* item, Fermata::LayoutData* ldata)
}

double x = 0.0;
double y = item->placeAbove() ? 0.0 : item->staff()->staffHeight(item->tick());
double y = item->placeAbove() ? 0.0 : vStaff->staffHeight(item->tick());
const Segment* s = item->segment();
const EngravingItem* e = s->element(item->track());

Shape staffShape = s->staffShape(item->vStaffIdx());
staffShape.removeTypes({ ElementType::FERMATA });

if (e) {
LD_CONDITION(e->ldata()->isSetBbox()); // e->shape()
LD_CONDITION(e->ldata()->isSetPos());

if (e->isChord()) {
const Chord* chord = toChord(e);
x = chord->x() + ChordLayout::centerX(chord);
} else if (e->isRest()) {
const Rest* rest = toRest(e);
x = rest->x() + rest->centerX();
if (e->isChordRest()) {
if (e->isChord()) {
const Chord* chord = toChord(e);
x = chord->x() + ChordLayout::centerX(chord);
} else if (e->isRest()) {
const Rest* rest = toRest(e);
x = rest->x() + rest->centerX();
}
const Beam* beam = toChordRest(e)->beam();
if (beam && beam->cross()) {
// staffShape.add(beam->shape().translate(beam->pagePos() - s->pagePos()));
}
} else {
x = e->x() - e->shape().left() + e->width() * item->staff()->staffMag(Fraction(0, 1)) * .5;
x = e->x() - e->shape().left() + e->width() * vStaff->staffMag(Fraction(0, 1)) * .5;
}
}

Expand All @@ -2229,8 +2239,6 @@ void TLayout::layoutFermata(const Fermata* item, Fermata::LayoutData* ldata)
if (item->isStyled(Pid::OFFSET)) {
y += item->offset().y();
}
Shape staffShape = item->segment()->staffShape(item->staffIdx());
staffShape.removeTypes({ ElementType::FERMATA });
if (item->placeAbove()) {
double minDist = ldata->shape().minVerticalDistance(staffShape) + item->minDistance().toMM(item->spatium());
y = std::min(y, -minDist);
Expand Down
Binary file added vtest/scores/fermata-7.mscz
Binary file not shown.
Loading