@@ -2178,7 +2178,8 @@ void TLayout::layoutExpression(const Expression* item, Expression::LayoutData* l
2178
2178
void TLayout::layoutFermata (const Fermata* item, Fermata::LayoutData* ldata)
2179
2179
{
2180
2180
LAYOUT_CALL_ITEM (item);
2181
- const StaffType* stType = item->staffType ();
2181
+ const Staff* vStaff = item->score ()->staff (item->vStaffIdx ());
2182
+ const StaffType* stType = vStaff->staffTypeForElement (item);
2182
2183
if (stType && stType->isHiddenElementOnTab (Sid::fermataShowTabCommon, Sid::fermataShowTabSimple)) {
2183
2184
ldata->setIsSkipDraw (true );
2184
2185
return ;
@@ -2191,22 +2192,31 @@ void TLayout::layoutFermata(const Fermata* item, Fermata::LayoutData* ldata)
2191
2192
}
2192
2193
2193
2194
double x = 0.0 ;
2194
- double y = item->placeAbove () ? 0.0 : item-> staff () ->staffHeight (item->tick ());
2195
+ double y = item->placeAbove () ? 0.0 : vStaff ->staffHeight (item->tick ());
2195
2196
const Segment* s = item->segment ();
2196
2197
const EngravingItem* e = s->element (item->track ());
2197
2198
2199
+ Shape staffShape = s->staffShape (item->vStaffIdx ());
2200
+ staffShape.removeTypes ({ ElementType::FERMATA });
2201
+
2198
2202
if (e) {
2199
2203
LD_CONDITION (e->ldata ()->isSetBbox ()); // e->shape()
2200
2204
LD_CONDITION (e->ldata ()->isSetPos ());
2201
2205
2202
- if (e->isChord ()) {
2203
- const Chord* chord = toChord (e);
2204
- x = chord->x () + ChordLayout::centerX (chord);
2205
- } else if (e->isRest ()) {
2206
- const Rest* rest = toRest (e);
2207
- x = rest->x () + rest->centerX ();
2206
+ if (e->isChordRest ()) {
2207
+ if (e->isChord ()) {
2208
+ const Chord* chord = toChord (e);
2209
+ x = chord->x () + ChordLayout::centerX (chord);
2210
+ } else if (e->isRest ()) {
2211
+ const Rest* rest = toRest (e);
2212
+ x = rest->x () + rest->centerX ();
2213
+ }
2214
+ const Beam* beam = toChordRest (e)->beam ();
2215
+ if (beam && beam->cross ()) {
2216
+ // staffShape.add(beam->shape().translate(beam->pagePos() - s->pagePos()));
2217
+ }
2208
2218
} else {
2209
- x = e->x () - e->shape ().left () + e->width () * item-> staff () ->staffMag (Fraction (0 , 1 )) * .5 ;
2219
+ x = e->x () - e->shape ().left () + e->width () * vStaff ->staffMag (Fraction (0 , 1 )) * .5 ;
2210
2220
}
2211
2221
}
2212
2222
@@ -2229,8 +2239,6 @@ void TLayout::layoutFermata(const Fermata* item, Fermata::LayoutData* ldata)
2229
2239
if (item->isStyled (Pid::OFFSET)) {
2230
2240
y += item->offset ().y ();
2231
2241
}
2232
- Shape staffShape = item->segment ()->staffShape (item->staffIdx ());
2233
- staffShape.removeTypes ({ ElementType::FERMATA });
2234
2242
if (item->placeAbove ()) {
2235
2243
double minDist = ldata->shape ().minVerticalDistance (staffShape) + item->minDistance ().toMM (item->spatium ());
2236
2244
y = std::min (y, -minDist);
0 commit comments