MuseScore/libmscore/staff.h

279 lines
9.5 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 __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"
2016-12-13 13:16:17 +01:00
#include "stafftypelist.h"
#include "groups.h"
#include "scoreElement.h"
2012-05-26 14:26:10 +02:00
2013-05-13 18:49:17 +02:00
namespace Ms {
class InstrumentTemplate;
2016-11-19 11:51:21 +01:00
class XmlWriter;
2012-05-26 14:26:10 +02:00
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;
2017-03-31 13:03:15 +02:00
class BracketItem;
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
};
Implementation of text swing (step1) added swing tab swing settings tab in staff text properties Implemented step 2 of swing implementation using staff texts Added call for updateSwing in stafftextproperties Initial page for dialog changed System flag enabled for swing parameters saving and loading with text specified swing implemented removed extra print statement fixed formatting Added groupbox to make the default behavior to no change in swing fixed indentation in stafftextproperties fixing conflicts in staff.h Removed writing of setSwing to file Removed SwingParameter member from staff and fixed layout of swing tab in dialog fixed the issue with disabled controls Added tests for staff text implementation of swing playback cleaned up the code Swing playback using staff texts implemented, facilitating local control over swing parameters and tests for the same added Cleaned up code Cleaned up code further Swing Playback using staff texts implemented Cleaned up code further Cleaning up code further Using MScore::division in place of 480 as ticks Modified test files according to new usage of MScore::division Removed unwanted printf statements Using strings to write to xml rather than doubles for swingUnit Replaced 240 and 120 in terms of MScore::division in stafftext:write Using TDuration to write to xml Replaced string literals by TDuration for style parameters Replaced "off" with "" in style.cpp Set defaults for unit and ratio in constructors Removed usage of two structs for SwingParameters Changed order of assignments in setSwingParameters Swing playback using staff-texts implemented and tests added
2014-07-24 20:09:49 +02:00
//---------------------------------------------------------
// SwingParameters
//---------------------------------------------------------
struct SwingParameters {
int swingUnit;
int swingRatio;
2014-08-16 11:21:56 +02:00
};
Implementation of text swing (step1) added swing tab swing settings tab in staff text properties Implemented step 2 of swing implementation using staff texts Added call for updateSwing in stafftextproperties Initial page for dialog changed System flag enabled for swing parameters saving and loading with text specified swing implemented removed extra print statement fixed formatting Added groupbox to make the default behavior to no change in swing fixed indentation in stafftextproperties fixing conflicts in staff.h Removed writing of setSwing to file Removed SwingParameter member from staff and fixed layout of swing tab in dialog fixed the issue with disabled controls Added tests for staff text implementation of swing playback cleaned up the code Swing playback using staff texts implemented, facilitating local control over swing parameters and tests for the same added Cleaned up code Cleaned up code further Swing Playback using staff texts implemented Cleaned up code further Cleaning up code further Using MScore::division in place of 480 as ticks Modified test files according to new usage of MScore::division Removed unwanted printf statements Using strings to write to xml rather than doubles for swingUnit Replaced 240 and 120 in terms of MScore::division in stafftext:write Using TDuration to write to xml Replaced string literals by TDuration for style parameters Replaced "off" with "" in style.cpp Set defaults for unit and ratio in constructors Removed usage of two structs for SwingParameters Changed order of assignments in setSwingParameters Swing playback using staff-texts implemented and tests added
2014-07-24 20:09:49 +02:00
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// Staff
/// Global staff data not directly related to drawing.
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class Staff final : public ScoreElement {
public:
enum class HideMode { AUTO, ALWAYS, NEVER, INSTRUMENT };
2015-08-04 19:53:54 +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
2017-03-31 13:03:15 +02:00
QList <BracketItem*> _brackets;
2017-05-29 14:59:10 +02:00
int _barLineSpan { false }; ///< true - span barline to next staff
2016-10-18 15:41:00 +02:00
int _barLineFrom { 0 }; ///< line of start staff to draw the barline from (0 = staff top line, ...)
2016-12-18 14:31:13 +01:00
int _barLineTo { 0 }; ///< line of end staff to draw the bar line to (0= staff bottom line, ...)
2016-10-18 15:41:00 +02:00
bool _invisible { false };
bool _cutaway { false };
bool _showIfEmpty { false }; ///< show this staff if system is empty and hideEmptyStaves is true
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
2016-10-18 15:41:00 +02:00
QColor _color { MScore::defaultColor };
qreal _userDist { 0.0 }; ///< user edited extra distance
2012-09-20 11:35:34 +02:00
2016-12-13 13:16:17 +01:00
StaffTypeList _staffTypeList;
2016-12-18 14:31:13 +01:00
2016-12-13 13:16:17 +01:00
LinkedStaves* _linkedStaves { 0 };
2012-05-26 14:26:10 +02:00
QMap<int,int> _channelList[VOICES];
Implementation of text swing (step1) added swing tab swing settings tab in staff text properties Implemented step 2 of swing implementation using staff texts Added call for updateSwing in stafftextproperties Initial page for dialog changed System flag enabled for swing parameters saving and loading with text specified swing implemented removed extra print statement fixed formatting Added groupbox to make the default behavior to no change in swing fixed indentation in stafftextproperties fixing conflicts in staff.h Removed writing of setSwing to file Removed SwingParameter member from staff and fixed layout of swing tab in dialog fixed the issue with disabled controls Added tests for staff text implementation of swing playback cleaned up the code Swing playback using staff texts implemented, facilitating local control over swing parameters and tests for the same added Cleaned up code Cleaned up code further Swing Playback using staff texts implemented Cleaned up code further Cleaning up code further Using MScore::division in place of 480 as ticks Modified test files according to new usage of MScore::division Removed unwanted printf statements Using strings to write to xml rather than doubles for swingUnit Replaced 240 and 120 in terms of MScore::division in stafftext:write Using TDuration to write to xml Replaced string literals by TDuration for style parameters Replaced "off" with "" in style.cpp Set defaults for unit and ratio in constructors Removed usage of two structs for SwingParameters Changed order of assignments in setSwingParameters Swing playback using staff-texts implemented and tests added
2014-07-24 20:09:49 +02:00
QMap<int,SwingParameters> _swingList;
2016-09-16 12:07:37 +02:00
bool _playbackVoice[VOICES] { true, true, true, true };
2012-05-26 14:26:10 +02:00
VeloList _velocities; ///< cached value
PitchList _pitchOffsets; ///< cached value
void scaleChanged(double oldValue, double newValue);
2017-03-31 13:03:15 +02:00
void fillBrackets(int);
void cleanBrackets();
2012-05-26 14:26:10 +02:00
public:
2016-12-18 14:31:13 +01:00
Staff(Score* score = 0) : ScoreElement(score) {}
2012-05-26 14:26:10 +02:00
~Staff();
void init(const InstrumentTemplate*, const StaffType *staffType, int);
void initFromStaffType(const StaffType* staffType);
void init(const Staff*);
2012-05-26 14:26:10 +02:00
2017-01-18 14:16:33 +01:00
virtual ElementType type() const override { return ElementType::STAFF; }
2016-03-18 09:29:16 +01:00
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&);
2016-12-23 12:05:18 +01:00
bool readProperties(XmlReader&);
2016-11-19 11:51:21 +01:00
void write(XmlWriter& xml) const;
2012-05-26 14:26:10 +02:00
Part* part() const { return _part; }
void setPart(Part* p) { _part = p; }
2017-03-31 13:03:15 +02:00
BracketType bracketType(int idx) const;
2012-05-26 14:26:10 +02:00
int bracketSpan(int idx) const;
2017-03-31 13:03:15 +02:00
void setBracketType(int idx, BracketType val);
2012-05-26 14:26:10 +02:00
void setBracketSpan(int idx, int val);
2017-03-31 13:03:15 +02:00
void swapBracket(int oldIdx, int newIdx);
void addBracket(BracketItem*);
const QList<BracketItem*>& brackets() const { return _brackets; }
QList<BracketItem*>& brackets() { return _brackets; }
2012-05-26 14:26:10 +02:00
void cleanupBrackets();
2017-03-31 13:03:15 +02:00
int bracketLevels() const;
2012-05-26 14:26:10 +02:00
ClefList& clefList() { return clefs; }
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;
int nextClefTick(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;
TimeSig* nextTimeSig(int tick) const;
bool isLocalTimeSignature(int tick) { return timeStretch(tick) != Fraction(1, 1); }
const Groups& group(int tick) const;
2012-05-26 14:26:10 +02:00
KeyList* keyList() { return &_keys; }
Key key(int tick) const { return keySigEvent(tick).key(); }
KeySigEvent keySigEvent(int tick) const;
int nextKeyTick(int tick) const;
2014-06-03 15:28:10 +02:00
int currentKeyTick(int tick) const;
KeySigEvent prevKey(int tick) const;
void setKey(int tick, KeySigEvent);
2012-05-26 14:26:10 +02:00
void removeKey(int tick);
bool show() const;
2016-12-13 13:16:17 +01:00
bool slashStyle(int tick) const;
2012-05-26 14:26:10 +02:00
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; }
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
2017-05-29 14:59: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; }
2017-05-29 14:59:10 +02:00
void setBarLineSpan(int val) { _barLineSpan = val; }
2012-10-14 00:35:11 +02:00
void setBarLineFrom(int val) { _barLineFrom = val; }
2016-12-23 12:05:18 +01:00
void setBarLineTo(int val) { _barLineTo = val; }
2012-05-26 14:26:10 +02:00
qreal height() const;
int channel(int tick, int voice) const;
QMap<int,int>* channelList(int voice) { return &_channelList[voice]; }
Implementation of text swing (step1) added swing tab swing settings tab in staff text properties Implemented step 2 of swing implementation using staff texts Added call for updateSwing in stafftextproperties Initial page for dialog changed System flag enabled for swing parameters saving and loading with text specified swing implemented removed extra print statement fixed formatting Added groupbox to make the default behavior to no change in swing fixed indentation in stafftextproperties fixing conflicts in staff.h Removed writing of setSwing to file Removed SwingParameter member from staff and fixed layout of swing tab in dialog fixed the issue with disabled controls Added tests for staff text implementation of swing playback cleaned up the code Swing playback using staff texts implemented, facilitating local control over swing parameters and tests for the same added Cleaned up code Cleaned up code further Swing Playback using staff texts implemented Cleaned up code further Cleaning up code further Using MScore::division in place of 480 as ticks Modified test files according to new usage of MScore::division Removed unwanted printf statements Using strings to write to xml rather than doubles for swingUnit Replaced 240 and 120 in terms of MScore::division in stafftext:write Using TDuration to write to xml Replaced string literals by TDuration for style parameters Replaced "off" with "" in style.cpp Set defaults for unit and ratio in constructors Removed usage of two structs for SwingParameters Changed order of assignments in setSwingParameters Swing playback using staff-texts implemented and tests added
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
2016-12-23 12:05:18 +01:00
//==== staff type
2016-12-13 13:16:17 +01:00
const StaffType* staffType(int tick) const;
StaffType* staffType(int tick);
2016-12-18 14:31:13 +01:00
StaffType* setStaffType(int tick, const StaffType*);
void staffTypeListChanged(int tick);
2014-04-28 18:38:50 +02:00
2016-12-13 13:16:17 +01:00
bool isPitchedStaff(int tick) const;
bool isTabStaff(int tick) const;
bool isDrumStaff(int tick) const;
int lines(int tick) const;
void setLines(int tick, int lines);
qreal lineDistance(int tick) const;
2016-12-23 12:05:18 +01:00
void setSlashStyle(int tick, bool val);
int middleLine(int tick) const;
int bottomLine(int tick) const;
qreal userMag(int tick) const;
void setUserMag(int tick, qreal m);
qreal mag(int tick) const;
bool small(int tick) const;
void setSmall(int tick, bool val);
qreal spatium(int tick) const;
//===========
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);
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; }
void setUserDist(qreal val) { _userDist = val; }
2012-05-26 14:26:10 +02:00
void spatiumChanged(qreal /*oldValue*/, qreal /*newValue*/);
bool genKeySig();
2016-12-13 13:16:17 +01:00
bool showLedgerLines(int tick);
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);
virtual QVariant getProperty(P_ID) const override;
virtual bool setProperty(P_ID, const QVariant&) override;
virtual QVariant propertyDefault(P_ID) const override;
2016-03-02 13:20:19 +01:00
BracketType innerBracket() const;
2016-09-16 12:07:37 +02:00
bool playbackVoice(int voice) const { return _playbackVoice[voice]; }
void setPlaybackVoice(int voice, bool val) { _playbackVoice[voice] = val; }
#ifndef NDEBUG
void dumpClefs(const char* title) const;
void dumpKeys(const char* title) const;
2015-02-16 12:12:23 +01:00
void dumpTimeSigs(const char*) const;
#else
void dumpClefs(const char*) const {}
void dumpKeys(const char*) const {}
2015-02-16 12:12:23 +01:00
void dumpTimeSigs(const char*) const {}
#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