#include "PluginEditor.h" HomAudioProcessorEditor::HomAudioProcessorEditor (HomAudioProcessor& p) : AudioProcessorEditor (&p), processor (p), progressBar (progressValue) { setSize (440, 240); setResizable (true, true); addAndMakeVisible (uploadBtn); uploadBtn.onClick = [this] { onUploadClicked(); }; addAndMakeVisible (statusLbl); statusLbl.setText ("Drop an audio file or click the button.", juce::dontSendNotification); statusLbl.setJustificationType (juce::Justification::centred); addAndMakeVisible (progressBar); progressBar.setVisible (false); } void HomAudioProcessorEditor::paint (juce::Graphics& g) { // Paper&Ink dark g.fillAll (juce::Colour (0xff1A1715)); g.setColour (juce::Colour (0xffD4A574)); g.setFont (16.0f); g.drawFittedText ("House of Mixtape", getLocalBounds().removeFromTop (40), juce::Justification::centred, 1); } void HomAudioProcessorEditor::resized() { auto r = getLocalBounds().reduced (16); r.removeFromTop (40); // brand header statusLbl.setBounds (r.removeFromTop (32)); r.removeFromTop (12); uploadBtn.setBounds (r.removeFromTop (44).reduced (40, 0)); r.removeFromTop (16); progressBar.setBounds (r.removeFromTop (24)); } bool HomAudioProcessorEditor::isInterestedInFileDrag (const juce::StringArray& files) { for (auto& f : files) if (f.endsWithIgnoreCase (".wav") || f.endsWithIgnoreCase (".mp3") || f.endsWithIgnoreCase (".flac") || f.endsWithIgnoreCase (".m4a")) return true; return false; } void HomAudioProcessorEditor::filesDropped (const juce::StringArray& files, int, int) { if (files.isEmpty()) return; setStatus ("Uploading " + juce::File (files[0]).getFileName() + "…"); progressBar.setVisible (true); progressValue = 0.05; // Hand off to the API client (skeleton — actual HTTP wiring lands in // a subsequent commit once Path 2 sprint resumes). processor.getApiClient().submitJobAsync ( juce::File (files[0]), /* onProgress */ [this] (double p) { progressValue = p; }, /* onDone */ [this] (juce::var output) { juce::ignoreUnused (output); progressBar.setVisible (false); setStatus ("Done — stems imported into the project."); }, /* onError */ [this] (const juce::String& msg) { progressBar.setVisible (false); setStatus ("Error: " + msg); } ); } void HomAudioProcessorEditor::onUploadClicked() { auto chooser = std::make_shared ( "Choose an audio file", juce::File::getSpecialLocation (juce::File::userMusicDirectory), "*.wav;*.mp3;*.flac;*.m4a" ); auto flags = juce::FileBrowserComponent::openMode | juce::FileBrowserComponent::canSelectFiles; chooser->launchAsync (flags, [this, chooser] (const juce::FileChooser& fc) { auto files = fc.getResults(); if (files.isEmpty()) return; juce::StringArray paths; paths.add (files[0].getFullPathName()); filesDropped (paths, 0, 0); }); } void HomAudioProcessorEditor::setStatus (const juce::String& msg) { statusLbl.setText (msg, juce::dontSendNotification); }