MuseScore/libmscore/stafftext.cpp
Marc Sabatella a780a36dea fix #301259
Resolves: https://musescore.org/en/node/301259

See also https://github.com/musescore/MuseScore/pull/5728/

The problem occurs in several different overrides to
getPropertyStyle() for various different text classes.
The function is supposed to determine
which Sid to use for Pid::OFFSET, based on placement above/below.
But that calculation should only be relevant
if the element is using the default text style for its type.
Otherwise it should use the offset in the current text style.

This code removes the overrides for getPropertyStyle() in each class,
instead modifying TextBase::getPropertyStyle() to check
if the element is using its default text style or not,
and then only if so does it use the placement to select a Sid.
Otherwise it uses the offset of the current text style.
2020-04-15 18:07:27 -06:00

66 lines
1.8 KiB
C++

//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2008-2011 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#include "score.h"
#include "stafftext.h"
#include "system.h"
#include "staff.h"
#include "xml.h"
#include "measure.h"
namespace Ms {
//---------------------------------------------------------
// staffStyle
//---------------------------------------------------------
static const ElementStyle staffStyle {
{ Sid::staffTextPlacement, Pid::PLACEMENT },
{ Sid::staffTextMinDistance, Pid::MIN_DISTANCE },
};
//---------------------------------------------------------
// StaffText
//---------------------------------------------------------
StaffText::StaffText(Score* s, Tid tid)
: StaffTextBase(s, tid, ElementFlag::MOVABLE | ElementFlag::ON_STAFF)
{
initElementStyle(&staffStyle);
}
//---------------------------------------------------------
// layout
//---------------------------------------------------------
void StaffText::layout()
{
TextBase::layout();
autoplaceSegmentElement();
}
//---------------------------------------------------------
// propertyDefault
//---------------------------------------------------------
QVariant StaffText::propertyDefault(Pid id) const
{
switch(id) {
case Pid::SUB_STYLE:
return int(Tid::STAFF);
default:
return StaffTextBase::propertyDefault(id);
}
}
}