//
// Created by Sergei Shubin <s.v.shubin@gmail.com>
//

#ifndef FRAME_ANIMATION_DECORATOR_H
#define FRAME_ANIMATION_DECORATOR_H

#include <Rocket/Core/Decorator.h>

class FrameAnimationDecorator: public Rocket::Core::Decorator {
public:
	virtual ~FrameAnimationDecorator();

	bool Initialise(const Rocket::Core::String& image_source, const Rocket::Core::String& image_path, int num_frames, int frame_width, float frame_delay, bool reverse = false);

	/// Called on a decorator to generate any required per-element data for a newly decorated element.
	/// @param element[in] The newly decorated element.
	/// @return A handle to a decorator-defined data handle, or NULL if none is needed for the element.
	virtual Rocket::Core::DecoratorDataHandle GenerateElementData(Rocket::Core::Element *element);
	/// Called to release element data generated by this decorator.
	/// @param element_data[in] The element data handle to release.
	virtual void ReleaseElementData(Rocket::Core::DecoratorDataHandle element_data);

	/// Called to render the decorator on an element.
	/// @param element[in] The element to render the decorator on.
	/// @param element_data[in] The handle to the data generated by the decorator for the element.
	virtual void RenderElement(Rocket::Core::Element *element, Rocket::Core::DecoratorDataHandle element_data);
private:
	int m_texture;
	int m_num_frames;
	int m_frame_width;
	float m_frame_delay;
	float m_init_time;
	bool m_reverse;
};

#endif /* FRAME_ANIMATION_DECORATOR_H */
