Skip to content

Commit

Permalink
implement vertical page orientation; enable properties for Score
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Oct 1, 2015
1 parent 643cefc commit e342fda
Show file tree
Hide file tree
Showing 17 changed files with 247 additions and 176 deletions.
14 changes: 11 additions & 3 deletions libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3268,10 +3268,18 @@ Page* Score::getEmptyPage()
Page* page = curPage >= _pages.size() ? addPage() : _pages[curPage];
page->setNo(curPage);
page->layout();
qreal x = (curPage == 0) ? 0.0 : _pages[curPage - 1]->pos().x()
+ page->width() + (((curPage+_pageNumberOffset) & 1) ? 50.0 : 1.0);
qreal x, y;
if (MScore::verticalOrientation()) {
x = 0.0;
y = (curPage == 0) ? 0.0 : _pages[curPage - 1]->pos().y() + page->height() + 5;
}
else {
y = 0.0;
x = (curPage == 0) ? 0.0 : _pages[curPage - 1]->pos().x()
+ page->width() + (((curPage+_pageNumberOffset) & 1) ? 50.0 : 1.0);
}
++curPage;
page->setPos(x, 0.0);
page->setPos(x, y);
page->systems()->clear();
return page;
}
Expand Down
1 change: 1 addition & 0 deletions libmscore/mscore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ MStyle* MScore::_baseStyle;
QString MScore::_globalShare;
int MScore::_vRaster;
int MScore::_hRaster;
bool MScore::_verticalOrientation = false;
QColor MScore::selectColor[VOICES];
QColor MScore::defaultColor;
QColor MScore::layoutBreakColor;
Expand Down
4 changes: 4 additions & 0 deletions libmscore/mscore.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ class MScore : public QObject {
static MStyle* _baseStyle; // buildin initial style
static QString _globalShare;
static int _hRaster, _vRaster;
static bool _verticalOrientation;

#ifdef SCRIPT_INTERFACE
static QQmlEngine* _qml;
Expand Down Expand Up @@ -381,6 +382,9 @@ class MScore : public QObject {
static void setNudgeStep10(qreal val) { nudgeStep10 = val; }
static void setNudgeStep50(qreal val) { nudgeStep50 = val; }

static bool verticalOrientation() { return _verticalOrientation; }
static void setVerticalOrientation(bool val) { _verticalOrientation = val; }

static QColor selectColor[4];
static QColor defaultColor;
static QColor dropColor;
Expand Down
5 changes: 4 additions & 1 deletion libmscore/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ static const PropertyData propertyList[] = {
{ P_ID::TRACK, false, 0, P_TYPE::INT },

{ P_ID::GLISSANDO_STYLE, false, "glissandoStyle", P_TYPE::GLISSANDO_STYLE},

{ P_ID::LAYOUT_MODE, false, 0, P_TYPE::INT },

{ P_ID::END, false, "", P_TYPE::INT }
};

Expand Down Expand Up @@ -308,7 +311,7 @@ QVariant getProperty(P_ID id, XmlReader& e)
QString value(e.readElementText());
if ( value == "baroque")
return QVariant(int(MScore::OrnamentStyle::BAROQUE));

return QVariant(int(MScore::OrnamentStyle::DEFAULT));
}
break; // break is really not necessary because of the default return
Expand Down
2 changes: 2 additions & 0 deletions libmscore/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ enum class P_ID : unsigned char {

GLISSANDO_STYLE,

LAYOUT_MODE,

END
};

Expand Down
78 changes: 65 additions & 13 deletions libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ void Score::init()
//---------------------------------------------------------

Score::Score()
: QObject(0), _is(this), _selection(this), _selectionFilter(this)
: QObject(0), ScoreElement(this), _is(this), _selection(this), _selectionFilter(this)
{
_parentScore = 0;
init();
Expand All @@ -343,7 +343,7 @@ Score::Score()
}

Score::Score(const MStyle* s)
: _is(this), _selection(this), _selectionFilter(this)
: ScoreElement(this), _is(this), _selection(this), _selectionFilter(this)
{
_parentScore = 0;
init();
Expand All @@ -365,7 +365,7 @@ Score::Score(const MStyle* s)
//

Score::Score(Score* parent)
: _is(this), _selection(this), _selectionFilter(this)
: ScoreElement(this), _is(this), _selection(this), _selectionFilter(this)
{
_parentScore = parent;
init();
Expand Down Expand Up @@ -394,7 +394,7 @@ Score::Score(Score* parent)
}

Score::Score(Score* parent, const MStyle* s)
: _is(this), _selection(this), _selectionFilter(this)
: ScoreElement(this), _is(this), _selection(this), _selectionFilter(this)
{
_parentScore = parent;
init();
Expand Down Expand Up @@ -3311,15 +3311,6 @@ void Score::undo(UndoCommand* cmd) const
undo()->push(cmd);
}

//---------------------------------------------------------
// setLayoutMode
//---------------------------------------------------------

void Score::setLayoutMode(LayoutMode lm)
{
_layoutMode = lm;
}

//---------------------------------------------------------
// linkId
//---------------------------------------------------------
Expand Down Expand Up @@ -4214,5 +4205,66 @@ void Score::cropPage(qreal margins)
}
}

//---------------------------------------------------------
// switchToPageMode
// switch to layout mode PAGE
//---------------------------------------------------------

void Score::switchToPageMode()
{
if (layoutMode() != LayoutMode::PAGE) {
startCmd();
ScoreElement::undoChangeProperty(P_ID::LAYOUT_MODE, int(LayoutMode::PAGE));
doLayout();
}
}

//---------------------------------------------------------
// getProperty
//---------------------------------------------------------

QVariant Score::getProperty(P_ID id) const
{
switch (id) {
case P_ID::LAYOUT_MODE:
return QVariant(static_cast<int>(_layoutMode));
default:
qDebug("Score::getProperty: unhandled id");
return QVariant();
}
}

//---------------------------------------------------------
// setProperty
//---------------------------------------------------------

bool Score::setProperty(P_ID id, const QVariant& v)
{
switch (id) {
case P_ID::LAYOUT_MODE:
setLayoutMode(LayoutMode(v.toInt()));
break;
default:
qDebug("Score::setProperty: unhandled id");
break;
}
score()->setLayoutAll(true);
return true;
}

//---------------------------------------------------------
// propertyDefault
//---------------------------------------------------------

QVariant Score::propertyDefault(P_ID id) const
{
switch (id) {
case P_ID::LAYOUT_MODE:
return static_cast<int>(LayoutMode::PAGE);
default:
return QVariant();
}
}

}

12 changes: 9 additions & 3 deletions libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ enum class Pad : char {

//---------------------------------------------------------
// LayoutMode
// PAGE The normal page view, honors page and line breaks
// PAGE The normal page view, honors page and line breaks.
// LINE The panoramic view, one long system
// FLOAT The "reflow" mode, ignore page and line breaks
// SYSTEM The "never ending page", page break are turned into line break
Expand Down Expand Up @@ -255,7 +255,7 @@ enum class PasteStatus : char {
// @P title string title of the score (read only)
//---------------------------------------------------------

class Score : public QObject {
class Score : public QObject, public ScoreElement {
Q_OBJECT
Q_PROPERTY(QString composer READ composer)
Q_PROPERTY(int duration READ duration)
Expand Down Expand Up @@ -989,7 +989,7 @@ class Score : public QObject {
void setSoloMute();

LayoutMode layoutMode() const { return _layoutMode; }
void setLayoutMode(LayoutMode lm);
void setLayoutMode(LayoutMode lm) { _layoutMode = lm; }

void doLayoutSystems();
void doLayoutPages();
Expand Down Expand Up @@ -1098,6 +1098,12 @@ class Score : public QObject {
bool checkKeys();
bool checkClefs();

void switchToPageMode();

virtual QVariant getProperty(P_ID) const override;
virtual bool setProperty(P_ID, const QVariant&) override;
virtual QVariant propertyDefault(P_ID) const override;

friend class ChangeSynthesizerState;
friend class Chord;
};
Expand Down
4 changes: 3 additions & 1 deletion libmscore/scorefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@
#include "mscore.h"
#include "stafftype.h"
#include "sym.h"

#ifdef OMR
#include "omr/omr.h"
#include "omr/omrpage.h"
#endif

#include "sig.h"
#include "undo.h"
#include "imageStore.h"
Expand Down Expand Up @@ -476,7 +478,7 @@ QImage Score::createThumbnail()
LayoutMode layoutMode = _layoutMode;
if (layoutMode != LayoutMode::PAGE) {
startCmd();
undo(new ChangeLayoutMode(this, LayoutMode::PAGE));
ScoreElement::undoChangeProperty(P_ID::LAYOUT_MODE, QVariant(int(LayoutMode::PAGE)));
doLayout();
}
Page* page = pages().at(0);
Expand Down
2 changes: 1 addition & 1 deletion libmscore/staff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ QVariant Staff::getProperty(P_ID id) const
case P_ID::SMALL:
return small();
default:
qDebug("Staff::setProperty: unhandled id");
qDebug("Staff::getProperty: unhandled id");
return QVariant();
}
}
Expand Down
1 change: 0 additions & 1 deletion libmscore/staff.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ class Staff : public QObject, public ScoreElement {
bool genKeySig();
bool showLedgerLines();


QColor color() const { return _color; }
void setColor(const QColor& val) { _color = val; }
void undoSetColor(const QColor& val);
Expand Down
12 changes: 0 additions & 12 deletions libmscore/undo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3597,18 +3597,6 @@ void ChangeStartEndSpanner::flip()
end = e;
}

//---------------------------------------------------------
// ChangeLayoutMode::flip
//---------------------------------------------------------

void ChangeLayoutMode::flip()
{
LayoutMode lm = score->layoutMode();
score->setLayoutMode(layoutMode);
layoutMode = lm;
score->setLayoutAll(true);
}

//---------------------------------------------------------
// ChangeMetaTags::flip
//---------------------------------------------------------
Expand Down
15 changes: 0 additions & 15 deletions libmscore/undo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1336,21 +1336,6 @@ class ChangeStartEndSpanner : public UndoCommand {
UNDO_NAME("ChangeStartEndSpanner")
};

//---------------------------------------------------------
// ChangeLayoutMode
//---------------------------------------------------------

class ChangeLayoutMode : public UndoCommand {
Score* score;
LayoutMode layoutMode;

void flip();

public:
ChangeLayoutMode(Score* s, LayoutMode m) : score(s), layoutMode(m) {}
UNDO_NAME("ChangeLayoutMode")
};

//---------------------------------------------------------
// ChangeMetaTags
//---------------------------------------------------------
Expand Down
38 changes: 7 additions & 31 deletions mscore/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@ void MuseScore::printFile()
LayoutMode layoutMode = cs->layoutMode();
if (layoutMode != LayoutMode::PAGE) {
cs->startCmd();
cs->undo(new ChangeLayoutMode(cs, LayoutMode::PAGE));
cs->ScoreElement::undoChangeProperty(P_ID::LAYOUT_MODE, int(LayoutMode::PAGE));
cs->doLayout();
}

Expand Down Expand Up @@ -1805,29 +1805,17 @@ bool MuseScore::saveAs(Score* cs, bool saveCopy, const QString& path, const QStr
}
else if (ext == "pdf") {
// save as pdf file *.pdf
if (layoutMode != LayoutMode::PAGE) {
cs->startCmd();
cs->undo(new ChangeLayoutMode(cs, LayoutMode::PAGE));
cs->doLayout();
}
cs->switchToPageMode();
rv = savePdf(cs, fn);
}
else if (ext == "png") {
// save as png file *.png
if (layoutMode != LayoutMode::PAGE) {
cs->startCmd();
cs->undo(new ChangeLayoutMode(cs, LayoutMode::PAGE));
cs->doLayout();
}
cs->switchToPageMode();
rv = savePng(cs, fn);
}
else if (ext == "svg") {
// save as svg file *.svg
if (layoutMode != LayoutMode::PAGE) {
cs->startCmd();
cs->undo(new ChangeLayoutMode(cs, LayoutMode::PAGE));
cs->doLayout();
}
cs->switchToPageMode();
rv = saveSvg(cs, fn);
}
#ifdef HAS_AUDIOFILE
Expand All @@ -1839,20 +1827,12 @@ bool MuseScore::saveAs(Score* cs, bool saveCopy, const QString& path, const QStr
rv = saveMp3(cs, fn);
#endif
else if (ext == "spos") {
if (layoutMode != LayoutMode::PAGE) {
cs->startCmd();
cs->undo(new ChangeLayoutMode(cs, LayoutMode::PAGE));
cs->doLayout();
}
cs->switchToPageMode();
// save positions of segments
rv = savePositions(cs, fn, true);
}
else if (ext == "mpos") {
if (layoutMode != LayoutMode::PAGE) {
cs->startCmd();
cs->undo(new ChangeLayoutMode(cs, LayoutMode::PAGE));
cs->doLayout();
}
cs->switchToPageMode();
// save positions of measures
rv = savePositions(cs, fn, false);
}
Expand Down Expand Up @@ -1959,11 +1939,7 @@ bool MuseScore::savePdf(QList<Score*> cs, const QString& saveName)
bool firstPage = true;
for (Score* s : cs) {
LayoutMode layoutMode = s->layoutMode();
if (layoutMode != LayoutMode::PAGE) {
s->startCmd();
s->undo(new ChangeLayoutMode(s, LayoutMode::PAGE));
s->doLayout();
}
s->switchToPageMode();
s->setPrinting(true);
MScore::pdfPrinting = true;

Expand Down
Loading

0 comments on commit e342fda

Please sign in to comment.