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 : #include "lasso.h"
24 :
25 : #include "score.h"
26 :
27 : using namespace mu;
28 : using namespace mu::engraving;
29 :
30 : namespace mu::engraving {
31 : //---------------------------------------------------------
32 : // Lasso
33 : //---------------------------------------------------------
34 :
35 0 : Lasso::Lasso(Score* s)
36 0 : : EngravingItem(ElementType::LASSO, s)
37 : {
38 0 : setVisible(false);
39 0 : }
40 :
41 : //---------------------------------------------------------
42 : // dragGrip
43 : //---------------------------------------------------------
44 :
45 0 : void Lasso::dragGrip(EditData& ed)
46 : {
47 : //Qt::CursorShape cursorShape = Qt::ArrowCursor;
48 0 : Lasso::LayoutData* ldata = mutldata();
49 0 : RectF bbox = ldata->bbox();
50 0 : switch (int(ed.curGrip)) {
51 0 : case 0:
52 : //cursorShape = Qt::SizeFDiagCursor;
53 0 : bbox.setTopLeft(bbox.topLeft() + ed.delta);
54 0 : break;
55 0 : case 1:
56 : //cursorShape = Qt::SizeBDiagCursor;
57 0 : bbox.setTopRight(bbox.topRight() + ed.delta);
58 0 : break;
59 0 : case 2:
60 : //cursorShape = Qt::SizeFDiagCursor;
61 0 : bbox.setBottomRight(bbox.bottomRight() + ed.delta);
62 0 : break;
63 0 : case 3:
64 : //cursorShape = Qt::SizeBDiagCursor;
65 0 : bbox.setBottomLeft(bbox.bottomLeft() + ed.delta);
66 0 : break;
67 0 : case 4:
68 : //cursorShape = Qt::SizeVerCursor;
69 0 : bbox.setTop(bbox.top() + ed.delta.y());
70 0 : break;
71 0 : case 5:
72 : //cursorShape = Qt::SizeHorCursor;
73 0 : bbox.setRight(bbox.right() + ed.delta.x());
74 0 : break;
75 0 : case 6:
76 : //cursorShape = Qt::SizeVerCursor;
77 0 : bbox.setBottom(bbox.bottom() + ed.delta.y());
78 0 : break;
79 0 : case 7:
80 : //cursorShape = Qt::SizeHorCursor;
81 0 : bbox.setLeft(bbox.left() + ed.delta.x());
82 0 : break;
83 : }
84 :
85 0 : ldata->setBbox(bbox);
86 :
87 : // ed.view()->setCursor(QCursor(cursorShape));
88 0 : }
89 :
90 : //---------------------------------------------------------
91 : // gripsPositions
92 : //---------------------------------------------------------
93 :
94 0 : std::vector<PointF> Lasso::gripsPositions(const EditData&) const
95 : {
96 0 : const auto box(ldata()->bbox());
97 : return {
98 0 : box.topLeft(),
99 0 : box.topRight(),
100 0 : box.bottomRight(),
101 0 : box.bottomLeft(),
102 0 : PointF(box.x() + box.width() * .5, box.top()),
103 0 : PointF(box.right(), box.y() + box.height() * .5),
104 0 : PointF(box.x() + box.width() * .5, box.bottom()),
105 0 : PointF(box.left(), box.y() + box.height() * .5)
106 0 : };
107 : }
108 : }
|