/
spanner.h
129 lines (102 loc) · 4.3 KB
/
spanner.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//=============================================================================
// MuseScore
// Music Composition & Notation
// $Id:$
//
// Copyright (C) 2010-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 __SPANNER_H__
#define __SPANNER_H__
#include "element.h"
class Segment;
class Spanner;
class System;
enum SpannerSegmentType {
SEGMENT_SINGLE, SEGMENT_BEGIN, SEGMENT_MIDDLE, SEGMENT_END
};
//---------------------------------------------------------
// @@ SpannerSegment
//---------------------------------------------------------
class SpannerSegment : public Element {
Q_OBJECT
SpannerSegmentType _subtype;
Spanner* _spanner;
public:
SpannerSegment(Score* s);
SpannerSegment(const SpannerSegment&);
virtual SpannerSegment* clone() const = 0;
Spanner* spanner() const { return _spanner; }
Spanner* setSpanner(Spanner* val) { return _spanner = val; }
void setSubtype(SpannerSegmentType s) { _subtype = s; }
SpannerSegmentType subtype() const { return _subtype; }
void setSystem(System* s);
System* system() const { return (System*)parent(); }
virtual void startEdit(MuseScoreView*, const QPointF&);
virtual void endEdit();
virtual bool isEditable() const { return true; }
virtual bool isEdited(SpannerSegment*) const = 0;
};
//---------------------------------------------------------
// @@ Spanner
/// Virtual base class for slurs, ties, lines etc.
//
// @P startElement Element*
// @P endElement Element*
//---------------------------------------------------------
class Spanner : public Element {
Q_OBJECT
Q_PROPERTY(Element* startElement READ startElement WRITE setStartElement)
Q_PROPERTY(Element* endElement READ endElement WRITE setEndElement)
Element* _startElement; // can be ChordRest, Segment or Measure
Element* _endElement; // depending on anchor
Anchor _anchor; // enum { ANCHOR_SEGMENT, ANCHOR_MEASURE,
// ANCHOR_CHORD, ANCHOR_NOTE};
QList<SpannerSegment*> segments;
int _tick1, _tick2; // used for backward compatibility
int _id; // used for xml serialization
protected:
Element* oStartElement; // start/end element at startEdit()
Element* oEndElement;
qreal _yoffset; // in spatium units
public:
Spanner(Score* = 0);
Spanner(const Spanner&);
~Spanner();
virtual ElementType type() const = 0;
virtual void setScore(Score* s);
void setStartElement(Element* e) { _startElement = e; }
void setEndElement(Element* e) { _endElement = e; }
Element* startElement() const { return _startElement; }
Element* endElement() const { return _endElement; }
//
// used for backward compatibility:
//
void __setTick1(int v) { _tick1 = v; }
void __setTick2(int v) { _tick2 = v; }
int __tick1() const { return _tick1; }
int __tick2() const { return _tick2; }
int id() const { return _id; }
void setId(int v) { _id = v; }
Anchor anchor() const { return _anchor; }
void setAnchor(Anchor a) { _anchor = a; }
const QList<SpannerSegment*>& spannerSegments() const { return segments; }
QList<SpannerSegment*>& spannerSegments() { return segments; }
virtual void add(Element*);
virtual void remove(Element*);
virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true);
virtual void startEdit(MuseScoreView*, const QPointF&);
virtual void setSelected(bool f);
void setYoff(qreal d) { _yoffset = d; }
qreal yoff() const { return _yoffset; }
virtual bool isEdited(Spanner* originalSpanner) const;
int startTick() const;
int endTick() const;
bool removeSpannerBack();
void addSpannerBack();
};
#endif