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

  This is an automatically generated file created by the Jucer!

  Creation date:  30 Sep 2012 11:31:53am

  Be careful when adding custom code to these files, as only the code within
  the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
  and re-saved.

  Jucer version: 1.12

  ------------------------------------------------------------------------------

  The Jucer is part of the JUCE library - "Jules' Utility Class Extensions"
  Copyright 2004-6 by Raw Material Software ltd.

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

#ifndef __JUCER_HEADER_VELKEYPOPUP_VELKEYPOPUP_9719552A__
#define __JUCER_HEADER_VELKEYPOPUP_VELKEYPOPUP_9719552A__

//[Headers]     -- You can add your own extra header files here --
#include <JuceHeader.h>
#include <synth/synth_defs.h>
#include "JaySynth.h"
#include "JaySynthMidiCC.h"

class VelKey_PopUp_Listener
{
public:
	virtual void VelKey_PopUp_event(int /*event*/) {};
};
//[/Headers]

#include "graph_window.h"


//==============================================================================
/**
                                                                    //[Comments]
    An auto-generated component, created by the Jucer.

    Describe your class and how it works here!
                                                                    //[/Comments]
*/
class VelKey_PopUp  : public Component,
                      public SliderListener,
                      public ButtonListener,
                      public LabelListener,
                      public ComboBoxListener
{
public:
    //==============================================================================
    VelKey_PopUp (JaySynthMidiCC *pMidiCC, int paramID, synth_float_t currParamValue, JaySynth::midi_note_info_t *pCurrentMidiNoteInfo, String name, VelKey_PopUp_Listener *listener);
    ~VelKey_PopUp();

    //==============================================================================
    //[UserMethods]     -- You can add your own custom methods in this section.
	enum
	{
		POPUP_DELETED = 0,
		POPUP_CREATED,
		POPUP_SHOW,
		POPUP_PARAM_CHANGED,
		POPUP_OK

	};

	void setKeyVel(int note, float velocity);
 	void addListener(VelKey_PopUp_Listener *listener)
	{
	    listeners.add (listener);
	}
	void show(void)
	{
		this->setVisible(true);
		listeners.call (&VelKey_PopUp_Listener::VelKey_PopUp_event, POPUP_SHOW);
	}
	int getParamID(void)
	{
		return m_paramID;
	}

	ComponentDragger myDragger;
    void mouseDown (const MouseEvent& e)
    {
        myDragger.startDraggingComponent (this, e);
    }

    void mouseDrag (const MouseEvent& e)
    {
        myDragger.dragComponent (this, e, nullptr);
    }
	void createNoteNameTbl(void);
	const String getNoteName(int midinotnumber);
	void displayUpdate(void);
	void setCurrParam(int paramID, float param);
    //[/UserMethods]

    void paint (Graphics& g);
    void resized();
    void sliderValueChanged (Slider* sliderThatWasMoved);
    void buttonClicked (Button* buttonThatWasClicked);
    void labelTextChanged (Label* labelThatHasChanged);
    void comboBoxChanged (ComboBox* comboBoxThatHasChanged);



    //==============================================================================
    juce_UseDebuggingNewOperator

private:
    //[UserVariables]   -- You can add your own custom variables in this section.
	param_info_t m_velKey_constraints;
	param_info_t m_shape_xform, m_skew_xform;
	JaySynthMidiCC *pMidiCC;
	midiCC_container_t *pMidiCC_container;
	ListenerList <VelKey_PopUp_Listener> listeners;
	synth_float_t m_currParamValue;
	int m_paramID;
	int m_label_prec, m_label_shape_prec, m_label_skew_prec;
	JaySynth::midi_note_info_t m_currentMidiNoteInfo;
	bool m_isFlipped_vel, m_isFlipped_key;
	String m_text_vel_min, m_text_vel_max;
	String m_text_key_min, m_text_key_max;
	String notename_tbl[128];
    //[/UserVariables]

    //==============================================================================
    Label* label_parameter_name;
    GroupComponent* groupComponent3;
    GroupComponent* groupComponent;
    GroupComponent* groupComponent2;
    GraphWindow* m_graph_vel;
    Slider* slider_vel_kexp;
    Slider* slider_vel_scenter;
    Label* label_vel_kexp;
    Label* label_vel_scenter;
    Label* label_vel_min;
    Slider* slider_vel_min;
    TextButton* textButton_OK;
    ToggleButton* button_vel_assign_enable;
    Label* label_vel_ymin;
    Label* label_vel_ymax;
    Label* label_vel_x100;
    Label* label_vel_x0;
    GraphWindow* m_graph_key;
    Slider* slider_key_kexp;
    Slider* slider_key_scenter;
    Label* label_key_kexp;
    Label* label_vel_scenter2;
    Label* label_key_min;
    Slider* slider_key_min;
    ToggleButton* button_key_assign_enable;
    Label* label_key_ymin;
    Label* label_key_ymax;
    Label* label_key_x100;
    Label* label_key_x0;
    ComboBox* comboBoxOPSel;
    Label* label_key;
    Label* label_vel;
    Slider* slider_vel_max;
    Label* label_vel_max;
    Label* label_key_max;
    Slider* slider_key_max;
    Label* label_vel_shape;
    Label* label_vel_skew;
    Label* label_key_shape;
    Label* label_key_skew;
    Label* label_vel_skew_text;
    Label* label_key_skew_text;
    Label* label_vel_shape_text;
    Label* label_key_shape_text;
    Label* label_vel_max_text;
    Label* label_vel_min_text;
    Label* label_key_min_text;
    Label* label_key_max_text;
    Label* label_vel_y;
    Label* label_key_y;
    Label* label_vel_x;
    Label* label_key_x;
    TextButton* m_btn_flip_vel;
    TextButton* m_btn_flip_key;


    //==============================================================================
    // (prevent copy constructor and operator= being generated..)
    VelKey_PopUp (const VelKey_PopUp&);
    const VelKey_PopUp& operator= (const VelKey_PopUp&);
};


#endif   // __JUCER_HEADER_VELKEYPOPUP_VELKEYPOPUP_9719552A__
