MuseScore/libmscore/tremolo.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

125 lines
4 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
//=============================================================================
#ifndef __TREMOLO_H__
#define __TREMOLO_H__
#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:
enum class TremoloType : signed char {
INVALID_TREMOLO = -1,
R8 = 0, R16, R32, R64, BUZZ_ROLL, // one note tremolo (repeat)
C8, C16, C32, C64 // two note tremolo (change)
2012-05-26 14:26:10 +02:00
};
enum class TremoloPlacement : signed char {
DEFAULT = 0, STEM_CENTER
};
// only appliable to minim two-note tremolo in non-TAB staves
enum class TremoloStrokeStyle : signed char {
DEFAULT = 0, ALL_STROKES_ATTACHED
};
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
//---------------------------------------------------------
class Tremolo final : public Element
{
2020-04-14 10:49:23 +02:00
TremoloType _tremoloType { TremoloType::R8 };
Chord* _chord1 { nullptr };
Chord* _chord2 { nullptr };
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
TremoloPlacement _tremoloPlacement { TremoloPlacement::DEFAULT };
TremoloStrokeStyle _strokeStyle { TremoloStrokeStyle::DEFAULT };
2020-05-26 15:54:26 +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*);
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
QString tremoloTypeName() const;
void setTremoloType(const QString& s);
static TremoloType name2Type(const QString& s);
static QString type2name(TremoloType t);
2020-05-26 15:54:26 +02:00
Chord* chord() const { return toChord(parent()); }
2020-05-26 15:54:26 +02: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
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;
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
bool placeMidStem() const;
2020-05-26 15:54:26 +02: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
TremoloPlacement tremoloPlacement() const { return _tremoloPlacement; }
void setTremoloPlacement(TremoloPlacement v) { _tremoloPlacement = v; }
2020-05-26 15:54:26 +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;
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