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