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

class NodeDialogBrowseItem : 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(NodeDialogBrowseItem* 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 NodeDialogBrowse : public NodeBorder
{
public:
    NodeButton* btn_cancel;
    NodeButton* btn_ok;
    NodeButton* btn_delete;
    NodeButton* btn_path;
    NodeText* working_path;
    NodeDialogBrowseItem* current = nullptr;
    Node* container;
    std::string selected_path;
    std::string selected_file;
    std::string selected_name;
    std::vector<std::string> search_paths;
    virtual Node* clone_instantiate() const override;
    virtual void clone_finalize(Node* dest) const override;
    virtual void init() override;
    void init_controls();
    void init_list();
    void clear_list();
    virtual void loaded() override;
    bool is_selected();
};
