//
//  LabelNode.h
//  PixelKit
//
//  Copyright (c) 2014 César Parent. All rights reserved.
//
#ifndef _LABELNODE_H
#define _LABELNODE_H

#include "includes.h"
#include "Node.h"
#include "Color.h"

namespace PixelKit
{
	class Animation;
	
	class LabelNode : public Node
	{
	public:
		/*!
		 * @brief LabelNode's constructor, builds a node with an empty string.
		 * @param font The filename of the bitmap font file.
		 */
		LabelNode(std::string font) : LabelNode("", font){};
		
		/*!
		 * @brief LabelNode's constructor, builds a node with a given string.
		 * @param text LabelNode's text.
		 * @param font The filename of the bitmap font file.
		 */
		LabelNode(std::string text, std::string font);
		
		/*!
		 * @brief LabelNode's destructor.
		 */
		virtual ~LabelNode() override;
		
		/*!
		 * @brief Change LabelNode's text.
		 * @param newText the new text string.
		 */
		virtual void setText(std::string newText);
		
		/*!
		 * @brief Change LabelNode's font size.
		 * @param size LabelNode's new size in pixels.
		 */
		virtual void setFontSize(int size);
		
		/*!
		 * @brief Change LabelNode text's color.
		 * @param newColor LabelNode's new color.
		 */
		virtual void setColor(Color newColor);
		
		/*!
		 * @brief Change LabelNode's background color.
		 * @param newColor LabelNode's new background color.
		 */
		virtual void setBackground(Color newColor);
		
		/*!
		 * @brief Draw LabelNode's text on the screen.
		 * @param renderer The renderer to draw to.
		 */
		virtual void draw(SDL_Renderer *renderer) override;
		
		/*!
		 * @brief LabelNode's text color.
		 */
		const Color& color;
		
		/*!
		 * @brief LabelNode's background color.
		 */
		const Color& background;
		
		/*!
		 * @biref LabelNode's text
		 */
		const std::string& text;
		
		/*!
		 * @brief LabelNode's font size in pixels.
		 */
		const int& fontSize;
		
	protected:
		int _fontSize;
		Color _color;
		Color _background;
		std::string _text;
		std::string _fontName;
		SDL_Texture *_texture;
		
	private:
		bool changed;
		void redrawText(SDL_Renderer *renderer);
		SDL_Texture *_font;
		int _glyphWidth;
		int _glyphHeight;
	};
}

#endif