#include <wit/hotspot.h>
Public Member Functions | |
Hotspot () | |
virtual | ~Hotspot () |
bool | isEnabled () const |
void | setEnabled (bool on) |
Rect | boundingBox () const |
bool | boundingBoxContains (float x, float y) |
Polygon | region () const |
void | setRegion (const Rect &rect) |
void | setRegion (const Polygon &polygon) |
bool | contains (float x, float y) |
void | setEventHandler (EventHandler *handler) |
EventHandler * | eventHandler () const |
int | zIndex () const |
void | setZIndex (int z) |
Static Public Member Functions | |
static std::auto_ptr< HotspotList > | findAtPoint (float x, float y) |
The Hotspot class is used for dispatching PointerEvent events to EventHandler objects.
A hotspot is, in essence, a claim laid to a particular region of the screen. When a Wii Remote is pointed at this region, the pointer events generated by it are sent to the assigned eventHandler(). When the Wii Remote is moved out of the region, a PointerLeaveEvent is likewise generated and dispatched to the eventHandler().
An EventHandler may push itself onto the focus stack (see Application::pushFocus) in response to the first PointerEvent received and then remove itself (see Application::removeFromFocusStack) in response to receiving a PointerLeaveEvent in order to capture button presses sent while the Wii Remote is pointed at it.
Definition at line 15 of file hotspot.h.
wit::Hotspot::Hotspot | ( | ) |
Creates a new Hotspot object. The hotspot's region is initially empty.
Definition at line 37 of file hotspot.cpp.
wit::Hotspot::~Hotspot | ( | ) | [virtual] |
Destroys the Hotspot object.
Definition at line 49 of file hotspot.cpp.
Rect wit::Hotspot::boundingBox | ( | ) | const |
Returns the axis-aligned bounding box of the hotspot.
This bounding box is the smallest rectangle parallel to the sides of the screen that contains the entire region.
Definition at line 83 of file hotspot.cpp.
bool wit::Hotspot::boundingBoxContains | ( | float | x, |
float | y | ||
) |
Returns true if the specified point is contained within the hotspot's bounding box.
This operation is significantly faster than contains() for non-rectangular regions.
Definition at line 135 of file hotspot.cpp.
bool wit::Hotspot::contains | ( | float | x, |
float | y | ||
) |
Returns true if the specified point is contained within the hotspot's region.
Definition at line 146 of file hotspot.cpp.
EventHandler * wit::Hotspot::eventHandler | ( | ) | const |
Sets the event handler that will receive pointer events generated when the Wii Remote enters the hotspot's region.
Definition at line 171 of file hotspot.cpp.
std::auto_ptr< HotspotList > wit::Hotspot::findAtPoint | ( | float | x, |
float | y | ||
) | [static] |
Returns a list of all hotspots that contain the specified point.
Definition at line 204 of file hotspot.cpp.
bool wit::Hotspot::isEnabled | ( | ) | const |
Returns true if the hotspot is enabled.
Definition at line 59 of file hotspot.cpp.
Polygon wit::Hotspot::region | ( | ) | const |
void wit::Hotspot::setEnabled | ( | bool | on ) |
Sets whether or not the hotspot is enabled.
Hotspots will only be used for dispatching pointer events if they are enabled, non-empty (see region()), and have an event handler set (see eventHandler()).
Definition at line 72 of file hotspot.cpp.
void wit::Hotspot::setEventHandler | ( | EventHandler * | handler ) |
Sets the event handler that will receive pointer events generated when the Wii Remote enters the hotspot's region.
Definition at line 160 of file hotspot.cpp.
void wit::Hotspot::setRegion | ( | const Polygon & | polygon ) |
Sets the region of the hotspot to the specified polygon.
Definition at line 120 of file hotspot.cpp.
void wit::Hotspot::setRegion | ( | const Rect & | rect ) |
Sets the region of the hotspot to the specified rectangle.
Rectangular hotspot regions should be created using this overload, not by passing a rectangular polygon to the other overload, because it enables performance optimizations that cannot be done with arbitrary polygons.
Definition at line 106 of file hotspot.cpp.
void wit::Hotspot::setZIndex | ( | int | z ) |
Sets the Z-index of the hotspot.
If more than one hotspot lays claim to some portion of the screen, the hotspot with the greatest Z-index will receive the event. If multiple hotspots have the same Z-index, an arbitrarily selected hotspot will receive the event.
Definition at line 196 of file hotspot.cpp.
int wit::Hotspot::zIndex | ( | ) | const |
Returns the Z-index of the hotspot.
Definition at line 181 of file hotspot.cpp.