From 6b51c64ed6f0fc7342efd5c7b819aa25fad33739 Mon Sep 17 00:00:00 2001 From: worldwideweary Date: Fri, 26 Aug 2022 22:47:43 -0700 Subject: [PATCH] [Commands] [Add A-G Below] Referenced at currently selected note --- libmscore/cmd.cpp | 22 +++++++++++++++---- libmscore/score.h | 2 +- mscore/shortcut.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 69 insertions(+), 6 deletions(-) diff --git a/libmscore/cmd.cpp b/libmscore/cmd.cpp index 4cd13966133d5..9b6c5429ac43a 100644 --- a/libmscore/cmd.cpp +++ b/libmscore/cmd.cpp @@ -4040,7 +4040,7 @@ void Score::cmdUnsetVisible() // c d e f g a b entered: //--------------------------------------------------------- -void Score::cmdAddPitch(const EditData& ed, int note, bool addFlag, bool insert) +void Score::cmdAddPitch(const EditData& ed, int note, bool addFlag, bool insert, bool useUpNote, bool below) { InputState& is = inputState(); if (is.track() == -1) // invalid state @@ -4088,16 +4088,23 @@ void Score::cmdAddPitch(const EditData& ed, int note, bool addFlag, bool insert) else { static const int tab[] = { 0, 2, 4, 5, 7, 9, 11 }; - // if adding notes, add above the upNote of the current chord Element* el = selection().element(); if (addFlag && el && el->isNote()) { Chord* chord = toNote(el)->chord(); - Note* n = chord->upNote(); + + // if adding notes, add above the upNote of the current chord + // alternatively, if adding tpc downward, base position will be current selected note + (void) useUpNote; + Note* n = below ? toNote(el) : chord->upNote(); + int tpc = n->tpc(); octave = (n->epitch() - int(tpc2alter(tpc))) / PITCH_DELTA_OCTAVE; - if (note <= tpc2step(tpc)) + if (note <= tpc2step(tpc) && !below) octave++; + else if (note >= tpc2step(tpc) && below) + octave--; } + // Observation: this is partial in that it will only work for one element and not on a range else { int curPitch = 60; if (is.segment()) { @@ -4483,6 +4490,13 @@ void Score::cmd(const QAction* a, EditData& ed) { "chord-g", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 4, true, false); }}, { "chord-a", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 5, true, false); }}, { "chord-b", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 6, true, false); }}, + { "chord-c-below", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 0, true, false, false, true); }}, + { "chord-d-below", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 1, true, false, false, true); }}, + { "chord-e-below", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 2, true, false, false, true); }}, + { "chord-f-below", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 3, true, false, false, true); }}, + { "chord-g-below", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 4, true, false, false, true); }}, + { "chord-a-below", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 5, true, false, false, true); }}, + { "chord-b-below", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 6, true, false, false, true); }}, { "insert-c", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 0, false, true); }}, { "insert-d", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 1, false, true); }}, { "insert-e", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 2, false, true); }}, diff --git a/libmscore/score.h b/libmscore/score.h index 27a137df5af5b..5071179a7a778 100644 --- a/libmscore/score.h +++ b/libmscore/score.h @@ -540,7 +540,7 @@ class Score : public QObject, public ScoreElement { void selectAdd(Element* e); void selectRange(Element* e, int staffIdx); - void cmdAddPitch(const EditData&, int note, bool addFlag, bool insert); + void cmdAddPitch(const EditData&, int note, bool addFlag, bool insert, bool useUpNote=false, bool below=false); void cmdAddFret(int fret); void cmdToggleVisible(); diff --git a/mscore/shortcut.cpp b/mscore/shortcut.cpp index fa6efb398ae64..536a9caaa91db 100644 --- a/mscore/shortcut.cpp +++ b/mscore/shortcut.cpp @@ -15,7 +15,6 @@ #include "icons.h" #include "libmscore/xml.h" - namespace Ms { bool Shortcut::dirty = false; @@ -556,6 +555,56 @@ Shortcut Shortcut::_sc[] = { QT_TRANSLATE_NOOP("action","Add G to Chord"), QT_TRANSLATE_NOOP("action","Add note G to chord") }, + { + MsWidget::SCORE_TAB, + STATE_NORMAL | STATE_NOTE_ENTRY_STAFF_PITCHED | STATE_NOTE_ENTRY_STAFF_DRUM, + "chord-a-below", + QT_TRANSLATE_NOOP("action","Add A to Chord (below)"), + QT_TRANSLATE_NOOP("action","Add note A to chord (below)") + }, + { + MsWidget::SCORE_TAB, + STATE_NORMAL | STATE_NOTE_ENTRY_STAFF_PITCHED | STATE_NOTE_ENTRY_STAFF_DRUM, + "chord-b-below", + QT_TRANSLATE_NOOP("action","Add B to Chord (below)"), + QT_TRANSLATE_NOOP("action","Add note B to chord (below)") + }, + + { + MsWidget::SCORE_TAB, + STATE_NORMAL | STATE_NOTE_ENTRY_STAFF_PITCHED | STATE_NOTE_ENTRY_STAFF_DRUM, + "chord-c-below", + QT_TRANSLATE_NOOP("action","Add C to Chord (below)"), + QT_TRANSLATE_NOOP("action","Add note C to chord (below)") + }, + { + MsWidget::SCORE_TAB, + STATE_NORMAL | STATE_NOTE_ENTRY_STAFF_PITCHED | STATE_NOTE_ENTRY_STAFF_DRUM, + "chord-d-below", + QT_TRANSLATE_NOOP("action","Add D to Chord (below)"), + QT_TRANSLATE_NOOP("action","Add note D to chord (below)") + }, + { + MsWidget::SCORE_TAB, + STATE_NORMAL | STATE_NOTE_ENTRY_STAFF_PITCHED | STATE_NOTE_ENTRY_STAFF_DRUM, + "chord-e-below", + QT_TRANSLATE_NOOP("action","Add E to Chord (below)"), + QT_TRANSLATE_NOOP("action","Add note E to chord (below)") + }, + { + MsWidget::SCORE_TAB, + STATE_NORMAL | STATE_NOTE_ENTRY_STAFF_PITCHED | STATE_NOTE_ENTRY_STAFF_DRUM, + "chord-f-below", + QT_TRANSLATE_NOOP("action","Add F to Chord (below)"), + QT_TRANSLATE_NOOP("action","Add note F to chord (below)") + }, + { + MsWidget::SCORE_TAB, + STATE_NORMAL | STATE_NOTE_ENTRY_STAFF_PITCHED | STATE_NOTE_ENTRY_STAFF_DRUM, + "chord-g-below", + QT_TRANSLATE_NOOP("action","Add G to Chord (below)"), + QT_TRANSLATE_NOOP("action","Add note G to chord (below)") + }, { MsWidget::SCORE_TAB, STATE_NORMAL | STATE_NOTE_ENTRY_STAFF_PITCHED | STATE_NOTE_ENTRY_STAFF_DRUM,