2015-02-04 22:12:13 +01:00
|
|
|
|
//=============================================================================
|
|
|
|
|
// MuseScore
|
|
|
|
|
// Music Composition & Notation
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2015 Werner Schweer
|
|
|
|
|
//
|
|
|
|
|
// 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 "scoreElement.h"
|
|
|
|
|
#include "score.h"
|
|
|
|
|
#include "undo.h"
|
|
|
|
|
#include "xml.h"
|
2017-03-31 13:03:15 +02:00
|
|
|
|
#include "bracket.h"
|
|
|
|
|
#include "bracketItem.h"
|
2018-07-11 12:23:32 +02:00
|
|
|
|
#include "spanner.h"
|
2018-10-18 11:53:01 +02:00
|
|
|
|
#include "musescoreCore.h"
|
2015-02-04 22:12:13 +01:00
|
|
|
|
|
|
|
|
|
namespace Ms {
|
|
|
|
|
|
2018-08-01 11:46:07 +02:00
|
|
|
|
ElementStyle const ScoreElement::emptyStyle;
|
|
|
|
|
|
2017-01-18 14:16:33 +01:00
|
|
|
|
//
|
|
|
|
|
// list has to be synchronized with ElementType enum
|
|
|
|
|
//
|
|
|
|
|
static const ElementName elementNames[] = {
|
2018-11-24 21:08:07 +01:00
|
|
|
|
{ ElementType::INVALID, "invalid", QT_TRANSLATE_NOOP("elementName", "Invalid") },
|
2018-11-16 15:31:18 +01:00
|
|
|
|
{ ElementType::BRACKET_ITEM, "BracketItem", QT_TRANSLATE_NOOP("elementName", "Bracket") },
|
2017-01-18 14:16:33 +01:00
|
|
|
|
{ ElementType::PART, "Part", QT_TRANSLATE_NOOP("elementName", "Part") },
|
|
|
|
|
{ ElementType::STAFF, "Staff", QT_TRANSLATE_NOOP("elementName", "Staff") },
|
|
|
|
|
{ ElementType::SCORE, "Score", QT_TRANSLATE_NOOP("elementName", "Score") },
|
|
|
|
|
{ ElementType::SYMBOL, "Symbol", QT_TRANSLATE_NOOP("elementName", "Symbol") },
|
|
|
|
|
{ ElementType::TEXT, "Text", QT_TRANSLATE_NOOP("elementName", "Text") },
|
2018-10-24 10:40:03 +02:00
|
|
|
|
{ ElementType::MEASURE_NUMBER, "MeasureNumber", QT_TRANSLATE_NOOP("elementName", "Measure Number") },
|
2017-01-18 14:16:33 +01:00
|
|
|
|
{ ElementType::INSTRUMENT_NAME, "InstrumentName", QT_TRANSLATE_NOOP("elementName", "Instrument Name") },
|
|
|
|
|
{ ElementType::SLUR_SEGMENT, "SlurSegment", QT_TRANSLATE_NOOP("elementName", "Slur Segment") },
|
|
|
|
|
{ ElementType::TIE_SEGMENT, "TieSegment", QT_TRANSLATE_NOOP("elementName", "Tie Segment") },
|
|
|
|
|
{ ElementType::BAR_LINE, "BarLine", QT_TRANSLATE_NOOP("elementName", "Barline") },
|
2018-01-04 12:41:42 +01:00
|
|
|
|
{ ElementType::STAFF_LINES, "StaffLines", QT_TRANSLATE_NOOP("elementName", "Staff Lines") },
|
2017-01-18 14:16:33 +01:00
|
|
|
|
{ ElementType::SYSTEM_DIVIDER, "SystemDivider", QT_TRANSLATE_NOOP("elementName", "System Divider") },
|
|
|
|
|
{ ElementType::STEM_SLASH, "StemSlash", QT_TRANSLATE_NOOP("elementName", "Stem Slash") },
|
|
|
|
|
{ ElementType::ARPEGGIO, "Arpeggio", QT_TRANSLATE_NOOP("elementName", "Arpeggio") },
|
|
|
|
|
{ ElementType::ACCIDENTAL, "Accidental", QT_TRANSLATE_NOOP("elementName", "Accidental") },
|
|
|
|
|
{ ElementType::LEDGER_LINE, "LedgerLine", QT_TRANSLATE_NOOP("elementName", "Ledger Line") },
|
|
|
|
|
{ ElementType::STEM, "Stem", QT_TRANSLATE_NOOP("elementName", "Stem") },
|
|
|
|
|
{ ElementType::NOTE, "Note", QT_TRANSLATE_NOOP("elementName", "Note") },
|
|
|
|
|
{ ElementType::CLEF, "Clef", QT_TRANSLATE_NOOP("elementName", "Clef") },
|
|
|
|
|
{ ElementType::KEYSIG, "KeySig", QT_TRANSLATE_NOOP("elementName", "Key Signature") },
|
|
|
|
|
{ ElementType::AMBITUS, "Ambitus", QT_TRANSLATE_NOOP("elementName", "Ambitus") },
|
|
|
|
|
{ ElementType::TIMESIG, "TimeSig", QT_TRANSLATE_NOOP("elementName", "Time Signature") },
|
|
|
|
|
{ ElementType::REST, "Rest", QT_TRANSLATE_NOOP("elementName", "Rest") },
|
|
|
|
|
{ ElementType::BREATH, "Breath", QT_TRANSLATE_NOOP("elementName", "Breath") },
|
|
|
|
|
{ ElementType::REPEAT_MEASURE, "RepeatMeasure", QT_TRANSLATE_NOOP("elementName", "Repeat Measure") },
|
|
|
|
|
{ ElementType::TIE, "Tie", QT_TRANSLATE_NOOP("elementName", "Tie") },
|
|
|
|
|
{ ElementType::ARTICULATION, "Articulation", QT_TRANSLATE_NOOP("elementName", "Articulation") },
|
2018-01-16 13:38:17 +01:00
|
|
|
|
{ ElementType::FERMATA, "Fermata", QT_TRANSLATE_NOOP("elementName", "Fermata") },
|
2017-01-18 14:16:33 +01:00
|
|
|
|
{ ElementType::CHORDLINE, "ChordLine", QT_TRANSLATE_NOOP("elementName", "Chord Line") },
|
|
|
|
|
{ ElementType::DYNAMIC, "Dynamic", QT_TRANSLATE_NOOP("elementName", "Dynamic") },
|
|
|
|
|
{ ElementType::BEAM, "Beam", QT_TRANSLATE_NOOP("elementName", "Beam") },
|
|
|
|
|
{ ElementType::HOOK, "Hook", QT_TRANSLATE_NOOP("elementName", "Hook") },
|
|
|
|
|
{ ElementType::LYRICS, "Lyrics", QT_TRANSLATE_NOOP("elementName", "Lyrics") },
|
|
|
|
|
{ ElementType::FIGURED_BASS, "FiguredBass", QT_TRANSLATE_NOOP("elementName", "Figured Bass") },
|
|
|
|
|
{ ElementType::MARKER, "Marker", QT_TRANSLATE_NOOP("elementName", "Marker") },
|
|
|
|
|
{ ElementType::JUMP, "Jump", QT_TRANSLATE_NOOP("elementName", "Jump") },
|
|
|
|
|
{ ElementType::FINGERING, "Fingering", QT_TRANSLATE_NOOP("elementName", "Fingering") },
|
|
|
|
|
{ ElementType::TUPLET, "Tuplet", QT_TRANSLATE_NOOP("elementName", "Tuplet") },
|
|
|
|
|
{ ElementType::TEMPO_TEXT, "Tempo", QT_TRANSLATE_NOOP("elementName", "Tempo") },
|
|
|
|
|
{ ElementType::STAFF_TEXT, "StaffText", QT_TRANSLATE_NOOP("elementName", "Staff Text") },
|
2017-01-20 11:05:52 +01:00
|
|
|
|
{ ElementType::SYSTEM_TEXT, "SystemText", QT_TRANSLATE_NOOP("elementName", "System Text") },
|
2017-01-18 14:16:33 +01:00
|
|
|
|
{ ElementType::REHEARSAL_MARK, "RehearsalMark", QT_TRANSLATE_NOOP("elementName", "Rehearsal Mark") },
|
|
|
|
|
{ ElementType::INSTRUMENT_CHANGE, "InstrumentChange", QT_TRANSLATE_NOOP("elementName", "Instrument Change") },
|
2017-03-16 00:58:46 +01:00
|
|
|
|
{ ElementType::STAFFTYPE_CHANGE, "StaffTypeChange", QT_TRANSLATE_NOOP("elementName", "Staff Type Change") },
|
2017-01-18 14:16:33 +01:00
|
|
|
|
{ ElementType::HARMONY, "Harmony", QT_TRANSLATE_NOOP("elementName", "Chord Symbol") },
|
|
|
|
|
{ ElementType::FRET_DIAGRAM, "FretDiagram", QT_TRANSLATE_NOOP("elementName", "Fretboard Diagram") },
|
|
|
|
|
{ ElementType::BEND, "Bend", QT_TRANSLATE_NOOP("elementName", "Bend") },
|
|
|
|
|
{ ElementType::TREMOLOBAR, "TremoloBar", QT_TRANSLATE_NOOP("elementName", "Tremolo Bar") },
|
|
|
|
|
{ ElementType::VOLTA, "Volta", QT_TRANSLATE_NOOP("elementName", "Volta") },
|
|
|
|
|
{ ElementType::HAIRPIN_SEGMENT, "HairpinSegment", QT_TRANSLATE_NOOP("elementName", "Hairpin Segment") },
|
|
|
|
|
{ ElementType::OTTAVA_SEGMENT, "OttavaSegment", QT_TRANSLATE_NOOP("elementName", "Ottava Segment") },
|
|
|
|
|
{ ElementType::TRILL_SEGMENT, "TrillSegment", QT_TRANSLATE_NOOP("elementName", "Trill Segment") },
|
2017-11-27 09:56:41 +01:00
|
|
|
|
{ ElementType::LET_RING_SEGMENT, "LetRingSegment", QT_TRANSLATE_NOOP("elementName", "Let Ring Segment") },
|
|
|
|
|
{ ElementType::VIBRATO_SEGMENT, "VibratoSegment", QT_TRANSLATE_NOOP("elementName", "Vibrato Segment") },
|
2017-11-27 16:55:52 +01:00
|
|
|
|
{ ElementType::PALM_MUTE_SEGMENT, "PalmMuteSegment", QT_TRANSLATE_NOOP("elementName", "Palm Mute Segment") },
|
2017-01-18 14:16:33 +01:00
|
|
|
|
{ ElementType::TEXTLINE_SEGMENT, "TextLineSegment", QT_TRANSLATE_NOOP("elementName", "Text Line Segment") },
|
|
|
|
|
{ ElementType::VOLTA_SEGMENT, "VoltaSegment", QT_TRANSLATE_NOOP("elementName", "Volta Segment") },
|
|
|
|
|
{ ElementType::PEDAL_SEGMENT, "PedalSegment", QT_TRANSLATE_NOOP("elementName", "Pedal Segment") },
|
|
|
|
|
{ ElementType::LYRICSLINE_SEGMENT, "LyricsLineSegment", QT_TRANSLATE_NOOP("elementName", "Melisma Line Segment") },
|
|
|
|
|
{ ElementType::GLISSANDO_SEGMENT, "GlissandoSegment", QT_TRANSLATE_NOOP("elementName", "Glissando Segment") },
|
|
|
|
|
{ ElementType::LAYOUT_BREAK, "LayoutBreak", QT_TRANSLATE_NOOP("elementName", "Layout Break") },
|
|
|
|
|
{ ElementType::SPACER, "Spacer", QT_TRANSLATE_NOOP("elementName", "Spacer") },
|
|
|
|
|
{ ElementType::STAFF_STATE, "StaffState", QT_TRANSLATE_NOOP("elementName", "Staff State") },
|
|
|
|
|
{ ElementType::NOTEHEAD, "NoteHead", QT_TRANSLATE_NOOP("elementName", "Notehead") },
|
|
|
|
|
{ ElementType::NOTEDOT, "NoteDot", QT_TRANSLATE_NOOP("elementName", "Note Dot") },
|
|
|
|
|
{ ElementType::TREMOLO, "Tremolo", QT_TRANSLATE_NOOP("elementName", "Tremolo") },
|
|
|
|
|
{ ElementType::IMAGE, "Image", QT_TRANSLATE_NOOP("elementName", "Image") },
|
|
|
|
|
{ ElementType::MEASURE, "Measure", QT_TRANSLATE_NOOP("elementName", "Measure") },
|
|
|
|
|
{ ElementType::SELECTION, "Selection", QT_TRANSLATE_NOOP("elementName", "Selection") },
|
|
|
|
|
{ ElementType::LASSO, "Lasso", QT_TRANSLATE_NOOP("elementName", "Lasso") },
|
|
|
|
|
{ ElementType::SHADOW_NOTE, "ShadowNote", QT_TRANSLATE_NOOP("elementName", "Shadow Note") },
|
|
|
|
|
{ ElementType::TAB_DURATION_SYMBOL, "TabDurationSymbol", QT_TRANSLATE_NOOP("elementName", "Tab Duration Symbol") },
|
|
|
|
|
{ ElementType::FSYMBOL, "FSymbol", QT_TRANSLATE_NOOP("elementName", "Font Symbol") },
|
|
|
|
|
{ ElementType::PAGE, "Page", QT_TRANSLATE_NOOP("elementName", "Page") },
|
|
|
|
|
{ ElementType::HAIRPIN, "HairPin", QT_TRANSLATE_NOOP("elementName", "Hairpin") },
|
|
|
|
|
{ ElementType::OTTAVA, "Ottava", QT_TRANSLATE_NOOP("elementName", "Ottava") },
|
|
|
|
|
{ ElementType::PEDAL, "Pedal", QT_TRANSLATE_NOOP("elementName", "Pedal") },
|
|
|
|
|
{ ElementType::TRILL, "Trill", QT_TRANSLATE_NOOP("elementName", "Trill") },
|
2017-11-27 09:56:41 +01:00
|
|
|
|
{ ElementType::LET_RING, "LetRing", QT_TRANSLATE_NOOP("elementName", "Let Ring") },
|
|
|
|
|
{ ElementType::VIBRATO, "Vibrato", QT_TRANSLATE_NOOP("elementName", "Vibrato") },
|
2017-11-27 16:55:52 +01:00
|
|
|
|
{ ElementType::PALM_MUTE, "PalmMute", QT_TRANSLATE_NOOP("elementName", "Palm Mute") },
|
2017-01-18 14:16:33 +01:00
|
|
|
|
{ ElementType::TEXTLINE, "TextLine", QT_TRANSLATE_NOOP("elementName", "Text Line") },
|
|
|
|
|
{ ElementType::TEXTLINE_BASE, "TextLineBase", QT_TRANSLATE_NOOP("elementName", "Text Line Base") }, // remove
|
|
|
|
|
{ ElementType::NOTELINE, "NoteLine", QT_TRANSLATE_NOOP("elementName", "Note Line") },
|
|
|
|
|
{ ElementType::LYRICSLINE, "LyricsLine", QT_TRANSLATE_NOOP("elementName", "Melisma Line") },
|
|
|
|
|
{ ElementType::GLISSANDO, "Glissando", QT_TRANSLATE_NOOP("elementName", "Glissando") },
|
|
|
|
|
{ ElementType::BRACKET, "Bracket", QT_TRANSLATE_NOOP("elementName", "Bracket") },
|
|
|
|
|
{ ElementType::SEGMENT, "Segment", QT_TRANSLATE_NOOP("elementName", "Segment") },
|
|
|
|
|
{ ElementType::SYSTEM, "System", QT_TRANSLATE_NOOP("elementName", "System") },
|
|
|
|
|
{ ElementType::COMPOUND, "Compound", QT_TRANSLATE_NOOP("elementName", "Compound") },
|
|
|
|
|
{ ElementType::CHORD, "Chord", QT_TRANSLATE_NOOP("elementName", "Chord") },
|
|
|
|
|
{ ElementType::SLUR, "Slur", QT_TRANSLATE_NOOP("elementName", "Slur") },
|
|
|
|
|
{ ElementType::ELEMENT, "Element", QT_TRANSLATE_NOOP("elementName", "Element") },
|
|
|
|
|
{ ElementType::ELEMENT_LIST, "ElementList", QT_TRANSLATE_NOOP("elementName", "Element List") },
|
|
|
|
|
{ ElementType::STAFF_LIST, "StaffList", QT_TRANSLATE_NOOP("elementName", "Staff List") },
|
|
|
|
|
{ ElementType::MEASURE_LIST, "MeasureList", QT_TRANSLATE_NOOP("elementName", "Measure List") },
|
|
|
|
|
{ ElementType::HBOX, "HBox", QT_TRANSLATE_NOOP("elementName", "Horizontal Frame") },
|
|
|
|
|
{ ElementType::VBOX, "VBox", QT_TRANSLATE_NOOP("elementName", "Vertical Frame") },
|
|
|
|
|
{ ElementType::TBOX, "TBox", QT_TRANSLATE_NOOP("elementName", "Text Frame") },
|
|
|
|
|
{ ElementType::FBOX, "FBox", QT_TRANSLATE_NOOP("elementName", "Fretboard Diagram Frame") },
|
|
|
|
|
{ ElementType::ICON, "Icon", QT_TRANSLATE_NOOP("elementName", "Icon") },
|
|
|
|
|
{ ElementType::OSSIA, "Ossia", QT_TRANSLATE_NOOP("elementName", "Ossia") },
|
|
|
|
|
{ ElementType::BAGPIPE_EMBELLISHMENT,"BagpipeEmbellishment", QT_TRANSLATE_NOOP("elementName", "Bagpipe Embellishment") }
|
|
|
|
|
};
|
|
|
|
|
|
2016-03-30 22:33:04 +02:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// ScoreElement
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
ScoreElement::ScoreElement(const ScoreElement& se)
|
|
|
|
|
{
|
2018-09-11 16:56:50 +02:00
|
|
|
|
_score = se._score;
|
|
|
|
|
_elementStyle = se._elementStyle;
|
2018-08-02 10:57:48 +02:00
|
|
|
|
if (_elementStyle) {
|
2018-09-11 16:56:50 +02:00
|
|
|
|
size_t n = _elementStyle->size();
|
2018-08-01 11:46:07 +02:00
|
|
|
|
_propertyFlagsList = new PropertyFlags[n];
|
2018-09-11 16:56:50 +02:00
|
|
|
|
for (size_t i = 0; i < n; ++i)
|
2018-08-01 11:46:07 +02:00
|
|
|
|
_propertyFlagsList[i] = se._propertyFlagsList[i];
|
|
|
|
|
}
|
2016-03-30 22:33:04 +02:00
|
|
|
|
_links = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2017-03-31 13:03:15 +02:00
|
|
|
|
// ~Element
|
2016-03-30 22:33:04 +02:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
ScoreElement::~ScoreElement()
|
|
|
|
|
{
|
|
|
|
|
if (_links) {
|
|
|
|
|
_links->removeOne(this);
|
|
|
|
|
if (_links->empty()) {
|
|
|
|
|
delete _links;
|
|
|
|
|
_links = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-27 14:40:34 +02:00
|
|
|
|
delete[] _propertyFlagsList;
|
2018-03-21 14:05:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-27 14:40:34 +02:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// propertyDefault
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
2018-08-09 15:36:37 +02:00
|
|
|
|
QVariant ScoreElement::propertyDefault(Pid pid, Tid tid) const
|
|
|
|
|
{
|
|
|
|
|
for (const StyledProperty& spp : *textStyle(tid)) {
|
2018-10-22 16:15:35 +02:00
|
|
|
|
if (spp.pid == pid)
|
2018-10-26 12:28:11 +02:00
|
|
|
|
return styleValue(pid, spp.sid);
|
2018-08-09 15:36:37 +02:00
|
|
|
|
}
|
|
|
|
|
return QVariant();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// propertyDefault
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
2018-07-24 15:48:24 +02:00
|
|
|
|
QVariant ScoreElement::propertyDefault(Pid pid) const
|
2018-03-27 14:40:34 +02:00
|
|
|
|
{
|
2018-10-18 11:53:01 +02:00
|
|
|
|
Sid sid = getPropertyStyle(pid);
|
|
|
|
|
if (sid != Sid::NOSTYLE)
|
2018-10-26 12:28:11 +02:00
|
|
|
|
return styleValue(pid, sid);
|
2018-10-25 15:43:59 +02:00
|
|
|
|
// qDebug("<%s>(%d) not found in <%s>", propertyQmlName(pid), int(pid), name());
|
2018-08-09 15:36:37 +02:00
|
|
|
|
return QVariant();
|
2018-03-27 14:40:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-21 14:05:33 +01:00
|
|
|
|
//---------------------------------------------------------
|
2018-08-01 11:46:07 +02:00
|
|
|
|
// initElementStyle
|
2018-03-21 14:05:33 +01:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
2018-08-01 11:46:07 +02:00
|
|
|
|
void ScoreElement::initElementStyle(const ElementStyle* ss)
|
2018-03-21 14:05:33 +01:00
|
|
|
|
{
|
2018-08-02 10:57:48 +02:00
|
|
|
|
_elementStyle = ss;
|
2018-10-18 11:53:01 +02:00
|
|
|
|
size_t n = _elementStyle->size();
|
2018-08-01 11:46:07 +02:00
|
|
|
|
delete[] _propertyFlagsList;
|
|
|
|
|
_propertyFlagsList = new PropertyFlags[n];
|
2018-09-11 16:56:50 +02:00
|
|
|
|
for (size_t i = 0; i < n; ++i)
|
2018-08-01 11:46:07 +02:00
|
|
|
|
_propertyFlagsList[i] = PropertyFlags::STYLED;
|
2018-10-18 11:53:01 +02:00
|
|
|
|
for (const StyledProperty& spp : *_elementStyle)
|
2018-12-05 15:17:33 +01:00
|
|
|
|
// setProperty(spp.pid, styleValue(spp.pid, spp.sid));
|
|
|
|
|
setProperty(spp.pid, styleValue(spp.pid, getPropertyStyle(spp.pid)));
|
2016-03-30 22:33:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-04 22:12:13 +01:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// resetProperty
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
2018-07-11 12:23:32 +02:00
|
|
|
|
void ScoreElement::resetProperty(Pid pid)
|
2015-02-04 22:12:13 +01:00
|
|
|
|
{
|
2018-07-11 12:23:32 +02:00
|
|
|
|
QVariant v = propertyDefault(pid);
|
2017-12-13 15:49:55 +01:00
|
|
|
|
if (v.isValid()) {
|
2018-07-11 12:23:32 +02:00
|
|
|
|
setProperty(pid, v);
|
|
|
|
|
PropertyFlags p = propertyFlags(pid);
|
2018-11-26 21:09:20 +01:00
|
|
|
|
if (p == PropertyFlags::UNSTYLED)
|
2018-07-11 12:23:32 +02:00
|
|
|
|
setPropertyFlags(pid, PropertyFlags::STYLED);
|
2017-12-13 15:49:55 +01:00
|
|
|
|
}
|
2015-02-04 22:12:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-18 14:16:33 +01:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// undoResetProperty
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
2018-03-27 15:36:00 +02:00
|
|
|
|
void ScoreElement::undoResetProperty(Pid id)
|
2017-01-18 14:16:33 +01:00
|
|
|
|
{
|
|
|
|
|
PropertyFlags f = propertyFlags(id);
|
2017-07-11 18:00:17 +02:00
|
|
|
|
if (f == PropertyFlags::UNSTYLED)
|
2018-11-26 21:09:20 +01:00
|
|
|
|
f = PropertyFlags::STYLED;
|
|
|
|
|
undoChangeProperty(id, propertyDefault(id), f);
|
2017-01-18 14:16:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-11 12:23:32 +02:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// isStyled
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
bool ScoreElement::isStyled(Pid pid) const
|
|
|
|
|
{
|
|
|
|
|
PropertyFlags f = propertyFlags(pid);
|
|
|
|
|
return f == PropertyFlags::STYLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// changeProperty
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
static void changeProperty(ScoreElement* e, Pid t, const QVariant& st, PropertyFlags ps)
|
|
|
|
|
{
|
|
|
|
|
if (e->getProperty(t) != st || e->propertyFlags(t) != ps) {
|
|
|
|
|
if (e->isBracketItem()) {
|
|
|
|
|
BracketItem* bi = toBracketItem(e);
|
|
|
|
|
e->score()->undo(new ChangeBracketProperty(bi->staff(), bi->column(), t, st, ps));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
e->score()->undo(new ChangeProperty(e, t, st, ps));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-04 12:41:42 +01:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// changeProperties
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
2018-03-27 15:36:00 +02:00
|
|
|
|
static void changeProperties(ScoreElement* e, Pid t, const QVariant& st, PropertyFlags ps)
|
2018-01-04 12:41:42 +01:00
|
|
|
|
{
|
|
|
|
|
if (propertyLink(t)) {
|
2018-07-11 12:23:32 +02:00
|
|
|
|
for (ScoreElement* ee : e->linkList())
|
|
|
|
|
changeProperty(ee, t, st, ps);
|
2018-01-04 12:41:42 +01:00
|
|
|
|
}
|
2018-07-11 12:23:32 +02:00
|
|
|
|
else
|
|
|
|
|
changeProperty(e, t, st, ps);
|
2018-01-04 12:41:42 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-04 22:12:13 +01:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// undoChangeProperty
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
2018-03-27 15:36:00 +02:00
|
|
|
|
void ScoreElement::undoChangeProperty(Pid id, const QVariant& v)
|
2015-02-04 22:12:13 +01:00
|
|
|
|
{
|
2017-01-18 14:16:33 +01:00
|
|
|
|
undoChangeProperty(id, v, propertyFlags(id));
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-27 15:36:00 +02:00
|
|
|
|
void ScoreElement::undoChangeProperty(Pid id, const QVariant& v, PropertyFlags ps)
|
2017-01-18 14:16:33 +01:00
|
|
|
|
{
|
2019-01-09 13:18:15 +01:00
|
|
|
|
if ((getProperty(id) == v) && (propertyFlags(id) == ps))
|
|
|
|
|
return;
|
2018-10-18 11:53:01 +02:00
|
|
|
|
bool doUpdateInspector = false;
|
2018-12-19 17:47:00 +01:00
|
|
|
|
if (id == Pid::PLACEMENT || id == Pid::HAIRPIN_TYPE) {
|
|
|
|
|
// first set property, then set offset for above/below if styled
|
2018-10-18 11:53:01 +02:00
|
|
|
|
changeProperties(this, id, v, ps);
|
2018-12-19 17:47:00 +01:00
|
|
|
|
|
2018-10-18 11:53:01 +02:00
|
|
|
|
if (isStyled(Pid::OFFSET))
|
|
|
|
|
ScoreElement::undoChangeProperty(Pid::OFFSET, score()->styleV(getPropertyStyle(Pid::OFFSET)).toPointF() * score()->spatium());
|
|
|
|
|
doUpdateInspector = true;
|
2017-01-18 14:16:33 +01:00
|
|
|
|
}
|
2018-11-26 21:09:20 +01:00
|
|
|
|
else if (id == Pid::SUB_STYLE) {
|
2017-01-18 14:16:33 +01:00
|
|
|
|
//
|
|
|
|
|
// change a list of properties
|
|
|
|
|
//
|
2018-08-01 11:46:07 +02:00
|
|
|
|
auto l = textStyle(Tid(v.toInt()));
|
|
|
|
|
// Change to ElementStyle defaults
|
|
|
|
|
for (const StyledProperty& p : *l) {
|
2018-03-28 10:43:28 +02:00
|
|
|
|
if (p.sid == Sid::NOSTYLE)
|
2018-03-21 14:05:33 +01:00
|
|
|
|
break;
|
2018-03-28 10:43:28 +02:00
|
|
|
|
changeProperties(this, p.pid, score()->styleV(p.sid), PropertyFlags::STYLED);
|
2018-03-21 14:05:33 +01:00
|
|
|
|
}
|
2017-01-18 14:16:33 +01:00
|
|
|
|
}
|
2018-01-04 12:41:42 +01:00
|
|
|
|
changeProperties(this, id, v, ps);
|
2018-06-08 18:24:28 +02:00
|
|
|
|
if (id != Pid::GENERATED)
|
|
|
|
|
changeProperties(this, Pid::GENERATED, QVariant(false), PropertyFlags::NOSTYLE);
|
2018-10-18 11:53:01 +02:00
|
|
|
|
if (doUpdateInspector)
|
|
|
|
|
MuseScoreCore::mscoreCore->updateInspector();
|
2015-02-04 22:12:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// undoPushProperty
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
2018-03-27 15:36:00 +02:00
|
|
|
|
void ScoreElement::undoPushProperty(Pid id)
|
2015-02-04 22:12:13 +01:00
|
|
|
|
{
|
|
|
|
|
QVariant val = getProperty(id);
|
2016-03-10 10:41:31 +01:00
|
|
|
|
score()->undoStack()->push1(new ChangeProperty(this, id, val));
|
2015-02-04 22:12:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-28 17:49:08 +02:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// readProperty
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
2018-10-26 10:41:07 +02:00
|
|
|
|
void ScoreElement::readProperty(XmlReader& e, Pid id)
|
|
|
|
|
{
|
|
|
|
|
QVariant v = Ms::readProperty(id, e);
|
|
|
|
|
switch (propertyType(id)) {
|
|
|
|
|
case P_TYPE::SP_REAL:
|
|
|
|
|
v = v.toReal() * score()->spatium();
|
|
|
|
|
break;
|
2018-10-26 12:28:11 +02:00
|
|
|
|
case P_TYPE::POINT_SP:
|
|
|
|
|
v = v.toPointF() * score()->spatium();
|
|
|
|
|
break;
|
2018-10-26 10:41:07 +02:00
|
|
|
|
case P_TYPE::POINT_SP_MM:
|
|
|
|
|
if (sizeIsSpatiumDependent())
|
|
|
|
|
v = v.toPointF() * score()->spatium();
|
|
|
|
|
else
|
|
|
|
|
v = v.toPointF() * DPMM;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
setProperty(id, v);
|
|
|
|
|
if (isStyled(id))
|
|
|
|
|
setPropertyFlags(id, PropertyFlags::UNSTYLED);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-28 17:49:08 +02:00
|
|
|
|
bool ScoreElement::readProperty(const QStringRef& s, XmlReader& e, Pid id)
|
|
|
|
|
{
|
|
|
|
|
if (s == propertyName(id)) {
|
2018-10-26 10:41:07 +02:00
|
|
|
|
readProperty(e, id);
|
2018-03-28 17:49:08 +02:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-06 11:27:27 +01:00
|
|
|
|
//-----------------------------------------------------------------------------
|
2015-02-04 22:12:13 +01:00
|
|
|
|
// writeProperty
|
2018-11-06 11:27:27 +01:00
|
|
|
|
//
|
|
|
|
|
// - styled properties are never written
|
|
|
|
|
// - unstyled properties are always written regardless of value,
|
|
|
|
|
// - properties without style are written if different from default value
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2015-02-04 22:12:13 +01:00
|
|
|
|
|
2018-11-06 11:27:27 +01:00
|
|
|
|
void ScoreElement::writeProperty(XmlWriter& xml, Pid pid) const
|
2015-02-04 22:12:13 +01:00
|
|
|
|
{
|
2018-11-06 11:27:27 +01:00
|
|
|
|
if (isStyled(pid))
|
|
|
|
|
return;
|
|
|
|
|
QVariant p = getProperty(pid);
|
|
|
|
|
if (!p.isValid()) {
|
2018-11-29 14:14:58 +01:00
|
|
|
|
qDebug("%s invalid property %d <%s><%s>", name(), int(pid), propertyName(pid), propertyQmlName(pid));
|
2018-10-25 15:43:59 +02:00
|
|
|
|
return;
|
2016-12-28 16:23:10 +01:00
|
|
|
|
}
|
2018-11-06 11:27:27 +01:00
|
|
|
|
PropertyFlags f = propertyFlags(pid);
|
2018-12-03 18:56:16 +01:00
|
|
|
|
QVariant d = (f != PropertyFlags::STYLED) ? propertyDefault(pid) : QVariant();
|
2018-11-06 11:27:27 +01:00
|
|
|
|
|
2018-11-26 21:09:20 +01:00
|
|
|
|
if (pid == Pid::FONT_STYLE) {
|
|
|
|
|
FontStyle ds = FontStyle(d.isValid() ? d.toInt() : 0);
|
|
|
|
|
FontStyle fs = FontStyle(p.toInt());
|
2018-12-03 18:56:16 +01:00
|
|
|
|
if ((fs & FontStyle::Bold) != (ds & FontStyle::Bold))
|
2018-11-26 21:09:20 +01:00
|
|
|
|
xml.tag("bold", fs & FontStyle::Bold);
|
2018-12-03 18:56:16 +01:00
|
|
|
|
if ((fs & FontStyle::Italic) != (ds & FontStyle::Italic))
|
|
|
|
|
xml.tag("italic", fs & FontStyle::Italic);
|
|
|
|
|
if ((fs & FontStyle::Underline) != (ds & FontStyle::Underline))
|
2018-11-26 21:09:20 +01:00
|
|
|
|
xml.tag("underline", fs & FontStyle::Underline);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-06 11:27:27 +01:00
|
|
|
|
if (propertyType(pid) == P_TYPE::SP_REAL) {
|
|
|
|
|
qreal f1 = p.toReal();
|
|
|
|
|
if (d.isValid() && qAbs(f1 - d.toReal()) < 0.0001) // fuzzy compare
|
2018-06-11 17:30:29 +02:00
|
|
|
|
return;
|
2018-11-06 11:27:27 +01:00
|
|
|
|
p = QVariant(f1/score()->spatium());
|
|
|
|
|
d = QVariant();
|
2018-06-11 17:30:29 +02:00
|
|
|
|
}
|
2018-11-06 11:27:27 +01:00
|
|
|
|
else if (propertyType(pid) == P_TYPE::POINT_SP) {
|
|
|
|
|
QPointF p1 = p.toPointF();
|
|
|
|
|
if (d.isValid()) {
|
|
|
|
|
QPointF p2 = d.toPointF();
|
|
|
|
|
if ( (qAbs(p1.x() - p2.x()) < 0.0001) && (qAbs(p1.y() - p2.y()) < 0.0001))
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
p = QVariant(p1/score()->spatium());
|
|
|
|
|
d = QVariant();
|
2018-10-18 11:53:01 +02:00
|
|
|
|
}
|
2018-11-06 11:27:27 +01:00
|
|
|
|
else if (propertyType(pid) == P_TYPE::POINT_SP_MM) {
|
|
|
|
|
QPointF p1 = p.toPointF();
|
|
|
|
|
if (d.isValid()) {
|
|
|
|
|
QPointF p2 = d.toPointF();
|
|
|
|
|
if ((qAbs(p1.x() - p2.x()) < 0.0001) && (qAbs(p1.y() - p2.y()) < 0.0001))
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
qreal q = sizeIsSpatiumDependent() ? score()->spatium() : DPMM;
|
|
|
|
|
p = QVariant(p1/q);
|
|
|
|
|
d = QVariant();
|
2017-12-13 15:49:55 +01:00
|
|
|
|
}
|
2018-11-06 11:27:27 +01:00
|
|
|
|
xml.tag(pid, p, d);
|
2015-02-04 22:12:13 +01:00
|
|
|
|
}
|
2018-09-26 12:54:45 +02:00
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// propertyId
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
Pid ScoreElement::propertyId(const QStringRef& xmlName) const
|
|
|
|
|
{
|
|
|
|
|
return propertyIdName(xmlName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// propertyUserValue
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QString ScoreElement::propertyUserValue(Pid id) const
|
|
|
|
|
{
|
|
|
|
|
QVariant val = getProperty(id);
|
|
|
|
|
switch (propertyType(id)) {
|
|
|
|
|
case P_TYPE::POINT_SP:
|
|
|
|
|
{
|
|
|
|
|
QPointF p = val.toPointF();
|
|
|
|
|
return QString("(%1, %2)").arg(p.x()).arg(p.y());
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return val.toString();
|
|
|
|
|
}
|
2015-02-04 22:12:13 +01:00
|
|
|
|
|
2018-03-28 17:49:08 +02:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// readStyledProperty
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
bool ScoreElement::readStyledProperty(XmlReader& e, const QStringRef& tag)
|
|
|
|
|
{
|
2018-08-01 11:46:07 +02:00
|
|
|
|
for (const StyledProperty& spp : *styledProperties()) {
|
|
|
|
|
if (readProperty(tag, e, spp.pid))
|
2018-03-28 17:49:08 +02:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-21 16:00:19 +01:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// writeStyledProperties
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
void ScoreElement::writeStyledProperties(XmlWriter& xml) const
|
|
|
|
|
{
|
2018-08-01 11:46:07 +02:00
|
|
|
|
for (const StyledProperty& spp : *styledProperties())
|
|
|
|
|
writeProperty(xml, spp.pid);
|
2018-03-21 16:00:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2018-03-28 17:49:08 +02:00
|
|
|
|
// reset
|
2018-03-21 16:00:19 +01:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
2018-03-28 17:49:08 +02:00
|
|
|
|
void ScoreElement::reset()
|
2018-03-21 16:00:19 +01:00
|
|
|
|
{
|
2018-08-01 11:46:07 +02:00
|
|
|
|
for (const StyledProperty& spp : *styledProperties())
|
|
|
|
|
undoResetProperty(spp.pid);
|
2018-03-21 16:00:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-26 20:01:06 +02:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// readAddConnector
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
void ScoreElement::readAddConnector(ConnectorInfoReader* info, bool pasteMode)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(pasteMode);
|
|
|
|
|
qDebug("Cannot add connector %s to %s", info->connector()->name(), name());
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-12 11:41:39 +01:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// linkTo
|
2018-04-27 13:29:20 +02:00
|
|
|
|
// link this to element
|
2015-02-12 11:41:39 +01:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
void ScoreElement::linkTo(ScoreElement* element)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(element != this);
|
2018-04-27 13:29:20 +02:00
|
|
|
|
Q_ASSERT(!_links);
|
|
|
|
|
|
|
|
|
|
if (element->links()) {
|
|
|
|
|
_links = element->_links;
|
|
|
|
|
Q_ASSERT(_links->contains(element));
|
2015-02-12 11:41:39 +01:00
|
|
|
|
}
|
|
|
|
|
else {
|
2018-04-27 13:29:20 +02:00
|
|
|
|
if (isStaff())
|
2018-11-27 22:49:18 +01:00
|
|
|
|
_links = new LinkedElements(score(), -1); // don’t use lid
|
2018-04-27 13:29:20 +02:00
|
|
|
|
else
|
|
|
|
|
_links = new LinkedElements(score());
|
2015-02-12 11:41:39 +01:00
|
|
|
|
_links->append(element);
|
|
|
|
|
element->_links = _links;
|
|
|
|
|
}
|
2018-04-27 13:29:20 +02:00
|
|
|
|
Q_ASSERT(!_links->contains(this));
|
|
|
|
|
_links->append(this);
|
2015-02-12 11:41:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// unlink
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
void ScoreElement::unlink()
|
|
|
|
|
{
|
2018-04-27 13:29:20 +02:00
|
|
|
|
Q_ASSERT(_links);
|
|
|
|
|
Q_ASSERT(_links->contains(this));
|
|
|
|
|
_links->removeOne(this);
|
|
|
|
|
|
|
|
|
|
// if link list is empty, remove list
|
|
|
|
|
if (_links->size() <= 1) {
|
|
|
|
|
if (!_links->empty())
|
|
|
|
|
_links->front()->_links = 0;
|
|
|
|
|
delete _links;
|
2015-02-12 11:41:39 +01:00
|
|
|
|
}
|
2018-04-27 13:29:20 +02:00
|
|
|
|
_links = 0; // this element is not linked anymore
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// isLinked
|
|
|
|
|
/// return true if se is different and
|
|
|
|
|
/// linked to this element
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
bool ScoreElement::isLinked(ScoreElement* se)
|
|
|
|
|
{
|
|
|
|
|
return se != this && _links && _links->contains(se);
|
2015-02-12 11:41:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// undoUnlink
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
void ScoreElement::undoUnlink()
|
|
|
|
|
{
|
2016-12-02 10:47:09 +01:00
|
|
|
|
if (_links)
|
|
|
|
|
_score->undo(new Unlink(this));
|
2015-02-12 11:41:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// linkList
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QList<ScoreElement*> ScoreElement::linkList() const
|
|
|
|
|
{
|
|
|
|
|
QList<ScoreElement*> el;
|
2018-01-04 12:41:42 +01:00
|
|
|
|
if (_links)
|
2018-04-27 13:29:20 +02:00
|
|
|
|
el = *_links;
|
2015-02-12 11:41:39 +01:00
|
|
|
|
else
|
2018-01-04 12:41:42 +01:00
|
|
|
|
el.append(const_cast<ScoreElement*>(this));
|
2015-02-12 11:41:39 +01:00
|
|
|
|
return el;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// LinkedElements
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
LinkedElements::LinkedElements(Score* score)
|
|
|
|
|
{
|
|
|
|
|
_lid = score->linkId(); // create new unique id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LinkedElements::LinkedElements(Score* score, int id)
|
|
|
|
|
{
|
|
|
|
|
_lid = id;
|
2018-04-27 13:29:20 +02:00
|
|
|
|
if (_lid != -1)
|
|
|
|
|
score->linkId(id); // remember used id
|
2015-02-12 11:41:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// setLid
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
void LinkedElements::setLid(Score* score, int id)
|
|
|
|
|
{
|
|
|
|
|
_lid = id;
|
|
|
|
|
score->linkId(id);
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-17 07:06:25 +02:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// mainElement
|
2018-12-07 09:39:23 +01:00
|
|
|
|
// Returns "main" linked element which is expected to
|
|
|
|
|
// be written to the file prior to others.
|
2018-06-17 07:06:25 +02:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
ScoreElement* LinkedElements::mainElement()
|
|
|
|
|
{
|
|
|
|
|
if (isEmpty())
|
|
|
|
|
return nullptr;
|
|
|
|
|
MasterScore* ms = at(0)->masterScore();
|
2018-12-07 09:39:23 +01:00
|
|
|
|
const bool elements = at(0)->isElement();
|
|
|
|
|
return *std::min_element(begin(), end(), [ms, elements](ScoreElement* s1, ScoreElement* s2) {
|
|
|
|
|
if (s1->score() == ms && s2->score() != ms)
|
|
|
|
|
return true;
|
|
|
|
|
if (elements) {
|
|
|
|
|
if (s1->score() != s2->score())
|
|
|
|
|
return false;
|
|
|
|
|
// Now we compare either two elements from master score
|
|
|
|
|
// or two elements from excerpt.
|
|
|
|
|
Element* e1 = toElement(s1);
|
|
|
|
|
Element* e2 = toElement(s2);
|
|
|
|
|
if (e1->track() < e2->track())
|
|
|
|
|
return true;
|
|
|
|
|
if (e1->track() == e2->track() && e1->tick() < e2->tick())
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
});
|
2018-06-17 07:06:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-10 10:41:31 +01:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// masterScore
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
MasterScore* ScoreElement::masterScore() const
|
|
|
|
|
{
|
|
|
|
|
return _score->masterScore();
|
|
|
|
|
}
|
2016-07-09 17:07:12 +02:00
|
|
|
|
|
2018-08-01 11:46:07 +02:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// getPropertyFlagsIdx
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
int ScoreElement::getPropertyFlagsIdx(Pid id) const
|
|
|
|
|
{
|
2018-08-02 10:57:48 +02:00
|
|
|
|
int i = 0;
|
|
|
|
|
for (const StyledProperty& p : *_elementStyle) {
|
|
|
|
|
if (p.pid == id)
|
|
|
|
|
return i;
|
|
|
|
|
++i;
|
2018-08-01 11:46:07 +02:00
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-09 17:07:12 +02:00
|
|
|
|
//---------------------------------------------------------
|
2017-12-13 15:49:55 +01:00
|
|
|
|
// propertyFlags
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
2018-07-11 12:23:32 +02:00
|
|
|
|
PropertyFlags ScoreElement::propertyFlags(Pid id) const
|
2017-12-13 15:49:55 +01:00
|
|
|
|
{
|
|
|
|
|
static PropertyFlags f = PropertyFlags::NOSTYLE;
|
2018-03-21 14:05:33 +01:00
|
|
|
|
|
2018-08-01 11:46:07 +02:00
|
|
|
|
int i = getPropertyFlagsIdx(id);
|
|
|
|
|
if (i == -1)
|
|
|
|
|
return f;
|
|
|
|
|
return _propertyFlagsList[i];
|
2017-12-13 15:49:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// setPropertyFlags
|
2016-07-09 17:07:12 +02:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
2018-03-27 15:36:00 +02:00
|
|
|
|
void ScoreElement::setPropertyFlags(Pid id, PropertyFlags f)
|
2016-07-09 17:07:12 +02:00
|
|
|
|
{
|
2018-08-01 11:46:07 +02:00
|
|
|
|
int i = getPropertyFlagsIdx(id);
|
|
|
|
|
if (i == -1)
|
|
|
|
|
return;
|
|
|
|
|
_propertyFlagsList[i] = f;
|
2016-07-09 17:07:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// getPropertyStyle
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
2018-03-27 15:36:00 +02:00
|
|
|
|
Sid ScoreElement::getPropertyStyle(Pid id) const
|
2016-07-09 17:07:12 +02:00
|
|
|
|
{
|
2018-08-02 10:57:48 +02:00
|
|
|
|
for (const StyledProperty& p : *_elementStyle) {
|
|
|
|
|
if (p.pid == id)
|
|
|
|
|
return p.sid;
|
2018-03-15 11:52:17 +01:00
|
|
|
|
}
|
2018-03-27 15:36:00 +02:00
|
|
|
|
return Sid::NOSTYLE;
|
2016-07-09 17:07:12 +02:00
|
|
|
|
}
|
2017-01-18 14:16:33 +01:00
|
|
|
|
|
2018-03-16 10:54:18 +01:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// styleChanged
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
void ScoreElement::styleChanged()
|
|
|
|
|
{
|
2018-08-02 10:57:48 +02:00
|
|
|
|
for (const StyledProperty& spp : *_elementStyle) {
|
|
|
|
|
PropertyFlags f = propertyFlags(spp.pid);
|
2018-10-25 16:26:44 +02:00
|
|
|
|
if (f == PropertyFlags::STYLED)
|
2018-12-05 15:17:33 +01:00
|
|
|
|
setProperty(spp.pid, styleValue(spp.pid, getPropertyStyle(spp.pid)));
|
2018-03-16 10:54:18 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-18 14:16:33 +01:00
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// name
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
const char* ScoreElement::name() const
|
|
|
|
|
{
|
|
|
|
|
return name(type());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// name
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
const char* ScoreElement::name(ElementType type)
|
|
|
|
|
{
|
|
|
|
|
return elementNames[int(type)].name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// userName
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QString ScoreElement::userName() const
|
|
|
|
|
{
|
|
|
|
|
return qApp->translate("elementName", elementNames[int(type())].userName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// name2type
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
2018-07-06 18:59:39 +02:00
|
|
|
|
ElementType ScoreElement::name2type(const QStringRef& s, bool silent)
|
2017-01-18 14:16:33 +01:00
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < int(ElementType::MAXTYPE); ++i) {
|
|
|
|
|
if (s == elementNames[i].name)
|
|
|
|
|
return ElementType(i);
|
|
|
|
|
}
|
2018-07-06 18:59:39 +02:00
|
|
|
|
if (!silent)
|
|
|
|
|
qDebug("unknown type <%s>", qPrintable(s.toString()));
|
2017-01-18 14:16:33 +01:00
|
|
|
|
return ElementType::INVALID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// isSLineSegment
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
bool ScoreElement::isSLineSegment() const
|
|
|
|
|
{
|
|
|
|
|
return isHairpinSegment() || isOttavaSegment() || isPedalSegment()
|
|
|
|
|
|| isTrillSegment() || isVoltaSegment() || isTextLineSegment()
|
2017-11-27 16:55:52 +01:00
|
|
|
|
|| isGlissandoSegment() || isLetRingSegment() || isVibratoSegment() || isPalmMuteSegment();
|
2017-01-18 14:16:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// isText
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
2018-04-18 14:31:36 +02:00
|
|
|
|
bool ScoreElement::isTextBase() const
|
2017-01-18 14:16:33 +01:00
|
|
|
|
{
|
|
|
|
|
return type() == ElementType::TEXT
|
|
|
|
|
|| type() == ElementType::LYRICS
|
|
|
|
|
|| type() == ElementType::DYNAMIC
|
|
|
|
|
|| type() == ElementType::FINGERING
|
|
|
|
|
|| type() == ElementType::HARMONY
|
|
|
|
|
|| type() == ElementType::MARKER
|
|
|
|
|
|| type() == ElementType::JUMP
|
|
|
|
|
|| type() == ElementType::STAFF_TEXT
|
2018-05-29 09:43:12 +02:00
|
|
|
|
|| type() == ElementType::SYSTEM_TEXT
|
2017-01-18 14:16:33 +01:00
|
|
|
|
|| type() == ElementType::REHEARSAL_MARK
|
|
|
|
|
|| type() == ElementType::INSTRUMENT_CHANGE
|
|
|
|
|
|| type() == ElementType::FIGURED_BASS
|
|
|
|
|
|| type() == ElementType::TEMPO_TEXT
|
|
|
|
|
|| type() == ElementType::INSTRUMENT_NAME
|
2018-10-24 10:40:03 +02:00
|
|
|
|
|| type() == ElementType::MEASURE_NUMBER
|
2017-01-18 14:16:33 +01:00
|
|
|
|
;
|
|
|
|
|
}
|
2018-10-26 12:28:11 +02:00
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
// styleValue
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QVariant ScoreElement::styleValue(Pid pid, Sid sid) const
|
|
|
|
|
{
|
|
|
|
|
switch (propertyType(pid)) {
|
|
|
|
|
case P_TYPE::SP_REAL:
|
|
|
|
|
return score()->styleP(sid);
|
|
|
|
|
case P_TYPE::POINT_SP:
|
|
|
|
|
return score()->styleV(sid).toPointF() * score()->spatium();
|
|
|
|
|
case P_TYPE::POINT_SP_MM: {
|
|
|
|
|
QPointF val = score()->styleV(sid).toPointF();
|
|
|
|
|
if (sizeIsSpatiumDependent())
|
|
|
|
|
val *= score()->spatium();
|
|
|
|
|
else
|
|
|
|
|
val *= DPMM;
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
return score()->styleV(sid);
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-02-04 22:12:13 +01:00
|
|
|
|
}
|
|
|
|
|
|