Skip to content

Commit

Permalink
more inspector cleanups; add measure property Measure Number Mode to …
Browse files Browse the repository at this point in the history
…allow adding/removing measure numbers on top of style rules
  • Loading branch information
wschweer committed Mar 8, 2013
1 parent b7b1545 commit 8210fb8
Show file tree
Hide file tree
Showing 12 changed files with 340 additions and 264 deletions.
24 changes: 19 additions & 5 deletions libmscore/barline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ void BarLine::write(Xml& xml) const
{
xml.stag("BarLine");
xml.tag("subtype", barLineTypeName());
if(customSubtype())
if (_customSubtype)
xml.tag("customSubtype", _customSubtype);
// if any span value is different from staff's, output all values
if ( (staff() && ( _span != staff()->barLineSpan()
Expand Down Expand Up @@ -368,11 +368,11 @@ void BarLine::read(XmlReader& e)
if (parent() && parent()->type() == SEGMENT) {
Measure* m = static_cast<Segment*>(parent())->measure();
if (barLineType() != m->endBarLineType())
setCustomSubtype(true);
_customSubtype = true;
}
}
else if (tag == "customSubtype")
setCustomSubtype(e.readInt() != 0);
_customSubtype = e.readInt();
else if (tag == "span") {
_span = e.readInt();
_spanFrom = e.intAttribute("from", _spanFrom);
Expand Down Expand Up @@ -530,7 +530,7 @@ void BarLine::startEdit(MuseScoreView*, const QPointF&)

void BarLine::endEdit()
{
if(ctrlDrag) { // if single bar line edit
if (ctrlDrag) { // if single bar line edit
ctrlDrag = false;
_customSpan = true; // mark bar line as custom spanning
int newSpan = _span; // copy edited span values
Expand Down Expand Up @@ -920,6 +920,10 @@ QVariant BarLine::getProperty(P_ID id) const
return int(_barLineType);
case P_BARLINE_SPAN:
return span();
case P_BARLINE_SPAN_FROM:
return spanFrom();
case P_BARLINE_SPAN_TO:
return spanTo();
default:
break;
}
Expand All @@ -935,11 +939,17 @@ bool BarLine::setProperty(P_ID id, const QVariant& v)
switch(id) {
case P_SUBTYPE:
_barLineType = BarLineType(v.toInt());
setCustomSubtype(parent() && (static_cast<Segment*>(parent())->measure())->endBarLineType() != v.toInt());
_customSubtype = parent() && (static_cast<Segment*>(parent())->measure())->endBarLineType() != v.toInt();
break;
case P_BARLINE_SPAN:
setSpan(v.toInt());
break;
case P_BARLINE_SPAN_FROM:
setSpanFrom(v.toInt());
break;
case P_BARLINE_SPAN_TO:
setSpanTo(v.toInt());
break;
default:
return Element::setProperty(id, v);
}
Expand All @@ -958,6 +968,10 @@ QVariant BarLine::propertyDefault(P_ID propertyId) const
return false;
case P_BARLINE_SPAN:
return 1;
case P_BARLINE_SPAN_FROM:
return 0;
case P_BARLINE_SPAN_TO:
return DEFAULT_BARLINE_TO;
default:
break;
}
Expand Down
22 changes: 11 additions & 11 deletions libmscore/barline.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ class BarLine : public Element {

virtual bool acceptDrop(MuseScoreView*, const QPointF&, Element*) const;
virtual Element* drop(const DropData&);
void setCustomSpan(bool val) { _customSpan = val; }
void setCustomSpan(bool val) { _customSpan = val; }
void setCustomSubtype(bool val) { _customSubtype = val; }
void setSpan(int val) { _span = val; }
void setSpanFrom(int val) { _spanFrom = val; }
void setSpanTo(int val) { _spanTo = val; }
bool customSpan() const { return _customSpan; }
bool customSubtype() const { return _customSubtype;}
int span() const { return _span; }
int spanFrom() const { return _spanFrom; }
int spanTo() const { return _spanTo; }
void setSpan(int val) { _span = val; }
void setSpanFrom(int val) { _spanFrom = val; }
void setSpanTo(int val) { _spanTo = val; }
bool customSpan() const { return _customSpan; }
bool customSubtype() const { return _customSubtype;}
int span() const { return _span; }
int spanFrom() const { return _spanFrom; }
int spanTo() const { return _spanTo; }

virtual bool isEditable() const { return parent()->type() == SEGMENT; }
virtual void startEdit(MuseScoreView*, const QPointF&);
Expand All @@ -98,8 +98,8 @@ class BarLine : public Element {
virtual void updateGrips(int*, QRectF*) const;
int tick() const;

ElementList* el() { return &_el; }
const ElementList* el() const { return &_el; }
ElementList* el() { return &_el; }
const ElementList* el() const { return &_el; }

QString barLineTypeName() const;
void setBarLineType(const QString& s);
Expand Down
49 changes: 34 additions & 15 deletions libmscore/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Measure::Measure(Score* s)
_spannerBack = 0;
_no = 0;
_noOffset = 0;
_noMode = MeasureNumberMode::AUTO;
_noText = 0;
_userStretch = 1.0; // ::style->measureSpacing;
_irregular = false;
Expand Down Expand Up @@ -581,14 +582,20 @@ void Measure::layout2()
bool smn = false;

if (!_noText || _noText->generated()) {
if (score()->styleB(ST_showMeasureNumber)
&& !_irregular
&& (_no || score()->styleB(ST_showMeasureNumberOne))) {
if (score()->styleB(ST_measureNumberSystem))
smn = system()->firstMeasure() == this;
else {
smn = (_no == 0 && score()->styleB(ST_showMeasureNumberOne)) ||
( ((_no+1) % score()->style(ST_measureNumberInterval).toInt()) == 0 );
if (_noMode == MeasureNumberMode::SHOW)
smn = true;
else if (_noMode == MeasureNumberMode::HIDE)
smn = false;
else {
if (score()->styleB(ST_showMeasureNumber)
&& !_irregular
&& (_no || score()->styleB(ST_showMeasureNumberOne))) {
if (score()->styleB(ST_measureNumberSystem))
smn = system()->firstMeasure() == this;
else {
smn = (_no == 0 && score()->styleB(ST_showMeasureNumberOne)) ||
( ((_no+1) % score()->style(ST_measureNumberInterval).toInt()) == 0 );
}
}
}
if (smn) {
Expand Down Expand Up @@ -1897,7 +1904,6 @@ void Measure::read(XmlReader& e, int staffIdx)
else if (barLine->barLineType() == START_REPEAT)
segment = getSegment(Segment::SegStartRepeatBarLine, e.tick());
else {
// setEndBarLineType(barLine->barLineType(), false, barLine->visible(), barLine->color());
setEndBarLineType(barLine->barLineType(), false, true, Qt::black);
if(!barLine->customSpan()) {
Staff* staff = score()->staff(staffIdx);
Expand Down Expand Up @@ -2616,7 +2622,7 @@ bool Measure::createEndBarLines()
}
// if just finished (span==0) a multi-staff span (spanTot>1) ending at the top of a staff (spanTo<=0)
// scan this staff again, as it may have its own bar lines (mensurstich(-like) span)
if(spanTot > 1 && spanTo <= 0 && span == 0)
if (spanTot > 1 && spanTo <= 0 && span == 0)
staffIdx--;
}
return changed;
Expand Down Expand Up @@ -3676,13 +3682,12 @@ QVariant Measure::getProperty(P_ID propertyId) const
switch(propertyId) {
case P_TIMESIG_NOMINAL:
return QVariant::fromValue(_timesig);
break;
case P_TIMESIG_ACTUAL:
return QVariant::fromValue(_len);
break;
case P_REPEAT_FLAGS:
return repeatFlags();
break;
case P_MEASURE_NUMBER_MODE:
return int(measureNumberMode());
default:
return MeasureBase::getProperty(propertyId);
}
Expand All @@ -3704,6 +3709,9 @@ bool Measure::setProperty(P_ID propertyId, const QVariant& value)
case P_REPEAT_FLAGS:
setRepeatFlags(value.toInt());
break;
case P_MEASURE_NUMBER_MODE:
setMeasureNumberMode(MeasureNumberMode(value.toInt()));
break;
default:
return MeasureBase::setProperty(propertyId, value);
}
Expand All @@ -3714,9 +3722,20 @@ bool Measure::setProperty(P_ID propertyId, const QVariant& value)
// propertyDefault
//---------------------------------------------------------

QVariant Measure::propertyDefault(P_ID) const
QVariant Measure::propertyDefault(P_ID propertyId) const
{
return QVariant();
switch(propertyId) {
case P_TIMESIG_NOMINAL:
case P_TIMESIG_ACTUAL:
return QVariant();
case P_REPEAT_FLAGS:
return 0;
case P_MEASURE_NUMBER_MODE:
return int(MeasureNumberMode::AUTO);
default:
break;
}
return MeasureBase::getProperty(propertyId);
}

//---------------------------------------------------------
Expand Down
23 changes: 20 additions & 3 deletions libmscore/measure.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ enum {
RepeatJump = 8
};

//---------------------------------------------------------
// MeasureNumberMode
//---------------------------------------------------------

enum class MeasureNumberMode : char {
AUTO, // show measure number depending on style
SHOW, // always show measure number
HIDE // dont show measure number
};

//---------------------------------------------------------
// @@ Measure
/// one measure in a system
Expand All @@ -97,6 +107,7 @@ class Measure : public MeasureBase {

int _no; ///< Measure number, counting from zero
int _noOffset; ///< Offset to measure number
MeasureNumberMode _noMode;
Text* _noText; ///< Measure number text object

qreal _userStretch;
Expand All @@ -108,9 +119,10 @@ class Measure : public MeasureBase {
bool _breakMultiMeasureRest; ///< set by user
bool _breakMMRest; ///< set by layout

bool _endBarLineGenerated;
bool _endBarLineVisible;
BarLineType _endBarLineType;
bool _endBarLineGenerated;
bool _endBarLineVisible;
QColor _endBarLineColor;

BarLineType _mmEndBarLineType; ///< bar line type if this measure is presented
///< as multi measure rest
Expand All @@ -123,7 +135,6 @@ class Measure : public MeasureBase {
int _playbackCount; // temp. value used in RepeatList
// counts how many times this measure was already played

QColor _endBarLineColor;

void push_back(Segment* e);
void push_front(Segment* e);
Expand Down Expand Up @@ -161,6 +172,10 @@ class Measure : public MeasureBase {
void setIrregular(bool val) { _irregular = val; }
int noOffset() const { return _noOffset; }
Text* noText() const { return _noText; }

MeasureNumberMode measureNumberMode() const { return _noMode; }
void setMeasureNumberMode(MeasureNumberMode v) { _noMode = v; }

void setNo(int n) { _no = n; }
void setNoOffset(int n) { _noOffset = n; }
virtual qreal distanceUp(int i) const;
Expand Down Expand Up @@ -231,8 +246,10 @@ class Measure : public MeasureBase {
Segment* findSegment(Segment::SegmentType st, int t);

bool createEndBarLines();

void setEndBarLineType(BarLineType val, bool g, bool visible = true, QColor color = Qt::black);
BarLineType endBarLineType() const { return _endBarLineType; }

void setMmEndBarLineType(BarLineType v) { _mmEndBarLineType = v; }
bool setStartRepeatBarLine(bool);
bool endBarLineGenerated() const { return _endBarLineGenerated; }
Expand Down
12 changes: 9 additions & 3 deletions libmscore/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ static const PropertyData propertyList[] = {
{ P_DISTRIBUTE, false, "distribute", T_BOOL },
{ P_MIRROR_HEAD, false, "mirror", T_DIRECTION_H },
{ P_DOT_POSITION, false, "dotPosition", T_DIRECTION },
{ P_TUNING, false, "tuning", T_REAL },
{ P_PAUSE, false, "pause", T_REAL },
{ P_BARLINE_SPAN, false, "", T_INT },
{ P_TUNING, false, "tuning", T_REAL },
{ P_PAUSE, false, "pause", T_REAL },
{ P_BARLINE_SPAN, false, "", T_INT },
{ P_BARLINE_SPAN_FROM, false, 0, T_INT },
{ P_BARLINE_SPAN_TO, false, 0, T_INT },
{ P_USER_OFF, false, 0, T_POINT },
{ P_FRET, false, "fret", T_INT },

Expand Down Expand Up @@ -138,6 +140,10 @@ static const PropertyData propertyList[] = {
{ P_ARP_USER_LEN2, false, 0, T_REAL },

{ P_REPEAT_FLAGS, false, 0, T_INT },
{ P_END_BARLINE_TYPE, false, 0, T_INT },
{ P_END_BARLINE_VISIBLE, false, 0, T_BOOL },
{ P_END_BARLINE_COLOR, false, 0, T_COLOR },
{ P_MEASURE_NUMBER_MODE, false, 0, T_INT },

{ P_GLISS_TYPE, false, 0, T_INT },
{ P_GLISS_TEXT, false, 0, T_STRING },
Expand Down
8 changes: 8 additions & 0 deletions libmscore/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ enum P_ID {
P_TUNING,
P_PAUSE,
P_BARLINE_SPAN,
P_BARLINE_SPAN_FROM,
P_BARLINE_SPAN_TO,
P_USER_OFF,
P_FRET,
P_STRING,
Expand Down Expand Up @@ -126,7 +128,13 @@ enum P_ID {
P_MARKER_TYPE,
P_ARP_USER_LEN1,
P_ARP_USER_LEN2,

P_REPEAT_FLAGS,
P_END_BARLINE_TYPE,
P_END_BARLINE_VISIBLE,
P_END_BARLINE_COLOR,
P_MEASURE_NUMBER_MODE,

P_GLISS_TYPE,
P_GLISS_TEXT,
P_GLISS_SHOW_TEXT,
Expand Down
2 changes: 1 addition & 1 deletion libmscore/undo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1991,7 +1991,7 @@ void ChangeSingleBarLineSpan::flip()
spanTo = nspanTo;
barLine->layout(); // update bbox
// re-create bar lines for other staves, if span of this bar line decreased
if(barLine->parent() && barLine->parent()->type() == Element::SEGMENT)
if (barLine->parent() && barLine->parent()->type() == Element::SEGMENT)
(static_cast<Segment*>(barLine->parent()))->measure()->createEndBarLines();
barLine->score()->addRefresh(barLine->abbox()); // new area of this bar line needs redraw
}
Expand Down
Loading

0 comments on commit 8210fb8

Please sign in to comment.