clef: fix insertion of clef at same tick position

This commit is contained in:
ws 2013-06-05 09:53:38 +02:00
parent 55ee0fbfa9
commit 91f2a5d14f
10 changed files with 570 additions and 8 deletions

View file

@ -999,6 +999,12 @@ void Measure::add(Element* el)
score()->staff(track/VOICES)->setUpdateKeymap(true);
}
}
// insert segment at specific position
if (seg->next()) {
_segments.insert(seg, seg->next());
break;
}
int t = seg->tick();
Segment::SegmentType st = seg->segmentType();
Segment* s;

View file

@ -457,23 +457,23 @@ void Score::undoChangeClef(Staff* ostaff, Segment* seg, ClefType st)
st, clefTable[st].staffGroup, staff->staffType()->group());
continue;
}
Measure* measure = score->tick2measure(seg->tick());
int tick = seg->tick();
Measure* measure = score->tick2measure(tick);
if (!measure) {
qDebug("measure for tick %d not found!", seg->tick());
qDebug("measure for tick %d not found!", tick);
continue;
}
// move clef to last segment of prev measure?
// TODO: section break?
Segment* segment = seg;
int tick = seg->tick();
if (firstSeg
&& measure->prevMeasure()
&& !(measure->prevMeasure()->repeatFlags() & RepeatEnd)
) {
measure = measure->prevMeasure();
segment = measure->findSegment(seg->segmentType(), tick);
if(!segment && (seg->segmentType() != Segment::SegClef))
if (!segment && (seg->segmentType() != Segment::SegClef))
segment = measure->findSegment(Segment::SegClef, tick);
}

View file

@ -3827,7 +3827,6 @@ void MuseScore::cmd(QAction* a)
void MuseScore::endCmd()
{
bool enableInput = false;
if (cs) {
if (cv->noteEntryMode())
cs->moveCursor();
@ -3860,7 +3859,6 @@ void MuseScore::endCmd()
if (e == 0 && cs->inputState().noteEntryMode)
e = cs->inputState().cr();
enableInput = e && (e->type() == Element::NOTE || e->isChordRest());
cs->end();
}
else {

View file

@ -11,7 +11,7 @@
# the file LICENSE.GPL
#=============================================================================
set(CMAKE_VERBOSE_MAKEFILE ON)
# set(CMAKE_VERBOSE_MAKEFILE ON)
enable_testing()
include_directories(

View file

@ -14,7 +14,7 @@
subdirs(
hairpin note compat link measure beam split join splitstaff
timesig layout element midi dynamic plugins copypaste tuplet
repeat concertpitch keysig
repeat concertpitch keysig clef
)
# midi - does not work

View file

@ -0,0 +1,16 @@
#=============================================================================
# MuseScore
# Music Composition & Notation
#
# Copyright (C) 2011 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 LICENSE.GPL
#=============================================================================
set(TARGET tst_clef)
include(${PROJECT_SOURCE_DIR}/mtest/cmake.inc)

View file

@ -0,0 +1,235 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="1.24">
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
<page-layout>
<page-height>283.465</page-height>
<page-width>1190.55</page-width>
<page-margins type="even">
<left-margin>28.3465</left-margin>
<right-margin>1.9984e-14</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
<page-margins type="odd">
<left-margin>0</left-margin>
<right-margin>28.3465</right-margin>
<top-margin>0</top-margin>
<bottom-margin>0</bottom-margin>
</page-margins>
</page-layout>
<Spatium>1.764</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="copyright"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle"></metaTag>
<PageList>
<Page>
</Page>
</PageList>
<Part>
<Staff id="1">
<type>0</type>
<bracket type="1" span="2"/>
<barLineSpan>2</barLineSpan>
</Staff>
<Staff id="2">
<type>0</type>
<bracket type="-1" span="0"/>
<barLineSpan>0</barLineSpan>
<distOffset>1.00169</distOffset>
</Staff>
<trackName>Piano</trackName>
<Instrument>
<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 number="1">
<Clef>
<concertClefType>G</concertClefType>
<transposingClefType>G</transposingClefType>
</Clef>
<TimeSig>
<sigN>3</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Clef>
<concertClefType>F</concertClefType>
<transposingClefType>F</transposingClefType>
</Clef>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>48</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>50</pitch>
<tpc>16</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>52</pitch>
<tpc>18</tpc>
</Note>
</Chord>
</Measure>
<Measure number="2">
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>52</pitch>
<tpc>18</tpc>
</Note>
</Chord>
<Rest>
<durationType>half</durationType>
</Rest>
</Measure>
<Measure number="3">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="4">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="5">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="6">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="7">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
</Staff>
<Staff id="2">
<Measure number="1">
<Clef>
<concertClefType>F</concertClefType>
<transposingClefType>F</transposingClefType>
</Clef>
<TimeSig>
<sigN>3</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Clef>
<concertClefType>G</concertClefType>
<transposingClefType>G</transposingClefType>
</Clef>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>74</pitch>
<tpc>16</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>76</pitch>
<tpc>18</tpc>
</Note>
</Chord>
</Measure>
<Measure number="2">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="3">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="4">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="5">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="6">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="7">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
</Staff>
</Score>
</museScore>

View file

@ -0,0 +1,244 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="1.24">
<programVersion>2.0.0</programVersion>
<programRevision>Unknown</programRevision>
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Synthesizer>
</Synthesizer>
<Division>480</Division>
<Style>
<page-layout>
<page-height>283.465</page-height>
<page-width>1190.55</page-width>
<page-margins type="even">
<left-margin>28.3465</left-margin>
<right-margin>1.9984e-14</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
<page-margins type="odd">
<left-margin>0</left-margin>
<right-margin>28.3465</right-margin>
<top-margin>0</top-margin>
<bottom-margin>0</bottom-margin>
</page-margins>
</page-layout>
<Spatium>1.764</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="copyright"></metaTag>
<metaTag name="creationDate">2013-06-05</metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="platform">X11</metaTag>
<metaTag name="source"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle"></metaTag>
<PageList>
<Page>
<System>
</System>
</Page>
</PageList>
<Part>
<Staff id="1">
<type>0</type>
<bracket type="1" span="2"/>
<barLineSpan>2</barLineSpan>
</Staff>
<Staff id="2">
<type>0</type>
<bracket type="-1" span="0"/>
<barLineSpan>0</barLineSpan>
<distOffset>1.00169</distOffset>
</Staff>
<trackName>Piano</trackName>
<Instrument>
<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"/>
<synti>Fluid</synti>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<Measure number="1">
<Clef>
<concertClefType>G</concertClefType>
<transposingClefType>G</transposingClefType>
</Clef>
<TimeSig>
<sigN>3</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Clef>
<concertClefType>F</concertClefType>
<transposingClefType>F</transposingClefType>
</Clef>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>48</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>50</pitch>
<tpc>16</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>52</pitch>
<tpc>18</tpc>
</Note>
</Chord>
</Measure>
<Measure number="2">
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>52</pitch>
<tpc>18</tpc>
</Note>
</Chord>
<Rest>
<durationType>half</durationType>
</Rest>
</Measure>
<Measure number="3">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="4">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="5">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="6">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="7">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
</Staff>
<Staff id="2">
<Measure number="1">
<Clef>
<concertClefType>F</concertClefType>
<transposingClefType>F</transposingClefType>
</Clef>
<TimeSig>
<sigN>3</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Clef>
<concertClefType>G</concertClefType>
<transposingClefType>G</transposingClefType>
</Clef>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>74</pitch>
<tpc>16</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>76</pitch>
<tpc>18</tpc>
</Note>
</Chord>
</Measure>
<Measure number="2">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="3">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="4">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="5">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="6">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
<Measure number="7">
<Rest>
<durationType>measure</durationType>
<duration z="3" n="4"/>
</Rest>
</Measure>
</Staff>
</Score>
</museScore>

View file

@ -0,0 +1,59 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2012 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 <QtTest/QtTest>
#include "mtest/testutils.h"
#include "libmscore/score.h"
#include "libmscore/measure.h"
#include "libmscore/undo.h"
#define DIR QString("libmscore/clef/")
using namespace Ms;
//---------------------------------------------------------
// TestClef
//---------------------------------------------------------
class TestClef : public QObject, public MTest
{
Q_OBJECT
private slots:
void initTestCase();
void clef1();
};
//---------------------------------------------------------
// initTestCase
//---------------------------------------------------------
void TestClef::initTestCase()
{
initMTest();
}
//---------------------------------------------------------
// clef1
// two clefs at tick position zero
//---------------------------------------------------------
void TestClef::clef1()
{
Score* score = readScore(DIR + "clef-1.mscx");
QVERIFY(saveCompareScore(score, "clef-1.mscx", DIR + "clef-1-ref.mscx"));
delete score;
}
QTEST_MAIN(TestClef)
#include "tst_clef.moc"

View file

@ -0,0 +1,4 @@
#!/bin/bash
cp ../../../build.debug/mtest/libmscore/clef/clef-1.mscx clef-1-ref.mscx