/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


#ifndef	__NSPRITE__
#define	__NSPRITE__


		#include "ui/ui_event_handler.h"
		#include "ui/ui_item.h"
		#include "core/ace.h"
		#include "core/render_data.h"
		#include "core/resource_factories.h"


namespace GS {
	namespace S2D {

/*
	@short	Sprite class.
	@author	Emmanuel Julien (ejulien@nworks.fr)
*/
class	Sprite : public Item, public ACE::Unit
{
protected:

		AutoPtr <EventTable> event_table;

public:

struct	RenderData
{
		Render::sTexture texture;
};

enum
{
	FlagFlipU					=	(1 << 2),
	FlagFlipV					=	(1 << 3),

	FlagBlendOpaque				=	(1 << 4),
	FlagBlendAdditive			=	(1 << 5),

	FlagNonSensitive			=	(1 << 6),
	FlagResolutionInvariant		=	(1 << 7),
	FlagTransformUV				=	(1 << 8),

	FlagSnapToPixel				=	(1 << 9)
};

		BitField		sprite_flags;

		String			texture;

		Vector2			uv_origin;
		Matrix3			uv_matrix;
		float			opacity;

virtual	EventTable		*GetEventTable() const { return event_table; }

		bool			ExecCommand(ACE::Command *, float dt);

virtual	void			Render(Render::Renderer &, GPU::TriangleBatch * = 0);
virtual	void			RenderSetup(Core::ResourceFactories * = 0);

		AutoPtr <RenderData> render_data;

virtual	bool			FromMetaTag(NML::Tag &);
virtual	NML::Tag		*AsMetaTag() const;

		Sprite();
};

	} // S2D
} // GS


#endif	// __NSPRITE__
