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 __STAFF_H__
|
|
|
|
#define __STAFF_H__
|
|
|
|
|
|
|
|
/**
|
|
|
|
\file
|
|
|
|
Definition of class Staff.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "mscore.h"
|
|
|
|
#include "velo.h"
|
|
|
|
#include "pitch.h"
|
|
|
|
#include "cleflist.h"
|
2014-06-03 15:28:10 +02:00
|
|
|
#include "keylist.h"
|
2012-08-16 11:09:36 +02:00
|
|
|
#include "stafftype.h"
|
2013-04-29 15:31:22 +02:00
|
|
|
#include "groups.h"
|
2015-02-04 22:12:13 +01:00
|
|
|
#include "scoreElement.h"
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
namespace Ms {
|
|
|
|
|
2012-08-12 16:08:58 +02:00
|
|
|
class InstrumentTemplate;
|
2012-05-26 14:26:10 +02:00
|
|
|
class Xml;
|
|
|
|
class Part;
|
|
|
|
class Score;
|
|
|
|
class KeyList;
|
|
|
|
class StaffType;
|
|
|
|
class Staff;
|
|
|
|
struct ClefTypeList;
|
|
|
|
class Segment;
|
|
|
|
class Clef;
|
|
|
|
class TimeSig;
|
2013-07-16 09:03:47 +02:00
|
|
|
class Ottava;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-06-20 17:07:22 +02:00
|
|
|
enum class Key;
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// LinkedStaves
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class LinkedStaves {
|
|
|
|
QList<Staff*> _staves;
|
|
|
|
|
|
|
|
public:
|
|
|
|
LinkedStaves() {}
|
|
|
|
QList<Staff*>& staves() { return _staves; }
|
|
|
|
const QList<Staff*>& staves() const { return _staves; }
|
|
|
|
void add(Staff*);
|
|
|
|
void remove(Staff*);
|
2016-02-06 22:03:43 +01:00
|
|
|
bool empty() const { return _staves.empty(); }
|
2012-05-26 14:26:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// BracketItem
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
struct BracketItem {
|
|
|
|
BracketType _bracket;
|
|
|
|
int _bracketSpan;
|
|
|
|
|
|
|
|
BracketItem() {
|
2014-05-26 22:25:34 +02:00
|
|
|
_bracket = BracketType::NO_BRACKET;
|
2012-05-26 14:26:10 +02:00
|
|
|
_bracketSpan = 0;
|
|
|
|
}
|
|
|
|
BracketItem(BracketType a, int b) {
|
|
|
|
_bracket = a;
|
|
|
|
_bracketSpan = b;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-07-24 20:09:49 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// SwingParameters
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
struct SwingParameters {
|
|
|
|
int swingUnit;
|
|
|
|
int swingRatio;
|
2014-08-16 11:21:56 +02:00
|
|
|
};
|
2014-07-24 20:09:49 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
2014-05-16 15:58:57 +02:00
|
|
|
// Staff
|
2014-05-16 13:44:32 +02:00
|
|
|
/// Global staff data not directly related to drawing.
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2015-02-04 22:12:13 +01:00
|
|
|
class Staff : public QObject, public ScoreElement {
|
2012-07-06 14:21:05 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2016-08-23 16:39:27 +02:00
|
|
|
public:
|
2015-12-13 00:44:25 +01:00
|
|
|
enum class HideMode { AUTO, ALWAYS, NEVER, INSTRUMENT };
|
2015-08-04 19:53:54 +02:00
|
|
|
|
2016-08-23 16:39:27 +02:00
|
|
|
private:
|
2014-08-16 13:32:08 +02:00
|
|
|
Part* _part { 0 };
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-09-05 16:37:49 +02:00
|
|
|
ClefList clefs;
|
2014-08-16 11:21:56 +02:00
|
|
|
ClefTypeList _defaultClefType;
|
|
|
|
|
2014-06-03 15:28:10 +02:00
|
|
|
KeyList _keys;
|
2014-07-25 17:13:27 +02:00
|
|
|
std::map<int,TimeSig*> timesigs;
|
2013-05-06 14:20:31 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
QList <BracketItem> _brackets;
|
2014-07-31 18:46:41 +02:00
|
|
|
int _barLineSpan { 1 }; ///< 0 - no bar line, 1 - span this staff, ...
|
|
|
|
int _barLineFrom { 0 }; ///< line of start staff to draw the barline from (0 = staff top line, ...)
|
|
|
|
int _barLineTo; ///< line of end staff to draw the bar line to (0= staff top line, ...)
|
|
|
|
bool _small { false };
|
|
|
|
bool _invisible { false };
|
2015-08-04 19:53:54 +02:00
|
|
|
bool _cutaway { false };
|
2014-08-06 16:37:41 +02:00
|
|
|
bool _showIfEmpty { false }; ///< show this staff if system is empty and hideEmptyStaves is true
|
2015-01-05 17:55:06 +01:00
|
|
|
bool _hideSystemBarLine { false }; // no system barline if not preceeded by staff with barline
|
2015-08-04 19:53:54 +02:00
|
|
|
HideMode _hideWhenEmpty { HideMode::AUTO }; // hide empty staves
|
2015-01-05 17:55:06 +01:00
|
|
|
|
2014-07-31 18:46:41 +02:00
|
|
|
QColor _color { MScore::defaultColor };
|
|
|
|
qreal _userDist { 0.0 }; ///< user edited extra distance
|
2014-08-14 16:52:58 +02:00
|
|
|
qreal _userMag { 1.0 }; // allowed 0.1 - 10.0
|
2012-09-20 11:35:34 +02:00
|
|
|
|
2014-04-28 18:38:50 +02:00
|
|
|
StaffType _staffType;
|
2014-07-31 18:46:41 +02:00
|
|
|
LinkedStaves* _linkedStaves { nullptr };
|
2012-05-26 14:26:10 +02:00
|
|
|
QMap<int,int> _channelList[VOICES];
|
2014-07-24 20:09:49 +02:00
|
|
|
QMap<int,SwingParameters> _swingList;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
VeloList _velocities; ///< cached value
|
|
|
|
PitchList _pitchOffsets; ///< cached value
|
|
|
|
|
2015-02-20 11:56:13 +01:00
|
|
|
void scaleChanged(double oldValue, double newValue);
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
public:
|
2012-07-06 14:21:05 +02:00
|
|
|
Staff(Score* = 0);
|
2012-05-26 14:26:10 +02:00
|
|
|
~Staff();
|
2013-03-25 20:39:24 +01:00
|
|
|
void init(const InstrumentTemplate*, const StaffType *staffType, int);
|
2013-04-05 15:52:35 +02:00
|
|
|
void initFromStaffType(const StaffType* staffType);
|
2015-03-03 17:32:13 +01:00
|
|
|
void init(const Staff*);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2016-03-18 09:29:16 +01:00
|
|
|
virtual const char* name() const override { return "Staff"; }
|
|
|
|
|
2014-08-11 15:25:55 +02:00
|
|
|
bool isTop() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
QString partName() const;
|
2014-08-11 15:25:55 +02:00
|
|
|
int rstaff() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
int idx() const;
|
2013-01-11 18:10:18 +01:00
|
|
|
void read(XmlReader&);
|
2012-05-26 14:26:10 +02:00
|
|
|
void write(Xml& xml) const;
|
|
|
|
Part* part() const { return _part; }
|
|
|
|
void setPart(Part* p) { _part = p; }
|
|
|
|
|
|
|
|
BracketType bracket(int idx) const;
|
|
|
|
int bracketSpan(int idx) const;
|
|
|
|
void setBracket(int idx, BracketType val);
|
|
|
|
void setBracketSpan(int idx, int val);
|
|
|
|
int bracketLevels() const { return _brackets.size(); }
|
|
|
|
void addBracket(BracketItem);
|
|
|
|
QList <BracketItem> brackets() const { return _brackets; }
|
|
|
|
void cleanupBrackets();
|
|
|
|
|
2014-08-16 11:21:56 +02:00
|
|
|
ClefTypeList clefType(int tick) const;
|
|
|
|
ClefTypeList defaultClefType() const { return _defaultClefType; }
|
|
|
|
void setDefaultClefType(const ClefTypeList& l) { _defaultClefType = l; }
|
2012-05-26 14:26:10 +02:00
|
|
|
ClefType clef(int tick) const;
|
2014-07-25 17:13:27 +02:00
|
|
|
|
|
|
|
void setClef(Clef*);
|
|
|
|
void removeClef(Clef*);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
void addTimeSig(TimeSig*);
|
|
|
|
void removeTimeSig(TimeSig*);
|
2014-11-27 13:04:03 +01:00
|
|
|
void clearTimeSig();
|
2012-05-26 14:26:10 +02:00
|
|
|
Fraction timeStretch(int tick) const;
|
|
|
|
TimeSig* timeSig(int tick) const;
|
2016-03-14 13:07:01 +01:00
|
|
|
bool isLocalTimeSignature(int tick) { return timeStretch(tick) != Fraction(1, 1); }
|
|
|
|
|
2013-04-29 15:31:22 +02:00
|
|
|
const Groups& group(int tick) const;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-12-08 18:02:17 +01:00
|
|
|
KeyList* keyList() { return &_keys; }
|
|
|
|
Key key(int tick) const { return keySigEvent(tick).key(); }
|
|
|
|
KeySigEvent keySigEvent(int tick) const;
|
2013-05-08 11:21:59 +02:00
|
|
|
int nextKeyTick(int tick) const;
|
2014-06-03 15:28:10 +02:00
|
|
|
int currentKeyTick(int tick) const;
|
2014-12-08 18:02:17 +01:00
|
|
|
KeySigEvent prevKey(int tick) const;
|
|
|
|
void setKey(int tick, KeySigEvent);
|
2012-05-26 14:26:10 +02:00
|
|
|
void removeKey(int tick);
|
|
|
|
|
2012-08-01 22:15:58 +02:00
|
|
|
bool show() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
bool slashStyle() const;
|
|
|
|
bool small() const { return _small; }
|
|
|
|
void setSmall(bool val) { _small = val; }
|
|
|
|
bool invisible() const { return _invisible; }
|
|
|
|
void setInvisible(bool val) { _invisible = val; }
|
2015-08-04 19:53:54 +02:00
|
|
|
bool cutaway() const { return _cutaway; }
|
|
|
|
void setCutaway(bool val) { _cutaway = val; }
|
2014-08-06 16:37:41 +02:00
|
|
|
bool showIfEmpty() const { return _showIfEmpty; }
|
|
|
|
void setShowIfEmpty(bool val) { _showIfEmpty = val; }
|
2014-07-31 18:46:41 +02:00
|
|
|
|
2015-01-05 17:55:06 +01:00
|
|
|
bool hideSystemBarLine() const { return _hideSystemBarLine; }
|
2015-08-04 19:53:54 +02:00
|
|
|
void setHideSystemBarLine(bool val) { _hideSystemBarLine = val; }
|
|
|
|
HideMode hideWhenEmpty() const { return _hideWhenEmpty; }
|
|
|
|
void setHideWhenEmpty(HideMode v) { _hideWhenEmpty = v; }
|
2015-01-05 17:55:06 +01:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
void setSlashStyle(bool val);
|
|
|
|
int lines() const;
|
|
|
|
void setLines(int);
|
2012-10-14 00:35:11 +02:00
|
|
|
qreal lineDistance() const;
|
2015-09-01 06:19:20 +02:00
|
|
|
qreal logicalLineDistance() const;
|
|
|
|
bool scaleNotesToLines() const;
|
|
|
|
int middleLine() const;
|
|
|
|
int bottomLine() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
int barLineSpan() const { return _barLineSpan; }
|
2012-10-14 00:35:11 +02:00
|
|
|
int barLineFrom() const { return _barLineFrom; }
|
|
|
|
int barLineTo() const { return _barLineTo; }
|
2012-05-26 14:26:10 +02:00
|
|
|
void setBarLineSpan(int val) { _barLineSpan = val; }
|
2012-10-14 00:35:11 +02:00
|
|
|
void setBarLineFrom(int val) { _barLineFrom = val; }
|
2014-08-05 16:09:14 +02:00
|
|
|
void setBarLineTo(int val);
|
2012-05-26 14:26:10 +02:00
|
|
|
qreal mag() const;
|
|
|
|
qreal height() const;
|
|
|
|
qreal spatium() const;
|
|
|
|
int channel(int tick, int voice) const;
|
|
|
|
QMap<int,int>* channelList(int voice) { return &_channelList[voice]; }
|
2014-07-24 20:09:49 +02:00
|
|
|
SwingParameters swing(int tick) const;
|
|
|
|
QMap<int,SwingParameters>* swingList() { return &_swingList; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-04-28 18:38:50 +02:00
|
|
|
const StaffType* staffType() const { return &_staffType; }
|
|
|
|
StaffType* staffType() { return &_staffType; }
|
|
|
|
|
|
|
|
void setStaffType(const StaffType* st);
|
|
|
|
StaffGroup staffGroup() const { return _staffType.group(); }
|
2014-05-27 13:30:23 +02:00
|
|
|
bool isPitchedStaff() const { return staffGroup() == StaffGroup::STANDARD; }
|
|
|
|
bool isTabStaff() const { return staffGroup() == StaffGroup::TAB; }
|
|
|
|
bool isDrumStaff() const { return staffGroup() == StaffGroup::PERCUSSION; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
VeloList& velocities() { return _velocities; }
|
2016-02-06 11:41:16 +01:00
|
|
|
PitchList& pitchOffsets() { return _pitchOffsets; }
|
|
|
|
|
2013-07-16 09:03:47 +02:00
|
|
|
int pitchOffset(int tick) { return _pitchOffsets.pitchOffset(tick); }
|
2014-07-15 12:49:51 +02:00
|
|
|
void updateOttava();
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
LinkedStaves* linkedStaves() const { return _linkedStaves; }
|
|
|
|
void setLinkedStaves(LinkedStaves* l) { _linkedStaves = l; }
|
2014-05-21 20:08:37 +02:00
|
|
|
QList<Staff*> staffList() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
void linkTo(Staff* staff);
|
2013-10-10 15:41:25 +02:00
|
|
|
bool isLinked(Staff* staff);
|
2014-08-01 16:21:39 +02:00
|
|
|
void unlink(Staff* staff);
|
2012-05-26 14:26:10 +02:00
|
|
|
bool primaryStaff() const;
|
2014-08-01 16:21:39 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
qreal userDist() const { return _userDist; }
|
2014-08-14 16:52:58 +02:00
|
|
|
void setUserDist(qreal val) { _userDist = val; }
|
|
|
|
qreal userMag() const { return _userMag; }
|
|
|
|
void setUserMag(qreal m) { _userMag = m; }
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
void spatiumChanged(qreal /*oldValue*/, qreal /*newValue*/);
|
2013-06-22 10:55:22 +02:00
|
|
|
bool genKeySig();
|
|
|
|
bool showLedgerLines();
|
2013-12-28 16:58:06 +01:00
|
|
|
|
2013-10-26 13:47:05 +02:00
|
|
|
QColor color() const { return _color; }
|
|
|
|
void setColor(const QColor& val) { _color = val; }
|
|
|
|
void undoSetColor(const QColor& val);
|
2014-05-08 17:59:24 +02:00
|
|
|
void insertTime(int tick, int len);
|
2015-02-04 22:12:13 +01:00
|
|
|
|
|
|
|
virtual QVariant getProperty(P_ID) const override;
|
|
|
|
virtual bool setProperty(P_ID, const QVariant&) override;
|
|
|
|
virtual QVariant propertyDefault(P_ID) const override;
|
2015-02-14 15:10:35 +01:00
|
|
|
|
2016-03-02 13:20:19 +01:00
|
|
|
BracketType innerBracket() const;
|
|
|
|
|
2015-02-14 15:10:35 +01:00
|
|
|
#ifndef NDEBUG
|
|
|
|
void dumpClefs(const char* title) const;
|
2015-02-14 16:24:29 +01:00
|
|
|
void dumpKeys(const char* title) const;
|
2015-02-16 12:12:23 +01:00
|
|
|
void dumpTimeSigs(const char*) const;
|
2015-02-14 15:10:35 +01:00
|
|
|
#else
|
|
|
|
void dumpClefs(const char*) const {}
|
2015-02-14 16:24:29 +01:00
|
|
|
void dumpKeys(const char*) const {}
|
2015-02-16 12:12:23 +01:00
|
|
|
void dumpTimeSigs(const char*) const {}
|
2015-02-14 15:10:35 +01:00
|
|
|
#endif
|
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
|
|
|
|
|