MuseScore/mscore/inspector/inspector.cpp

1169 lines
44 KiB
C++
Raw Normal View History

2012-05-26 14:49:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
// $Id:$
//
// 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 LICENSE.GPL
//=============================================================================
#include "inspector.h"
#include "inspectorBeam.h"
#include "inspectorImage.h"
2012-07-12 15:35:35 +02:00
#include "inspectorLasso.h"
2012-05-26 14:49:10 +02:00
#include "inspectorGroupElement.h"
2012-09-17 15:37:31 +02:00
#include "inspectorVolta.h"
2012-09-17 17:35:49 +02:00
#include "inspectorOttava.h"
2012-09-17 18:09:30 +02:00
#include "inspectorTrill.h"
#include "inspectorHairpin.h"
2013-05-02 16:12:17 +02:00
#include "inspectorTextLine.h"
2013-02-25 18:15:28 +01:00
#include "inspectorMarker.h"
#include "inspectorJump.h"
2013-02-28 15:06:54 +01:00
#include "inspectorGlissando.h"
2015-07-06 18:16:52 +02:00
#include "inspectorArpeggio.h"
2013-03-07 13:31:14 +01:00
#include "inspectorNote.h"
2013-11-25 12:17:12 +01:00
#include "inspectorAmbitus.h"
2015-01-15 14:50:50 +01:00
#include "inspectorFret.h"
#include "inspectorText.h"
2012-05-26 14:49:10 +02:00
#include "musescore.h"
#include "scoreview.h"
#include "bendproperties.h"
2012-05-26 14:49:10 +02:00
#include "libmscore/element.h"
#include "libmscore/score.h"
#include "libmscore/box.h"
#include "libmscore/undo.h"
#include "libmscore/spacer.h"
#include "libmscore/note.h"
#include "libmscore/chord.h"
#include "libmscore/segment.h"
#include "libmscore/rest.h"
#include "libmscore/beam.h"
#include "libmscore/clef.h"
#include "libmscore/notedot.h"
#include "libmscore/hook.h"
#include "libmscore/stem.h"
2012-07-27 18:35:37 +02:00
#include "libmscore/keysig.h"
#include "libmscore/barline.h"
#include "libmscore/staff.h"
#include "libmscore/measure.h"
2014-09-28 13:15:45 +02:00
#include "libmscore/tuplet.h"
#include "libmscore/bend.h"
#include "libmscore/tremolobar.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
//---------------------------------------------------------
// showInspector
//---------------------------------------------------------
void MuseScore::showInspector(bool visible)
{
QAction* a = getAction("inspector");
2014-08-29 19:18:39 +02:00
if (!_inspector) {
_inspector = new Inspector();
connect(_inspector, SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool)));
addDockWidget(Qt::RightDockWidgetArea, _inspector);
}
2014-08-29 19:18:39 +02:00
if (_inspector)
_inspector->setVisible(visible);
if (visible)
updateInspector();
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
// Inspector
//---------------------------------------------------------
Inspector::Inspector(QWidget* parent)
: QDockWidget(tr("Inspector"), parent)
{
setObjectName("inspector");
2013-05-13 18:49:17 +02:00
setAllowedAreas(Qt::DockWidgetAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea));
2013-03-07 13:31:14 +01:00
sa = new QScrollArea;
sa->setAccessibleName(tr("Inspector Subwindow"));
sa->setFrameShape(QFrame::NoFrame);
2013-03-11 11:36:29 +01:00
sa->setWidgetResizable(true);
2012-05-26 14:49:10 +02:00
setWidget(sa);
sa->setFocusPolicy(Qt::NoFocus);
2012-05-26 14:49:10 +02:00
_inspectorEdit = false;
ie = 0;
_element = 0;
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
// reset
//---------------------------------------------------------
void Inspector::reset()
{
if (ie)
ie->setElement();
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
// setElement
//---------------------------------------------------------
void Inspector::setElement(Element* e)
{
QList<Element*> el;
if (e)
el.append(e);
setElements(el);
}
2013-02-25 18:15:28 +01:00
//---------------------------------------------------------
// setElements
//---------------------------------------------------------
void Inspector::setElements(const QList<Element*>& l)
{
2013-03-13 12:19:27 +01:00
if (_inspectorEdit) // if within an inspector-originated edit
return;
Element* e = l.isEmpty() ? 0 : l[0];
if (e == 0 || _element == 0 || (_el != l)) {
_el = l;
2012-05-26 14:49:10 +02:00
ie = 0;
_element = e;
if (_element == 0)
2013-08-02 10:47:20 +02:00
ie = new InspectorEmpty(this);
bool sameTypes = true;
foreach(Element* ee, _el) {
if (_element->type() != ee->type())
sameTypes = false;
2014-09-23 18:07:32 +02:00
else {
// HACK:
if (ee->type() == Element::Type::NOTE
&& static_cast<Note*>(ee)->chord()->isGrace() != static_cast<Note*>(_element)->chord()->isGrace())
sameTypes = false;
}
}
if (!sameTypes)
ie = new InspectorGroupElement(this);
2013-08-02 10:47:20 +02:00
else if (_element) {
switch(_element->type()) {
case Element::Type::FBOX:
case Element::Type::VBOX:
ie = new InspectorVBox(this);
break;
case Element::Type::TBOX:
ie = new InspectorTBox(this);
break;
case Element::Type::HBOX:
ie = new InspectorHBox(this);
break;
case Element::Type::ARTICULATION:
ie = new InspectorArticulation(this);
break;
case Element::Type::SPACER:
ie = new InspectorSpacer(this);
break;
case Element::Type::NOTE:
ie = new InspectorNote(this);
break;
case Element::Type::ACCIDENTAL:
2013-03-12 11:18:25 +01:00
ie = new InspectorAccidental(this);
break;
case Element::Type::REST:
ie = new InspectorRest(this);
break;
case Element::Type::CLEF:
ie = new InspectorClef(this);
break;
case Element::Type::TIMESIG:
ie = new InspectorTimeSig(this);
break;
case Element::Type::KEYSIG:
ie = new InspectorKeySig(this);
break;
case Element::Type::TUPLET:
2013-03-11 14:15:42 +01:00
ie = new InspectorTuplet(this);
break;
case Element::Type::BEAM:
ie = new InspectorBeam(this);
break;
case Element::Type::IMAGE:
ie = new InspectorImage(this);
break;
case Element::Type::LASSO:
ie = new InspectorLasso(this);
break;
case Element::Type::VOLTA_SEGMENT:
ie = new InspectorVolta(this);
break;
case Element::Type::OTTAVA_SEGMENT:
ie = new InspectorOttava(this);
break;
case Element::Type::TRILL_SEGMENT:
ie = new InspectorTrill(this);
break;
case Element::Type::HAIRPIN_SEGMENT:
ie = new InspectorHairpin(this);
break;
case Element::Type::TEXTLINE_SEGMENT:
case Element::Type::PEDAL_SEGMENT:
2013-05-02 16:12:17 +02:00
ie = new InspectorTextLine(this);
break;
case Element::Type::SLUR_SEGMENT:
2013-07-01 16:57:44 +02:00
ie = new InspectorSlur(this);
break;
case Element::Type::BAR_LINE:
2016-02-09 13:51:19 +01:00
// if (_element->isEditable())
Bar lines: Fix custom span and generated management. This PR should complete the revision of bar line flag managements. - Make sure single bar line span changes affect both the `_customSpan` and the `_generated` flags. - Make sure that manually bringing a custom-spanned bar line to default span resets the `_customSpan` flag and, if no other customization is in effect. the `_generated` flag. - Deleting a measure bar line resets it to default configuration. - Fix a missing initialization of `Measure::_endBarLineColor` variable. - To simplify tests and debug, check boxes for the `BarLine::_customSpan` and the `BarLine::_customSubtype` have been added to the debugger dialogue box. As far as system-initial bar lines are concerned, they were made un-editable by a recent commit (https://github.com/musescore/MuseScore/pull/1300). This PR add a few consistency changes: - system-initial bar lines do not accept drops; - they are not saved to score output files and are ignored when reading from them; - their internal `_customSybtype` and _customSpan` flags are always false; - they do not show up in the Inspector (if a system bar line is selected, the Inspector remains blank) This PR DOES NOT include the special system-initial double bar management recently discussed. This will be part of a specific PR in the next days. Together with previous PR's, this should ensure that: - bar lines are written to a score output file only when some customization is in effect which cannot be reconstructed when reading back; - any measure bar line can be edited; - any measure bar line user edit is saved, written to the score file and read back properly; - no system bar line edit is possible.
2014-09-11 01:31:10 +02:00
ie = new InspectorBarLine(this);
2016-02-09 13:51:19 +01:00
// else
// ie = new InspectorEmpty(this);
break;
case Element::Type::JUMP:
ie = new InspectorJump(this);
break;
case Element::Type::MARKER:
ie = new InspectorMarker(this);
break;
case Element::Type::GLISSANDO:
2015-02-26 17:09:28 +01:00
case Element::Type::GLISSANDO_SEGMENT:
ie = new InspectorGlissando(this);
break;
case Element::Type::TEMPO_TEXT:
ie = new InspectorTempoText(this);
break;
case Element::Type::DYNAMIC:
ie = new InspectorDynamic(this);
break;
case Element::Type::AMBITUS:
2013-11-25 12:17:12 +01:00
ie = new InspectorAmbitus(this);
break;
2015-01-15 14:50:50 +01:00
case Element::Type::FRET_DIAGRAM:
2015-11-02 11:20:40 +01:00
ie = new InspectorFretDiagram(this);
2015-01-15 14:50:50 +01:00
break;
case Element::Type::LAYOUT_BREAK:
ie = new InspectorBreak(this);
break;
case Element::Type::BEND:
ie = new InspectorBend(this);
break;
case Element::Type::TREMOLOBAR:
ie = new InspectorTremoloBar(this);
break;
2015-07-06 18:16:52 +02:00
case Element::Type::ARPEGGIO:
ie = new InspectorArpeggio(this);
break;
default:
if (_element->isText()) {
if (_element->type() == Element::Type::INSTRUMENT_NAME) // these are generated
ie = new InspectorEmpty(this);
else
ie = new InspectorText(this);
}
else {
if (_element->type() == Element::Type::BRACKET) // these are generated
ie = new InspectorEmpty(this);
else
ie = new InspectorElement(this);
}
break;
}
2012-05-26 14:49:10 +02:00
}
2014-08-12 09:26:17 +02:00
QWidget* ww = sa->takeWidget();
if (ww)
ww->deleteLater();
2013-03-07 13:31:14 +01:00
sa->setWidget(ie);
//focus policies were set by hand in each inspector_*.ui. this code just helps keeping them like they are
//also fixes mac problem. on Mac Qt::TabFocus doesn't work, but Qt::StrongFocus works
QList<QWidget*> widgets = ie->findChildren<QWidget*>();
for (int i = 0; i < widgets.size(); i++) {
QWidget* currentWidget = widgets.at(i);
switch (currentWidget->focusPolicy()) {
case Qt::WheelFocus:
case Qt::StrongFocus:
2014-12-04 22:20:22 +01:00
if (currentWidget->inherits("QComboBox") ||
currentWidget->parent()->inherits("QAbstractSpinBox") ||
currentWidget->inherits("QAbstractSpinBox") ||
currentWidget->inherits("QLineEdit")) ; //leave it like it is
else
currentWidget->setFocusPolicy(Qt::TabFocus);
break;
case Qt::NoFocus:
case Qt::ClickFocus:
currentWidget->setFocusPolicy(Qt::NoFocus);
break;
2014-12-04 22:20:22 +01:00
case Qt::TabFocus:
break;
}
}
2012-05-26 14:49:10 +02:00
}
_element = e;
ie->setElement();
2012-05-26 14:49:10 +02:00
}
2013-07-22 16:21:19 +02:00
//---------------------------------------------------------
// setupUi
//---------------------------------------------------------
void UiInspectorElement::setupUi(QWidget *InspectorElement)
{
Ui::InspectorElement::setupUi(InspectorElement);
QAction* a = getAction("hraster");
a->setCheckable(true);
hRaster->setDefaultAction(a);
hRaster->setContextMenuPolicy(Qt::ActionsContextMenu);
hRaster->addAction(getAction("config-raster"));
a = getAction("vraster");
a->setCheckable(true);
vRaster->setDefaultAction(a);
vRaster->setContextMenuPolicy(Qt::ActionsContextMenu);
vRaster->addAction(getAction("config-raster"));
2013-07-22 16:21:19 +02:00
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// InspectorElement
//---------------------------------------------------------
InspectorElement::InspectorElement(QWidget* parent)
: InspectorBase(parent)
{
b.setupUi(addWidget());
2012-05-26 14:49:10 +02:00
iList = {
2014-05-26 18:18:01 +02:00
{ P_ID::COLOR, 0, 0, b.color, b.resetColor },
{ P_ID::VISIBLE, 0, 0, b.visible, b.resetVisible },
{ P_ID::USER_OFF, 0, 0, b.offsetX, b.resetX },
{ P_ID::USER_OFF, 1, 0, b.offsetY, b.resetY }
};
2012-05-26 14:49:10 +02:00
mapSignals();
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
// InspectorBreak
//---------------------------------------------------------
InspectorBreak::InspectorBreak(QWidget* parent)
: InspectorBase(parent)
{
b.setupUi(addWidget());
iList = { // currently empty
};
mapSignals();
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// InspectorVBox
//---------------------------------------------------------
InspectorVBox::InspectorVBox(QWidget* parent)
: InspectorBase(parent)
{
vb.setupUi(addWidget());
2012-05-26 14:49:10 +02:00
iList = {
2014-05-26 18:18:01 +02:00
{ P_ID::TOP_GAP, 0, 0, vb.topGap, vb.resetTopGap },
{ P_ID::BOTTOM_GAP, 0, 0, vb.bottomGap, vb.resetBottomGap },
{ P_ID::LEFT_MARGIN, 0, 0, vb.leftMargin, vb.resetLeftMargin },
{ P_ID::RIGHT_MARGIN, 0, 0, vb.rightMargin, vb.resetRightMargin },
{ P_ID::TOP_MARGIN, 0, 0, vb.topMargin, vb.resetTopMargin },
{ P_ID::BOTTOM_MARGIN, 0, 0, vb.bottomMargin, vb.resetBottomMargin },
{ P_ID::BOX_HEIGHT, 0, 0, vb.height, 0 }
};
2012-05-26 14:49:10 +02:00
mapSignals();
}
//---------------------------------------------------------
// InspectorTBox
//---------------------------------------------------------
InspectorTBox::InspectorTBox(QWidget* parent)
: InspectorBase(parent)
{
tb.setupUi(addWidget());
iList = {
{ P_ID::TOP_GAP, 0, 0, tb.topGap, tb.resetTopGap },
{ P_ID::BOTTOM_GAP, 0, 0, tb.bottomGap, tb.resetBottomGap },
{ P_ID::LEFT_MARGIN, 0, 0, tb.leftMargin, tb.resetLeftMargin },
{ P_ID::RIGHT_MARGIN, 0, 0, tb.rightMargin, tb.resetRightMargin },
{ P_ID::TOP_MARGIN, 0, 0, tb.topMargin, tb.resetTopMargin },
{ P_ID::BOTTOM_MARGIN, 0, 0, tb.bottomMargin, tb.resetBottomMargin },
};
mapSignals();
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// InspectorHBox
//---------------------------------------------------------
InspectorHBox::InspectorHBox(QWidget* parent)
: InspectorBase(parent)
{
hb.setupUi(addWidget());
2012-05-26 14:49:10 +02:00
iList = {
2014-05-26 18:18:01 +02:00
{ P_ID::TOP_GAP, 0, 0, hb.leftGap, hb.resetLeftGap },
{ P_ID::BOTTOM_GAP, 0, 0, hb.rightGap, hb.resetRightGap },
{ P_ID::BOX_WIDTH, 0, 0, hb.width, 0 }
};
2012-05-26 14:49:10 +02:00
mapSignals();
}
//---------------------------------------------------------
// InspectorArticulation
//---------------------------------------------------------
InspectorArticulation::InspectorArticulation(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
ar.setupUi(addWidget());
2012-05-26 14:49:10 +02:00
iList = {
2014-05-26 18:18:01 +02:00
{ P_ID::COLOR, 0, 0, e.color, e.resetColor },
{ P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_ID::ARTICULATION_ANCHOR, 0, 0, ar.anchor, ar.resetAnchor },
{ P_ID::DIRECTION, 0, 0, ar.direction, ar.resetDirection },
{ P_ID::TIME_STRETCH, 0, 0, ar.timeStretch, ar.resetTimeStretch },
{ P_ID::ORNAMENT_STYLE, 0, 0, ar.ornamentStyle, ar.resetOrnamentStyle },
{ P_ID::PLAY, 0, 0, ar.playArticulation, ar.resetPlayArticulation}
};
mapSignals();
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
// InspectorSpacer
//---------------------------------------------------------
InspectorSpacer::InspectorSpacer(QWidget* parent)
: InspectorBase(parent)
{
sp.setupUi(addWidget());
2012-05-26 14:49:10 +02:00
iList = {
2014-05-26 18:18:01 +02:00
{ P_ID::SPACE, 0, false, sp.height, sp.resetHeight }
};
mapSignals();
2012-05-26 14:49:10 +02:00
}
//---------------------------------------------------------
// InspectorRest
//---------------------------------------------------------
InspectorRest::InspectorRest(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
s.setupUi(addWidget());
r.setupUi(addWidget());
iList = {
2014-05-26 18:18:01 +02:00
{ P_ID::COLOR, 0, 0, e.color, e.resetColor },
{ P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_ID::SMALL, 0, 0, r.small, r.resetSmall },
{ P_ID::LEADING_SPACE, 0, 1, s.leadingSpace, s.resetLeadingSpace },
};
mapSignals();
2014-09-28 13:15:45 +02:00
//
// Select
//
QLabel* l = new QLabel;
l->setText(tr("Select"));
QFont font(l->font());
font.setBold(true);
l->setFont(font);
l->setAlignment(Qt::AlignHCenter);
_layout->addWidget(l);
QFrame* f = new QFrame;
f->setFrameStyle(QFrame::HLine | QFrame::Raised);
f->setLineWidth(2);
_layout->addWidget(f);
QHBoxLayout* hbox = new QHBoxLayout;
tuplet = new QToolButton(this);
tuplet->setText(tr("Tuplet"));
tuplet->setEnabled(false);
hbox->addWidget(tuplet);
_layout->addLayout(hbox);
e.offsetY->setSingleStep(1.0); // step in spatium units
2014-09-28 13:15:45 +02:00
connect(tuplet, SIGNAL(clicked()), SLOT(tupletClicked()));
}
//---------------------------------------------------------
// setElement
//---------------------------------------------------------
void InspectorRest::setElement()
{
Rest* rest = static_cast<Rest*>(inspector->element());
tuplet->setEnabled(rest->tuplet());
InspectorBase::setElement();
}
//---------------------------------------------------------
// tupletClicked
//---------------------------------------------------------
void InspectorRest::tupletClicked()
{
Rest* rest = static_cast<Rest*>(inspector->element());
if (rest == 0)
return;
Tuplet* tuplet = rest->tuplet();
if (tuplet) {
rest->score()->select(tuplet);
inspector->setElement(tuplet);
rest->score()->update();
2014-09-28 13:15:45 +02:00
}
2012-05-26 14:49:10 +02:00
}
2012-07-27 18:01:15 +02:00
//---------------------------------------------------------
// InspectorTimeSig
//---------------------------------------------------------
InspectorTimeSig::InspectorTimeSig(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
s.setupUi(addWidget());
t.setupUi(addWidget());
2012-07-27 18:01:15 +02:00
2013-03-06 20:45:10 +01:00
iList = {
2014-05-26 18:18:01 +02:00
{ P_ID::COLOR, 0, 0, e.color, e.resetColor },
{ P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_ID::LEADING_SPACE, 0, 1, s.leadingSpace, s.resetLeadingSpace },
{ P_ID::SHOW_COURTESY, 0, 0, t.showCourtesy, t.resetShowCourtesy },
// { P_ID::TIMESIG, 0, 0, t.timesigZ, t.resetTimesig },
// { P_ID::TIMESIG, 1, 0, t.timesigN, t.resetTimesig },
// { P_ID::TIMESIG_GLOBAL, 0, 0, t.globalTimesigZ, t.resetGlobalTimesig },
// { P_ID::TIMESIG_GLOBAL, 1, 0, t.globalTimesigN, t.resetGlobalTimesig }
2013-03-06 20:45:10 +01:00
};
mapSignals();
2012-07-27 18:01:15 +02:00
}
// InspectorTimeSig::setElement
void InspectorTimeSig::setElement()
{
InspectorBase::setElement();
TimeSig* ts = static_cast<TimeSig*>(inspector->element());
if (ts->generated())
t.showCourtesy->setEnabled(false);
}
2012-07-27 18:35:37 +02:00
//---------------------------------------------------------
// InspectorKeySig
//---------------------------------------------------------
InspectorKeySig::InspectorKeySig(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
s.setupUi(addWidget());
k.setupUi(addWidget());
2012-07-27 18:35:37 +02:00
2013-03-06 20:45:10 +01:00
iList = {
2014-05-26 18:18:01 +02:00
{ P_ID::COLOR, 0, 0, e.color, e.resetColor },
{ P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_ID::LEADING_SPACE, 0, 1, s.leadingSpace, s.resetLeadingSpace },
{ P_ID::SHOW_COURTESY, 0, 0, k.showCourtesy, k.resetShowCourtesy },
// { P_ID::SHOW_NATURALS, 0, 0, k.showNaturals, k.resetShowNaturals }
2013-03-06 20:45:10 +01:00
};
mapSignals();
2012-07-27 18:35:37 +02:00
}
// InspectorKeySig::setElement
void InspectorKeySig::setElement()
{
InspectorBase::setElement();
KeySig* ks = static_cast<KeySig*>(inspector->element());
if (ks->generated())
k.showCourtesy->setEnabled(false);
}
2013-03-11 14:15:42 +01:00
//---------------------------------------------------------
// InspectorTuplet
//---------------------------------------------------------
InspectorTuplet::InspectorTuplet(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
t.setupUi(addWidget());
iList = {
2014-05-26 18:18:01 +02:00
{ P_ID::COLOR, 0, 0, e.color, e.resetColor },
{ P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_ID::DIRECTION, 0, 0, t.direction, t.resetDirection },
{ P_ID::NUMBER_TYPE, 0, 0, t.numberType, t.resetNumberType },
{ P_ID::BRACKET_TYPE, 0, 0, t.bracketType, t.resetBracketType }
2013-03-11 14:15:42 +01:00
};
mapSignals();
}
2013-03-12 11:18:25 +01:00
//---------------------------------------------------------
// InspectorAccidental
//---------------------------------------------------------
InspectorAccidental::InspectorAccidental(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
a.setupUi(addWidget());
iList = {
2014-05-26 18:18:01 +02:00
{ P_ID::COLOR, 0, 0, e.color, e.resetColor },
{ P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_ID::SMALL, 0, 0, a.small, a.resetSmall }
2013-03-12 11:18:25 +01:00
};
mapSignals();
}
//---------------------------------------------------------
// InspectorBend
//---------------------------------------------------------
InspectorBend::InspectorBend(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
g.setupUi(addWidget());
iList = {
2015-07-07 20:33:31 +02:00
{ P_ID::COLOR, 0, 0, e.color, e.resetColor },
{ P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_ID::PLAY, 0, 0, g.playBend, g.resetPlayBend }
};
mapSignals();
connect(g.properties, SIGNAL(clicked()), SLOT(propertiesClicked()));
}
//---------------------------------------------------------
// propertiesClicked
//---------------------------------------------------------
void InspectorBend::propertiesClicked()
{
Bend* b = static_cast<Bend*>(inspector->element());
Score* score = b->score();
score->startCmd();
mscore->currentScoreView()->editBendProperties(b);
2016-03-02 13:20:19 +01:00
score->setLayoutAll();
score->endCmd();
}
//---------------------------------------------------------
// InspectorTremoloBar
//---------------------------------------------------------
InspectorTremoloBar::InspectorTremoloBar(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
g.setupUi(addWidget());
iList = {
{ P_ID::COLOR, 0, 0, e.color, e.resetColor },
{ P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY },
// { P_ID::PLAY, 0, 0, g.playBend, g.resetPlayBend }
{ P_ID::MAG, 0, 0, g.mag, g.resetMag }
};
mapSignals();
connect(g.properties, SIGNAL(clicked()), SLOT(propertiesClicked()));
}
//---------------------------------------------------------
// propertiesClicked
//---------------------------------------------------------
void InspectorTremoloBar::propertiesClicked()
{
Bend* b = static_cast<Bend*>(inspector->element());
Score* score = b->score();
score->startCmd();
mscore->currentScoreView()->editBendProperties(b);
2016-03-02 13:20:19 +01:00
score->setLayoutAll();
score->endCmd();
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// InspectorClef
//---------------------------------------------------------
InspectorClef::InspectorClef(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
s.setupUi(addWidget());
c.setupUi(addWidget());
iList = {
2014-05-26 18:18:01 +02:00
{ P_ID::COLOR, 0, 0, e.color, e.resetColor },
{ P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_ID::LEADING_SPACE, 0, 1, s.leadingSpace, s.resetLeadingSpace },
{ P_ID::SHOW_COURTESY, 0, 0, c.showCourtesy, c.resetShowCourtesy }
};
mapSignals();
2012-05-26 14:49:10 +02:00
}
// InspectorClef::setElement
void InspectorClef::setElement()
{
otherClef = nullptr; // no 'other clef' yet
InspectorBase::setElement();
// try to locate the 'other clef' of a courtesy / main pair
Clef* clef = static_cast<Clef*>(inspector->element());
// if not in a clef-segment-measure hierachy, do nothing
if (!clef->parent() || clef->parent()->type() != Element::Type::SEGMENT)
return;
Segment* segm = static_cast<Segment*>(clef->parent());
int segmTick = segm->tick();
if (!segm->parent() || segm->parent()->type() != Element::Type::MEASURE)
return;
Measure* meas = static_cast<Measure*>(segm->parent());
Measure* otherMeas = nullptr;
Segment* otherSegm = nullptr;
if (segmTick == meas->tick()) // if clef segm is measure-initial
otherMeas = meas->prevMeasure(); // look for a previous measure
else if (segmTick == meas->tick()+meas->ticks()) // if clef segm is measure-final
otherMeas = meas->nextMeasure(); // look for a next measure
// look for a clef segment in the 'other' measure at the same tick of this clef segment
if (otherMeas)
otherSegm = otherMeas->findSegment(Segment::Type::Clef, segmTick);
// if any 'other' segment found, look for a clef in the same track as this
if (otherSegm)
otherClef = static_cast<Clef*>(otherSegm->element(clef->track()));
}
// InspectorClef::valueChanged
void InspectorClef::valueChanged(int idx)
{
// copy into 'other clef' the ShowCouretsy ser of this clef
if (idx == 6 && otherClef)
otherClef->setShowCourtesy(c.showCourtesy->isChecked());
InspectorBase::valueChanged(idx);
}
2012-05-26 14:49:10 +02:00
//---------------------------------------------------------
// InspectorTempoText
//---------------------------------------------------------
InspectorTempoText::InspectorTempoText(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
t.setupUi(addWidget());
2014-04-18 06:59:30 +02:00
tt.setupUi(addWidget());
iList = {
2014-05-26 18:18:01 +02:00
{ P_ID::COLOR, 0, 0, e.color, e.resetColor },
{ P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_ID::TEXT_STYLE_TYPE, 0, 0, t.style, t.resetStyle },
{ P_ID::TEMPO, 0, 0, tt.tempo, tt.resetTempo },
{ P_ID::TEMPO_FOLLOW_TEXT, 0, 0, tt.followText, tt.resetFollowText }
};
mapSignals();
connect(t.resetToStyle, SIGNAL(clicked()), SLOT(resetToStyle()));
2014-04-18 06:59:30 +02:00
connect(tt.followText, SIGNAL(toggled(bool)), tt.tempo, SLOT(setDisabled(bool)));
}
//---------------------------------------------------------
// setElement
//---------------------------------------------------------
void InspectorTempoText::setElement()
{
Element* e = inspector->element();
Score* score = e->score();
t.style->blockSignals(true);
t.style->clear();
const QList<TextStyle>& ts = score->style()->textStyles();
int n = ts.size();
for (int i = 0; i < n; ++i) {
2014-06-18 12:05:41 +02:00
if (!(ts.at(i).hidden() & TextStyleHidden::IN_LISTS) )
t.style->addItem(qApp->translate("TextStyle",ts.at(i).name().toUtf8().data()), i);
2014-04-18 06:59:30 +02:00
}
t.style->blockSignals(false);
InspectorBase::setElement();
}
2013-07-22 16:21:19 +02:00
//---------------------------------------------------------
// postInit
//---------------------------------------------------------
void InspectorTempoText::postInit()
{
bool followText = tt.followText->isChecked();
//tt.resetFollowText->setDisabled(followText);
tt.tempo->setDisabled(followText);
tt.resetTempo->setDisabled(followText);
}
//---------------------------------------------------------
// InspectorDynamic
//---------------------------------------------------------
InspectorDynamic::InspectorDynamic(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
2013-07-22 16:21:19 +02:00
t.setupUi(addWidget());
d.setupUi(addWidget());
iList = {
2014-05-26 18:18:01 +02:00
{ P_ID::COLOR, 0, 0, e.color, e.resetColor },
{ P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_ID::TEXT_STYLE_TYPE, 0, 0, t.style, t.resetStyle },
{ P_ID::DYNAMIC_RANGE, 0, 0, d.dynRange, d.resetDynRange },
{ P_ID::VELOCITY, 0, 0, d.velocity, d.resetVelocity }
};
mapSignals();
connect(t.resetToStyle, SIGNAL(clicked()), SLOT(resetToStyle()));
}
//---------------------------------------------------------
2013-07-22 16:21:19 +02:00
// setElement
//---------------------------------------------------------
void InspectorDynamic::setElement()
{
Element* e = inspector->element();
Score* score = e->score();
t.style->blockSignals(true);
t.style->clear();
const QList<TextStyle>& ts = score->style()->textStyles();
int n = ts.size();
for (int i = 0; i < n; ++i) {
2014-06-18 12:05:41 +02:00
if (!(ts.at(i).hidden() & TextStyleHidden::IN_LISTS) )
t.style->addItem(qApp->translate("TextStyle",ts.at(i).name().toUtf8().data()), i);
2013-07-22 16:21:19 +02:00
}
t.style->blockSignals(false);
InspectorBase::setElement();
}
2013-07-01 16:57:44 +02:00
//---------------------------------------------------------
// InspectorSlur
//---------------------------------------------------------
InspectorSlur::InspectorSlur(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
s.setupUi(addWidget());
iList = {
{ P_ID::COLOR, 0, 0, e.color, e.resetColor },
{ P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY },
{ P_ID::LINE_TYPE, 0, 0, s.lineType, s.resetLineType },
{ P_ID::SLUR_DIRECTION, 0, 0, s.slurDirection, s.resetSlurDirection }
2013-07-01 16:57:44 +02:00
};
mapSignals();
}
2013-08-02 10:47:20 +02:00
//---------------------------------------------------------
// InspectorEmpty
//---------------------------------------------------------
InspectorEmpty::InspectorEmpty(QWidget* parent)
:InspectorBase(parent)
{
e.setupUi(addWidget());
2013-08-02 10:47:20 +02:00
}
2013-07-01 16:57:44 +02:00
//---------------------------------------------------------
// sizeHint
//---------------------------------------------------------
QSize InspectorEmpty::sizeHint() const
{
return QSize(255 * guiScaling, 170 * guiScaling);
}
2016-02-09 13:51:19 +01:00
static const BarLineType types[8] = {
BarLineType::NORMAL,
BarLineType::BROKEN,
BarLineType::DOTTED,
BarLineType::DOUBLE,
BarLineType::END,
BarLineType::START_REPEAT, // repeat types cannot be set for a single bar line
BarLineType::END_REPEAT, // of a multi-staff scores
BarLineType::END_START_REPEAT,
};
2014-03-24 11:50:26 +01:00
//---------------------------------------------------------
// InspectorBarLine
//---------------------------------------------------------
InspectorBarLine::InspectorBarLine(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
2016-01-04 14:48:58 +01:00
s.setupUi(addWidget());
2014-03-24 11:50:26 +01:00
b.setupUi(addWidget());
for (BarLineType t : types)
2015-02-25 11:54:31 +01:00
b.type->addItem(BarLine::userTypeName(t), int(t));
2014-03-24 11:50:26 +01:00
iList = {
2014-05-26 18:18:01 +02:00
{ P_ID::COLOR, 0, 0, e.color, e.resetColor },
{ P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible },
{ P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX },
{ P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY },
2016-01-04 14:48:58 +01:00
{ P_ID::LEADING_SPACE, 0, 1, s.leadingSpace, s.resetLeadingSpace },
2016-02-09 13:51:19 +01:00
{ P_ID::BARLINE_TYPE, 0, 0, b.type, b.resetType },
2014-05-26 18:18:01 +02:00
{ P_ID::BARLINE_SPAN, 0, 0, b.span, b.resetSpan },
{ P_ID::BARLINE_SPAN_FROM, 0, 0, b.spanFrom, b.resetSpanFrom },
{ P_ID::BARLINE_SPAN_TO, 0, 0, b.spanTo, b.resetSpanTo },
2014-03-24 11:50:26 +01:00
};
mapSignals();
// when any of the span parameters is changed, span data need to be managed
2016-02-09 13:51:19 +01:00
connect(b.span, SIGNAL(valueChanged(int)), SLOT(manageSpanData()));
connect(b.spanFrom, SIGNAL(valueChanged(int)), SLOT(manageSpanData()));
connect(b.spanTo, SIGNAL(valueChanged(int)), SLOT(manageSpanData()));
connect(b.presetDefault, SIGNAL(clicked()), SLOT(presetDefaultClicked()));
connect(b.presetTick1, SIGNAL(clicked()), SLOT(presetTick1Clicked()));
connect(b.presetTick2, SIGNAL(clicked()), SLOT(presetTick2Clicked()));
connect(b.presetShort1, SIGNAL(clicked()), SLOT(presetShort1Clicked()));
connect(b.presetShort2, SIGNAL(clicked()), SLOT(presetShort2Clicked()));
2014-03-24 11:50:26 +01:00
}
//---------------------------------------------------------
// setElement
//---------------------------------------------------------
#include <QStandardItem>
2014-03-24 11:50:26 +01:00
void InspectorBarLine::setElement()
{
blockSpanDataSignals(true);
2014-03-24 11:50:26 +01:00
InspectorBase::setElement();
BarLine* bl = static_cast<BarLine*>(inspector->element());
// enable / disable individual type combo items according to score and selected bar line status
bool bMultiStaff = bl->score()->nstaves() > 1;
BarLineType blt = bl->barLineType();
2016-02-09 13:51:19 +01:00
bool isRepeat = (blt == BarLineType::START_REPEAT
|| blt == BarLineType::END_REPEAT
|| blt == BarLineType::END_START_REPEAT);
const QStandardItemModel* model = qobject_cast<const QStandardItemModel*>(b.type->model());
2016-02-09 13:51:19 +01:00
for (unsigned i = 0; i < sizeof(types)/sizeof(*types); ++i) {
BarLineType type = types[i];
QStandardItem* item = model->item(i);
// if combo item is repeat type, should be disabled for multi-staff scores
if (type == BarLineType::START_REPEAT
|| type == BarLineType::END_REPEAT
|| type == BarLineType::END_START_REPEAT) {
// disable / enable
item->setFlags(bMultiStaff ?
item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) :
item->flags() | (Qt::ItemFlags)(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
}
// if combo item is NOT repeat type, should be disabled if selected bar line is a repeat
else {
2016-02-09 13:51:19 +01:00
item->setFlags(isRepeat ?
item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) :
item->flags() | (Qt::ItemFlags)(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
}
}
manageSpanData();
blockSpanDataSignals(false);
2014-03-24 11:50:26 +01:00
}
//---------------------------------------------------------
2016-02-09 13:51:19 +01:00
// presetDefaultClicked
2014-03-24 11:50:26 +01:00
//---------------------------------------------------------
2016-02-09 13:51:19 +01:00
void InspectorBarLine::presetDefaultClicked()
2014-03-24 11:50:26 +01:00
{
2016-02-09 13:51:19 +01:00
BarLine* bl = static_cast<BarLine*>(inspector->element());
Score* score = bl->score();
score->startCmd();
2016-02-09 13:51:19 +01:00
bl->undoResetProperty(P_ID::BARLINE_SPAN);
bl->undoResetProperty(P_ID::BARLINE_SPAN_FROM);
bl->undoResetProperty(P_ID::BARLINE_SPAN_TO);
2016-02-09 13:51:19 +01:00
score->endCmd();
mscore->endCmd();
}
//---------------------------------------------------------
// presetTick1Clicked
//---------------------------------------------------------
void InspectorBarLine::presetTick1Clicked()
{
BarLine* bl = static_cast<BarLine*>(inspector->element());
Score* score = bl->score();
score->startCmd();
bl->undoChangeProperty(P_ID::BARLINE_SPAN, 1);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_TICK1_FROM);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_TICK1_TO);
score->endCmd();
mscore->endCmd();
}
//---------------------------------------------------------
// presetTick2Clicked
//---------------------------------------------------------
void InspectorBarLine::presetTick2Clicked()
{
BarLine* bl = static_cast<BarLine*>(inspector->element());
Score* score = bl->score();
score->startCmd();
bl->undoChangeProperty(P_ID::BARLINE_SPAN, 1);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_TICK2_FROM);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_TICK2_TO);
score->endCmd();
mscore->endCmd();
}
//---------------------------------------------------------
// presetShort1Clicked
//---------------------------------------------------------
void InspectorBarLine::presetShort1Clicked()
{
BarLine* bl = static_cast<BarLine*>(inspector->element());
Score* score = bl->score();
score->startCmd();
bl->undoChangeProperty(P_ID::BARLINE_SPAN, 1);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_SHORT1_FROM);
int shortDelta = bl->staff() ? (bl->staff()->lines() - 5) * 2 : 0;
bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_SHORT1_TO + shortDelta);
score->endCmd();
mscore->endCmd();
}
//---------------------------------------------------------
// presetShort2Clicked
//---------------------------------------------------------
void InspectorBarLine::presetShort2Clicked()
{
BarLine* bl = static_cast<BarLine*>(inspector->element());
Score* score = bl->score();
score->startCmd();
bl->undoChangeProperty(P_ID::BARLINE_SPAN, 1);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_SHORT2_FROM);
int shortDelta = bl->staff() ? (bl->staff()->lines() - 5) * 2 : 0;
bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_SHORT2_TO + shortDelta);
score->endCmd();
mscore->endCmd();
2014-03-24 11:50:26 +01:00
}
//---------------------------------------------------------
// manageSpanData
//
// Makes sure span data are legal and consistent
//---------------------------------------------------------
void InspectorBarLine::manageSpanData()
{
BarLine* bl = static_cast<BarLine*>(inspector->element());
// determine MIN and MAX for SPANFROM and SPANTO
Staff* staffFrom = bl->staff();
Staff* staffTo = bl->score()->staff(bl->staffIdx() + bl->span() - 1);
int staffFromLines= (staffFrom ? staffFrom->lines() : 5);
int staffToLines = (staffTo ? staffTo->lines() : 5);
// From: min = minimum possible according to number of staff lines
// max = if same as To, at least 1sp (2 units) above To; if not, max possible according to num.of lines
2016-02-09 13:51:19 +01:00
int min = staffFromLines == 1 ? BARLINE_SPAN_1LINESTAFF_FROM : MIN_BARLINE_SPAN_FROMTO;
int max = bl->span() < 2 ? bl->spanTo() - MIN_BARLINE_FROMTO_DIST
: (staffFromLines == 1 ? BARLINE_SPAN_1LINESTAFF_TO : (staffFromLines-1) * 2 + 2);
b.spanFrom->setMinimum(min);
b.spanFrom->setMaximum(max);
b.spanFrom->setWrapping(false);
// To: min = if same as From, at least 1sp (2 units) below From; if not, min possible according to num.of lines
// max = max possible according to number of staff lines
min = bl->span() < 2 ? bl->spanFrom() + MIN_BARLINE_FROMTO_DIST
: (staffToLines == 1 ? BARLINE_SPAN_1LINESTAFF_FROM : MIN_BARLINE_SPAN_FROMTO);
2015-04-10 05:41:03 +02:00
max = staffToLines == 1 ? BARLINE_SPAN_1LINESTAFF_TO : (staffToLines-1) * 2 + 2;
2016-02-09 13:51:19 +01:00
b.spanTo->setMinimum(min);
b.spanTo->setMaximum(max);
b.spanTo->setWrapping(false);
// determin MAX for SPAN
max = bl->score()->nstaves() - bl->staffIdx();
b.span->setMaximum(max);
b.span->setWrapping(false);
2014-03-24 11:50:26 +01:00
}
//---------------------------------------------------------
// blockSpanDataSignals
//
// block/unblok signals for span value controls
//---------------------------------------------------------
void InspectorBarLine::blockSpanDataSignals(bool val)
{
b.span->blockSignals(val);
b.spanFrom->blockSignals(val);
b.spanTo->blockSignals(val);
}
2013-05-13 18:49:17 +02:00
}