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 : #ifndef MU_ENGRAVING_CONNECTORINFOREADER_H
23 : #define MU_ENGRAVING_CONNECTORINFOREADER_H
24 :
25 : #include "../../dom/connector.h"
26 :
27 : //---------------------------------------------------------
28 : // @@ ConnectorInfoReader
29 : /// Helper class for reading beams, tuplets and spanners.
30 : //---------------------------------------------------------
31 :
32 : namespace mu::engraving {
33 : class XmlReader;
34 : class ChordRest;
35 : class Measure;
36 : class Note;
37 : }
38 :
39 : namespace mu::engraving::read400 {
40 : class ReadContext;
41 : class ConnectorInfoReader final : public ConnectorInfo
42 : {
43 6124 : OBJECT_ALLOCATOR(engraving, ConnectorInfoReader)
44 :
45 : public:
46 : ConnectorInfoReader(XmlReader& e, ReadContext* ctx, EngravingItem* current, int track = -1);
47 : ConnectorInfoReader(XmlReader& e, ReadContext* ctx, Score* current, int track = -1);
48 :
49 3100 : ConnectorInfoReader* prev() const { return static_cast<ConnectorInfoReader*>(m_prev); }
50 6126 : ConnectorInfoReader* next() const { return static_cast<ConnectorInfoReader*>(m_next); }
51 :
52 : EngravingItem* connector();
53 : const EngravingItem* connector() const;
54 : EngravingItem* releaseConnector(); // returns connector and "forgets" it by
55 : // setting an internal pointer to it to zero
56 :
57 : bool read();
58 : void update();
59 : void addToScore(bool pasteMode);
60 :
61 : static void readConnector(std::shared_ptr<ConnectorInfoReader> info, XmlReader& e, ReadContext& ctx);
62 :
63 : static void readAddConnector(ChordRest* item, ConnectorInfoReader* info, bool pasteMode);
64 : static void readAddConnector(Measure* item, ConnectorInfoReader* info, bool pasteMode);
65 : static void readAddConnector(Note* item, ConnectorInfoReader* info, bool pasteMode);
66 : static void readAddConnector(Score* item, ConnectorInfoReader* info, bool pasteMode);
67 :
68 : private:
69 : void readEndpointLocation(Location& l);
70 :
71 : XmlReader* m_reader = nullptr;
72 : ReadContext* m_ctx = nullptr;
73 : EngravingItem* m_connector = nullptr;
74 : EngravingObject* m_connectorReceiver = nullptr;
75 : };
76 : }
77 :
78 : #endif // MU_ENGRAVING_CONNECTORINFOREADER_H
|