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 <vector>
26 :
27 : #include "modularity/ioc.h"
28 : #include "notation/inotationconfiguration.h"
29 : #include "engraving/iengravingconfiguration.h"
30 : #include "engraving/rendering/iscorerenderer.h"
31 :
32 : #include "draw/types/geometry.h"
33 : #include "notation/inotation.h"
34 :
35 : namespace mu::engraving {
36 : class Score;
37 : class Text;
38 : class Clef;
39 : class KeySig;
40 : class TimeSig;
41 : class BarLine;
42 : class Segment;
43 : }
44 :
45 : namespace muse::draw {
46 : class Painter;
47 : }
48 :
49 : namespace mu::notation {
50 : class ContinuousPanel
51 : {
52 : muse::GlobalInject<INotationConfiguration> notationConfiguration;
53 : muse::GlobalInject<engraving::IEngravingConfiguration> engravingConfiguration;
54 : muse::GlobalInject<engraving::rendering::IScoreRenderer> scoreRender;
55 :
56 : public:
57 0 : ContinuousPanel() = default;
58 : ~ContinuousPanel();
59 :
60 : void setNotation(INotationPtr notation);
61 :
62 : struct NotationViewContext {
63 : qreal xOffset = 0.;
64 : qreal yOffset = 0.;
65 : qreal scaling = 0.;
66 : std::function<muse::PointF(const muse::PointF&)> fromLogical;
67 : };
68 :
69 : qreal width() const;
70 : void paint(muse::draw::Painter& painter, const NotationViewContext& ctx, const engraving::rendering::PaintOptions& opt);
71 :
72 : private:
73 : void clearCache();
74 : void ensureCacheSize(size_t staffCount);
75 :
76 : INotationPtr m_notation;
77 : qreal m_width = 0;
78 : muse::RectF m_rect;
79 :
80 : mu::engraving::Text* m_cachedMeasureNumberText = nullptr;
81 : std::vector<mu::engraving::Text*> m_cachedStaffNameTexts;
82 : std::vector<mu::engraving::Clef*> m_cachedClefs;
83 : std::vector<mu::engraving::KeySig*> m_cachedKeySigs;
84 : std::vector<mu::engraving::TimeSig*> m_cachedTimeSigs;
85 : std::vector<mu::engraving::BarLine*> m_cachedBarLines;
86 : };
87 : }
|