#ifndef HEADER_LAYER
#define HEADER_LAYER

#include <stdlib.h>
#include "../../source/XLayer.hpp"
#include "Source.cpp"
#include "Filter.cpp"

USING_NS_GAODING_MEDIA

class Layer {
    public:
        Layer(int id) {
            layer = std::make_shared<XLayer>(id);
        }

        ~Layer() {
            layer.reset();
        }

        std::shared_ptr<XLayer> getInstance() {
            return layer;
        }

        void setSource(Source* source) {
            layer->setSource(source->getInstance());
        }

        void setTimeRange(long startTime, long duration) {
            layer->setTimeRange(startTime, duration);
        }

        void setZOrder(int zOrder) {
            layer->setZOrder(zOrder);
        }

        void setViewPort(int x, int y, int width, int height) {
            layer->setViewPort({ x, y, static_cast<unsigned int>(width), static_cast<unsigned int>(height) });
        }

        void setFlip(bool vertical, bool horizontal) {
            layer->setFlip(vertical, horizontal);
        }

        void setOpacity(float opacity) {
            layer->setOpacity(opacity);
        }

        void setFillType(int type) {
            layer->setFillType(static_cast<XFillType>(type));
        } 

        void translate(float x, float y, float z) {
            layer->translate({ x, y, z });
        }

        void scale(float x, float y, float z) {
            layer->scale({ x, y, z });
        }

        void rotate(float x, float y, float z) {
            layer->rotate({ x, y, z });
        }

        void setMixerType(int type) {
            layer->setMixer(static_cast<XMixerType>(type));
        }

        void updateMixerValue(std::string name, float value) {
            layer->updateMixerValue(name, value);
        }

        void setEnterAnimation(int type) {
            layer->setEnterAnimation(static_cast<XFilterType>(type));
        }

        void updateEnterAnimationProgress(float progress) {
            layer->updateEnterProgress(progress);
        }

        void setExitAnimation(int type) {
            layer->setExitAnimation(static_cast<XFilterType>(type));
        }

        void updateExitAnimationProgress(float progress) {
            layer->updateExitProgress(progress);
        }

        void addEffect(BFilter* filter, bool wrapPixelAround = true) {
            layer->addEffect(filter->getInstance(), wrapPixelAround);
        }

        void removeEffect(BFilter* filter) {
            layer->removeEffect(filter->getInstance());
        }

        void clearEffects() {
            layer->clearEffects();
        }

        void updateEffectIntensity(float intensity) {
            layer->updateEffectIntensity(intensity);
        }

    private:
        std::shared_ptr<XLayer> layer;
};
#endif