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-10-31 10:15:45 +01:00
|
|
|
//-----------------------------------------------------------------------------
|
2012-07-25 11:49:34 +02:00
|
|
|
// @@ Dynamic
|
2014-05-16 13:44:32 +02:00
|
|
|
/// dynamics marker; determines midi velocity
|
2012-10-31 10:15:45 +01:00
|
|
|
//
|
2015-04-23 21:06:36 +02:00
|
|
|
// @P range enum (Dynamic.STAFF, .PART, .SYSTEM)
|
2012-10-31 10:15:45 +01:00
|
|
|
//-----------------------------------------------------------------------------
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2017-12-27 11:51:00 +01:00
|
|
|
class Dynamic final : public TextBase
|
|
|
|
{
|
2019-05-28 14:52:14 +02:00
|
|
|
Q_GADGET
|
2013-02-12 20:51:17 +01:00
|
|
|
public:
|
2014-06-24 16:03:04 +02:00
|
|
|
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
|
2013-02-12 20:51:17 +01:00
|
|
|
};
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2014-06-24 16:42:47 +02:00
|
|
|
enum class Range : char {
|
|
|
|
STAFF, PART, SYSTEM
|
|
|
|
};
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2018-12-22 11:43:23 +01:00
|
|
|
enum class Speed : char {
|
|
|
|
SLOW, NORMAL, FAST
|
|
|
|
};
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2018-12-22 11:43:23 +01:00
|
|
|
struct ChangeSpeedItem {
|
|
|
|
Speed speed;
|
|
|
|
const char* name;
|
|
|
|
};
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2019-03-12 11:55:00 +01:00
|
|
|
Q_ENUM(Type);
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2013-02-12 20:51:17 +01:00
|
|
|
private:
|
2014-06-24 16:03:04 +02:00
|
|
|
Type _dynamicType;
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
mutable QPointF dragOffset;
|
2014-06-24 16:42:47 +02:00
|
|
|
int _velocity; // associated midi velocity 0-127
|
|
|
|
Range _dynRange; // STAFF, PART, SYSTEM
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2018-12-22 11:43:23 +01:00
|
|
|
int _changeInVelocity { 128 };
|
|
|
|
Speed _velChangeSpeed { Speed::NORMAL };
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2020-03-24 14:49:16 +01:00
|
|
|
QRectF drag(EditData&) override;
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
public:
|
|
|
|
Dynamic(Score*);
|
|
|
|
Dynamic(const Dynamic&);
|
2020-03-24 14:49:16 +01:00
|
|
|
Dynamic* clone() const override { return new Dynamic(*this); }
|
|
|
|
ElementType type() const override { return ElementType::DYNAMIC; }
|
|
|
|
Segment* segment() const { return (Segment*)parent(); }
|
|
|
|
Measure* measure() const { return (Measure*)parent()->parent(); }
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2018-12-18 18:02:10 +01:00
|
|
|
void setDynamicType(Type val) { _dynamicType = val; }
|
2013-03-05 20:23:59 +01:00
|
|
|
void setDynamicType(const QString&);
|
2019-03-12 11:55:00 +01:00
|
|
|
static QString dynamicTypeName(Dynamic::Type type);
|
|
|
|
QString dynamicTypeName() const { return dynamicTypeName(_dynamicType); }
|
2018-12-18 18:02:10 +01:00
|
|
|
Type dynamicType() const { return _dynamicType; }
|
2020-03-24 14:49:16 +01:00
|
|
|
int subtype() const override { return static_cast<int>(_dynamicType); }
|
|
|
|
QString subtypeName() const override { return dynamicTypeName(); }
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2020-03-24 14:49:16 +01:00
|
|
|
void layout() override;
|
|
|
|
void write(XmlWriter& xml) const override;
|
|
|
|
void read(XmlReader&) override;
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2020-03-24 14:49:16 +01:00
|
|
|
bool isEditable() const override { return true; }
|
|
|
|
void startEdit(EditData&) override;
|
|
|
|
void endEdit(EditData&) override;
|
|
|
|
void reset() override;
|
2020-05-26 15:54:26 +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;
|
2014-06-24 16:42:47 +02:00
|
|
|
Range dynRange() const { return _dynRange; }
|
|
|
|
void setDynRange(Range t) { _dynRange = t; }
|
|
|
|
void undoSetDynRange(Range t);
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2018-12-22 11:43:23 +01:00
|
|
|
int changeInVelocity() const;
|
|
|
|
void setChangeInVelocity(int val);
|
|
|
|
Fraction velocityChangeLength() const;
|
2020-04-08 21:57:52 +02:00
|
|
|
bool isVelocityChangeAvailable() const;
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2018-12-22 11:43:23 +01:00
|
|
|
Speed velChangeSpeed() const { return _velChangeSpeed; }
|
|
|
|
void setVelChangeSpeed(Speed val) { _velChangeSpeed = val; }
|
|
|
|
static QString speedToName(Speed speed);
|
|
|
|
static Speed nameToSpeed(QString name);
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2020-03-24 14:49:16 +01:00
|
|
|
QVariant getProperty(Pid propertyId) const override;
|
|
|
|
bool setProperty(Pid propertyId, const QVariant&) override;
|
|
|
|
QVariant propertyDefault(Pid id) const override;
|
|
|
|
Pid propertyId(const QStringRef& xmlName) const override;
|
|
|
|
QString propertyUserValue(Pid) const override;
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2020-02-20 10:57:55 +01:00
|
|
|
std::unique_ptr<ElementGroup> getDragGroup(std::function<bool(const Element*)> isDragged) override;
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2020-03-24 14:49:16 +01:00
|
|
|
QString accessibleInfo() const override;
|
|
|
|
QString screenReaderInfo() const override;
|
2016-07-19 14:36:09 +02:00
|
|
|
void doAutoplace();
|
2020-05-26 15:54:26 +02:00
|
|
|
|
2018-12-22 11:43:23 +01:00
|
|
|
static const std::vector<ChangeSpeedItem> changeSpeedTable;
|
2020-03-21 13:19:54 +01:00
|
|
|
static int findInString(const QString& text, int& length, QString& type);
|
2014-07-10 14:13:37 +02:00
|
|
|
};
|
2013-05-13 18:49:17 +02:00
|
|
|
} // namespace Ms
|
2014-06-24 16:42:47 +02:00
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Ms::Dynamic::Range);
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
#endif
|