ganeswidgets/src/hgmediawallrenderer.cpp
changeset 13 8bf920201dea
parent 9 dde80bf4a8c7
child 19 31a1a9e11046
equal deleted inserted replaced
9:dde80bf4a8c7 13:8bf920201dea
   434     {
   434     {
   435         mScrollDirection = Qt::Horizontal;
   435         mScrollDirection = Qt::Horizontal;
   436         mNextScrollDirection = mScrollDirection;
   436         mNextScrollDirection = mScrollDirection;
   437         return;
   437         return;
   438     }
   438     }
   439     
   439         
   440     if (mScrollDirection != scrollDirection)
   440     if (mScrollDirection != scrollDirection)
   441     {
   441     {
   442         mStateMachine->setAnimated(animate);
   442         mStateMachine->setAnimated(animate);
   443         mNextScrollDirection = scrollDirection;
   443         mNextScrollDirection = scrollDirection;
   444 
   444 
   447         }
   447         }
   448         else
   448         else
   449         {
   449         {
   450             //emit renderingNeeded();            
   450             //emit renderingNeeded();            
   451         }
   451         }
   452     } else if (!animate) {
   452     } else {
   453         // reset next scrolldirection just to be sure. In some cases
   453         // reset next scrolldirection just to be sure. In some cases
   454         // when orientation changes couple of times and container visibility changes
   454         // when orientation changes couple of times and container visibility changes
   455         // we might otherwise end up in wrong state.
   455         // we might otherwise end up in wrong state.
   456         mNextScrollDirection = scrollDirection;
   456         mNextScrollDirection = scrollDirection;
   457     }
   457     }
   659 {
   659 {
   660     return mRenderer->reflectionsEnabled();
   660     return mRenderer->reflectionsEnabled();
   661 }
   661 }
   662     
   662     
   663 qreal HgMediaWallRenderer::getWorldWidth() const
   663 qreal HgMediaWallRenderer::getWorldWidth() const
   664 {   
   664 {
   665     qreal width = ceil((qreal)mDataProvider->imageCount() / (qreal)mRowCount - 1.0f);
   665     qreal worldWidth = ceil((qreal)mDataProvider->imageCount() / (qreal)mRowCount);
   666     
   666     qreal worldWidthAsIndex = worldWidth - 1.0f;
       
   667 
   667     // if we are in vertical orientation we want last and first item
   668     // if we are in vertical orientation we want last and first item
   668     // to place at the top and bottom of the screen instead of center
   669     // to place at the top and bottom of the screen instead of center
   669     if (mScrollDirection == Qt::Vertical)
   670     if (mScrollDirection == Qt::Vertical)
   670     {
   671     {
   671         qreal step = mSpacing2D.height() + mImageSize2D.height(); 
   672         qreal step = mSpacing2D.height() + mImageSize2D.height();
   672         width -= (mRect.height() / step - 1.0f);
   673         qreal screenWidth = mRect.height() / step;
       
   674         if(worldWidth > screenWidth) //do the items take over one screenful?
       
   675         {
       
   676             worldWidthAsIndex -= (screenWidth - 1.0f);
       
   677         }
       
   678         else
       
   679         {
       
   680             // all items fit to one screenful
       
   681             return 0;
       
   682         }
   673     }
   683     }
   674     else if (mScrollDirection == Qt::Horizontal && !mCoverflowMode)
   684     else if (mScrollDirection == Qt::Horizontal && !mCoverflowMode)
   675     {
   685     {
   676         qreal step = mSpacing2D.width() + mImageSize2D.width();
   686         qreal step = mSpacing2D.width() + mImageSize2D.width();
   677         width -= (mRect.width() / step - 1.0f);
   687         qreal screenWidth = mRect.width() / step;
   678     }
   688         if(worldWidth > screenWidth) //do the items take over one screenful?
   679        
   689         {
   680     return width;
   690             worldWidthAsIndex -= (screenWidth - 1.0f);
       
   691         }
       
   692         else
       
   693         {
       
   694             // all items fit to one screenful
       
   695             return 0;
       
   696         }
       
   697     }
       
   698     
       
   699     return worldWidthAsIndex;
   681 }
   700 }
   682 
   701 
   683 
   702 
   684 void HgMediaWallRenderer::createAnimatedQuads(const HgAnimatedQuadFactory& factory)
   703 void HgMediaWallRenderer::createAnimatedQuads(const HgAnimatedQuadFactory& factory)
   685 {
   704 {