Skip to content

Commit

Permalink
Allow brackets to be invisible
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-spa committed Mar 20, 2023
1 parent 20e199b commit 232729e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/engraving/libmscore/bracket.cpp
Expand Up @@ -170,6 +170,7 @@ void Bracket::layout()
return;
}

setVisible(_bi->visible());
_shape.clear();
switch (bracketType()) {
case BracketType::BRACE: {
Expand Down
3 changes: 3 additions & 0 deletions src/engraving/libmscore/bracketItem.cpp
Expand Up @@ -70,6 +70,9 @@ bool BracketItem::setProperty(Pid id, const PropertyValue& v)
case Pid::BRACKET_SPAN:
_bracketSpan = static_cast<size_t>(v.toInt());
break;
case Pid::VISIBLE:
setVisible(v.toBool());
break;
default:
return EngravingItem::setProperty(id, v);
}
Expand Down
4 changes: 0 additions & 4 deletions src/engraving/libmscore/cmd.cpp
Expand Up @@ -4485,10 +4485,6 @@ void Score::cmdToggleVisible()
bool newVisible = !allVisible;

for (EngravingItem* item : selection().elements()) {
if (item->isBracket()) {
continue;
}

undoChangeVisible(item, newVisible);
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/engraving/libmscore/staff.cpp
Expand Up @@ -218,6 +218,12 @@ void Staff::setBracketSpan(size_t idx, size_t val)
_brackets[idx]->setBracketSpan(val);
}

void Staff::setBracketVisible(size_t idx, bool v)
{
fillBrackets(idx);
_brackets[idx]->setVisible(v);
}

//---------------------------------------------------------
// addBracket
//---------------------------------------------------------
Expand Down Expand Up @@ -810,8 +816,9 @@ void Staff::write(XmlWriter& xml) const
BracketType a = i->bracketType();
size_t b = i->bracketSpan();
size_t c = i->column();
bool v = i->visible();
if (a != BracketType::NO_BRACKET || b > 0) {
xml.tag("bracket", { { "type", static_cast<int>(a) }, { "span", b }, { "col", c } });
xml.tag("bracket", { { "type", static_cast<int>(a) }, { "span", b }, { "col", c }, { "visible", v } });
}
}

Expand Down Expand Up @@ -883,6 +890,7 @@ bool Staff::readProperties(XmlReader& e)
}
setBracketType(col, BracketType(e.intAttribute("type", -1)));
setBracketSpan(col, e.intAttribute("span", 0));
setBracketVisible(col, static_cast<bool>(e.intAttribute("visible", 1)));
e.readNext();
} else if (tag == "barLineSpan") {
_barLineSpan = e.readInt();
Expand Down
1 change: 1 addition & 0 deletions src/engraving/libmscore/staff.h
Expand Up @@ -153,6 +153,7 @@ class Staff final : public EngravingItem
size_t bracketSpan(size_t idx) const;
void setBracketType(size_t idx, BracketType val);
void setBracketSpan(size_t idx, size_t val);
void setBracketVisible(size_t idx, bool v);
void swapBracket(size_t oldIdx, size_t newIdx);
void changeBracketColumn(size_t oldColumn, size_t newColumn);
void addBracket(BracketItem*);
Expand Down
5 changes: 4 additions & 1 deletion src/engraving/libmscore/system.cpp
Expand Up @@ -366,7 +366,7 @@ double System::totalBracketOffset(LayoutContext& ctx)
for (staff_idx_t staffIdx = 0; staffIdx < nstaves; ++staffIdx) {
const Staff* staff = ctx.score()->staff(staffIdx);
for (auto bi : staff->brackets()) {
if (bi->bracketType() == BracketType::NO_BRACKET) {
if (bi->bracketType() == BracketType::NO_BRACKET || !bi->visible()) {
continue;
}

Expand Down Expand Up @@ -826,6 +826,9 @@ void System::setBracketsXPosition(const double xPosition)
// Compute offset cause by other stacked brackets
double xOffset = 0;
for (const Bracket* b2 : _brackets) {
if (!b2->bracketItem()->visible()) {
continue;
}
bool b1FirstStaffInB2 = (b1->firstStaff() >= b2->firstStaff() && b1->firstStaff() <= b2->lastStaff());
bool b1LastStaffInB2 = (b1->lastStaff() >= b2->firstStaff() && b1->lastStaff() <= b2->lastStaff());
if (b1->column() > b2->column()
Expand Down

0 comments on commit 232729e

Please sign in to comment.