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 "score.h"
|
|
|
|
#include "rehearsalmark.h"
|
2017-02-08 13:27:35 +01:00
|
|
|
#include "measure.h"
|
2017-06-02 11:59:32 +02:00
|
|
|
#include "system.h"
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
namespace Ms {
|
|
|
|
|
2018-08-01 11:46:07 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// rehearsalMarkStyle
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
static const ElementStyle rehearsalMarkStyle {
|
2018-09-25 13:18:45 +02:00
|
|
|
{ Sid::rehearsalMarkPlacement, Pid::PLACEMENT },
|
2019-05-06 20:41:21 +02:00
|
|
|
{ Sid::rehearsalMarkMinDistance, Pid::MIN_DISTANCE },
|
2018-08-01 11:46:07 +02:00
|
|
|
};
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// RehearsalMark
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
RehearsalMark::RehearsalMark(Score* s)
|
2018-08-01 11:46:07 +02:00
|
|
|
: TextBase(s, Tid::REHEARSAL_MARK)
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
2018-08-01 11:46:07 +02:00
|
|
|
initElementStyle(&rehearsalMarkStyle);
|
2017-12-27 11:51:00 +01:00
|
|
|
setSystemFlag(true);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
2016-06-03 16:51:17 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// layout
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2014-08-11 21:53:48 +02:00
|
|
|
void RehearsalMark::layout()
|
|
|
|
{
|
2018-10-18 11:53:01 +02:00
|
|
|
TextBase::layout();
|
2018-09-20 17:41:51 +02:00
|
|
|
|
2014-08-11 21:53:48 +02:00
|
|
|
Segment* s = segment();
|
2016-06-09 09:26:13 +02:00
|
|
|
if (s) {
|
2019-01-30 15:13:54 +01:00
|
|
|
if (s->rtick().isZero()) {
|
2019-04-14 23:55:36 +02:00
|
|
|
// first CR of measure, alignment is hcenter or right (the usual cases)
|
|
|
|
// align with barline, point just after header, or start of measure depending on context
|
|
|
|
|
|
|
|
Measure* m = s->measure();
|
|
|
|
Segment* header = s->prev(); // possibly just a start repeat
|
|
|
|
qreal measureX = -s->x();
|
|
|
|
Segment* repeat = m->findSegmentR(SegmentType::StartRepeatBarLine, Fraction(0, 1));
|
|
|
|
qreal barlineX = repeat ? repeat->x() - s->x() : measureX;
|
|
|
|
System* sys = m->system();
|
|
|
|
bool systemFirst = (sys && sys->firstMeasure() == m);
|
|
|
|
|
|
|
|
if (!header || repeat || !systemFirst) {
|
|
|
|
// no header, or header with repeat, or header mid-system - align with barline
|
|
|
|
rxpos() = barlineX;
|
2016-06-09 09:26:13 +02:00
|
|
|
}
|
2019-04-14 23:55:36 +02:00
|
|
|
else {
|
|
|
|
// header at start of system
|
|
|
|
// align to a point just after the header
|
|
|
|
Element* e = header->element(track()); // TODO: firstVisibleStaff
|
|
|
|
qreal w = e ? e->width() : header->width();
|
|
|
|
rxpos() = header->x() + w - s->x();
|
|
|
|
|
|
|
|
// special case for right aligned rehearsal marks at start of system
|
|
|
|
// left align with start of measure if that is further left
|
|
|
|
if (align() & Align::RIGHT)
|
|
|
|
rxpos() = qMin(rpos().x(), measureX + width());
|
2016-06-09 09:26:13 +02:00
|
|
|
}
|
2015-12-17 07:36:42 +01:00
|
|
|
}
|
2019-05-07 06:06:22 +02:00
|
|
|
autoplaceSegmentElement();
|
2014-08-11 21:53:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-16 20:51:12 +01:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// propertyDefault
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2018-03-27 15:36:00 +02:00
|
|
|
QVariant RehearsalMark::propertyDefault(Pid id) const
|
2017-01-16 20:51:12 +01:00
|
|
|
{
|
|
|
|
switch (id) {
|
2018-03-27 15:36:00 +02:00
|
|
|
case Pid::SUB_STYLE:
|
2018-08-01 11:46:07 +02:00
|
|
|
return int(Tid::REHEARSAL_MARK);
|
2018-03-27 15:36:00 +02:00
|
|
|
case Pid::PLACEMENT:
|
|
|
|
return score()->styleV(Sid::rehearsalMarkPlacement);
|
2017-01-16 20:51:12 +01:00
|
|
|
default:
|
2017-12-27 11:51:00 +01:00
|
|
|
return TextBase::propertyDefault(id);
|
2017-01-16 20:51:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-22 09:37:19 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// getPropertyStyle
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Sid RehearsalMark::getPropertyStyle(Pid pid) const
|
|
|
|
{
|
|
|
|
if (pid == Pid::OFFSET)
|
|
|
|
return placeAbove() ? Sid::rehearsalMarkPosAbove : Sid::rehearsalMarkPosBelow;
|
|
|
|
return TextBase::getPropertyStyle(pid);
|
|
|
|
}
|
|
|
|
|
2016-06-09 09:26:13 +02:00
|
|
|
} // namespace Ms
|
2013-05-13 18:49:17 +02:00
|
|
|
|