Skip to content

Commit

Permalink
add style option for barline scaling of small staves
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Jan 22, 2015
1 parent de4961e commit 93d828f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
29 changes: 16 additions & 13 deletions libmscore/barline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,9 @@ void BarLine::draw(QPainter* painter) const
if (y2-y1 < 0.1)
return;

// qreal _spatium = spatium();
qreal lw = point(score()->styleS(StyleIdx::barWidth));
qreal _spatium = score()->styleB(StyleIdx::scaleBarlines) ? spatium() : score()->spatium();

qreal lw = score()->styleS(StyleIdx::barWidth).val() * _spatium;

QPen pen(curColor(), lw, Qt::SolidLine, Qt::FlatCap);
painter->setPen(pen);
Expand All @@ -341,8 +342,8 @@ void BarLine::draw(QPainter* painter) const

case BarLineType::END:
{
qreal lw2 = point(score()->styleS(StyleIdx::endBarWidth));
qreal d = point(score()->styleS(StyleIdx::endBarDistance));
qreal lw2 = score()->styleS(StyleIdx::endBarWidth).val() * _spatium;
qreal d = score()->styleS(StyleIdx::endBarDistance).val() * _spatium;

painter->drawLine(QLineF(lw * .5, y1, lw * .5, y2));
pen.setWidthF(lw2);
Expand All @@ -354,8 +355,8 @@ void BarLine::draw(QPainter* painter) const

case BarLineType::DOUBLE:
{
lw = point(score()->styleS(StyleIdx::doubleBarWidth));
qreal d = point(score()->styleS(StyleIdx::doubleBarDistance));
lw = score()->styleS(StyleIdx::doubleBarWidth).val() * _spatium;
qreal d = score()->styleS(StyleIdx::doubleBarDistance).val() * _spatium;

pen.setWidthF(lw);
painter->setPen(pen);
Expand All @@ -368,8 +369,8 @@ void BarLine::draw(QPainter* painter) const

case BarLineType::START_REPEAT:
{
qreal lw2 = point(score()->styleS(StyleIdx::endBarWidth));
qreal d1 = point(score()->styleS(StyleIdx::endBarDistance));
qreal lw2 = score()->styleS(StyleIdx::endBarWidth).val() * _spatium;
qreal d1 = score()->styleS(StyleIdx::endBarDistance).val() * _spatium;

qreal x2 = lw2 * .5; // thick line (lw2)
qreal x1 = lw2 + d1 + lw * .5; // thin line (lw)
Expand All @@ -392,8 +393,8 @@ void BarLine::draw(QPainter* painter) const

case BarLineType::END_REPEAT:
{
qreal lw2 = point(score()->styleS(StyleIdx::endBarWidth));
qreal d1 = point(score()->styleS(StyleIdx::endBarDistance));
qreal lw2 = score()->styleS(StyleIdx::endBarWidth).val() * _spatium;
qreal d1 = score()->styleS(StyleIdx::endBarDistance).val() * _spatium;
qreal dotw = symWidth(SymId::repeatDot);
qreal x1 = dotw + d1 + lw * .5;
qreal x2 = dotw + d1 + lw + d1 + lw2 * .5;
Expand All @@ -415,8 +416,8 @@ void BarLine::draw(QPainter* painter) const

case BarLineType::END_START_REPEAT:
{
qreal lw2 = point(score()->styleS(StyleIdx::endBarWidth));
qreal d1 = point(score()->styleS(StyleIdx::endBarDistance));
qreal lw2 = score()->styleS(StyleIdx::endBarWidth).val() * _spatium;
qreal d1 = score()->styleS(StyleIdx::endBarDistance).val() * _spatium;
qreal dotw = symWidth(SymId::repeatDot);

qreal x1 = dotw + d1 + lw * .5; // thin bar
Expand Down Expand Up @@ -895,7 +896,9 @@ void BarLine::endEditDrag()

qreal BarLine::layoutWidth(Score* score, BarLineType type, qreal mag)
{
qreal _spatium = score->spatium() * mag;
qreal _spatium = score->spatium();
if (score->styleB(StyleIdx::scaleBarlines))
_spatium *= mag;
qreal dw = score->styleS(StyleIdx::barWidth).val() * _spatium;

qreal dotwidth = score->scoreFont()->width(SymId::repeatDot, mag);
Expand Down
4 changes: 3 additions & 1 deletion libmscore/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ static const StyleTypes2 styleTypes2[] = {
{ StyleIdx::tupletNoteRightDistance, StyleType("tupletNoteRightDistance", StyleValueType::SPATIUM) },
{ StyleIdx::barreLineWidth, StyleType("barreLineWidth", StyleValueType::DOUBLE) },
{ StyleIdx::fretMag, StyleType("fretMag", StyleValueType::DOUBLE) },
{ StyleIdx::scaleBarlines, StyleType("scaleBarlines", StyleValueType::BOOL) }
};

class StyleTypes {
Expand Down Expand Up @@ -562,7 +563,8 @@ StyleData::StyleData()
{ StyleIdx::tupletNoteLeftDistance, QVariant(0.0) },
{ StyleIdx::tupletNoteRightDistance, QVariant(0.0) },
{ StyleIdx::barreLineWidth, QVariant(1.0) },
{ StyleIdx::fretMag, QVariant(1.0) }
{ StyleIdx::fretMag, QVariant(1.0) },
{ StyleIdx::scaleBarlines, QVariant(true) }
};
for (unsigned i = 0; i < sizeof(values2)/sizeof(*values2); ++i)
_values[int(values2[i].idx)] = values2[i].val;
Expand Down
1 change: 1 addition & 0 deletions libmscore/style.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ enum class StyleIdx : unsigned char {

barreLineWidth,
fretMag,
scaleBarlines,


STYLES
Expand Down
2 changes: 2 additions & 0 deletions mscore/editstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ void EditStyle::getValues()

lstyle.set(StyleIdx::barreLineWidth, barreLineWidth->value());
lstyle.set(StyleIdx::fretMag, fretMag->value());
lstyle.set(StyleIdx::scaleBarlines, scaleBarlines->isChecked());
}

//---------------------------------------------------------
Expand Down Expand Up @@ -816,6 +817,7 @@ void EditStyle::setValues()

barreLineWidth->setValue(lstyle.value(StyleIdx::barreLineWidth).toDouble());
fretMag->setValue(lstyle.value(StyleIdx::fretMag).toDouble());
scaleBarlines->setChecked(lstyle.value(StyleIdx::scaleBarlines).toBool());
}

//---------------------------------------------------------
Expand Down
9 changes: 8 additions & 1 deletion mscore/editstyle.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>904</width>
<height>577</height>
<height>739</height>

This comment has been minimized.

Copy link
@Jojo-Schmitz

Jojo-Schmitz Jan 22, 2015

Contributor

This needs to get turned back to 577 again...

</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -2221,6 +2221,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="scaleBarlines">
<property name="text">
<string>Scale Barlines to staff size</string>

This comment has been minimized.

Copy link
@Jojo-Schmitz

Jojo-Schmitz Jan 22, 2015

Contributor

lower case 'barlines' please

</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down

2 comments on commit 93d828f

@wschweer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In one of the next commits i will programmatically override the designer settings with a widget->resize(...) call to get rid of this...

@Jojo-Schmitz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that'd be much better than having to fix this time and time again...

Please sign in to comment.