Game Development Reference
In-Depth Information
{
if ( FActivePage ) FActivePage->Render();
}
void OnKey( vec2 MousePos, int Key, bool KeyState )
{
FMousePosition = MousePos;
if ( FActivePage ) FActivePage->OnKey( Key, KeyState );
}
void OnTouch( const LVector2& Pos, bool TouchState )
{
if ( FActivePage )
FActivePage->OnTouch( Pos, TouchState );
}
private:
vec2 FMousePosition;
clPtr<clGUIPage> FActivePage;
std::vector< clPtr<clGUIPage> > FPages;
};
5.
The page itself serves as a container for the clGUIButton objects:
class clGUIButton: public iObject
{
public:
clGUIButton( const LRect& R, const std::string Title,
clPtr<clGUIPage> Page )
: FRect(R)
, FTitle(Title)
, FPressed(false)
, FFallbackPage(Page) {}
virtual void Render();
virtual void OnTouch( const LVector2& Pos, bool
TouchState );
6.
The most important thing here is that clGUIButton can detect whether a touch
point is contained inside the button:
virtual bool Contains( const LVector2& Pos )
{
return FRect.ContainsPoint( Pos );
}
public:
LRect FRect;
std::string FTitle;
bool FPressed;
clPtr<clGUIPage> FFallbackPage;
};
 
Search WWH ::




Custom Search