File: box.h

package info (click to toggle)
musescore3 3.2.3%2Bdfsg2-16
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 214,188 kB
  • sloc: cpp: 291,198; xml: 200,238; sh: 3,779; ansic: 1,447; python: 393; makefile: 244; perl: 82; pascal: 79
file content (159 lines) | stat: -rw-r--r-- 6,210 bytes parent folder | download | duplicates (4)
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//=============================================================================
//  MuseScore
//  Music Composition & Notation
//
//  Copyright (C) 2002-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 __BOX_H__
#define __BOX_H__

/**
 \file
 Definition of HBox and VBox classes.
*/

#include "measurebase.h"
#include "property.h"

namespace Ms {

class MuseScoreView;

//---------------------------------------------------------
//   @@ Box
///    virtual base class for frames "boxes"
//---------------------------------------------------------

class Box : public MeasureBase {
      Spatium _boxWidth             { Spatium(0) };  // only valid for HBox
      Spatium _boxHeight            { Spatium(0) };  // only valid for VBox
      qreal _topGap                 { 0.0   };       // distance from previous system (left border for hbox)
                                                     // initialized with Sid::systemFrameDistance
      qreal _bottomGap              { 0.0   };       // distance to next system (right border for hbox)
                                                     // initialized with Sid::frameSystemDistance
      qreal _leftMargin             { 0.0   };
      qreal _rightMargin            { 0.0   };       // inner margins in metric mm
      qreal _topMargin              { 0.0   };
      qreal _bottomMargin           { 0.0   };
      bool editMode                 { false };
      qreal dragX;                        // used during drag of hbox

   public:
      Box(Score*);
      virtual void draw(QPainter*) const override;
      virtual bool isEditable() const override { return true; }

      virtual void startEdit(EditData&) override;
      virtual bool edit(EditData&) override;
      virtual void startEditDrag(EditData&) override;
      virtual void editDrag(EditData&) override;
      virtual void endEdit(EditData&) override;

      virtual void updateGrips(EditData&) const override;
      virtual void layout() override;
      virtual void write(XmlWriter&) const override;
      virtual void write(XmlWriter& xml, int, bool, bool) const override { write(xml); }
      virtual void writeProperties(XmlWriter&) const override;
      virtual bool readProperties(XmlReader&) override;
      virtual void read(XmlReader&) override;
      virtual bool acceptDrop(EditData&) const override;
      virtual Element* drop(EditData&) override;
      virtual void add(Element* e) override;

      Spatium boxWidth() const        { return _boxWidth;     }
      void setBoxWidth(Spatium val)   { _boxWidth = val;      }
      Spatium boxHeight() const       { return _boxHeight;    }
      void setBoxHeight(Spatium val)  { _boxHeight = val;     }
      qreal leftMargin() const        { return _leftMargin;   }
      qreal rightMargin() const       { return _rightMargin;  }
      qreal topMargin() const         { return _topMargin;    }
      qreal bottomMargin() const      { return _bottomMargin; }
      void setLeftMargin(qreal val)   { _leftMargin = val;    }
      void setRightMargin(qreal val)  { _rightMargin = val;   }
      void setTopMargin(qreal val)    { _topMargin = val;     }
      void setBottomMargin(qreal val) { _bottomMargin = val;  }
      qreal topGap() const            { return _topGap;       }
      void setTopGap(qreal val)       { _topGap = val;        }
      qreal bottomGap() const         { return _bottomGap;    }
      void setBottomGap(qreal val)    { _bottomGap = val;     }
      void copyValues(Box* origin);

      virtual QVariant getProperty(Pid propertyId) const override;
      virtual bool setProperty(Pid propertyId, const QVariant&) override;
      virtual QVariant propertyDefault(Pid) const override;
      };

//---------------------------------------------------------
//   @@ HBox
///    horizontal frame
//---------------------------------------------------------

class HBox final : public Box {
      bool _createSystemHeader { true };

   public:
      HBox(Score* score);
      virtual ~HBox() {}
      virtual HBox* clone() const override        { return new HBox(*this); }
      virtual ElementType type() const override { return ElementType::HBOX;       }

      virtual void layout() override;
      virtual void writeProperties(XmlWriter&) const override;
      virtual bool readProperties(XmlReader&) override;

      virtual QRectF drag(EditData&) override;
      virtual void endEditDrag(EditData&) override;
      void layout2();
      virtual bool isMovable() const override;
      virtual void computeMinWidth();

      bool createSystemHeader() const      { return _createSystemHeader; }
      void setCreateSystemHeader(bool val) { _createSystemHeader = val;  }

      virtual QVariant getProperty(Pid propertyId) const override;
      virtual bool setProperty(Pid propertyId, const QVariant&) override;
      virtual QVariant propertyDefault(Pid) const override;
      };

//---------------------------------------------------------
//   @@ VBox
///    vertical frame
//---------------------------------------------------------

class VBox : public Box {
   public:
      VBox(Score* score);
      virtual ~VBox() {}
      virtual VBox* clone() const override        { return new VBox(*this);           }
      virtual ElementType type() const override { return ElementType::VBOX;       }

      virtual void layout() override;

      };

//---------------------------------------------------------
//   @@ FBox
///    frame containing fret diagrams
//---------------------------------------------------------

class FBox : public VBox {
   public:
      FBox(Score* score) : VBox(score) {}
      virtual ~FBox() {}
      virtual FBox* clone() const override        { return new FBox(*this); }
      virtual ElementType type() const override { return ElementType::FBOX;       }

      virtual void layout() override;
      virtual void add(Element*) override;
      };


}     // namespace Ms
#endif