Skip to content

Commit

Permalink
fix #106726: Incorrect distance from barline to accidental
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Apr 18, 2016
1 parent a254f68 commit 94589cc
Show file tree
Hide file tree
Showing 23 changed files with 100 additions and 87 deletions.
14 changes: 9 additions & 5 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ void Score::startCmd()
// user-visible undo action.

if (undoStack()->active()) {
// if (MScore::debugMode)
qDebug("Score::startCmd(): cmd already active");
return;
}
Expand Down Expand Up @@ -175,7 +174,8 @@ void Score::endCmd(bool rollback)
masterScore()->_playlistDirty = true; // TODO: flag individual operations
masterScore()->_autosaveDirty = true;
}
MuseScoreCore::mscoreCore->endCmd();
// MuseScoreCore::mscoreCore->endCmd();
cmdState().reset();
}

//---------------------------------------------------------
Expand All @@ -189,16 +189,19 @@ void Score::update()
if (cs.layoutAll()) {
for (Score* s : scoreList())
s->doLayout();
cs._setUpdateMode(UpdateMode::UpdateAll);
}
else if (cs.layoutRange()) {
for (Score* s : scoreList())
s->doLayoutRange(cs.startTick(), cs.endTick());
cs._setUpdateMode(UpdateMode::UpdateAll);
}
if (cs.updateAll()) {
for (Score* s : scoreList()) {
for (MuseScoreView* v : s->viewer)
v->updateAll();
}
cs._setUpdateMode(UpdateMode::DoNothing);
}
else if (cs.updateRange()) {
// updateRange updates only current score
Expand Down Expand Up @@ -1726,11 +1729,12 @@ void Score::cmdResetBeamMode()

bool Score::processMidiInput()
{
if (MScore::debugMode)
qDebug("processMidiInput");
if (midiInputQueue().empty())
return false;

if (MScore::debugMode)
qDebug("processMidiInput");

bool cmdActive = false;
while (!midiInputQueue().empty()) {
MidiInputEvent ev = midiInputQueue().dequeue();
Expand All @@ -1746,7 +1750,7 @@ bool Score::processMidiInput()
if (p) {
if (!styleB(StyleIdx::concertPitch)) {
ev.pitch += p->instrument(selection().tickStart())->transpose().chromatic;
}
}
MScore::seq->startNote(
p->instrument()->channel(0)->channel,
ev.pitch,
Expand Down
10 changes: 8 additions & 2 deletions libmscore/excerpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,14 @@ void createExcerpt(Excerpt* excerpt)

void deleteExcerpt(Excerpt* excerpt)
{
Score* oscore = excerpt->oscore();
Score* partScore = excerpt->partScore();
MasterScore* oscore = excerpt->oscore();
Score* partScore = excerpt->partScore();

if (!partScore) {
qDebug("deleteExcerpt: no partScore");
return;
}

// unlink the staves in the excerpt
for (Staff* s : partScore->staves()) {
Staff* staff = nullptr;
Expand Down
15 changes: 12 additions & 3 deletions libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2069,8 +2069,9 @@ qreal Score::computeMinWidth(Segment* s, bool isFirstMeasureInSystem)
qreal keysigLeftMargin = styleP(StyleIdx::keysigLeftMargin);
qreal timesigLeftMargin = styleP(StyleIdx::timesigLeftMargin);

if (s->isChordRestType())
x += styleP(StyleIdx::barNoteDistance);
if (s->isChordRestType()) {
x = qMax(x + styleP(StyleIdx::minNoteDistance), styleP(StyleIdx::barNoteDistance));
}
else if (s->isClefType())
// x = qMax(x, clefLeftMargin);
x += styleP(StyleIdx::clefLeftMargin);
Expand Down Expand Up @@ -3122,7 +3123,8 @@ System* Score::collectSystem(LayoutContext& lc)
break;
}

if (lc.rangeLayout && lc.endTick <= lc.curMeasure->tick()) {
// if (lc.rangeLayout && lc.endTick <= lc.curMeasure->tick()) {
if (lc.rangeLayout && lc.endTick < lc.curMeasure->tick()) {
// TODO: we may check if another measure fits in this system
if (lc.curMeasure == lc.systemOldMeasure) {
lc.rangeDone = true;
Expand Down Expand Up @@ -3575,6 +3577,13 @@ bool Score::collectPage(LayoutContext& lc)

void Score::doLayout()
{
#if 0
static int mops= 0;

++mops;
if (mops == 1)
abort();
#endif

This comment has been minimized.

Copy link
@Jojo-Schmitz

Jojo-Schmitz Apr 18, 2016

Contributor

Left over debug code?

This comment has been minimized.

Copy link
@wschweer

wschweer Apr 18, 2016

Author Contributor

yes :-) to catch the n 'th call of doLayout()

qDebug();

if (_staves.empty() || first() == 0) {
Expand Down
2 changes: 1 addition & 1 deletion libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3008,7 +3008,7 @@ void Score::cmdSelectAll()
selectRange(first, 0);
selectRange(last, nstaves() - 1);
setUpdateAll();
end();
update();
}

//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ class CmdState {
void reset();
UpdateMode updateMode() const { return _updateMode; }
void setUpdateMode(UpdateMode m);
void _setUpdateMode(UpdateMode m) { _updateMode = m; }
bool layoutAll() const { return _updateMode == UpdateMode::LayoutAll; }
bool layoutRange() const { return _updateMode == UpdateMode::LayoutRange; }
bool updateAll() const { return int(_updateMode) >= int(UpdateMode::UpdateAll); }
Expand Down Expand Up @@ -654,7 +655,6 @@ class Score : public QObject, public ScoreElement {
void startCmd(); // start undoable command
void endCmd(bool rollback = false); // end undoable command
void update();
void end() { update(); }

void cmdRemoveTimeSig(TimeSig*);
void cmdAddTimeSig(Measure*, int staffIdx, TimeSig*, bool local);
Expand Down
4 changes: 2 additions & 2 deletions libmscore/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2431,7 +2431,7 @@ void Text::dragTo(const QPointF& p)
{
setCursor(p, QTextCursor::KeepAnchor);
score()->setUpdateAll();
score()->end();
score()->update();
}

//---------------------------------------------------------
Expand Down Expand Up @@ -2618,7 +2618,7 @@ void Text::paste()
score()->setUpdateAll();
if (type() == Element::Type::INSTRUMENT_NAME)
score()->setLayoutAll();
score()->end();
score()->update();
}

//---------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions mscore/debugger/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ void Debugger::layout()
{
if (!curElement)
return;
curElement->score()->doLayout();
curElement->score()->end();
curElement->score()->setLayoutAll();
curElement->score()->update();
mscore->endCmd();
}

Expand Down
14 changes: 7 additions & 7 deletions mscore/dragdrop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ void ScoreView::dragMoveEvent(QDragMoveEvent* event)
}

dragElement->scanElements(&pos, moveElement, false);
_score->end();
_score->update();
return;
}

Expand All @@ -426,7 +426,7 @@ void ScoreView::dragMoveEvent(QDragMoveEvent* event)
else
setDropTarget(0);
}
_score->end();
_score->update();
return;
}
QByteArray data;
Expand All @@ -440,12 +440,12 @@ void ScoreView::dragMoveEvent(QDragMoveEvent* event)
data = md->data(mimeStaffListFormat);
}
else {
_score->end();
_score->update();
return;
}
Element* el = elementAt(pos);
if (el == 0 || el->type() != Element::Type::MEASURE) {
_score->end();
_score->update();
return;
}
else if (etype == Element::Type::ELEMENT_LIST) {
Expand All @@ -454,7 +454,7 @@ void ScoreView::dragMoveEvent(QDragMoveEvent* event)
else if (etype == Element::Type::STAFF_LIST || etype == Element::Type::MEASURE_LIST) {
//TODO el->acceptDrop(this, pos, etype, e);
}
_score->end();
_score->update();
}

//---------------------------------------------------------
Expand Down Expand Up @@ -699,7 +699,7 @@ void ScoreView::dropEvent(QDropEvent* event)
QStringList sl = md->formats();
foreach(QString s, sl)
qDebug(" %s", qPrintable(s));
_score->end();
_score->update();
return;
}

Expand Down Expand Up @@ -744,7 +744,7 @@ void ScoreView::dragLeaveEvent(QDragLeaveEvent*)
_score->setUpdateAll();
delete dragElement;
dragElement = 0;
_score->end();
_score->update();
}
setDropTarget(0);
}
Expand Down
2 changes: 1 addition & 1 deletion mscore/dragelement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void ScoreView::startDrag()
foreach(Element* e, _score->selection().elements())
e->setStartDragPosition(e->userOff());
}
_score->end();
_score->update();
}

//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion mscore/drumroll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void DrumrollEditor::selectionChanged()
}
}
_score->setUpdateAll();
_score->end();
_score->update();
// _score->blockSignals(false);
}

Expand Down
12 changes: 6 additions & 6 deletions mscore/editelement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void ScoreView::startEdit(Element* e)
e = static_cast<TBox*>(e)->text();
editObject = e;
sm->postEvent(new CommandEvent("edit"));
_score->end();
_score->update();
}

//---------------------------------------------------------
Expand Down Expand Up @@ -80,7 +80,7 @@ void ScoreView::startEdit()
editObject->startEdit(this, data.startMove);
curGrip = Grip::NO_GRIP;
updateGrips();
_score->end();
_score->update();
}

//---------------------------------------------------------
Expand Down Expand Up @@ -121,7 +121,7 @@ void ScoreView::endEdit()
if (dragElement && (dragElement != editObject)) {
curElement = dragElement;
_score->select(curElement);
_score->end();
_score->update();
}
mscore->updateInspector();

Expand All @@ -146,7 +146,7 @@ bool ScoreView::editElementDragTransition(QMouseEvent* ev)
if (e && (e == editObject) && (editObject->isText())) {
if (editObject->mousePress(data.startMove, ev)) {
_score->addRefresh(editObject->canvasBoundingRect());
_score->end();
_score->update();
}
return true;
}
Expand All @@ -158,7 +158,7 @@ bool ScoreView::editElementDragTransition(QMouseEvent* ev)
curGrip = Grip(i);
data.curGrip = Grip(i);
updateGrips();
score()->end();
score()->update();
break;
}
}
Expand Down Expand Up @@ -219,7 +219,7 @@ void ScoreView::endDragEdit()
updateGrips();
_score->rebuildBspTree();
_score->addRefresh(editObject->canvasBoundingRect());
_score->end();
_score->update();
}

}
Expand Down
2 changes: 1 addition & 1 deletion mscore/exampleview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void ExampleView::dragMoveEvent(QDragMoveEvent* event)
if (!found)
setDropTarget(0);
dragElement->scanElements(&pos, moveElement, false);
_score->end();
_score->update();
return;
}

Expand Down
2 changes: 1 addition & 1 deletion mscore/excerptsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void MuseScore::startExcerptsDialog()
settings.setValue("pos", ed.pos());
settings.endGroup();
cs->setLayoutAll();
cs->end();
cs->update();
}

//---------------------------------------------------------
Expand Down
12 changes: 6 additions & 6 deletions mscore/fotomode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ void ScoreView::startFotomode()
curGrip = Grip::START;
updateGrips();
_score->addRefresh(_foto->abbox());
_score->end();
_score->update();
mscore->changeState(STATE_FOTO);
}

Expand All @@ -392,7 +392,7 @@ void ScoreView::stopFotomode()
void ScoreView::startFotoDrag()
{
_score->addRefresh(_foto->abbox());
_score->end();
_score->update();
grips = 0;
}

Expand Down Expand Up @@ -431,7 +431,7 @@ void ScoreView::endFotoDrag()
editObject = _foto;
updateGrips();
_score->setUpdateAll();
_score->end();
_score->update();
}

//---------------------------------------------------------
Expand All @@ -450,7 +450,7 @@ void ScoreView::doFotoDragEdit(QMouseEvent* ev)
_foto->editDrag(ed);
updateGrips();
data.startMove = p;
_score->end();
_score->update();
if (mscore->inspector())
mscore->inspector()->setElement(_foto);
}
Expand Down Expand Up @@ -493,7 +493,7 @@ bool ScoreView::fotoEditElementDragTransition(QMouseEvent* ev)
break;
}
updateGrips();
score()->end();
score()->update();
break;
}
}
Expand Down Expand Up @@ -547,7 +547,7 @@ void ScoreView::doDragFotoRect(QMouseEvent* ev)
score()->addRefresh(_foto->abbox());
data.startMove = p;
updateGrips();
_score->end();
_score->update();
if (mscore->inspector())
mscore->inspector()->setElement(_foto);
}
Expand Down
2 changes: 1 addition & 1 deletion mscore/inspector/inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ void InspectorRest::tupletClicked()
if (tuplet) {
rest->score()->select(tuplet);
inspector->setElement(tuplet);
rest->score()->end();
rest->score()->update();
}
}

Expand Down
4 changes: 2 additions & 2 deletions mscore/inspector/inspectorGroupElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void InspectorGroupElement::notesClicked()
}
}
inspector->setElements(nel);
score->end();
score->update();
}

//---------------------------------------------------------
Expand All @@ -152,7 +152,7 @@ void InspectorGroupElement::restsClicked()
}
}
inspector->setElements(nel);
score->end();
score->update();
}

}
Expand Down
Loading

0 comments on commit 94589cc

Please sign in to comment.