Implemented a mesh renderer to display 3D objects from files.
[platform/core/uifw/dali-demo.git] / demo / dali-table-view.cpp
index e1ff174..04cfaa3 100644 (file)
@@ -37,10 +37,10 @@ using namespace Dali::Toolkit;
 namespace
 {
 
-const std::string LOGO_PATH( DALI_IMAGE_DIR "Logo-for-demo.png" );
-const std::string DEFAULT_TOOLBAR_IMAGE_PATH( DALI_IMAGE_DIR "top-bar.png" );
-const std::string TILE_BACKGROUND(DALI_IMAGE_DIR "item-background.9.png");
-const std::string TILE_BACKGROUND_ALPHA(DALI_IMAGE_DIR "item-background-alpha.9.png");
+const std::string LOGO_PATH( DEMO_IMAGE_DIR "Logo-for-demo.png" );
+const std::string DEFAULT_TOOLBAR_IMAGE_PATH( DEMO_IMAGE_DIR "top-bar.png" );
+const std::string TILE_BACKGROUND(DEMO_IMAGE_DIR "item-background.9.png");
+const std::string TILE_BACKGROUND_ALPHA(DEMO_IMAGE_DIR "item-background-alpha.9.png");
 
 const char * const DEFAULT_TOOLBAR_TEXT( "TOUCH TO LAUNCH EXAMPLE" );
 
@@ -116,11 +116,10 @@ public:
     const Vector3& parentSize = inputs[1]->GetVector3();
     const Vector3& childSize = inputs[2]->GetVector3();
 
-    // Wrap bubbles verically.
-    if( position.y + childSize.y * 0.5f < -parentSize.y * 0.5f )
-    {
-      position.y = parentSize.y * 0.5f + childSize.y * 0.5f;
-    }
+    // Wrap bubbles vertically.
+    float range = parentSize.y + childSize.y;
+    // This performs a float mod (we don't use fmod as we want the arithmetic modulus as opposed to the remainder).
+    position.y -= range * ( floor( position.y / range ) + 0.5f );
 
     // Bubbles X position moves parallax to horizontal
     // panning by a scale factor unique to each bubble.
@@ -242,7 +241,7 @@ void DaliTableView::Initialize( Application& application )
   mScrollView.SetAxisAutoLock( true );
   mScrollView.ScrollCompletedSignal().Connect( this, &DaliTableView::OnScrollComplete );
   mScrollView.ScrollStartedSignal().Connect( this, &DaliTableView::OnScrollStart );
-  mScrollView.TouchedSignal().Connect( this, &DaliTableView::OnScrollTouched );
+  mScrollView.TouchSignal().Connect( this, &DaliTableView::OnScrollTouched );
 
   mScrollViewLayer = Layer::New();
 
@@ -300,8 +299,6 @@ void DaliTableView::Initialize( Application& application )
   unsigned int degrees = 0;
   Rotate( degrees );
 
-  //orientation.ChangedSignal().Connect( this, &DaliTableView::OrientationChanged );
-
   winHandle.ShowIndicator( Dali::Window::INVISIBLE );
 
   // Background animation
@@ -416,11 +413,6 @@ void DaliTableView::Populate()
   mScrollView.SetRulerY( mScrollRulerY );
 }
 
-void DaliTableView::OrientationChanged( Orientation orientation )
-{
-  // TODO: Implement if orientation change required
-}
-
 void DaliTableView::Rotate( unsigned int degrees )
 {
   // Resize the root actor
@@ -484,7 +476,7 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit
   content.SetKeyboardFocusable(true);
 
   // connect to the touch events
-  content.TouchedSignal().Connect( this, &DaliTableView::OnTilePressed );
+  content.TouchSignal().Connect( this, &DaliTableView::OnTilePressed );
   content.HoveredSignal().Connect( this, &DaliTableView::OnTileHovered );
 
   return content;
@@ -504,12 +496,16 @@ Toolkit::ImageView DaliTableView::NewStencilImage()
   return stencil;
 }
 
-bool DaliTableView::OnTilePressed( Actor actor, const TouchEvent& event )
+bool DaliTableView::OnTilePressed( Actor actor, const TouchData& event )
+{
+  return DoTilePress( actor, event.GetState( 0 ) );
+}
+
+bool DaliTableView::DoTilePress( Actor actor, PointState::Type pointState )
 {
   bool consumed = false;
 
-  const TouchPoint& point = event.GetPoint( 0 );
-  if( TouchPoint::Down == point.state )
+  if( PointState::DOWN == pointState )
   {
     mPressedActor = actor;
     consumed = true;
@@ -517,7 +513,7 @@ bool DaliTableView::OnTilePressed( Actor actor, const TouchEvent& event )
 
   // A button press is only valid if the Down & Up events
   // both occurred within the button.
-  if( ( TouchPoint::Up == point.state ) &&
+  if( ( PointState::UP == pointState ) &&
       ( mPressedActor == actor ) )
   {
     // ignore Example button presses when scrolling or button animating.
@@ -562,7 +558,7 @@ void DaliTableView::OnPressedAnimationFinished( Dali::Animation& source )
     std::string name = mPressedActor.GetName();
 
     std::stringstream stream;
-    stream << DALI_EXAMPLE_BIN << name.c_str();
+    stream << DEMO_EXAMPLE_BIN << name.c_str();
     pid_t pid = fork();
     if( pid == 0)
     {
@@ -589,10 +585,9 @@ void DaliTableView::OnScrollComplete( const Dali::Vector2& position )
   accessibilityManager.SetCurrentFocusActor(mPages[mScrollView.GetCurrentPage()].GetChildAt(0) );
 }
 
-bool DaliTableView::OnScrollTouched( Actor actor, const TouchEvent& event )
+bool DaliTableView::OnScrollTouched( Actor actor, const TouchData& event )
 {
-  const TouchPoint& point = event.GetPoint( 0 );
-  if( TouchPoint::Down == point.state )
+  if( PointState::DOWN == event.GetState( 0 ) )
   {
     mPressedActor = actor;
   }
@@ -698,11 +693,12 @@ void DaliTableView::InitialiseBackgroundActors( Actor actor )
     animConstraint.AddSource( Source( mScrollView, ScrollView::Property::SCROLL_POSITION ) );
     animConstraint.AddSource( Dali::ParentSource( Dali::Actor::Property::SIZE ) );
     animConstraint.AddSource( Dali::LocalSource( Dali::Actor::Property::SIZE ) );
+    animConstraint.SetRemoveAction( Constraint::Discard );
     animConstraint.Apply();
 
     // Kickoff animation
-    Animation animation = Animation::New( Random::Range( 40.0f, 80.0f ) );
-    animation.AnimateBy( Property( child, Actor::Property::POSITION ), Vector3( 0.0f, -1.0f, 0.0f ), AlphaFunction::LINEAR );
+    Animation animation = Animation::New( Random::Range( 30.0f, 160.0f ) );
+    animation.AnimateBy( Property( child, Actor::Property::POSITION ), Vector3( 0.0f, -2000.0f, 0.0f ), AlphaFunction::LINEAR );
     animation.SetLooping( true );
     animation.Play();
     mBackgroundAnimations.push_back( animation );
@@ -908,9 +904,7 @@ void DaliTableView::OnFocusedActorActivated( Dali::Actor activatedActor )
     mPressedActor = activatedActor;
 
     // Activate the current focused actor;
-    TouchEvent touchEventUp;
-    touchEventUp.points.push_back( TouchPoint ( 0, TouchPoint::Up, 0.0f, 0.0f ) );
-    OnTilePressed(mPressedActor, touchEventUp);
+    DoTilePress( mPressedActor, PointState::UP );
   }
 }