MuseScore/libmscore/dynamic.h

123 lines
3.6 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 enum (Dynamic.STAFF, .PART, .SYSTEM)
//-----------------------------------------------------------------------------
2012-05-26 14:26:10 +02:00
2017-12-27 11:51:00 +01:00
class Dynamic final : public TextBase {
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
};
enum class Range : char {
STAFF, PART, SYSTEM
};
private:
Type _dynamicType;
2012-05-26 14:26:10 +02:00
mutable QPointF dragOffset;
int _velocity; // associated midi velocity 0-127
Range _dynRange; // STAFF, PART, SYSTEM
2012-05-26 14:26:10 +02:00
2017-03-31 13:03:15 +02:00
virtual QRectF drag(EditData&) override;
virtual Sid getPropertyStyle(Pid) const override;
2013-10-22 12:05:31 +02:00
2012-05-26 14:26:10 +02:00
public:
Dynamic(Score*);
Dynamic(const Dynamic&);
virtual Dynamic* clone() const override { return new Dynamic(*this); }
virtual ElementType type() const override { return ElementType::DYNAMIC; }
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; }
virtual int subtype() const override { return (int) _dynamicType; }
virtual QString subtypeName() const override { return dynamicTypeName(); }
2012-05-26 14:26:10 +02:00
2014-03-14 18:34:07 +01:00
virtual void layout() override;
2016-11-19 11:51:21 +01:00
virtual void write(XmlWriter& xml) const override;
2014-03-14 18:34:07 +01:00
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; }
2017-03-31 13:03:15 +02:00
virtual void startEdit(EditData&) override;
virtual void endEdit(EditData&) override;
2014-03-14 18:34:07 +01:00
virtual void reset() override;
2012-05-26 14:26:10 +02:00
2016-08-02 17:00:49 +02:00
void setVelocity(int v) { _velocity = v; }
2012-05-26 14:26:10 +02:00
int velocity() const;
Range dynRange() const { return _dynRange; }
void setDynRange(Range t) { _dynRange = t; }
void undoSetDynRange(Range t);
2012-05-26 14:26:10 +02:00
2018-03-27 15:36:00 +02:00
virtual QVariant getProperty(Pid propertyId) const override;
virtual bool setProperty(Pid propertyId, const QVariant&) override;
virtual QVariant propertyDefault(Pid id) const override;
2012-05-26 14:26:10 +02:00
2016-02-04 17:06:32 +01:00
virtual QString accessibleInfo() const override;
virtual QString screenReaderInfo() const override;
2016-07-19 14:36:09 +02:00
void doAutoplace();
};
2013-05-13 18:49:17 +02:00
} // namespace Ms
Q_DECLARE_METATYPE(Ms::Dynamic::Range);
2012-05-26 14:26:10 +02:00
#endif