MuseScore/libmscore/tuplet.h

131 lines
4.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 __TUPLET_H__
#define __TUPLET_H__
#include "duration.h"
2013-05-13 18:49:17 +02:00
class QPainter;
namespace Ms {
2012-05-26 14:26:10 +02:00
class Text;
class Spanner;
//------------------------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ Tuplet
//! Example of 1/8 triplet:
//! _baseLen = 1/8
//! _actualNotes = 3
//! _normalNotes = 2 (3 notes played in the time of 2/8)
//!
//! The tuplet has a len of _baseLen * _normalNotes.
//! A tuplet note has len of _baseLen * _normalNotes / _actualNotes.
2012-05-26 14:26:10 +02:00
//------------------------------------------------------------------------
class Tuplet : public DurationElement {
Q_OBJECT
2012-05-26 14:26:10 +02:00
int _tick;
public:
enum class NumberType : char { SHOW_NUMBER, SHOW_RELATION, NO_TEXT };
enum class BracketType : char { AUTO_BRACKET, SHOW_BRACKET, SHOW_NO_BRACKET };
2012-05-26 14:26:10 +02:00
private:
QList<DurationElement*> _elements;
NumberType _numberType;
BracketType _bracketType;
2012-05-26 14:26:10 +02:00
bool _hasBracket;
Fraction _ratio;
TDuration _baseLen; // 1/8 for a triplet of 1/8
MScore::Direction _direction;
2012-05-26 14:26:10 +02:00
bool _isUp;
QPointF p1, p2;
QPointF _p1, _p2; // user offset
mutable int _id; // used during read/write
Text* _number;
QPointF bracketL[4];
QPointF bracketR[3];
public:
Tuplet(Score*);
Tuplet(const Tuplet&);
~Tuplet();
virtual Tuplet* clone() const { return new Tuplet(*this); }
virtual Element::Type type() const { return Element::Type::TUPLET; }
2012-05-26 14:26:10 +02:00
virtual void setTrack(int val);
virtual void add(Element*);
virtual void remove(Element*);
virtual bool isEditable() const;
virtual void editDrag(const EditData&);
2014-03-16 14:57:32 +01:00
virtual void updateGrips(int*, int*, QRectF*) const override;
2012-05-26 14:26:10 +02:00
virtual void setSelected(bool f);
virtual Measure* measure() const { return (Measure*)parent(); }
NumberType numberType() const { return _numberType; }
BracketType bracketType() const { return _bracketType; }
void setNumberType(NumberType val) { _numberType = val; }
void setBracketType(BracketType val) { _bracketType = val; }
bool hasBracket() const { return _hasBracket; }
2012-05-26 14:26:10 +02:00
Fraction ratio() const { return _ratio; }
void setRatio(const Fraction& r) { _ratio = r; }
const QList<DurationElement*>& elements() const { return _elements; }
void clear() { _elements.clear(); }
virtual void layout();
Text* number() const { return _number; }
2013-01-11 18:10:18 +01:00
void read(XmlReader&);
2012-05-26 14:26:10 +02:00
void write(Xml&) const;
2012-11-19 10:08:15 +01:00
virtual void reset();
2012-05-26 14:26:10 +02:00
virtual void draw(QPainter*) const;
int id() const { return _id; }
void setId(int i) const { _id = i; }
2014-05-07 18:09:01 +02:00
TDuration baseLen() const { return _baseLen; }
void setBaseLen(const TDuration& d) { _baseLen = d; }
2012-05-26 14:26:10 +02:00
virtual void dump() const;
void setDirection(MScore::Direction d) { _direction = d; }
MScore::Direction direction() const { return _direction; }
2012-05-26 14:26:10 +02:00
bool isUp() const { return _isUp; }
virtual int tick() const { return _tick; }
void setTick(int val) { _tick = val; }
void sortElements();
Fraction elementsDuration();
2012-05-26 14:26:10 +02:00
virtual void setVisible(bool f);
2012-08-10 17:01:35 +02:00
QVariant getProperty(P_ID propertyId) const;
bool setProperty(P_ID propertyId, const QVariant& v);
QVariant propertyDefault(P_ID id) 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