MuseScore/libmscore/staff.h

219 lines
7.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 "key.h"
#include "velo.h"
#include "pitch.h"
#include "cleflist.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 StaffTypeTablature;
class Staff;
class Tablature;
class ClefList;
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
//---------------------------------------------------------
// 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 = NO_BRACKET;
_bracketSpan = 0;
}
BracketItem(BracketType a, int b) {
_bracket = a;
_bracketSpan = b;
}
};
//---------------------------------------------------------
2012-07-11 21:29:42 +02:00
// @@ Staff
2012-07-25 11:49:34 +02:00
/// 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
2012-05-26 14:26:10 +02:00
Score* _score;
Part* _part;
2012-09-20 11:35:34 +02:00
int _rstaff; ///< Index in Part.
2012-05-26 14:26:10 +02:00
ClefTypeList _initialClef; // used by new score wizard
2013-06-24 19:01:31 +02:00
std::multimap<int, Clef*> clefs;
2013-05-06 14:20:31 +02:00
std::map<int,TimeSig*> timesigs;
2013-05-28 15:42:02 +02:00
KeyList _keymap;
2013-05-06 14:20:31 +02:00
2012-05-26 14:26:10 +02:00
QList <BracketItem> _brackets;
int _barLineSpan; ///< 0 - no bar line, 1 - span this staff, ...
2012-10-14 00:35:11 +02:00
int _barLineFrom; ///< 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, ...)
2012-05-26 14:26:10 +02:00
bool _small;
bool _invisible;
bool _updateKeymap;
2012-09-20 11:35:34 +02:00
qreal _userDist; ///< user edited extra distance
2012-05-26 14:26:10 +02:00
StaffType* _staffType;
LinkedStaves* _linkedStaves;
QMap<int,int> _channelList[VOICES];
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(Score*, Part*, int);
~Staff();
void init(const InstrumentTemplate*, const StaffType *staffType, int);
void initFromStaffType(const StaffType* staffType);
2012-05-26 14:26:10 +02:00
bool isTop() const { return _rstaff == 0; }
QString partName() const;
int rstaff() const { return _rstaff; }
int idx() const;
void setRstaff(int n) { _rstaff = n; }
2013-01-11 18:10:18 +01:00
void read(XmlReader&);
void read114(XmlReader&, ClefList&);
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();
ClefTypeList clefTypeList(int tick) const;
ClefType clef(int tick) const;
ClefType clef(Segment*) const;
void addClef(Clef*);
void removeClef(Clef*);
void setInitialClef(const ClefTypeList& cl);
void setInitialClef(ClefType ct);
2012-05-26 14:26:10 +02:00
ClefTypeList initialClef() const { return _initialClef; }
void addTimeSig(TimeSig*);
void removeTimeSig(TimeSig*);
Fraction timeStretch(int tick) const;
TimeSig* timeSig(int tick) const;
const Groups& group(int tick) const;
2012-05-26 14:26:10 +02:00
2013-05-28 15:42:02 +02:00
KeyList* keymap() { return &_keymap; }
2012-05-26 14:26:10 +02:00
KeySigEvent key(int tick) const;
int nextKeyTick(int tick) const;
2012-05-26 14:26:10 +02:00
void setKey(int tick, int st);
void setKey(int tick, const KeySigEvent& st);
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; }
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; }
void setBarLineTo(int val) { _barLineTo = 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]; }
StaffType* staffType() const { return _staffType; }
void setStaffType(StaffType* st);
StaffGroup staffGroup() const { return _staffType->group(); }
Re-factor presets and staff types. 1) Built-in staff types have been removed. 2) Presets are internally used as source for the staff types of a new score, to match data in Instruments.xml and as reference to check for modifications. 3) Each new score is given by default one staff type for each preset with the same name. 4) The Instrument page of the New Score Wizard lists (under the name of "Staff types") the default staff types applicable to the instrument (actually it lists the preset, as the score does not have any staff type yet). 5) The "Add | Instruments" dlg box lists all the staff types applicable to the instrument: = to the list of 4) + any user-created staff type. 6) The Staff Properties dlg box lists all the staff types applicable to the instrument: = list in 5) 7) The Staff Type Editor lists all the staff types This should ensure consistency among the several lists of staff types and avoid duplication of similar items Terminology: 7) A new staff type created in the editor is named by default with the group name ("Standard-", "Perc-", "Tab-") + the index of the new type in its group + the suffix "[*]" marking a user customisation. The user is anyway able to rename it, if he want. 8) The pitched staff type has been renamed everywhere (hopefully!) to "Standard" 9) The term 'preset' have been removed from the UI, except from the Staff Type Editor where it keeps its meaning of ready-made collections of parameters The commit affects many files, but a fair number of them have only changes in names of literals. The files with significant code changes are: libmscore/score.cpp libmscore/stafftype.cpp/.h mscore/editstafftype.cpp (code for naming a new staff type) mscore/instrdialog.cpp (building type list) Note: as score files store staff type indications as integer indices and the number and order of new default staff types is different from the old built-in types, there is a compatibility issue with old 2.0 score which use percussion and tab staves. In Score::read() (libmscore/scorefile.cpp), there is a rudimentary attempt to cope with this.Old scores will need manual fix anyway. There should not be any (new) compatibility issue with 1.x scores, as they did not use staff types.
2013-08-18 11:55:31 +02:00
bool isPitchedStaff() const { return staffGroup() == STANDARD_STAFF_GROUP; }
bool isTabStaff() const { return staffGroup() == TAB_STAFF_GROUP; }
bool isDrumStaff() const { return staffGroup() == PERCUSSION_STAFF_GROUP; }
2012-05-26 14:26:10 +02:00
bool updateKeymap() const { return _updateKeymap; }
void setUpdateKeymap(bool v) { _updateKeymap = v; }
VeloList& velocities() { return _velocities; }
PitchList& pitchOffsets() { return _pitchOffsets; }
2013-07-16 09:03:47 +02:00
int pitchOffset(int tick) { return _pitchOffsets.pitchOffset(tick); }
void updateOttava(Ottava*);
2012-05-26 14:26:10 +02:00
LinkedStaves* linkedStaves() const { return _linkedStaves; }
void setLinkedStaves(LinkedStaves* l) { _linkedStaves = l; }
void linkTo(Staff* staff);
bool primaryStaff() const;
qreal userDist() const { return _userDist; }
void setUserDist(qreal val) { _userDist = val; }
void spatiumChanged(qreal /*oldValue*/, qreal /*newValue*/);
bool genKeySig();
bool showLedgerLines();
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