Skip to content

Commit

Permalink
implement 'never hide' flag for staff
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Jul 31, 2014
1 parent 46bc25f commit 4e426c4
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 39 deletions.
5 changes: 5 additions & 0 deletions libmscore/layout.cpp
Expand Up @@ -2058,6 +2058,10 @@ bool Score::layoutSystem(qreal& minWidth, qreal w, bool isFirstSystem, bool long
}


//---------------------------------------------------------
// hideEmptyStaves
//---------------------------------------------------------

void Score::hideEmptyStaves(System* system, bool isFirstSystem)
{
//
Expand All @@ -2071,6 +2075,7 @@ void Score::hideEmptyStaves(System* system, bool isFirstSystem)
if (styleB(StyleIdx::hideEmptyStaves)
&& (staves > 1)
&& !(isFirstSystem && styleB(StyleIdx::dontHideStavesInFirstSystem))
&& !staff->neverHide()
) {
bool hideStaff = true;
foreach(MeasureBase* m, system->measures()) {
Expand Down
19 changes: 5 additions & 14 deletions libmscore/staff.cpp
Expand Up @@ -162,29 +162,15 @@ Staff::Staff(Score* s)
_score = s;
_rstaff = 0;
_part = 0;
_small = false;
_invisible = false;
_userDist = .0;
_barLineSpan = 1;
_barLineFrom = 0;
_barLineTo = (lines()-1)*2;
_linkedStaves = 0;
_color = MScore::defaultColor;
}

Staff::Staff(Score* s, Part* p, int rs)
{
_score = s;
_rstaff = rs;
_part = p;
_small = false;
_invisible = false;
_userDist = .0;
_barLineSpan = 1;
_barLineFrom = 0;
_barLineTo = (lines()-1)*2;
_linkedStaves = 0;
_color = MScore::defaultColor;
}

//---------------------------------------------------------
Expand Down Expand Up @@ -437,6 +423,9 @@ void Staff::write(Xml& xml) const
xml.tag("small", small());
if (invisible())
xml.tag("invisible", invisible());
if (neverHide())
xml.tag("neverHide", neverHide());

foreach(const BracketItem& i, _brackets)
xml.tagE("bracket type=\"%d\" span=\"%d\"", i._bracket, i._bracketSpan);

Expand Down Expand Up @@ -495,6 +484,8 @@ void Staff::read(XmlReader& e)
setSmall(e.readInt());
else if (tag == "invisible")
setInvisible(e.readInt());
else if (tag == "neverHide")
setNeverHide(e.readInt());
else if (tag == "keylist")
_keys.read(e, _score);
else if (tag == "bracket") {
Expand Down
22 changes: 12 additions & 10 deletions libmscore/staff.h
Expand Up @@ -19,7 +19,6 @@
*/

#include "mscore.h"
// #include "key.h"
#include "velo.h"
#include "pitch.h"
#include "cleflist.h"
Expand Down Expand Up @@ -97,18 +96,18 @@ class Staff : public QObject {
std::map<int,TimeSig*> timesigs;

QList <BracketItem> _brackets;
int _barLineSpan; ///< 0 - no bar line, 1 - span this staff, ...
int _barLineFrom; ///< line of start staff to draw the barline from (0 = staff top line, ...)
int _barLineTo; ///< line of end staff to draw the bar line to (0= staff top line, ...)
bool _small;
bool _invisible;
QColor _color;

qreal _userDist; ///< user edited extra distance
int _barLineSpan { 1 }; ///< 0 - no bar line, 1 - span this staff, ...
int _barLineFrom { 0 }; ///< line of start staff to draw the barline from (0 = staff top line, ...)
int _barLineTo; ///< line of end staff to draw the bar line to (0= staff top line, ...)
bool _small { false };
bool _invisible { false };
bool _neverHide { false };
QColor _color { MScore::defaultColor };
qreal _userDist { 0.0 }; ///< user edited extra distance

StaffType _staffType;

LinkedStaves* _linkedStaves;
LinkedStaves* _linkedStaves { nullptr };

QMap<int,int> _channelList[VOICES];

Expand Down Expand Up @@ -173,6 +172,9 @@ class Staff : public QObject {
void setSmall(bool val) { _small = val; }
bool invisible() const { return _invisible; }
void setInvisible(bool val) { _invisible = val; }
bool neverHide() const { return _neverHide; }
void setNeverHide(bool val) { _neverHide = val; }

void setSlashStyle(bool val);
int lines() const;
void setLines(int);
Expand Down
7 changes: 6 additions & 1 deletion libmscore/undo.cpp
Expand Up @@ -2315,13 +2315,15 @@ void ChangePageFormat::flip()
// ChangeStaff
//---------------------------------------------------------

ChangeStaff::ChangeStaff(Staff* _staff, bool _small, bool _invisible, qreal _userDist, QColor _color)
ChangeStaff::ChangeStaff(Staff* _staff, bool _small, bool _invisible,
qreal _userDist, QColor _color, bool _neverHide)
{
staff = _staff;
small = _small;
invisible = _invisible;
userDist = _userDist;
color = _color;
neverHide = _neverHide;
}

//---------------------------------------------------------
Expand All @@ -2347,16 +2349,19 @@ void ChangeStaff::flip()
bool oldInvisible = staff->invisible();
qreal oldUserDist = staff->userDist();
QColor oldColor = staff->color();
bool oldNeverHide = staff->neverHide();

staff->setSmall(small);
staff->setInvisible(invisible);
staff->setUserDist(userDist);
staff->setColor(color);
staff->setNeverHide(neverHide);

small = oldSmall;
invisible = oldInvisible;
userDist = oldUserDist;
color = oldColor;
neverHide = oldNeverHide;

Score* score = staff->score();
if (invisibleChanged) {
Expand Down
3 changes: 2 additions & 1 deletion libmscore/undo.h
Expand Up @@ -721,11 +721,12 @@ class ChangeStaff : public UndoCommand {
bool invisible;
qreal userDist;
QColor color;
bool neverHide;

void flip();

public:
ChangeStaff(Staff*, bool small, bool invisible, qreal userDist, QColor _color);
ChangeStaff(Staff*, bool small, bool invisible, qreal userDist, QColor _color, bool _neverHide);
UNDO_NAME("ChangeStaff")
};

Expand Down
12 changes: 10 additions & 2 deletions mscore/editstaff.cpp
Expand Up @@ -61,6 +61,7 @@ EditStaff::EditStaff(Staff* s, QWidget* parent)
staff->setColor(orgStaff->color());
staff->setStaffType(orgStaff->staffType());
staff->setPart(part);
staff->setNeverHide(orgStaff->neverHide());

// hide string data controls if instrument has no strings
stringDataFrame->setVisible(instrument.stringData() && instrument.stringData()->strings() > 0);
Expand All @@ -70,6 +71,7 @@ EditStaff::EditStaff(Staff* s, QWidget* parent)
small->setChecked(staff->small());
color->setColor(s->color());
partName->setText(part->partName());
neverHide->setChecked(staff->neverHide());

updateStaffType();
updateInstrument();
Expand Down Expand Up @@ -232,6 +234,7 @@ void EditStaff::apply()
bool inv = invisible->isChecked();
qreal userDist = spinExtraDistance->value();
QColor col = color->color();
bool nhide = neverHide->isChecked();

if (!(instrument == *part->instr()) || part->partName() != partName->text()) {
Interval v1 = instrument.transpose();
Expand All @@ -244,8 +247,13 @@ void EditStaff::apply()
score->transpositionChanged(part);
}

if (s != staff->small() || inv != staff->invisible() || userDist != staff->userDist() || col != staff->color())
score->undo(new ChangeStaff(orgStaff, s, inv, userDist * score->spatium(), col));
if (s != staff->small()
|| inv != staff->invisible()
|| userDist != staff->userDist()
|| col != staff->color()
|| nhide != staff->neverHide()
)
score->undo(new ChangeStaff(orgStaff, s, inv, userDist * score->spatium(), col, nhide));

if ( !(*orgStaff->staffType() == *staff->staffType()) ) {
// updateNeeded |= (orgStaff->staffGroup() == StaffGroup::TAB || staff->staffGroup() == StaffGroup::TAB);
Expand Down
29 changes: 18 additions & 11 deletions mscore/editstaff.ui
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>696</width>
<height>542</height>
<width>893</width>
<height>583</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -605,14 +605,14 @@
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="grid_StaffProps">
<item row="1" column="1">
<item row="2" column="1">
<widget class="QCheckBox" name="showTimesig">
<property name="text">
<string>Show time signature</string>
</property>
</widget>
</item>
<item row="2" column="2">
<item row="3" column="2">
<layout class="QHBoxLayout" name="hLayout_LineColor">
<item>
<widget class="QLabel" name="labelColor">
Expand All @@ -636,14 +636,14 @@
</item>
</layout>
</item>
<item row="3" column="2">
<item row="4" column="2">
<widget class="QToolButton" name="changeStaffType">
<property name="text">
<string>Advanced style properties...</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<layout class="QHBoxLayout" name="hLayout_StyleGroup">
<item>
<widget class="QLabel" name="labelStaffGroup">
Expand Down Expand Up @@ -682,21 +682,21 @@
</item>
</layout>
</item>
<item row="1" column="2">
<item row="2" column="2">
<widget class="QCheckBox" name="invisible">
<property name="text">
<string>Invisible staff lines</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QCheckBox" name="showBarlines">
<property name="text">
<string>Show barlines</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="QCheckBox" name="showClef">
<property name="toolTip">
<string/>
Expand All @@ -706,7 +706,7 @@
</property>
</widget>
</item>
<item row="0" column="2">
<item row="1" column="2">
<widget class="QCheckBox" name="small">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
Expand All @@ -719,7 +719,14 @@
</property>
</widget>
</item>
<item row="0" column="0" rowspan="3">
<item row="0" column="1">
<widget class="QCheckBox" name="neverHide">
<property name="text">
<string>Never hide</string>

This comment has been minimized.

Copy link
@Jojo-Schmitz

Jojo-Schmitz Jul 31, 2014

Contributor

How comes that this new string (as well as some others from recent comits) hasn't made it to Transifex yet?

This comment has been minimized.

Copy link
@lasconic

lasconic Jul 31, 2014

Contributor

The server is down for a week now. I contacted the IT department and waiting for them.

</property>
</widget>
</item>
<item row="0" column="0" rowspan="4">
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
Expand Down

0 comments on commit 4e426c4

Please sign in to comment.