//#####################################################################
// Copyright 2020, Craig Schroeder.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
#ifndef __QT_COMPONENT_OPTIONS__
#define __QT_COMPONENT_OPTIONS__

#include <Core/Data_Structures/HASHTABLE.h>
#include <Core/Viewer/VIEWER_OPTIONS.h>
#include "../QT_WINDOW.h"
#include <functional>
#include <QDialog>
#include <QKeyEvent>
#include <QMainWindow>
#include <QWindow>

QT_BEGIN_NAMESPACE
class QPainter;
class QOpenGLContext;
class QOpenGLPaintDevice;
class QOpenGLShaderProgram;
class QOpenGLFunctions;
class QMenu;
class QGridLayout;
QT_END_NAMESPACE

namespace PhysBAM{
class QT_CAMERA;
class QT_WORLD;
class QT_RENDER_UTILS;
class QT_COMPONENT;
class PARSE_ARGS;
template<class T> class INTERPOLATED_COLOR_MAP;

class QT_COMPONENT_OPTIONS : public QDialog
{
    Q_OBJECT
public:
    typedef VECTOR<float,3> C;
    QT_COMPONENT_OPTIONS(QT_WINDOW& window,QT_COMPONENT& comp);
    virtual ~QT_COMPONENT_OPTIONS();

    void Add_Button(const std::string& name,std::function<void()> func);
    void Add(const std::string& desc,OPTION<bool>& full,OPTION<bool>& user);
    void Add(const std::string& desc,OPTION<int>& full,OPTION<int>& user);
    void Add(const std::string& desc,OPTION<float>& full,OPTION<float>& user);
    void Add(const std::string& desc,OPTION<std::string>& full,OPTION<std::string>& user);
    void Add(const std::string& desc,OPTION<C>& full,OPTION<C>& user);
    void Add(const std::string& desc,OPTION<INTERPOLATED_COLOR_MAP<float>>& full,OPTION<INTERPOLATED_COLOR_MAP<float>>& user);
    void Add(const std::string& desc,OPTION<ARRAY<C>>& full,OPTION<ARRAY<C>>& user);
    void Add_End_Buttons();

    QGridLayout *layout;
public slots:
//    void Quit();
private:
    void Load();
    void Save();

    void Action_Cancel();
    void Action_Apply();
    void Action_Accept();
    void Update_Button_Color(QPushButton* button,
        const INTERPOLATED_COLOR_MAP<float>& out);

    QT_WINDOW& window;
    QT_COMPONENT& comp;
    ARRAY<std::function<void()> > save_contents;
    ARRAY<std::function<void()> > load_contents;
    int next_row=0;
};
}
#endif
