//
// Tools_GUIMenu_Element_Path.h
//
// Created by Richard Rice - 05/12/2006
// 
// Copyright (C) 2006 Rebellion, All Rights Reserved.
//


#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif


#ifndef _TOOLS_GUIMENU_ELEMENT_PATH_H_
#define _TOOLS_GUIMENU_ELEMENT_PATH_H_
#ifdef ASURA_USE_GUI_MENU_SYSTEM

#include "GUIMenu/Tools_GUIMenu_Element_Base.h"


class Asura_GUIMenu_Element_Path;

class Tools_GUIMenu_Element_Path : public Tools_GUIMenu_Element_Base
{
	typedef Tools_GUIMenu_Element_Base PARENT;
public :
	Tools_GUIMenu_Element_Path(Asura_GUIMenu_Element_Path* pxAsuraPath,Tools_GUIMenu_Root* pxToolsParent);
	~Tools_GUIMenu_Element_Path();

	virtual void InitialiseNewItem();
	virtual void Update();
	virtual void RenderUI();
	virtual void OnDeselection();
	virtual bool IsUsingKey(int iKey);
	virtual void Copy(const Tools_GUIMenu_Root* pxSource);
	virtual bool IsValidChildType(int iItemType) const;
	virtual void CopyFromAsura();


protected :
	virtual void SetRectangle(const Asura_Bounding_Rectangle& xRect);
	virtual void AddOverlayControls(Asura_Overlay* pxOverlay,Asura_Vector_2& xOffset);


private :
	void UpdatePathEdit();
	int GetPointFromPosition(const Asura_Vector_2& xPos);
	void CreatePoint();
	void DeletePoint(int iIndex);

	void UpdateChildrenRelativeToPath();

	#define OVERLAY_VOID_CALLBACK(__FnName)\
	static void __FnName(int iThis){((Tools_GUIMenu_Element_Path*)iThis)->__FnName();}\
	void __FnName();

	OVERLAY_VOID_CALLBACK(AddElement_Image)

	#undef OVERLAY_VOID_CALLBACK


	//Sets the position of a point , clamping and snapping as required	
	void SetPointPosition(int iIndex,const Asura_Vector_2& xPos);

	Asura_GUIMenu_Element_Path* m_pxAsuraPath;

	u_int m_uNumPoints;
	Asura_Vector_2* m_pxLocalPoints;

	int m_iSelectedPoint;

	static bool s_bClickedForPathEditing;
	static bool s_bDrag;
	static Asura_Vector_2 s_xInitialClickPos;

	static bool s_bEditPath;

};




#endif //ASURA_USE_GUI_MENU_SYSTEM
#endif //_TOOLS_GUIMENU_ELEMENT_PATH_H_
