#pragma once
#include "node_border.h"

class NodeSliderH : public NodeBorder
{
    bool dragging = false;
public:
    int m_comp = 0;
    float m_value = 0;
    float m_old_value = 0;
    std::function<void(Node* target, float value)> on_value_changed;
    std::function<void(Node* target, float value)> on_value_final;
    virtual Node* clone_instantiate() const override;
    virtual void clone_copy(Node* dest) const override;
    virtual void init() override;
    virtual void draw() override;
    void set_value(float value, bool propagate = false);
    float get_value();
    virtual void parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr) override;
    virtual kEventResult handle_event(Event* e) override;
};

class NodeSliderV : public NodeSliderH
{
public:
    virtual Node* clone_instantiate() const override { return new NodeSliderV(); }
    NodeSliderV() { m_comp = 1; }
};

class NodeSliderHue : public NodeSliderV
{
public:
    glm::vec4 m_color;
    std::function<void(Node* target, glm::vec4 color)> on_hue_changed;
    virtual Node* clone_instantiate() const override;
    virtual void clone_finalize(Node* dest) const override;
    virtual void init() override;
    void init_controls();
    glm::vec4 get_hue();
    virtual void draw() override;
};
