MuseScore/libmscore/duration.h

76 lines
2.4 KiB
C
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2008-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 __DURATION_H__
#define __DURATION_H__
2015-04-07 10:26:33 +02:00
#include "config.h"
2012-05-26 14:26:10 +02:00
#include "element.h"
#include "durationtype.h"
2013-05-13 18:49:17 +02:00
namespace Ms {
2012-05-26 14:26:10 +02:00
class Tuplet;
class Beam;
class Spanner;
//---------------------------------------------------------
2012-07-14 23:24:14 +02:00
// @@ DurationElement
/// Virtual base class for Chord, Rest and Tuplet.
2012-07-25 11:49:34 +02:00
//
2015-05-02 12:17:45 +02:00
// @P duration Fraction duration (as written)
// @P globalDuration Fraction played duration
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class DurationElement : public Element {
Fraction _duration;
Tuplet* _tuplet;
2015-04-07 10:26:33 +02:00
#ifdef SCRIPT_INTERFACE
void setDurationW(FractionWrapper* f) { _duration = f->fraction(); }
FractionWrapper* durationW() const { return new FractionWrapper(_duration); }
2015-05-02 12:17:45 +02:00
FractionWrapper* globalDurW() const { return new FractionWrapper(globalDuration()); }
2015-04-07 10:26:33 +02:00
#endif
2012-05-26 14:26:10 +02:00
public:
DurationElement(Score* = 0, ElementFlags = ElementFlag::MOVABLE | ElementFlag::ON_STAFF);
2012-05-26 14:26:10 +02:00
DurationElement(const DurationElement& e);
~DurationElement();
virtual Measure* measure() const { return (Measure*)(parent()); }
2018-06-09 06:19:36 +02:00
void readAddTuplet(Tuplet* t);
void writeTupletStart(XmlWriter& xml) const;
void writeTupletEnd(XmlWriter& xml) const;
2012-05-26 14:26:10 +02:00
void setTuplet(Tuplet* t) { _tuplet = t; }
Tuplet* tuplet() const { return _tuplet; }
Tuplet* topTuplet() const;
2012-05-26 14:26:10 +02:00
virtual Beam* beam() const { return 0; }
int actualTicks() const;
2013-07-08 20:17:13 +02:00
Fraction actualFraction() const;
Fraction afrac() const override;
Fraction rfrac() const override;
2012-05-26 14:26:10 +02:00
2013-02-25 11:17:08 +01:00
virtual Fraction duration() const { return _duration; }
2012-05-26 14:26:10 +02:00
Fraction globalDuration() const;
void setDuration(const Fraction& f) { _duration = f; }
2018-03-27 15:36:00 +02:00
virtual QVariant getProperty(Pid propertyId) const override;
virtual bool setProperty(Pid propertyId, const QVariant&) override;
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