From 508055092ac5960fae0c74225cebe76761784a00 Mon Sep 17 00:00:00 2001 From: "J.G" Date: Mon, 30 Sep 2024 03:23:27 +0000 Subject: [PATCH] [Adv. Preference] Octave preference for next note-entry position (default is bottom note of chord) More useful when building chords downwards, or just personal preference --- global/settings/types/preferencekeys.h | 1 + libmscore/cmd.cpp | 18 +++++++++--------- libmscore/mscore.cpp | 3 +++ libmscore/mscore.h | 3 +++ mscore/musescore.cpp | 2 ++ mscore/preferences.cpp | 1 + 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/global/settings/types/preferencekeys.h b/global/settings/types/preferencekeys.h index 5a5c00fb4a34b..37e23d9aaf301 100644 --- a/global/settings/types/preferencekeys.h +++ b/global/settings/types/preferencekeys.h @@ -124,6 +124,7 @@ #define PREF_SCORE_NOTE_DEFAULTPLAYDURATION "score/note/defaultPlayDuration" #define PREF_SCORE_NOTE_WARNPITCHRANGE "score/note/warnPitchRange" #define PREF_SCORE_NOTE_INPUT_DISABLE_MOUSE_INPUT "ui/score/noteEntry/disableMouseEntry" +#define PREF_SCORE_NOTE_INPUT_OCTAVE_TENDENCY "ui/score/noteEntry/octaveTendencyIsTopNote" #define PREF_SCORE_STYLE_DEFAULTSTYLEFILE "score/style/defaultStyleFile" #define PREF_SCORE_STYLE_PARTSTYLEFILE "score/style/partStyleFile" #define PREF_UI_CANVAS_BG_USECOLOR "ui/canvas/background/useColor" diff --git a/libmscore/cmd.cpp b/libmscore/cmd.cpp index 4cd13966133d5..2d5535cea7367 100644 --- a/libmscore/cmd.cpp +++ b/libmscore/cmd.cpp @@ -4107,9 +4107,9 @@ void Score::cmdAddPitch(const EditData& ed, int note, bool addFlag, bool insert) if (seg->isChordRestType()) { Element* p = seg->element(is.track()); if (p && p->isChord()) { - Note* n = toChord(p)->downNote(); + auto note = useUpNote ? toChord(p)->upNote() : toChord(p)->downNote(); // forget any accidental and/or adjustment due to key signature - curPitch = n->epitch() - static_cast(tpc2alter(n->tpc())); + curPitch = note->epitch() - static_cast(tpc2alter(note->tpc())); break; } } @@ -4469,13 +4469,13 @@ void Score::cmd(const QAction* a, EditData& ed) }; static const std::vector cmdList { - { "note-c", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 0, false, false); }}, - { "note-d", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 1, false, false); }}, - { "note-e", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 2, false, false); }}, - { "note-f", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 3, false, false); }}, - { "note-g", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 4, false, false); }}, - { "note-a", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 5, false, false); }}, - { "note-b", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 6, false, false); }}, + { "note-c", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 0, false, false, MScore::noteInputOctaveTendencyIsTopNote); }}, + { "note-d", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 1, false, false, MScore::noteInputOctaveTendencyIsTopNote); }}, + { "note-e", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 2, false, false, MScore::noteInputOctaveTendencyIsTopNote); }}, + { "note-f", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 3, false, false, MScore::noteInputOctaveTendencyIsTopNote); }}, + { "note-g", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 4, false, false, MScore::noteInputOctaveTendencyIsTopNote); }}, + { "note-a", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 5, false, false, MScore::noteInputOctaveTendencyIsTopNote); }}, + { "note-b", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 6, false, false, MScore::noteInputOctaveTendencyIsTopNote); }}, { "chord-c", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 0, true, false); }}, { "chord-d", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 1, true, false); }}, { "chord-e", [](Score* cs, EditData& ed){ cs->cmdAddPitch(ed, 2, true, false); }}, diff --git a/libmscore/mscore.cpp b/libmscore/mscore.cpp index 67a97d4b39426..465e6facb8b36 100644 --- a/libmscore/mscore.cpp +++ b/libmscore/mscore.cpp @@ -90,6 +90,9 @@ qreal MScore::horizontalPageGapOdd = 50.0; QColor MScore::selectColor[VOICES]; QColor MScore::cursorColor; QColor MScore::defaultColor; + +bool MScore::noteInputOctaveTendencyIsTopNote; + QColor MScore::layoutBreakColor; QColor MScore::frameMarginColor; QColor MScore::bgColor; diff --git a/libmscore/mscore.h b/libmscore/mscore.h index 61142a6eb15ef..83f5bb8a882cf 100644 --- a/libmscore/mscore.h +++ b/libmscore/mscore.h @@ -336,6 +336,9 @@ class MScore { static QColor selectColor[VOICES]; static QColor cursorColor; static QColor defaultColor; + + static bool noteInputOctaveTendencyIsTopNote; + static QColor dropColor; static QColor layoutBreakColor; static QColor frameMarginColor; diff --git a/mscore/musescore.cpp b/mscore/musescore.cpp index 9ccff72637a76..f362ba0564341 100644 --- a/mscore/musescore.cpp +++ b/mscore/musescore.cpp @@ -428,6 +428,8 @@ void updateExternalValuesFromPreferences() { MScore::bgColor = preferences.getColor(PREF_UI_CANVAS_BG_COLOR); MScore::dropColor = preferences.getColor(PREF_UI_SCORE_NOTE_DROPCOLOR); MScore::defaultColor = preferences.getColor(PREF_UI_SCORE_DEFAULTCOLOR); + + MScore::noteInputOctaveTendencyIsTopNote = preferences.getBool(PREF_SCORE_NOTE_INPUT_OCTAVE_TENDENCY); MScore::defaultPlayDuration = preferences.getInt(PREF_SCORE_NOTE_DEFAULTPLAYDURATION); MScore::panPlayback = preferences.getBool(PREF_APP_PLAYBACK_PANPLAYBACK); MScore::harmonyPlayDisableCompatibility = preferences.getBool(PREF_SCORE_HARMONY_PLAY_DISABLE_COMPATIBILITY); diff --git a/mscore/preferences.cpp b/mscore/preferences.cpp index 2087d4d04b2ca..e5fcc7e9e9b94 100644 --- a/mscore/preferences.cpp +++ b/mscore/preferences.cpp @@ -224,6 +224,7 @@ void Preferences::init(bool storeInMemoryOnly) {PREF_SCORE_NOTE_DEFAULTPLAYDURATION, new IntPreference(300 /* ms */, false)}, {PREF_SCORE_NOTE_WARNPITCHRANGE, new BoolPreference(true, false)}, {PREF_SCORE_NOTE_INPUT_DISABLE_MOUSE_INPUT, new BoolPreference(false, true)}, + {PREF_SCORE_NOTE_INPUT_OCTAVE_TENDENCY, new BoolPreference(false, true)}, {PREF_SCORE_STYLE_DEFAULTSTYLEFILE, new StringPreference("", false)}, {PREF_SCORE_STYLE_PARTSTYLEFILE, new StringPreference("", false)}, {PREF_UI_CANVAS_BG_USECOLOR, new BoolPreference(true, false)},