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
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
#ifndef __TREMOLO_H__
|
|
|
|
#define __TREMOLO_H__
|
|
|
|
|
2018-12-19 14:36:02 +01:00
|
|
|
#include "durationtype.h"
|
2012-05-26 14:26:10 +02:00
|
|
|
#include "symbol.h"
|
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
namespace Ms {
|
|
|
|
class Chord;
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
// Tremolo subtypes:
|
2018-12-01 12:38:10 +01:00
|
|
|
enum class TremoloType : signed char {
|
2018-05-11 23:14:49 +02:00
|
|
|
INVALID_TREMOLO = -1,
|
2020-01-15 22:03:47 +01:00
|
|
|
R8 = 0, R16, R32, R64, BUZZ_ROLL, // one note tremolo (repeat)
|
2014-05-26 11:35:24 +02:00
|
|
|
C8, C16, C32, C64 // two note tremolo (change)
|
2012-05-26 14:26:10 +02:00
|
|
|
};
|
|
|
|
|
2019-06-10 14:07:15 +02:00
|
|
|
enum class TremoloPlacement : signed char {
|
2020-01-15 22:03:47 +01:00
|
|
|
DEFAULT = 0, STEM_CENTER
|
|
|
|
};
|
|
|
|
|
2020-01-17 12:14:50 +01:00
|
|
|
// only appliable to minim two-note tremolo in non-TAB staves
|
2020-04-16 10:36:29 +02:00
|
|
|
enum class TremoloStrokeStyle : signed char {
|
|
|
|
DEFAULT = 0, ALL_STROKES_ATTACHED
|
2019-06-10 14:07:15 +02:00
|
|
|
};
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
2012-07-25 11:49:34 +02:00
|
|
|
// @@ Tremolo
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2017-12-21 14:03:45 +01:00
|
|
|
class Tremolo final : public Element
|
|
|
|
{
|
2020-04-14 10:49:23 +02:00
|
|
|
TremoloType _tremoloType { TremoloType::R8 };
|
|
|
|
Chord* _chord1 { nullptr };
|
|
|
|
Chord* _chord2 { nullptr };
|
2018-12-19 14:36:02 +01:00
|
|
|
TDuration _durationType;
|
2012-05-26 14:26:10 +02:00
|
|
|
QPainterPath path;
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2012-11-14 12:24:08 +01:00
|
|
|
int _lines; // derived from _subtype
|
2020-04-16 10:36:29 +02:00
|
|
|
TremoloPlacement _tremoloPlacement { TremoloPlacement::DEFAULT };
|
|
|
|
TremoloStrokeStyle _strokeStyle { TremoloStrokeStyle::DEFAULT };
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2019-06-05 10:06:25 +02:00
|
|
|
QPainterPath basePath() const;
|
|
|
|
void computeShape();
|
|
|
|
void layoutOneNoteTremolo(qreal x, qreal y, qreal spatium);
|
|
|
|
void layoutTwoNotesTremolo(qreal x, qreal y, qreal h, qreal spatium);
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
public:
|
|
|
|
Tremolo(Score*);
|
2014-05-10 20:06:00 +02:00
|
|
|
Tremolo(const Tremolo&);
|
2014-06-27 13:41:49 +02:00
|
|
|
Tremolo& operator=(const Tremolo&) = delete;
|
2020-03-21 15:03:04 +01:00
|
|
|
Tremolo* clone() const override { return new Tremolo(*this); }
|
|
|
|
ElementType type() const override { return ElementType::TREMOLO; }
|
|
|
|
int subtype() const override { return static_cast<int>(_tremoloType); }
|
|
|
|
QString subtypeName() const override;
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2013-03-05 20:23:59 +01:00
|
|
|
QString tremoloTypeName() const;
|
|
|
|
void setTremoloType(const QString& s);
|
2018-05-11 23:14:49 +02:00
|
|
|
static TremoloType name2Type(const QString& s);
|
|
|
|
static QString type2name(TremoloType t);
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2018-12-12 13:40:19 +01:00
|
|
|
Chord* chord() const { return toChord(parent()); }
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2013-03-05 20:23:59 +01:00
|
|
|
void setTremoloType(TremoloType t);
|
|
|
|
TremoloType tremoloType() const { return _tremoloType; }
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2020-03-21 15:03:04 +01:00
|
|
|
qreal mag() const override;
|
|
|
|
void draw(QPainter*) const override;
|
|
|
|
void layout() override;
|
2016-02-16 21:21:28 +01:00
|
|
|
void layout2();
|
2020-03-21 15:03:04 +01:00
|
|
|
void write(XmlWriter& xml) const override;
|
|
|
|
void read(XmlReader&) override;
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
Chord* chord1() const { return _chord1; }
|
|
|
|
Chord* chord2() const { return _chord2; }
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2018-12-19 14:36:02 +01:00
|
|
|
TDuration durationType() const { return _durationType; }
|
|
|
|
void setDurationType(TDuration d) { _durationType = d; }
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
void setChords(Chord* c1, Chord* c2)
|
|
|
|
{
|
|
|
|
_chord1 = c1;
|
|
|
|
_chord2 = c2;
|
|
|
|
}
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
Fraction tremoloLen() const;
|
2018-05-14 23:06:56 +02:00
|
|
|
bool twoNotes() const { return tremoloType() >= TremoloType::C8; } // is it a two note tremolo?
|
2012-11-14 12:24:08 +01:00
|
|
|
int lines() const { return _lines; }
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2019-06-05 10:06:25 +02:00
|
|
|
bool placeMidStem() const;
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2020-02-16 08:02:40 +01:00
|
|
|
bool crossStaffBeamBetween() const;
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2020-03-21 15:03:04 +01:00
|
|
|
void spatiumChanged(qreal oldValue, qreal newValue) override;
|
|
|
|
void localSpatiumChanged(qreal oldValue, qreal newValue) override;
|
|
|
|
void styleChanged() override;
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2020-03-21 15:03:04 +01:00
|
|
|
QString accessibleInfo() const override;
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2020-01-15 22:03:47 +01:00
|
|
|
TremoloPlacement tremoloPlacement() const { return _tremoloPlacement; }
|
|
|
|
void setTremoloPlacement(TremoloPlacement v) { _tremoloPlacement = v; }
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2020-04-16 10:36:29 +02:00
|
|
|
TremoloStrokeStyle strokeStyle() const { return _strokeStyle; }
|
|
|
|
void setStrokeStyle(TremoloStrokeStyle v) { _strokeStyle = v; }
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2020-03-21 15:03:04 +01:00
|
|
|
QVariant getProperty(Pid propertyId) const override;
|
|
|
|
bool setProperty(Pid propertyId, const QVariant&) override;
|
2020-01-15 22:03:47 +01:00
|
|
|
QVariant propertyDefault(Pid propertyId) const override;
|
2020-03-21 15:03:04 +01:00
|
|
|
Pid propertyId(const QStringRef& xmlName) const override;
|
|
|
|
QString propertyUserValue(Pid) const override;
|
2012-05-26 14:26:10 +02:00
|
|
|
};
|
2013-05-13 18:49:17 +02:00
|
|
|
} // namespace Ms
|
2012-05-26 14:26:10 +02:00
|
|
|
#endif
|