Skip to content

Commit 4d34407

Browse files
committed
Design pass #1
- Disable "Text" inspector panel when only "pure" dynamics is selected - Move "Above - below" selector to Dynamics panel - Turn "Center on dynamics - Use text centering" button group into "Center on notehead" checkbox (defaults to true) - General UI improvements in inspector panel for Dynamics
1 parent 1ec7d60 commit 4d34407

File tree

18 files changed

+133
-103
lines changed

18 files changed

+133
-103
lines changed

src/engraving/libmscore/dynamic.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static const ElementStyle dynamicsStyle {
117117
{ Sid::dynamicsMinDistance, Pid::MIN_DISTANCE },
118118
{ Sid::avoidBarLines, Pid::AVOID_BARLINES },
119119
{ Sid::dynamicsSize, Pid::DYNAMICS_SIZE },
120-
{ Sid::useTextAlignment, Pid::USE_TEXT_ALIGNMENT },
120+
{ Sid::centerOnNotehead, Pid::CENTER_ON_NOTEHEAD },
121121
};
122122

123123
//---------------------------------------------------------
@@ -145,7 +145,7 @@ Dynamic::Dynamic(const Dynamic& d)
145145
_velChangeSpeed = d._velChangeSpeed;
146146
_avoidBarLines = d._avoidBarLines;
147147
_dynamicsSize = d._dynamicsSize;
148-
_useTextAlignment = d._useTextAlignment;
148+
_centerOnNotehead = d._centerOnNotehead;
149149
}
150150

151151
//---------------------------------------------------------
@@ -253,8 +253,7 @@ void Dynamic::write(XmlWriter& xml) const
253253
writeProperty(xml, Pid::VELO_CHANGE_SPEED);
254254
}
255255

256-
String dynamicTypeString = String::fromUtf8(dynList[int(_dynamicType)].text);
257-
bool writeText = xmlText() != dynamicTypeString;
256+
bool writeText = hasCustomText();
258257
TextBase::writeProperties(xml, writeText);
259258
xml.endElement();
260259
}
@@ -278,7 +277,7 @@ void Dynamic::layout()
278277
TextBase::layout();
279278

280279
Segment* s = segment();
281-
if (!s || (_useTextAlignment && align().horizontal == AlignH::LEFT)) {
280+
if (!s || (!_centerOnNotehead && align().horizontal == AlignH::LEFT)) {
282281
return;
283282
}
284283

@@ -300,14 +299,14 @@ void Dynamic::layout()
300299
}
301300

302301
Chord* chord = toChord(itemToAlign);
303-
bool centerOnNote = !_useTextAlignment || (_useTextAlignment && align().horizontal == AlignH::HCENTER);
302+
bool centerOnNote = _centerOnNotehead || (!_centerOnNotehead && align().horizontal == AlignH::HCENTER);
304303

305304
// Move to center of notehead width
306305
Note* note = chord->notes().at(0);
307306
double noteHeadWidth = note->headWidth();
308307
movePosX(noteHeadWidth * (centerOnNote ? 0.5 : 1));
309308

310-
if (_useTextAlignment) {
309+
if (!_centerOnNotehead) {
311310
return;
312311
}
313312

@@ -328,7 +327,7 @@ void Dynamic::layout()
328327

329328
double Dynamic::customTextOffset()
330329
{
331-
if (_useTextAlignment || _dynamicType == DynamicType::OTHER) {
330+
if (!_centerOnNotehead || _dynamicType == DynamicType::OTHER) {
332331
return 0.0;
333332
}
334333

@@ -657,8 +656,8 @@ PropertyValue Dynamic::getProperty(Pid propertyId) const
657656
return avoidBarLines();
658657
case Pid::DYNAMICS_SIZE:
659658
return _dynamicsSize;
660-
case Pid::USE_TEXT_ALIGNMENT:
661-
return _useTextAlignment;
659+
case Pid::CENTER_ON_NOTEHEAD:
660+
return _centerOnNotehead;
662661
default:
663662
return TextBase::getProperty(propertyId);
664663
}
@@ -697,8 +696,8 @@ bool Dynamic::setProperty(Pid propertyId, const PropertyValue& v)
697696
case Pid::DYNAMICS_SIZE:
698697
_dynamicsSize = v.toDouble();
699698
break;
700-
case Pid::USE_TEXT_ALIGNMENT:
701-
_useTextAlignment = v.toBool();
699+
case Pid::CENTER_ON_NOTEHEAD:
700+
_centerOnNotehead = v.toBool();
702701
break;
703702
default:
704703
if (!TextBase::setProperty(propertyId, v)) {

src/engraving/libmscore/dynamic.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Dynamic final : public TextBase
5252

5353
M_PROPERTY(bool, avoidBarLines, setAvoidBarLines)
5454
M_PROPERTY(double, dynamicsSize, setDynamicsSize)
55-
M_PROPERTY(bool, useTextAlignment, setUseTextAlignment)
55+
M_PROPERTY(bool, centerOnNotehead, setCenterOnNotehead)
5656

5757
mutable mu::PointF dragOffset;
5858
int _velocity; // associated midi velocity 0-127
@@ -114,8 +114,10 @@ class Dynamic final : public TextBase
114114
void manageBarlineCollisions();
115115

116116
static String dynamicText(DynamicType t);
117+
bool hasCustomText() const { return dynamicText(_dynamicType) != xmlText(); }
117118

118119
void setSnappedExpression(Expression* e) { _snappedExpression = e; }
120+
Expression* snappedExpression() const { return _snappedExpression; }
119121

120122
bool acceptDrop(EditData& ed) const override;
121123
EngravingItem* drop(EditData& ed) override;

src/engraving/libmscore/expression.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class Expression final : public TextBase
3333
PropertyValue getProperty(Pid propertyId) const override;
3434
bool setProperty(Pid propertyId, const PropertyValue& v) override;
3535
void mapPropertiesFromOldExpressions(StaffText* staffText);
36+
37+
Dynamic* snappedDynamic() const { return _snappedDynamic; }
3638
};
3739
} // namespace mu::engraving
3840
#endif // EXPRESSION_H

src/engraving/libmscore/property.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ static constexpr PropertyMetaData propertyList[] = {
344344

345345
{ Pid::AVOID_BARLINES, false, "avoidBarLines", P_TYPE::BOOL, DUMMY_QT_TR_NOOP("propertyName", "avoid bar lines") },
346346
{ Pid::DYNAMICS_SIZE, false, "dynamicsSize", P_TYPE::REAL, DUMMY_QT_TR_NOOP("propertyName", "dynamic size") },
347-
{ Pid::USE_TEXT_ALIGNMENT, false, "useTextAlignment", P_TYPE::BOOL, DUMMY_QT_TR_NOOP("propertyName", "use text alignment") },
347+
{ Pid::CENTER_ON_NOTEHEAD, false, "centerOnNotehead", P_TYPE::BOOL, DUMMY_QT_TR_NOOP("propertyName", "use text alignment") },
348348
{ Pid::SNAP_TO_DYNAMICS, false, "snapToDynamics", P_TYPE::BOOL, DUMMY_QT_TR_NOOP("propertyName", "snap expression") },
349349

350350
{ Pid::POS_ABOVE, false, "posAbove", P_TYPE::MILLIMETRE, DUMMY_QT_TR_NOOP("propertyName", "position above") },

src/engraving/libmscore/property.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ enum class Pid {
353353

354354
AVOID_BARLINES, // meant for Dynamics
355355
DYNAMICS_SIZE,
356-
USE_TEXT_ALIGNMENT,
356+
CENTER_ON_NOTEHEAD,
357357
SNAP_TO_DYNAMICS,
358358

359359
POS_ABOVE,

src/engraving/libmscore/textbase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ void TextBlock::layout(TextBase* t)
980980

981981
double rx = 0;
982982
AlignH alignH = t->align().horizontal;
983-
bool dynamicAlwaysCentered = t->isDynamic() && !t->getProperty(Pid::USE_TEXT_ALIGNMENT).toBool();
983+
bool dynamicAlwaysCentered = t->isDynamic() && !t->getProperty(Pid::CENTER_ON_NOTEHEAD).toBool();
984984

985985
if (alignH == AlignH::HCENTER || dynamicAlwaysCentered) {
986986
rx = (layoutWidth - (_bbox.left() + _bbox.right())) * .5;

src/engraving/rw/400/tread.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,8 @@ void TRead::read(Dynamic* d, XmlReader& e, ReadContext& ctx)
517517
readProperty(d, e, ctx, Pid::AVOID_BARLINES);
518518
} else if (tag == "dynamicsSize") {
519519
readProperty(d, e, ctx, Pid::DYNAMICS_SIZE);
520-
} else if (tag == "useTextAlignment") {
521-
readProperty(d, e, ctx, Pid::USE_TEXT_ALIGNMENT);
520+
} else if (tag == "centerOnNotehead") {
521+
readProperty(d, e, ctx, Pid::CENTER_ON_NOTEHEAD);
522522
} else if (!readProperties(static_cast<TextBase*>(d), e, ctx)) {
523523
e.unknown();
524524
}

src/engraving/style/styledef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
635635
{ Sid::dynamicsPosBelow, "dynamicsPosBelow", PointF(.0, 2.5) },
636636
{ Sid::avoidBarLines, "avoidBarLines", true },
637637
{ Sid::snapToDynamics, "snapToDynamics", true },
638-
{ Sid::useTextAlignment, "useTextAlignment", false },
638+
{ Sid::centerOnNotehead, "centerOnNotehead", true },
639639
{ Sid::dynamicsMinDistance, "dynamicsMinDistance", Spatium(0.5) },
640640
{ Sid::autoplaceVerticalAlignRange, "autoplaceVerticalAlignRange", int(VerticalAlignRange::SYSTEM) },
641641

src/engraving/style/styledef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ enum class Sid {
648648
dynamicsPosBelow,
649649
avoidBarLines,
650650
snapToDynamics,
651-
useTextAlignment,
651+
centerOnNotehead,
652652
dynamicsMinDistance,
653653
autoplaceVerticalAlignRange,
654654

src/engraving/tests/dynamic_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ TEST_F(Engraving_DynamicTests, test1)
131131
d = static_cast<Dynamic*>(ScoreRW::writeReadElement(dynamic));
132132
EXPECT_EQ(d->dynamicsSize(), 0.5);
133133

134-
dynamic->setProperty(Pid::USE_TEXT_ALIGNMENT, true);
135-
dynamic->setPropertyFlags(Pid::USE_TEXT_ALIGNMENT, PropertyFlags::UNSTYLED);
134+
dynamic->setProperty(Pid::CENTER_ON_NOTEHEAD, true);
135+
dynamic->setPropertyFlags(Pid::CENTER_ON_NOTEHEAD, PropertyFlags::UNSTYLED);
136136
d = static_cast<Dynamic*>(ScoreRW::writeReadElement(dynamic));
137-
EXPECT_EQ(d->useTextAlignment(), true);
137+
EXPECT_EQ(d->centerOnNotehead(), true);
138138

139139
delete d;
140140
}

src/inspector/models/abstractinspectormodel.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2121
*/
2222
#include "abstractinspectormodel.h"
23+
#include "libmscore/dynamic.h"
2324

2425
#include "types/texttypes.h"
2526

@@ -215,7 +216,25 @@ InspectorModelTypeSet AbstractInspectorModel::modelTypesByElementKeys(const Elem
215216
return types;
216217
}
217218

218-
InspectorSectionTypeSet AbstractInspectorModel::sectionTypesByElementKeys(const ElementKeySet& elementKeySet, bool isRange)
219+
static bool isPureDynamics(const QList<mu::engraving::EngravingItem*>& selectedElementList)
220+
{
221+
for (EngravingItem* item : selectedElementList) {
222+
if (!item->isTextBase()) {
223+
continue;
224+
}
225+
if (!item->isDynamic()) {
226+
return false;
227+
}
228+
Dynamic* dynamic = toDynamic(item);
229+
if (dynamic->hasCustomText()) {
230+
return false;
231+
}
232+
}
233+
return true;
234+
}
235+
236+
InspectorSectionTypeSet AbstractInspectorModel::sectionTypesByElementKeys(const ElementKeySet& elementKeySet, bool isRange,
237+
const QList<mu::engraving::EngravingItem*>& selectedElementList)
219238
{
220239
InspectorSectionTypeSet types;
221240

@@ -225,7 +244,8 @@ InspectorSectionTypeSet AbstractInspectorModel::sectionTypesByElementKeys(const
225244
types << InspectorSectionType::SECTION_NOTATION;
226245
}
227246

228-
if (TEXT_ELEMENT_TYPES.contains(key.type)) {
247+
// Don't show the "Text" inspector panel for "pure" dynamics (i.e. without custom text)
248+
if (TEXT_ELEMENT_TYPES.contains(key.type) && !isPureDynamics(selectedElementList)) {
229249
types << InspectorSectionType::SECTION_TEXT;
230250
}
231251

src/inspector/models/abstractinspectormodel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ class AbstractInspectorModel : public QObject, public async::Asyncable
140140

141141
static InspectorModelType modelTypeByElementKey(const ElementKey& elementKey);
142142
static QSet<InspectorModelType> modelTypesByElementKeys(const ElementKeySet& elementKeySet);
143-
static QSet<InspectorSectionType> sectionTypesByElementKeys(const ElementKeySet& elementKeySet, bool isRange);
143+
static QSet<InspectorSectionType> sectionTypesByElementKeys(const ElementKeySet& elementKeySet, bool isRange,
144+
const QList<mu::engraving::EngravingItem*>& selectedElementList = {});
144145

145146
virtual bool isEmpty() const;
146147

src/inspector/models/inspectorlistmodel.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ InspectorListModel::InspectorListModel(QObject* parent)
4747
});
4848
}
4949

50-
void InspectorListModel::buildModelsForSelectedElements(const ElementKeySet& selectedElementKeySet, bool isRangeSelection)
50+
void InspectorListModel::buildModelsForSelectedElements(const ElementKeySet& selectedElementKeySet, bool isRangeSelection,
51+
const QList<mu::engraving::EngravingItem*>& selectedElementList)
5152
{
5253
removeUnusedModels(selectedElementKeySet, isRangeSelection);
5354

5455
InspectorSectionTypeSet buildingSectionTypeSet = AbstractInspectorModel::sectionTypesByElementKeys(selectedElementKeySet,
55-
isRangeSelection);
56+
isRangeSelection,
57+
selectedElementList);
5658

5759
createModelsBySectionType(buildingSectionTypeSet.values(), selectedElementKeySet);
5860

@@ -90,7 +92,7 @@ void InspectorListModel::setElementList(const QList<mu::engraving::EngravingItem
9092
newElementKeySet << ElementKey(element->type(), element->subtype());
9193
}
9294

93-
buildModelsForSelectedElements(newElementKeySet, selectionState == SelectionState::RANGE);
95+
buildModelsForSelectedElements(newElementKeySet, selectionState == SelectionState::RANGE, selectedElementList);
9496
}
9597

9698
m_repository->updateElementList(selectedElementList, selectionState);

src/inspector/models/inspectorlistmodel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ class InspectorListModel : public QAbstractListModel, public mu::async::Asyncabl
5858
notation::SelectionState selectionState = notation::SelectionState::NONE);
5959

6060
void buildModelsForEmptySelection();
61-
void buildModelsForSelectedElements(const ElementKeySet& selectedElementKeySet, bool isRangeSelection);
61+
void buildModelsForSelectedElements(const ElementKeySet& selectedElementKeySet, bool isRangeSelection,
62+
const QList<engraving::EngravingItem*>& selectedElementList);
6263

6364
void createModelsBySectionType(const QList<InspectorSectionType>& sectionTypeList, const ElementKeySet& selectedElementKeySet = {});
6465
void removeUnusedModels(const ElementKeySet& newElementKeySet, bool isRangeSelection,

src/inspector/models/notation/dynamics/dynamicsettingsmodel.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ void DynamicsSettingsModel::createProperties()
3939
m_dynamicSize = buildPropertyItem(mu::engraving::Pid::DYNAMICS_SIZE, [this](const mu::engraving::Pid pid, const QVariant& newValue) {
4040
onPropertyValueChanged(pid, newValue.toDouble() / 100);
4141
});
42-
m_useTextAlignment = buildPropertyItem(mu::engraving::Pid::USE_TEXT_ALIGNMENT);
43-
m_snapExpression = buildPropertyItem(mu::engraving::Pid::SNAP_TO_DYNAMICS);
42+
m_centerOnNotehead = buildPropertyItem(mu::engraving::Pid::CENTER_ON_NOTEHEAD);
43+
m_placement = buildPropertyItem(mu::engraving::Pid::PLACEMENT);
4444
}
4545

4646
void DynamicsSettingsModel::requestElements()
@@ -54,16 +54,16 @@ void DynamicsSettingsModel::loadProperties()
5454
loadPropertyItem(m_dynamicSize, [](const QVariant& elementPropertyValue) -> QVariant {
5555
return DataFormatter::roundDouble(elementPropertyValue.toDouble()) * 100;
5656
});
57-
loadPropertyItem(m_useTextAlignment);
58-
loadPropertyItem(m_snapExpression);
57+
loadPropertyItem(m_centerOnNotehead);
58+
loadPropertyItem(m_placement);
5959
}
6060

6161
void DynamicsSettingsModel::resetProperties()
6262
{
6363
m_avoidBarLines->resetToDefault();
6464
m_dynamicSize->resetToDefault();
65-
m_useTextAlignment->resetToDefault();
66-
m_snapExpression->resetToDefault();
65+
m_centerOnNotehead->resetToDefault();
66+
m_placement->resetToDefault();
6767
}
6868

6969
PropertyItem* DynamicsSettingsModel::avoidBarLines() const
@@ -76,12 +76,12 @@ PropertyItem* DynamicsSettingsModel::dynamicSize() const
7676
return m_dynamicSize;
7777
}
7878

79-
PropertyItem* DynamicsSettingsModel::useTextAlignment() const
79+
PropertyItem* DynamicsSettingsModel::centerOnNotehead() const
8080
{
81-
return m_useTextAlignment;
81+
return m_centerOnNotehead;
8282
}
8383

84-
PropertyItem* DynamicsSettingsModel::snapExpression() const
84+
PropertyItem* DynamicsSettingsModel::placement() const
8585
{
86-
return m_snapExpression;
86+
return m_placement;
8787
}

src/inspector/models/notation/dynamics/dynamicsettingsmodel.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ class DynamicsSettingsModel : public AbstractInspectorModel
3131

3232
Q_PROPERTY(PropertyItem * avoidBarLines READ avoidBarLines CONSTANT)
3333
Q_PROPERTY(PropertyItem * dynamicSize READ dynamicSize CONSTANT)
34-
Q_PROPERTY(PropertyItem * useTextAlignment READ useTextAlignment CONSTANT)
35-
Q_PROPERTY(PropertyItem * snapExpression READ snapExpression CONSTANT)
34+
Q_PROPERTY(PropertyItem * centerOnNotehead READ centerOnNotehead CONSTANT)
35+
Q_PROPERTY(PropertyItem * placement READ placement CONSTANT)
3636

3737
public:
3838
explicit DynamicsSettingsModel(QObject* parent, IElementRepositoryService* repository);
@@ -44,14 +44,14 @@ class DynamicsSettingsModel : public AbstractInspectorModel
4444

4545
PropertyItem* avoidBarLines() const;
4646
PropertyItem* dynamicSize() const;
47-
PropertyItem* useTextAlignment() const;
48-
PropertyItem* snapExpression() const;
47+
PropertyItem* centerOnNotehead() const;
48+
PropertyItem* placement() const;
4949

5050
private:
5151
PropertyItem* m_avoidBarLines = nullptr;
5252
PropertyItem* m_dynamicSize = nullptr;
53-
PropertyItem* m_useTextAlignment = nullptr;
54-
PropertyItem* m_snapExpression = nullptr;
53+
PropertyItem* m_centerOnNotehead = nullptr;
54+
PropertyItem* m_placement = nullptr;
5555
};
5656
}
5757

0 commit comments

Comments
 (0)