~ubuntu-branches/ubuntu/saucy/kblocks/saucy-proposed

« back to all changes in this revision

Viewing changes to KBlocksAnimator.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-12-07 17:39:13 UTC
  • Revision ID: package-import@ubuntu.com-20121207173913-5wqlq9suj93x4ap2
Tags: upstream-4.9.90
ImportĀ upstreamĀ versionĀ 4.9.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
*   KBlocks, a falling blocks game for KDE                                *
 
3
*   Copyright (C) 2009 Mauricio Piacentini <mauricio@tabuleiro.com>       *
 
4
*                      Zhongjie Cai <squall.leonhart.cai@gmail.com>       *
 
5
*                                                                         *
 
6
*   This program is free software; you can redistribute it and/or modify  *
 
7
*   it under the terms of the GNU General Public License as published by  *
 
8
*   the Free Software Foundation; either version 2 of the License, or     *
 
9
*   (at your option) any later version.                                   *
 
10
***************************************************************************/
 
11
#include "KBlocksAnimator.h"
 
12
 
 
13
KBlocksAnimator::KBlocksAnimator()
 
14
{
 
15
    mpAnimFade = 0;
 
16
    mpAnimDrop = 0;
 
17
}
 
18
 
 
19
KBlocksAnimator::~KBlocksAnimator()
 
20
{
 
21
    if (mpAnimDrop)
 
22
    {
 
23
        delete mpAnimDrop;
 
24
        mpAnimDrop = 0;
 
25
    }
 
26
    if (mpAnimFade)
 
27
    {
 
28
        delete mpAnimFade;
 
29
        mpAnimFade = 0;
 
30
    }
 
31
}
 
32
 
 
33
bool KBlocksAnimator::createFadeAnim(const QList<KBlocksSvgItem*> & items, int duration, QTimeLine::Direction direction)
 
34
{
 
35
    if (mpAnimFade)
 
36
    {
 
37
        return false;
 
38
    }
 
39
    
 
40
    mpAnimFade = new KBlocksAnimFade(items, duration, direction);
 
41
    
 
42
    if (direction == QTimeLine::Forward)
 
43
    {
 
44
        connect(mpAnimFade, SIGNAL(animationFinished()), this, SLOT(endFadeInAnim()));
 
45
    }
 
46
    else
 
47
    {
 
48
        connect(mpAnimFade, SIGNAL(animationFinished()), this, SLOT(endFadeOutAnim()));
 
49
    }
 
50
    
 
51
    return true;
 
52
}
 
53
 
 
54
bool KBlocksAnimator::deleteFadeAnim()
 
55
{
 
56
    if (mpAnimFade)
 
57
    {
 
58
        delete mpAnimFade;
 
59
        mpAnimFade = 0;
 
60
        return true;
 
61
    }
 
62
    return false;
 
63
}
 
64
 
 
65
KBlocksAnimFade* KBlocksAnimator::getFadeAnim()
 
66
{
 
67
    return mpAnimFade;
 
68
}
 
69
 
 
70
bool KBlocksAnimator::createDropAnim(const QList<KBlocksSvgItem*> & items, int duration, QTimeLine::Direction direction)
 
71
{
 
72
    if (mpAnimDrop)
 
73
    {
 
74
        return false;
 
75
    }
 
76
    
 
77
    mpAnimDrop = new KBlocksAnimDrop(items, duration, direction);
 
78
    
 
79
    connect(mpAnimDrop, SIGNAL(animationFinished()), this, SLOT(endDropAnim()));
 
80
    
 
81
    return true;
 
82
}
 
83
 
 
84
bool KBlocksAnimator::deleteDropAnim()
 
85
{
 
86
    if (mpAnimDrop)
 
87
    {
 
88
        delete mpAnimDrop;
 
89
        mpAnimDrop = 0;
 
90
        return true;
 
91
    }
 
92
    return false;
 
93
}
 
94
 
 
95
KBlocksAnimDrop* KBlocksAnimator::getDropAnim()
 
96
{
 
97
    return mpAnimDrop;
 
98
}
 
99
 
 
100
void KBlocksAnimator::endFadeInAnim()
 
101
{
 
102
    emit animFinished(KBlocks_Animation_Fade_In);
 
103
}
 
104
 
 
105
void KBlocksAnimator::endFadeOutAnim()
 
106
{
 
107
    emit animFinished(KBlocks_Animation_Fade_Out);
 
108
}
 
109
 
 
110
void KBlocksAnimator::endDropAnim()
 
111
{
 
112
    emit animFinished(KBlocks_Animation_Drop);
 
113
}