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
|
|
|
|
{
|
2014-05-08 17:59:24 +02:00
|
|
|
if (empty())
|
2014-08-14 14:29:35 +02:00
|
|
|
return ClefTypeList(ClefType::INVALID, ClefType::INVALID);
|
2013-09-05 16:37:49 +02:00
|
|
|
auto i = upper_bound(tick);
|
2014-05-08 17:59:24 +02:00
|
|
|
if (i == begin())
|
2014-08-14 14:29:35 +02:00
|
|
|
return ClefTypeList(ClefType::INVALID, ClefType::INVALID);
|
2014-05-08 17:59:24 +02:00
|
|
|
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
|
|
|
{
|
2014-07-25 17:13:27 +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
|
|
|
}
|
|
|
|
|
2016-10-25 17:30:55 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// nextClefTick
|
|
|
|
//
|
|
|
|
// return the tick at which the clef after tick is located
|
|
|
|
// return -1, if no such clef
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
int ClefList::nextClefTick(int tick) const
|
|
|
|
{
|
|
|
|
if (empty())
|
|
|
|
return -1;
|
|
|
|
auto i = upper_bound(tick+1);
|
|
|
|
if (i == end())
|
|
|
|
return -1;
|
|
|
|
return i->first;
|
|
|
|
}
|
2013-05-13 18:49:17 +02:00
|
|
|
}
|
|
|
|
|