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

  This file was auto-generated by the Introjucer!

  It contains the basic startup code for a Juce application.

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

#ifndef __PLUGINEDITOR_H_3BD4AE6E__
#define __PLUGINEDITOR_H_3BD4AE6E__

#include "JuceHeader.h"
#include "PluginProcessor.h"
#include "gui/pitcheddelaytab.h"
#include "gui/DelayGraph.h"

#include "presetmanager.h"

class PitchedDelayLookAndFeel : public LookAndFeel_V2
{
public:
	PitchedDelayLookAndFeel()
	{
		setColour(Slider::thumbColourId, Colours::lightgrey);

		setColour(TextButton::buttonColourId, Colours::lightgrey);
		setColour(TextButton::buttonOnColourId, Colours::grey);

		setColour(ComboBox::buttonColourId, Colours::lightgrey);

		setColour(TextEditor::focusedOutlineColourId, Colours::transparentBlack);
		setColour(TextEditor::highlightColourId, Colours::darkgrey.withAlpha(0.25f));
	}

private:

};




//==============================================================================
/**
*/
class CallbackTab : public TabbedComponent
{
public:
	CallbackTab(TabbedButtonBar::Orientation orientation, PitchedDelayAudioProcessor* processor_)
		: TabbedComponent(orientation),
		  processor(processor_)
	{
	}

	void currentTabChanged(int newCurrentTabIndex, const String& /*newCurrentTabName*/) override
	{
		processor->currentTab = newCurrentTabIndex;
	}

private:
	PitchedDelayAudioProcessor* processor;
};


class PitchedDelayAudioProcessorEditor  : public AudioProcessorEditor,
                                          public Timer,
                                          public ActionListener,
                                          public Slider::Listener,
                                          public Button::Listener,
										  public ComboBox::Listener
{
public:
  PitchedDelayAudioProcessorEditor (PitchedDelayAudioProcessor* ownerFilter);
  ~PitchedDelayAudioProcessorEditor() override;

  //==============================================================================
  // This is just a standard Juce paint method...
  void paint (Graphics& g) override;
	void resized() override;

	void timerCallback() override;
	void actionListenerCallback (const String& message) override;
	void sliderValueChanged (Slider* slider) override;
	void buttonClicked (Button* button) override;
	void comboBoxChanged (ComboBox* comboBoxThatHasChanged) override;

private:

	void updatePresets();
	
	PitchedDelayAudioProcessor* getProcessor()
	{
		return static_cast<PitchedDelayAudioProcessor*> (getAudioProcessor());
	}

	CallbackTab tabs;
	OwnedArray<PitchedDelayTab> delays;

	ScopedPointer<DelayGraph> graph;

	Slider dryVolume;
	Slider masterVolume;
	ToggleButton showTooltips;

	PitchedDelayLookAndFeel lookAndFeel;

	ScopedPointer<TooltipWindow> tooltipWindow;
	ScopedPointer<PresetManager> presetManager;

	TextButton addPreset;
	TextButton removePreset;
	ComboBox presetList;

  //==============================================================================
  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PitchedDelayAudioProcessorEditor);
};


#endif  // __PLUGINEDITOR_H_3BD4AE6E__
