Harmonic Flow Framework (libhffwk)
Cross platform C++ 2D Game Engine Framework
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
HFCore::Mouse Class Reference

Interface for input type Mouse. More...

#include <Mouse.h>

Inheritance diagram for HFCore::Mouse:
Inheritance graph
[legend]

Classes

struct  MouseInfo
 A structure that contains Mouse event information. More...
 

Public Types

enum  Button { BUTTON_LEFT = 0, BUTTON_MIDDLE = 1, BUTTON_RIGHT = 2, BUTTON_UNKNOWN = 0xff }
 Mouse button enum. More...
 

Public Member Functions

 Mouse (int32_hf id)
 Constructor. More...
 
virtual ~Mouse ()
 Destructor.
 
const Vector2getPosition ()
 Get Mouse position. More...
 
void setPosition (const Vector2 &pos)
 Set Mouse position. More...
 
int32_hf getId ()
 Get Mouse ID. More...
 
Mouse::MouseInfo getMouseInfoDefaults (uint32_hf windowID)
 Get initialized MouseInfo structure. More...
 
bool isVisible ()
 Determines whether Mouse is visible or not. More...
 
void setVisible (bool visible)
 Set Mouse visibility. More...
 
bool isInBounds ()
 Determines whether the Mouse is in bounds or not. More...
 
bool getButtonsEnabled ()
 Determines whether Mouse buttons is enabled or not. More...
 
void setButtonsEnabled (bool enabled)
 Set Mouse buttons enabled / disabled. More...
 
bool isButtonDown (Button button)
 Determines whether given Mouse button is down or not. More...
 
void addListener (MouseListener *listener)
 Add a new listener class to receive MouseListener callbacks. More...
 
void removeListener (MouseListener *listener)
 Remove a listener class from receiving further MouseListener callbacks. More...
 
void fireMoveEvent (MouseInfo mouse)
 Called internally when a Mouse motion event occurs. It calls MouseListener::mouseMove(). More...
 
void fireDownEvent (MouseInfo mouse)
 Called internally when a Mouse button down event occurs. It calls MouseListener::mouseButtonDown(). More...
 
void fireUpEvent (MouseInfo mouse)
 Called internally when a Mouse button up event occurs. It calls MouseListener::mouseButtonUp(). More...
 
void fireWheelEvent (MouseInfo mouse)
 Called internally when a Mouse wheel event occurs. It calls MouseListener::mouseWheel(). More...
 
void fireEnterEvent (MouseInfo mouse)
 Called internally when a Mouse enter event occurs. It calls MouseListener::mouseEnter(). More...
 
void fireLeaveEvent (MouseInfo mouse)
 Called internally when a Mouse leave event occurs. It calls MouseListener::mouseLeave(). More...
 
virtual void setEnabled (bool enabled)
 Set controller enabled or disabled. More...
 
virtual void setConnected (bool connected)
 Set controller connected or disconnected. More...
 
- Public Member Functions inherited from HFCore::Controller
 Controller ()
 Constructor.
 
virtual ~Controller ()
 Destructor.
 
virtual bool isEnabled ()
 Check whether controller is enabled. More...
 
virtual bool isConnected ()
 Check whether controller is connected. More...
 

Protected Attributes

MouseListenerVector mListeners
 Vector holding MouseListener classes.
 
Vector2 mPosition
 Vector2 holding Mouse position.
 
bool mIsVisible
 Mouse visibility.
 
int32_hf mId
 Mouse ID.
 
bool mButtonsEnabled
 Mouse buttons enabled / disabled.
 
bool mIsInBounds
 Mouse in bounds.
 
bool mIsButtonDown [3]
 Mouse button array for holding button down or not for Left, Middle and Right buttons.
 

Detailed Description

Interface for input type Mouse.

See MouseListener for methods available as callbacks for registered listeners.

Definition at line 46 of file Mouse.h.

Member Enumeration Documentation

◆ Button

Mouse button enum.

Enumerator
BUTTON_LEFT 

Left button.

BUTTON_MIDDLE 

Middle button.

BUTTON_RIGHT 

Right button.

BUTTON_UNKNOWN 

No button pressed.

Definition at line 52 of file Mouse.h.

Constructor & Destructor Documentation

◆ Mouse()

Mouse::Mouse ( int32_hf  id)

Constructor.

Parameters
idMouse ID.

Definition at line 36 of file Mouse.cpp.

Member Function Documentation

◆ addListener()

void Mouse::addListener ( MouseListener listener)

Add a new listener class to receive MouseListener callbacks.

Parameters
listenerClass to add as listener.
See also
removeListener()

Definition at line 61 of file Mouse.cpp.

◆ fireDownEvent()

void Mouse::fireDownEvent ( MouseInfo  mouse)

Called internally when a Mouse button down event occurs. It calls MouseListener::mouseButtonDown().

Parameters
mouseMouseInfo structure.

Definition at line 89 of file Mouse.cpp.

◆ fireEnterEvent()

void Mouse::fireEnterEvent ( MouseInfo  mouse)

Called internally when a Mouse enter event occurs. It calls MouseListener::mouseEnter().

Parameters
mouseMouseInfo structure.

Definition at line 130 of file Mouse.cpp.

◆ fireLeaveEvent()

void Mouse::fireLeaveEvent ( MouseInfo  mouse)

Called internally when a Mouse leave event occurs. It calls MouseListener::mouseLeave().

Parameters
mouseMouseInfo structure.

Definition at line 147 of file Mouse.cpp.

◆ fireMoveEvent()

void Mouse::fireMoveEvent ( MouseInfo  mouse)

Called internally when a Mouse motion event occurs. It calls MouseListener::mouseMove().

Parameters
mouseMouseInfo structure.

Definition at line 73 of file Mouse.cpp.

◆ fireUpEvent()

void Mouse::fireUpEvent ( MouseInfo  mouse)

Called internally when a Mouse button up event occurs. It calls MouseListener::mouseButtonUp().

Parameters
mouseMouseInfo structure.

Definition at line 103 of file Mouse.cpp.

◆ fireWheelEvent()

void Mouse::fireWheelEvent ( MouseInfo  mouse)

Called internally when a Mouse wheel event occurs. It calls MouseListener::mouseWheel().

Parameters
mouseMouseInfo structure.

Definition at line 117 of file Mouse.cpp.

◆ getButtonsEnabled()

bool Mouse::getButtonsEnabled ( )

Determines whether Mouse buttons is enabled or not.

Returns
true if enabled, else false.
See also
setButtonsEnabled()

Definition at line 218 of file Mouse.cpp.

◆ getId()

int32_hf HFCore::Mouse::getId ( )
inline

Get Mouse ID.

Returns
Mouse ID.

Definition at line 112 of file Mouse.h.

◆ getMouseInfoDefaults()

Mouse::MouseInfo Mouse::getMouseInfoDefaults ( uint32_hf  windowID)

Get initialized MouseInfo structure.

Parameters
windowIDWindow ID.
Returns
Initialized MouseInfo structure.

Definition at line 174 of file Mouse.cpp.

◆ getPosition()

const Vector2 & Mouse::getPosition ( )

Get Mouse position.

Returns
Vector2 position.
See also
setPosition()

Definition at line 164 of file Mouse.cpp.

◆ isButtonDown()

bool Mouse::isButtonDown ( Button  button)

Determines whether given Mouse button is down or not.

Parameters
buttonMouse button to check if down.
Returns
true if button is down, else false.

Definition at line 229 of file Mouse.cpp.

◆ isInBounds()

bool Mouse::isInBounds ( )

Determines whether the Mouse is in bounds or not.

Returns
true if in bounds, else false.

Definition at line 238 of file Mouse.cpp.

◆ isVisible()

bool Mouse::isVisible ( )

Determines whether Mouse is visible or not.

Returns
true if visible, else false.
See also
setVisible()

Definition at line 56 of file Mouse.cpp.

◆ removeListener()

void Mouse::removeListener ( MouseListener listener)

Remove a listener class from receiving further MouseListener callbacks.

Parameters
listenerClass to remove as listener.
See also
addListener()

Definition at line 67 of file Mouse.cpp.

◆ setButtonsEnabled()

void Mouse::setButtonsEnabled ( bool  enabled)

Set Mouse buttons enabled / disabled.

Parameters
enabledtrue to enable, else false.
See also
getButtonsEnabled()

Definition at line 223 of file Mouse.cpp.

◆ setConnected()

void Mouse::setConnected ( bool  connected)
virtual

Set controller connected or disconnected.

Parameters
connectedtrue if connected, else false.
See also
isConnected()

Reimplemented from HFCore::Controller.

Definition at line 190 of file Mouse.cpp.

◆ setEnabled()

void Mouse::setEnabled ( bool  enabled)
virtual

Set controller enabled or disabled.

Parameters
enabledtrue to enable, else false.
See also
isEnabled()

Reimplemented from HFCore::Controller.

Definition at line 212 of file Mouse.cpp.

◆ setPosition()

void Mouse::setPosition ( const Vector2 pos)

Set Mouse position.

Parameters
posVector2 position.
See also
getPosition()

Definition at line 169 of file Mouse.cpp.

◆ setVisible()

void Mouse::setVisible ( bool  visible)

Set Mouse visibility.

Parameters
visibletrue if visible, else false.
See also
isVisible()

Definition at line 51 of file Mouse.cpp.


The documentation for this class was generated from the following files: