MuseScore/libmscore/staff.h

246 lines
8.1 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"
#include "stafftype.h"
#include "groups.h"
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
class Instrument;
class InstrumentTemplate;
2012-05-26 14:26:10 +02:00
class Xml;
class Part;
class Score;
class KeyList;
class StaffType;
class Staff;
class StringData;
2012-05-26 14:26:10 +02:00
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*);
bool isEmpty() const { return _staves.isEmpty(); }
};
//---------------------------------------------------------
// BracketItem
//---------------------------------------------------------
struct BracketItem {
BracketType _bracket;
int _bracketSpan;
BracketItem() {
_bracket = BracketType::NO_BRACKET;
2012-05-26 14:26:10 +02:00
_bracketSpan = 0;
}
BracketItem(BracketType a, int b) {
_bracket = a;
_bracketSpan = b;
}
};
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
//---------------------------------------------------------
2012-07-06 14:21:05 +02:00
class Staff : public QObject {
Q_OBJECT
2014-08-16 13:32:08 +02:00
Score* _score ;
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 };
bool _neverHide { false }; ///< always show this staff, even if empty and hideEmptyStaves is true
bool _showIfEmpty { false }; ///< show this staff if system is empty and hideEmptyStaves is true
2014-07-31 18:46:41 +02:00
QColor _color { MScore::defaultColor };
qreal _userDist { 0.0 }; ///< user edited extra distance
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];
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;
2012-05-26 14:26:10 +02:00
VeloList _velocities; ///< cached value
PitchList _pitchOffsets; ///< cached value
public:
2012-07-06 14:21:05 +02:00
Staff(Score* = 0);
2012-05-26 14:26:10 +02:00
~Staff();
void init(const InstrumentTemplate*, const StaffType *staffType, int);
void initFromStaffType(const StaffType* staffType);
2012-05-26 14:26:10 +02: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&);
2013-09-05 16:37:49 +02:00
void read114(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;
const Groups& group(int tick) const;
2012-05-26 14:26:10 +02:00
2014-06-03 15:28:10 +02:00
KeyList* keyList() { return &_keys; }
2014-06-20 17:07:22 +02:00
Key key(int tick) const;
int nextKeyTick(int tick) const;
2014-06-03 15:28:10 +02:00
int currentKeyTick(int tick) const;
2014-06-20 17:07:22 +02:00
Key prevKey(int tick) const;
void setKey(int tick, Key);
2012-05-26 14:26:10 +02:00
void removeKey(int tick);
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; }
2014-07-31 18:46:41 +02:00
bool neverHide() const { return _neverHide; }
void setNeverHide(bool val) { _neverHide = val; }
bool showIfEmpty() const { return _showIfEmpty; }
void setShowIfEmpty(bool val) { _showIfEmpty = val; }
2014-07-31 18:46:41 +02: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;
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
Score* score() const { return _score; }
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]; }
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
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(); }
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; }
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; }
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*/);
bool genKeySig();
bool showLedgerLines();
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);
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