diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 328e964..5663002 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -57,13 +57,22 @@ MonoslicerEditor::MonoslicerEditor(MonoslicerProcessor& p) addAndMakeVisible(waveformDisplay); - // Status bar - addAndMakeVisible(statusBar); - statusBar.setText("Build: " GIT_VERSION " (" __DATE__ ", " __TIME__ ")", - juce::dontSendNotification); - statusBar.setColour(juce::Label::textColourId, juce::Colour(0xff666688)); - statusBar.setFont(juce::Font(juce::FontOptions(11.0f))); - statusBar.setJustificationType(juce::Justification::centredRight); + // Status bar labels + fileInfoLabel.setButtonText("No file loaded"); + fileInfoLabel.setColour(juce::TextButton::buttonColourId, juce::Colours::transparentBlack); + fileInfoLabel.setColour(juce::TextButton::textColourOffId, juce::Colour(0xff666688)); + fileInfoLabel.setColour(juce::TextButton::textColourOnId, juce::Colour(0xff88aacc)); + fileInfoLabel.setTooltip("Click to show file in Finder"); + fileInfoLabel.setMouseClickGrabsKeyboardFocus(false); + fileInfoLabel.addListener(this); + addAndMakeVisible(fileInfoLabel); + + addAndMakeVisible(buildInfoLabel); + buildInfoLabel.setText("Build: " GIT_VERSION " (" __DATE__ ", " __TIME__ ")", + juce::dontSendNotification); + buildInfoLabel.setColour(juce::Label::textColourId, juce::Colour(0xff666688)); + buildInfoLabel.setFont(juce::Font(juce::FontOptions(11.0f))); + buildInfoLabel.setJustificationType(juce::Justification::centredRight); // Slice knobs attachSlider(bassSlider, bassLabel, "Bass", "bass", bassAttachment); @@ -209,6 +218,7 @@ MonoslicerEditor::~MonoslicerEditor() zoomResetButton.removeListener(this); scrollLeftButton.removeListener(this); scrollRightButton.removeListener(this); + fileInfoLabel.removeListener(this); stretchButton.removeListener(this); } @@ -254,8 +264,11 @@ void MonoslicerEditor::resized() auto bounds = getLocalBounds(); auto titleBar = bounds.removeFromTop(40); - auto statusBarArea = bounds.removeFromBottom(18).withTrimmedRight(5); - statusBar.setBounds(statusBarArea); + auto statusBarArea = bounds.removeFromBottom(18); + fileInfoLabel.setBounds(statusBarArea.getX() + 5, statusBarArea.getY(), + statusBarArea.getWidth() / 2 - 5, statusBarArea.getHeight()); + buildInfoLabel.setBounds(statusBarArea.getCentreX(), statusBarArea.getY(), + statusBarArea.getWidth() / 2 - 5, statusBarArea.getHeight()); int tx = 120; @@ -366,6 +379,25 @@ void MonoslicerEditor::timerCallback() waveformDisplay.setSampleBuffer(&processorRef.getSampleBuffer(), processorRef.getSampleRateLoaded()); } + const auto& file = processorRef.getCurrentFile(); + if (file != currentLoadedFile) + { + currentLoadedFile = file; + if (file.existsAsFile()) + { + double duration = static_cast(processorRef.getSampleBuffer().getNumSamples()) + / processorRef.getSampleRateLoaded(); + int mins = static_cast(duration) / 60; + int secs = static_cast(duration) % 60; + fileInfoLabel.setButtonText(file.getFileName() + " " + + juce::String(mins) + ":" + juce::String(secs).paddedLeft('0', 2)); + } + else + { + fileInfoLabel.setButtonText("No file loaded"); + } + } + waveformDisplay.setPlaybackPosition(processorRef.currentPlaybackSample.load()); waveformDisplay.setActiveSliceIndex(processorRef.currentActiveSlice.load()); waveformDisplay.setSelectedSlice(processorRef.selectedSlice.load()); @@ -471,6 +503,11 @@ void MonoslicerEditor::buttonClicked(juce::Button* button) { waveformDisplay.scrollRight(); } + else if (button == &fileInfoLabel) + { + if (currentLoadedFile.existsAsFile()) + currentLoadedFile.startAsProcess(); + } } void MonoslicerEditor::comboBoxChanged(juce::ComboBox* comboBoxThatHasChanged) diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 0689574..94ce887 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -90,7 +90,9 @@ private: std::unique_ptr filterTypeAttachment; juce::FileChooser fileChooser { "Load Audio File", juce::File{}, "*.wav;*.aiff;*.flac;*.ogg" }; - juce::Label statusBar; + juce::TextButton fileInfoLabel; + juce::Label buildInfoLabel; + juce::File currentLoadedFile; void setupSlider(juce::Slider& slider, juce::Label& label, const juce::String& name); void attachSlider(juce::Slider& slider, juce::Label& label, const juce::String& name, diff --git a/monoslicershot.png b/monoslicershot.png index 0d37ca8..979ab3a 100644 Binary files a/monoslicershot.png and b/monoslicershot.png differ