MuseScore/libmscore/cleflist.cpp

83 lines
2.4 KiB
C++
Raw Normal View History

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())
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())
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
}
//---------------------------------------------------------
// 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
}