MuseScore  3.4
Music composition and notation
bracket.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2002-2011 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 __BRACKET_H__
14 #define __BRACKET_H__
15 
16 #include "element.h"
17 #include "bracketItem.h"
18 
19 namespace Ms {
20 
21 class MuseScoreView;
22 class System;
23 enum class BracketType : signed char;
24 
25 //---------------------------------------------------------
26 // @@ Bracket
27 //---------------------------------------------------------
28 
29 class Bracket final : public Element {
31  qreal ay1;
32  qreal h2;
33 
36 
37  QPainterPath path;
40 
41  // horizontal scaling factor for brace symbol. Cannot be equal to magY or depend on h
42  // because layout needs width of brace before knowing height of system...
43  qreal _magx;
44  Measure* _measure = nullptr;
45 
46  public:
47  Bracket(Score*);
48  virtual ~Bracket();
49  virtual Bracket* clone() const override { return new Bracket(*this); }
50  virtual ElementType type() const override { return ElementType::BRACKET; }
51 
52  void setBracketItem(BracketItem* i) { _bi = i; }
53  BracketItem* bracketItem() const { return _bi; }
54 
55  BracketType bracketType() const { return _bi->bracketType(); }
56  static const char* bracketTypeName(BracketType type);
57 
58  int firstStaff() const { return _firstStaff; }
59  int lastStaff() const { return _lastStaff; }
60  void setStaffSpan(int a, int b);
61 
62  SymId braceSymbol() const { return _braceSymbol; }
63  int column() const { return _bi->column(); }
64  int span() const { return _bi->bracketSpan(); }
65  qreal magx() const { return _magx; }
66 
67  System* system() const { return (System*)parent(); }
68 
69  Measure* measure() const { return _measure; }
70  void setMeasure(Measure* measure) { _measure = measure; }
71 
72  virtual void setHeight(qreal) override;
73  virtual qreal width() const override;
74 
75  virtual Shape shape() const override { return _shape; }
76 
77  virtual void draw(QPainter*) const override;
78  virtual void layout() override;
79 
80  virtual void write(XmlWriter& xml) const override;
81  virtual void read(XmlReader&) override;
82 
83  virtual bool isEditable() const override { return true; }
84  virtual void startEdit(EditData&) override;
85  virtual bool edit(EditData&) override;
86  virtual void endEdit(EditData&) override;
87  virtual void editDrag(EditData&) override;
88  virtual void endEditDrag(EditData&) override;
89 
90  virtual bool acceptDrop(EditData&) const override;
91  virtual Element* drop(EditData&) override;
92 
93  virtual QVariant getProperty(Pid propertyId) const override;
94  virtual bool setProperty(Pid propertyId, const QVariant&) override;
95  virtual QVariant propertyDefault(Pid) const override;
96 
97  void undoChangeProperty(Pid id, const QVariant& v, PropertyFlags ps) override;
99 
100  int gripsCount() const override { return 1; }
101  Grip initialEditModeGrip() const override { return Grip::START; }
102  Grip defaultGrip() const override { return Grip::START; }
103  std::vector<QPointF> gripsPositions(const EditData&) const override;
104 
105  virtual void setSelected(bool f) override;
106  };
107 
108 
109 } // namespace Ms
110 #endif
111 
Definition: bracketItem.h:25
Pid
Definition: property.h:62
virtual Shape shape() const override
Definition: bracket.h:75
Definition: xml.h:67
virtual void undoChangeProperty(Pid id, const QVariant &, PropertyFlags ps)
Definition: scoreElement.cpp:291
qreal magx() const
Definition: bracket.h:65
int gripsCount() const override
Definition: bracket.h:100
int bracketSpan() const
Definition: bracketItem.h:40
Grip defaultGrip() const override
Definition: bracket.h:102
int firstStaff() const
Definition: bracket.h:58
one measure in a system
Definition: measure.h:65
virtual ElementType type() const override
Definition: bracket.h:50
BracketItem * _bi
Definition: bracket.h:30
QPainterPath path
Definition: bracket.h:37
Measure * measure() const
Definition: bracket.h:69
SymId
Definition: sym.h:30
qreal _magx
Definition: bracket.h:43
Base class of score layout elements.
Definition: element.h:158
virtual Bracket * clone() const override
Definition: bracket.h:49
int span() const
Definition: bracket.h:64
int column() const
Definition: bracketItem.h:47
SymId braceSymbol() const
Definition: bracket.h:62
int lastStaff() const
Definition: bracket.h:59
Definition: score.h:391
PropertyFlags
Definition: property.h:54
Definition: bracket.h:29
SymId _braceSymbol
Definition: bracket.h:38
Grip
Definition: element.h:43
Definition: aeolus.cpp:26
virtual bool isEditable() const override
Definition: bracket.h:83
Definition: xml.h:218
Grip initialEditModeGrip() const override
Definition: bracket.h:101
int _lastStaff
Definition: bracket.h:35
qreal h2
Definition: bracket.h:32
System * system() const
Definition: bracket.h:67
void setMeasure(Measure *measure)
Definition: bracket.h:70
int _firstStaff
Definition: bracket.h:34
BracketType bracketType() const
Definition: bracket.h:55
Definition: element.h:111
BracketType
Definition: mscore.h:107
One row of measures for all instruments; a complete piece of the timeline.
Definition: system.h:79
Definition: shape.h:42
ElementType
Definition: types.h:34
BracketType bracketType() const
Definition: bracketItem.h:41
int column() const
Definition: bracket.h:63
void setBracketItem(BracketItem *i)
Definition: bracket.h:52
BracketItem * bracketItem() const
Definition: bracket.h:53
Pid propertyId(const QStringRef &s)
Definition: property.cpp:347
Shape _shape
Definition: bracket.h:39
qreal ay1
Definition: bracket.h:31