/**
 *  Triangles
 *  Copyright (C) 2016 POSITIVE MENTAL ATTITUDE
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, version 3 of the License.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include <SFML/Graphics.hpp>
#include <iostream>
#include "InputTarget.hpp"
#include "Context.hpp"

class TrianglesWindow: public InputTarget<int>
{
	public:
		TrianglesWindow() = delete;
		TrianglesWindow(const std::string& title, sf::Vector2u size);
		~TrianglesWindow();
		
		void clear();
		void clear(sf::Color color);
		void render();
		void recreate();
		void lockFramerate(bool locked);
		void setContext(Context* context);
		bool setActive(bool active);
		void setSize(sf::Vector2u& size);
		void setSize(unsigned width, unsigned height);
		sf::Vector2u getSize();
		void setView(const sf::View* view);
		void setView();
		const sf::View& getDefaultView();
		void draw(sf::Drawable& drawable);
		void draw(sf::Drawable& drawable, sf::RenderStates states);
		void draw(sf::Drawable& drawable, sf::Shader* shader);
		bool pollEvent(sf::Event& event);
		sf::Vector2i getMousePosition();
		void lockMouse();
		void lockMouse(sf::Vector2i position);

	private:
		void open();
		void close();
		
		Context* _context;
		InputMap<int> _inputMap;
		sf::RenderWindow _window;
		sf::Vector2u _size;
		std::string _title;
		bool _mouseLocked;
		std::vector<sf::Texture> _textures;	
};

