gui: moar refactoring work.
[fail.git] / gui / game / Widget.h
blob0facb74bb2eea5bda3c31d676af9670a09626814
1 #ifndef AWFUL_GUI_GAME_WIDGET_H_
2 #define AWFUL_GUI_GAME_WIDGET_H_
4 #include "core/core.h"
5 #include "gui/Widget_i.h"
6 #include "EventHandler.h"
7 #include "math/Rectf.h"
8 #include "math/Vector2f.h"
9 #include "scenegraph/Renderable.h"
10 #include "scenegraph/Frame.h"
11 #include <string>
13 namespace awful { namespace gui { namespace game
15 class Container;
16 class Theme;
18 class Widget : virtual public Widget_i, public EventHandler
20 public:
21 Widget( Pointer< Theme > pTheme_ );
22 Widget( Container* pParent_ );
24 virtual void buildSceneGraph() {}
25 virtual void calcMinMax() {}
26 virtual void layout() {}
28 virtual void reLayout()
30 layout();
33 const math::Rectf& getRect() const { return m_Rect; }
34 virtual void setRect( const math::Rectf& r );
36 const math::Vector2f& getMinSize() const { return m_MinSize; }
37 void setMinSize( const math::Vector2f& x ) { m_MinSize = x; }
39 const math::Vector2f& getMaxSize() const { return m_MaxSize; }
40 void setMaxSize( const math::Vector2f& x ) { m_MaxSize = x; }
42 const math::Vector2f& getAbsPos() const { return m_AbsPos; }
43 virtual void setAbsPos( const math::Vector2f& p );
45 const Pointer< Theme >& getTheme() const { return m_Theme; }
46 void setTheme( const Pointer< Theme >& x ) { m_Theme = x; }
48 const Pointer< scenegraph::Renderable >& getpRenderable() const { return m_pRenderable; }
49 const Pointer< scenegraph::Frame >& getpFrame() const { return m_pFrame; }
51 bool isInside( const math::Vector2f pos ) const
53 float right = m_AbsPos.x() + m_Rect.width() - 1.f;
54 float bottom = m_AbsPos.y() + m_Rect.height() - 1.f;
55 return pos.x() >= m_AbsPos.x() && pos.x() < right
56 && pos.y() >= m_AbsPos.y() && pos.y() < bottom;
59 protected:
60 math::Rectf m_Rect;
61 math::Vector2f m_MinSize;
62 math::Vector2f m_MaxSize;
63 math::Vector2f m_AbsPos;
65 Pointer< Theme > m_Theme;
66 Container* m_pParent;
68 Pointer< scenegraph::Renderable > m_pRenderable;
69 Pointer< scenegraph::Frame > m_pFrame;
71 }}}
73 #endif