93e31dc04c
When a staff type change is undone, the previous staff clef is not restored, if it has been changed to suit the new staff type. Fixed by storing the original initial clef and restoring it on undo. Should fix the following issues: #18869, #23374, #24294 and, possibly others too. - Added to ChangeStaffType class an initialClef member variable to hold the original staff initial clef type list. - ChangeStaffType::flip() split into undo() and redo(), as the managing the clef and setting the staff type must be applied in reversed order in the two cases. - Clef::layout() now hides a clef not compatible with the staff group, if the clef is not generated or changes it to the same clef as the staff initial clef if generated - TAB ad-hoc code in Clef::layout() to check for compatibility between the clef type and the staff group generalized to all groups removed. - Fixed GuitarPro test reference scores, which all contained wrong clefs for the TAB staves. Tested with a few 2.0 and 1.3 scores; more tests are probably necessary.
91 lines
2.7 KiB
C++
91 lines
2.7 KiB
C++
//=============================================================================
|
|
// 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 LICENCE.GPL
|
|
//=============================================================================
|
|
|
|
#include "cleflist.h"
|
|
#include "clef.h"
|
|
#include "score.h"
|
|
#include "xml.h"
|
|
|
|
namespace Ms {
|
|
|
|
//---------------------------------------------------------
|
|
// ClefTypeList::operator==
|
|
//---------------------------------------------------------
|
|
|
|
bool ClefTypeList::operator==(const ClefTypeList& t) const
|
|
{
|
|
return t._concertClef == _concertClef && t._transposingClef == _transposingClef;
|
|
}
|
|
|
|
//---------------------------------------------------------
|
|
// ClefTypeList::operator!=
|
|
//---------------------------------------------------------
|
|
|
|
bool ClefTypeList::operator!=(const ClefTypeList& t) const
|
|
{
|
|
return t._concertClef != _concertClef || t._transposingClef != _transposingClef;
|
|
}
|
|
|
|
//---------------------------------------------------------
|
|
// clef
|
|
//---------------------------------------------------------
|
|
|
|
ClefTypeList ClefList::clef(int tick) const
|
|
{
|
|
if (empty())
|
|
return ClefTypeList();
|
|
auto i = upper_bound(tick);
|
|
if (i == begin())
|
|
return ClefTypeList();
|
|
return (--i)->second;
|
|
}
|
|
|
|
//---------------------------------------------------------
|
|
// setClef
|
|
//---------------------------------------------------------
|
|
|
|
void ClefList::setClef(int tick, ClefTypeList ctl)
|
|
{
|
|
if (clef(tick) == ctl)
|
|
return;
|
|
if (tick > 0 && clef(tick-1) == ctl)
|
|
erase(tick);
|
|
else {
|
|
auto i = find(tick);
|
|
if (i == end())
|
|
insert(std::pair<int, ClefTypeList>(tick, ctl));
|
|
else
|
|
i->second = ctl;
|
|
}
|
|
}
|
|
|
|
//---------------------------------------------------------
|
|
// ClefList::read
|
|
// only used for 1.3 scores
|
|
//---------------------------------------------------------
|
|
|
|
void ClefList::read(XmlReader& e, Score* cs)
|
|
{
|
|
clear();
|
|
while (e.readNextStartElement()) {
|
|
if (e.name() == "clef") {
|
|
int tick = e.intAttribute("tick", 0);
|
|
ClefType ct = Clef::clefType(e.attribute("idx", "0"));
|
|
insert(std::pair<int, ClefTypeList>(cs->fileDivision(tick), ClefTypeList(ct, ct)));
|
|
e.readNext();
|
|
}
|
|
else
|
|
e.unknown();
|
|
}
|
|
}
|
|
}
|
|
|