MuseScore/libmscore/hook.cpp

84 lines
2.6 KiB
C++
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2002-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 "hook.h"
#include "sym.h"
#include "chord.h"
#include "stem.h"
#include "score.h"
2013-05-13 18:49:17 +02:00
namespace Ms {
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// Hook
//---------------------------------------------------------
Hook::Hook(Score* s)
: Symbol(s)
{
setFlag(ElementFlag::MOVABLE, false);
2015-06-01 10:41:24 +02:00
setZ(int(type()) * 100);
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// setHookType
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
void Hook::setHookType(int i)
2012-05-26 14:26:10 +02:00
{
_hookType = i;
2012-05-26 14:26:10 +02:00
switch(i) {
case 0: break;
2013-11-06 15:58:05 +01:00
case 1: setSym(SymId::flag8thUp); break;
case 2: setSym(SymId::flag16thUp); break;
case 3: setSym(SymId::flag32ndUp); break;
case 4: setSym(SymId::flag64thUp); break;
case 5: setSym(SymId::flag128thUp); break;
case 6: setSym(SymId::flag256thUp); break;
2013-11-07 19:58:42 +01:00
case 7: setSym(SymId::flag512thUp); break;
2013-11-06 15:58:05 +01:00
case -1: setSym(SymId::flag8thDown); break;
case -2: setSym(SymId::flag16thDown); break;
case -3: setSym(SymId::flag32ndDown); break;
case -4: setSym(SymId::flag64thDown); break;
case -5: setSym(SymId::flag128thDown); break;
case -6: setSym(SymId::flag256thDown); break;
2013-11-07 19:58:42 +01:00
case -7: setSym(SymId::flag512thDown); break;
2012-05-26 14:26:10 +02:00
default:
qDebug("no hook for subtype %d", i);
2012-05-26 14:26:10 +02:00
break;
}
}
//---------------------------------------------------------
// layout
//---------------------------------------------------------
void Hook::layout()
{
2013-11-11 15:11:28 +01:00
setbbox(symBbox(_sym));
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// draw
//---------------------------------------------------------
void Hook::draw(QPainter* painter) const
2013-05-13 18:49:17 +02:00
{
// hide if belonging to the second chord of a cross-measure pair
if (chord() && chord()->crossMeasure() == CrossMeasure::SECOND)
return;
Symbol::draw(painter);
2013-05-13 18:49:17 +02:00
}
}