MuseScore  3.4
Music composition and notation
tie.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2002-2016 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 __TIE_H__
14 #define __TIE_H__
15 
16 #include "slurtie.h"
17 
18 namespace Ms {
19 
20 //---------------------------------------------------------
21 // @@ TieSegment
23 //---------------------------------------------------------
24 
25 class TieSegment final : public SlurTieSegment {
27 
28  void setAutoAdjust(const QPointF& offset);
29  void setAutoAdjust(qreal x, qreal y) { setAutoAdjust(QPointF(x, y)); }
30  QPointF getAutoAdjust() const { return autoAdjustOffset; }
31 
32  protected:
33  virtual void changeAnchor(EditData&, Element*) override;
34 
35  public:
36  TieSegment(Score* s) : SlurTieSegment(s) { autoAdjustOffset = QPointF(); }
37  TieSegment(const TieSegment& s) : SlurTieSegment(s) { autoAdjustOffset = QPointF(); }
38  virtual TieSegment* clone() const override { return new TieSegment(*this); }
39  virtual ElementType type() const override { return ElementType::TIE_SEGMENT; }
40  virtual int subtype() const override { return static_cast<int>(spanner()->type()); }
41  virtual QString subtypeName() const override { return name(spanner()->type()); }
42  virtual void draw(QPainter*) const override;
43 
44  void layoutSegment(const QPointF& p1, const QPointF& p2);
45 
46  bool isEdited() const;
47  virtual void editDrag(EditData&) override;
48  virtual bool edit(EditData&) override;
49 
50  Tie* tie() const { return (Tie*)spanner(); }
51 
52  virtual void computeBezier(QPointF so = QPointF());
53  };
54 
55 //---------------------------------------------------------
56 // @@ Tie
58 //---------------------------------------------------------
59 
60 class Tie final : public SlurTie {
62  static Note* editEndNote;
63 
64  public:
65  Tie(Score* = 0);
66  virtual Tie* clone() const override { return new Tie(*this); }
67  virtual ElementType type() const override { return ElementType::TIE; }
68 
69  void setStartNote(Note* note);
70  void setEndNote(Note* note) { setEndElement((Element*)note); }
71  Note* startNote() const;
72  Note* endNote() const;
73 
74  void calculateDirection();
75  virtual void write(XmlWriter& xml) const override;
76 // virtual void layout() override;
77  virtual void slurPos(SlurPos*) override;
78 
79  TieSegment* layoutFor(System*);
80  TieSegment* layoutBack(System*);
81 
82  TieSegment* frontSegment() { return toTieSegment(Spanner::frontSegment()); }
83  const TieSegment* frontSegment() const { return toTieSegment(Spanner::frontSegment()); }
84  TieSegment* backSegment() { return toTieSegment(Spanner::backSegment()); }
85  const TieSegment* backSegment() const { return toTieSegment(Spanner::backSegment()); }
86  TieSegment* segmentAt(int n) { return toTieSegment(Spanner::segmentAt(n)); }
87  const TieSegment* segmentAt(int n) const { return toTieSegment(Spanner::segmentAt(n)); }
88 
89  virtual SlurTieSegment* newSlurTieSegment() override { return new TieSegment(score()); }
90  };
91 
92 } // namespace Ms
93 #endif
94 
virtual QString subtypeName() const override
Definition: tie.h:41
void layoutSegment(const QPointF &p1, const QPointF &p2)
Definition: tie.cpp:326
static Note * editStartNote
Definition: tie.h:61
Definition: slurtie.h:132
virtual SlurTieSegment * newSlurTieSegment() override
Definition: tie.h:89
const TieSegment * frontSegment() const
Definition: tie.h:83
const TieSegment * segmentAt(int n) const
Definition: tie.h:87
virtual void computeBezier(QPointF so=QPointF())
Definition: tie.cpp:189
SpannerSegment * segmentAt(int n)
Definition: spanner.h:211
TieSegment(const TieSegment &s)
Definition: tie.h:37
Base class of score layout elements.
Definition: element.h:158
virtual TieSegment * clone() const override
Definition: tie.h:38
Spanner * spanner() const
Definition: spanner.h:67
virtual void write(XmlWriter &) const
Definition: element.cpp:732
virtual ElementType type() const =0
TieSegment(Score *s)
Definition: tie.h:36
Definition: score.h:391
QPointF autoAdjustOffset
Definition: tie.h:26
void setAutoAdjust(const QPointF &offset)
Definition: tie.cpp:390
const TieSegment * backSegment() const
Definition: tie.h:85
virtual int subtype() const override
Definition: tie.h:40
TieSegment * segmentAt(int n)
Definition: tie.h:86
TieSegment * frontSegment()
Definition: tie.h:82
Score * score() const
Definition: scoreElement.h:189
TieSegment * backSegment()
Definition: tie.h:84
SpannerSegment * backSegment()
Definition: spanner.h:209
Definition: aeolus.cpp:26
Definition: slurtie.h:80
Definition: slurtie.h:25
Definition: xml.h:218
virtual Tie * clone() const override
Definition: tie.h:66
virtual qreal y() const
Definition: element.h:232
a Tie has a Note as startElement/endElement
Definition: tie.h:60
virtual qreal x() const
Definition: element.h:231
const QPointF & offset() const
Definition: element.h:245
Definition: element.h:111
virtual ElementType type() const override
Definition: tie.h:67
One row of measures for all instruments; a complete piece of the timeline.
Definition: system.h:79
const char * name() const
Definition: scoreElement.cpp:787
static Note * editEndNote
Definition: tie.h:62
Graphic representation of a note.
Definition: note.h:212
virtual void changeAnchor(EditData &, Element *) override
Definition: tie.cpp:92
ElementType
Definition: types.h:34
virtual bool edit(EditData &) override
Definition: tie.cpp:71
void setEndNote(Note *note)
Definition: tie.h:70
virtual ElementType type() const override
Definition: tie.h:39
bool isEdited() const
Definition: tie.cpp:407
Tie * tie() const
Definition: tie.h:50
QPointF getAutoAdjust() const
Definition: tie.h:30
SpannerSegment * frontSegment()
Definition: spanner.h:207
void setAutoAdjust(qreal x, qreal y)
Definition: tie.h:29
virtual void editDrag(EditData &) override
Definition: tie.cpp:132
a single segment of slur; also used for Tie
Definition: tie.h:25
virtual void draw(QPainter *) const override
Definition: tie.cpp:29