2012-05-26 14:49:10 +02:00
|
|
|
//=============================================================================
|
|
|
|
// MusE Score
|
|
|
|
// Linux Music Score Editor
|
|
|
|
// $Id: measureproperties.cpp 5628 2012-05-15 07:46:43Z wschweer $
|
|
|
|
//
|
|
|
|
// Copyright (C) 2007 Werner Schweer and others
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License version 2.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
#include "measureproperties.h"
|
|
|
|
#include "libmscore/measure.h"
|
|
|
|
#include "libmscore/sig.h"
|
|
|
|
#include "libmscore/score.h"
|
|
|
|
#include "libmscore/repeat.h"
|
|
|
|
#include "libmscore/undo.h"
|
2014-11-28 12:07:14 +01:00
|
|
|
#include "libmscore/range.h"
|
2016-09-26 20:44:20 +02:00
|
|
|
#include "musescore.h"
|
2012-05-26 14:49:10 +02:00
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
namespace Ms {
|
|
|
|
|
2012-05-26 14:49:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// MeasureProperties
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
MeasureProperties::MeasureProperties(Measure* _m, QWidget* parent)
|
|
|
|
: QDialog(parent)
|
|
|
|
{
|
2016-09-26 20:44:20 +02:00
|
|
|
setObjectName("MeasureProperties");
|
2012-05-26 14:49:10 +02:00
|
|
|
setupUi(this);
|
2013-02-07 13:10:46 +01:00
|
|
|
setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
2016-09-26 20:44:20 +02:00
|
|
|
|
2012-05-26 14:49:10 +02:00
|
|
|
setMeasure(_m);
|
|
|
|
staves->verticalHeader()->hide();
|
2016-09-26 20:44:20 +02:00
|
|
|
|
2012-05-26 14:49:10 +02:00
|
|
|
connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(bboxClicked(QAbstractButton*)));
|
|
|
|
connect(nextButton, SIGNAL(clicked()), SLOT(gotoNextMeasure()));
|
|
|
|
connect(previousButton, SIGNAL(clicked()), SLOT(gotoPreviousMeasure()));
|
2016-09-26 20:44:20 +02:00
|
|
|
|
2013-10-03 16:17:08 +02:00
|
|
|
nextButton->setEnabled(_m->nextMeasure() != 0);
|
|
|
|
previousButton->setEnabled(_m->prevMeasure() != 0);
|
2016-10-04 16:26:58 +02:00
|
|
|
if (qApp->layoutDirection() == Qt::LayoutDirection::RightToLeft) {
|
|
|
|
horizontalLayout_2->removeWidget(nextButton);
|
|
|
|
horizontalLayout_2->insertWidget(0, nextButton);
|
|
|
|
}
|
2016-09-26 20:44:20 +02:00
|
|
|
|
|
|
|
MuseScore::restoreGeometry(this);
|
2012-05-26 14:49:10 +02:00
|
|
|
}
|
|
|
|
|
2015-03-30 10:42:27 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// getNextMeasure
|
|
|
|
// skip multi measure rests
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Measure* getNextMeasure(Measure* m)
|
|
|
|
{
|
|
|
|
Measure* mm = m->nextMeasureMM();
|
|
|
|
while (mm && mm->isMMRest())
|
|
|
|
mm = mm->nextMeasureMM();
|
|
|
|
return mm;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// getPrevMeasure
|
|
|
|
// skip multi measure rests
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Measure* getPrevMeasure(Measure* m)
|
|
|
|
{
|
|
|
|
Measure* mm = m->prevMeasureMM();
|
|
|
|
while (mm && mm->isMMRest())
|
|
|
|
mm = mm->prevMeasureMM();
|
|
|
|
return mm;
|
|
|
|
}
|
|
|
|
|
2012-05-26 14:49:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// gotoNextMeasure
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void MeasureProperties::gotoNextMeasure()
|
|
|
|
{
|
2015-03-30 10:42:27 +02:00
|
|
|
if (getNextMeasure(m))
|
|
|
|
setMeasure(getNextMeasure(m));
|
|
|
|
nextButton->setEnabled(getNextMeasure(m));
|
|
|
|
previousButton->setEnabled(getPrevMeasure(m));
|
2016-04-18 18:11:51 +02:00
|
|
|
m->score()->update();
|
2012-05-26 14:49:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// gotoPreviousMeasure
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void MeasureProperties::gotoPreviousMeasure()
|
|
|
|
{
|
2015-03-30 10:42:27 +02:00
|
|
|
if (getPrevMeasure(m))
|
|
|
|
setMeasure(getPrevMeasure(m));
|
|
|
|
nextButton->setEnabled(getNextMeasure(m));
|
|
|
|
previousButton->setEnabled(getPrevMeasure(m));
|
2016-04-18 18:11:51 +02:00
|
|
|
m->score()->update();
|
2012-05-26 14:49:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// setMeasure
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void MeasureProperties::setMeasure(Measure* _m)
|
|
|
|
{
|
|
|
|
m = _m;
|
2017-03-28 18:54:29 +02:00
|
|
|
setWindowTitle(tr("Measure Properties for Measure %1").arg(m->no()+1));
|
2016-11-07 11:19:21 +01:00
|
|
|
m->score()->deselectAll();
|
2014-10-04 00:50:19 +02:00
|
|
|
m->score()->select(m, SelectType::ADD, 0);
|
|
|
|
|
2012-05-26 14:49:10 +02:00
|
|
|
actualZ->setValue(m->len().numerator());
|
2012-09-06 19:23:53 +02:00
|
|
|
int index = actualN->findText(QString::number(m->len().denominator()));
|
|
|
|
if (index == -1)
|
|
|
|
index = 2;
|
|
|
|
actualN->setCurrentIndex(index);
|
2012-05-26 14:49:10 +02:00
|
|
|
nominalZ->setNum(m->timesig().numerator());
|
|
|
|
nominalN->setNum(m->timesig().denominator());
|
|
|
|
|
|
|
|
irregular->setChecked(m->irregular());
|
2016-01-04 14:48:58 +01:00
|
|
|
breakMultiMeasureRest->setChecked(m->breakMultiMeasureRest());
|
2012-05-26 14:49:10 +02:00
|
|
|
int n = m->repeatCount();
|
|
|
|
count->setValue(n);
|
2016-02-04 11:27:47 +01:00
|
|
|
count->setEnabled(m->repeatEnd());
|
2012-05-26 14:49:10 +02:00
|
|
|
layoutStretch->setValue(m->userStretch());
|
2013-03-08 12:55:12 +01:00
|
|
|
measureNumberMode->setCurrentIndex(int(m->measureNumberMode()));
|
2012-05-26 14:49:10 +02:00
|
|
|
measureNumberOffset->setValue(m->noOffset());
|
|
|
|
|
|
|
|
Score* score = m->score();
|
|
|
|
int rows = score->nstaves();
|
|
|
|
staves->setRowCount(rows);
|
|
|
|
staves->setColumnCount(3);
|
|
|
|
|
|
|
|
for (int staffIdx = 0; staffIdx < rows; ++staffIdx) {
|
|
|
|
QTableWidgetItem* item = new QTableWidgetItem(QString("%1").arg(staffIdx+1));
|
|
|
|
staves->setItem(staffIdx, 0, item);
|
|
|
|
|
|
|
|
item = new QTableWidgetItem(tr("visible"));
|
|
|
|
item->setFlags(item->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
|
2016-12-12 14:55:35 +01:00
|
|
|
item->setCheckState(m->visible(staffIdx) ? Qt::Checked : Qt::Unchecked);
|
2012-05-26 14:49:10 +02:00
|
|
|
if (rows == 1) // cannot be invisible if only one row
|
|
|
|
item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
|
|
|
|
staves->setItem(staffIdx, 1, item);
|
|
|
|
|
|
|
|
item = new QTableWidgetItem(tr("stemless"));
|
|
|
|
item->setFlags(item->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
|
2016-12-12 14:55:35 +01:00
|
|
|
item->setCheckState(m->slashStyle(staffIdx) ? Qt::Checked : Qt::Unchecked);
|
2012-05-26 14:49:10 +02:00
|
|
|
staves->setItem(staffIdx, 2, item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// bboxClicked
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void MeasureProperties::bboxClicked(QAbstractButton* button)
|
|
|
|
{
|
|
|
|
QDialogButtonBox::ButtonRole br = buttonBox->buttonRole(button);
|
|
|
|
switch(br) {
|
|
|
|
case QDialogButtonBox::ApplyRole:
|
|
|
|
apply();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QDialogButtonBox::AcceptRole:
|
|
|
|
apply();
|
|
|
|
// fall through
|
|
|
|
|
|
|
|
case QDialogButtonBox::RejectRole:
|
|
|
|
close();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2014-03-25 13:33:47 +01:00
|
|
|
qDebug("EditStaff: unknown button %d", int(br));
|
2012-05-26 14:49:10 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// visible
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
bool MeasureProperties::visible(int staffIdx)
|
|
|
|
{
|
|
|
|
QTableWidgetItem* item = staves->item(staffIdx, 1);
|
|
|
|
return item->checkState() == Qt::Checked;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// slashStyle
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
bool MeasureProperties::slashStyle(int staffIdx)
|
|
|
|
{
|
|
|
|
QTableWidgetItem* item = staves->item(staffIdx, 2);
|
|
|
|
return item->checkState() == Qt::Checked;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// sig
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Fraction MeasureProperties::len() const
|
|
|
|
{
|
2012-09-06 19:23:53 +02:00
|
|
|
return Fraction(actualZ->value(), 1 << actualN->currentIndex());
|
2012-05-26 14:49:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// isIrregular
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
bool MeasureProperties::isIrregular() const
|
|
|
|
{
|
|
|
|
return irregular->isChecked();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// repeatCount
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
int MeasureProperties::repeatCount() const
|
|
|
|
{
|
|
|
|
return count->value();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// apply
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void MeasureProperties::apply()
|
|
|
|
{
|
|
|
|
Score* score = m->score();
|
|
|
|
|
|
|
|
for (int staffIdx = 0; staffIdx < score->nstaves(); ++staffIdx) {
|
|
|
|
bool v = visible(staffIdx);
|
|
|
|
bool s = slashStyle(staffIdx);
|
2016-12-12 14:55:35 +01:00
|
|
|
if (m->visible(staffIdx) != v || m->slashStyle(staffIdx) != s)
|
|
|
|
score->undo(new ChangeMStaffProperties(m, staffIdx, v, s));
|
2012-05-26 14:49:10 +02:00
|
|
|
}
|
2014-05-20 17:26:26 +02:00
|
|
|
|
2014-05-26 18:18:01 +02:00
|
|
|
m->undoChangeProperty(P_ID::REPEAT_COUNT, repeatCount());
|
|
|
|
m->undoChangeProperty(P_ID::BREAK_MMR, breakMultiMeasureRest->isChecked());
|
|
|
|
m->undoChangeProperty(P_ID::USER_STRETCH, layoutStretch->value());
|
|
|
|
m->undoChangeProperty(P_ID::MEASURE_NUMBER_MODE, measureNumberMode->currentIndex());
|
|
|
|
m->undoChangeProperty(P_ID::NO_OFFSET, measureNumberOffset->value());
|
|
|
|
m->undoChangeProperty(P_ID::IRREGULAR, isIrregular());
|
2014-05-20 17:26:26 +02:00
|
|
|
|
2014-11-28 12:07:14 +01:00
|
|
|
if (m->len() != len()) {
|
|
|
|
ScoreRange range;
|
|
|
|
range.read(m->first(), m->last());
|
2016-12-06 09:35:52 +01:00
|
|
|
m->adjustToLen(len());
|
|
|
|
#if 0
|
|
|
|
// handled by endCmd():
|
2014-11-28 12:07:14 +01:00
|
|
|
else if (!MScore::noGui) {
|
|
|
|
QMessageBox::warning(0,
|
|
|
|
QT_TRANSLATE_NOOP("MeasureProperties", "MuseScore"),
|
|
|
|
QT_TRANSLATE_NOOP("MeasureProperties", "cannot change measure length:\n"
|
|
|
|
"tuplet would cross measure")
|
|
|
|
);
|
|
|
|
}
|
2016-12-06 09:35:52 +01:00
|
|
|
#endif
|
2014-11-28 12:07:14 +01:00
|
|
|
}
|
2016-11-07 11:19:21 +01:00
|
|
|
score->select(m, SelectType::SINGLE, 0);
|
2014-10-04 00:50:19 +02:00
|
|
|
score->update();
|
2012-05-26 14:49:10 +02:00
|
|
|
}
|
2016-09-26 20:44:20 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// hideEvent
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void MeasureProperties::hideEvent(QHideEvent* event)
|
|
|
|
{
|
|
|
|
MuseScore::saveGeometry(this);
|
|
|
|
QWidget::hideEvent(event);
|
|
|
|
}
|
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
}
|
2012-05-26 14:49:10 +02:00
|
|
|
|