/*
  ==============================================================================

    This file contains the basic framework code for a JUCE plugin editor.

  ==============================================================================
*/

#include "PluginProcessor.h"
#include "PluginEditor.h"

//==============================================================================
LeiwandizerAudioProcessorEditor::LeiwandizerAudioProcessorEditor (LeiwandizerAudioProcessor& p)
    : AudioProcessorEditor (&p), audioProcessor (p)
{
    backgroundOn = juce::ImageCache::getFromMemory(BinaryData::Leiwand_ON_2x_png, BinaryData::Leiwand_ON_2x_pngSize);
    backgroundOff = juce::ImageCache::getFromMemory(BinaryData::Leiwand_OFF_2x_png, BinaryData::Leiwand_OFF_2x_pngSize);

    btLeiwand.setColour(juce::TextButton::ColourIds::buttonColourId, juce::Colours::transparentBlack);
    btLeiwand.setColour(juce::TextButton::ColourIds::buttonOnColourId, juce::Colours::transparentBlack);
    btLeiwand.setColour(juce::TextButton::ColourIds::textColourOnId, juce::Colours::transparentBlack);
    btLeiwand.setColour(juce::TextButton::ColourIds::textColourOffId, juce::Colours::transparentBlack);
    btLeiwand.setLookAndFeel(&borderlessLook);
    addAndMakeVisible(btLeiwand);
    btLeiwand.setBounds(97, 66, 45, 75); // x, y, width, height
    btLeiwand.onClick = [this]() {
        auto& proc = audioProcessor;
        proc.isLeiwand = !proc.isLeiwand;
        };

    // Make sure that before the constructor has finished, you've set the
    // editor's size to whatever you need it to be.
    setSize (979, 179);
}

LeiwandizerAudioProcessorEditor::~LeiwandizerAudioProcessorEditor()
{
}

//==============================================================================
void LeiwandizerAudioProcessorEditor::paint (juce::Graphics& g)
{
    // (Our component is opaque, so we must completely fill the background with a solid colour)
    //g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));

    //g.setColour (juce::Colours::white);
    //g.setFont (juce::FontOptions (15.0f));
    //g.drawFittedText ("Hello World!", getLocalBounds(), juce::Justification::centred, 1);
    if (audioProcessor.isLeiwand) g.drawImage(backgroundOn, getLocalBounds().toFloat());
    else g.drawImage(backgroundOff, getLocalBounds().toFloat());
}

void LeiwandizerAudioProcessorEditor::resized()
{
    // This is generally where you'll want to lay out the positions of any
    // subcomponents in your editor..
}
