Made mouseEnter and mouseExit work independently of whether widgets process mouseMotion.
[fail.git] / gui / Widget.h
blob46f37634116090e5901c199ef21eb1a440c015af
1 #ifndef AWFUL_GUI_WIDGET_H_
2 #define AWFUL_GUI_WIDGET_H_
4 #include "EventHandler.h"
5 #include "renderer/Context.h"
6 #include "core/core.h"
7 #include <string>
9 namespace awful { namespace gui
11 class ContainerWidget;
12 class Theme;
14 class Widget : public EventHandler
16 public:
17 Widget( Pointer< Theme > pTheme_ );
18 Widget( Pointer< ContainerWidget > pParent_ );
20 virtual ~Widget() {}
22 Signal<> m_Layout;
23 Signal< Pointer< renderer::Context > > m_Render;
25 virtual void reLayout()
27 m_Layout();
30 void doRender( Pointer< renderer::Context > pContext )
32 m_Render( pContext );
35 const float& getLeft() const { return m_Left; }
36 void setLeft( const float& x ) { m_Left = x; }
38 const float& getTop() const { return m_Top; }
39 void setTop( const float& x ) { m_Top = x; }
41 const float& getWidth() const { return m_Width; }
42 void setWidth( const float& x ) { m_Width = x; }
44 const float& getHeight() const { return m_Height; }
45 void setHeight( const float& x ) { m_Height = x; }
47 const Pointer< Theme >& getTheme() const { return m_Theme; }
48 void setTheme( const Pointer< Theme >& x ) { m_Theme = x; }
50 bool isInside( float x, float y ) const
52 float right = m_Left + m_Width - 1.f;
53 float bottom = m_Top + m_Height - 1.f;
54 return x >= m_Left && x < right
55 && y >= m_Top && y < bottom;
59 protected:
60 float m_Left;
61 float m_Top;
62 float m_Width;
63 float m_Height;
65 Pointer< Theme > m_Theme;
69 #endif