1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2019 Werner Schweer and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#include "score.h"
#include "cursor.h"
#include "elements.h"
#include "libmscore/measure.h"
#include "libmscore/score.h"
#include "libmscore/segment.h"
#include "libmscore/text.h"
namespace Ms {
namespace PluginAPI {
//---------------------------------------------------------
// Score::newCursor
//---------------------------------------------------------
Cursor* Score::newCursor()
{
return new Cursor(score());
}
//---------------------------------------------------------
// Score::addText
/// \brief Adds a header text to the score.
/// \param type One of the following values:
/// - "title"
/// - "subtitle"
/// - "composer"
/// - "lyricist"
/// - Any other value corresponds to default text style.
/// \param txt Text to be added.
//---------------------------------------------------------
void Score::addText(const QString& type, const QString& txt)
{
MeasureBase* measure = score()->first();
if (!measure || !measure->isVBox()) {
score()->insertMeasure(ElementType::VBOX, measure);
measure = score()->first();
}
Tid tid = Tid::DEFAULT;
if (type == "title")
tid = Tid::TITLE;
else if (type == "subtitle")
tid = Tid::SUBTITLE;
else if (type == "composer")
tid = Tid::COMPOSER;
else if (type == "lyricist")
tid = Tid::POET;
Ms::Text* text = new Ms::Text(score(), tid);
text->setParent(measure);
text->setXmlText(txt);
score()->undoAddElement(text);
}
//---------------------------------------------------------
// Score::firstSegment
//---------------------------------------------------------
Segment* Score::firstSegment()
{
return wrap<Segment>(score()->firstSegment(Ms::SegmentType::All), Ownership::SCORE);
}
//---------------------------------------------------------
// Score::lastSegment
//---------------------------------------------------------
Segment* Score::lastSegment()
{
return wrap<Segment>(score()->lastSegment(), Ownership::SCORE);
}
//---------------------------------------------------------
// Score::firstMeasure
//---------------------------------------------------------
Measure* Score::firstMeasure()
{
return wrap<Measure>(score()->firstMeasure(), Ownership::SCORE);
}
//---------------------------------------------------------
// Score::firstMeasureMM
//---------------------------------------------------------
Measure* Score::firstMeasureMM()
{
return wrap<Measure>(score()->firstMeasureMM(), Ownership::SCORE);
}
//---------------------------------------------------------
// Score::lastMeasure
//---------------------------------------------------------
Measure* Score::lastMeasure()
{
return wrap<Measure>(score()->lastMeasure(), Ownership::SCORE);
}
//---------------------------------------------------------
// Score::firstMeasureMM
//---------------------------------------------------------
Measure* Score::lastMeasureMM()
{
return wrap<Measure>(score()->lastMeasureMM(), Ownership::SCORE);
}
}
}
|