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) 2023 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 : #include "scorerenderer.h"
23 :
24 : #include "dom/arpeggio.h"
25 : #include "dom/beam.h"
26 : #include "dom/textlinebase.h"
27 : #include "dom/harmony.h"
28 : #include "dom/chord.h"
29 :
30 : #include "tdraw.h"
31 : #include "tlayout.h"
32 : #include "textlayout.h"
33 : #include "chordlayout.h"
34 : #include "layoutcontext.h"
35 : #include "scorelayout.h"
36 : #include "scorepageviewlayout.h"
37 : #include "horizontalspacing.h"
38 : #include "slurtielayout.h"
39 : #include "headerfooterlayout.h"
40 :
41 : #include "paint.h"
42 :
43 : #include "log.h"
44 :
45 : using namespace muse::draw;
46 : using namespace mu::engraving;
47 : using namespace mu::engraving::rendering::score;
48 :
49 4000 : void ScoreRenderer::layoutScore(Score* score, const Fraction& st, const Fraction& et) const
50 : {
51 4000 : ScoreLayout::layoutRange(score, st, et);
52 4000 : }
53 :
54 0 : void ScoreRenderer::layoutHeadersFooters(Score* score) const
55 : {
56 0 : LayoutContext ctx(score);
57 0 : if (!ctx.conf().isMode(LayoutMode::PAGE) && !ctx.conf().isMode(LayoutMode::FLOAT)) {
58 0 : return;
59 : }
60 :
61 0 : ScorePageViewLayout::layoutHeadersFooters(ctx);
62 0 : }
63 :
64 1 : SizeF ScoreRenderer::pageSizeInch(const Score* score) const
65 : {
66 1 : return Paint::pageSizeInch(score);
67 : }
68 :
69 0 : SizeF ScoreRenderer::pageSizeInch(const Score* score, const ScorePaintOptions& opt) const
70 : {
71 0 : return Paint::pageSizeInch(score, opt);
72 : }
73 :
74 5 : void ScoreRenderer::paintScore(Painter* painter, Score* score, const ScorePaintOptions& opt) const
75 : {
76 5 : Paint::paintScore(painter, score, opt);
77 5 : }
78 :
79 0 : void ScoreRenderer::paintItem(Painter& painter, const EngravingItem* item, const PaintOptions& opt) const
80 : {
81 0 : Paint::paintItem(painter, item, opt);
82 0 : }
83 :
84 9 : void ScoreRenderer::doLayoutItem(EngravingItem* item)
85 : {
86 9 : LayoutContext ctx(item->score());
87 9 : TLayout::layoutItem(item, ctx);
88 9 : }
89 :
90 0 : void ScoreRenderer::doDrawItem(const EngravingItem* item, Painter* p, const PaintOptions& opt)
91 : {
92 0 : TDraw::drawItem(item, p, opt);
93 0 : }
94 :
95 31766 : void ScoreRenderer::layoutText1(TextBase* item, bool base)
96 : {
97 31766 : LayoutContext ctx(item->score());
98 31766 : if (base) {
99 0 : TextLayout::layoutBaseTextBase1(item, ctx);
100 31766 : } else if (Harmony::classof(item)) {
101 0 : TLayout::layoutHarmony(toHarmony(item), toHarmony(item)->mutldata(), ctx);
102 : } else {
103 31766 : TextLayout::layoutBaseTextBase1(item, ctx);
104 : }
105 31766 : }
106 :
107 0 : void ScoreRenderer::computeBezier(TieSegment* tieSeg, PointF shoulderOffset)
108 : {
109 0 : SlurTieLayout::computeBezier(tieSeg, shoulderOffset);
110 0 : }
111 :
112 0 : void ScoreRenderer::computeBezier(SlurSegment* slurSeg, PointF shoulderOffset)
113 : {
114 0 : SlurTieLayout::computeBezier(slurSeg, shoulderOffset);
115 0 : }
116 :
117 98 : void ScoreRenderer::layoutTextLineBaseSegment(TextLineBaseSegment* item)
118 : {
119 98 : LayoutContext ctx(item->score());
120 98 : TLayout::layoutTextLineBaseSegment(item, ctx);
121 98 : }
122 :
123 109 : void ScoreRenderer::layoutBeam1(Beam* item)
124 : {
125 109 : LayoutContext ctx(item->score());
126 109 : TLayout::layoutBeam1(item, ctx);
127 109 : }
128 :
129 34216 : void ScoreRenderer::layoutStem(Chord* item)
130 : {
131 34216 : LayoutContext ctx(item->score());
132 34216 : ChordLayout::layoutStem(item, ctx);
133 34216 : }
134 :
135 0 : bool ScoreRenderer::scoreHasTimestampHeadersFooters(const Score* score) const
136 : {
137 0 : if (score->layoutMode() != LayoutMode::PAGE && score->layoutMode() != LayoutMode::FLOAT) {
138 0 : return false;
139 : }
140 0 : return HeaderFooterLayout::scoreHasTimestampHeadersFooters(score);
141 : }
|