MuseScore/libmscore/system.h

172 lines
5.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 __SYSTEM_H__
#define __SYSTEM_H__
/**
\file
2012-07-25 11:49:34 +02:00
Definition of classes SysStaff and System
2012-05-26 14:26:10 +02:00
*/
#include "element.h"
#include "spatium.h"
2015-07-25 08:43:02 +02:00
#include "symbol.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 Staff;
class StaffLines;
class Clef;
class Page;
class Bracket;
class Lyrics;
class Segment;
class MeasureBase;
class Text;
class InstrumentName;
class SpannerSegment;
class VBox;
class BarLine;
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// SysStaff
2012-07-25 11:49:34 +02:00
/// One staff of a System.
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class SysStaff {
QRectF _bbox; // Bbox of StaffLines.
qreal _yOff { 0 }; // offset of top staff line within bbox
bool _show { true }; // derived from Staff or false if empty
// staff is hidden
2012-05-26 14:26:10 +02:00
public:
int idx { 0 };
2012-05-26 14:26:10 +02:00
QList<InstrumentName*> instrumentNames;
const QRectF& bbox() const { return _bbox; }
2013-01-02 09:29:17 +01:00
QRectF& bbox() { return _bbox; }
2012-05-26 14:26:10 +02:00
void setbbox(const QRectF& r) { _bbox = r; }
2016-02-16 21:21:28 +01:00
qreal y() const { return _bbox.y() + _yOff; }
void setYOff(qreal offset) { _yOff = offset; }
2012-05-26 14:26:10 +02:00
bool show() const { return _show; }
void setShow(bool v) { _show = v; }
SysStaff() {}
2012-05-26 14:26:10 +02:00
~SysStaff();
};
//---------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ System
/// One row of measures for all instruments;
/// a complete piece of the timeline.
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class System : public Element {
Q_GADGET
2016-02-10 13:40:34 +01:00
SystemDivider* _systemDividerLeft { 0 };
SystemDivider* _systemDividerRight { 0 };
2016-01-04 14:48:58 +01:00
std::vector<MeasureBase*> ml;
2012-05-26 14:26:10 +02:00
QList<SysStaff*> _staves;
2012-10-12 15:36:57 +02:00
QList<Bracket*> _brackets;
QList<SpannerSegment*> _spannerSegments;
2012-10-12 15:36:57 +02:00
2016-10-20 11:32:07 +02:00
qreal _leftMargin { 0.0 }; ///< left margin for instrument name, brackets etc.
mutable bool fixedDownDistance { false };
2012-05-26 14:26:10 +02:00
public:
System(Score*);
~System();
2016-01-04 14:48:58 +01:00
virtual System* clone() const override { return new System(*this); }
2017-06-02 10:27:32 +02:00
virtual ElementType type() const override { return ElementType::SYSTEM; }
2012-05-26 14:26:10 +02:00
2016-01-04 14:48:58 +01:00
virtual void add(Element*) override;
virtual void remove(Element*) override;
virtual void change(Element* o, Element* n) override;
2016-11-19 11:51:21 +01:00
virtual void write(XmlWriter&) const override;
2016-01-04 14:48:58 +01:00
virtual void read(XmlReader&) override;
2012-05-26 14:26:10 +02:00
2016-01-04 14:48:58 +01:00
virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true) override;
2012-05-26 14:26:10 +02:00
2017-03-14 17:00:38 +01:00
void appendMeasure(MeasureBase*);
2016-01-04 14:48:58 +01:00
Page* page() const { return (Page*)parent(); }
2016-12-14 09:56:16 +01:00
void layoutSystem(qreal);
2012-05-26 14:26:10 +02:00
void layout2(); ///< Called after Measure layout.
void clear(); ///< Clear measure list.
QRectF bboxStaff(int staff) const { return _staves[staff]->bbox(); }
QList<SysStaff*>* staves() { return &_staves; }
const QList<SysStaff*>* staves() const { return &_staves; }
2013-08-30 12:46:15 +02:00
qreal staffYpage(int staffIdx) const;
qreal staffCanvasYpage(int staffIdx) const;
2012-05-26 14:26:10 +02:00
SysStaff* staff(int staffIdx) const { return _staves[staffIdx]; }
2016-02-10 13:40:34 +01:00
bool pageBreak() const;
2012-05-26 14:26:10 +02:00
SysStaff* insertStaff(int);
void removeStaff(int);
int y2staff(qreal y) const;
void setInstrumentNames(bool longName);
int snap(int tick, const QPointF p) const;
int snapNote(int tick, const QPointF p, int staff) const;
2016-01-04 14:48:58 +01:00
std::vector<MeasureBase*>& measures() { return ml; }
const std::vector<MeasureBase*>& measures() const { return ml; }
2012-09-05 12:14:58 +02:00
MeasureBase* measure(int idx) { return ml[idx]; }
2012-05-26 14:26:10 +02:00
Measure* firstMeasure() const;
Measure* lastMeasure() const;
2016-03-18 09:29:16 +01:00
int endTick() const;
2012-05-26 14:26:10 +02:00
MeasureBase* prevMeasure(const MeasureBase*) const;
MeasureBase* nextMeasure(const MeasureBase*) const;
qreal leftMargin() const { return _leftMargin; }
2016-03-02 13:20:19 +01:00
VBox* vbox() const;
2012-05-26 14:26:10 +02:00
2016-02-04 11:27:47 +01:00
const QList<Bracket*>& brackets() const { return _brackets; }
2013-06-10 11:03:34 +02:00
2013-07-24 14:33:35 +02:00
QList<SpannerSegment*>& spannerSegments() { return _spannerSegments; }
const QList<SpannerSegment*>& spannerSegments() const { return _spannerSegments; }
2016-02-10 13:40:34 +01:00
SystemDivider* systemDividerLeft() const { return _systemDividerLeft; }
SystemDivider* systemDividerRight() const { return _systemDividerRight; }
virtual Element* nextElement() override;
virtual Element* prevElement() override;
2016-01-04 14:48:58 +01:00
qreal minDistance(System*) const;
2016-06-15 16:11:17 +02:00
qreal topDistance(int staffIdx, const Shape&) const;
qreal bottomDistance(int staffIdx, const Shape&) const;
2016-01-04 14:48:58 +01:00
qreal minTop() const;
qreal minBottom() const;
2016-02-04 11:27:47 +01:00
void moveBracket(int staffIdx, int srcCol, int dstCol);
2016-10-12 20:06:46 +02:00
bool hasFixedDownDistance() const { return fixedDownDistance; }
2017-06-02 10:27:32 +02:00
int firstVisibleStaff() const;
2017-06-02 11:59:32 +02:00
int nextVisibleStaff(int) const;
2012-05-26 14:26:10 +02:00
};
typedef QList<System*>::iterator iSystem;
typedef QList<System*>::const_iterator ciSystem;
2013-05-13 18:49:17 +02:00
} // namespace Ms
2012-05-26 14:26:10 +02:00
#endif