MuseScore/libmscore/hairpin.cpp

667 lines
23 KiB
C++
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// 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 "hairpin.h"
#include "style.h"
#include "xml.h"
#include "utils.h"
#include "score.h"
#include "measure.h"
#include "segment.h"
#include "system.h"
#include "undo.h"
#include "staff.h"
#include "mscore.h"
2013-05-13 18:49:17 +02:00
namespace Ms {
Spatium Hairpin::editHairpinHeight;
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// layout
//---------------------------------------------------------
void HairpinSegment::layout()
{
2015-08-23 22:08:14 +02:00
if (hairpin()->useTextLine()) {
2015-08-30 23:51:17 +02:00
// layout as textline rather than true hairpin
// use dynamics text style for position, so the text aligns with dynamics
// TODO: new style setting specifically for vertical offset of textline hairpins?
// or, use hairpinY but adjust by 0.5sp, which currently yields same vertical position as dynamics
2015-08-23 22:08:14 +02:00
if (parent())
2015-08-30 23:51:17 +02:00
rypos() += score()->textStyle(TextStyleType::DYNAMICS).offset(spatium()).y();
2015-08-23 22:08:14 +02:00
TextLineSegment::layout();
return;
}
2012-05-26 14:26:10 +02:00
QTransform t;
qreal _spatium = spatium();
2013-08-13 14:26:40 +02:00
qreal h1 = hairpin()->hairpinHeight().val() * spatium() * .5;
qreal h2 = hairpin()->hairpinContHeight().val() * spatium() * .5;
2012-05-26 14:26:10 +02:00
qreal len;
qreal x = pos2().x();
if (x < _spatium) // minimum size of hairpin
x = _spatium;
qreal y = pos2().y();
len = sqrt(x * x + y * y);
t.rotateRadians(asin(y/len));
drawCircledTip = hairpin()->hairpinCircledTip();
circledTipRadius = 0;
if( drawCircledTip )
circledTipRadius = 0.6 * _spatium * .5;
if (hairpin()->hairpinType() == Hairpin::Type::CRESCENDO) {
2012-05-26 14:26:10 +02:00
// crescendo
switch (spannerSegmentType()) {
case SpannerSegmentType::SINGLE:
case SpannerSegmentType::BEGIN:
l1.setLine(.0 + circledTipRadius*2, .0, len, h1);
l2.setLine(.0 + circledTipRadius*2, .0, len, -h1);
circledTip.setX( 0 + circledTipRadius );
circledTip.setY( 0 );
2012-05-26 14:26:10 +02:00
break;
case SpannerSegmentType::MIDDLE:
case SpannerSegmentType::END:
drawCircledTip = false;
2012-08-23 17:40:04 +02:00
l1.setLine(.0, h2, len, h1);
l2.setLine(.0, -h2, len, -h1);
2012-05-26 14:26:10 +02:00
break;
}
}
else {
// decrescendo
switch(spannerSegmentType()) {
case SpannerSegmentType::SINGLE:
case SpannerSegmentType::END:
l1.setLine(.0, h1, len - circledTipRadius*2, 0.0);
l2.setLine(.0, -h1, len - circledTipRadius*2, 0.0);
circledTip.setX( len - circledTipRadius );
circledTip.setY( 0 );
2012-05-26 14:26:10 +02:00
break;
case SpannerSegmentType::BEGIN:
case SpannerSegmentType::MIDDLE:
drawCircledTip = false;
2012-08-23 17:40:04 +02:00
l1.setLine(.0, h1, len, + h2);
l2.setLine(.0, -h1, len, - h2);
2012-05-26 14:26:10 +02:00
break;
}
}
// Do Coord rotation
2012-05-26 14:26:10 +02:00
l1 = t.map(l1);
l2 = t.map(l2);
if( drawCircledTip )
circledTip = t.map(circledTip);
2012-05-26 14:26:10 +02:00
QRectF r = QRectF(l1.p1(), l1.p2()).normalized() | QRectF(l2.p1(), l2.p2()).normalized();
2014-05-26 15:31:36 +02:00
qreal w = point(score()->styleS(StyleIdx::hairpinLineWidth));
2012-05-26 14:26:10 +02:00
setbbox(r.adjusted(-w*.5, -w*.5, w, w));
2012-11-08 12:59:30 +01:00
if (parent())
2014-05-26 15:31:36 +02:00
rypos() += score()->styleS(StyleIdx::hairpinY).val() * _spatium;
2012-10-27 14:46:35 +02:00
adjustReadPos();
2012-05-26 14:26:10 +02:00
}
2013-07-26 15:26:18 +02:00
//---------------------------------------------------------
// updateGrips
//---------------------------------------------------------
void HairpinSegment::updateGrips(Grip* defaultGrip, QVector<QRectF>& grip) const
2013-07-26 15:26:18 +02:00
{
*defaultGrip = Grip::END;
2014-03-16 14:57:32 +01:00
2013-07-26 15:26:18 +02:00
QPointF pp(pagePos());
qreal _spatium = spatium();
qreal x = pos2().x();
if (x < _spatium) // minimum size of hairpin
x = _spatium;
qreal y = pos2().y();
QPointF p(x, y);
2014-02-26 21:28:00 +01:00
// Calc QPointF for Grip Aperture
QTransform doRotation;
QPointF gripLineAperturePoint;
qreal h1 = hairpin()->hairpinHeight().val() * spatium() * .5;
qreal len = sqrt( x * x + y * y );
doRotation.rotateRadians( asin(y/len) );
qreal lineApertureX;
qreal offsetX = 10; // Horizontal offset for x Grip
if(len < offsetX * 3 ) // For small hairpin, offset = 30% of len
offsetX = len/3; // else offset is fixed to 10
2014-02-26 21:28:00 +01:00
if( hairpin()->hairpinType() == Hairpin::Type::CRESCENDO )
2014-02-26 21:28:00 +01:00
lineApertureX = len - offsetX; // End of CRESCENDO - Offset
else
lineApertureX = offsetX; // Begin of DECRESCENDO + Offset
qreal lineApertureH = ( len - offsetX ) * h1/len; // Vertical position for y grip
gripLineAperturePoint.setX( lineApertureX );
gripLineAperturePoint.setY( lineApertureH );
gripLineAperturePoint = doRotation.map( gripLineAperturePoint );
// End calc position grip aperture
grip[int(Grip::START)].translate( pp );
grip[int(Grip::END)].translate( p + pp );
grip[int(Grip::MIDDLE)].translate( p * .5 + pp );
grip[int(Grip::APERTURE)].translate( gripLineAperturePoint + pp );
2014-02-26 21:28:00 +01:00
}
2014-02-26 21:28:00 +01:00
//---------------------------------------------------------
// editDrag
//---------------------------------------------------------
void HairpinSegment::editDrag(const EditData& ed)
{
if (ed.curGrip == Grip::APERTURE) {
qreal newHeight = hairpin()->hairpinHeight().val() + ed.delta.y()/spatium()/.5;
if (newHeight < 0.5)
newHeight = 0.5;
hairpin()->setHairpinHeight(Spatium(newHeight));
2016-03-02 13:20:19 +01:00
score()->setLayoutAll();
}
LineSegment::editDrag(ed);
2013-07-26 15:26:18 +02:00
}
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// draw
//---------------------------------------------------------
void HairpinSegment::draw(QPainter* painter) const
{
2015-08-23 22:08:14 +02:00
if (hairpin()->useTextLine()) {
TextLineSegment::draw(painter);
return;
}
2013-05-02 16:12:17 +02:00
QColor color;
if (selected() && !(score() && score()->printing()))
color = (track() > -1) ? MScore::selectColor[voice()] : MScore::selectColor[0];
else if (!hairpin()->visible()) // || !hairpin()->lineVisible()
2013-05-02 16:12:17 +02:00
color = Qt::gray;
else
color = hairpin()->lineColor();
QPen pen(color, point(hairpin()->lineWidth()), hairpin()->lineStyle());
2015-08-23 22:08:14 +02:00
if (hairpin()->lineStyle() == Qt::CustomDashLine) {
QVector<qreal> pattern;
pattern << 5.0 << 20.0;
pen.setDashPattern(pattern);
}
2012-05-26 14:26:10 +02:00
painter->setPen(pen);
2012-08-23 17:40:04 +02:00
painter->drawLine(l1);
painter->drawLine(l2);
if( drawCircledTip ) {
2015-08-23 22:08:14 +02:00
painter->setBrush(Qt::NoBrush);
painter->drawEllipse( circledTip,circledTipRadius,circledTipRadius );
}
2012-05-26 14:26:10 +02:00
}
2013-03-27 17:52:26 +01:00
//---------------------------------------------------------
// getProperty
//---------------------------------------------------------
QVariant HairpinSegment::getProperty(P_ID id) const
{
2013-05-02 16:12:17 +02:00
switch (id) {
case P_ID::HAIRPIN_TEXTLINE:
2014-05-26 18:18:01 +02:00
case P_ID::HAIRPIN_CIRCLEDTIP:
case P_ID::HAIRPIN_TYPE:
case P_ID::VELO_CHANGE:
case P_ID::DYNAMIC_RANGE:
case P_ID::DIAGONAL:
case P_ID::HAIRPIN_HEIGHT:
case P_ID::HAIRPIN_CONT_HEIGHT:
2013-05-02 16:12:17 +02:00
return hairpin()->getProperty(id);
default:
return TextLineSegment::getProperty(id);
2013-05-02 16:12:17 +02:00
}
2013-03-27 17:52:26 +01:00
}
//---------------------------------------------------------
// setProperty
//---------------------------------------------------------
bool HairpinSegment::setProperty(P_ID id, const QVariant& v)
{
2013-05-02 16:12:17 +02:00
switch (id) {
case P_ID::HAIRPIN_TEXTLINE:
2014-05-26 18:18:01 +02:00
case P_ID::HAIRPIN_CIRCLEDTIP:
case P_ID::HAIRPIN_TYPE:
case P_ID::VELO_CHANGE:
case P_ID::DYNAMIC_RANGE:
case P_ID::DIAGONAL:
case P_ID::LINE_WIDTH:
case P_ID::HAIRPIN_HEIGHT:
case P_ID::HAIRPIN_CONT_HEIGHT:
2013-05-02 16:12:17 +02:00
return hairpin()->setProperty(id, v);
default:
return TextLineSegment::setProperty(id, v);
2013-05-02 16:12:17 +02:00
}
2013-03-27 17:52:26 +01:00
}
//---------------------------------------------------------
// propertyDefault
//---------------------------------------------------------
QVariant HairpinSegment::propertyDefault(P_ID id) const
{
2013-05-02 16:12:17 +02:00
switch (id) {
case P_ID::HAIRPIN_TEXTLINE:
case P_ID::TEXT_STYLE_TYPE:
2014-05-26 18:18:01 +02:00
case P_ID::HAIRPIN_CIRCLEDTIP:
case P_ID::HAIRPIN_TYPE:
case P_ID::VELO_CHANGE:
case P_ID::DYNAMIC_RANGE:
case P_ID::DIAGONAL:
case P_ID::HAIRPIN_HEIGHT:
case P_ID::HAIRPIN_CONT_HEIGHT:
2013-05-02 16:12:17 +02:00
return hairpin()->propertyDefault(id);
default:
return TextLineSegment::propertyDefault(id);
2013-05-02 16:12:17 +02:00
}
2013-03-27 17:52:26 +01:00
}
2013-08-09 11:42:24 +02:00
//---------------------------------------------------------
// propertyStyle
//---------------------------------------------------------
PropertyStyle HairpinSegment::propertyStyle(P_ID id) const
{
switch (id) {
2014-05-26 18:18:01 +02:00
case P_ID::LINE_WIDTH:
case P_ID::HAIRPIN_HEIGHT:
case P_ID::HAIRPIN_CONT_HEIGHT:
2013-08-09 11:42:24 +02:00
return hairpin()->propertyStyle(id);
default:
return TextLineSegment::propertyStyle(id);
2013-08-09 11:42:24 +02:00
}
}
//---------------------------------------------------------
// resetProperty
//---------------------------------------------------------
void HairpinSegment::resetProperty(P_ID id)
{
switch (id) {
2014-05-26 18:18:01 +02:00
case P_ID::LINE_WIDTH:
case P_ID::HAIRPIN_HEIGHT:
case P_ID::HAIRPIN_CONT_HEIGHT:
2013-08-09 11:42:24 +02:00
return hairpin()->resetProperty(id);
default:
return TextLineSegment::resetProperty(id);
2013-08-09 11:42:24 +02:00
}
}
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// Hairpin
//---------------------------------------------------------
Hairpin::Hairpin(Score* s)
2015-08-23 22:08:14 +02:00
: TextLine(s)
2012-05-26 14:26:10 +02:00
{
_hairpinType = Type::CRESCENDO;
2015-08-23 22:08:14 +02:00
_useTextLine = false;
_hairpinCircledTip = false;
_veloChange = 0;
_dynRange = Dynamic::Range::PART;
2014-05-26 15:31:36 +02:00
setLineWidth(score()->styleS(StyleIdx::hairpinLineWidth));
2013-08-13 14:26:40 +02:00
lineWidthStyle = PropertyStyle::STYLED;
2014-05-26 15:31:36 +02:00
_hairpinHeight = score()->styleS(StyleIdx::hairpinHeight);
2013-08-13 14:26:40 +02:00
hairpinHeightStyle = PropertyStyle::STYLED;
2014-05-26 15:31:36 +02:00
_hairpinContHeight = score()->styleS(StyleIdx::hairpinContHeight);
2013-08-13 14:26:40 +02:00
hairpinContHeightStyle = PropertyStyle::STYLED;
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// layout
// compute segments from tick() to _tick2
//---------------------------------------------------------
void Hairpin::layout()
{
setPos(0.0, 0.0);
2015-08-23 22:08:14 +02:00
TextLine::layout();
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// createLineSegment
//---------------------------------------------------------
LineSegment* Hairpin::createLineSegment()
{
return new HairpinSegment(score());
}
//---------------------------------------------------------
// write
//---------------------------------------------------------
void Hairpin::write(Xml& xml) const
{
2014-08-13 15:42:40 +02:00
if (!xml.canWrite(this))
return;
2014-07-21 13:24:21 +02:00
int id = xml.spannerId(this);
xml.stag(QString("%1 id=\"%2\"").arg(name()).arg(id));
2014-05-21 15:45:01 +02:00
xml.tag("subtype", int(_hairpinType));
2015-08-23 22:08:14 +02:00
if (_useTextLine)
xml.tag("useTextLine", true);
writeProperty(xml, P_ID::VELO_CHANGE);
2014-05-26 18:18:01 +02:00
writeProperty(xml, P_ID::HAIRPIN_CIRCLEDTIP);
writeProperty(xml, P_ID::DYNAMIC_RANGE);
writeProperty(xml, P_ID::PLACEMENT);
writeProperty(xml, P_ID::HAIRPIN_HEIGHT);
writeProperty(xml, P_ID::HAIRPIN_CONT_HEIGHT);
2015-08-23 22:08:14 +02:00
TextLine::writeProperties(xml);
2012-05-26 14:26:10 +02:00
xml.etag();
}
//---------------------------------------------------------
// read
//---------------------------------------------------------
2013-01-11 18:10:18 +01:00
void Hairpin::read(XmlReader& e)
2012-05-26 14:26:10 +02:00
{
foreach(SpannerSegment* seg, spannerSegments())
delete seg;
spannerSegments().clear();
2013-01-11 18:10:18 +01:00
2014-07-21 13:24:21 +02:00
int id = e.intAttribute("id", -1);
e.addSpanner(id, this);
2013-01-11 18:10:18 +01:00
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
2012-05-26 14:26:10 +02:00
if (tag == "subtype")
_hairpinType = Type(e.readInt());
2013-08-09 11:42:24 +02:00
else if (tag == "lineWidth") {
setLineWidth(Spatium(e.readDouble()));
lineWidthStyle = PropertyStyle::UNSTYLED;
}
2013-08-13 14:26:40 +02:00
else if (tag == "hairpinHeight") {
setHairpinHeight(Spatium(e.readDouble()));
hairpinHeightStyle = PropertyStyle::UNSTYLED;
}
else if (tag == "hairpinContHeight") {
setHairpinContHeight(Spatium(e.readDouble()));
hairpinContHeightStyle = PropertyStyle::UNSTYLED;
}
else if (tag == "hairpinCircledTip")
_hairpinCircledTip = e.readInt();
2012-05-26 14:26:10 +02:00
else if (tag == "veloChange")
2013-01-11 18:10:18 +01:00
_veloChange = e.readInt();
else if (tag == "dynType")
_dynRange = Dynamic::Range(e.readInt());
2015-08-23 22:08:14 +02:00
else if (tag == "useTextLine")
_useTextLine = e.readInt();
else if (!TextLine::readProperties(e))
2013-01-11 18:10:18 +01:00
e.unknown();
2012-05-26 14:26:10 +02:00
}
2015-09-03 18:00:11 +02:00
// add default text to legacy hairpins
if (score()->mscVersion() <= 206 && !_useTextLine) {
2015-09-03 18:00:11 +02:00
bool cresc = _hairpinType == Hairpin::Type::CRESCENDO;
if (!_beginText)
setBeginText(cresc ? "cresc." : "dim.");
if (!_continueText)
setContinueText(cresc ? "(cresc.)" : "(dim.)");
2015-09-03 18:00:11 +02:00
}
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// undoSetHairpinType
//---------------------------------------------------------
void Hairpin::undoSetHairpinType(Type val)
{
2016-06-09 09:26:13 +02:00
undoChangeProperty(P_ID::HAIRPIN_TYPE, int(val));
}
//---------------------------------------------------------
// undoSetVeloChange
//---------------------------------------------------------
void Hairpin::undoSetVeloChange(int val)
{
2016-06-09 09:26:13 +02:00
undoChangeProperty(P_ID::VELO_CHANGE, val);
}
//---------------------------------------------------------
// undoSetDynType
//---------------------------------------------------------
void Hairpin::undoSetDynRange(Dynamic::Range val)
{
2016-06-09 09:26:13 +02:00
undoChangeProperty(P_ID::DYNAMIC_RANGE, int(val));
}
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// getProperty
//---------------------------------------------------------
2012-08-10 17:01:35 +02:00
QVariant Hairpin::getProperty(P_ID id) const
2012-05-26 14:26:10 +02:00
{
2013-05-02 16:12:17 +02:00
switch (id) {
case P_ID::HAIRPIN_TEXTLINE:
return _useTextLine;
2014-05-26 18:18:01 +02:00
case P_ID::HAIRPIN_CIRCLEDTIP:
return _hairpinCircledTip;
2014-05-26 18:18:01 +02:00
case P_ID::HAIRPIN_TYPE:
2014-05-21 15:45:01 +02:00
return int(_hairpinType);
2014-05-26 18:18:01 +02:00
case P_ID::VELO_CHANGE:
return _veloChange;
2014-05-26 18:18:01 +02:00
case P_ID::DYNAMIC_RANGE:
return int(_dynRange);
2014-05-26 18:18:01 +02:00
case P_ID::HAIRPIN_HEIGHT:
2016-03-05 15:31:26 +01:00
return _hairpinHeight;
2014-05-26 18:18:01 +02:00
case P_ID::HAIRPIN_CONT_HEIGHT:
2016-03-05 15:31:26 +01:00
return _hairpinContHeight;
default:
2015-08-23 22:08:14 +02:00
return TextLine::getProperty(id);
}
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// setProperty
//---------------------------------------------------------
2012-08-10 17:01:35 +02:00
bool Hairpin::setProperty(P_ID id, const QVariant& v)
2012-05-26 14:26:10 +02:00
{
2013-05-02 16:12:17 +02:00
switch (id) {
case P_ID::HAIRPIN_TEXTLINE:
_useTextLine = v.toBool();
break;
2014-05-26 18:18:01 +02:00
case P_ID::HAIRPIN_CIRCLEDTIP:
_hairpinCircledTip = v.toBool();
break;
2014-05-26 18:18:01 +02:00
case P_ID::HAIRPIN_TYPE:
_hairpinType = Type(v.toInt());
setGenerated(false);
break;
2014-05-26 18:18:01 +02:00
case P_ID::VELO_CHANGE:
_veloChange = v.toInt();
break;
2014-05-26 18:18:01 +02:00
case P_ID::DYNAMIC_RANGE:
_dynRange = Dynamic::Range(v.toInt());
break;
2014-05-26 18:18:01 +02:00
case P_ID::LINE_WIDTH:
2013-08-09 11:42:24 +02:00
lineWidthStyle = PropertyStyle::UNSTYLED;
2015-08-23 22:08:14 +02:00
TextLine::setProperty(id, v);
2013-08-09 11:42:24 +02:00
break;
2014-05-26 18:18:01 +02:00
case P_ID::HAIRPIN_HEIGHT:
hairpinHeightStyle = PropertyStyle::UNSTYLED;
2016-03-05 15:31:26 +01:00
_hairpinHeight = v.value<Spatium>();
2013-08-13 14:26:40 +02:00
break;
2014-05-26 18:18:01 +02:00
case P_ID::HAIRPIN_CONT_HEIGHT:
2013-08-13 14:26:40 +02:00
hairpinContHeightStyle = PropertyStyle::UNSTYLED;
2016-03-05 15:31:26 +01:00
_hairpinContHeight = v.value<Spatium>();
2013-08-13 14:26:40 +02:00
break;
default:
2015-08-23 22:08:14 +02:00
return TextLine::setProperty(id, v);
2012-05-26 14:26:10 +02:00
}
2016-03-02 13:20:19 +01:00
score()->setLayoutAll();
return true;
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// propertyDefault
//---------------------------------------------------------
QVariant Hairpin::propertyDefault(P_ID id) const
{
2013-05-02 16:12:17 +02:00
switch (id) {
case P_ID::HAIRPIN_TEXTLINE: return _useTextLine; // HACK: treat current setting as default
case P_ID::TEXT_STYLE_TYPE: return int(TextStyleType::HAIRPIN);
2014-05-26 18:18:01 +02:00
case P_ID::HAIRPIN_CIRCLEDTIP: return false;
case P_ID::HAIRPIN_TYPE: return int(Type::CRESCENDO);
case P_ID::VELO_CHANGE: return 0;
case P_ID::DYNAMIC_RANGE: return int(Dynamic::Range::PART);
2016-03-05 15:31:26 +01:00
case P_ID::LINE_WIDTH: return score()->style(StyleIdx::hairpinLineWidth);
case P_ID::HAIRPIN_HEIGHT: return score()->style(StyleIdx::hairpinHeight);
case P_ID::HAIRPIN_CONT_HEIGHT: return score()->style(StyleIdx::hairpinContHeight);
2015-08-23 22:08:14 +02:00
case P_ID::LINE_STYLE: return _useTextLine ? int(Qt::CustomDashLine) : int(Qt::SolidLine);
2013-08-13 14:26:40 +02:00
default:
2015-08-23 22:08:14 +02:00
return TextLine::propertyDefault(id);
}
}
2013-08-09 11:42:24 +02:00
//---------------------------------------------------------
// propertyStyle
//---------------------------------------------------------
PropertyStyle Hairpin::propertyStyle(P_ID id) const
{
switch (id) {
2014-05-26 18:18:01 +02:00
case P_ID::LINE_WIDTH: return lineWidthStyle;
case P_ID::HAIRPIN_HEIGHT: return hairpinHeightStyle;
case P_ID::HAIRPIN_CONT_HEIGHT: return hairpinContHeightStyle;
2013-08-13 14:26:40 +02:00
default:
2015-08-23 22:08:14 +02:00
return TextLine::propertyStyle(id);
2013-08-09 11:42:24 +02:00
}
}
//---------------------------------------------------------
// resetProperty
//---------------------------------------------------------
void Hairpin::resetProperty(P_ID id)
{
switch (id) {
2014-05-26 18:18:01 +02:00
case P_ID::LINE_WIDTH:
2016-03-05 15:31:26 +01:00
setProperty(id, propertyDefault(id));
2013-08-09 11:42:24 +02:00
lineWidthStyle = PropertyStyle::STYLED;
break;
2014-05-26 18:18:01 +02:00
case P_ID::HAIRPIN_HEIGHT:
2016-03-05 15:31:26 +01:00
setProperty(id, propertyDefault(id));
2013-08-13 14:26:40 +02:00
hairpinHeightStyle = PropertyStyle::STYLED;
break;
2014-05-26 18:18:01 +02:00
case P_ID::HAIRPIN_CONT_HEIGHT:
2016-03-05 15:31:26 +01:00
setLineWidth(score()->styleS(StyleIdx::hairpinLineWidth));
2013-08-13 14:26:40 +02:00
hairpinContHeightStyle = PropertyStyle::STYLED;
break;
2013-08-09 11:42:24 +02:00
default:
2015-08-23 22:08:14 +02:00
return TextLine::resetProperty(id);
2013-08-09 11:42:24 +02:00
}
2016-03-02 13:20:19 +01:00
score()->setLayoutAll();
2013-08-09 11:42:24 +02:00
}
2013-03-27 17:52:26 +01:00
//---------------------------------------------------------
// setYoff
//---------------------------------------------------------
void Hairpin::setYoff(qreal val)
{
2014-05-26 15:31:36 +02:00
rUserYoffset() += (val - score()->styleS(StyleIdx::hairpinY).val()) * spatium();
2013-03-27 17:52:26 +01:00
}
2013-08-09 11:42:24 +02:00
//---------------------------------------------------------
// styleChanged
// reset all styled values to actual style
//---------------------------------------------------------
void Hairpin::styleChanged()
{
if (lineWidthStyle == PropertyStyle::STYLED)
2014-05-26 15:31:36 +02:00
setLineWidth(score()->styleS(StyleIdx::hairpinLineWidth));
2013-08-13 14:26:40 +02:00
if (hairpinHeightStyle == PropertyStyle::STYLED)
2014-05-26 15:31:36 +02:00
setHairpinHeight(score()->styleS(StyleIdx::hairpinHeight));
2013-08-13 14:26:40 +02:00
if (hairpinContHeightStyle == PropertyStyle::STYLED)
2014-05-26 15:31:36 +02:00
setHairpinContHeight(score()->styleS(StyleIdx::hairpinContHeight));
2013-08-09 11:42:24 +02:00
}
2013-08-09 13:19:54 +02:00
//---------------------------------------------------------
// reset
//---------------------------------------------------------
void Hairpin::reset()
{
if (lineWidthStyle == PropertyStyle::UNSTYLED)
2016-06-09 09:26:13 +02:00
undoChangeProperty(P_ID::LINE_WIDTH, propertyDefault(P_ID::LINE_WIDTH), PropertyStyle::STYLED);
2013-08-13 14:26:40 +02:00
if (hairpinHeightStyle == PropertyStyle::UNSTYLED)
2016-06-09 09:26:13 +02:00
undoChangeProperty(P_ID::HAIRPIN_HEIGHT, propertyDefault(P_ID::HAIRPIN_HEIGHT), PropertyStyle::STYLED);
2013-08-13 14:26:40 +02:00
if (hairpinContHeightStyle == PropertyStyle::UNSTYLED)
2016-06-09 09:26:13 +02:00
undoChangeProperty(P_ID::HAIRPIN_CONT_HEIGHT, propertyDefault(P_ID::HAIRPIN_CONT_HEIGHT), PropertyStyle::STYLED);
2015-08-23 22:08:14 +02:00
TextLine::reset();
2013-08-09 13:19:54 +02:00
}
//---------------------------------------------------------
// accessibleInfo
//---------------------------------------------------------
2016-02-04 17:06:32 +01:00
QString Hairpin::accessibleInfo() const
{
2015-08-23 22:08:14 +02:00
QString rez = TextLine::accessibleInfo();
switch (hairpinType()) {
case Type::CRESCENDO:
rez += ": " + tr("Crescendo");
break;
case Type::DECRESCENDO:
2015-08-23 22:08:14 +02:00
rez += ": " + tr("Decrescendo");
break;
default:
rez += ": " + tr("Custom");
}
return rez;
}
//---------------------------------------------------------
// startEdit
//---------------------------------------------------------
void Hairpin::startEdit(MuseScoreView* view, const QPointF& p)
{
editHairpinHeight = _hairpinHeight;
2015-08-23 22:08:14 +02:00
TextLine::startEdit(view, p);
}
//---------------------------------------------------------
// endEdit
//---------------------------------------------------------
void Hairpin::endEdit()
{
if (editHairpinHeight != _hairpinHeight)
2016-03-05 15:31:26 +01:00
score()->undoPropertyChanged(this, P_ID::HAIRPIN_HEIGHT, editHairpinHeight);
2015-08-23 22:08:14 +02:00
TextLine::endEdit();
}
2013-05-13 18:49:17 +02:00
}