Merge "DALi Version 1.2.21" into devel/master
[platform/core/uifw/dali-demo.git] / examples / item-view / item-view-example.cpp
index aeb1d2e..f93aaec 100644 (file)
@@ -133,6 +133,8 @@ const float LABEL_TEXT_SIZE_Y = 20.0f;
 
 const Vector3 INITIAL_OFFSCREEN_POSITION( 1000.0f, 0, -1000.0f );
 
+const float SCROLL_TO_ITEM_ANIMATION_TIME = 5.f;
+
 static Vector3 DepthLayoutItemSizeFunctionPortrait( float layoutWidth )
 {
   float width = ( layoutWidth / ( DEPTH_LAYOUT_COLUMNS + 1.0f ) ) * DEPTH_LAYOUT_ITEM_SIZE_FACTOR_PORTRAIT;
@@ -300,6 +302,10 @@ public:
     // Set the title and icon to the current layout
     SetLayoutTitle();
     SetLayoutImage();
+
+    mLongPressDetector = LongPressGestureDetector::New();
+    mLongPressDetector.Attach( mItemView );
+    mLongPressDetector.DetectedSignal().Connect( this, &ItemViewExample::OnLongPress );
   }
 
   Actor OnKeyboardPreFocusChange( Actor current, Actor proposed, Control::KeyboardFocus::Direction direction )
@@ -540,6 +546,35 @@ public:
     }
   }
 
+  void OnLongPress( Actor actor, const LongPressGesture& gesture )
+  {
+    switch( gesture.state )
+    {
+      case Gesture::Started:
+      {
+        const Size& size = Stage::GetCurrent().GetSize();
+
+        ItemRange range( 0u, 0u );
+        mItemView.GetItemsRange( range );
+
+        const unsigned int item = ( gesture.screenPoint.y < 0.5f * size.height ) ? range.begin : range.end;
+        mItemView.ScrollToItem( item, SCROLL_TO_ITEM_ANIMATION_TIME );
+
+        break;
+      }
+      case Gesture::Finished:
+      {
+        Property::Map attributes;
+        mItemView.DoAction( "stopScrolling", attributes );
+        break;
+      }
+      default:
+      {
+        break;
+      }
+    }
+  }
+
   bool OnDeleteButtonClicked( Toolkit::Button button )
   {
     ItemIdContainer removeList;
@@ -843,10 +878,10 @@ public: // From ItemFactory
     borderActor.SetColorMode( USE_PARENT_COLOR );
 
     Property::Map borderProperty;
-    borderProperty.Insert( "rendererType", "border" );
-    borderProperty.Insert( "borderColor", Color::WHITE );
-    borderProperty.Insert( "borderSize", ITEM_BORDER_SIZE );
-    borderProperty.Insert( "antiAliasing", true );
+    borderProperty.Insert( Visual::Property::TYPE, Visual::BORDER );
+    borderProperty.Insert( BorderVisual::Property::COLOR, Color::WHITE );
+    borderProperty.Insert( BorderVisual::Property::SIZE, ITEM_BORDER_SIZE );
+    borderProperty.Insert( BorderVisual::Property::ANTI_ALIASING, true );
     borderActor.SetProperty( ImageView::Property::IMAGE, borderProperty );
 
     actor.Add(borderActor);
@@ -867,8 +902,8 @@ public: // From ItemFactory
     checkbox.SetZ( 0.1f );
 
     Property::Map solidColorProperty;
-    solidColorProperty.Insert( "rendererType", "color" );
-    solidColorProperty.Insert( "blendColor", Vector4(0.f, 0.f, 0.f, 0.6f) );
+    solidColorProperty.Insert( Visual::Property::TYPE, Visual::COLOR );
+    solidColorProperty.Insert( ColorVisual::Property::MIX_COLOR, Vector4(0.f, 0.f, 0.f, 0.6f) );
     checkbox.SetProperty( ImageView::Property::IMAGE, solidColorProperty );
 
     if( MODE_REMOVE_MANY  != mMode &&
@@ -954,6 +989,8 @@ private:
   Toolkit::PushButton mDeleteButton;
   Toolkit::PushButton mInsertButton;
   Toolkit::PushButton mReplaceButton;
+
+  LongPressGestureDetector mLongPressDetector;
 };
 
 void RunTest(Application& app)