FahlGrahn Audio v1.0.0
Loading...
Searching...
No Matches
PluginEditor.h
1#pragma once
2
3#include "CustomLookAndFeel/DeathMetalLookAndFeel.h"
4#include "CustomLookAndFeel/FontAudioLookAndFeel.h"
5#include "PluginProcessor.h"
6
7//==============================================================================
8class AudioPluginAudioProcessorEditor final : public juce::AudioProcessorEditor
9{
10 public:
13
14 //==============================================================================
15 void paint(juce::Graphics &) override;
16 void resized() override;
17
18 void loadFileButtonClicked()
19 {
20 juce::Logger::writeToLog("Button clicked");
21 fileChooser = std::make_unique<juce::FileChooser>(
22 "Select file...", juce::File::getSpecialLocation(juce::File::userHomeDirectory), "*.wav");
23
24 fileChooser->launchAsync(
25 juce::FileBrowserComponent::openMode | juce::FileBrowserComponent::canSelectFiles,
26 [this](const juce::FileChooser &chooser) {
27 auto audioFile = chooser.getResult();
28 if (audioFile.getFileName().isNotEmpty())
29 {
30 if (processorRef.loadFile(audioFile))
31 {
32 juce::Logger::writeToLog(audioFile.getFileName());
33 fileName.setText(audioFile.getFullPathName(), juce::NotificationType::dontSendNotification);
34 }
35 else
36 {
37 juce::NativeMessageBox::showMessageBoxAsync(
38 juce::AlertWindow::WarningIcon, "Error",
39 "The file \"" + audioFile.getFileName() +
40 "\" is encoded in a format that isn't supported.");
41 fileName.setText("No file loaded", juce::NotificationType::dontSendNotification);
42 }
43 }
44 });
45 }
46
47 void playButtonClicked()
48 {
49 }
50
51 private:
52 // This reference is provided as a quick way for your editor to
53 // access the processor object that created it.
54 AudioPluginAudioProcessor &processorRef;
55 DeathMetalLookAndFeel deathMetalLookAndFeel;
56 FontAudioLookAndFeel fontAudioLookAndFeel;
57 juce::TextButton loadFileButton;
58 juce::TextButton playButton;
59 juce::Slider gainSlider;
60 juce::TextButton loopButton;
61 juce::Label fileName;
62 std::unique_ptr<juce::FileChooser> fileChooser;
63
64 using SliderAttachment = juce::AudioProcessorValueTreeState::SliderAttachment;
65 using ButtonAttachment = juce::AudioProcessorValueTreeState::ButtonAttachment;
66
67 std::unique_ptr<SliderAttachment> gainAttachment;
68 std::unique_ptr<ButtonAttachment> loopAttachment;
69 std::unique_ptr<ButtonAttachment> playAttachment;
70
71 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AudioPluginAudioProcessorEditor)
72};
Definition PluginEditor.h:11
Definition PluginProcessor.h:9
Definition DeathMetalLookAndFeel.h:9
Definition FontAudioLookAndFeel.h:6