Added colour property to the lines of a staff.

Colour is set with a colour box in the Staff Properties dialogue box.
This commit is contained in:
Maurizio M. Gavioli 2013-10-26 13:47:05 +02:00
parent a8e8b7b039
commit c309b21a5a
8 changed files with 129 additions and 64 deletions

View file

@ -879,6 +879,8 @@ void StaffLines::layout()
// qDebug("StaffLines::layout:: dist %f st %p\n", dist, st);
setColor(staff() ? staff()->color() : MScore::defaultColor);
lw = score()->styleS(ST_staffLineWidth).val() * _spatium;
bbox().setRect(0.0, -lw*.5, width(), lines * dist + lw);
}
@ -919,6 +921,7 @@ void StaffLines::draw(QPainter* painter) const
y = _pos.y() + (lines+4) * dist;
painter->drawLine(QLineF(x1, y, x2, y));
}
painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::FlatCap));
painter->drawLines(ll);
}

View file

@ -172,6 +172,7 @@ Staff::Staff(Score* s)
_barLineTo = (lines()-1)*2;
_updateKeymap = true;
_linkedStaves = 0;
_color = MScore::defaultColor;
setClef(0, ClefType::G);
}
@ -190,6 +191,7 @@ Staff::Staff(Score* s, Part* p, int rs)
_barLineTo = (lines()-1)*2;
_updateKeymap = true;
_linkedStaves = 0;
_color = MScore::defaultColor;
setClef(0, ClefType::G);
}
@ -402,6 +404,8 @@ void Staff::write(Xml& xml) const
}
if (_userDist != 0.0)
xml.tag("distOffset", _userDist / spatium());
if (color() != Qt::black)
xml.tag("color", color());
xml.etag();
}
@ -474,6 +478,8 @@ void Staff::read(XmlReader& e)
linkTo(score()->staff(v));
}
}
else if (tag == "color")
_color = e.readColor();
else
e.unknown();
}
@ -862,5 +868,15 @@ void Staff::updateOttava(Ottava* o)
pitchOffsets().setPitchOffset(o->tick(), o->pitchShift());
pitchOffsets().setPitchOffset(o->tick2()+1, 0);
}
//---------------------------------------------------------
// undoSetColor
//---------------------------------------------------------
void Staff::undoSetColor(const QColor& val)
{
// score()->undoChangeProperty(this, P_COLOR, val);
}
}

View file

@ -102,6 +102,7 @@ class Staff : public QObject {
bool _small;
bool _invisible;
bool _updateKeymap;
QColor _color;
qreal _userDist; ///< user edited extra distance
@ -210,6 +211,10 @@ class Staff : public QObject {
bool genKeySig();
bool showLedgerLines();
const ClefList& clefList() const { return clefs; }
QColor color() const { return _color; }
void setColor(const QColor& val) { _color = val; }
void undoSetColor(const QColor& val);
};
} // namespace Ms

View file

@ -2290,12 +2290,13 @@ void ChangePageFormat::flip()
// ChangeStaff
//---------------------------------------------------------
ChangeStaff::ChangeStaff(Staff* _staff, bool _small, bool _invisible, qreal _userDist, StaffType* st)
ChangeStaff::ChangeStaff(Staff* _staff, bool _small, bool _invisible, qreal _userDist, QColor _color, StaffType* st)
{
staff = _staff;
small = _small;
invisible = _invisible;
userDist = _userDist;
color = _color;
staffType = st;
}
@ -2311,16 +2312,19 @@ void ChangeStaff::flip()
int oldSmall = staff->small();
bool oldInvisible = staff->invisible();
qreal oldUserDist = staff->userDist();
QColor oldColor = staff->color();
StaffType* st = staff->staffType();
staff->setSmall(small);
staff->setInvisible(invisible);
staff->setUserDist(userDist);
staff->setColor(color);
staff->setStaffType(staffType);
small = oldSmall;
invisible = oldInvisible;
userDist = oldUserDist;
color = oldColor;
staffType = st;
Score* score = staff->score();

View file

@ -734,13 +734,14 @@ class ChangeStaff : public UndoCommand {
bool small;
bool invisible;
qreal userDist;
QColor color;
StaffType* staffType;
void flip();
public:
ChangeStaff(Staff*, bool small, bool invisible, qreal userDist, StaffType*);
UNDO_NAME("ChangeStaff");
ChangeStaff(Staff*, bool small, bool invisible, qreal userDist, QColor _color, StaffType*);
UNDO_NAME("ChangeStaff")
};
//---------------------------------------------------------

View file

@ -60,6 +60,7 @@ EditStaff::EditStaff(Staff* s, QWidget* parent)
small->setChecked(staff->small());
invisible->setChecked(staff->invisible());
spinExtraDistance->setValue(s->userDist() / score->spatium());
color->setColor(s->color());
partName->setText(part->partName());
updateInstrument();
@ -224,6 +225,7 @@ void EditStaff::apply()
bool s = small->isChecked();
bool inv = invisible->isChecked();
qreal userDist = spinExtraDistance->value();
QColor col = color->color();
int staffIdx = staffType->itemData(staffType->currentIndex()).toInt();
StaffType* st = score->staffType(staffIdx);
@ -244,8 +246,8 @@ void EditStaff::apply()
emit instrumentChanged();
}
if (s != staff->small() || inv != staff->invisible() || userDist != staff->userDist() || st != staff->staffType())
score->undo(new ChangeStaff(staff, s, inv, userDist * score->spatium(), st));
if (s != staff->small() || inv != staff->invisible() || userDist != staff->userDist() || st != staff->staffType() || col != staff->color())
score->undo(new ChangeStaff(staff, s, inv, userDist * score->spatium(), col, st));
if (updateNeeded)
score->cmdUpdateNotes();

View file

@ -568,7 +568,31 @@
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="3">
<widget class="QComboBox" name="staffType">
<property name="maxVisibleItems">
<number>16</number>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Extra distance:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="invisible">
<property name="text">
<string>Invisible staff lines</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -581,64 +605,7 @@
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="invisible">
<property name="text">
<string>Invisible staff lines</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QComboBox" name="staffType">
<property name="maxVisibleItems">
<number>16</number>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="small">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Small staff</string>
</property>
</widget>
</item>
<item row="0" column="6">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>79</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="4">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Extra distance:</string>
</property>
</widget>
</item>
<item row="1" column="5">
<item row="1" column="3">
<widget class="QDoubleSpinBox" name="spinExtraDistance">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -657,11 +624,78 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>79</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="small">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Small staff</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="Awl::ColorLabel" name="color">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Staff line color:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Awl::ColorLabel</class>
<extends>QFrame</extends>
<header>awl/colorlabel.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>invisible</tabstop>
<tabstop>small</tabstop>

View file

@ -1125,7 +1125,7 @@ void MuseScore::editInstrList()
// use selected staff type
if (st != staff->staffType())
rootScore->undo(new ChangeStaff(staff, staff->small(), staff->invisible(), staff->userDist(), st));
rootScore->undo(new ChangeStaff(staff, staff->small(), staff->invisible(), staff->userDist(), staff->color(), st));
if (updateNeeded)
rootScore->cmdUpdateNotes();
}