ginebra2/animators/SlideAnimator.cpp
changeset 3 0954f5dd2cd0
parent 0 1450b09d0cfd
equal deleted inserted replaced
1:b0dd75e285d2 3:0954f5dd2cd0
     1 /*
     1 /*
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
     4 *
     9 * Initial Contributors:
     5 * This program is free software: you can redistribute it and/or modify
    10 * Nokia Corporation - initial contribution.
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
    11 *
     8 *
    12 * Contributors:
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
    13 *
    13 *
    14 * Description: 
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not,
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:
    15 *
    19 *
    16 */
    20 */
    17 
       
    18 
    21 
    19 #include "SlideAnimator.h"
    22 #include "SlideAnimator.h"
    20 #include "../ChromeSnippet.h"
    23 #include "../ChromeSnippet.h"
    21 #include <QList>
    24 #include <QList>
    22 #include <QDebug>
    25 #include <QDebug>
    23 
    26 
    24 namespace GVA {
    27 namespace GVA {
    25 
    28 
    26 SlideAnimator::SlideAnimator(ChromeSnippet* m_snippet) 
    29 SlideAnimator::SlideAnimator(ChromeSnippet* m_snippet)
    27   : VisibilityAnimator(m_snippet)
    30   : VisibilityAnimator(m_snippet)
    28 {
    31 {
    29   //  m_visiblePosition = m_snippet->widget()->pos();
    32   //  m_visiblePosition = m_snippet->widget()->pos();
    30   setDirection("up");
    33   setDirection("up");
    31   m_originalTransform = m_snippet->widget()->transform();
    34   m_originalTransform = m_snippet->widget()->transform();
    37 
    40 
    38 void SlideAnimator::setDirection(const QString & direction)
    41 void SlideAnimator::setDirection(const QString & direction)
    39 {
    42 {
    40   m_direction = direction;
    43   m_direction = direction;
    41 
    44 
    42   if(m_direction == "up"){
    45   if (m_direction == "up"){
    43     m_xRange = 0;
    46     m_xRange = 0;
    44     m_yRange = -m_snippet->widget()->size().height();
    47     m_yRange = -m_snippet->widget()->size().height();
    45   }
    48   }
    46   else if(m_direction == "down"){
    49   else if (m_direction == "down"){
    47     m_xRange = 0;
    50     m_xRange = 0;
    48     m_yRange = m_snippet->widget()->size().height();
    51     m_yRange = m_snippet->widget()->size().height();
    49   }  
    52   }
    50   else if(m_direction == "left"){
    53   else if (m_direction == "left"){
    51     m_xRange = -m_snippet->widget()->size().width();
    54     m_xRange = -m_snippet->widget()->size().width();
    52     m_yRange = 0;
    55     m_yRange = 0;
    53   }  
    56   }
    54   else if(m_direction == "right"){
    57   else if (m_direction == "right"){
    55     m_xRange = m_snippet->widget()->size().width();
    58     m_xRange = m_snippet->widget()->size().width();
    56     m_yRange = 0;
    59     m_yRange = 0;
    57   }  
    60   }
    58 }
    61 }
    59 
    62 
    60 void SlideAnimator::updateVisibility(qreal step)
    63 void SlideAnimator::updateVisibility(qreal step)
    61 {
    64 {
    62   qDebug() << step;
       
    63   QTransform transform = m_originalTransform;
    65   QTransform transform = m_originalTransform;
    64   transform.translate(step*m_xRange, step*m_yRange);
    66   transform.translate(step*m_xRange, step*m_yRange);
    65   m_snippet->widget()->setTransform(transform);
    67   m_snippet->widget()->setTransform(transform);
    66   emit moving(step);
    68   emit moving(step);
    67 }
    69 }