{
mObjectView = Pepper::ObjectView::New();
- mObjectView.TouchedSignal().Connect( this, &Object::OnTouched );
-
- // Set surface
+ // Set surface and input modules
Pepper::GetImplementation( mObjectView ).SetSurface( mSurface );
+ Pepper::GetImplementation( mObjectView ).SetInput( mPointer, mKeyboard, mTouch );
// TODO: support multi touch, focus in/out, mouse in/out
return mObjectViewDeletedSignal;
}
-bool Object::OnTouched( Actor actor, const TouchEvent& touchEvent )
-{
- const TouchPoint& point = touchEvent.GetPoint(0);
-
- Pepper::Internal::ShellClientPtr shellClient = reinterpret_cast< Pepper::Internal::ShellClient* >( pepper_object_get_user_data( reinterpret_cast< pepper_object_t* >( mSurface ), pepper_surface_get_role( mSurface ) ) );
- if( !shellClient )
- {
- DALI_LOG_INFO( gPepperObjectLogging, Debug::General, "Object::OnTouched: shellClient is null. mSurface = %p\n", mSurface );
- return false;
- }
-
- switch( point.state )
- {
- case TouchPoint::Down:
- {
- pepper_touch_add_point( mTouch, point.deviceId, point.local.x, point.local.y );
- pepper_touch_send_down( mTouch, shellClient->GetView(), touchEvent.time, point.deviceId, point.local.x, point.local.y );
-
- DALI_LOG_INFO( gPepperObjectLogging, Debug::Verbose, "Object::OnTouched: Touch Down (%.2f, %.2f) device = %d surface = %p\n", point.local.x, point.local.y, point.deviceId, mSurface );
- return true;
- }
- case TouchPoint::Up:
- {
- pepper_touch_send_up( mTouch, shellClient->GetView(), touchEvent.time, point.deviceId );
- pepper_touch_remove_point( mTouch, point.deviceId );
-
- DALI_LOG_INFO( gPepperObjectLogging, Debug::Verbose, "Object::OnTouched: Touch Up (%.2f, %.2f) surface = %p\n", point.local.x, point.local.y, mSurface );
- return true;
- }
- case TouchPoint::Motion:
- {
- pepper_touch_send_motion( mTouch, shellClient->GetView(), touchEvent.time, point.deviceId, point.local.x, point.local.y );
-
-// DALI_LOG_INFO( gPepperObjectLogging, Debug::Verbose, "Object::OnTouched: Touch Motion (%.2f, %.2f)\n", point.local.x, point.local.y );
- return true;
- }
- default:
- {
- return false;
- }
- }
-
- return false;
-}
-
void Object::OnDestroySurface( pepper_event_listener_t* listener, pepper_object_t* pepperObject, uint32_t id, void* info, void* data )
{
Object* object = static_cast< Object* >( data );
#include <pepper-dali/internal/shell-client-impl.h>
// EXTERNAL INCLUDES
+#include <dali/public-api/events/touch-event.h>
#include <dali/integration-api/debug.h>
namespace Dali
: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS ) ),
mWidth( 0 ),
mHeight( 0 ),
- mSurface( NULL )
+ mTouchDown( false ),
+ mSurface( NULL ),
+ mPointer( NULL ),
+ mKeyboard( NULL ),
+ mTouch( NULL )
{
}
return appId;
}
+bool ObjectView::CancelTouchEvent()
+{
+ if( !mTouchDown )
+ {
+ return false;
+ }
+
+ Pepper::Internal::ShellClientPtr shellClient = reinterpret_cast< Pepper::Internal::ShellClient* >( pepper_object_get_user_data( reinterpret_cast< pepper_object_t* >( mSurface ), pepper_surface_get_role( mSurface ) ) );
+ if( !shellClient )
+ {
+ DALI_LOG_INFO( gPepperObjectViewLogging, Debug::General, "ObjectView::CancelTouchEvent: shellClient is null. mSurface = %p\n", mSurface );
+ return false;
+ }
+
+ pepper_touch_send_cancel( mTouch, shellClient->GetView() );
+ pepper_touch_remove_point( mTouch, 0 );
+
+ mTouchDown = false;
+
+ return true;
+}
+
void ObjectView::SetSurface( pepper_surface_t* surface )
{
mSurface = surface;
}
+void ObjectView::SetInput( pepper_pointer_t* pointer, pepper_keyboard_t* keyboard, pepper_touch_t* touch )
+{
+ mPointer = pointer;
+ mKeyboard = keyboard;
+ mTouch = touch;
+}
+
+bool ObjectView::OnTouchEvent( const TouchEvent& touchEvent )
+{
+ if( 1 == touchEvent.GetPointCount() )
+ {
+ const TouchPoint& point = touchEvent.GetPoint(0);
+
+ Pepper::Internal::ShellClientPtr shellClient = reinterpret_cast< Pepper::Internal::ShellClient* >( pepper_object_get_user_data( reinterpret_cast< pepper_object_t* >( mSurface ), pepper_surface_get_role( mSurface ) ) );
+ if( !shellClient )
+ {
+ DALI_LOG_INFO( gPepperObjectViewLogging, Debug::General, "ObjectView::OnTouchEvent: shellClient is null. mSurface = %p\n", mSurface );
+ return false;
+ }
+
+ switch( point.state )
+ {
+ case TouchPoint::Down:
+ {
+ mTouchDown = true;
+
+ pepper_touch_add_point( mTouch, point.deviceId, point.local.x, point.local.y );
+ pepper_touch_send_down( mTouch, shellClient->GetView(), touchEvent.time, point.deviceId, point.local.x, point.local.y );
+
+ DALI_LOG_INFO( gPepperObjectViewLogging, Debug::Verbose, "ObjectView::OnTouchEvent: Touch Down (%.2f, %.2f) device = %d surface = %p\n", point.local.x, point.local.y, point.deviceId, mSurface );
+ return true;
+ }
+ case TouchPoint::Up:
+ {
+ if( mTouchDown )
+ {
+ mTouchDown = false;
+
+ pepper_touch_send_up( mTouch, shellClient->GetView(), touchEvent.time, point.deviceId );
+ pepper_touch_remove_point( mTouch, point.deviceId );
+
+ DALI_LOG_INFO( gPepperObjectViewLogging, Debug::Verbose, "ObjectView::OnTouchEvent: Touch Up (%.2f, %.2f) surface = %p\n", point.local.x, point.local.y, mSurface );
+ return true;
+ }
+ break;
+ }
+ case TouchPoint::Motion:
+ {
+ pepper_touch_send_motion( mTouch, shellClient->GetView(), touchEvent.time, point.deviceId, point.local.x, point.local.y );
+
+// DALI_LOG_INFO( gPepperObjectViewLogging, Debug::Verbose, "ObjectView::OnTouchEvent: Touch Motion (%.2f, %.2f)\n", point.local.x, point.local.y );
+ return true;
+ }
+ default:
+ {
+ return false;
+ }
+ }
+ }
+
+ return false;
+}
+
void ObjectView::OnInitialize()
{
mImageView = Toolkit::ImageView::New();
std::string GetAppId() const;
/**
+ * @copydoc Dali::Pepper::ObjectView::CancelTouchEvent
+ */
+ bool CancelTouchEvent();
+
+ /**
* Set pepper surface
*/
void SetSurface( pepper_surface_t* surface );
+ /**
+ * Set pepper input modules
+ */
+ void SetInput( pepper_pointer_t* pointer, pepper_keyboard_t* keyboard, pepper_touch_t* touch );
+
protected:
/**
*/
virtual ~ObjectView();
+protected: // From CustomActorImpl
+
+ /**
+ * @copydoc Dali::CustomActorImpl::OnTouchEvent( const TouchEvent& event )
+ */
+ virtual bool OnTouchEvent( const TouchEvent& event );
+
private: // From Control
/**
int mWidth;
int mHeight;
+ bool mTouchDown;
+
pepper_surface_t* mSurface;
+ pepper_pointer_t* mPointer;
+ pepper_keyboard_t* mKeyboard;
+ pepper_touch_t* mTouch;
};
} // namespace Internal
return Dali::Pepper::GetImplementation( *this ).GetAppId();
}
+bool ObjectView::CancelTouchEvent()
+{
+ return Dali::Pepper::GetImplementation( *this ).CancelTouchEvent();
+}
+
ObjectView::ObjectView( Internal::ObjectView& implementation )
: Control( implementation )
{
*/
std::string GetAppId() const;
+ /**
+ * @brief Cancels touch event procedure.
+ *
+ * @since_tizen 3.0
+ * @return true on success, false otherwise.
+ */
+ bool CancelTouchEvent();
+
public: // Not intended for application developers
/**