Skip to content

Commit

Permalink
change text frame width and margins from mm units to space units
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Sep 10, 2012
1 parent a3d585d commit 4b90126
Show file tree
Hide file tree
Showing 14 changed files with 170 additions and 94 deletions.
2 changes: 2 additions & 0 deletions libmscore/mscore.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static const int MSCVERSION = 125;
// 1.23 measure property for actual length
// 1.24 default image size is spatium dependent
// 1.25 symbol numbers in TextLine() replaced by symbol names
// TextStyle: frameWidth, paddingWidth are now in Spatium units (instead of mm)


class MStyle;
Expand All @@ -55,6 +56,7 @@ static const qreal INCH = 25.4;
static const qreal PPI = 72.0; // printer points per inch
static const qreal SPATIUM20 = 5.0 / PPI; // size of Spatium for 20pt font in inch
static const int MAX_STAVES = 4;
#define MMSP(x) Spatium((x) * .1)

static const char mimeSymbolFormat[] = "application/mscore/symbol";
static const char mimeSymbolListFormat[] = "application/mscore/symbollist";
Expand Down
5 changes: 3 additions & 2 deletions libmscore/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,9 @@ void Segment::add(Element* el)
case CHORD:
case REST:
if (_elist[track]) {
qDebug("Segment::add(%s) there is already an %s at %d track %d\n",
el->name(), _elist[track]->name(), tick(), track);
qDebug("Segment::add(%s) there is already an %s at %s track %d",
el->name(), _elist[track]->name(),
score()->sigmap()->pos(tick()), track);
// abort();
return;
}
Expand Down
17 changes: 17 additions & 0 deletions libmscore/sig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,23 @@ void TimeSigMap::tickValues(int t, int* bar, int* beat, int* tick) const
*tick = rest % ticksB;
}

//---------------------------------------------------------
// pos
// Return string representation of tick position.
// This is not reentrant and only for debugging!
//---------------------------------------------------------

const char* TimeSigMap::pos(int t)
{
static char* s = 0;
delete s;
int bar, beat, tick;
tickValues(t, &bar, &beat, &tick);
QString ss = QString("%1:%2:%3").arg(bar).arg(beat).arg(tick);
s = strdup(qPrintable(ss));
return s;
}

//---------------------------------------------------------
// bar2tick
//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions libmscore/sig.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class TimeSigMap : public std::map<const int, SigEvent > {

void tickValues(int t, int* bar, int* beat, int* tick) const;
int bar2tick(int bar, int beat) const;
const char* pos(int t) const;

unsigned raster(unsigned tick, int raster) const;
unsigned raster1(unsigned tick, int raster) const; // round down
Expand Down
13 changes: 7 additions & 6 deletions libmscore/simpletext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ void SimpleText::drawFrame(QPainter* painter) const
color = Qt::gray;
else if (selected())
color = Qt::blue;
if (frameWidth() != 0.0) {
QPen pen(color, frameWidth() * MScore::DPMM);
if (frameWidth().val() != 0.0) {
QPen pen(color, frameWidth().val() * spatium());
painter->setPen(pen);
}
else
Expand Down Expand Up @@ -184,9 +184,10 @@ void SimpleText::layoutFrame()
frame.setWidth(frame.height());
}
}
qreal w = (paddingWidth() + frameWidth() * .5) * MScore::DPMM;
qreal _spatium = spatium();
qreal w = (paddingWidth() + frameWidth() * .5).val() * _spatium;
frame.adjust(-w, -w, w, w);
w = frameWidth() * MScore::DPMM;
w = frameWidth().val() * _spatium;
setbbox(frame.adjusted(-w, -w, w, w));
}

Expand Down Expand Up @@ -221,7 +222,7 @@ qreal SimpleText::baseLine() const
// frameWidth
//---------------------------------------------------------

qreal SimpleText::frameWidth() const
Spatium SimpleText::frameWidth() const
{
return textStyle().frameWidth();
}
Expand All @@ -239,7 +240,7 @@ bool SimpleText::hasFrame() const
// paddingWidth
//---------------------------------------------------------

qreal SimpleText::paddingWidth() const
Spatium SimpleText::paddingWidth() const
{
return textStyle().paddingWidth();
}
Expand Down
4 changes: 2 additions & 2 deletions libmscore/simpletext.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ class SimpleText : public Element {
bool layoutToParentWidth() const { return _layoutToParentWidth; }
void setLayoutToParentWidth(bool v) { _layoutToParentWidth = v; }

qreal frameWidth() const;
Spatium frameWidth() const;
QColor backgroundColor() const;
bool hasFrame() const;
qreal paddingWidth() const;
Spatium paddingWidth() const;
QColor frameColor() const;
int frameRound() const;
bool circle() const;
Expand Down
Loading

0 comments on commit 4b90126

Please sign in to comment.