// EXTERNAL INCLUDES
#include <algorithm>
+#include <cmath> // abs<float>
// INTERNAL INCLUDES
#include <dali/integration-api/events/touch-event-integ.h>
* @param[in] touchPoint The point to add.
* @param[in] pointTime The time of the point event.
*/
- PointInfo( const TouchPoint& touchPoint, unsigned long pointTime )
+ PointInfo( const Point& touchPoint, unsigned long pointTime )
: point( touchPoint ),
time( pointTime )
{
// Data
- TouchPoint point; ///< The point.
+ Point point; ///< The point.
unsigned long time; ///< The time the point event took place.
};
{
}
-TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( const TouchPoint& point, unsigned long time, TouchEvent& touchEvent, HoverEvent& hoverEvent )
+TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( const Point& point, unsigned long time, TouchEvent& touchEvent, HoverEvent& hoverEvent )
{
TouchEventCombiner::EventDispatchType dispatchEvent( TouchEventCombiner::DispatchNone );
+ const PointState::Type state = point.GetState();
+ const int deviceId = point.GetDeviceId();
- switch ( point.state )
+ switch ( state )
{
- case TouchPoint::Started:
+ case PointState::STARTED:
{
touchEvent.time = time;
bool addToContainer( true );
// Iterate through already stored touch points and add to TouchEvent
for ( PointInfoContainer::iterator iter = mPressedPoints.begin(), endIter = mPressedPoints.end(); iter != endIter; ++iter )
{
- if ( iter->point.deviceId != point.deviceId )
+ if ( iter->point.GetDeviceId() != deviceId )
{
- iter->point.state = TouchPoint::Stationary;
+ iter->point.SetState( PointState::STATIONARY );
}
else
{
PointInfoContainer::iterator match( mHoveredPoints.end() );
for ( PointInfoContainer::iterator iter = mHoveredPoints.begin(), endIter = mHoveredPoints.end(); iter != endIter; ++iter )
{
- if ( point.deviceId == iter->point.deviceId )
+ if ( deviceId == iter->point.GetDeviceId() )
{
match = iter;
// Add new point to the HoverEvent
- iter->point.state = TouchPoint::Finished;
+ iter->point.SetState( PointState::FINISHED );
hoverEvent.AddPoint( iter->point );
}
else
{
- iter->point.state = TouchPoint::Stationary;
+ iter->point.SetState( PointState::STATIONARY );
hoverEvent.AddPoint( iter->point );
}
}
break;
}
- case TouchPoint::Finished:
+ case PointState::FINISHED:
{
touchEvent.time = time;
PointInfoContainer::iterator match( mPressedPoints.end() );
for ( PointInfoContainer::iterator iter = mPressedPoints.begin(), endIter = mPressedPoints.end(); iter != endIter; ++iter )
{
- if ( point.deviceId == iter->point.deviceId )
+ if ( deviceId == iter->point.GetDeviceId() )
{
match = iter;
}
else
{
- iter->point.state = TouchPoint::Stationary;
+ iter->point.SetState( PointState::STATIONARY );
touchEvent.AddPoint( iter->point );
}
}
// Iterate through already stored touch points for HoverEvent and delete them
for ( PointInfoContainer::iterator iter = mHoveredPoints.begin(), endIter = mHoveredPoints.end(); iter != endIter; ++iter )
{
- if ( iter->point.deviceId == point.deviceId )
+ if ( iter->point.GetDeviceId() == deviceId )
{
- mHoveredPoints.erase( iter );
+ iter = mHoveredPoints.erase( iter );
}
}
}
break;
}
- case TouchPoint::Motion:
+ case PointState::MOTION:
{
bool fromNewDeviceId = false;
bool ignore = false;
PointInfoContainer::iterator match = mPressedPoints.end();
+ const Vector2& pointScreenPosition = point.GetScreenPosition();
for ( PointInfoContainer::iterator iter = mPressedPoints.begin(), endIter = mPressedPoints.end(); iter != endIter; ++iter )
{
- if ( point.deviceId == iter->point.deviceId )
+ if ( deviceId == iter->point.GetDeviceId() )
{
unsigned long timeDiff( time - iter->time );
break;
}
- if ( ( abs( point.screen.x - iter->point.screen.x ) < mMinMotionDistance.x ) &&
- ( abs( point.screen.y - iter->point.screen.y ) < mMinMotionDistance.y ) )
+ const Vector2& currentScreenPosition = iter->point.GetScreenPosition();
+ if ( ( std::abs( pointScreenPosition.x - currentScreenPosition.x ) < mMinMotionDistance.x ) &&
+ ( std::abs( pointScreenPosition.y - currentScreenPosition.y ) < mMinMotionDistance.y ) )
{
// Not enough positional change from last event so ignore
ignore = true;
}
else
{
- iter->point.state = TouchPoint::Stationary;
+ iter->point.SetState( PointState::STATIONARY );
touchEvent.AddPoint( iter->point );
}
}
// Iterate through already stored touch points and add to HoverEvent
bool ignore = false;
PointInfoContainer::iterator match = mHoveredPoints.end();
+ const Vector2& pointScreenPosition = point.GetScreenPosition();
for ( PointInfoContainer::iterator iter = mHoveredPoints.begin(), endIter = mHoveredPoints.end(); iter != endIter; ++iter )
{
- if ( iter->point.deviceId == point.deviceId )
+ if ( iter->point.GetDeviceId() == deviceId )
{
unsigned long timeDiff( time - iter->time );
break;
}
- if ( ( abs( point.screen.x - iter->point.screen.x ) < mMinMotionDistance.x ) &&
- ( abs( point.screen.y - iter->point.screen.y ) < mMinMotionDistance.y ) )
+ const Vector2& currentScreenPosition = iter->point.GetScreenPosition();
+ if ( ( std::abs( pointScreenPosition.x - currentScreenPosition.x ) < mMinMotionDistance.x ) &&
+ ( std::abs( pointScreenPosition.y - currentScreenPosition.y ) < mMinMotionDistance.y ) )
{
// Not enough positional change from last event so ignore
ignore = true;
}
else
{
- iter->point.state = TouchPoint::Stationary;
+ iter->point.SetState( PointState::STATIONARY );
hoverEvent.AddPoint( iter->point );
}
}
{
if( match == mHoveredPoints.end() )
{
- TouchPoint hoverPoint(point);
- hoverPoint.state = TouchPoint::Started; // The first hover event received
+ Point hoverPoint(point);
+ hoverPoint.SetState( PointState::STARTED ); // The first hover event received
mHoveredPoints.push_back( PointInfo( hoverPoint, time ) );
hoverEvent.AddPoint( hoverPoint );
}
break;
}
- case TouchPoint::Interrupted:
+ case PointState::INTERRUPTED:
{
Reset();