#pragma once

#include "SceneModel.h"
#include "AbstractMesh.h"

#include "Image.h"
#include "DiscretePoint.h"

#include <memory>

#include <iostream>

class FontsManager;

class AbstractVisualNode
{
public:
    AbstractVisualNode(const DiscretePoint& location, const std::string& name = {});

    virtual ~AbstractVisualNode() = default;

    void addChild(AbstractVisualNode* child);

    virtual SceneItem* getSceneItem(std::size_t idx) const;

    virtual unsigned getNumSceneItems() const;

    unsigned getNumChildren() const;

    const std::vector<AbstractVisualNode*>& getChildren() const;

    const std::string& getName() const;

    Image<unsigned char>* getImage() const;

    bool getIsVisible() const;

    virtual void update(FontsManager* fontsManager);

    void syncChildren(const std::vector<AbstractVisualNode*>& children);

    void setIsVisible(bool isVisible);

    void setName(const std::string& name);

    void setLocation(const DiscretePoint& loc);

protected:
    DiscretePoint mLocation;
    std::vector<std::unique_ptr<SceneItem> > mSceneItems;
    std::unique_ptr<Image<unsigned char> > mImage;

    std::vector<AbstractVisualNode*> mChildren;

    bool mIsVisible{true};
    bool mTransformIsDirty{true};
    std::string mName;
};
