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 : #pragma once
23 :
24 : #include "../xmlreader.h"
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 ChordRest;
34 : class Measure;
35 : class Note;
36 : }
37 :
38 : namespace mu::engraving::read460 {
39 : class ReadContext;
40 : class ConnectorInfoReader final : public ConnectorInfo
41 : {
42 664 : OBJECT_ALLOCATOR(engraving, ConnectorInfoReader)
43 :
44 : public:
45 : ConnectorInfoReader(XmlReader& e, ReadContext* ctx, EngravingItem* current, int track = -1);
46 : ConnectorInfoReader(XmlReader& e, ReadContext* ctx, Score* current, int track = -1);
47 :
48 428 : ConnectorInfoReader* prev() const { return static_cast<ConnectorInfoReader*>(m_prev); }
49 664 : ConnectorInfoReader* next() const { return static_cast<ConnectorInfoReader*>(m_next); }
50 :
51 : EngravingItem* connector();
52 : const EngravingItem* connector() const;
53 : EngravingItem* releaseConnector(); // returns connector and "forgets" it by
54 : // setting an internal pointer to it to zero
55 :
56 : bool read();
57 : void update();
58 : void addToScore(bool pasteMode);
59 :
60 : static void readConnector(std::shared_ptr<ConnectorInfoReader> info, XmlReader& e, ReadContext& ctx);
61 :
62 : static void readAddConnector(ChordRest* item, ConnectorInfoReader* info, bool pasteMode);
63 : static void readAddConnector(Measure* item, ConnectorInfoReader* info, bool pasteMode);
64 : static void readAddConnector(Note* item, ConnectorInfoReader* info, bool pasteMode);
65 : static void readAddConnector(Score* item, ConnectorInfoReader* info, bool pasteMode);
66 :
67 : private:
68 : void readEndpointLocation(Location& l);
69 : Fraction curTick() const;
70 :
71 : XmlReader* m_reader = nullptr;
72 : ReadContext* m_ctx = nullptr;
73 : EngravingItem* m_connector = nullptr;
74 : EngravingObject* m_connectorReceiver = nullptr;
75 : };
76 : }
|