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 __SLUR_H__
14 #define __SLUR_H__
15 
16 #include "slurtie.h"
17 
18 namespace Ms {
19 
20 //---------------------------------------------------------
21 //   @@ SlurSegment
22 ///    a single segment of slur; also used for Tie
23 //---------------------------------------------------------
24 
25 class SlurSegment final : public SlurTieSegment {
26 
27    protected:
28       qreal _extraHeight = 0.0;
29       void changeAnchor(EditData&, Element*) override;
30 
31    public:
SlurSegment(Score * s)32       SlurSegment(Score* s) : SlurTieSegment(s) {}
SlurSegment(const SlurSegment & ss)33       SlurSegment(const SlurSegment& ss) : SlurTieSegment(ss) {}
34 
clone()35       SlurSegment* clone() const override  { return new SlurSegment(*this); }
type()36       ElementType type() const override    { return ElementType::SLUR_SEGMENT; }
subtype()37       int subtype() const override         { return static_cast<int>(spanner()->type()); }
38       void draw(QPainter*) const override;
39 
40       void layoutSegment(const QPointF& p1, const QPointF& p2);
41 
42       bool isEdited() const;
43       bool edit(EditData&) override;
44 
slur()45       Slur* slur() const { return toSlur(spanner()); }
46 
47       void computeBezier(QPointF so = QPointF()) override;
48       };
49 
50 //---------------------------------------------------------
51 //   @@ Slur
52 //---------------------------------------------------------
53 
54 class Slur final : public SlurTie {
55 
56       void slurPosChord(SlurPos*);
57 
58    public:
59       Slur(Score* = 0);
~Slur()60       ~Slur() {}
61 
clone()62       Slur* clone() const override        { return new Slur(*this); }
type()63       ElementType type() const override { return ElementType::SLUR; }
64       void write(XmlWriter& xml) const override;
65       void layout() override;
66       SpannerSegment* layoutSystem(System*) override;
67       void setTrack(int val) override;
68       void slurPos(SlurPos*) override;
69 
frontSegment()70       SlurSegment* frontSegment()               { return toSlurSegment(Spanner::frontSegment()); }
frontSegment()71       const SlurSegment* frontSegment() const   { return toSlurSegment(Spanner::frontSegment()); }
backSegment()72       SlurSegment* backSegment()                { return toSlurSegment(Spanner::backSegment());  }
backSegment()73       const SlurSegment* backSegment() const    { return toSlurSegment(Spanner::backSegment());  }
segmentAt(int n)74       SlurSegment* segmentAt(int n)             { return toSlurSegment(Spanner::segmentAt(n));   }
segmentAt(int n)75       const SlurSegment* segmentAt(int n) const { return toSlurSegment(Spanner::segmentAt(n));   }
76 
newSlurTieSegment()77       SlurTieSegment* newSlurTieSegment() override { return new SlurSegment(score()); }
78       };
79 
80 }     // namespace Ms
81 #endif
82 
83