111 lines
2.9 KiB
C++
111 lines
2.9 KiB
C++
//=============================================================================
|
|
// MuseScore
|
|
// Music Composition & Notation
|
|
//
|
|
// Copyright (C) 2002-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 "breath.h"
|
|
#include "sym.h"
|
|
#include "system.h"
|
|
#include "segment.h"
|
|
#include "measure.h"
|
|
#include "score.h"
|
|
#include "xml.h"
|
|
|
|
namespace Ms {
|
|
|
|
SymId Breath::symList[Breath::breathSymbols] = {
|
|
SymId::breathMark,
|
|
SymId::breathMark, // TODO-smufl SymId(lcommaSym),
|
|
SymId::caesura, // SymId(caesuraCurvedSym),
|
|
SymId::caesura
|
|
};
|
|
|
|
//---------------------------------------------------------
|
|
// Breath
|
|
//---------------------------------------------------------
|
|
|
|
Breath::Breath(Score* s)
|
|
: Element(s)
|
|
{
|
|
_breathType = 0;
|
|
setFlags(ELEMENT_MOVABLE | ELEMENT_SELECTABLE);
|
|
}
|
|
|
|
//---------------------------------------------------------
|
|
// layout
|
|
//---------------------------------------------------------
|
|
|
|
void Breath::layout()
|
|
{
|
|
setbbox(symBbox(symList[breathType()]));
|
|
}
|
|
|
|
//---------------------------------------------------------
|
|
// write
|
|
//---------------------------------------------------------
|
|
|
|
void Breath::write(Xml& xml) const
|
|
{
|
|
xml.stag("Breath");
|
|
xml.tag("subtype", _breathType);
|
|
Element::writeProperties(xml);
|
|
xml.etag();
|
|
}
|
|
|
|
//---------------------------------------------------------
|
|
// read
|
|
//---------------------------------------------------------
|
|
|
|
void Breath::read(XmlReader& e)
|
|
{
|
|
while (e.readNextStartElement()) {
|
|
if (e.name() == "subtype")
|
|
_breathType = e.readInt();
|
|
else if (!Element::readProperties(e))
|
|
e.unknown();
|
|
}
|
|
}
|
|
|
|
//---------------------------------------------------------
|
|
// draw
|
|
//---------------------------------------------------------
|
|
|
|
void Breath::draw(QPainter* p) const
|
|
{
|
|
p->setPen(curColor());
|
|
drawSymbol(symList[_breathType], p);
|
|
}
|
|
|
|
//---------------------------------------------------------
|
|
// space
|
|
//---------------------------------------------------------
|
|
|
|
Space Breath::space() const
|
|
{
|
|
return Space(0.0, spatium() * 1.5);
|
|
}
|
|
|
|
//---------------------------------------------------------
|
|
// pagePos
|
|
//---------------------------------------------------------
|
|
|
|
QPointF Breath::pagePos() const
|
|
{
|
|
if (parent() == 0)
|
|
return pos();
|
|
System* system = segment()->measure()->system();
|
|
qreal yp = y();
|
|
if (system)
|
|
yp += system->staff(staffIdx())->y() + system->y();
|
|
return QPointF(pageX(), yp);
|
|
}
|
|
|
|
}
|
|
|