CUGL 2.3
Cornell University Game Library
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
cugl::ButtonState Class Reference

#include <CUMouse.h>

Public Member Functions

 ButtonState ()
 
 ButtonState (Uint32 state)
 
bool hasLeft () const
 
bool hasMiddle () const
 
bool hasRight () const
 
bool hasX1 () const
 
bool hasX2 () const
 
void setLeft (bool value)
 
void setMiddle (bool value)
 
void setRight (bool value)
 
void setX1 (bool value)
 
void setX2 (bool value)
 
ButtonStateoperator&= (ButtonState mouse)
 
ButtonStateoperator|= (ButtonState mouse)
 
ButtonStateoperator^= (ButtonState mouse)
 
ButtonStateoperator-= (ButtonState mouse)
 
const ButtonState operator& (ButtonState mouse) const
 
const ButtonState operator| (ButtonState mouse) const
 
const ButtonState operator^ (ButtonState mouse) const
 
const ButtonState operator- (ButtonState mouse) const
 
const ButtonState operator~ () const
 

Friends

class MouseEvent
 

Detailed Description

This class is a bit vector representing a mouse and a set of mouse buttons

As this class is intended to be used as a bit set, it supports bit-wise operations for combining mouse states together.

The exact meaning of a ButtonState depends on the context. It could be a set of buttons held down. It could be a set of buttons recently released. It is simply a way to record a set of buttons.

Constructor & Destructor Documentation

◆ ButtonState() [1/2]

cugl::ButtonState::ButtonState ( )
inline

Creates an empty mouse state with no buttons

◆ ButtonState() [2/2]

cugl::ButtonState::ButtonState ( Uint32  state)
inline

Creates a mouse state from the given collection of masks.

Parameters
stateA collection of SDL button masks.

Member Function Documentation

◆ hasLeft()

bool cugl::ButtonState::hasLeft ( ) const
inline

Returns true if this state has the left button included

Returns
true if this state has the left button included

◆ hasMiddle()

bool cugl::ButtonState::hasMiddle ( ) const
inline

Returns true if this state has the middle button included

Returns
true if this state has the middle button included

◆ hasRight()

bool cugl::ButtonState::hasRight ( ) const
inline

Returns true if this state has the right button included

Returns
true if this state has the right button included

◆ hasX1()

bool cugl::ButtonState::hasX1 ( ) const
inline

Returns true if this state has the first extra button included

This button only appears on mice that have four or more buttons. It is occasionally mapped to the scroll wheel buton.

Returns
true if this state has the first extra button included

◆ hasX2()

bool cugl::ButtonState::hasX2 ( ) const
inline

Returns true if this state has the second extra button included

This button only appears on mice that have five or more buttons.

Returns
true if this state has the first extra button included

◆ operator&()

const ButtonState cugl::ButtonState::operator& ( ButtonState  mouse) const
inline

Returns the intersection of these buttons with those in mouse.

The new state will be equivalent to this one if mouse is a different device than this one. If they are the same, the new state will contain those buttons that are in both the state of this object and mouse.

Parameters
mouseThe mouse state to interset with
Returns
the intersection of these buttons with those in mouse.

◆ operator&=()

ButtonState & cugl::ButtonState::operator&= ( ButtonState  mouse)
inline

Assigns the intersection of these buttons with those in mouse.

This method will do nothing if mouse is a different device from this one. If the are the same, this mouse state will now contain those buttons that are in both the state this object and mouse.

Parameters
mouseThe mouse state to interset with
Returns
This mouse state after modification, for chaining

◆ operator-()

const ButtonState cugl::ButtonState::operator- ( ButtonState  mouse) const
inline

Returns the set difference of these buttons exluding those in mouse.

The new state will be equivalent to this one if mouse is a different device than this one. If they are the same, the new state will contain those buttons that are in this state of this object, but not in mouse.

Parameters
mouseThe mouse state to exclude
Returns
the set difference of these buttons exluding those in mouse.

◆ operator-=()

ButtonState & cugl::ButtonState::operator-= ( ButtonState  mouse)
inline

Assigns the set difference of these buttons exluding those in mouse.

This method will do nothing if mouse is a different device from this one. If the are the same, this mouse state will now contain those buttons that are in the state of this object, but not in mouse.

Parameters
mouseThe mouse state to exclude
Returns
This mouse state after modification, for chaining

◆ operator^()

const ButtonState cugl::ButtonState::operator^ ( ButtonState  mouse) const
inline

Returns the symmetric difference of these buttons with those in mouse.

The new state will be equivalent to this one if mouse is a different device than this one. If they are the same, the new state will contain those buttons that are in either the state of this object or in mouse, but not in both.

Parameters
mouseThe mouse state to symmetric difference with
Returns
the symmetric difference of these buttons with those in mouse.

◆ operator^=()

ButtonState & cugl::ButtonState::operator^= ( ButtonState  mouse)
inline

Assigns the symmetric difference of these buttons with those in mouse.

This method will do nothing if mouse is a different device from this one. If the are the same, this mouse state will now contain those buttons that are in either the state of this object or in mouse, but not in both.

Parameters
mouseThe mouse state to symmetric difference with
Returns
This mouse state after modification, for chaining

◆ operator|()

const ButtonState cugl::ButtonState::operator| ( ButtonState  mouse) const
inline

Returns the union of these buttons with those in mouse.

The new state will be equivalent to this one if mouse is a different device than this one. If they are the same, the new state will contain those buttons that are in either the state of this object or in mouse.

Parameters
mouseThe mouse state to union with
Returns
the union of these buttons with those in mouse.

◆ operator|=()

ButtonState & cugl::ButtonState::operator|= ( ButtonState  mouse)
inline

Assigns the union of these buttons with those in mouse.

This method will do nothing if mouse is a different device from this one. If the are the same, this mouse state will now contain those buttons that are in either the state of this object or in mouse.

Parameters
mouseThe mouse state to union with
Returns
This mouse state after modification, for chaining

◆ operator~()

const ButtonState cugl::ButtonState::operator~ ( ) const
inline

Returns the complement of this set of buttons.

The new mouse state will contain those buttons that are not in the state of this object.

Returns
the complement of this set of buttons.

◆ setLeft()

void cugl::ButtonState::setLeft ( bool  value)
inline

Sets whether this state has the left button included

Parameters
valueWhether this state has the left button included

◆ setMiddle()

void cugl::ButtonState::setMiddle ( bool  value)
inline

Sets whether this state has the middle button included

Parameters
valueWhether this state has the middle button included

◆ setRight()

void cugl::ButtonState::setRight ( bool  value)
inline

Sets whether this state has the right button included

Parameters
valueWhether this state has the right button included

◆ setX1()

void cugl::ButtonState::setX1 ( bool  value)
inline

Sets whether this state has the first extra button included

This button only appears on mice that have four or more buttons. It is occasionally mapped to the scroll wheel buton.

Parameters
valueWhether this state has the first extra button included

◆ setX2()

void cugl::ButtonState::setX2 ( bool  value)
inline

Sets whether this state has the second extra button included

This button only appears on mice that have five or more buttons.

Parameters
valueWhether this state has the second extra button included

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