Line data Source code
1 : #include "chordbracket.h"
2 :
3 : #include "style/style.h"
4 :
5 : namespace mu::engraving {
6 : static const ElementStyle chordBracketStyle {
7 : { Sid::chordBracketHookLen, Pid::BRACKET_HOOK_LEN },
8 : };
9 :
10 0 : ChordBracket::ChordBracket(DummyParentOr<Chord> parent)
11 0 : : Arpeggio(parent, ElementType::CHORD_BRACKET)
12 : {
13 0 : setArpeggioType(ArpeggioType::BRACKET);
14 :
15 0 : initElementStyle(&chordBracketStyle);
16 0 : }
17 :
18 0 : PropertyValue ChordBracket::getProperty(Pid propertyId) const
19 : {
20 0 : switch (propertyId) {
21 0 : case Pid::BRACKET_HOOK_LEN:
22 0 : return m_hookLength;
23 0 : case Pid::BRACKET_HOOK_POS:
24 0 : return m_hookPos;
25 0 : case Pid::BRACKET_RIGHT_SIDE:
26 0 : return m_rightSide;
27 0 : default:
28 0 : break;
29 : }
30 0 : return Arpeggio::getProperty(propertyId);
31 : }
32 :
33 : //---------------------------------------------------------
34 : // setProperty
35 : //---------------------------------------------------------
36 :
37 0 : bool ChordBracket::setProperty(Pid propertyId, const PropertyValue& val)
38 : {
39 0 : switch (propertyId) {
40 0 : case Pid::BRACKET_HOOK_LEN:
41 0 : m_hookLength = val.value<Spatium>();
42 0 : break;
43 0 : case Pid::BRACKET_HOOK_POS:
44 0 : m_hookPos = val.value<DirectionV>();
45 0 : break;
46 0 : case Pid::BRACKET_RIGHT_SIDE:
47 0 : m_rightSide = val.toBool();
48 0 : break;
49 0 : default:
50 0 : if (!Arpeggio::setProperty(propertyId, val)) {
51 0 : return false;
52 : }
53 0 : break;
54 : }
55 0 : triggerLayout();
56 0 : return true;
57 : }
58 :
59 : //---------------------------------------------------------
60 : // propertyDefault
61 : //---------------------------------------------------------
62 :
63 0 : PropertyValue ChordBracket::propertyDefault(Pid propertyId) const
64 : {
65 0 : switch (propertyId) {
66 0 : case Pid::BRACKET_HOOK_LEN:
67 0 : return style().styleS(Sid::chordBracketHookLen);
68 0 : case Pid::BRACKET_HOOK_POS:
69 0 : return DirectionV::AUTO; // Both
70 0 : case Pid::BRACKET_RIGHT_SIDE:
71 0 : return false;
72 0 : default:
73 0 : break;
74 : }
75 0 : return Arpeggio::propertyDefault(propertyId);
76 : }
77 :
78 0 : void ChordBracket::reset()
79 : {
80 0 : resetProperty(Pid::BRACKET_HOOK_LEN);
81 0 : resetProperty(Pid::BRACKET_HOOK_POS);
82 0 : resetProperty(Pid::BRACKET_RIGHT_SIDE);
83 :
84 0 : Arpeggio::reset();
85 0 : }
86 : }
|