Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/engraving/api/v1/apitypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ enum class ElementType {
SYSTEM_DIVIDER = int(mu::engraving::ElementType::SYSTEM_DIVIDER),
STEM_SLASH = int(mu::engraving::ElementType::STEM_SLASH),
ARPEGGIO = int(mu::engraving::ElementType::ARPEGGIO),
CHORD_BRACKET = int(mu::engraving::ElementType::CHORD_BRACKET),
ACCIDENTAL = int(mu::engraving::ElementType::ACCIDENTAL),
LEDGER_LINE = int(mu::engraving::ElementType::LEDGER_LINE),
STEM = int(mu::engraving::ElementType::STEM),
Expand Down
1 change: 1 addition & 0 deletions src/engraving/api/v1/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ void Cursor::add(EngravingItem* wrapped)
// To be added at chord level
case ElementType::NOTE:
case ElementType::ARPEGGIO:
case ElementType::CHORD_BRACKET:
case ElementType::TREMOLO_SINGLECHORD:
case ElementType::TREMOLO_TWOCHORD:
case ElementType::CHORDLINE:
Expand Down
7 changes: 4 additions & 3 deletions src/engraving/dom/arpeggio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
using namespace mu;
using namespace mu::engraving;

Arpeggio::Arpeggio(Chord* parent)
: EngravingItem(ElementType::ARPEGGIO, parent, ElementFlag::MOVABLE)
Arpeggio::Arpeggio(Chord* parent, ElementType type)
: EngravingItem(type, parent, ElementFlag::MOVABLE)
{
m_arpeggioType = ArpeggioType::NORMAL;
m_span = 1;
Expand Down Expand Up @@ -395,7 +395,7 @@ void Arpeggio::spatiumChanged(double oldValue, double newValue)

bool Arpeggio::acceptDrop(EditData& data) const
{
return data.dropElement->type() == ElementType::ARPEGGIO;
return data.dropElement->type() == ElementType::ARPEGGIO || data.dropElement->type() == ElementType::CHORD_BRACKET;
}

//---------------------------------------------------------
Expand All @@ -407,6 +407,7 @@ EngravingItem* Arpeggio::drop(EditData& data)
EngravingItem* e = data.dropElement;
switch (e->type()) {
case ElementType::ARPEGGIO:
case ElementType::CHORD_BRACKET:
{
Arpeggio* a = toArpeggio(e);
if (explicitParent()) {
Expand Down
8 changes: 4 additions & 4 deletions src/engraving/dom/arpeggio.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ enum class AnchorRebaseDirection : unsigned char {
DOWN
};

class Arpeggio final : public EngravingItem
class Arpeggio : public EngravingItem
{
OBJECT_ALLOCATOR(engraving, Arpeggio)
DECLARE_CLASSOF(ElementType::ARPEGGIO)
Expand Down Expand Up @@ -113,12 +113,12 @@ class Arpeggio final : public EngravingItem
};
DECLARE_LAYOUTDATA_METHODS(Arpeggio)

private:

protected:
friend class Factory;

Arpeggio(Chord* parent);
Arpeggio(Chord* parent, ElementType type = ElementType::ARPEGGIO);

private:
void spatiumChanged(double /*oldValue*/, double /*newValue*/) override;
std::vector<LineF> dragAnchorLines() const override;
std::vector<LineF> gripAnchorLines(Grip) const override;
Expand Down
11 changes: 9 additions & 2 deletions src/engraving/dom/chord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include "accidental.h"
#include "arpeggio.h"
#include "chordbracket.h"
#include "articulation.h"
#include "beam.h"
#include "chordline.h"
Expand Down Expand Up @@ -325,7 +326,7 @@ Chord::Chord(const Chord& c, bool link)
add(Factory::copyStemSlash(*(c.m_stemSlash)));
}
if (c.m_arpeggio) {
Arpeggio* a = new Arpeggio(*(c.m_arpeggio));
Arpeggio* a = c.m_arpeggio->isChordBracket() ? new ChordBracket(*toChordBracket(c.m_arpeggio)) : new Arpeggio(*(c.m_arpeggio));
add(a);
if (link) {
score()->undo(new Link(a, const_cast<Arpeggio*>(c.m_arpeggio)));
Expand Down Expand Up @@ -602,6 +603,7 @@ void Chord::add(EngravingItem* e)
score()->setPlaylistDirty();
break;
case ElementType::ARPEGGIO:
case ElementType::CHORD_BRACKET:
m_arpeggio = toArpeggio(e);
break;
case ElementType::TREMOLO_TWOCHORD:
Expand Down Expand Up @@ -703,6 +705,7 @@ void Chord::remove(EngravingItem* e)
break;

case ElementType::ARPEGGIO:
case ElementType::CHORD_BRACKET:
if (m_spanArpeggio == m_arpeggio) {
m_spanArpeggio = nullptr;
}
Expand Down Expand Up @@ -1468,6 +1471,7 @@ EngravingItem* Chord::drop(EditData& data)
break;

case ElementType::ARPEGGIO:
case ElementType::CHORD_BRACKET:
{
Arpeggio* a = toArpeggio(e);
if (arpeggio()) {
Expand Down Expand Up @@ -2382,6 +2386,7 @@ EngravingItem* Chord::nextElement()
break;
}
case ElementType::ARPEGGIO:
case ElementType::CHORD_BRACKET:
if (m_tremoloTwoChord) {
return m_tremoloTwoChord;
} else if (m_tremoloSingleChord) {
Expand Down Expand Up @@ -2488,7 +2493,9 @@ EngravingItem* Chord::prevElement()
return m_arpeggio;
}
// fall through
case ElementType::ARPEGGIO: {
case ElementType::ARPEGGIO:
case ElementType::CHORD_BRACKET:
{
Note* n = m_notes.front();
EngravingItem* elN = n->lastElementBeforeSegment();
assert(elN != NULL);
Expand Down
86 changes: 86 additions & 0 deletions src/engraving/dom/chordbracket.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include "chordbracket.h"

#include "style/style.h"

namespace mu::engraving {
static const ElementStyle chordBracketStyle {
{ Sid::chordBracketHookLen, Pid::BRACKET_HOOK_LEN },
};

ChordBracket::ChordBracket(Chord* parent)
: Arpeggio(parent, ElementType::CHORD_BRACKET)
{
setArpeggioType(ArpeggioType::BRACKET);

initElementStyle(&chordBracketStyle);
}

PropertyValue ChordBracket::getProperty(Pid propertyId) const
{
switch (propertyId) {
case Pid::BRACKET_HOOK_LEN:
return m_hookLength;
case Pid::BRACKET_HOOK_POS:
return m_hookPos;
case Pid::BRACKET_RIGHT_SIDE:
return m_rightSide;
default:
break;
}
return Arpeggio::getProperty(propertyId);
}

//---------------------------------------------------------
// setProperty
//---------------------------------------------------------

bool ChordBracket::setProperty(Pid propertyId, const PropertyValue& val)
{
switch (propertyId) {
case Pid::BRACKET_HOOK_LEN:
m_hookLength = val.value<Spatium>();
break;
case Pid::BRACKET_HOOK_POS:
m_hookPos = val.value<DirectionV>();
break;
case Pid::BRACKET_RIGHT_SIDE:
m_rightSide = val.toBool();
break;
default:
if (!Arpeggio::setProperty(propertyId, val)) {
return false;
}
break;
}
triggerLayout();
return true;
}

//---------------------------------------------------------
// propertyDefault
//---------------------------------------------------------

PropertyValue ChordBracket::propertyDefault(Pid propertyId) const
{
switch (propertyId) {
case Pid::BRACKET_HOOK_LEN:
return style().styleS(Sid::chordBracketHookLen);
case Pid::BRACKET_HOOK_POS:
return DirectionV::AUTO; // Both
case Pid::BRACKET_RIGHT_SIDE:
return false;
default:
break;
}
return Arpeggio::propertyDefault(propertyId);
}

void ChordBracket::reset()
{
resetProperty(Pid::BRACKET_HOOK_LEN);
resetProperty(Pid::BRACKET_HOOK_POS);
resetProperty(Pid::BRACKET_RIGHT_SIDE);

Arpeggio::reset();
}
}
56 changes: 56 additions & 0 deletions src/engraving/dom/chordbracket.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-Studio-CLA-applies
*
* MuseScore Studio
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore Limited
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include "arpeggio.h"
#include "engravingitem.h"

namespace mu::engraving {
class ChordBracket final : public Arpeggio
{
OBJECT_ALLOCATOR(engraving, ChordBracket)
DECLARE_CLASSOF(ElementType::CHORD_BRACKET)

public:
ChordBracket* clone() const override { return new ChordBracket(*this); }

PropertyValue getProperty(Pid propertyId) const override;
bool setProperty(Pid propertyId, const PropertyValue&) override;
PropertyValue propertyDefault(Pid propertyId) const override;

void reset() override;

Spatium hookLength() const { return m_hookLength; }
DirectionV hookPos() const { return m_hookPos; }
bool rightSide() const { return m_rightSide; }

private:
friend class Factory;

ChordBracket(Chord* parent);

Spatium m_hookLength = Spatium(1);
DirectionV m_hookPos = DirectionV::AUTO; // AUTO == both up and down hooks
bool m_rightSide = false;
};
}
2 changes: 2 additions & 0 deletions src/engraving/dom/dom.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ set(DOM_SRC
${CMAKE_CURRENT_LIST_DIR}/check.cpp
${CMAKE_CURRENT_LIST_DIR}/chord.cpp
${CMAKE_CURRENT_LIST_DIR}/chord.h
${CMAKE_CURRENT_LIST_DIR}/chordbracket.cpp
${CMAKE_CURRENT_LIST_DIR}/chordbracket.h
${CMAKE_CURRENT_LIST_DIR}/chordline.cpp
${CMAKE_CURRENT_LIST_DIR}/chordline.h
${CMAKE_CURRENT_LIST_DIR}/chordlist.cpp
Expand Down
16 changes: 15 additions & 1 deletion src/engraving/dom/engravingobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Bracket;
class BracketItem;
class Breath;
class Chord;
class ChordBracket;
class ChordLine;
class ChordRest;
class Clef;
Expand Down Expand Up @@ -427,6 +428,7 @@ class EngravingObject
CONVERT(FiguredBassItem, FIGURED_BASS_ITEM)
CONVERT(StaffState, STAFF_STATE)
CONVERT(Arpeggio, ARPEGGIO)
CONVERT(ChordBracket, CHORD_BRACKET)
CONVERT(Image, IMAGE)
CONVERT(ChordLine, CHORDLINE)
CONVERT(FretDiagram, FRET_DIAGRAM)
Expand Down Expand Up @@ -612,6 +614,18 @@ static inline const Articulation* toArticulation(const EngravingObject* e)
return (const Articulation*)e;
}

static inline Arpeggio* toArpeggio(EngravingObject* e)
{
assert(!e || e->isArpeggio() || e->isChordBracket());
return (Arpeggio*)e;
}

static inline const Arpeggio* toArpeggio(const EngravingObject* e)
{
assert(!e || e->isArpeggio() || e->isChordBracket());
return (const Arpeggio*)e;
}

#define CONVERT(a) \
static inline a* to##a(EngravingObject * e) { assert(!e || e->is##a()); return (a*)e; } \
static inline const a* to##a(const EngravingObject * e) { assert(!e || e->is##a()); return (const a*)e; }
Expand Down Expand Up @@ -739,7 +753,7 @@ CONVERT(LyricsLineSegment)
CONVERT(FiguredBass)
CONVERT(FiguredBassItem)
CONVERT(StaffState)
CONVERT(Arpeggio)
CONVERT(ChordBracket)
CONVERT(Image)
CONVERT(ChordLine)
CONVERT(FretDiagram)
Expand Down
5 changes: 5 additions & 0 deletions src/engraving/dom/factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "bracket.h"
#include "breath.h"
#include "chord.h"
#include "chordbracket.h"
#include "chordline.h"
#include "capo.h"
#include "deadslapped.h"
Expand Down Expand Up @@ -162,6 +163,7 @@ EngravingItem* Factory::doCreateItem(ElementType type, EngravingItem* parent)
case ElementType::BAR_LINE: return new BarLine(parent->isSegment() ? toSegment(parent) : dummy->segment());
case ElementType::SYSTEM_DIVIDER: return new SystemDivider(parent->isSystem() ? toSystem(parent) : dummy->system());
case ElementType::ARPEGGIO: return new Arpeggio(parent->isChord() ? toChord(parent) : dummy->chord());
case ElementType::CHORD_BRACKET: return new ChordBracket(parent->isChord() ? toChord(parent) : dummy->chord());
case ElementType::BREATH: return new Breath(parent->isSegment() ? toSegment(parent) : dummy->segment());
case ElementType::GLISSANDO: return new Glissando(parent);
case ElementType::BRACKET: return new Bracket(parent);
Expand Down Expand Up @@ -349,6 +351,9 @@ MAKE_ITEM_IMPL(Ambitus, Segment)
CREATE_ITEM_IMPL(Arpeggio, ElementType::ARPEGGIO, Chord, isAccessibleEnabled)
MAKE_ITEM_IMPL(Arpeggio, Chord)

CREATE_ITEM_IMPL(ChordBracket, ElementType::CHORD_BRACKET, Chord, isAccessibleEnabled)
MAKE_ITEM_IMPL(ChordBracket, Chord)

CREATE_ITEM_IMPL(Articulation, ElementType::ARTICULATION, ChordRest, isAccessibleEnabled)
MAKE_ITEM_IMPL(Articulation, ChordRest)

Expand Down
3 changes: 3 additions & 0 deletions src/engraving/dom/factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class Factory
static Arpeggio* createArpeggio(Chord* parent, bool isAccessibleEnabled = true);
static std::shared_ptr<Arpeggio> makeArpeggio(Chord* parent);

static ChordBracket* createChordBracket(Chord* parent, bool isAccessibleEnabled = true);
static std::shared_ptr<ChordBracket> makeChordBracket(Chord* parent);

static Articulation* createArticulation(ChordRest* parent, bool isAccessibleEnabled = true);
static std::shared_ptr<Articulation> makeArticulation(ChordRest* parent);

Expand Down
1 change: 1 addition & 0 deletions src/engraving/dom/note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,7 @@ bool Note::acceptDrop(EditData& data) const
case ElementType::TEXT:
case ElementType::ACCIDENTAL:
case ElementType::ARPEGGIO:
case ElementType::CHORD_BRACKET:
case ElementType::NOTEHEAD:
case ElementType::NOTE:
case ElementType::TREMOLO_SINGLECHORD:
Expand Down
5 changes: 5 additions & 0 deletions src/engraving/dom/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,11 @@ static constexpr PropertyMetaData propertyList[] = {

{ Pid::ARPEGGIO_SPAN, P_TYPE::INT, PropertyGroup::NONE, true, "arpeggioSpan", QT_TRANSLATE_NOOP("engraving/propertyName", "arpeggio span") },

{ Pid::BRACKET_HOOK_LEN, P_TYPE::SPATIUM, PropertyGroup::APPEARANCE, true, "bracketHookLen", QT_TRANSLATE_NOOP("engraving/propertyName", "bracket hook length") },
{ Pid::BRACKET_HOOK_POS, P_TYPE::DIRECTION_V, PropertyGroup::NONE, true, "bracketHookPos", QT_TRANSLATE_NOOP("engraving/propertyName", "bracket hook position") },
{ Pid::BRACKET_RIGHT_SIDE, P_TYPE::BOOL, PropertyGroup::NONE, true, "bracketRightSide", QT_TRANSLATE_NOOP("engraving/propertyName", "bracket right side") },


{ Pid::BEND_TYPE, P_TYPE::INT, PropertyGroup::APPEARANCE, true, "bendType", QT_TRANSLATE_NOOP("engraving/propertyName", "bend type") },
{ Pid::BEND_CURVE, P_TYPE::PITCH_VALUES, PropertyGroup::APPEARANCE, true, "bendCurve", QT_TRANSLATE_NOOP("engraving/propertyName", "bend curve") },
{ Pid::BEND_VERTEX_OFF, P_TYPE::POINT, PropertyGroup::POSITION , false, "bendVertexOffset", QT_TRANSLATE_NOOP("engraving/propertyName", "bend vertex offset") },
Expand Down
4 changes: 4 additions & 0 deletions src/engraving/dom/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ enum class Pid : short {

ARPEGGIO_SPAN,

BRACKET_HOOK_LEN,
BRACKET_HOOK_POS,
BRACKET_RIGHT_SIDE,

BEND_TYPE,
BEND_CURVE,
BEND_VERTEX_OFF,
Expand Down
Loading
Loading