MuseScore/mscore/menus.cpp

1100 lines
36 KiB
C++
Raw Normal View History

2012-05-26 14:49:10 +02:00
//=============================================================================
// MuseScore
// Linux Music Score Editor
// $Id: menus.cpp 5651 2012-05-19 15:57:26Z lasconic $
//
// Copyright (C) 2002-2011 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.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "libmscore/score.h"
#include "palette.h"
2013-02-10 14:50:18 +01:00
#include "palettebox.h"
2012-05-26 14:49:10 +02:00
#include "libmscore/note.h"
#include "libmscore/chordrest.h"
#include "libmscore/dynamic.h"
#include "libmscore/slur.h"
#include "libmscore/sym.h"
#include "libmscore/hairpin.h"
#include "scoreview.h"
#include "musescore.h"
#include "edittempo.h"
#include "libmscore/select.h"
#include "libmscore/tempo.h"
#include "libmscore/segment.h"
#include "libmscore/undo.h"
#include "icons.h"
#include "libmscore/bracket.h"
#include "libmscore/ottava.h"
#include "libmscore/textline.h"
#include "libmscore/trill.h"
#include "libmscore/pedal.h"
#include "libmscore/clef.h"
#include "libmscore/timesig.h"
#include "libmscore/barline.h"
#include "libmscore/layoutbreak.h"
#include "symboldialog.h"
#include "libmscore/volta.h"
#include "libmscore/keysig.h"
#include "libmscore/breath.h"
#include "libmscore/arpeggio.h"
#include "libmscore/tremolo.h"
#include "libmscore/repeat.h"
#include "libmscore/tempotext.h"
#include "libmscore/glissando.h"
#include "libmscore/articulation.h"
#include "libmscore/chord.h"
#include "libmscore/drumset.h"
#include "libmscore/spacer.h"
#include "libmscore/measure.h"
#include "libmscore/fret.h"
#include "libmscore/staffstate.h"
#include "libmscore/fingering.h"
#include "libmscore/bend.h"
#include "libmscore/tremolobar.h"
#include "libmscore/chordline.h"
#include "libmscore/stafftext.h"
#include "libmscore/instrchange.h"
2013-02-06 16:43:25 +01:00
#include "workspace.h"
2012-05-26 14:49:10 +02:00
#include "libmscore/icon.h"
#include "libmscore/accidental.h"
#include "libmscore/harmony.h"
#include "libmscore/rehearsalmark.h"
#include "shortcut.h"
2013-02-25 14:56:34 +01:00
#include "libmscore/marker.h"
#include "libmscore/jump.h"
2012-05-26 14:49:10 +02:00
2013-05-13 18:49:17 +02:00
namespace Ms {
2012-05-26 14:49:10 +02:00
extern bool useFactorySettings;
//---------------------------------------------------------
// populateIconPalette
//---------------------------------------------------------
void populateIconPalette(Palette* p, const IconAction* a)
{
while (a->subtype != -1) {
Icon* ik = new Icon(gscore);
ik->setIconType(a->subtype);
2012-05-26 14:49:10 +02:00
Shortcut* s = Shortcut::getShortcut(a->action);
QAction* action = s->action();
QIcon icon(action->icon());
ik->setAction(a->action, icon);
p->append(ik, s->help());
++a;
}
}
//---------------------------------------------------------
// newBeamPalette
//---------------------------------------------------------
Palette* MuseScore::newBeamPalette()
{
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Beam Properties"));
2012-05-26 14:49:10 +02:00
sp->setGrid(27, 40);
sp->setDrawGrid(true);
static const IconAction bpa[] = {
{ ICON_SBEAM, "beam-start" },
{ ICON_MBEAM, "beam-mid" },
{ ICON_NBEAM, "no-beam" },
{ ICON_BEAM32, "beam32" },
{ ICON_BEAM64, "beam64" },
{ ICON_AUTOBEAM, "auto-beam" },
{ ICON_FBEAM1, "fbeam1" },
{ ICON_FBEAM2, "fbeam2" },
{ -1, ""}
};
populateIconPalette(sp, bpa);
return sp;
}
//---------------------------------------------------------
// newFramePalette
//---------------------------------------------------------
Palette* MuseScore::newFramePalette()
{
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Frames"));
2012-05-26 14:49:10 +02:00
sp->setGrid(27, 40);
sp->setDrawGrid(true);
if(enableExperimental) {
static const IconAction bpa[] = {
{ ICON_VFRAME, "insert-vbox" },
{ ICON_HFRAME, "insert-hbox" },
{ ICON_TFRAME, "insert-textframe" },
{ ICON_FFRAME, "insert-fretframe" },
{ ICON_MEASURE, "insert-measure" },
{ -1, ""}
};
populateIconPalette(sp, bpa);
}
else {
static const IconAction bpa[] = {
{ ICON_VFRAME, "insert-vbox" },
{ ICON_HFRAME, "insert-hbox" },
{ ICON_TFRAME, "insert-textframe" },
{ ICON_MEASURE, "insert-measure" },
{ -1, ""}
};
populateIconPalette(sp, bpa);
}
2012-05-26 14:49:10 +02:00
return sp;
}
//---------------------------------------------------------
// newDynamicsPalette
//---------------------------------------------------------
Palette* MuseScore::newDynamicsPalette()
{
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Dynamics"));
2012-05-26 14:49:10 +02:00
sp->setMag(.8);
sp->setGrid(42, 28);
sp->setDrawGrid(true);
2013-02-13 22:01:48 +01:00
const char* array[8] = { "ppp", "pp", "p", "mp", "mf", "f", "ff", "fff" };
for (const char* c : array) {
2012-05-26 14:49:10 +02:00
Dynamic* dynamic = new Dynamic(gscore);
dynamic->setDynamicType(c);
sp->append(dynamic, dynamic->dynamicTypeName());
2012-05-26 14:49:10 +02:00
}
return sp;
}
//---------------------------------------------------------
// newKeySigPalette
//---------------------------------------------------------
Palette* MuseScore::newKeySigPalette()
{
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Key Signatures"));
2012-05-26 14:49:10 +02:00
sp->setMag(0.8);
sp->setGrid(56, 45);
sp->setYOffset(1.0);
for (int i = 0; i < 7; ++i) {
KeySig* k = new KeySig(gscore);
k->setKeySigEvent(KeySigEvent(i+1));
2013-03-01 17:14:21 +01:00
sp->append(k, keyNames[i*2]);
2012-05-26 14:49:10 +02:00
}
for (int i = -7; i < 0; ++i) {
KeySig* k = new KeySig(gscore);
k->setKeySigEvent(KeySigEvent(i));
2013-03-01 17:14:21 +01:00
sp->append(k, keyNames[(7 + i) * 2 + 1]);
2012-05-26 14:49:10 +02:00
}
KeySig* k = new KeySig(gscore);
k->setKeySigEvent(KeySigEvent(0));
2013-03-01 17:14:21 +01:00
sp->append(k, keyNames[14]);
2012-05-26 14:49:10 +02:00
return sp;
}
//---------------------------------------------------------
// newAccidentalsPalette
//---------------------------------------------------------
Palette* MuseScore::newAccidentalsPalette()
{
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Accidentals"));
2012-05-26 14:49:10 +02:00
sp->setGrid(33, 36);
sp->setDrawGrid(true);
for (int i = Accidental::ACC_SHARP; i < Accidental::ACC_END; ++i) {
2012-05-26 14:49:10 +02:00
Accidental* s = new Accidental(gscore);
s->setAccidentalType(Accidental::AccidentalType(i));
2013-03-01 17:14:21 +01:00
sp->append(s, s->subtypeUserName());
2012-05-26 14:49:10 +02:00
}
AccidentalBracket* ab = new AccidentalBracket(gscore);
2013-03-01 17:14:21 +01:00
sp->append(ab, QT_TRANSLATE_NOOP("Palette", "round bracket"));
2012-05-26 14:49:10 +02:00
return sp;
}
//---------------------------------------------------------
// newBarLinePalette
//---------------------------------------------------------
Palette* MuseScore::newBarLinePalette()
{
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Barlines"));
2012-05-26 14:49:10 +02:00
sp->setMag(0.8);
sp->setGrid(42, 38);
// bar line styles
2012-05-26 14:49:10 +02:00
struct {
BarLineType type;
const char* name;
} t[] = {
2013-03-01 17:14:21 +01:00
{ NORMAL_BAR, QT_TRANSLATE_NOOP("Palette", "Normal") },
{ BROKEN_BAR, QT_TRANSLATE_NOOP("Palette", "Dashed") },
{ DOTTED_BAR, QT_TRANSLATE_NOOP("Palette", "Dotted") },
{ END_BAR, QT_TRANSLATE_NOOP("Palette", "End Bar") },
{ DOUBLE_BAR, QT_TRANSLATE_NOOP("Palette", "Double Bar") },
{ START_REPEAT, QT_TRANSLATE_NOOP("Palette", "Start Repeat") },
{ END_REPEAT, QT_TRANSLATE_NOOP("Palette", "End Repeat") },
{ END_START_REPEAT, QT_TRANSLATE_NOOP("Palette", "End-Start Repeat") },
2012-05-26 14:49:10 +02:00
};
for (unsigned i = 0; i < sizeof(t)/sizeof(*t); ++i) {
BarLine* b = new BarLine(gscore);
b->setBarLineType(t[i].type);
2013-03-01 17:14:21 +01:00
sp->append(b, t[i].name);
2012-05-26 14:49:10 +02:00
}
// bar line spans
struct {
int from, to;
const char* name;
} span[] = {
2013-03-01 17:14:21 +01:00
{ -1, 1, QT_TRANSLATE_NOOP("Palette", "Tick 1") },
{ -2, 2, QT_TRANSLATE_NOOP("Palette", "Tick 2") },
{ 2, 6, QT_TRANSLATE_NOOP("Palette", "Short 1") },
{ 1, 7, QT_TRANSLATE_NOOP("Palette", "Short 2") },
};
for (unsigned i = 0; i < sizeof(span)/sizeof(*span); ++i) {
BarLine* b = new BarLine(gscore);
b->setBarLineType(NORMAL_BAR);
b->setSpanFrom(span[i].from);
b->setSpanTo(span[i].to);
2013-03-01 17:14:21 +01:00
sp->append(b, span[i].name);
}
2012-05-26 14:49:10 +02:00
return sp;
}
//---------------------------------------------------------
// newRepeatsPalette
//---------------------------------------------------------
Palette* MuseScore::newRepeatsPalette()
{
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Repeats"));
2012-05-26 14:49:10 +02:00
sp->setMag(0.65);
sp->setGrid(84, 28);
sp->setDrawGrid(true);
RepeatMeasure* rm = new RepeatMeasure(gscore);
sp->append(rm, tr("Repeat measure sign"));
Marker* mk = new Marker(gscore);
2013-02-25 14:56:34 +01:00
mk->setMarkerType(MarkerType::SEGNO);
2012-05-26 14:49:10 +02:00
sp->append(mk, tr("Segno"));
mk = new Marker(gscore);
2013-02-25 14:56:34 +01:00
mk->setMarkerType(MarkerType::VARSEGNO);
2012-05-26 14:49:10 +02:00
PaletteCell* cell = sp->append(mk, tr("Segno Variation"), "", 0.6);
cell->yoffset = -2;
mk = new Marker(gscore);
2013-02-25 14:56:34 +01:00
mk->setMarkerType(MarkerType::CODA);
2012-05-26 14:49:10 +02:00
sp->append(mk, tr("Coda"));
mk = new Marker(gscore);
2013-02-25 14:56:34 +01:00
mk->setMarkerType(MarkerType::VARCODA);
2012-05-26 14:49:10 +02:00
sp->append(mk, tr("Varied coda"));
mk = new Marker(gscore);
2013-02-25 14:56:34 +01:00
mk->setMarkerType(MarkerType::CODETTA);
2012-05-26 14:49:10 +02:00
sp->append(mk, tr("Codetta"));
mk = new Marker(gscore);
2013-02-25 14:56:34 +01:00
mk->setMarkerType(MarkerType::FINE);
2012-05-26 14:49:10 +02:00
sp->append(mk, tr("Fine"));
Jump* jp = new Jump(gscore);
2013-02-25 14:56:34 +01:00
jp->setJumpType(JumpType::DC);
2012-05-26 14:49:10 +02:00
sp->append(jp, tr("Da Capo"));
jp = new Jump(gscore);
2013-02-25 14:56:34 +01:00
jp->setJumpType(JumpType::DC_AL_FINE);
2012-05-26 14:49:10 +02:00
sp->append(jp, tr("Da Capo al Fine"));
jp = new Jump(gscore);
2013-02-25 14:56:34 +01:00
jp->setJumpType(JumpType::DC_AL_CODA);
2012-05-26 14:49:10 +02:00
sp->append(jp, tr("Da Capo al Coda"));
jp = new Jump(gscore);
2013-02-25 14:56:34 +01:00
jp->setJumpType(JumpType::DS_AL_CODA);
2012-05-26 14:49:10 +02:00
sp->append(jp, tr("D.S al Coda"));
jp = new Jump(gscore);
2013-02-25 14:56:34 +01:00
jp->setJumpType(JumpType::DS_AL_FINE);
2012-05-26 14:49:10 +02:00
sp->append(jp, tr("D.S al Fine"));
jp = new Jump(gscore);
2013-02-25 14:56:34 +01:00
jp->setJumpType(JumpType::DS);
2012-05-26 14:49:10 +02:00
sp->append(jp, tr("D.S"));
mk = new Marker(gscore);
2013-02-25 14:56:34 +01:00
mk->setMarkerType(MarkerType::TOCODA);
2012-05-26 14:49:10 +02:00
sp->append(mk, tr("To Coda"));
return sp;
}
//---------------------------------------------------------
// newBreaksPalette
//---------------------------------------------------------
Palette* MuseScore::newBreaksPalette()
{
qreal _spatium = gscore->spatium();
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Breaks && Spacer"));
2013-05-15 11:41:46 +02:00
sp->setMag(1.0);
2012-05-26 14:49:10 +02:00
sp->setGrid(42, 36);
sp->setDrawGrid(true);
LayoutBreak* lb = new LayoutBreak(gscore);
lb->setLayoutBreakType(LAYOUT_BREAK_LINE);
2013-05-15 11:41:46 +02:00
PaletteCell* cell = sp->append(lb, tr("Line break"));
cell->mag = 1.2;
2012-05-26 14:49:10 +02:00
lb = new LayoutBreak(gscore);
lb->setLayoutBreakType(LAYOUT_BREAK_PAGE);
2013-05-15 11:41:46 +02:00
cell = sp->append(lb, tr("Page break"));
cell->mag = 1.2;
2012-05-26 14:49:10 +02:00
lb = new LayoutBreak(gscore);
lb->setLayoutBreakType(LAYOUT_BREAK_SECTION);
2013-05-15 11:41:46 +02:00
cell = sp->append(lb, tr("Section break"));
cell->mag = 1.2;
2012-05-26 14:49:10 +02:00
Spacer* spacer = new Spacer(gscore);
spacer->setSpacerType(SPACER_DOWN);
2013-05-15 11:41:46 +02:00
spacer->setGap(3 * _spatium);
cell = sp->append(spacer, tr("Staff spacer down"));
cell->mag = .7;
2012-05-26 14:49:10 +02:00
spacer = new Spacer(gscore);
spacer->setSpacerType(SPACER_UP);
2013-05-15 11:41:46 +02:00
spacer->setGap(3 * _spatium);
cell = sp->append(spacer, tr("Staff spacer up"));
cell->mag = .7;
2012-05-26 14:49:10 +02:00
return sp;
}
//---------------------------------------------------------
// newFingeringPalette
//---------------------------------------------------------
Palette* MuseScore::newFingeringPalette()
{
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Fingering"));
2012-05-26 14:49:10 +02:00
sp->setMag(1.5);
sp->setGrid(28, 30);
sp->setDrawGrid(true);
const char finger[] = "012345pimac";
for (unsigned i = 0; i < strlen(finger); ++i) {
Fingering* f = new Fingering(gscore);
f->setText(QString(finger[i]));
sp->append(f, tr("Fingering %1").arg(finger[i]));
}
const char stringnumber[] = "0123456";
for (unsigned i = 0; i < strlen(stringnumber); ++i) {
Fingering* f = new Fingering(gscore);
f->setTextStyleType(TEXT_STYLE_STRING_NUMBER);
f->setText(QString(stringnumber[i]));
sp->append(f, tr("String number %1").arg(stringnumber[i]));
}
Symbol* symbol = new Symbol(gscore, thumbSym);
sp->append(symbol, tr("Thumb"));
return sp;
}
//---------------------------------------------------------
// newTremoloPalette
//---------------------------------------------------------
Palette* MuseScore::newTremoloPalette()
{
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Tremolo"));
2012-05-26 14:49:10 +02:00
sp->setGrid(27, 40);
sp->setDrawGrid(true);
const char* tremoloName[] = {
QT_TR_NOOP("1/8 through stem"),
QT_TR_NOOP("1/16 through stem"),
QT_TR_NOOP("1/32 through stem"),
QT_TR_NOOP("1/64 through stem"),
QT_TR_NOOP("1/8 between notes"),
QT_TR_NOOP("1/16 between notes"),
QT_TR_NOOP("1/32 between notes"),
QT_TR_NOOP("1/64 between notes")
};
for (int i = TREMOLO_R8; i <= TREMOLO_C64; ++i) {
Tremolo* tremolo = new Tremolo(gscore);
tremolo->setTremoloType(TremoloType(i));
2012-05-26 14:49:10 +02:00
sp->append(tremolo, tr(tremoloName[i - TREMOLO_R8]));
}
return sp;
}
//---------------------------------------------------------
// newNoteHeadsPalette
//---------------------------------------------------------
Palette* MuseScore::newNoteHeadsPalette()
{
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Note Heads"));
2012-05-26 14:49:10 +02:00
sp->setMag(1.3);
sp->setGrid(33, 36);
sp->setDrawGrid(true);
2012-08-04 15:46:43 +02:00
for (int i = 0; i < Note::HEAD_GROUPS; ++i) {
SymId sym = noteHeads[0][i][1];
2012-08-04 15:46:43 +02:00
if (i == Note::HEAD_BREVIS_ALT)
2012-05-26 14:49:10 +02:00
sym = noteHeads[0][i][3];
NoteHead* nh = new NoteHead(gscore);
nh->setSym(sym);
sp->append(nh, qApp->translate("symbol", Sym::id2name(sym)));
2012-05-26 14:49:10 +02:00
}
Icon* ik = new Icon(gscore);
ik->setIconType(ICON_BRACKETS);
Shortcut* s = Shortcut::getShortcut("add-brackets");
QAction* action = s->action();
QIcon icon(action->icon());
ik->setAction("add-brackets", icon);
sp->append(ik, s->help());
2012-05-26 14:49:10 +02:00
return sp;
}
//---------------------------------------------------------
// newArticulationsPalette
//---------------------------------------------------------
Palette* MuseScore::newArticulationsPalette()
{
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Articulations && Ornaments"));
2012-05-26 14:49:10 +02:00
sp->setGrid(42, 25);
sp->setDrawGrid(true);
for (int i = 0; i < ARTICULATIONS; ++i) {
Articulation* s = new Articulation(gscore);
s->setArticulationType(ArticulationType(i));
2012-05-26 14:49:10 +02:00
sp->append(s, qApp->translate("articulation", qPrintable(s->subtypeUserName())));
}
Bend* bend = new Bend(gscore);
bend->points().append(PitchValue(0, 0, false));
bend->points().append(PitchValue(15, 100, false));
bend->points().append(PitchValue(60, 100, false));
sp->append(bend, qApp->translate("articulation", "Bend"));
TremoloBar* tb = new TremoloBar(gscore);
tb->points().append(PitchValue(0, 0, false)); // "Dip"
tb->points().append(PitchValue(30, -100, false));
tb->points().append(PitchValue(60, 0, false));
sp->append(tb, qApp->translate("articulation", "Tremolo Bar"));
return sp;
}
//---------------------------------------------------------
// newBracketsPalette
//---------------------------------------------------------
Palette* MuseScore::newBracketsPalette()
{
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Brackets"));
2012-05-26 14:49:10 +02:00
sp->setMag(0.7);
sp->setGrid(42, 60);
sp->setDrawGrid(true);
Bracket* b1 = new Bracket(gscore);
b1->setBracketType(BRACKET_NORMAL);
2012-05-26 14:49:10 +02:00
Bracket* b2 = new Bracket(gscore);
b2->setBracketType(BRACKET_BRACE);
2013-05-15 11:44:18 +02:00
Bracket* b3 = new Bracket(gscore);
b3->setBracketType(BRACKET_SQUARE);
2012-05-26 14:49:10 +02:00
sp->append(b1, tr("Bracket"));
sp->append(b2, tr("Brace"));
sp->append(b3, tr("Square"));
2012-05-26 14:49:10 +02:00
return sp;
}
//---------------------------------------------------------
// newBreathPalette
//---------------------------------------------------------
Palette* MuseScore::newBreathPalette()
{
Palette* sp = new Palette();
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Breath && Pauses"));
2012-05-26 14:49:10 +02:00
sp->setGrid(42, 40);
sp->setDrawGrid(true);
sp->setDrawGrid(true);
for (int i = 0; i < 4; ++i) {
Breath* a = new Breath(gscore);
a->setBreathType(i);
2012-05-26 14:49:10 +02:00
if (i < 2)
sp->append(a, tr("Breath"));
else
sp->append(a, tr("Caesura"));
}
return sp;
}
//---------------------------------------------------------
// newArpeggioPalette
//---------------------------------------------------------
Palette* MuseScore::newArpeggioPalette()
{
Palette* sp = new Palette();
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Arpeggio && Glissando"));
2012-05-26 14:49:10 +02:00
sp->setGrid(27, 60);
sp->setDrawGrid(true);
for (int i = 0; i < 6; ++i) {
2012-05-26 14:49:10 +02:00
Arpeggio* a = new Arpeggio(gscore);
a->setArpeggioType(ArpeggioType(i));
2012-05-26 14:49:10 +02:00
sp->append(a, tr("Arpeggio"));
}
for (int i = 0; i < 2; ++i) {
Glissando* a = new Glissando(gscore);
a->setGlissandoType(GlissandoType(i));
2012-05-26 14:49:10 +02:00
sp->append(a, tr("Glissando"));
}
2013-04-27 12:41:54 +02:00
//fall and doits
const char* scorelineNames[] = {
QT_TR_NOOP("fall"),
QT_TR_NOOP("doit"),
QT_TR_NOOP("plop"),
QT_TR_NOOP("scoop"),
};
ChordLine* cl = new ChordLine(gscore);
cl->setChordLineType(CHORDLINE_FALL);
sp->append(cl, tr(scorelineNames[0]));
cl = new ChordLine(gscore);
cl->setChordLineType(CHORDLINE_DOIT);
sp->append(cl, tr(scorelineNames[1]));
cl = new ChordLine(gscore);
cl->setChordLineType(CHORDLINE_PLOP);
sp->append(cl, tr(scorelineNames[2]));
cl = new ChordLine(gscore);
cl->setChordLineType(CHORDLINE_SCOOP);
sp->append(cl, tr(scorelineNames[3]));
2012-05-26 14:49:10 +02:00
return sp;
}
//---------------------------------------------------------
// newClefsPalette
//---------------------------------------------------------
Palette* MuseScore::newClefsPalette()
{
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Clefs"));
2012-05-26 14:49:10 +02:00
sp->setMag(0.8);
sp->setGrid(33, 60);
sp->setYOffset(1.0);
static const ClefType clefs[21] = {
CLEF_G, CLEF_G1, CLEF_G2, CLEF_G3, CLEF_G4,
CLEF_C1, CLEF_C2, CLEF_C3, CLEF_C4, CLEF_C5,
CLEF_F, CLEF_F_8VA, CLEF_F_15MA, CLEF_F8, CLEF_F15, CLEF_F_B, CLEF_F_C,
CLEF_PERC, CLEF_TAB, CLEF_TAB2, CLEF_PERC2
};
for (int i = 0; i < 20; ++i) {
ClefType j = clefs[i];
2013-05-13 18:49:17 +02:00
Clef* k = new Ms::Clef(gscore);
2012-05-26 14:49:10 +02:00
k->setClefType(ClefTypeList(j, j));
sp->append(k, qApp->translate("clefTable", clefTable[j].name));
}
return sp;
}
//---------------------------------------------------------
// newGraceNotePalette
//---------------------------------------------------------
Palette* MuseScore::newGraceNotePalette()
{
Palette* notePalette = new Palette;
2013-03-01 17:14:21 +01:00
notePalette->setName(QT_TRANSLATE_NOOP("Palette", "Grace Notes"));
2012-05-26 14:49:10 +02:00
notePalette->setGrid(32, 40);
notePalette->setDrawGrid(true);
static const IconAction gna[] = {
{ ICON_ACCIACCATURA, "acciaccatura" },
{ ICON_APPOGGIATURA, "appoggiatura" },
{ ICON_GRACE4, "grace4" },
{ ICON_GRACE16, "grace16" },
{ ICON_GRACE32, "grace32" },
{ ICON_GRACE8B, "grace8b" },
{ -1, "" }
};
populateIconPalette(notePalette, gna);
return notePalette;
}
//---------------------------------------------------------
// newLinesPalette
//---------------------------------------------------------
Palette* MuseScore::newLinesPalette()
{
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Lines"));
2012-05-26 14:49:10 +02:00
sp->setMag(.8);
sp->setGrid(82, 23);
sp->setDrawGrid(true);
qreal w = gscore->spatium() * 7;
2012-05-26 14:49:10 +02:00
Slur* slur = new Slur(gscore);
slur->setId(0);
sp->append(slur, qApp->translate("lines", "Slur"));
Hairpin* gabel0 = new Hairpin(gscore);
gabel0->setHairpinType(Hairpin::CRESCENDO);
2012-05-26 14:49:10 +02:00
gabel0->setLen(w);
sp->append(gabel0, qApp->translate("lines", "Crescendo"));
Hairpin* gabel1 = new Hairpin(gscore);
gabel1->setHairpinType(Hairpin::DECRESCENDO);
2012-05-26 14:49:10 +02:00
gabel1->setLen(w);
sp->append(gabel1, QT_TRANSLATE_NOOP("Palette", "Diminuendo"));
2012-05-26 14:49:10 +02:00
Volta* volta = new Volta(gscore);
volta->setVoltaType(VoltaType::CLOSED);
2012-05-26 14:49:10 +02:00
volta->setLen(w);
volta->setText("1.");
QList<int> il;
il.append(1);
volta->setEndings(il);
sp->append(volta, QT_TRANSLATE_NOOP("Palette", "Prima volta"));
2012-05-26 14:49:10 +02:00
volta = new Volta(gscore);
volta->setVoltaType(VoltaType::CLOSED);
2012-05-26 14:49:10 +02:00
volta->setLen(w);
volta->setText("2.");
il.clear();
il.append(2);
volta->setEndings(il);
sp->append(volta, QT_TRANSLATE_NOOP("Palette", "Seconda volta"));
2012-05-26 14:49:10 +02:00
volta = new Volta(gscore);
volta->setVoltaType(VoltaType::CLOSED);
2012-05-26 14:49:10 +02:00
volta->setLen(w);
volta->setText("3.");
il.clear();
il.append(3);
volta->setEndings(il);
sp->append(volta, QT_TRANSLATE_NOOP("Palette", "Terza volta"));
2012-05-26 14:49:10 +02:00
volta = new Volta(gscore);
volta->setVoltaType(VoltaType::OPEN);
2012-05-26 14:49:10 +02:00
volta->setLen(w);
volta->setText("2.");
il.clear();
il.append(2);
volta->setEndings(il);
sp->append(volta, QT_TRANSLATE_NOOP("Palette", "Seconda volta 2"));
2012-05-26 14:49:10 +02:00
Ottava* ottava = new Ottava(gscore);
ottava->setOttavaType(Ottava::OTTAVA_8VA);
2012-05-26 14:49:10 +02:00
ottava->setLen(w);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "8va"));
2012-05-26 14:49:10 +02:00
ottava = new Ottava(gscore);
ottava->setOttavaType(Ottava::OTTAVA_15MA);
2012-05-26 14:49:10 +02:00
ottava->setLen(w);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "15ma"));
2012-05-26 14:49:10 +02:00
ottava = new Ottava(gscore);
ottava->setOttavaType(Ottava::OTTAVA_8VB);
2012-05-26 14:49:10 +02:00
ottava->setLen(w);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "8vb"));
2012-05-26 14:49:10 +02:00
ottava = new Ottava(gscore);
ottava->setOttavaType(Ottava::OTTAVA_15MB);
2012-05-26 14:49:10 +02:00
ottava->setLen(w);
sp->append(ottava, QT_TRANSLATE_NOOP("Palette", "15mb"));
2012-05-26 14:49:10 +02:00
Pedal* pedal = new Pedal(gscore);
pedal->setLen(w);
sp->append(pedal, QT_TRANSLATE_NOOP("Palette", "Pedal"));
2012-05-26 14:49:10 +02:00
pedal = new Pedal(gscore);
pedal->setLen(w);
pedal->setEndHookType(HOOK_45);
sp->append(pedal, QT_TRANSLATE_NOOP("Palette", "Pedal"));
2012-05-26 14:49:10 +02:00
pedal = new Pedal(gscore);
pedal->setLen(w);
pedal->setBeginSymbol(noSym);
2012-05-26 14:49:10 +02:00
pedal->setBeginHook(true);
pedal->setBeginHookType(HOOK_45);
pedal->setEndHookType(HOOK_45);
sp->append(pedal, QT_TRANSLATE_NOOP("Palette", "Pedal"));
2012-05-26 14:49:10 +02:00
pedal = new Pedal(gscore);
pedal->setLen(w);
pedal->setBeginSymbol(noSym);
2012-05-26 14:49:10 +02:00
pedal->setBeginHook(true);
pedal->setBeginHookType(HOOK_45);
sp->append(pedal, QT_TRANSLATE_NOOP("Palette", "Pedal"));
2012-05-26 14:49:10 +02:00
Trill* trill = new Trill(gscore);
trill->setLen(w);
sp->append(trill, QT_TRANSLATE_NOOP("Palette", "Trill line"));
2012-05-26 14:49:10 +02:00
trill = new Trill(gscore);
trill->setTrillType("upprall");
2012-05-26 14:49:10 +02:00
trill->setLen(w);
sp->append(trill, QT_TRANSLATE_NOOP("Palette", "Upprall line"));
2012-05-26 14:49:10 +02:00
trill = new Trill(gscore);
trill->setTrillType("downprall");
2012-05-26 14:49:10 +02:00
trill->setLen(w);
sp->append(trill, QT_TRANSLATE_NOOP("Palette", "Downprall line"));
2012-05-26 14:49:10 +02:00
trill = new Trill(gscore);
trill->setTrillType("prallprall");
2012-05-26 14:49:10 +02:00
trill->setLen(w);
sp->append(trill, QT_TRANSLATE_NOOP("Palette", "Prallprall line"));
2013-02-06 16:43:25 +01:00
2012-10-25 09:29:51 +02:00
trill = new Trill(gscore);
trill->setTrillType("pure");
2012-10-25 09:29:51 +02:00
trill->setLen(w);
sp->append(trill, QT_TRANSLATE_NOOP("Palette", "Wavy line"));
2012-05-26 14:49:10 +02:00
TextLine* textLine = new TextLine(gscore);
textLine->setLen(w);
textLine->setBeginText("VII", gscore->textStyle(TEXT_STYLE_TEXTLINE));
textLine->setEndHook(true);
sp->append(textLine, QT_TRANSLATE_NOOP("Palette", "Text line"));
2012-05-26 14:49:10 +02:00
TextLine* line = new TextLine(gscore);
line->setLen(w);
line->setDiagonal(true);
sp->append(line, QT_TRANSLATE_NOOP("Palette", "Line"));
2012-05-26 14:49:10 +02:00
return sp;
}
//---------------------------------------------------------
// showPalette
//---------------------------------------------------------
void MuseScore::showPalette(bool visible)
{
QAction* a = getAction("toggle-palette");
if (paletteBox == 0)
2013-02-10 14:50:18 +01:00
Workspace::currentWorkspace->read();
2012-05-26 14:49:10 +02:00
if (paletteBox) // read failed?
2012-05-31 16:24:35 +02:00
paletteBox->setVisible(visible);
2012-05-26 14:49:10 +02:00
a->setChecked(visible);
}
//---------------------------------------------------------
// TempoPattern
//---------------------------------------------------------
struct TempoPattern {
QString pattern;
double f;
TempoPattern(const QString& s, double v) : pattern(s), f(v) {}
};
//---------------------------------------------------------
// newTempoPalette
//---------------------------------------------------------
Palette* MuseScore::newTextPalette()
{
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Text"));
2012-05-26 14:49:10 +02:00
sp->setMag(0.65);
sp->setGrid(84, 28);
sp->setDrawGrid(true);
StaffText* st = new StaffText(gscore);
st->setTextStyleType(TEXT_STYLE_STAFF);
st->setText(tr("staff-text"));
sp->append(st, tr("Staff Text"));
st = new StaffText(gscore);
st->setTextStyleType(TEXT_STYLE_SYSTEM);
st->setText(tr("system-text"));
sp->append(st, tr("System Text"));
RehearsalMark* rhm = new RehearsalMark(gscore);
rhm->setTrack(0);
rhm->setText("B1");
sp->append(rhm, tr("Rehearsal Mark"));
InstrumentChange* is = new InstrumentChange(gscore);
is->setText(tr("Instrument"));
sp->append(is, tr("Instrument Change"));
Text* text = new Text(gscore);
text->setTrack(0);
text->setTextStyleType(TEXT_STYLE_LYRICS_VERSE_NUMBER);
text->setText(tr("1."));
sp->append(text, tr("Lyrics Verse Number"));
static const TempoPattern tp[] = {
TempoPattern(QString("%1%2 = 80"). arg(QChar(0xd834)).arg(QChar(0xdd5f)), 80.0/60.0), // 1/4
TempoPattern(QString("%1%2 = 80"). arg(QChar(0xd834)).arg(QChar(0xdd5e)), 80.0/30.0), // 1/2
TempoPattern(QString("%1%2 = 80"). arg(QChar(0xd834)).arg(QChar(0xdd60)), 80.0/120.0), // 1/8
TempoPattern(QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5f)).arg(QChar(0xd834)).arg(QChar(0xdd6d)), 120.0/60.0), // dotted 1/4
TempoPattern(QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd5e)).arg(QChar(0xd834)).arg(QChar(0xdd6d)), 120/30.0), // dotted 1/2
TempoPattern(QString("%1%2%3%4 = 80").arg(QChar(0xd834)).arg(QChar(0xdd60)).arg(QChar(0xd834)).arg(QChar(0xdd6d)), 120/120.0) // dotted 1/8
};
for (unsigned i = 0; i < sizeof(tp)/sizeof(*tp); ++i) {
TempoText* tt = new TempoText(gscore);
tt->setFollowText(true);
tt->setTrack(0);
tt->setTempo(tp[i].f);
tt->setText(tp[i].pattern);
sp->append(tt, tr("Tempo Text"), QString(), 1.5);
}
Harmony* harmony = new Harmony(gscore);
2013-04-11 16:16:44 +02:00
harmony->setText("C7");
2012-05-26 14:49:10 +02:00
sp->append(harmony, tr("Chord Name"));
return sp;
}
//---------------------------------------------------------
// newTimePalette
// create default time signature palette
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
Palette* MuseScore::newTimePalette()
2012-05-26 14:49:10 +02:00
{
struct TS {
int numerator;
int denominator;
TimeSigType type;
QString name;
};
2012-05-26 14:49:10 +02:00
TS tsList[] = {
{ 2, 4, TSIG_NORMAL, "2/4" },
{ 3, 4, TSIG_NORMAL, "3/4" },
{ 4, 4, TSIG_NORMAL, "4/4" },
{ 5, 4, TSIG_NORMAL, "5/4" },
{ 6, 4, TSIG_NORMAL, "6/4" },
{ 3, 8, TSIG_NORMAL, "3/8" },
{ 6, 8, TSIG_NORMAL, "6/8" },
{ 9, 8, TSIG_NORMAL, "9/8" },
{ 12, 8, TSIG_NORMAL, "12/8" },
{ 4, 4, TSIG_FOUR_FOUR, tr("4/4 common time") },
{ 2, 2, TSIG_ALLA_BREVE, tr("2/2 alla breve") }
};
2012-05-26 14:49:10 +02:00
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Time Signatures"));
2012-05-26 14:49:10 +02:00
sp->setMag(.8);
sp->setGrid(42, 38);
for (unsigned i = 0; i < sizeof(tsList)/sizeof(*tsList); ++i) {
TimeSig* ts;
ts = new TimeSig(gscore);
ts->setSig(Fraction(tsList[i].numerator, tsList[i].denominator), tsList[i].type);
sp->append(ts, tsList[i].name);
}
return sp;
}
//---------------------------------------------------------
// populatePalette
//---------------------------------------------------------
2012-05-26 14:49:10 +02:00
void MuseScore::populatePalette()
{
paletteBox->addPalette(newGraceNotePalette());
paletteBox->addPalette(newClefsPalette());
paletteBox->addPalette(newKeySigPalette());
paletteBox->addPalette(newTimePalette());
2012-05-26 14:49:10 +02:00
paletteBox->addPalette(newBarLinePalette());
paletteBox->addPalette(newLinesPalette());
paletteBox->addPalette(newArpeggioPalette());
paletteBox->addPalette(newBreathPalette());
paletteBox->addPalette(newBracketsPalette());
paletteBox->addPalette(newArticulationsPalette());
paletteBox->addPalette(newAccidentalsPalette());
paletteBox->addPalette(newDynamicsPalette());
paletteBox->addPalette(newFingeringPalette());
paletteBox->addPalette(newNoteHeadsPalette());
paletteBox->addPalette(newTremoloPalette());
paletteBox->addPalette(newRepeatsPalette());
paletteBox->addPalette(newTextPalette());
paletteBox->addPalette(newBreaksPalette());
//-----------------------------------
// staff state changes
//-----------------------------------
#if 0
sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Staff Changes"));
2012-05-26 14:49:10 +02:00
sp->setMag(.7);
sp->setGrid(42, 36);
sp->setDrawGrid(true);
StaffState* st = new StaffState(gscore);
st->setSubtype(STAFF_STATE_VISIBLE);
sp->append(st, tr("set visible"));
st = new StaffState(gscore);
st->setSubtype(STAFF_STATE_INVISIBLE);
sp->append(st, tr("set invisible"));
st = new StaffState(gscore);
st->setSubtype(STAFF_STATE_TYPE);
sp->append(st, tr("change staff type"));
st = new StaffState(gscore);
st->setSubtype(STAFF_STATE_INSTRUMENT);
sp->append(st, tr("change instrument"));
paletteBox->addPalette(sp);
#endif
paletteBox->addPalette(newBeamPalette());
paletteBox->addPalette(newFramePalette());
//-----------------------------------
// Symbols
//-----------------------------------
Palette* sp = new Palette;
2013-03-01 17:14:21 +01:00
sp->setName(QT_TRANSLATE_NOOP("Palette", "Symbols"));
2012-05-26 14:49:10 +02:00
sp->setGrid(42, 45);
sp->setDrawGrid(true);
sp->append(accDiscantSym);
sp->append(accDotSym);
sp->append(accFreebaseSym);
sp->append(accStdbaseSym);
sp->append(accBayanbaseSym);
sp->append(accOldEESym);
sp->append(accpushSym);
sp->append(accpullSym);
FretDiagram* fret = new FretDiagram(gscore);
fret->setDot(5, 1);
fret->setDot(2, 2);
fret->setDot(1, 3);
fret->setMarker(0, 'X');
fret->setMarker(3, 'O');
fret->setMarker(4, 'O');
sp->append(fret, tr("Fret Diagram"));
paletteBox->addPalette(sp);
}
//---------------------------------------------------------
// genCreateMenu
//---------------------------------------------------------
QMenu* MuseScore::genCreateMenu(QWidget* parent)
{
QMenu* popup = new QMenu(tr("&Insert"), parent);
popup->setObjectName("Insert");
2012-05-26 14:49:10 +02:00
popup->addAction(getAction("instruments"));
QMenu* measures = popup->addMenu(tr("&Measures"));
measures->addAction(getAction("insert-measure"));
measures->addAction(getAction("insert-measures"));
measures->addSeparator();
measures->addAction(getAction("append-measure"));
measures->addAction(getAction("append-measures"));
QMenu* frames = popup->addMenu(tr("&Frames"));
frames->addAction(getAction("insert-hbox"));
frames->addAction(getAction("insert-vbox"));
frames->addAction(getAction("insert-textframe"));
if(enableExperimental)
frames->addAction(getAction("insert-fretframe"));
2012-05-26 14:49:10 +02:00
frames->addSeparator();
frames->addAction(getAction("append-hbox"));
frames->addAction(getAction("append-vbox"));
frames->addAction(getAction("append-textframe"));
QMenu* text = popup->addMenu(tr("&Text"));
text->addAction(getAction("title-text"));
text->addAction(getAction("subtitle-text"));
text->addAction(getAction("composer-text"));
text->addAction(getAction("poet-text"));
text->addSeparator();
text->addAction(getAction("system-text"));
text->addAction(getAction("staff-text"));
text->addAction(getAction("chord-text"));
text->addAction(getAction("rehearsalmark-text"));
text->addSeparator();
text->addAction(getAction("lyrics"));
2013-02-18 14:47:16 +01:00
text->addAction(getAction("figured-bass"));
2012-05-26 14:49:10 +02:00
text->addAction(getAction("tempo"));
2012-09-12 16:19:03 +02:00
popup->addSeparator();
popup->addAction(getAction("add-slur"));
popup->addAction(getAction("add-hairpin"));
popup->addAction(getAction("add-hairpin-reverse"));
popup->addAction(getAction("add-noteline"));
2012-05-26 14:49:10 +02:00
return popup;
}
//---------------------------------------------------------
// addTempo
//---------------------------------------------------------
void MuseScore::addTempo()
{
ChordRest* cr = cs->getSelectedChordRest();
if (!cr)
return;
if (editTempo == 0)
editTempo = new EditTempo(0);
int rv = editTempo->exec();
if (rv == 1) {
double bps = editTempo->bpm() / 60.0;
TempoText* tt = new TempoText(cs);
tt->setParent(cr->segment());
tt->setTrack(cr->track());
tt->setText(editTempo->text());
tt->setTempo(bps);
cs->undoAddElement(tt);
cs->addRefresh(tt->abbox()); // ??
}
}
2013-05-13 18:49:17 +02:00
}
2012-05-26 14:49:10 +02:00