Skip to content
Merged
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
2 changes: 1 addition & 1 deletion projects/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ COMMONFILES := \
View.o ModalView.o FieldView.o UIField.o UIIntField.o \
UIIntVarOffField.o UIIntVarField.o ViewEvent.o I_Action.o\
UITempoField.o UIActionField.o \
MessageBox.o \
MessageBox.o CommandSelectorModal.o \
GrooveView.o UINoteVarField.o UIBigHexVarField.o \
SRPUpdaters.o UIStaticField.o \
Song.o Chain.o Phrase.o Project.o Scale.o \
Expand Down
8 changes: 8 additions & 0 deletions projects/lgpt.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,14 @@
RelativePath="..\sources\Application\Views\ModalDialogs\SelectProjectDialog.h"
>
</File>
<File
RelativePath="..\sources\Application\Views\ModalDialogs\CommandSelectorModal.h"
>
</File>
<File
RelativePath="..\sources\Application\Views\ModalDialogs\CommandSelectorModal.cpp"
>
</File>
</Filter>
</Filter>
<Filter
Expand Down
6 changes: 6 additions & 0 deletions projects/lgpt64.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
73F8437916FF66480061161B /* MidiEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 73F8437316FF66480061161B /* MidiEvent.cpp */; };
73F8437A16FF66480061161B /* MidiInMerger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 73F8437516FF66480061161B /* MidiInMerger.cpp */; };
73F8437E16FF666A0061161B /* RTMidiInDevice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 73F8437C16FF666A0061161B /* RTMidiInDevice.cpp */; };
7F3A46532F9BF9BE0051C795 /* CommandSelectorModal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7F3A46522F9BF9BE0051C795 /* CommandSelectorModal.cpp */; };
7F4C76E42CC62DD200C03703 /* FxPrinter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7F4C76E32CC62DD200C03703 /* FxPrinter.cpp */; };
7FBF05162C932165009B5828 /* FontConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7FBF05142C932165009B5828 /* FontConfig.cpp */; };
87CA0E830F7E0FC4001D6BD0 /* PlayerChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 87CA0E7F0F7E0FC4001D6BD0 /* PlayerChannel.cpp */; };
Expand Down Expand Up @@ -478,6 +479,8 @@
73F8437716FF66480061161B /* MidiMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MidiMessage.h; path = ../../LittleGPTracker/sources/Services/Midi/MidiMessage.h; sourceTree = SOURCE_ROOT; };
73F8437C16FF666A0061161B /* RTMidiInDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RTMidiInDevice.cpp; path = ../../LittleGPTracker/sources/Adapters/RTMidi/RTMidiInDevice.cpp; sourceTree = SOURCE_ROOT; };
73F8437D16FF666A0061161B /* RTMidiInDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RTMidiInDevice.h; path = ../../LittleGPTracker/sources/Adapters/RTMidi/RTMidiInDevice.h; sourceTree = SOURCE_ROOT; };
7F3A46512F9BF9BE0051C795 /* CommandSelectorModal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandSelectorModal.h; path = ../Views/ModalDialogs/CommandSelectorModal.h; sourceTree = "<group>"; };
7F3A46522F9BF9BE0051C795 /* CommandSelectorModal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandSelectorModal.cpp; path = ../Views/ModalDialogs/CommandSelectorModal.cpp; sourceTree = "<group>"; };
7F4C76E22CC62DD200C03703 /* FxPrinter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FxPrinter.h; sourceTree = "<group>"; };
7F4C76E32CC62DD200C03703 /* FxPrinter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FxPrinter.cpp; sourceTree = "<group>"; };
7FBF05142C932165009B5828 /* FontConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontConfig.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -833,6 +836,8 @@
737D11CD0BCE66F000099CB3 /* views */ = {
isa = PBXGroup;
children = (
7F3A46522F9BF9BE0051C795 /* CommandSelectorModal.cpp */,
7F3A46512F9BF9BE0051C795 /* CommandSelectorModal.h */,
87CA0E9D0F7E110D001D6BD0 /* MixerView.cpp */,
87CA0E9E0F7E110D001D6BD0 /* MixerView.h */,
73A4F1160DAB74B1006B1114 /* NullView.cpp */,
Expand Down Expand Up @@ -1616,6 +1621,7 @@
73F8437816FF66480061161B /* MidiChannel.cpp in Sources */,
73F8437916FF66480061161B /* MidiEvent.cpp in Sources */,
73F8437A16FF66480061161B /* MidiInMerger.cpp in Sources */,
7F3A46532F9BF9BE0051C795 /* CommandSelectorModal.cpp in Sources */,
73F8437E16FF666A0061161B /* RTMidiInDevice.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
61 changes: 54 additions & 7 deletions sources/Application/Instruments/CommandList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,54 @@ static FourCC _all[]= {
I_CMD_VOLM
} ;

int CommandList::GetCount() { return sizeof(_all) / sizeof(FourCC); }

FourCC CommandList::GetAt(int index) {
int count = GetCount() ;
if (count <= 0) {
return I_CMD_NONE ;
}
while (index < 0) {
index += count;
}
index %= count;
return _all[index] ;
}

int CommandList::IndexOf(FourCC current) {
for (int i=0;i<GetCount();i++) {
if (_all[i] == current) {
return i;
}
}
return -1;
}

FourCC CommandList::GetNext(FourCC current) {
for (uint i=0;i<sizeof(_all)/sizeof(FourCC)-1;i++) {
if (_all[i]==current) {
return _all[i+1] ;
} ;
} ;
return current ;
// Wrap around: if current is last, return first
if (_all[sizeof(_all)/sizeof(FourCC)-1] == current) {
return _all[0];
}
return _all[0] ;
} ;

FourCC CommandList::GetPrev(FourCC current) {
uint count=sizeof(_all)/sizeof(FourCC) ;
for (uint i=2;i<count;i++) {
if (_all[i]==current) {
return _all[i-1] ;
} ;
} ;
return current ;
for (uint i = 1; i < count; i++) {
if (_all[i]==current) {
return _all[i - 1];
} ;
};
// Wrap around: if current is first, return last
if (_all[0] == current) {
return _all[count - 1];
}
return _all[count-1] ;
} ;

FourCC CommandList::GetNextAlpha(FourCC current) {
Expand Down Expand Up @@ -100,3 +131,19 @@ FourCC CommandList::GetPrevAlpha(FourCC current) {
}
return current ;
} ;

FourCC CommandList::GetFirst() { return _all[0]; }

FourCC CommandList::GetLast() {
uint count = sizeof(_all)/sizeof(FourCC) ;
return _all[count-1] ;
}

bool CommandList::IsFirst(FourCC current) {
return current == _all[0] ;
}

bool CommandList::IsLast(FourCC current) {
uint count = sizeof(_all)/sizeof(FourCC) ;
return current == _all[count-1] ;
}
10 changes: 9 additions & 1 deletion sources/Application/Instruments/CommandList.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ class CommandList {
static FourCC GetNext(FourCC current) ;
static FourCC GetPrev(FourCC current) ;
static FourCC GetNextAlpha(FourCC current) ;
static FourCC GetPrevAlpha(FourCC current) ;};
static FourCC GetPrevAlpha(FourCC current);
static int GetCount() ;
static FourCC GetAt(int index) ;
static int IndexOf(FourCC current) ;
static FourCC GetFirst() ;
static FourCC GetLast() ;
static bool IsFirst(FourCC current) ;
static bool IsLast(FourCC current) ;
};
#endif

76 changes: 76 additions & 0 deletions sources/Application/Views/CommandSelectorCommon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#ifndef _COMMAND_SELECTOR_COMMON_H_
#define _COMMAND_SELECTOR_COMMON_H_

#include "Application/Instruments/CommandList.h"
#include "Application/Views/BaseClasses/View.h"

namespace CommandSelectorCommon {

static const int kColumns = 5;

static const int kCellPitch = 5;
static const int kScreenCenterX = 20;
inline int getPopupInnerWidth() { return kColumns * kCellPitch; }
inline int getPopupStartX() { return kScreenCenterX - (getPopupInnerWidth() / 2); }
inline int getDisplayCount() { return CommandList::GetCount() - 1; }

inline int getRows() {
int count = getDisplayCount();
return (count + kColumns - 1) / kColumns;
}

inline int getPopupStartY(const GUIPoint &anchor) {
int startY = anchor._y + (16 - getRows()) / 2;
if (startY < anchor._y) {
startY = anchor._y;
}
return startY;
}

/*
* Used to not overwrite the popup with the play cursor
*/
inline bool popupContainsPoint(const GUIPoint &anchor, int x, int y) {
int startX = getPopupStartX() - 1;
int endX = getPopupStartX() + getPopupInnerWidth();
int startY = getPopupStartY(anchor) - 4; // Magic number for top border
int endY = getPopupStartY(anchor) + getRows() - 1; // Magic number for bottom border
return x >= startX && x <= endX && y >= startY && y <= endY;
}

inline bool isCommandColumn(int col, int c1, int c2) {
return col == c1 || col == c2;
}

inline bool isCommandColumn(int col, int c1, int c2, int c3) {
return col == c1 || col == c2 || col == c3;
}

inline FourCC *getCommandPointerByCol(int col, int c1, FourCC *p1, int c2,
FourCC *p2) {
if (col == c1) {
return p1;
}
if (col == c2) {
return p2;
}
return 0;
}

inline FourCC *getCommandPointerByCol(int col, int c1, FourCC *p1, int c2,
FourCC *p2, int c3, FourCC *p3) {
if (col == c1) {
return p1;
}
if (col == c2) {
return p2;
}
if (col == c3) {
return p3;
}
return 0;
}

} // namespace CommandSelectorCommon

#endif
Loading
Loading