Skip to content
Closed
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
35 changes: 35 additions & 0 deletions Source/CartManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,36 @@ void CartManager::programSelected(ProgramListBox *source, int pos) {
}
}

void CartManager::programAutoCopied(ProgramListBox *source, int pos) {

ProgramListBox *otherListBox;

if ( source == activeCart.get() ) {
otherListBox = browserCart.get();
} else {
otherListBox = activeCart.get();
}

int i;
int foundIndex = -1;

for ( i = 0; i < otherListBox->programNames.size(); i++ ) {
if ( otherListBox->programNames[i] == "- " || otherListBox->programNames[i] == " " ) {
foundIndex = i;
break;
}
}

if ( foundIndex < 0 ){
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "Auto Copy", "No free program slot found!");
return;
}

char *sourceSysExPointer = source->getCurrentCart().getRawVoice() + (pos*128);

programDragged(otherListBox, foundIndex, sourceSysExPointer);
}

void CartManager::buttonClicked(juce::Button *buttonThatWasClicked) {
if ( buttonThatWasClicked == closeButton.get() ) {
hideCartridgeManager();
Expand Down Expand Up @@ -306,6 +336,11 @@ void CartManager::buttonClicked(juce::Button *buttonThatWasClicked) {
void CartManager::fileDoubleClicked(const File& file) {
if ( file.isDirectory() )
return;
int rc = AlertWindow::showOkCancelBox(AlertWindow::QuestionIcon, "Load Cartridge",
"This will replace the current cartridge. "
"Are you sure?");
if ( rc == 0 )
return;
mainWindow->loadCart(file);
activeCart->setCartridge(mainWindow->processor->currentCart);
updateCartFilename();
Expand Down
1 change: 1 addition & 0 deletions Source/CartManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class CartManager : public Component, public Button::Listener, public DragAndDr
virtual void programSelected(ProgramListBox *source, int pos) override;
virtual void programRightClicked(ProgramListBox *source, int pos) override;
virtual void programDragged(ProgramListBox *destListBox, int dest, char *packedPgm) override;
virtual void programAutoCopied(ProgramListBox *source, int pos) override;
virtual bool keyPressed(const KeyPress& key, Component* originatingComponent) override;

void initialFocus();
Expand Down
7 changes: 6 additions & 1 deletion Source/ProgramListBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ bool ProgramListBox::keyPressed(const KeyPress &key, Component *originatingCompo
if ( key.isKeyCode(KeyPress::returnKey) ) {
activePgm = programLabel->idx;
if ( activePgm != -1 ) {
listener->programSelected(this, activePgm);
listener->programAutoCopied(this, activePgm);
}
return true;
}
Expand All @@ -108,6 +108,11 @@ bool ProgramListBox::keyPressed(const KeyPress &key, Component *originatingCompo
return false;
}

activePgm = currentIdx;
if ( activePgm != -1 ) {
listener->programSelected(this, activePgm);
}

labels[currentIdx]->grabKeyboardFocus();

repaint();
Expand Down
1 change: 1 addition & 0 deletions Source/ProgramListBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ProgramListBoxListener {
virtual void programSelected(ProgramListBox *source, int pos) = 0;
virtual void programRightClicked(ProgramListBox *source, int pos) = 0;
virtual void programDragged(ProgramListBox *destListBox, int dest, char *packedPgm) = 0;
virtual void programAutoCopied(ProgramListBox *source, int pos) = 0;
};

class ProgramLabel;
Expand Down