MuseScore/libmscore/rest.h

79 lines
2.6 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 __REST_H__
#define __REST_H__
#include "chordrest.h"
2013-05-13 18:49:17 +02:00
namespace Ms {
2012-05-26 14:26:10 +02:00
class TDuration;
enum class SymId : short;
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
2012-07-11 21:29:42 +02:00
// @@ Rest
/// This class implements a rest.
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class Rest : public ChordRest {
Q_OBJECT
2012-05-26 14:26:10 +02:00
// values calculated by layout:
2013-11-06 15:58:05 +01:00
SymId _sym;
2012-05-26 14:26:10 +02:00
int dotline; // depends on rest symbol
qreal _mmWidth; // width of multi measure rest
2013-10-22 12:05:31 +02:00
virtual QRectF drag(EditData*) override;
2013-07-31 11:05:48 +02:00
virtual qreal upPos() const override;
virtual qreal downPos() const override;
virtual qreal centerX() const override;
virtual void setUserOff(const QPointF& o) override;
2012-05-26 14:26:10 +02:00
public:
Rest(Score* s = 0);
Rest(Score*, const TDuration&);
2013-07-31 11:05:48 +02:00
virtual Rest* clone() const override { return new Rest(*this); }
virtual ElementType type() const override { return ElementType::REST; }
2012-05-26 14:26:10 +02:00
2013-07-31 11:05:48 +02:00
virtual Measure* measure() const override { return parent() ? (Measure*)(parent()->parent()) : 0; }
virtual qreal mag() const override;
virtual void draw(QPainter*) const override;
virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true) override;
2012-05-26 14:26:10 +02:00
2013-07-31 11:05:48 +02:00
virtual bool acceptDrop(MuseScoreView*, const QPointF&, Element*) const override;
virtual Element* drop(const DropData&) override;
virtual void layout() override;
2012-05-26 14:26:10 +02:00
2013-07-31 11:05:48 +02:00
virtual void reset() override;
2012-08-23 17:40:04 +02:00
2012-05-26 14:26:10 +02:00
void setMMWidth(qreal val);
qreal mmWidth() const { return _mmWidth; }
2013-11-06 15:58:05 +01:00
SymId getSymbol(TDuration::DurationType type, int line, int lines, int* yoffset);
2012-05-26 14:26:10 +02:00
int getDotline() const { return dotline; }
2013-11-06 15:58:05 +01:00
SymId sym() const { return _sym; }
int computeLineOffset();
bool isFullMeasureRest() const { return durationType() == TDuration::DurationType::V_MEASURE; }
2014-05-16 13:52:22 +02:00
virtual int upLine() const;
virtual int downLine() const;
virtual QPointF stemPos() const;
virtual qreal stemPosX() const;
2014-05-17 15:48:18 +02:00
virtual QPointF stemPosBeam() 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