2012-05-26 14:26:10 +02:00
|
|
|
//=============================================================================
|
|
|
|
// 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"
|
2014-04-09 16:09:21 +02:00
|
|
|
#include "xml.h"
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
namespace Ms {
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
{
|
2013-09-05 16:37:49 +02:00
|
|
|
auto i = upper_bound(tick);
|
|
|
|
if (i != begin())
|
|
|
|
--i;
|
|
|
|
return i->second;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// setClef
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2013-09-05 16:37:49 +02:00
|
|
|
void ClefList::setClef(int tick, ClefTypeList ctl)
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
2013-09-05 16:37:49 +02:00
|
|
|
auto i = find(tick);
|
|
|
|
if (i == end())
|
|
|
|
insert(std::pair<int, ClefTypeList>(tick, ctl));
|
|
|
|
else
|
|
|
|
i->second = ctl;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// ClefList::read
|
2013-09-05 16:37:49 +02:00
|
|
|
// only used for 1.3 scores
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2013-01-11 18:10:18 +01:00
|
|
|
void ClefList::read(XmlReader& e, Score* cs)
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
2013-09-05 16:37:49 +02:00
|
|
|
clear();
|
2013-01-11 18:10:18 +01:00
|
|
|
while (e.readNextStartElement()) {
|
|
|
|
if (e.name() == "clef") {
|
|
|
|
int tick = e.intAttribute("tick", 0);
|
2012-05-26 14:26:10 +02:00
|
|
|
ClefType ct = Clef::clefType(e.attribute("idx", "0"));
|
2013-09-05 16:37:49 +02:00
|
|
|
insert(std::pair<int, ClefTypeList>(cs->fileDivision(tick), ClefTypeList(ct, ct)));
|
2013-01-17 12:56:14 +01:00
|
|
|
e.readNext();
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
else
|
2013-01-11 18:10:18 +01:00
|
|
|
e.unknown();
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
}
|
|
|
|
|