Index: /home/mmg/Documents/Projects/musescore/mscore/mscore/mscore/undo.cpp =================================================================== --- /home/mmg/Documents/Projects/musescore/mscore/mscore/mscore/undo.cpp (revision 3714) +++ /home/mmg/Documents/Projects/musescore/mscore/mscore/mscore/undo.cpp (working copy) @@ -70,6 +70,7 @@ #include "excerpt.h" #include "tempotext.h" #include "instrchange.h" +#include "box.h" extern Measure* tick2measure(int tick); @@ -2835,5 +2836,54 @@ instrument = oi; } +//--------------------------------------------------------- +// ChangeBoxProperties +//--------------------------------------------------------- +ChangeBoxProperties::ChangeBoxProperties(Box * box, double marginLeft, double marginTop, double marginRight, + double marginBottom, double height, double width) +{ + _box = box; + _marginLeft = marginLeft; + _marginTop = marginTop; + _marginRight = marginRight; + _marginBottom = marginBottom; + _height = height; + _width = width; +}; +//--------------------------------------------------------- +// flip +//--------------------------------------------------------- + +void ChangeBoxProperties::flip() +{ // flip margins + double marginLeft = _box->leftMargin(); + double marginTop = _box->topMargin(); + double marginRight = _box->rightMargin(); + double marginBottom = _box->bottomMargin(); + + _box->setLeftMargin (_marginLeft); + _box->setRightMargin (_marginRight); + _box->setTopMargin (_marginTop); + _box->setBottomMargin(_marginBottom); + + _marginLeft = marginLeft; + _marginTop = marginTop; + _marginRight = marginRight; + _marginBottom = marginBottom; + + // according to box type, flip either height or width (or none) + double val; + if(_box->type() == VBOX) + { val = _box->boxHeight().val(); + _box->setBoxHeight(Spatium(_height)); + _height = val; + } + if(_box->type() == HBOX) + { val = _box->boxWidth().val(); + _box->setBoxWidth(Spatium(_width)); + _width = val; + } +} + Index: /home/mmg/Documents/Projects/musescore/mscore/mscore/mscore/boxproperties.ui =================================================================== --- /home/mmg/Documents/Projects/musescore/mscore/mscore/mscore/boxproperties.ui (revision 3714) +++ /home/mmg/Documents/Projects/musescore/mscore/mscore/mscore/boxproperties.ui (working copy) @@ -10,7 +10,7 @@ 0 0 508 - 210 + 226 @@ -43,7 +43,7 @@ Margins - false + true @@ -162,19 +162,68 @@ - - - - Qt::Vertical + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Size + + + + + + width: - - - 20 - 40 - + + + + + + false - + + sp + + + 999.000000000000000 + + + + + + height: + + + + + + + false + + + sp + + + 999.000000000000000 + + + @@ -194,6 +243,15 @@ + + leftMargin + topMargin + rightMargin + bottomMargin + frameWidth + frameHeight + dialogButtonBox + Index: /home/mmg/Documents/Projects/musescore/mscore/mscore/mscore/boxproperties.cpp =================================================================== --- /home/mmg/Documents/Projects/musescore/mscore/mscore/mscore/boxproperties.cpp (revision 3714) +++ /home/mmg/Documents/Projects/musescore/mscore/mscore/mscore/boxproperties.cpp (working copy) @@ -20,6 +20,8 @@ #include "boxproperties.h" #include "box.h" +#include "score.h" +#include "undo.h" //--------------------------------------------------------- // BoxProperties @@ -31,6 +33,17 @@ _box = b; setupUi(this); + if(b->type() == HBOX) + { // enable width and set it to box width + frameWidth->setEnabled(true); + frameWidth->setValue(b->boxWidth().val()); + } + if(b->type() == VBOX) + { // enable height and set it to box height + frameHeight->setEnabled(true); + frameHeight->setValue(b->boxHeight().val()); + } + leftMargin->setValue(b->leftMargin()); rightMargin->setValue(b->rightMargin()); topMargin->setValue(b->topMargin()); @@ -43,10 +56,21 @@ //--------------------------------------------------------- void BoxProperties::ok() +{ + Box * box; + Element * elem; + ElementType type; + + type = _box->type(); + // scan selection and update each element of the same type of this one + foreach(elem, _box->score()->selection().elements()) { - _box->setLeftMargin(leftMargin->value()); - _box->setRightMargin(rightMargin->value()); - _box->setTopMargin(topMargin->value()); - _box->setBottomMargin(bottomMargin->value()); + if(elem->type() == type) + { // if current element matches type of this box, push new box props in undo stack + box = static_cast(elem); + box->score()->undo()->push(new ChangeBoxProperties(box, leftMargin->value(), topMargin->value(), + rightMargin->value(), bottomMargin->value(), frameHeight->value(), frameWidth->value())); + } } +} Index: /home/mmg/Documents/Projects/musescore/mscore/mscore/mscore/undo.h =================================================================== --- /home/mmg/Documents/Projects/musescore/mscore/mscore/mscore/undo.h (revision 3714) +++ /home/mmg/Documents/Projects/musescore/mscore/mscore/mscore/undo.h (working copy) @@ -75,6 +75,7 @@ class NoteEvent; class SlurSegment; class InstrumentChange; +class Box; // #define DEBUG_UNDO @@ -1521,5 +1522,24 @@ extern void updateNoteLines(Segment* segment, int track); +//--------------------------------------------------------- +// ChangeBoxProperties +//--------------------------------------------------------- + +class ChangeBoxProperties : public UndoCommand { + Box* _box; + + double _marginLeft, _marginTop, _marginRight, _marginBottom; + double _height, _width; + + void flip(); + + public: + ChangeBoxProperties(Box *, double, double, double, double, double, double); + virtual void undo() { flip(); } + virtual void redo() { flip(); } + UNDO_NAME("ChangeBoxProperties"); + }; + #endif