Skip to content

Commit

Permalink
remove many setLayoutAll() calls; cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Jun 14, 2016
1 parent 64034e6 commit 1a8cdf1
Show file tree
Hide file tree
Showing 32 changed files with 352 additions and 349 deletions.
3 changes: 1 addition & 2 deletions libmscore/accidental.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,7 @@ bool Accidental::setProperty(P_ID propertyId, const QVariant& v)
default:
return Element::setProperty(propertyId, v);
}
layout();
score()->setLayoutAll(); // spacing changes
triggerLayout();
return true;
}

Expand Down
31 changes: 16 additions & 15 deletions libmscore/ambitus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,7 @@ QVariant Ambitus::getProperty(P_ID propertyId) const

bool Ambitus::setProperty(P_ID propertyId, const QVariant& v)
{
bool rv = true;

score()->addRefresh(canvasBoundingRect());
switch(propertyId) {
switch (propertyId) {
case P_ID::HEAD_GROUP:
setNoteHeadGroup( NoteHead::Group(v.toInt()) );
break;
Expand Down Expand Up @@ -673,12 +670,10 @@ bool Ambitus::setProperty(P_ID propertyId, const QVariant& v)
setBottomPitch(bottomPitch() % 12 + v.toInt() * 12);
break;
default:
rv = Element::setProperty(propertyId, v);
break;
return Element::setProperty(propertyId, v);
}
if (rv)
score()->setLayoutAll();
return rv;
triggerLayout();
return true;
}

//---------------------------------------------------------
Expand All @@ -688,19 +683,25 @@ bool Ambitus::setProperty(P_ID propertyId, const QVariant& v)
QVariant Ambitus::propertyDefault(P_ID id) const
{
switch(id) {
case P_ID::HEAD_GROUP: return int(NOTEHEADGROUP_DEFAULT);
case P_ID::HEAD_TYPE: return int(NOTEHEADTYPE_DEFAULT);
case P_ID::MIRROR_HEAD: return int(DIR_DEFAULT);
case P_ID::GHOST: return HASLINE_DEFAULT;
case P_ID::LINE_WIDTH: return Spatium(LINEWIDTH_DEFAULT);
case P_ID::HEAD_GROUP:
return int(NOTEHEADGROUP_DEFAULT);
case P_ID::HEAD_TYPE:
return int(NOTEHEADTYPE_DEFAULT);
case P_ID::MIRROR_HEAD:
return int(DIR_DEFAULT);
case P_ID::GHOST:
return HASLINE_DEFAULT;
case P_ID::LINE_WIDTH:
return Spatium(LINEWIDTH_DEFAULT);
case P_ID::TPC1: // no defaults for pitches, tpc's and octaves
case P_ID::FBPARENTHESIS1:
case P_ID::PITCH:
case P_ID::FBPARENTHESIS2:
case P_ID::FBPARENTHESIS3:
case P_ID::FBPARENTHESIS4:
break;
default: return Element::propertyDefault(id);
default:
return Element::propertyDefault(id);
}
return QVariant();
}
Expand Down
2 changes: 1 addition & 1 deletion libmscore/arpeggio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ bool Arpeggio::setProperty(P_ID propertyId, const QVariant& val)
return false;
break;
}
score()->setLayoutAll();
triggerLayout();
return true;
}

Expand Down
23 changes: 1 addition & 22 deletions libmscore/articulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,17 +450,6 @@ Page* Articulation::page() const
return static_cast<Page*>(s ? s->parent() : 0);
}

//---------------------------------------------------------
// canvasBoundingRectChanged
//---------------------------------------------------------

void Articulation::canvasBoundingRectChanged()
{
Page* p = page();
if (p)
p->rebuildBspTree();
}

//---------------------------------------------------------
// subtypeUserName
//---------------------------------------------------------
Expand Down Expand Up @@ -543,7 +532,6 @@ QVariant Articulation::getProperty(P_ID propertyId) const

bool Articulation::setProperty(P_ID propertyId, const QVariant& v)
{
score()->addRefresh(canvasBoundingRect());
switch (propertyId) {
case P_ID::DIRECTION:
setDirection(v.value<Direction>());
Expand All @@ -565,16 +553,7 @@ bool Articulation::setProperty(P_ID propertyId, const QVariant& v)
default:
return Element::setProperty(propertyId, v);
}

// layout:
if (chordRest())
chordRest()->layoutArticulations();
else if (parent() && parent()->isBarLine())
toBarLine(parent())->layout();

score()->addRefresh(canvasBoundingRect());
score()->setLayoutAll(); // DEBUG
canvasBoundingRectChanged(); // rebuild bsp tree
triggerLayout();
return true;
}

Expand Down
1 change: 0 additions & 1 deletion libmscore/articulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ class Articulation : public Element {
Measure* measure() const;
System* system() const;
Page* page() const;
void canvasBoundingRectChanged();

static ArticulationInfo articulationList[];

Expand Down
2 changes: 1 addition & 1 deletion libmscore/barline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ bool BarLine::setProperty(P_ID id, const QVariant& v)
return Element::setProperty(id, v);
}
setGenerated(false);
score()->setLayoutAll();
triggerLayout();
return true;
}

Expand Down
15 changes: 13 additions & 2 deletions libmscore/beam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2229,8 +2229,19 @@ void Beam::endEdit()
{
Element::endEdit();
editFragment = -1;
// we need a full relayout to trigger stems to be redrawn
score()->setLayoutAll();
triggerLayout();
}

//---------------------------------------------------------
// triggerLayout
//---------------------------------------------------------

void Beam::triggerLayout() const
{
if (!_elements.empty()) {
_elements.front()->triggerLayout();
_elements.back()->triggerLayout();
}
}

//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions libmscore/beam.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class Beam : public Element {
bool isGrace() const { return _isGrace; } // for debugger
bool cross() const { return _cross; }
virtual Shape shape() const override;
virtual void triggerLayout() const override;
};


Expand Down
2 changes: 1 addition & 1 deletion libmscore/bend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ bool Bend::setProperty(P_ID propertyId, const QVariant& v)
default:
return Element::setProperty(propertyId, v);
}
score()->setLayoutAll();
triggerLayout();
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion libmscore/breath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ bool Breath::setProperty(P_ID propertyId, const QVariant& v)
return false;
break;
}
score()->setLayoutAll();
triggerLayout();
setGenerated(false);
return true;
}
Expand Down
4 changes: 1 addition & 3 deletions libmscore/chord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2632,19 +2632,17 @@ bool Chord::setProperty(P_ID propertyId, const QVariant& v)
switch (propertyId) {
case P_ID::NO_STEM:
setNoStem(v.toBool());
score()->setLayoutAll();
break;
case P_ID::SMALL:
setSmall(v.toBool());
score()->setLayoutAll();
break;
case P_ID::STEM_DIRECTION:
setStemDirection(v.value<Direction>());
score()->setLayoutAll();
break;
default:
return ChordRest::setProperty(propertyId, v);
}
triggerLayout();
return true;
}

Expand Down
44 changes: 26 additions & 18 deletions libmscore/chordrest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1241,9 +1241,15 @@ QVariant ChordRest::getProperty(P_ID propertyId) const
bool ChordRest::setProperty(P_ID propertyId, const QVariant& v)
{
switch (propertyId) {
case P_ID::SMALL: setSmall(v.toBool()); break;
case P_ID::BEAM_MODE: setBeamMode(Beam::Mode(v.toInt())); break;
case P_ID::STAFF_MOVE: setStaffMove(v.toInt()); break;
case P_ID::SMALL:
setSmall(v.toBool());
break;
case P_ID::BEAM_MODE:
setBeamMode(Beam::Mode(v.toInt()));
break;
case P_ID::STAFF_MOVE:
setStaffMove(v.toInt());
break;
case P_ID::VISIBLE:
setVisible(v.toBool());
measure()->checkMultiVoices(staffIdx());
Expand All @@ -1254,7 +1260,7 @@ bool ChordRest::setProperty(P_ID propertyId, const QVariant& v)
default:
return DurationElement::setProperty(propertyId, v);
}
score()->setLayoutAll();
triggerLayout();
return true;
}

Expand All @@ -1265,12 +1271,16 @@ bool ChordRest::setProperty(P_ID propertyId, const QVariant& v)
QVariant ChordRest::propertyDefault(P_ID propertyId) const
{
switch (propertyId) {
case P_ID::SMALL: return false;
case P_ID::BEAM_MODE: return int(Beam::Mode::AUTO);
case P_ID::STAFF_MOVE: return 0;
default: return DurationElement::propertyDefault(propertyId);
case P_ID::SMALL:
return false;
case P_ID::BEAM_MODE:
return int(Beam::Mode::AUTO);
case P_ID::STAFF_MOVE:
return 0;
default:
return DurationElement::propertyDefault(propertyId);
}
score()->setLayoutAll();
triggerLayout();
}

//---------------------------------------------------------
Expand All @@ -1279,7 +1289,7 @@ QVariant ChordRest::propertyDefault(P_ID propertyId) const

bool ChordRest::isGrace() const
{
return type() == Element::Type::CHORD && ((Chord*)this)->noteType() != NoteType::NORMAL;
return isChord() && toChord(this)->noteType() != NoteType::NORMAL;
}

//---------------------------------------------------------
Expand All @@ -1288,11 +1298,10 @@ bool ChordRest::isGrace() const

bool ChordRest::isGraceBefore() const
{
return (type() == Element::Type::CHORD && (((Chord*)this)->noteType() == NoteType::ACCIACCATURA
|| ((Chord*)this)->noteType() == NoteType::APPOGGIATURA
|| ((Chord*)this)->noteType() == NoteType::GRACE4
|| ((Chord*)this)->noteType() == NoteType::GRACE16
|| ((Chord*)this)->noteType() == NoteType::GRACE32));
return isChord()
&& (toChord(this)->noteType() & (
NoteType::ACCIACCATURA | NoteType::APPOGGIATURA | NoteType::GRACE4 | NoteType::GRACE16 | NoteType::GRACE32
));
}

//---------------------------------------------------------
Expand All @@ -1301,9 +1310,8 @@ bool ChordRest::isGraceBefore() const

bool ChordRest::isGraceAfter() const
{
return (type() == Element::Type::CHORD && (((Chord*)this)->noteType() == NoteType::GRACE8_AFTER
|| ((Chord*)this)->noteType() == NoteType::GRACE16_AFTER
|| ((Chord*)this)->noteType() == NoteType::GRACE32_AFTER));
return isChord()
&& (toChord(this)->noteType() & (NoteType::GRACE8_AFTER | NoteType::GRACE16_AFTER | NoteType::GRACE32_AFTER));
}

//---------------------------------------------------------
Expand Down
Loading

0 comments on commit 1a8cdf1

Please sign in to comment.