fix #287245: allow symbols and images on barlines
It sometimes comes up that the best way to solve some particular problem would be to attach a symbol to a barline (eg, think about the commonly-requested multimeasure repeat symbol). But we don't support symbols on barlines, so you end up settling for attaching to the first note or rest in the bar then moving manually, and this adjustment does not necessarily survicve layout changes. This commit adds direct support for symbols on barlines. Also images, since the code involved is so similar, they are handled here as well. Symbols and images are recorded as child elements, which were already being laid out so no special handling was needed beyond adding & removing, reading nd writing. Although I did need to make sure the track & score were managed correctly.
This commit is contained in:
parent
002416819f
commit
4eadb70636
6 changed files with 267 additions and 4 deletions
|
@ -26,6 +26,8 @@
|
|||
#include "spanner.h"
|
||||
#include "undo.h"
|
||||
#include "fermata.h"
|
||||
#include "symbol.h"
|
||||
#include "image.h"
|
||||
|
||||
namespace Ms {
|
||||
|
||||
|
@ -292,7 +294,7 @@ BarLine::BarLine(const BarLine& bl)
|
|||
y2 = bl.y2;
|
||||
|
||||
for (Element* e : bl._el)
|
||||
_el.push_back(e->clone());
|
||||
add(e->clone());
|
||||
}
|
||||
|
||||
BarLine::~BarLine()
|
||||
|
@ -725,6 +727,22 @@ void BarLine::read(XmlReader& e)
|
|||
a->read(e);
|
||||
add(a);
|
||||
}
|
||||
else if (tag == "Symbol") {
|
||||
Symbol* s = new Symbol(score());
|
||||
s->setTrack(track());
|
||||
s->read(e);
|
||||
add(s);
|
||||
}
|
||||
else if (tag == "Image") {
|
||||
if (MScore::noImages)
|
||||
e.skipCurrentElement();
|
||||
else {
|
||||
Image* image = new Image(score());
|
||||
image->setTrack(track());
|
||||
image->read(e);
|
||||
add(image);
|
||||
}
|
||||
}
|
||||
else if (!Element::readProperties(e))
|
||||
e.unknown();
|
||||
}
|
||||
|
@ -741,7 +759,7 @@ bool BarLine::acceptDrop(EditData& data) const
|
|||
return true;
|
||||
}
|
||||
else {
|
||||
return ((type == ElementType::ARTICULATION || type == ElementType::FERMATA)
|
||||
return ((type == ElementType::ARTICULATION || type == ElementType::FERMATA || type == ElementType::SYMBOL || type == ElementType::IMAGE)
|
||||
&& segment()
|
||||
&& segment()->isEndBarLineType());
|
||||
}
|
||||
|
@ -805,6 +823,12 @@ Element* BarLine::drop(EditData& data)
|
|||
score()->undoAddElement(atr);
|
||||
return atr;
|
||||
}
|
||||
else if (e->isSymbol() || e->isImage()) {
|
||||
e->setParent(this);
|
||||
e->setTrack(track());
|
||||
score()->undoAddElement(e);
|
||||
return e;
|
||||
}
|
||||
else if (e->isFermata()) {
|
||||
e->setPlacement(track() & 1 ? Placement::BELOW : Placement::ABOVE);
|
||||
for (Element* el: segment()->annotations())
|
||||
|
@ -1366,6 +1390,28 @@ void BarLine::scanElements(void* data, void (*func)(void*, Element*), bool all)
|
|||
e->scanElements(data, func, all);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// setTrack
|
||||
//---------------------------------------------------------
|
||||
|
||||
void BarLine::setTrack(int t)
|
||||
{
|
||||
Element::setTrack(t);
|
||||
for (Element* e : _el)
|
||||
e->setTrack(t);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// setScore
|
||||
//---------------------------------------------------------
|
||||
|
||||
void BarLine::setScore(Score* s)
|
||||
{
|
||||
Element::setScore(s);
|
||||
for (Element* e : _el)
|
||||
e->setScore(s);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// add
|
||||
//---------------------------------------------------------
|
||||
|
@ -1375,6 +1421,8 @@ void BarLine::add(Element* e)
|
|||
e->setParent(this);
|
||||
switch (e->type()) {
|
||||
case ElementType::ARTICULATION:
|
||||
case ElementType::SYMBOL:
|
||||
case ElementType::IMAGE:
|
||||
_el.push_back(e);
|
||||
setGenerated(false);
|
||||
break;
|
||||
|
@ -1393,6 +1441,8 @@ void BarLine::remove(Element* e)
|
|||
{
|
||||
switch(e->type()) {
|
||||
case ElementType::ARTICULATION:
|
||||
case ElementType::SYMBOL:
|
||||
case ElementType::IMAGE:
|
||||
if (!_el.remove(e))
|
||||
qDebug("BarLine::remove(): cannot find %s", e->name());
|
||||
break;
|
||||
|
|
|
@ -86,6 +86,8 @@ class BarLine final : public Element {
|
|||
virtual void layout() override;
|
||||
void layout2();
|
||||
virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true) override;
|
||||
virtual void setTrack(int t) override;
|
||||
virtual void setScore(Score* s) override;
|
||||
virtual void add(Element*) override;
|
||||
virtual void remove(Element*) override;
|
||||
virtual bool acceptDrop(EditData&) const override;
|
||||
|
|
|
@ -40,7 +40,7 @@ else
|
|||
emmentaler-text-2 gonville-text-2 bravura-text-2 musejazz-text-2\
|
||||
emmentaler-text-3 gonville-text-3 bravura-text-3 musejazz-text-3\
|
||||
frametext ottava \
|
||||
barline-1 instrument-1 \
|
||||
barline-1 instrument-1 symbol-1 \
|
||||
slurs-1 slurs-2 slurs-3 slurs-4 slurs-5 slurs-6 slurs-7 slurs-8 slurs-9 slurs-10 \
|
||||
hairpins-1 pedal-1 line-1 line-2 line-3 line-4 line-5 line-6 gliss-1 gliss-2\
|
||||
chord-layout-1 chord-layout-2 chord-layout-3 chord-layout-4 chord-layout-5\
|
||||
|
|
|
@ -20,7 +20,7 @@ set SRC=mmrest-1,bravura-mmrest,gonville-mmrest,mmrest-2,mmrest-4,mmrest-5,mmres
|
|||
emmentaler-text-2,gonville-text-2,bravura-text-2,musejazz-text-2, ^
|
||||
emmentaler-text-3,gonville-text-3,bravura-text-3,musejazz-text-3, ^
|
||||
frametext,ottava, ^
|
||||
barline-1,instrument-1, ^
|
||||
barline-1,instrument-1,symbol-1, ^
|
||||
slurs-1,slurs-2,slurs-3,slurs-4,hairpins-1,pedal-1,line-1,line-2,line-3,line-4,line-5,line-6,gliss-1,gliss-2, ^
|
||||
chord-layout-1,chord-layout-2,chord-layout-3,chord-layout-4,chord-layout-5, ^
|
||||
chord-layout-6,chord-layout-7,chord-layout-8,chord-layout-9,chord-layout-10, ^
|
||||
|
|
211
vtest/symbol-1.mscx
Normal file
211
vtest/symbol-1.mscx
Normal file
|
@ -0,0 +1,211 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<museScore version="3.01">
|
||||
<Score>
|
||||
<LayerTag id="0" tag="default"></LayerTag>
|
||||
<currentLayer>0</currentLayer>
|
||||
<Division>480</Division>
|
||||
<Style>
|
||||
<pageWidth>3.93701</pageWidth>
|
||||
<pageHeight>1.96851</pageHeight>
|
||||
<pagePrintableWidth>3.77953</pagePrintableWidth>
|
||||
<pageEvenLeftMargin>0.0787403</pageEvenLeftMargin>
|
||||
<pageOddLeftMargin>0.0787403</pageOddLeftMargin>
|
||||
<pageEvenTopMargin>0</pageEvenTopMargin>
|
||||
<pageEvenBottomMargin>0</pageEvenBottomMargin>
|
||||
<pageOddTopMargin>0</pageOddTopMargin>
|
||||
<pageOddBottomMargin>0</pageOddBottomMargin>
|
||||
<pageTwosided>0</pageTwosided>
|
||||
<lyricsDashForce>0</lyricsDashForce>
|
||||
<doubleBarDistance>0.46</doubleBarDistance>
|
||||
<endBarDistance>0.65</endBarDistance>
|
||||
<clefLeftMargin>0.64</clefLeftMargin>
|
||||
<clefKeyRightMargin>1.75</clefKeyRightMargin>
|
||||
<barNoteDistance>1.2</barNoteDistance>
|
||||
<harmonyFretDist>0.5</harmonyFretDist>
|
||||
<showMeasureNumber>0</showMeasureNumber>
|
||||
<showFooter>0</showFooter>
|
||||
<defaultFramePadding>0.5</defaultFramePadding>
|
||||
<defaultFrameWidth>0.2</defaultFrameWidth>
|
||||
<defaultFrameRound>25</defaultFrameRound>
|
||||
<titleFramePadding>0.5</titleFramePadding>
|
||||
<titleFrameWidth>0.2</titleFrameWidth>
|
||||
<titleFrameRound>25</titleFrameRound>
|
||||
<subTitleFramePadding>0.5</subTitleFramePadding>
|
||||
<subTitleFrameWidth>0.2</subTitleFrameWidth>
|
||||
<subTitleFrameRound>25</subTitleFrameRound>
|
||||
<composerFramePadding>0.5</composerFramePadding>
|
||||
<composerFrameWidth>0.2</composerFrameWidth>
|
||||
<composerFrameRound>25</composerFrameRound>
|
||||
<lyricistFramePadding>0.5</lyricistFramePadding>
|
||||
<lyricistFrameWidth>0.2</lyricistFrameWidth>
|
||||
<lyricistFrameRound>25</lyricistFrameRound>
|
||||
<fingeringFramePadding>0.5</fingeringFramePadding>
|
||||
<fingeringFrameWidth>0.2</fingeringFrameWidth>
|
||||
<fingeringFrameRound>25</fingeringFrameRound>
|
||||
<lhGuitarFingeringFramePadding>0.5</lhGuitarFingeringFramePadding>
|
||||
<lhGuitarFingeringFrameWidth>0.2</lhGuitarFingeringFrameWidth>
|
||||
<lhGuitarFingeringFrameRound>25</lhGuitarFingeringFrameRound>
|
||||
<rhGuitarFingeringFramePadding>0.5</rhGuitarFingeringFramePadding>
|
||||
<rhGuitarFingeringFrameWidth>0.2</rhGuitarFingeringFrameWidth>
|
||||
<rhGuitarFingeringFrameRound>25</rhGuitarFingeringFrameRound>
|
||||
<partInstrumentFramePadding>0.5</partInstrumentFramePadding>
|
||||
<partInstrumentFrameWidth>0.2</partInstrumentFrameWidth>
|
||||
<partInstrumentFrameRound>25</partInstrumentFrameRound>
|
||||
<tempoFramePadding>0.5</tempoFramePadding>
|
||||
<tempoFrameWidth>0.2</tempoFrameWidth>
|
||||
<tempoFrameRound>25</tempoFrameRound>
|
||||
<systemFramePadding>0.5</systemFramePadding>
|
||||
<systemFrameWidth>0.2</systemFrameWidth>
|
||||
<systemFrameRound>25</systemFrameRound>
|
||||
<staffAlign>left,top</staffAlign>
|
||||
<staffPosAbove x="0" y="-4"/>
|
||||
<staffFramePadding>0.5</staffFramePadding>
|
||||
<staffFrameWidth>0.2</staffFrameWidth>
|
||||
<staffFrameRound>25</staffFrameRound>
|
||||
<repeatLeftFramePadding>0.5</repeatLeftFramePadding>
|
||||
<repeatLeftFrameWidth>0.2</repeatLeftFrameWidth>
|
||||
<repeatLeftFrameRound>25</repeatLeftFrameRound>
|
||||
<repeatRightFramePadding>0.5</repeatRightFramePadding>
|
||||
<repeatRightFrameWidth>0.2</repeatRightFrameWidth>
|
||||
<repeatRightFrameRound>25</repeatRightFrameRound>
|
||||
<Spatium>1.764</Spatium>
|
||||
</Style>
|
||||
<showInvisible>1</showInvisible>
|
||||
<showUnprintable>1</showUnprintable>
|
||||
<showFrames>1</showFrames>
|
||||
<showMargins>0</showMargins>
|
||||
<metaTag name="arranger"></metaTag>
|
||||
<metaTag name="composer"></metaTag>
|
||||
<metaTag name="copyright"></metaTag>
|
||||
<metaTag name="lyricist"></metaTag>
|
||||
<metaTag name="movementNumber"></metaTag>
|
||||
<metaTag name="movementTitle"></metaTag>
|
||||
<metaTag name="poet"></metaTag>
|
||||
<metaTag name="source"></metaTag>
|
||||
<metaTag name="translator"></metaTag>
|
||||
<metaTag name="workNumber"></metaTag>
|
||||
<metaTag name="workTitle"></metaTag>
|
||||
<Part>
|
||||
<Staff id="1">
|
||||
<StaffType group="pitched">
|
||||
<name>Standard</name>
|
||||
</StaffType>
|
||||
</Staff>
|
||||
<Staff id="2">
|
||||
<StaffType group="pitched">
|
||||
<name>Standard</name>
|
||||
</StaffType>
|
||||
<defaultClef>F</defaultClef>
|
||||
</Staff>
|
||||
<trackName>Piano</trackName>
|
||||
<Instrument>
|
||||
<shortName>Pno.</shortName>
|
||||
<trackName>Piano</trackName>
|
||||
<minPitchP>21</minPitchP>
|
||||
<maxPitchP>108</maxPitchP>
|
||||
<minPitchA>21</minPitchA>
|
||||
<maxPitchA>108</maxPitchA>
|
||||
<Articulation>
|
||||
<velocity>100</velocity>
|
||||
<gateTime>70</gateTime>
|
||||
</Articulation>
|
||||
<Articulation name="staccato">
|
||||
<velocity>100</velocity>
|
||||
<gateTime>40</gateTime>
|
||||
</Articulation>
|
||||
<Articulation name="tenuto">
|
||||
<velocity>100</velocity>
|
||||
<gateTime>100</gateTime>
|
||||
</Articulation>
|
||||
<Articulation name="sforzato">
|
||||
<velocity>120</velocity>
|
||||
<gateTime>100</gateTime>
|
||||
</Articulation>
|
||||
<Channel>
|
||||
<program value="0"/>
|
||||
</Channel>
|
||||
</Instrument>
|
||||
</Part>
|
||||
<Staff id="1">
|
||||
<Measure>
|
||||
<voice>
|
||||
<TimeSig>
|
||||
<sigN>4</sigN>
|
||||
<sigD>4</sigD>
|
||||
</TimeSig>
|
||||
<Rest>
|
||||
<durationType>measure</durationType>
|
||||
<duration>4/4</duration>
|
||||
<Symbol>
|
||||
<name>miscEyeglasses</name>
|
||||
<font>Bravura</font>
|
||||
</Symbol>
|
||||
</Rest>
|
||||
<BarLine>
|
||||
<Symbol>
|
||||
<name>repeat2Bars</name>
|
||||
<font>Bravura</font>
|
||||
<offset x="-1.5" y="2"/>
|
||||
</Symbol>
|
||||
</BarLine>
|
||||
</voice>
|
||||
</Measure>
|
||||
<Measure>
|
||||
<voice>
|
||||
<Rest>
|
||||
<durationType>measure</durationType>
|
||||
<duration>4/4</duration>
|
||||
</Rest>
|
||||
<BarLine>
|
||||
<subtype>end</subtype>
|
||||
</BarLine>
|
||||
</voice>
|
||||
</Measure>
|
||||
</Staff>
|
||||
<Staff id="2">
|
||||
<Measure>
|
||||
<voice>
|
||||
<TimeSig>
|
||||
<sigN>4</sigN>
|
||||
<sigD>4</sigD>
|
||||
</TimeSig>
|
||||
<Chord>
|
||||
<durationType>whole</durationType>
|
||||
<Note>
|
||||
<Symbol>
|
||||
<name>miscEyeglasses</name>
|
||||
<font>Bravura</font>
|
||||
</Symbol>
|
||||
<pitch>48</pitch>
|
||||
<tpc>14</tpc>
|
||||
</Note>
|
||||
</Chord>
|
||||
</voice>
|
||||
</Measure>
|
||||
<Measure>
|
||||
<voice>
|
||||
<Chord>
|
||||
<durationType>quarter</durationType>
|
||||
<Note>
|
||||
<pitch>48</pitch>
|
||||
<tpc>14</tpc>
|
||||
</Note>
|
||||
</Chord>
|
||||
<Rest>
|
||||
<durationType>quarter</durationType>
|
||||
<Symbol>
|
||||
<name>miscEyeglasses</name>
|
||||
<font>Bravura</font>
|
||||
</Symbol>
|
||||
</Rest>
|
||||
<Rest>
|
||||
<durationType>half</durationType>
|
||||
</Rest>
|
||||
<BarLine>
|
||||
<subtype>end</subtype>
|
||||
</BarLine>
|
||||
</voice>
|
||||
</Measure>
|
||||
</Staff>
|
||||
</Score>
|
||||
</museScore>
|
BIN
vtest/symbol-1.png
Normal file
BIN
vtest/symbol-1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.1 KiB |
Loading…
Reference in a new issue