summaryrefslogtreecommitdiff
path: root/views/animation.c
blob: d06a81076d5dde790bd23b681af90ca0f3af486f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include "animation.h"

using namespace std;

cAnimation::cAnimation(eAnimType animType, int animFreq, cRect &pos, int layer) : cPixmapContainer(1) {
    delay = 0;
    this->animType = animType;
    this->animFreq = animFreq;
    this->pos = pos;
    this->layer = layer;
    blinkOn = true;
}

cAnimation::~cAnimation() {
}

void cAnimation::Action(void) {
    CreatePixmap(0, layer+1, pos);
    bool init = true;
    DoSleep(delay);
    while (Running()) {
        if (animType == atBlink) {
            if (!blinkOn) {
                Fill(0, clrTransparent);
                blinkOn = true;
            } else {
                DrawBlink();
            }
        } else if (animType == atAnimated) {
            esyslog("skindesigner: animationType atAnimated not implemented");
        }
        if (init)
            FadeIn();
        init = false;
        DoFlush();
        DoSleep(animFreq);
    }
}

void cAnimation::Stop(void) {
    CancelSave();
}

/********************************************************************************************
* cAnimatedImage
********************************************************************************************/
cAnimatedImage::cAnimatedImage(eAnimType animType, int animFreq, cRect &pos, int layer) : cAnimation(animType, animFreq, pos, layer) {
    image = NULL;
}

cAnimatedImage::~cAnimatedImage() {
}

void cAnimatedImage::DrawBlink(void) {
    blinkOn = false;
    if (!image)
        return;

    cPoint posImage(0,0);
    if (Running())
        DrawImage(0, posImage, *image);
}

/********************************************************************************************
* cAnimatedText
********************************************************************************************/
cAnimatedText::cAnimatedText(eAnimType animType, int animFreq, cRect &pos, int layer) : cAnimation(animType, animFreq, pos, layer) {
    text = "";
    fontName = "";
    fontSize = 1;
    fontColor = clrTransparent;
}

cAnimatedText::~cAnimatedText() {
}

void cAnimatedText::DrawBlink(void) {
    blinkOn = false;
    if (text.size() == 0)
        return;

    cPoint posText(0,0);
    if (Running())
        DrawText(0, posText, text.c_str(), fontColor, clrTransparent, fontName, fontSize);
}

/********************************************************************************************
* cAnimatedOsdObject
********************************************************************************************/
cAnimatedOsdObject::cAnimatedOsdObject(eFuncType type, eAnimType animType, int animFreq, cRect &pos, int layer) : cAnimation(animType, animFreq, pos, layer) {
    this->type = type;
    color = 0x00000000;
    quadrant = 0;
}

cAnimatedOsdObject::~cAnimatedOsdObject() {
}

void cAnimatedOsdObject::DrawBlink(void) {
    blinkOn = false;
    cRect posObject(0, 0, pos.Width(), pos.Height());
    if (Running()) {
        if (type == ftDrawRectangle) {
            DrawRectangle(0, posObject, color);
        } else if (type == ftDrawEllipse) {
            DrawEllipse(0, posObject, color, quadrant);
        } else if (type == ftDrawSlope) {
            DrawSlope(0, posObject, color, quadrant);
        }
    }
}