MuseScore/libmscore/systemtext.cpp

67 lines
2 KiB
C++
Raw Normal View History

2017-01-20 11:05:52 +01:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 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 "systemtext.h"
namespace Ms {
2018-08-01 11:46:07 +02:00
static const ElementStyle systemStyle {
{ Sid::systemTextPlacement, Pid::PLACEMENT },
};
2017-01-20 11:05:52 +01:00
//---------------------------------------------------------
// SystemText
//---------------------------------------------------------
SystemText::SystemText(Score* s)
2018-08-01 11:46:07 +02:00
: StaffTextBase(s, Tid::SYSTEM, ElementFlag::SYSTEM)
2017-01-20 11:05:52 +01:00
{
2018-08-01 11:46:07 +02:00
initElementStyle(&systemStyle);
2017-01-20 11:05:52 +01:00
}
2018-08-01 11:46:07 +02:00
SystemText::SystemText(Score* s, Tid tid, ElementFlags flags)
: StaffTextBase(s, tid, flags)
2017-01-23 10:54:57 +01:00
{
2018-08-01 11:46:07 +02:00
initElementStyle(&systemStyle);
2017-01-23 10:54:57 +01:00
}
2017-01-20 11:05:52 +01:00
//---------------------------------------------------------
// propertyDefault
//---------------------------------------------------------
2018-03-27 15:36:00 +02:00
QVariant SystemText::propertyDefault(Pid id) const
2017-01-20 11:05:52 +01:00
{
switch (id) {
2018-03-27 15:36:00 +02:00
case Pid::SUB_STYLE:
2018-08-01 11:46:07 +02:00
return int(Tid::SYSTEM);
2017-01-20 11:05:52 +01:00
default:
2017-12-27 11:51:00 +01:00
return TextBase::propertyDefault(id);
2017-01-20 11:05:52 +01:00
}
}
//---------------------------------------------------------
// layout
//---------------------------------------------------------
void SystemText::layout()
{
Staff* s = staff();
qreal y = placeAbove() ? styleP(Sid::systemTextPosAbove) : styleP(Sid::systemTextPosBelow) + (s ? s->height() : 0.0);
QPointF o(offset() * (offsetType() == OffsetType::SPATIUM ? spatium() : DPI));
setPos(o + QPointF(0.0, y));
TextBase::layout1();
autoplaceSegmentElement(styleP(Sid::systemTextMinDistance));
}
2017-01-20 11:05:52 +01:00
} // namespace Ms