Skip to content

Commit

Permalink
Merge pull request #1304 from mgavioli/Bar_line_custom_span_and_gener…
Browse files Browse the repository at this point in the history
…ated_flags

Bar lines: Fix custom span and generated management.
  • Loading branch information
mgavioli committed Sep 15, 2014
2 parents 14952b1 + e7465e9 commit 3338af9
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 64 deletions.
26 changes: 18 additions & 8 deletions libmscore/barline.cpp
Expand Up @@ -532,12 +532,15 @@ bool BarLine::acceptDrop(const DropData& data) const
if (type == Element::Type::BAR_LINE) {
if (parent() && parent()->type() == Element::Type::SEGMENT)
return true;
/* system bar lines not currently modifiable
TODO : support for special system-initial bar line
if (parent() && parent()->type() == Element::Type::SYSTEM) {
BarLine* b = static_cast<BarLine*>(data.element);
return (b->barLineType() == BarLineType::BROKEN || b->barLineType() == BarLineType::DOTTED
|| b->barLineType() == BarLineType::NORMAL || b->barLineType() == BarLineType::DOUBLE
|| b->spanFrom() != 0 || b->spanTo() != DEFAULT_BARLINE_TO);
}
*/
}
else {
return (type == Element::Type::ARTICULATION
Expand Down Expand Up @@ -1079,14 +1082,16 @@ void BarLine::remove(Element* e)

void BarLine::updateCustomSpan()
{
// if barline belongs to a staff and any of the staff span params is different from barline's...
if (staff())
if (staff()->barLineSpan() != _span || staff()->barLineFrom() != _spanFrom || staff()->barLineTo() != _spanTo) {
_customSpan = true; // ...span is custom
return;
}
// system bar line span is internally managed: _customSpan can never be true
if (parent() && parent()->type() == Element::Type::SYSTEM) {
_customSpan = false;
return;
}
// span is custom if barline belongs to a staff and any of the staff span params is different from barline's
// if no staff or same span params as staff, span is not custom
_customSpan = false;
Staff* stf = staff();
_customSpan = stf && (stf->barLineSpan() != _span || stf->barLineFrom() != _spanFrom || stf->barLineTo() != _spanTo);
updateGenerated(!_customSpan);
}

//---------------------------------------------------------
Expand Down Expand Up @@ -1121,7 +1126,12 @@ void BarLine::updateCustomType()
break;
}
}
// if parent is not a segment, it can only be a system and NORMAL can be used as ref. type
// if parent is not a segment, it can only be a system and for systems
// bar line type is internally managed and _customSubtype can never be true
else {
_customSubtype = false;
return;
}
}
_customSubtype = (_barLineType != refType);
updateGenerated(!_customSubtype); // if _customSubType, _genereated is surely false
Expand Down
7 changes: 7 additions & 0 deletions libmscore/edit.cpp
Expand Up @@ -1506,6 +1506,13 @@ void Score::deleteItem(Element* el)
undoChangeEndBarLineType(m, BarLineType::NORMAL);
m->setEndBarLineGenerated(true);
}
// if bar line has custom span, reset to staff default
if (bl->customSpan() && bl->staff()) {
Staff* stf = bl->staff();
undoChangeProperty(bl, P_ID::BARLINE_SPAN, stf->barLineSpan());
undoChangeProperty(bl, P_ID::BARLINE_SPAN_FROM, stf->barLineFrom());
undoChangeProperty(bl, P_ID::BARLINE_SPAN_TO, stf->barLineTo());
}
}
}
}
Expand Down
11 changes: 8 additions & 3 deletions libmscore/measure.cpp
Expand Up @@ -150,6 +150,7 @@ Measure::Measure(Score* s)
_irregular = false;
_breakMultiMeasureRest = false;
_breakMMRest = false;
_endBarLineColor = MScore::defaultColor;
_endBarLineGenerated = true;
_endBarLineVisible = true;
_endBarLineType = BarLineType::NORMAL;
Expand Down Expand Up @@ -1826,16 +1827,20 @@ void Measure::read(XmlReader& e, int staffIdx)
else if (barLine->barLineType() == BarLineType::START_REPEAT && e.tick() == tick())
st = Segment::Type::StartRepeatBarLine;
else {
st = Segment::Type::EndBarLine;
}
segment = getSegment(st, e.tick()); // let the bar line know it belongs to a Segment,
segment->add(barLine); // before setting its flags
if (st == Segment::Type::EndBarLine) {
if (!barLine->customSubtype())
setEndBarLineType(barLine->barLineType(), false, true);
if (!barLine->customSpan()) {
Staff* staff = score()->staff(staffIdx);
barLine->setSpan(staff->barLineSpan());
barLine->setSpanFrom(staff->barLineFrom());
barLine->setSpanTo(staff->barLineTo());
}
st = Segment::Type::EndBarLine;
}
segment = getSegment(st, e.tick());
segment->add(barLine);
}
else if (tag == "Chord") {
Chord* chord = new Chord(score());
Expand Down
17 changes: 11 additions & 6 deletions libmscore/system.cpp
Expand Up @@ -1069,8 +1069,9 @@ qreal System::staffYpage(int staffIdx) const
void System::write(Xml& xml) const
{
xml.stag("System");
if (_barLine && !_barLine->generated())
_barLine->write(xml);
// bar line is always generated
// if (_barLine && !_barLine->generated())
// _barLine->write(xml);
xml.etag();
}

Expand All @@ -1084,10 +1085,14 @@ void System::read(XmlReader& e)
const QStringRef& tag(e.name());

if (tag == "BarLine") {
_barLine = new BarLine(score());
_barLine->read(e);
_barLine->setTrack(0);
_barLine->setParent(this);
// _barLine = new BarLine(score());
// _barLine->read(e);
// _barLine->setTrack(0);
// _barLine->setParent(this);
// read the bar line for backward compatibility, but ignore it
BarLine* bl = new BarLine(score());
bl->read(e);
delete bl;
}
else
e.unknown();
Expand Down
159 changes: 113 additions & 46 deletions mscore/debugger/barline.ui
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>105</height>
<height>144</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -17,7 +17,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
Expand All @@ -35,49 +44,32 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>8</number>
</property>
<property name="topMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>8</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="3">
<widget class="QSpinBox" name="span">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
<number>999999</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string notr="true"/>
</property>
<property name="text">
<string notr="true">SubType:</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignRight</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="subType">
<property name="readOnly">
Expand Down Expand Up @@ -107,7 +99,7 @@
<item row="0" column="2">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand All @@ -124,16 +116,38 @@
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>span</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="0" column="3">
<widget class="QSpinBox" name="span">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
<number>999999</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string notr="true">spanFrom:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>spanFrom</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="1" column="3">
<widget class="QSpinBox" name="spanFrom">
<property name="readOnly">
<bool>true</bool>
Expand All @@ -146,7 +160,34 @@
</property>
</widget>
</item>
<item row="1" column="3">
<item row="2" column="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string notr="true">spanTo:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>spanTo</cstring>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="customSubtype">
<property name="text">
<string>custom subtype</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="customSpan">
<property name="text">
<string>custom span</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QSpinBox" name="spanTo">
<property name="readOnly">
<bool>true</bool>
Expand All @@ -159,10 +200,28 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_4">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string notr="true"/>
</property>
<property name="text">
<string notr="true">spanTo:</string>
<string notr="true">subtype:</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>subType</cstring>
</property>
</widget>
</item>
Expand All @@ -173,6 +232,14 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>subType</tabstop>
<tabstop>span</tabstop>
<tabstop>spanFrom</tabstop>
<tabstop>spanTo</tabstop>
<tabstop>customSubtype</tabstop>
<tabstop>customSpan</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
2 changes: 2 additions & 0 deletions mscore/debugger/debugger.cpp
Expand Up @@ -1557,6 +1557,8 @@ void BarLineView::setElement(Element* e)
bl.span->setValue(barline->span());
bl.spanFrom->setValue(barline->spanFrom());
bl.spanTo->setValue(barline->spanTo());
bl.customSubtype->setChecked(barline->customSubtype());
bl.customSpan->setChecked(barline->customSpan());
}

//---------------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion mscore/inspector/inspector.cpp
Expand Up @@ -204,7 +204,10 @@ void Inspector::setElements(const QList<Element*>& l)
ie = new InspectorSlur(this);
break;
case Element::Type::BAR_LINE:
ie = new InspectorBarLine(this);
if (_element->isEditable())
ie = new InspectorBarLine(this);
else
ie = new InspectorEmpty(this);
break;
case Element::Type::JUMP:
ie = new InspectorJump(this);
Expand Down

0 comments on commit 3338af9

Please sign in to comment.