Skip to content

Commit

Permalink
expose minimal support for 3 dots
Browse files Browse the repository at this point in the history
  • Loading branch information
lasconic committed Mar 23, 2017
1 parent 9ca7d0b commit 370e4da
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 3 deletions.
2 changes: 2 additions & 0 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2439,6 +2439,8 @@ void Score::cmd(const QAction* a)
padToggle(Pad::DOT);
else if (cmd == "pad-dotdot")
padToggle(Pad::DOTDOT);
else if (cmd == "pad-dot3")
padToggle(Pad::DOT3);
else if (cmd == "beam-start")
cmdSetBeamMode(Beam::Mode::BEGIN);
else if (cmd == "beam-mid")
Expand Down
6 changes: 5 additions & 1 deletion libmscore/durationtype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ static int getDots(int base, int rest, char* dots)
*dots = *dots + 1;
rest -= base / 4;
}
if (rest >= base / 8) {
*dots = *dots + 1;
rest -= base / 8;
}
if (*dots > MAX_DOTS)
*dots = MAX_DOTS;
return rest;
Expand Down Expand Up @@ -64,7 +68,7 @@ void TDuration::setVal(int ticks)
int t = dt.ticks();
if (ticks / t) {
int remain = ticks % t;
if ((t - remain) < (t/4)) {
if ((t - remain) < (t/POW_MAX_DOTS)) {
_val = DurationType(i - 1);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions libmscore/durationtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TDuration {

public:
TDuration() : _val(DurationType::V_INVALID), _dots(0) {}
TDuration(const Fraction& l, bool truncate = false, int maxDots = 3, DurationType maxType = DurationType::V_LONG);
TDuration(const Fraction& l, bool truncate = false, int maxDots = MAX_DOTS, DurationType maxType = DurationType::V_LONG);
TDuration(const QString&);
TDuration(DurationType t) : _val(t), _dots(0) {}

Expand Down Expand Up @@ -77,7 +77,7 @@ class TDuration {
QString durationTypeUserName() const;
};

QList<TDuration> toDurationList(Fraction l, bool useDots, int maxDots = 3, bool printRestRemains = true);
QList<TDuration> toDurationList(Fraction l, bool useDots, int maxDots = MAX_DOTS, bool printRestRemains = true);
QList<TDuration> toRhythmicDurationList(const Fraction& l, bool isRest, int rtickStart, const TimeSigFrac& nominal, Measure* msr, int maxDots);

bool forceRhythmicSplit(bool isRest, BeatType startBeat, BeatType endBeat, int beatsCrossed, BeatType strongestBeatCrossed, const TimeSigFrac& nominal);
Expand Down
1 change: 1 addition & 0 deletions libmscore/note.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum class SymId;
enum class AccidentalType : char;

static const int MAX_DOTS = 3;
static const int POW_MAX_DOTS = qPow(2,MAX_DOTS);


//---------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2715,6 +2715,15 @@ void Score::padToggle(Pad n)
else
_is.setDots(2);
break;
case Pad::DOT3:
if ((_is.duration().dots() == 3)
|| (_is.duration() == TDuration::DurationType::V_32ND)
|| (_is.duration() == TDuration::DurationType::V_64TH)
|| (_is.duration() == TDuration::DurationType::V_128TH))
_is.setDots(0);
else
_is.setDots(3);
break;
}
if (n >= Pad::NOTE00 && n <= Pad::NOTE128) {
_is.setDots(0);
Expand Down
1 change: 1 addition & 0 deletions libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ enum class Pad : char {
REST,
DOT,
DOTDOT,
DOT3
};

//---------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions mscore/keyb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,11 @@ void MuseScore::updateInputState(Score* score)
getAction("pad-rest")->setChecked(is.rest());
getAction("pad-dot")->setChecked(is.duration().dots() == 1);
getAction("pad-dotdot")->setChecked(is.duration().dots() == 2);
getAction("pad-dot3")->setChecked(is.duration().dots() == 3);
if ((mscore->state() & STATE_NORMAL) | (mscore->state() & STATE_NOTE_ENTRY)) {
getAction("pad-dot")->setEnabled(true);
getAction("pad-dotdot")->setEnabled(true);
getAction("pad-dot3")->setEnabled(true);
}
switch (is.duration().type()) {
case TDuration::DurationType::V_128TH:
Expand All @@ -344,6 +346,9 @@ void MuseScore::updateInputState(Score* score)
case TDuration::DurationType::V_64TH:
getAction("pad-dotdot")->setChecked(false);
getAction("pad-dotdot")->setEnabled(false);
case TDuration::DurationType::V_32ND:
getAction("pad-dot3")->setChecked(false);
getAction("pad-dot3")->setEnabled(false);
break;
default:
break;
Expand Down
11 changes: 11 additions & 0 deletions mscore/shortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,17 @@ Shortcut Shortcut::_sc[] = {
Qt::WindowShortcut,
ShortcutFlags::A_CMD | ShortcutFlags::A_CHECKABLE
},
{
MsWidget::SCORE_TAB,
STATE_NORMAL | STATE_NOTE_ENTRY,
"pad-dot3",
QT_TRANSLATE_NOOP("action","Triple Augmentation Dot"),
QT_TRANSLATE_NOOP("action","Note duration: Triple augmentation dot"),
QT_TRANSLATE_NOOP("action","Triple augmentation dot"),
Icons::Invalid_ICON,
Qt::WindowShortcut,
ShortcutFlags::A_CMD | ShortcutFlags::A_CHECKABLE
},
{
MsWidget::SCORE_TAB,
STATE_NORMAL | STATE_NOTE_ENTRY,
Expand Down

0 comments on commit 370e4da

Please sign in to comment.