MuseScore/libmscore/dynamic.h

115 lines
3.2 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 __DYNAMICS_H__
#define __DYNAMICS_H__
#include "text.h"
#include "mscore.h"
2013-05-13 18:49:17 +02:00
namespace Ms {
2012-05-26 14:26:10 +02:00
class Measure;
class Segment;
//-----------------------------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ Dynamic
/// dynamics marker; determines midi velocity
//
// @P range Ms::DynamicRange (STAFF, PART, SYSTEM)
//-----------------------------------------------------------------------------
2012-05-26 14:26:10 +02:00
class Dynamic : public Text {
Q_OBJECT
Q_PROPERTY(DynamicRange range READ dynRange WRITE undoSetDynRange)
public:
enum class Type : char {
2014-05-21 15:44:16 +02:00
OTHER,
PPPPPP,
PPPPP,
PPPP,
PPP,
PP,
P,
MP,
MF,
F,
FF,
FFF,
FFFF,
FFFFF,
FFFFFF,
FP,
SF,
SFZ,
SFF,
SFFZ,
SFP,
SFPP,
RFZ,
RF,
FZ,
M,
R,
S,
Z
};
private:
Type _dynamicType;
2012-05-26 14:26:10 +02:00
mutable QPointF dragOffset;
int _velocity; // associated midi velocity 0-127
DynamicRange _dynRange; // STAFF, PART, SYSTEM
2012-05-26 14:26:10 +02:00
2013-10-22 12:05:31 +02:00
virtual QRectF drag(EditData*) override;
2012-05-26 14:26:10 +02:00
public:
Dynamic(Score*);
Dynamic(const Dynamic&);
2014-03-14 18:34:07 +01:00
virtual Dynamic* clone() const override { return new Dynamic(*this); }
virtual ElementType type() const override { return ElementType::DYNAMIC; }
2014-03-14 18:34:07 +01:00
Segment* segment() const { return (Segment*)parent(); }
Measure* measure() const { return (Measure*)parent()->parent(); }
2012-05-26 14:26:10 +02:00
void setDynamicType(Type val) { _dynamicType = val; }
void setDynamicType(const QString&);
QString dynamicTypeName() const;
Type dynamicType() const { return _dynamicType; }
2012-05-26 14:26:10 +02:00
2014-03-14 18:34:07 +01:00
virtual void layout() override;
virtual void write(Xml& xml) const override;
virtual void read(XmlReader&) override;
2012-05-26 14:26:10 +02:00
2014-03-14 18:34:07 +01:00
virtual bool isEditable() const override { return true; }
virtual void startEdit(MuseScoreView*, const QPointF&) override;
virtual void endEdit() override;
virtual void reset() override;
2012-05-26 14:26:10 +02:00
void setVelocity(int v);
int velocity() const;
DynamicRange dynRange() const { return _dynRange; }
void setDynRange(DynamicRange t) { _dynRange = t; }
void undoSetDynRange(DynamicRange t);
2012-05-26 14:26:10 +02:00
2014-03-14 18:34:07 +01:00
virtual QLineF dragAnchor() const override;
2014-03-14 18:34:07 +01:00
virtual QVariant getProperty(P_ID propertyId) const override;
virtual bool setProperty(P_ID propertyId, const QVariant&) override;
virtual QVariant propertyDefault(P_ID id) 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