#pragma once
#include "node_border.h"
#include "node_button.h"
#include "node_image_texture.h"
#include "node_text.h"
#include "node_text_input.h"
#include "node_combobox.h"

class NodeDialogOpenItem : public NodeBorder
{
public:
    NodeText* m_text;
    NodeImageTexture* m_thumb;
    glm::vec4 m_color_normal = glm::vec4(.4, .4, .4, 1);
    glm::vec4 m_color_selected = glm::vec4(.3, .3, .3, 1);
    glm::vec4 m_color_hover = glm::vec4(.5, .5, .5, 1);
    bool m_selected = false;
    std::string m_path;
    std::string m_file_name;
    std::function<void(NodeDialogOpenItem* target)> on_selected;
    virtual Node* clone_instantiate() const override;
    virtual void clone_finalize(Node* dest) const override;
    virtual void init() override;
    void init_controls();
    virtual void loaded() override;
    virtual void draw() override;
    virtual kEventResult handle_event(Event* e) override;
};

class NodeDialogOpen : public NodeBorder
{
public:
    NodeButton* btn_cancel;
    NodeButton* btn_ok;
    NodeButton* btn_delete;
    NodeDialogOpenItem* current = nullptr;
    Node* container;
    std::string selected_path;
    std::string selected_file;
    std::string selected_name;
    virtual Node* clone_instantiate() const override;
    virtual void clone_finalize(Node* dest) const override;
    virtual void init() override;
    void init_controls();
    virtual void loaded() override;
};

class NodeDialogSave : public NodeBorder
{
public:
    NodeButton* btn_cancel;
    NodeButton* btn_ok;
    NodeButton* btn_path;
    NodeText* working_path;
    NodeTextInput* input;
    std::string selected_path;
    virtual Node* clone_instantiate() const override;
    virtual void clone_finalize(Node* dest) const override;
    virtual void init() override;
    void init_controls();
    virtual void loaded() override;
    virtual void added(Node* parent) override;
};

class NodeDialogNewDoc : public NodeBorder
{
public:
    NodeButton* btn_cancel;
    NodeButton* btn_ok;
    NodeButton* btn_path;
    NodeTextInput* input;
    NodeText* working_path;
    NodeComboBox* m_resolution;
    virtual Node* clone_instantiate() const override;
    virtual void clone_finalize(Node* dest) const override;
    virtual void init() override;
    void init_controls();
    virtual void loaded() override;
    virtual void added(Node* parent) override;
};
