Skip to content

Commit

Permalink
fix #267721, fix #268624: added iteration over all selected elements …
Browse files Browse the repository at this point in the history
…on preset click, changes resetClicked() to simply call valueChanged with second parameter (reset) =true
  • Loading branch information
lyrischesich committed Jan 19, 2018
1 parent 9d9cd89 commit 5182e79
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 47 deletions.
81 changes: 52 additions & 29 deletions mscore/inspector/inspectorBarline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,18 @@ void InspectorBarLine::setElement()

void InspectorBarLine::presetDefaultClicked()
{
BarLine* bl = toBarLine(inspector->element());
Score* score = bl->score();
Score* score = inspector->element()->score();
score->startCmd();

bl->undoResetProperty(P_ID::BARLINE_SPAN);
bl->undoResetProperty(P_ID::BARLINE_SPAN_FROM);
bl->undoResetProperty(P_ID::BARLINE_SPAN_TO);
BarLine* bl;
for (Element* e : *inspector->el()) {
if (e->isBarLine()) {
bl = toBarLine(e);
bl->undoResetProperty(P_ID::BARLINE_SPAN);
bl->undoResetProperty(P_ID::BARLINE_SPAN_FROM);
bl->undoResetProperty(P_ID::BARLINE_SPAN_TO);
}
}

score->endCmd();
}
Expand All @@ -144,13 +149,18 @@ void InspectorBarLine::presetDefaultClicked()

void InspectorBarLine::presetTick1Clicked()
{
BarLine* bl = toBarLine(inspector->element());
Score* score = bl->score();
Score* score = inspector->element()->score();
score->startCmd();

bl->undoChangeProperty(P_ID::BARLINE_SPAN, false);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_TICK1_FROM);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_TICK1_TO);
BarLine* bl;
for (Element* e : *inspector->el()) {
if (e->isBarLine()) {
bl = toBarLine(e);
bl->undoChangeProperty(P_ID::BARLINE_SPAN, false);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_TICK1_FROM);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_TICK1_TO);
}
}

score->endCmd();
}
Expand All @@ -161,13 +171,18 @@ void InspectorBarLine::presetTick1Clicked()

void InspectorBarLine::presetTick2Clicked()
{
BarLine* bl = toBarLine(inspector->element());
Score* score = bl->score();
Score* score = inspector->element()->score();
score->startCmd();

bl->undoChangeProperty(P_ID::BARLINE_SPAN, false);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_TICK2_FROM);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_TICK2_TO);
BarLine* bl;
for (Element* e : *inspector->el()) {
if (e->isBarLine()) {
bl = toBarLine(e);
bl->undoChangeProperty(P_ID::BARLINE_SPAN, false);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_TICK2_FROM);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_TICK2_TO);
}
}

score->endCmd();
}
Expand All @@ -178,15 +193,19 @@ void InspectorBarLine::presetTick2Clicked()

void InspectorBarLine::presetShort1Clicked()
{
BarLine* bl = toBarLine(inspector->element());
Score* score = bl->score();
Score* score = inspector->element()->score();
score->startCmd();

bl->undoChangeProperty(P_ID::BARLINE_SPAN, false);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_SHORT1_FROM);
int shortDelta = bl->staff() ? (bl->staff()->lines(bl->tick()) - 5) * 2 : 0;
bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_SHORT1_TO + shortDelta);

BarLine* bl;
for (Element* e : *inspector->el()) {
if (e->isBarLine()) {
bl = toBarLine(e);
bl->undoChangeProperty(P_ID::BARLINE_SPAN, false);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_SHORT1_FROM);
int shortDelta = bl->staff() ? (bl->staff()->lines(bl->tick()) - 5) * 2 : 0;
bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_SHORT1_TO + shortDelta);
}
}
score->endCmd();
}

Expand All @@ -196,15 +215,19 @@ void InspectorBarLine::presetShort1Clicked()

void InspectorBarLine::presetShort2Clicked()
{
BarLine* bl = toBarLine(inspector->element());
Score* score = bl->score();
Score* score = inspector->element()->score();
score->startCmd();

bl->undoChangeProperty(P_ID::BARLINE_SPAN, false);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_SHORT2_FROM);
int shortDelta = bl->staff() ? (bl->staff()->lines(bl->tick()) - 5) * 2 : 0;
bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_SHORT2_TO + shortDelta);

BarLine* bl;
for (Element* e : *inspector->el()) {
if (e->isBarLine()) {
bl = toBarLine(e);
bl->undoChangeProperty(P_ID::BARLINE_SPAN, false);
bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_SHORT2_FROM);
int shortDelta = bl->staff() ? (bl->staff()->lines(bl->tick()) - 5) * 2 : 0;
bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_SHORT2_TO + shortDelta);
}
}
score->endCmd();
}

Expand Down
27 changes: 9 additions & 18 deletions mscore/inspector/inspectorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,14 @@ void InspectorBase::valueChanged(int idx, bool reset)
else if (ps == PropertyFlags::STYLED)
ps = PropertyFlags::UNSTYLED;
QVariant val1 = e->getProperty(id);
if (val1 != val2 || (reset && ps != PropertyFlags::NOSTYLE))
if (reset) {
val2 = e->propertyDefault(id);
}
if (val2.isValid() && val1 != val2)
if (reset) {
val2 = e->propertyDefault(id);
setValue(ii, val2);
}
e->undoChangeProperty(id, val2, ps);
}
inspector->setInspectorEdit(true);
Expand All @@ -377,23 +384,7 @@ void InspectorBase::valueChanged(int idx, bool reset)

void InspectorBase::resetClicked(int i)
{
Element* e = inspector->element();
const InspectorItem& ii = iList[i];
P_ID id = ii.t;
for (int i = 0; i < ii.parent; ++i)
e = e->parent();
QVariant def = e->propertyDefault(id);
if (!def.isValid()) {
qDebug("default value not valid");
return;
}
Score* s = e->score();
s->startCmd();
e->undoResetProperty(id);
inspector->setInspectorEdit(true);
s->endCmd(); // this may remove element
inspector->setInspectorEdit(false);
inspector->update(s);
valueChanged(i, true);
}

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

0 comments on commit 5182e79

Please sign in to comment.