1 //============================================================================= 2 // MuseScore 3 // Music Composition & Notation 4 // 5 // Copyright (C) 2008-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 __SPACER_H__ 14 #define __SPACER_H__ 15 16 #include "element.h" 17 18 namespace Ms { 19 20 //--------------------------------------------------------- 21 // SpacerType 22 //--------------------------------------------------------- 23 24 enum class SpacerType : char { 25 UP, DOWN, FIXED 26 }; 27 28 //------------------------------------------------------------------- 29 // @@ Spacer 30 /// Vertical spacer element to adjust the distance of staves. 31 //------------------------------------------------------------------- 32 33 class Spacer final : public Element { 34 SpacerType _spacerType; 35 qreal _gap; 36 37 QPainterPath path; 38 39 void layout0(); 40 41 public: 42 Spacer(Score*); 43 Spacer(const Spacer&); 44 clone()45 Spacer* clone() const override { return new Spacer(*this); } type()46 ElementType type() const override { return ElementType::SPACER; } 47 spacerType()48 SpacerType spacerType() const { return _spacerType; } setSpacerType(SpacerType t)49 void setSpacerType(SpacerType t) { _spacerType = t; } 50 51 void write(XmlWriter&) const override; 52 void read(XmlReader&) override; 53 54 void draw(QPainter*) const override; 55 isEditable()56 bool isEditable() const override { return true; } 57 void startEditDrag(EditData&) override; 58 void editDrag(EditData&) override; 59 void spatiumChanged(qreal, qreal) override; 60 61 void setGap(qreal sp); gap()62 qreal gap() const { return _gap; } 63 normalModeEditBehavior()64 EditBehavior normalModeEditBehavior() const override { return EditBehavior::Edit; } gripsCount()65 int gripsCount() const override { return 1; } initialEditModeGrip()66 Grip initialEditModeGrip() const override { return Grip::START; } defaultGrip()67 Grip defaultGrip() const override { return Grip::START; } 68 std::vector<QPointF> gripsPositions(const EditData&) const override; 69 70 QVariant getProperty(Pid propertyId) const override; 71 bool setProperty(Pid propertyId, const QVariant&) override; 72 QVariant propertyDefault(Pid id) const override; 73 }; 74 75 76 } // namespace Ms 77 #endif 78