Skip to content

Commit

Permalink
[Commands] [Add A-G Below] Referenced at currently selected note
Browse files Browse the repository at this point in the history
  • Loading branch information
worldwideweary committed Sep 30, 2024
1 parent 33f2b19 commit 6b51c64
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 6 deletions.
22 changes: 18 additions & 4 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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); }},
Expand Down
2 changes: 1 addition & 1 deletion libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
51 changes: 50 additions & 1 deletion mscore/shortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "icons.h"
#include "libmscore/xml.h"


namespace Ms {

bool Shortcut::dirty = false;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 6b51c64

Please sign in to comment.