Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add enharmonic sharp/flat toggle in pattern menu #376

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/tracker/ControlIDs.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ enum
BUTTON_PATTERN_SHRINK = 225,
BUTTON_PATTERN_CAPTURE = 226,
BUTTON_PATTERN_CAPTURE_OVERDUB = 227,
BUTTON_PATTERN_SHARPFLAT = 2271,

STATICTEXT_PATTERN_INDEX = 10400,
STATICTEXT_PATTERN_LENGTH = 10401,
Expand Down Expand Up @@ -333,6 +334,8 @@ enum
BUTTON_ABOUT_SHOWPEAK = 601,
BUTTON_ABOUT_SHOWTIME = 602,
BUTTON_ABOUT_FOLLOWSONG = 603,
// Kind of using Basic listing rules to sandwich SHARPFLAT under
// the button it'll show up under
BUTTON_ABOUT_PROSPECTIVE = 604,
BUTTON_ABOUT_WRAPCURSOR = 605,
BUTTON_ABOUT_LIVESWITCH = 606,
Expand Down
3 changes: 2 additions & 1 deletion src/tracker/PatternEditorControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ PatternEditorControl::PatternEditorControl(pp_int32 id, PPScreen* parentScreen,
patternMenuControl->setSubMenu(true);
patternMenuControl->addEntry("Transpose", MAINMENU_TRANSPOSE);
patternMenuControl->addEntry("Advanced edit", MAINMENU_ADVEDIT);
patternMenuControl->addEntry("Toggle #/b notation", BUTTON_PATTERN_SHARPFLAT);
patternMenuControl->addEntry("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4", -1);
patternMenuControl->addEntry("Render to sample", BUTTON_PATTERN_CAPTURE);
patternMenuControl->addEntry("Render to sample [overdub]", BUTTON_PATTERN_CAPTURE_OVERDUB);


keyboardMenuControl = new PPContextMenu(4, parentScreen, this, PPPoint(0,0), TrackerConfig::colorPatternEditorCursorLine);
keyboardMenuControl->setSubMenu(true);
Expand Down Expand Up @@ -1555,6 +1555,7 @@ void PatternEditorControl::executeMenuCommand(pp_int32 commandId)
case BUTTON_ADD_MINUS:
case BUTTON_PATTERN_CAPTURE:
case BUTTON_PATTERN_CAPTURE_OVERDUB:
case BUTTON_PATTERN_SHARPFLAT:
{
patternEditor->triggerButton(commandId, parentScreen, eventListener);
break;
Expand Down
18 changes: 17 additions & 1 deletion src/tracker/PatternTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "PatternTools.h"
#include "MilkyPlay.h"

static const char* noteNames[12] = {"C-","C#","D-","D#","E-","F-","F#","G-","G#","A-","A#","B-"};
static char* noteNames[12] = {(char*)"C-",(char*)"C#",(char*)"D-",(char*)"D#",(char*)"E-",(char*)"F-",(char*)"F#",(char*)"G-",(char*)"G#",(char*)"A-",(char*)"A#",(char*)"B-"};
static const char hex[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

/*TXMPattern* PatternTools::pattern = NULL;
Expand All @@ -35,6 +35,22 @@ pp_int32 PatternTools::offset = 0;

pp_int32 PatternTools::lockOffset = 0;*/

void PatternTools::switchSharpFlat() {
if (strcmp(noteNames[1], "C#") == 0) {
noteNames[1] = (char *) "Db";
noteNames[3] = (char *) "Eb";
noteNames[6] = (char *) "Gb";
noteNames[8] = (char *) "Ab";
noteNames[10] = (char *) "Bb";
} else {
noteNames[1] = (char *) "C#";
noteNames[3] = (char *) "D#";
noteNames[6] = (char *) "F#";
noteNames[8] = (char *) "G#";
noteNames[10] = (char *) "A#";
}
}

void PatternTools::setPosition(TXMPattern* pattern, pp_uint32 channel, pp_uint32 row)
{
if (channel >= pattern->channum ||
Expand Down
1 change: 1 addition & 0 deletions src/tracker/PatternTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class PatternTools
pattern = src.pattern;
}

static void switchSharpFlat();
void setPosition(TXMPattern* pattern, pp_uint32 channel, pp_uint32 row);
pp_int32 getNote();
void setNote(pp_uint32);
Expand Down
10 changes: 9 additions & 1 deletion src/tracker/Tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ pp_int32 Tracker::handleEvent(PPObject* sender, PPEvent* event)
caughtMouseInUpperLeftCorner = false;
}
#endif
else if (event->getID() == eCommand || event->getID() == eCommandRepeat)
else if (event->getID() == eCommand)
{

switch (reinterpret_cast<PPControl*>(sender)->getID())
Expand Down Expand Up @@ -647,6 +647,14 @@ pp_int32 Tracker::handleEvent(PPObject* sender, PPEvent* event)
break;
}

case BUTTON_PATTERN_SHARPFLAT:
{
if (event->getID() != eCommand)
break;
eventKeyDownBinding_ToggleSharpFlat();
break;
}

case BUTTON_ABOUT_PROSPECTIVE:
{
if (event->getID() != eCommand)
Expand Down
1 change: 1 addition & 0 deletions src/tracker/Tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ class Tracker : public EventListenerInterface
// Some handy shortcuts
void eventKeyDownBinding_ToggleFT2Edit();
void eventKeyDownBinding_ToggleFollowSong();
void eventKeyDownBinding_ToggleSharpFlat();
void eventKeyDownBinding_ToggleProspectiveMode();
void eventKeyDownBinding_ToggleCursorWrapAround();
void eventKeyDownBinding_ToggleLiveSwitch();
Expand Down
6 changes: 6 additions & 0 deletions src/tracker/TrackerKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "ListBox.h"
#include "ListBoxFileBrowser.h"
#include "PatternEditorControl.h"
#include "PatternTools.h"

#include "ControlIDs.h"
#include "TrackerConfig.h"
Expand Down Expand Up @@ -731,6 +732,11 @@ void Tracker::eventKeyDownBinding_ToggleFollowSong()
setFollowSong(!getFollowSong());
}

void Tracker::eventKeyDownBinding_ToggleSharpFlat()
{
PatternTools::switchSharpFlat();
}

void Tracker::eventKeyDownBinding_ToggleProspectiveMode()
{
setProspectiveMode(!getProspectiveMode());
Expand Down