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)
|
|
|
|
{
|
2014-05-22 10:10:58 +02:00
|
|
|
setFlag(ElementFlag::MOVABLE, false);
|
2015-06-01 10:41:24 +02:00
|
|
|
setZ(int(type()) * 100);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2013-03-05 20:23:59 +01:00
|
|
|
// setHookType
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2013-03-05 20:23:59 +01:00
|
|
|
void Hook::setHookType(int i)
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
2013-03-05 20:23:59 +01: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:
|
2014-03-25 13:33:47 +01:00
|
|
|
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
|
|
|
}
|
2012-10-17 00:17:54 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// draw
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Hook::draw(QPainter* painter) const
|
2013-05-13 18:49:17 +02:00
|
|
|
{
|
2012-10-17 00:17:54 +02:00
|
|
|
// hide if belonging to the second chord of a cross-measure pair
|
2014-05-21 15:41:23 +02:00
|
|
|
if (chord() && chord()->crossMeasure() == CrossMeasure::SECOND)
|
2012-10-17 00:17:54 +02:00
|
|
|
return;
|
|
|
|
Symbol::draw(painter);
|
2013-05-13 18:49:17 +02:00
|
|
|
}
|
|
|
|
|
2012-10-17 00:17:54 +02:00
|
|
|
}
|