Skip to content

Commit

Permalink
Adding functionality. When Auto-play is active and a section of the f…
Browse files Browse the repository at this point in the history
…ile browser has keyboard focus, the user can use the arrow keys to hear each new sample the select by pressed up or down on the arrow keys.
  • Loading branch information
krismakesstuff committed Oct 9, 2024
1 parent eb51511 commit e2866c3
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 8 deletions.
7 changes: 2 additions & 5 deletions KrumSampler TODO.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
KrumSampler TODO:

- Make files in file browser be able to drop onto Drop Samples Here, auto add to Favorites
- SEEMS TO BE WORKING, Test!
- write more detailed code comments


- show midi note number when hovering over keys
- file browser: when the file is selected, you can use the arrow keys to navigate. But if auto-play is selected and you use the arrow key to change the selected file, the audioPreviewer won't play back the file. The mouseDown callback is where we are triggering the audioPreviewer trigger
- had a dragging module crash after a deleting many modules at once. Crash happened in getModulesDraggedArea()
- not reloading state on first open in ableton
Expand All @@ -16,8 +13,8 @@ KrumSampler TODO:


OPTIMIZATION:
-loading images from binary on module creation, good or bad?

- loading images from binary on module creation, good or bad?
- make loading audio previewer a more encapsulated process. Each callback for each item in the FileBrwoser is using similar if not identical code.

FOR NEXT TIME:
- trigger mode?
Expand Down
65 changes: 65 additions & 0 deletions Source/UI/FileBrowser/KrumFileBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,26 @@ void RecentFilesList::listBoxItemDoubleClicked(int row, const juce::MouseEvent&
}
}

void RecentFilesList::selectedRowsChanged(int lastRowSelected)
{
// we handle clicked items in the itemClicked method, so this is just for the selection made using the keyboard arrows
if (isMouseButtonDown())
{
return;
}

juce::File file{ getFilePath(lastRowSelected) };
if (previewer && !file.isDirectory() && previewer->isAutoPlayActive())
{
if (file != previewer->getCurrentFile())
{
previewer->loadFile(file);
}
previewer->setWantsToPlayFile(true);
}

}


void RecentFilesList::paintListBoxItem(int rowNumber, juce::Graphics& g, int width, int height, bool rowIsSelected)
{
Expand Down Expand Up @@ -308,6 +328,29 @@ void KrumTreeItem::itemDoubleClicked(const juce::MouseEvent& e)
}
}

void KrumTreeItem::itemSelectionChanged(bool isNowSelected)
{
// we handle clicked items in the itemClicked method, so this is just for the selection made using the keyboard arrows
if(parentTreeView->isMouseButtonDown())
{
return;
}


if (isNowSelected && previewer)
{
juce::File file{ getFilePath() };
if (!file.isDirectory() && previewer->isAutoPlayActive())
{
if (file != previewer->getCurrentFile())
{
previewer->loadFile(file);
}

previewer->setWantsToPlayFile(true);
}
}
}

void KrumTreeItem::closeLabelEditor(juce::Label* label)
{
Expand Down Expand Up @@ -2053,6 +2096,28 @@ void FileChooser::goUp()

void FileChooser::selectionChanged()
{
//DBG("Selection Changed");

// we want to filter out selection changes that are caused by the user clicking on the treeview
// this is intended to catch changes made from using the keyboards up and down arrows
if(isMouseButtonDown())
{
return;
}

auto file = getSelectedFile();

if (!file.isDirectory() && previewer.isAutoPlayActive()
&& fileBrowser.doesPreviewerSupport(file.getFileExtension()))
{
if (previewer.getCurrentFile() != file)
{
previewer.loadFile(file);
}

previewer.setWantsToPlayFile(true);
}

}

void FileChooser::fileClicked(const juce::File& file, const juce::MouseEvent& e)
Expand Down
2 changes: 2 additions & 0 deletions Source/UI/FileBrowser/KrumFileBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class KrumTreeItem : public juce::TreeViewItem,

void itemClicked(const juce::MouseEvent& e) override;
void itemDoubleClicked(const juce::MouseEvent& e) override;
void itemSelectionChanged(bool isNowSelected) override;

void closeLabelEditor(juce::Label* label);

Expand Down Expand Up @@ -366,6 +367,7 @@ class RecentFilesList : public juce::ListBoxModel,

void listBoxItemClicked(int row, const juce::MouseEvent& e) override;
void listBoxItemDoubleClicked(int row, const juce::MouseEvent& e) override;
void selectedRowsChanged(int lastRowSelected) override;

void paintListBoxItem(int rowNumber, juce::Graphics& g, int width, int height, bool rowIsSelected) override;

Expand Down
2 changes: 1 addition & 1 deletion Source/UI/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ KrumSamplerAudioProcessorEditor::KrumSamplerAudioProcessorEditor (KrumSamplerAud

//add Presets menu
addAndMakeVisible(presetsComboBox);
presetsComboBox.setTextWhenNothingSelected("Coming Soon!!");
presetsComboBox.setTextWhenNothingSelected("Coming in future update");
presetsComboBox.setColour(juce::ComboBox::ColourIds::backgroundColourId, juce::Colours::transparentBlack);
presetsComboBox.setColour(juce::ComboBox::ColourIds::outlineColourId, juce::Colours::black);
presetsComboBox.setColour(juce::ComboBox::ColourIds::arrowColourId, Colors::getFontColor());
Expand Down
4 changes: 2 additions & 2 deletions Source/UI/PluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ class KrumSamplerAudioProcessorEditor : public juce::AudioProcessorEditor,
InfoPanelDrawableButton collapseBrowserButton { juce::DrawableButton::ButtonStyle::ImageFitted, "Hide Browser", "This will hide the browser and give you more screen real estate when you aren't using the browser anymore"};


InfoPanelComboBox presetsComboBox{"Presets", "COMING SOON!!"};
InfoPanelDrawableButton settingsButton{ juce::DrawableButton::ButtonStyle::ImageFitted, "Global Settings", "COMING SOON!!" };
InfoPanelComboBox presetsComboBox{"Presets", "Coming in future update"};
InfoPanelDrawableButton settingsButton{ juce::DrawableButton::ButtonStyle::ImageFitted, "Global Settings", "Coming in future update" };

juce::ComponentBoundsConstrainer constrainer;

Expand Down

0 comments on commit e2866c3

Please sign in to comment.