//
// Okzoniom::RPG
// Copyright (C) 2010 - 2013
//
// - Louis SCHNELLBACH
//
#ifndef WIDGET_H_INCLUDED
#define WIDGET_H_INCLUDED
#include <SFML/Window/Mouse.hpp>
#include <SFML/Window/Event.hpp>
#include "Callback.h"
#include "../Drawable.h"
#include "../TexCoord.h"
namespace okz
{
class UI;
class Widget : public Drawable, public priv::Callback
{
friend class UI;
public:
static float Z_DECREMENT;
Widget(const std::string& id, Widget* parent=NULL);
virtual ~Widget();
virtual void update(const sf::Event& event);
virtual void call(const sf::Event& event);
void setID(const std::string&);
std::string getID() const;
Widget* getParent();
void addChild(Widget* w);
void removeChild(Widget* w);
Widget* getRootParent();
virtual void visible(bool b);
bool isVisible() const;
virtual void focus(bool b);
void focusable(bool);
bool isFocused() const;
bool isKeepingFocus() const;
bool isFocusable() const;
void movable(bool);
bool isMovable() const;
float setZ(float);
virtual void setSize(const okz::fVertex&);
virtual okz::fVertex getSize() const;
virtual void setOffset(const okz::fVertex&);
virtual okz::fVertex getOffset() const;
virtual void setPosition(const okz::fVertex&);
virtual okz::fVertex getPosition() const;
virtual bool contains(float x, float y) const;
virtual void initialize();
virtual void render();
virtual void createVBO();
protected:
std::string _id;
std::string _type;
//----------------------
bool _visible;
bool _focus;
bool _keepFocus;
bool _focusable;
bool _movable;
std::vector<Widget*> _child;
Widget* _parent;
okz::fVertex _offset;
okz::fVertex _size;
//Specific OpenGL texture attribute
okz::VBOTemplate<okz::TexCoord> _texCoords;
float _shaderTime;
private:
//Used by UI
bool _destroyMe;
void __propagateDestruction();
};
//Comparison functor
struct pWidget_comp
{
bool operator() (const Widget*, const Widget*) const;
};
}
#endif // WIDGET_H_INCLUDED