Skip to content

Commit 12595c2

Browse files
committed
more option when selecting similar notes
1 parent 03da1d1 commit 12595c2

14 files changed

+497
-46
lines changed

libmscore/chord.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,8 @@ void Chord::write(Xml& xml) const
928928
case NoteType::GRACE32_AFTER:
929929
xml.tagE("grace32after");
930930
break;
931+
default:
932+
break;
931933
}
932934

933935
if (_noStem)

libmscore/glissando.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,11 +530,15 @@ Note* Glissando::guessInitialNote(Chord* chord)
530530
else // no parent or parent is not a chord?
531531
return nullptr;
532532
case NoteType::NORMAL:
533+
{
533534
// if chord has grace notes before, the last one is the previous note
534535
QVector<Chord*>graces = chord->graceNotesBefore();
535536
if (graces.size() > 0)
536537
return graces.last()->upNote();
538+
}
537539
break; // else process to standard case
540+
default:
541+
break;
538542
}
539543

540544
// standard case (NORMAL or grace before chord)
@@ -619,10 +623,14 @@ Note* Glissando::guessFinalNote(Chord* chord)
619623
return nullptr;
620624
break;
621625
case NoteType::NORMAL:
626+
{
622627
// if chord has grace notes after, the first one is the next note
623628
QVector<Chord*>graces = chord->graceNotesAfter();
624629
if (graces.size() > 0)
625630
return graces.first()->upNote();
631+
}
632+
break;
633+
default:
626634
break;
627635
}
628636

libmscore/mscore.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ enum class NoteType : unsigned char {
295295
GRACE32 = 0x10,
296296
GRACE8_AFTER = 0x20,
297297
GRACE16_AFTER = 0x40,
298-
GRACE32_AFTER = 0x80
298+
GRACE32_AFTER = 0x80,
299+
INVALID = 0xFF
299300
};
300301

301302
constexpr NoteType operator| (NoteType t1, NoteType t2) {

libmscore/note.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ enum class AccidentalType : char;
4747

4848
static const int MAX_DOTS = 4;
4949

50+
5051
//---------------------------------------------------------
5152
// @@ NoteHead
5253
//---------------------------------------------------------

libmscore/score.cpp

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2885,19 +2885,9 @@ void Score::collectMatch(void* data, Element* e)
28852885
if (p->type != int(e->type()))
28862886
return;
28872887

2888-
if (p->subtypeValid) {
2889-
// HACK: grace note is different from normal note
2890-
// TODO: this disables the ability to distinguish noteheads in subtype
2888+
if (p->subtypeValid && p->subtype != e->subtype())
2889+
return;
28912890

2892-
if (p->type == int(Element::Type::NOTE)) {
2893-
if (p->subtype != toNote(e)->chord()->isGrace())
2894-
return;
2895-
}
2896-
else {
2897-
if (p->subtype != e->subtype())
2898-
return;
2899-
}
2900-
}
29012891
if ((p->staffStart != -1)
29022892
&& ((p->staffStart > e->staffIdx()) || (p->staffEnd <= e->staffIdx())))
29032893
return;
@@ -2919,6 +2909,30 @@ void Score::collectMatch(void* data, Element* e)
29192909
p->el.append(e);
29202910
}
29212911

2912+
//---------------------------------------------------------
2913+
// collectNoteMatch
2914+
//---------------------------------------------------------
2915+
2916+
void Score::collectNoteMatch(void* data, Element* e)
2917+
{
2918+
NotePattern* p = static_cast<NotePattern*>(data);
2919+
if (!e->isNote())
2920+
return;
2921+
Note* n = toNote(e);
2922+
if (p->type != NoteType::INVALID && p->type != n->noteType())
2923+
return;
2924+
if (p->pitch != -1 && p->pitch != n->pitch())
2925+
return;
2926+
if (p->tpc != Tpc::TPC_INVALID && p->tpc != n->tpc())
2927+
return;
2928+
if (p->notehead != NoteHead::Group::HEAD_INVALID && p->notehead != n->headGroup())
2929+
return;
2930+
if (p->duration.type() != TDuration::DurationType::V_INVALID && p->duration != n->chord()->actualDurationType())
2931+
return;
2932+
p->el.append(n);
2933+
}
2934+
2935+
29222936
//---------------------------------------------------------
29232937
// selectSimilar
29242938
//---------------------------------------------------------

libmscore/score.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@ class Score : public QObject, public ScoreElement {
734734
void selectSimilar(Element* e, bool sameStaff);
735735
void selectSimilarInRange(Element* e);
736736
static void collectMatch(void* data, Element* e);
737+
static void collectNoteMatch(void* data, Element* e);
737738
void deselect(Element* obj);
738739
void deselectAll() { _selection.deselectAll(); }
739740
void updateSelection() { _selection.update(); }

libmscore/select.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#ifndef __SELECT_H__
1414
#define __SELECT_H__
1515

16+
#include "pitchspelling.h"
17+
#include "mscore.h"
18+
#include "durationtype.h"
19+
1620
namespace Ms {
1721

1822
class Score;
@@ -40,6 +44,23 @@ struct ElementPattern {
4044
bool subtypeValid;
4145
};
4246

47+
//---------------------------------------------------------
48+
// NotePattern
49+
//---------------------------------------------------------
50+
51+
struct NotePattern {
52+
QList<Note*> el;
53+
int pitch = -1;
54+
int tpc = Tpc::TPC_INVALID;;
55+
NoteHead::Group notehead = NoteHead::Group::HEAD_INVALID;
56+
TDuration duration = TDuration();
57+
NoteType type = NoteType::INVALID;
58+
int staffStart;
59+
int staffEnd; // exclusive
60+
int voice;
61+
const System* system;
62+
};
63+
4364
//---------------------------------------------------------
4465
// SelState
4566
//---------------------------------------------------------

mscore/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ QT5_WRAP_UI (ui_headers
4242
editstaff.ui timesigproperties.ui
4343
instrwizard.ui timesigwizard.ui newwizard.ui aboutbox.ui aboutmusicxmlbox.ui
4444
transposedialog.ui lineproperties.ui excerptsdialog.ui stafftext.ui tupletdialog.ui
45-
articulation.ui metaedit.ui palette.ui select.ui
45+
articulation.ui metaedit.ui palette.ui selectdialog.ui selectnotedialog.ui
4646
synthcontrol.ui splitstaff.ui cellproperties.ui keyedit.ui selectinstr.ui
4747
fretdprops.ui editstafftype.ui sectionbreak.ui bend.ui tremolobar.ui textproperties.ui
4848
editpitch.ui editstringdata.ui editraster.ui mediadialog.ui textstyledialog.ui albummanager.ui layer.ui
@@ -254,7 +254,7 @@ add_executable ( ${ExecutableName}
254254
articulationprop.cpp textprop.cpp
255255
fretproperties.cpp sectionbreakprop.cpp
256256
bendproperties.cpp tremolobarprop.cpp file.cpp keyb.cpp osc.cpp
257-
layer.cpp selectdialog.cpp propertymenu.cpp shortcut.cpp bb.cpp
257+
layer.cpp selectdialog.cpp selectnotedialog.cpp propertymenu.cpp shortcut.cpp bb.cpp
258258
inspector/inspector.cpp dragelement.cpp svggenerator.cpp
259259
inspector/inspectorBase.cpp inspector/inspectorBeam.cpp masterpalette.cpp
260260
inspector/inspectorGroupElement.cpp dragdrop.cpp inspector/inspectorImage.cpp

mscore/musescore.cpp

Lines changed: 66 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#include "mediadialog.h"
6565
#include "workspace.h"
6666
#include "selectdialog.h"
67+
#include "selectnotedialog.h"
6768
#include "transposedialog.h"
6869
#include "metaedit.h"
6970
#include "inspector/inspector.h"
@@ -4295,42 +4296,77 @@ void MuseScore::selectSimilarInRange(Element* e)
42954296
void MuseScore::selectElementDialog(Element* e)
42964297
{
42974298
Score* score = e->score();
4298-
SelectDialog sd(e, 0);
4299-
if (sd.exec()) {
4300-
ElementPattern pattern;
4301-
sd.setPattern(&pattern);
4302-
4303-
if (sd.isInSelection())
4304-
score->scanElementsInRange(&pattern, Score::collectMatch);
4305-
else
4306-
score->scanElements(&pattern, Score::collectMatch);
4299+
if (e->isNote()) {
4300+
SelectNoteDialog sd(toNote(e), 0);
4301+
if (sd.exec()) {
4302+
NotePattern pattern;
4303+
sd.setPattern(&pattern);
4304+
4305+
if (sd.isInSelection())
4306+
score->scanElementsInRange(&pattern, Score::collectNoteMatch);
4307+
else
4308+
score->scanElements(&pattern, Score::collectNoteMatch);
43074309

4308-
if (sd.doReplace()) {
4309-
score->select(0, SelectType::SINGLE, 0);
4310-
foreach(Element* ee, pattern.el)
4311-
score->select(ee, SelectType::ADD, 0);
4312-
}
4313-
else if (sd.doSubtract()) {
4314-
QList<Element*> sl(score->selection().elements());
4315-
foreach(Element* ee, pattern.el)
4316-
sl.removeOne(ee);
4317-
score->select(0, SelectType::SINGLE, 0);
4318-
foreach(Element* ee, sl)
4319-
score->select(ee, SelectType::ADD, 0);
4320-
}
4321-
else if (sd.doAdd()) {
4322-
QList<Element*> sl(score->selection().elements());
4323-
foreach(Element* ee, pattern.el) {
4324-
if(!sl.contains(ee))
4310+
if (sd.doReplace()) {
4311+
score->select(0, SelectType::SINGLE, 0);
4312+
for (Note* ee : pattern.el)
4313+
score->select(ee, SelectType::ADD, 0);
4314+
}
4315+
else if (sd.doSubtract()) {
4316+
QList<Element*> sl(score->selection().elements());
4317+
for (Note* ee : pattern.el)
4318+
sl.removeOne(ee);
4319+
score->select(0, SelectType::SINGLE, 0);
4320+
for (Element* ee : sl)
43254321
score->select(ee, SelectType::ADD, 0);
43264322
}
4323+
else if (sd.doAdd()) {
4324+
QList<Element*> sl(score->selection().elements());
4325+
for (Note* ee : pattern.el) {
4326+
if(!sl.contains(ee))
4327+
score->select(ee, SelectType::ADD, 0);
4328+
}
4329+
}
43274330
}
4328-
if (score->selectionChanged()) {
4329-
score->setSelectionChanged(false);
4330-
SelState ss = score->selection().state();
4331-
selectionChanged(ss);
4331+
}
4332+
else {
4333+
SelectDialog sd(e, 0);
4334+
if (sd.exec()) {
4335+
ElementPattern pattern;
4336+
sd.setPattern(&pattern);
4337+
4338+
if (sd.isInSelection())
4339+
score->scanElementsInRange(&pattern, Score::collectMatch);
4340+
else
4341+
score->scanElements(&pattern, Score::collectMatch);
4342+
4343+
if (sd.doReplace()) {
4344+
score->select(0, SelectType::SINGLE, 0);
4345+
for (Element* ee : pattern.el)
4346+
score->select(ee, SelectType::ADD, 0);
4347+
}
4348+
else if (sd.doSubtract()) {
4349+
QList<Element*> sl(score->selection().elements());
4350+
for (Element* ee : pattern.el)
4351+
sl.removeOne(ee);
4352+
score->select(0, SelectType::SINGLE, 0);
4353+
for (Element* ee : sl)
4354+
score->select(ee, SelectType::ADD, 0);
4355+
}
4356+
else if (sd.doAdd()) {
4357+
QList<Element*> sl(score->selection().elements());
4358+
for (Element* ee : pattern.el) {
4359+
if(!sl.contains(ee))
4360+
score->select(ee, SelectType::ADD, 0);
4361+
}
4362+
}
43324363
}
43334364
}
4365+
if (score->selectionChanged()) {
4366+
score->setSelectionChanged(false);
4367+
SelState ss = score->selection().state();
4368+
selectionChanged(ss);
4369+
}
43344370
}
43354371

43364372
//---------------------------------------------------------

mscore/selectdialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#ifndef __SELECTDIALOG_H__
2222
#define __SELECTDIALOG_H__
2323

24-
#include "ui_select.h"
24+
#include "ui_selectdialog.h"
2525

2626
namespace Ms {
2727

0 commit comments

Comments
 (0)