Skip to content

Commit

Permalink
Merge pull request #1848 from AntonioBL/bracket_type
Browse files Browse the repository at this point in the history
fix #22662 Dropping bracket onto existing one does not save correctly
  • Loading branch information
lasconic committed Mar 8, 2015
2 parents c764e58 + 3428515 commit 9617cf8
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 9 deletions.
11 changes: 2 additions & 9 deletions libmscore/bracket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,8 @@ Element* Bracket::drop(const DropData& data)
Element* e = data.element;
if (e->type() == Element::Type::BRACKET) {
Bracket* b = static_cast<Bracket*>(e);
b->setParent(parent());
b->setTrack(track());
b->setSpan(span());
b->setFirstStaff(firstStaff());
b->setLastStaff(lastStaff());
b->setLevel(level());
score()->undoRemoveElement(this);
score()->undoAddElement(b);
return b;
score()->undoChangeBracketType(this, b->bracketType());
return this;
}
delete e;
return 0;
Expand Down
1 change: 1 addition & 0 deletions libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ class Score : public QObject {
void undoInsertStaff(Staff* staff, int idx, bool createRests=true);
void undoChangeInvisible(Element*, bool);
void undoChangeBracketSpan(Staff* staff, int column, int span);
void undoChangeBracketType(Bracket* bracket, BracketType type);
void undoChangeTuning(Note*, qreal);
void undoChangePageFormat(PageFormat*);
void undoChangePageFormat(PageFormat*, qreal spatium, int);
Expand Down
1 change: 1 addition & 0 deletions libmscore/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ void System::layout(qreal xo1)
_brackets.append(b);
b->setFirstStaff(firstStaff);
b->setLastStaff(lastStaff);
b->setBracketType(s->bracket(i));
bracketWidth[i] = qMax(bracketWidth[i], b->width());
}
}
Expand Down
28 changes: 28 additions & 0 deletions libmscore/undo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,15 @@ void Score::undoChangeBracketSpan(Staff* staff, int column, int span)
undo(new ChangeBracketSpan(staff, column, span));
}

//---------------------------------------------------------
// undoChangeBracketType
//---------------------------------------------------------

void Score::undoChangeBracketType(Bracket* bracket, BracketType type)
{
undo(new ChangeBracketType(bracket, type));
}

//---------------------------------------------------------
// undoChangeInvisible
//---------------------------------------------------------
Expand Down Expand Up @@ -2344,6 +2353,25 @@ void ChangeBracketSpan::flip()
staff->score()->setLayoutAll(true);
}

//---------------------------------------------------------
// ChangeBracketType
//---------------------------------------------------------

ChangeBracketType::ChangeBracketType(Bracket* b, BracketType t)
{
bracket = b;
type = t;
}

void ChangeBracketType::flip()
{
BracketType oType = bracket->bracketType();
bracket->setBracketType(type);
type = oType;
bracket->staff()->setBracket(bracket->level(), bracket->bracketType());
bracket->staff()->score()->setLayoutAll(true);
}

//---------------------------------------------------------
// EditText::undo
//---------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions libmscore/undo.h
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,20 @@ class ChangeBracketSpan : public UndoCommand {
UNDO_NAME("ChangeBracketSpan")
};

//---------------------------------------------------------
// ChangeBracketType
//---------------------------------------------------------

class ChangeBracketType : public UndoCommand {
Bracket* bracket;
BracketType type;
void flip();

public:
ChangeBracketType(Bracket*, BracketType type);
UNDO_NAME("ChangeBracketType")
};

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

0 comments on commit 9617cf8

Please sign in to comment.