2 #include "ButtonDecorator.h"
3 #include "EventManager.h"
6 using namespace awful::gui::game
;
8 Button::Button( Container
* pParent_
, const std::string
& Label_
) :
11 m_bDepressCheck( false )
14 m_pDecorator
= getTheme()->newButtonDecorator( this );
17 void Button::setLabel( const std::string
& Label_
)
23 void Button::mouseEnter( const math::Vector2f
& pos
)
25 m_State
= s_Hilighted
;
26 m_pDecorator
->updateState();
29 void Button::mouseExit()
32 m_pDecorator
->updateState();
35 bool Button::mouseMotionEvent( const math::Vector2f
& pos
, const math::Vector2f
& rel
)
37 EventManager
* pEventManager
= EventManager::GetInstance();
41 // we are currently waiting to see if the user will depress the button,
42 // update the idle/pressed state according to mouse position
43 m_State
= isInside( pos
) ? s_Pressed
: s_Idle
;
44 m_pDecorator
->updateState();
50 bool Button::mouseButtonEvent( const math::Vector2f
& pos
, e_MouseButton Button
, bool bPressed
)
52 if( Button
!= mb_Left
)
55 EventManager
* pEventManager
= EventManager::GetInstance();
60 m_bDepressCheck
= true;
61 pEventManager
->setCurrentMouseMotionHandler( this );
62 pEventManager
->setCurrentMouseButtonHandler( this );
63 setWantMouseMotion( true );
65 else if( m_bDepressCheck
)
67 m_bDepressCheck
= false;
68 pEventManager
->setCurrentMouseButtonHandler( 0 );
69 pEventManager
->setCurrentMouseMotionHandler( 0 );
70 setWantMouseMotion( false );
74 // The user released the mouse button inside the button:
75 // go to hilighted state and trigger the Depressed signal
76 m_State
= s_Hilighted
;
80 // Otherwise, turn back to idle state and do nothing
84 m_pDecorator
->updateState();
88 void Button::buildSceneGraph()
90 m_pDecorator
->buildSceneGraph( m_pFrame
, m_pRenderable
);
93 void Button::calcMinMax()
95 m_pDecorator
->calcMinMax();
100 m_pDecorator
->layout();