2012-05-26 14:26:10 +02:00
|
|
|
//=============================================================================
|
|
|
|
// MuseScore
|
|
|
|
// Music Composition & Notation
|
|
|
|
//
|
|
|
|
// Copyright (C) 2002-2012 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 __BEAM_H__
|
|
|
|
#define __BEAM_H__
|
|
|
|
|
|
|
|
#include "element.h"
|
|
|
|
#include "durationtype.h"
|
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
class QPainter;
|
|
|
|
|
|
|
|
namespace Ms {
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
class ChordRest;
|
|
|
|
class MuseScoreView;
|
|
|
|
class Chord;
|
2014-07-09 18:05:58 +02:00
|
|
|
class System;
|
|
|
|
enum class SpannerSegmentType : char;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
struct BeamFragment;
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2012-07-25 11:49:34 +02:00
|
|
|
// @@ Beam
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class Beam : public Element {
|
2012-05-28 11:29:21 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
QList<ChordRest*> _elements; // must be sorted by tick
|
|
|
|
QList<QLineF*> beamSegments;
|
2014-06-26 10:53:57 +02:00
|
|
|
MScore::Direction _direction;
|
2013-08-13 16:52:34 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
bool _up;
|
|
|
|
bool _distribute; // equal spacing of elements
|
2013-08-13 16:52:34 +02:00
|
|
|
bool _noSlope;
|
|
|
|
PropertyStyle noSlopeStyle;
|
|
|
|
|
|
|
|
bool _userModified[2]; // 0: auto/down 1: up
|
2014-10-28 13:45:35 +01:00
|
|
|
bool _isGrace;
|
|
|
|
bool _cross;
|
2013-08-13 16:52:34 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
qreal _grow1; // define "feather" beams
|
|
|
|
qreal _grow2;
|
|
|
|
qreal _beamDist;
|
|
|
|
|
|
|
|
QList<BeamFragment*> fragments; // beam splits across systems
|
|
|
|
|
|
|
|
mutable int _id; // used in read()/write()
|
|
|
|
|
|
|
|
int minMove; // set in layout1()
|
|
|
|
int maxMove;
|
|
|
|
TDuration maxDuration;
|
|
|
|
qreal slope;
|
|
|
|
|
|
|
|
int editFragment; // valid in edit mode
|
|
|
|
|
|
|
|
void layout2(QList<ChordRest*>, SpannerSegmentType, int frag);
|
|
|
|
bool twoBeamedNotes();
|
2012-09-25 13:33:50 +02:00
|
|
|
void computeStemLen(const QList<ChordRest*>& crl, qreal& py1, int beamLevels);
|
2013-08-13 16:52:34 +02:00
|
|
|
bool slopeZero(const QList<ChordRest*>& crl);
|
|
|
|
bool hasNoSlope();
|
2015-05-05 18:28:39 +02:00
|
|
|
void addChordRest(ChordRest* a);
|
|
|
|
void removeChordRest(ChordRest* a);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
public:
|
2014-06-26 07:45:09 +02:00
|
|
|
enum class Mode : signed char {
|
|
|
|
AUTO, BEGIN, MID, END, NONE, BEGIN32, BEGIN64, INVALID = -1
|
|
|
|
};
|
2015-04-03 18:23:51 +02:00
|
|
|
Q_ENUMS(Mode)
|
2014-06-26 07:45:09 +02:00
|
|
|
|
2015-03-18 12:17:01 +01:00
|
|
|
Beam(Score* = 0);
|
2012-05-26 14:26:10 +02:00
|
|
|
Beam(const Beam&);
|
|
|
|
~Beam();
|
2013-08-13 16:52:34 +02:00
|
|
|
virtual Beam* clone() const override { return new Beam(*this); }
|
2014-06-24 18:36:02 +02:00
|
|
|
virtual Element::Type type() const override { return Element::Type::BEAM; }
|
2013-08-13 16:52:34 +02:00
|
|
|
virtual QPointF pagePos() const override; ///< position in page coordinates
|
|
|
|
virtual QPointF canvasPos() const override; ///< position in page coordinates
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-08-13 16:52:34 +02:00
|
|
|
virtual bool isEditable() const override { return true; }
|
|
|
|
virtual void startEdit(MuseScoreView*, const QPointF&) override;
|
2015-03-06 21:37:30 +01:00
|
|
|
virtual void endEdit() override;
|
2013-08-13 16:52:34 +02:00
|
|
|
virtual void editDrag(const EditData&) override;
|
2015-01-19 12:37:17 +01:00
|
|
|
virtual void updateGrips(Grip*, QVector<QRectF>&) const override;
|
|
|
|
virtual int grips() const override { return 2; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-08-13 16:52:34 +02:00
|
|
|
virtual void write(Xml& xml) const override;
|
|
|
|
virtual void read(XmlReader&) override;
|
|
|
|
virtual void spatiumChanged(qreal /*oldValue*/, qreal /*newValue*/) override;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-08-13 16:52:34 +02:00
|
|
|
virtual void reset() override;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
System* system() const { return (System*)parent(); }
|
|
|
|
|
|
|
|
void layout1();
|
2013-06-16 23:33:37 +02:00
|
|
|
void layoutGraceNotes();
|
2012-05-26 14:26:10 +02:00
|
|
|
void layout();
|
|
|
|
|
|
|
|
const QList<ChordRest*>& elements() { return _elements; }
|
|
|
|
void clear() { _elements.clear(); }
|
|
|
|
bool isEmpty() const { return _elements.isEmpty(); }
|
2013-08-13 16:52:34 +02:00
|
|
|
|
2015-05-05 18:28:39 +02:00
|
|
|
virtual void add(Element*) override;
|
|
|
|
virtual void remove(Element*) override;
|
2013-08-13 16:52:34 +02:00
|
|
|
|
2015-05-08 08:57:24 +02:00
|
|
|
virtual void move(const QPointF&) override;
|
2013-08-13 16:52:34 +02:00
|
|
|
virtual void draw(QPainter*) const override;
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
bool up() const { return _up; }
|
|
|
|
void setUp(bool v) { _up = v; }
|
|
|
|
void setId(int i) const { _id = i; }
|
|
|
|
int id() const { return _id; }
|
2013-08-13 16:52:34 +02:00
|
|
|
bool noSlope() const { return _noSlope; }
|
|
|
|
void setNoSlope(bool val) { _noSlope = val; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-06-26 10:53:57 +02:00
|
|
|
void setBeamDirection(MScore::Direction d);
|
|
|
|
MScore::Direction beamDirection() const { return _direction; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-08-13 16:52:34 +02:00
|
|
|
virtual QPainterPath shape() const override;
|
|
|
|
virtual bool contains(const QPointF& p) const override;
|
2014-08-13 21:01:21 +02:00
|
|
|
virtual bool acceptDrop(const DropData&) const override;
|
2013-08-13 16:52:34 +02:00
|
|
|
virtual Element* drop(const DropData&) override;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
qreal growLeft() const { return _grow1; }
|
|
|
|
qreal growRight() const { return _grow2; }
|
|
|
|
void setGrowLeft(qreal val) { _grow1 = val; }
|
|
|
|
void setGrowRight(qreal val) { _grow2 = val; }
|
|
|
|
|
|
|
|
bool distribute() const { return _distribute; }
|
|
|
|
void setDistribute(bool val) { _distribute = val; }
|
|
|
|
|
|
|
|
bool userModified() const;
|
|
|
|
void setUserModified(bool val);
|
|
|
|
|
|
|
|
QPointF beamPos() const;
|
|
|
|
void setBeamPos(const QPointF& bp);
|
|
|
|
|
2013-08-13 16:52:34 +02:00
|
|
|
virtual QVariant getProperty(P_ID propertyId) const override;
|
|
|
|
virtual bool setProperty(P_ID propertyId, const QVariant&) override;
|
|
|
|
virtual QVariant propertyDefault(P_ID id) const override;
|
|
|
|
virtual PropertyStyle propertyStyle(P_ID) const override;
|
|
|
|
virtual void resetProperty(P_ID id) override;
|
|
|
|
virtual void styleChanged() override;
|
2014-10-28 13:45:35 +01:00
|
|
|
bool isGrace() const { return _isGrace; } // for debugger
|
|
|
|
bool cross() const { return _cross; }
|
2012-05-26 14:26:10 +02:00
|
|
|
};
|
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
|
|
|
|
} // namespace Ms
|
2014-06-26 07:45:09 +02:00
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Ms::Beam::Mode);
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
#endif
|
|
|
|
|