MuseScore  3.4
Music composition and notation
chordline.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2002-2012 Werner Schweer
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __CHORDLINE_H__
14 #define __CHORDLINE_H__
15 
16 #include "element.h"
17 
18 namespace Ms {
19 
20 class Chord;
21 
22 // subtypes:
23 enum class ChordLineType : char {
24  NOTYPE, FALL, DOIT,
25  PLOP, SCOOP
26  };
27 
28 //---------------------------------------------------------
29 // @@ ChordLine
32 //---------------------------------------------------------
33 
34 class ChordLine final : public Element {
36  bool _straight;
37  QPainterPath path;
38  bool modified;
39  qreal _lengthX;
40  qreal _lengthY;
41  const int _initialLength = 2;
42 
43  public:
44  ChordLine(Score*);
45  ChordLine(const ChordLine&);
46 
47  virtual ChordLine* clone() const override { return new ChordLine(*this); }
48  virtual ElementType type() const override { return ElementType::CHORDLINE; }
49 
50  virtual void setChordLineType(ChordLineType);
51  ChordLineType chordLineType() const { return _chordLineType; }
52  Chord* chord() const { return (Chord*)(parent()); }
53  virtual bool isStraight() const { return _straight; }
54  virtual void setStraight(bool straight) { _straight = straight; }
55  virtual void setLengthX(qreal length) { _lengthX = length; }
56  virtual void setLengthY(qreal length) { _lengthY = length; }
57 
58  virtual void read(XmlReader&) override;
59  virtual void write(XmlWriter& xml) const override;
60  virtual void layout() override;
61  virtual void draw(QPainter*) const override;
62 
63  void startEditDrag(EditData&) override;
64  virtual void editDrag(EditData&) override;
65 
66  virtual QString accessibleInfo() const override;
67 
68  virtual QVariant getProperty(Pid propertyId) const override;
69  virtual bool setProperty(Pid propertyId, const QVariant&) override;
70  virtual QVariant propertyDefault(Pid) const override;
71  virtual Pid propertyId(const QStringRef& xmlName) const override;
72 
74  int gripsCount() const override { return _straight ? 1 : path.elementCount(); }
75  Grip initialEditModeGrip() const override { return Grip(gripsCount() - 1); }
76  Grip defaultGrip() const override { return initialEditModeGrip(); }
77  std::vector<QPointF> gripsPositions(const EditData&) const override;
78 
79  };
80 
81 extern const char* scorelineNames[];
82 
83 } // namespace Ms
84 #endif
85 
virtual ChordLine * clone() const override
Definition: chordline.h:47
Element::EditBehavior normalModeEditBehavior() const override
Definition: chordline.h:73
bool modified
Definition: chordline.h:38
bezier line attached to top note of a chord implements fall, doit, plop, bend
Definition: chordline.h:34
Pid
Definition: property.h:62
Definition: xml.h:67
Grip initialEditModeGrip() const override
Definition: chordline.h:75
Grip defaultGrip() const override
Definition: chordline.h:76
virtual void setStraight(bool straight)
Definition: chordline.h:54
int gripsCount() const override
Definition: chordline.h:74
Base class of score layout elements.
Definition: element.h:158
Definition: score.h:391
QPainterPath path
Definition: chordline.h:37
ChordLineType
Definition: chordline.h:23
Grip
Definition: element.h:43
virtual void setLengthY(qreal length)
Definition: chordline.h:56
ChordLineType _chordLineType
Definition: chordline.h:35
ChordLineType chordLineType() const
Definition: chordline.h:51
Definition: aeolus.cpp:26
Chord * chord() const
Definition: chordline.h:52
virtual ElementType type() const override
Definition: chordline.h:48
Definition: xml.h:218
const char * scorelineNames[]
Definition: chordline.cpp:22
Graphic representation of a chord.
Definition: chord.h:55
Definition: element.h:111
qreal _lengthX
Definition: chordline.h:39
ElementType
Definition: types.h:34
Pid propertyId(const QStringRef &s)
Definition: property.cpp:347
EditBehavior
Definition: element.h:173
virtual void setLengthX(qreal length)
Definition: chordline.h:55
virtual bool isStraight() const
Definition: chordline.h:53
qreal _lengthY
Definition: chordline.h:40
bool _straight
Definition: chordline.h:36