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 __SLUR_H__
|
|
|
|
#define __SLUR_H__
|
|
|
|
|
|
|
|
#include "mscore.h"
|
|
|
|
#include "spanner.h"
|
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
class QPainter;
|
|
|
|
|
|
|
|
namespace Ms {
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
class Note;
|
|
|
|
class Chord;
|
|
|
|
class System;
|
|
|
|
class SlurTie;
|
|
|
|
class Score;
|
|
|
|
class MuseScoreView;
|
|
|
|
class ChordRest;
|
2012-08-12 16:08:58 +02:00
|
|
|
struct SlurPos;
|
2012-07-24 18:21:22 +02:00
|
|
|
|
|
|
|
enum {
|
2013-08-23 13:55:54 +02:00
|
|
|
GRIP_START, GRIP_BEZIER1, GRIP_SHOULDER, GRIP_BEZIER2, GRIP_DRAG, GRIP_END,
|
2012-07-24 18:21:22 +02:00
|
|
|
SLUR_GRIPS
|
|
|
|
};
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-08-22 12:18:14 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// SlurPos
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
struct SlurPos {
|
|
|
|
QPointF p1; // start point of slur
|
|
|
|
System* system1; // start system of slur
|
|
|
|
QPointF p2; // end point of slur
|
|
|
|
System* system2; // end system of slur
|
|
|
|
};
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// UP
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
struct UP {
|
|
|
|
QPointF p; // layout position relative to pos()
|
|
|
|
QPointF off; // user offset in spatium units
|
|
|
|
|
|
|
|
bool operator!=(const UP& up) const {
|
|
|
|
return p != up.p || off != up.off;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2012-07-25 11:49:34 +02:00
|
|
|
// @@ SlurSegment
|
|
|
|
/// also used for Tie
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class SlurSegment : public SpannerSegment {
|
2012-05-28 11:29:21 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
protected:
|
|
|
|
struct UP ups[SLUR_GRIPS];
|
|
|
|
QPainterPath path;
|
|
|
|
QPainterPath shapePath;
|
2014-03-30 18:14:55 +02:00
|
|
|
QPointF autoAdjustOffset;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
void computeBezier();
|
2013-08-22 12:18:14 +02:00
|
|
|
void changeAnchor(MuseScoreView*, int curGrip, Element*);
|
2014-03-30 18:14:55 +02:00
|
|
|
void setAutoAdjust(const QPointF& offset);
|
|
|
|
void setAutoAdjust(qreal x, qreal y) { setAutoAdjust(QPointF(x, y)); }
|
|
|
|
QPointF getAutoAdjust() const { return autoAdjustOffset; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
SlurSegment(Score*);
|
|
|
|
SlurSegment(const SlurSegment&);
|
|
|
|
virtual SlurSegment* clone() const { return new SlurSegment(*this); }
|
|
|
|
virtual ElementType type() const { return SLUR_SEGMENT; }
|
|
|
|
|
|
|
|
void layout(const QPointF& p1, const QPointF& p2);
|
|
|
|
virtual QPainterPath shape() const { return shapePath; }
|
|
|
|
virtual void draw(QPainter*) const;
|
|
|
|
|
2014-04-01 03:39:01 +02:00
|
|
|
bool isEdited() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
virtual bool isEditable() const { return true; }
|
|
|
|
virtual void editDrag(const EditData&);
|
|
|
|
virtual bool edit(MuseScoreView*, int grip, int key, Qt::KeyboardModifiers, const QString& s);
|
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 QPointF gripAnchor(int grip) const;
|
|
|
|
virtual QPointF getGrip(int) const;
|
|
|
|
virtual void setGrip(int, const QPointF&);
|
|
|
|
|
|
|
|
virtual void move(qreal xd, qreal yd) { move(QPointF(xd, yd)); }
|
|
|
|
virtual void move(const QPointF& s);
|
|
|
|
|
2013-07-01 16:57:44 +02:00
|
|
|
virtual QVariant getProperty(P_ID propertyId) const;
|
|
|
|
virtual bool setProperty(P_ID propertyId, const QVariant&);
|
|
|
|
virtual QVariant propertyDefault(P_ID id) const;
|
|
|
|
|
2012-07-24 18:21:22 +02:00
|
|
|
SlurTie* slurTie() const { return (SlurTie*)spanner(); }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
void write(Xml& xml, int no) const;
|
2013-01-11 18:10:18 +01:00
|
|
|
void read(XmlReader&);
|
2012-11-19 10:08:15 +01:00
|
|
|
virtual void reset();
|
2012-05-26 14:26:10 +02:00
|
|
|
void setSlurOffset(int i, const QPointF& val) { ups[i].off = val; }
|
|
|
|
QPointF slurOffset(int i) const { return ups[i].off; }
|
|
|
|
const struct UP* getUps(int idx) const { return &ups[idx]; }
|
|
|
|
|
|
|
|
friend class Tie;
|
|
|
|
friend class Slur;
|
|
|
|
};
|
|
|
|
|
2012-07-24 18:21:22 +02:00
|
|
|
//-------------------------------------------------------------------
|
2012-07-13 19:44:03 +02:00
|
|
|
// @@ SlurTie
|
2014-05-16 13:44:32 +02:00
|
|
|
// @P lineType int (0 - solid, 1 - dotted, 2 - dashed)
|
|
|
|
// @P slurDirection Direction (AUTO, UP, DOWN)
|
2012-07-24 18:21:22 +02:00
|
|
|
//-------------------------------------------------------------------
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
class SlurTie : public Spanner {
|
2012-05-28 11:29:21 +02:00
|
|
|
Q_OBJECT
|
2014-05-12 12:28:07 +02:00
|
|
|
Q_PROPERTY(int lineType READ lineType WRITE undoSetLineType)
|
|
|
|
Q_PROPERTY(Ms::Direction slurDirection READ slurDirection WRITE undoSetSlurDirection)
|
2012-05-28 11:29:21 +02:00
|
|
|
|
2013-06-10 11:03:34 +02:00
|
|
|
int _lineType; // 0 = solid, 1 = dotted, 2 = dashed
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
protected:
|
2012-07-24 18:21:22 +02:00
|
|
|
bool _up; // actual direction
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
QQueue<SlurSegment*> delSegments; // "deleted" segments
|
2014-05-07 18:09:01 +02:00
|
|
|
Direction _slurDirection;
|
2012-05-26 14:26:10 +02:00
|
|
|
qreal firstNoteRestSegmentX(System* system);
|
|
|
|
void fixupSegments(unsigned nsegs);
|
|
|
|
|
|
|
|
public:
|
|
|
|
SlurTie(Score*);
|
|
|
|
SlurTie(const SlurTie&);
|
|
|
|
~SlurTie();
|
|
|
|
|
|
|
|
virtual ElementType type() const = 0;
|
2014-05-07 18:09:01 +02:00
|
|
|
bool up() const { return _up; }
|
2012-07-24 18:21:22 +02:00
|
|
|
|
2014-05-07 18:09:01 +02:00
|
|
|
Direction slurDirection() const { return _slurDirection; }
|
|
|
|
void setSlurDirection(Direction d) { _slurDirection = d; }
|
|
|
|
void undoSetSlurDirection(Direction d);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
virtual void layout2(const QPointF, int, struct UP&) {}
|
|
|
|
virtual bool contains(const QPointF&) const { return false; } // not selectable
|
|
|
|
|
|
|
|
void writeProperties(Xml& xml) const;
|
2013-01-11 18:10:18 +01:00
|
|
|
bool readProperties(XmlReader&);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2012-11-19 10:08:15 +01:00
|
|
|
virtual void reset();
|
2012-07-24 18:21:22 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
int lineType() const { return _lineType; }
|
|
|
|
void setLineType(int val) { _lineType = val; }
|
2012-07-24 18:21:22 +02:00
|
|
|
void undoSetLineType(int);
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
SlurSegment* frontSegment() const { return (SlurSegment*)spannerSegments().front(); }
|
|
|
|
SlurSegment* backSegment() const { return (SlurSegment*)spannerSegments().back(); }
|
|
|
|
SlurSegment* takeLastSegment() { return (SlurSegment*)spannerSegments().takeLast(); }
|
|
|
|
SlurSegment* segmentAt(int n) const { return (SlurSegment*)spannerSegments().at(n); }
|
|
|
|
virtual void slurPos(SlurPos*) = 0;
|
|
|
|
virtual void computeBezier(SlurSegment*, QPointF so = QPointF()) = 0;
|
2013-07-01 16:57:44 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
virtual QVariant getProperty(P_ID propertyId) const;
|
|
|
|
virtual bool setProperty(P_ID propertyId, const QVariant&);
|
2013-07-01 16:57:44 +02:00
|
|
|
virtual QVariant propertyDefault(P_ID id) const;
|
2012-05-26 14:26:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2012-07-13 19:44:03 +02:00
|
|
|
// @@ Slur
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class Slur : public SlurTie {
|
2012-05-28 11:29:21 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2013-06-16 23:33:37 +02:00
|
|
|
void slurPosChord(SlurPos*);
|
|
|
|
void layoutChord();
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
public:
|
2012-07-13 19:44:03 +02:00
|
|
|
Slur(Score* = 0);
|
2012-05-26 14:26:10 +02:00
|
|
|
~Slur();
|
|
|
|
virtual Slur* clone() const { return new Slur(*this); }
|
|
|
|
virtual ElementType type() const { return SLUR; }
|
|
|
|
virtual void write(Xml& xml) const;
|
2013-01-11 18:10:18 +01:00
|
|
|
virtual void read(XmlReader&);
|
2012-05-26 14:26:10 +02:00
|
|
|
virtual void layout();
|
|
|
|
virtual void setTrack(int val);
|
|
|
|
virtual void slurPos(SlurPos*);
|
|
|
|
virtual void computeBezier(SlurSegment*, QPointF so = QPointF());
|
2013-06-10 11:03:34 +02:00
|
|
|
friend SlurSegment;
|
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
|
|
|
|
|