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 : #pragma once
24 :
25 : #include <QFrame>
26 :
27 : #include "modularity/ioc.h"
28 : #include "ipaletteconfiguration.h"
29 : #include "notation/inotationconfiguration.h"
30 : #include "engraving/iengravingconfiguration.h"
31 : #include "engraving/rendering/isinglerenderer.h"
32 : #include "engraving/ipalettescoreprovider.h"
33 : namespace mu::engraving {
34 : class Accidental;
35 : class Clef;
36 : }
37 :
38 : namespace mu::palette {
39 : class KeyCanvas : public QFrame, public muse::Contextable
40 : {
41 : Q_OBJECT
42 :
43 : muse::GlobalInject<IPaletteConfiguration> configuration;
44 : muse::GlobalInject<notation::INotationConfiguration> notationConfiguration;
45 : muse::GlobalInject<engraving::IEngravingConfiguration> engravingConfiguration;
46 : muse::GlobalInject<engraving::rendering::ISingleRenderer> engravingRender;
47 : muse::ContextInject<engraving::IPaletteScoreProvider> paletteScoreProvider = { this };
48 :
49 : engraving::Accidental* dragElement = nullptr;
50 : engraving::Accidental* moveElement = nullptr;
51 : QTransform _matrix, imatrix;
52 : double extraMag = 1.0;
53 : QList<engraving::Accidental*> accidentals;
54 : QPointF startMove;
55 : QPointF base;
56 : engraving::Clef* clef = nullptr;
57 :
58 : virtual void paintEvent(QPaintEvent*);
59 : virtual void mousePressEvent(QMouseEvent*);
60 : virtual void mouseMoveEvent(QMouseEvent*);
61 : virtual void mouseReleaseEvent(QMouseEvent*);
62 :
63 : virtual void dragEnterEvent(QDragEnterEvent*);
64 : virtual void dragMoveEvent(QDragMoveEvent*);
65 : virtual void dropEvent(QDropEvent*);
66 : void snap(engraving::Accidental*);
67 :
68 : private slots:
69 : void deleteElement();
70 :
71 : public:
72 : KeyCanvas(QWidget* parent = 0);
73 : void clear();
74 0 : const QList<engraving::Accidental*> getAccidentals() const { return accidentals; }
75 : };
76 : }
|