Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #ifndef MU_ENGRAVING_STAFFLINES_H
24 : #define MU_ENGRAVING_STAFFLINES_H
25 :
26 : #include <vector>
27 :
28 : #include "engravingitem.h"
29 :
30 : namespace mu::engraving {
31 : //-------------------------------------------------------------------
32 : // @@ StaffLines
33 : /// The StaffLines class is the graphic representation of a staff,
34 : /// it draws the horizontal staff lines.
35 : //-------------------------------------------------------------------
36 :
37 : class StaffLines final : public EngravingItem
38 : {
39 55290 : OBJECT_ALLOCATOR(engraving, StaffLines)
40 : DECLARE_CLASSOF(ElementType::STAFF_LINES)
41 :
42 : public:
43 :
44 0 : StaffLines* clone() const override { return new StaffLines(*this); }
45 0 : void setOwnershipParent(DummyParentOr<Measure> parent) { EngravingItem::setOwnershipParent(parent); }
46 :
47 : PointF pagePos() const override; ///< position in page coordinates
48 : PointF canvasPos() const override; ///< position in page coordinates
49 :
50 20 : const std::vector<LineF>& lines() const { return m_lines; }
51 50291 : void setLines(const std::vector<LineF>& l) { m_lines = l; }
52 :
53 266565 : Measure* measure() const { return (Measure*)ownershipParent(); }
54 : double y1() const;
55 :
56 100602 : double lw() const { return m_lw; }
57 50291 : void setLw(double w) { m_lw = w; }
58 :
59 : RectF hitBBox() const override;
60 : Shape hitShape() const override;
61 :
62 : bool collectForDrawing() const override;
63 :
64 : private:
65 : friend class Factory;
66 : StaffLines(DummyParentOr<Measure> parent);
67 :
68 : double m_lw = 0.0;
69 : std::vector<LineF> m_lines;
70 : };
71 : }
72 :
73 : #endif // MU_LIBMSCORE_STAFFLINES_H
|