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 __MEASUREBASE_H__
|
|
|
|
#define __MEASUREBASE_H__
|
|
|
|
|
|
|
|
/**
|
|
|
|
\file
|
|
|
|
Definition of MeasureBase class.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "element.h"
|
2013-08-21 19:53:24 +02:00
|
|
|
#include "layoutbreak.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 Score;
|
|
|
|
class System;
|
|
|
|
class Measure;
|
|
|
|
|
2016-01-04 14:48:58 +01:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Repeat
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
enum class Repeat : char {
|
|
|
|
NONE = 0,
|
|
|
|
END = 1,
|
|
|
|
START = 2,
|
|
|
|
MEASURE = 4,
|
|
|
|
JUMP = 8
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr Repeat operator| (Repeat t1, Repeat t2) {
|
|
|
|
return static_cast<Repeat>(static_cast<int>(t1) | static_cast<int>(t2));
|
|
|
|
}
|
|
|
|
constexpr bool operator& (Repeat t1, Repeat t2) {
|
|
|
|
return static_cast<int>(t1) & static_cast<int>(t2);
|
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
2012-07-11 21:29:42 +02:00
|
|
|
// @@ MeasureBase
|
2014-05-16 13:44:32 +02:00
|
|
|
/// Virtual base class for Measure, HBox and VBox
|
2013-08-21 19:53:24 +02:00
|
|
|
//
|
2015-04-24 01:38:32 +02:00
|
|
|
// @P lineBreak bool true if a system break is positioned on this measure
|
|
|
|
// @P nextMeasure Measure the next Measure (read-only)
|
|
|
|
// @P nextMeasureMM Measure the next multi-measure rest Measure (read-only)
|
|
|
|
// @P pageBreak bool true if a page break is positioned on this measure
|
|
|
|
// @P prevMeasure Measure the previous Measure (read-only)
|
|
|
|
// @P prevMeasureMM Measure the previous multi-measure rest Measure (read-only)
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class MeasureBase : public Element {
|
2016-01-04 14:48:58 +01:00
|
|
|
MeasureBase* _next { 0 };
|
|
|
|
MeasureBase* _prev { 0 };
|
|
|
|
|
|
|
|
ElementList _el; ///< Measure(/tick) relative -elements: with defined start time
|
|
|
|
///< but outside the staff
|
2019-01-30 15:13:54 +01:00
|
|
|
Fraction _tick { Fraction(0, 1) };
|
2016-10-12 17:56:05 +02:00
|
|
|
int _no { 0 }; ///< Measure number, counting from zero
|
|
|
|
int _noOffset { 0 }; ///< Offset to measure number
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2016-01-04 14:48:58 +01:00
|
|
|
protected:
|
2019-01-30 15:13:54 +01:00
|
|
|
Fraction _len { Fraction(0, 1) }; ///< actual length of measure
|
2016-10-13 14:28:00 +02:00
|
|
|
void cleanupLayoutBreaks(bool undo);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
public:
|
2012-05-28 19:34:13 +02:00
|
|
|
MeasureBase(Score* score = 0);
|
2012-05-26 14:26:10 +02:00
|
|
|
~MeasureBase();
|
|
|
|
MeasureBase(const MeasureBase&);
|
2015-02-23 10:10:18 +01:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
virtual MeasureBase* clone() const = 0;
|
2017-01-18 14:16:33 +01:00
|
|
|
virtual ElementType type() const = 0;
|
2015-02-23 10:10:18 +01:00
|
|
|
|
2015-01-19 12:37:17 +01:00
|
|
|
virtual void setScore(Score* s) override;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
MeasureBase* next() const { return _next; }
|
2013-09-19 15:08:54 +02:00
|
|
|
MeasureBase* nextMM() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
void setNext(MeasureBase* e) { _next = e; }
|
|
|
|
MeasureBase* prev() const { return _prev; }
|
2020-02-21 20:23:26 +01:00
|
|
|
MeasureBase* prevMM() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
void setPrev(MeasureBase* e) { _prev = e; }
|
|
|
|
|
2014-07-06 01:56:30 +02:00
|
|
|
Ms::Measure* nextMeasure() const;
|
|
|
|
Ms::Measure* prevMeasure() const;
|
2013-09-19 15:08:54 +02:00
|
|
|
Ms::Measure* nextMeasureMM() const;
|
2013-09-27 18:43:25 +02:00
|
|
|
Ms::Measure* prevMeasureMM() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2016-11-19 11:51:21 +01:00
|
|
|
virtual void write(XmlWriter&) const override = 0;
|
2017-03-09 23:55:10 +01:00
|
|
|
virtual void write(XmlWriter&, int, bool, bool) const = 0;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
virtual void layout();
|
|
|
|
|
|
|
|
virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true);
|
2016-01-04 14:48:58 +01:00
|
|
|
ElementList& el() { return _el; }
|
2015-02-17 20:22:24 +01:00
|
|
|
const ElementList& el() const { return _el; }
|
2012-05-26 14:26:10 +02:00
|
|
|
System* system() const { return (System*)parent(); }
|
|
|
|
void setSystem(System* s) { setParent((Element*)s); }
|
|
|
|
|
2016-10-13 14:28:00 +02:00
|
|
|
LayoutBreak* sectionBreakElement() const;
|
|
|
|
|
2014-06-25 13:57:29 +02:00
|
|
|
void undoSetBreak(bool v, LayoutBreak::Type type);
|
2016-10-12 17:56:05 +02:00
|
|
|
void undoSetLineBreak(bool v) { undoSetBreak(v, LayoutBreak::LINE);}
|
|
|
|
void undoSetPageBreak(bool v) { undoSetBreak(v, LayoutBreak::PAGE);}
|
|
|
|
void undoSetSectionBreak(bool v) { undoSetBreak(v, LayoutBreak::SECTION);}
|
|
|
|
void undoSetNoBreak(bool v) { undoSetBreak(v, LayoutBreak::NOBREAK);}
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2019-01-30 15:13:54 +01:00
|
|
|
virtual void moveTicks(const Fraction& diff) { setTick(tick() + diff); }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2015-02-17 21:12:19 +01:00
|
|
|
virtual void add(Element*) override;
|
|
|
|
virtual void remove(Element*) override;
|
2016-11-19 11:51:21 +01:00
|
|
|
virtual void writeProperties(XmlWriter&) const override;
|
2016-01-04 14:48:58 +01:00
|
|
|
virtual bool readProperties(XmlReader&) override;
|
|
|
|
|
2019-01-30 15:13:54 +01:00
|
|
|
Fraction tick() const { return _tick; }
|
|
|
|
void setTick(const Fraction& f) { _tick = f; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2019-01-30 15:13:54 +01:00
|
|
|
Fraction ticks() const { return _len; }
|
|
|
|
void setTicks(const Fraction& f) { _len = f; }
|
|
|
|
|
|
|
|
Fraction endTick() const { return _tick + _len; }
|
2018-06-02 20:41:28 +02:00
|
|
|
|
2019-10-24 15:49:23 +02:00
|
|
|
void triggerLayout() const override;
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
qreal pause() const;
|
2012-08-02 18:33:43 +02:00
|
|
|
|
2018-03-27 15:36:00 +02:00
|
|
|
virtual QVariant getProperty(Pid) const override;
|
|
|
|
virtual bool setProperty(Pid, const QVariant&) override;
|
|
|
|
virtual QVariant propertyDefault(Pid) const override;
|
2015-02-17 21:12:19 +01:00
|
|
|
|
|
|
|
void clearElements();
|
2015-02-25 10:48:39 +01:00
|
|
|
ElementList takeElements();
|
2016-01-04 14:48:58 +01:00
|
|
|
|
2016-10-20 11:32:07 +02:00
|
|
|
int no() const { return _no; }
|
|
|
|
void setNo(int n) { _no = n; }
|
|
|
|
int noOffset() const { return _noOffset; }
|
|
|
|
void setNoOffset(int n) { _noOffset = n; }
|
|
|
|
|
|
|
|
bool repeatEnd() const { return flag(ElementFlag::REPEAT_END); }
|
|
|
|
void setRepeatEnd(bool v) { setFlag(ElementFlag::REPEAT_END, v); }
|
|
|
|
|
|
|
|
bool repeatStart() const { return flag(ElementFlag::REPEAT_START); }
|
|
|
|
void setRepeatStart(bool v) { setFlag(ElementFlag::REPEAT_START, v); }
|
|
|
|
|
|
|
|
bool repeatJump() const { return flag(ElementFlag::REPEAT_JUMP); }
|
|
|
|
void setRepeatJump(bool v) { setFlag(ElementFlag::REPEAT_JUMP, v); }
|
|
|
|
|
|
|
|
bool irregular() const { return flag(ElementFlag::IRREGULAR); }
|
|
|
|
void setIrregular(bool v) { setFlag(ElementFlag::IRREGULAR, v); }
|
|
|
|
|
|
|
|
bool lineBreak() const { return flag(ElementFlag::LINE_BREAK); }
|
|
|
|
void setLineBreak(bool v) { setFlag(ElementFlag::LINE_BREAK, v); }
|
|
|
|
|
|
|
|
bool pageBreak() const { return flag(ElementFlag::PAGE_BREAK); }
|
|
|
|
void setPageBreak(bool v) { setFlag(ElementFlag::PAGE_BREAK, v); }
|
|
|
|
|
|
|
|
bool sectionBreak() const { return flag(ElementFlag::SECTION_BREAK); }
|
|
|
|
void setSectionBreak(bool v) { setFlag(ElementFlag::SECTION_BREAK, v); }
|
2016-01-04 14:48:58 +01:00
|
|
|
|
2016-10-20 11:32:07 +02:00
|
|
|
bool noBreak() const { return flag(ElementFlag::NO_BREAK); }
|
|
|
|
void setNoBreak(bool v) { setFlag(ElementFlag::NO_BREAK, v); }
|
2016-02-04 11:27:47 +01:00
|
|
|
|
2016-10-20 11:32:07 +02:00
|
|
|
bool hasCourtesyKeySig() const { return flag(ElementFlag::KEYSIG); }
|
|
|
|
void setHasCourtesyKeySig(int v) { setFlag(ElementFlag::KEYSIG, v); }
|
2016-02-12 19:14:24 +01:00
|
|
|
|
2016-10-25 17:30:55 +02:00
|
|
|
virtual void computeMinWidth() { };
|
2016-02-12 19:14:24 +01:00
|
|
|
|
2016-01-04 14:48:58 +01:00
|
|
|
int index() const;
|
2018-08-14 23:15:43 +02:00
|
|
|
int measureIndex() const;
|
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
|
|
|
|
|